How do I resolve runtime errors?

Problem Code: QUALPREL
I have submitted the following code, but after seeing the results, I get a runtime error saying that it has failed. How do I fix it?
#include

using namespace std;

int main()
{

int t,n,k,p1,p2;

//int a[1000];
int a1[10];
int arr=0;

cin>>t;

while(t--){
    cin>>n>>k;

    for(int i=0;i<n;i++)
    {
        cin>>arr;
        a1[i]=arr;

              }
     //for(int j=0;j<n;j++){
        //cin>>arr;
        //a1[j]=arr;
     //}


    //cin>>a1;

    //for(int i=0;i<n;i++){
        //a[i]=n;
    //}
    if(t==1)
    {

    //}
    if(a1[2]!=0)
    {
        p1=a1[2];
    }
}

    //for(int j=0;j<n;j++){
        //a[j]=n;
   // }
   if(t==0){

   //}
    if(a1[2]!=0)
    {
        p2=a1[2];
    }

   // cout<<p1<<endl;
   // cout<<p2<<endl;
}




}

cout<<p1<<endl;
cout<<p2<<endl;

return 0;

}