semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int n,i,sz[10000][30],a[10000],b[10000],l=0,k;

int main()
 
{

   scanf("%d",&n);

    for(i=0;i<n;i++)

      for(l=0;l<21;l++)  sz[i][l]=-1;

       

   l=0;

   for(i=0;i<n;i++)

   {

      scanf("%d",&b[i]);

      sz[i][0]=b[i];
 
      for(l=0;l<b[i];l++)  scanf("%d",&(sz[i][l+1]));

   }

   

   for(i=0;i<n;i++)

   {

      //printf("%d\n",i);

      l=1;
 
      if(sz[i][0]==0)

      {

       a[i]=60;

       continue;

      }

      while(sz[i][l]!=-1)

      {

       k=sz[i][l]+3*l;

       if(k<60&&(sz[i][l+1]==-1))
 
       {

        a[i]=60-3*l;

        break;

       }

       else if(k<60&&(sz[i][l+1]!=-1)) l++;

       else if((k>=60)&&(k<=63))

        {

        a[i]=sz[i][l];

        break;

       }

       else if(k>63)

       {

        a[i]=60-3*(l-1);

        break;

       }
 
      }

  }

for(i=0;i<n;i++)

 printf("%d\n",a[i]);

 return 0;

}
int main()
{
    int m, i;
    scanf("%d", &m);
    for(i=1; i<=m; i++)
    {
         int n, j, num[100], k;
         scanf("%d", &n);
         if(n==0) 
               printf("60\n");
         else
         { 
               for(j=1; j<=n; j++)
               {
                    scanf("%d", &num[j]);
               }
               for(j=1;j<=n;j++){
               if((num[j] + 3 * (j - 1))>= 60)
                         { k = 60-3*(j-1);
                          break;}
               else if((num[j]+3*j )>= 60)
                          {k = num[j];
                          break;}
                    else 
                          k = 60-3*j;
                          
              }
              printf("%d\n", k);
         }           
    }
    return 0;
}
int main()
{
	int n,p,i,j,temp[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&p);
        if(p==0) printf("60\n");
	      else
		  {
	         for(j=1;j<=p;j++)
			scanf("%d",&temp[j]);
	         for(j=p;j>0;j--)
			 {
		       if(temp[j]+3*j>63)
			   continue;
		       
		        else if(temp[j]+3*j<=60)
				{
				printf("%d\n",60-3*j);
		       break;
				}
				else
			   { printf("%d\n",temp[j]);
			   break;
				}
			 } 
		
		  }
		}
	return 0;
}
int main()
{
	int n;
	int rope[Number_children][Number];
	int i,j,sum,time,tmp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		for(j=0;j<Number;j++)
			rope[i][j]=0;
	}
	for(i=0;i<n;i++)
	{
		scanf("%d",&rope[i][0]);
		for(j=1;j<1+rope[i][0];j++)
			scanf("%d",&rope[i][j]);
	}
	for(i=0;i<n;i++)
	{
		for(j=1,sum=0,time=0,tmp=1;(time<=60)&&(j<=rope[i][0]);j++)
		{
			if((rope[i][1]==0)||(rope[i][1]>=60))
			{
				printf("%d\n",60);
				tmp=0;
				break;
			}
			sum=rope[i][j];
			time=rope[i][j]+3*j;
		}
		if(tmp==0)
			continue;
		else
		{
		if(time<60)
		{
			sum=sum+60-time;
			printf("%d\n",sum);
			continue;
		}
		if(time>63)
		{
		sum=60-(j-2)*3;
		printf("%d\n",sum);
		continue;
		}
		sum=60-(j-2)*3-(3-(time-60));
		printf("%d\n",sum);
		}
	}
	return 0;
}
int main(){
 int n,i,j,t,num;
 int br[100];
 int count[100][61]={0};
 scanf("%d",&n);
 for (i=0;i<n;i++){
  scanf("%d",&br[i]);
  for (j=0;j<br[i];j++){
   scanf("%d",&t);
   count[i][t]=1;
  }
 }
 for (i=0;i<n;i++){
  j=0;num=0;
  while (j<60){
   
   j+=1;
   num+=1;
   if (count[i][num]==1) {
    j+=3;
    if (j>=60) break;
   };
  }
  printf("%d\n",num);
 }
 return 0;
}
/**
 * ??? ???
 * ??? 1000012844
 * ??? ????
 **/


int timesPerMin( int *, int );

int main()
{
	int i, j, n;
	int failedTimes[ 100 ];
	int num[ 100 ][ 100 ] = { 0 };

	cin >> n;

	for ( i = 0; i < n; i++ )
	{
		cin >> failedTimes[ i ];
		for ( j = 0; j < failedTimes[ i ]; j++ )
		{
			cin >> num[ i ][ j ];
		}
	}

	for ( i = 0; i < n; i++ )
	{
			cout << timesPerMin( num[ i ], failedTimes[ i ] ) << endl;
	}

	return 0;
}

int timesPerMin( int num[], int failed )
{
	int i = 0;

	for ( i = 0; ;i++ )
	{
		if ( num[ i ] == 0 )
		{
			num[ i ] = 60;
			break;
		}
	}
	
	for ( i = 0; ;i++ )
	{
		if ( ( num[ i ] + i * 3 <= 60 ) &&
			( num[ i ] + i * 3 + 3 > 60 ) )
		{
			return num[ i ];
			break;
		}
		else
		{
			if ( num[ i ] + i * 3 + 3 <= 60 &&
				 i * 3 + 3 + num[ i + 1 ] > 60 )
			{
				return 60 - i * 3 - 3;
				break;
			}
		}
	}

}
int main()
{
	int i,j,k,l,m,n,c,d,e,f;
	int a,b,g[60];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		if(m==0) printf("60\n");
		else 
		{
			a=b=0;
		   // memset(g,0,sizeof(g));
			for(k=0;k<60;k++) g[k]=0;
			for(k=0;k<m;k++) scanf("%d",&g[k]);
            k=0;
			for(;b<60;)
			{
				a++;b++;
			    if(a==g[k]) {b+=3;k++;}
				
			}
			printf("%d\n",a);
		}
	}
	return 0;
}
int main()
{
	int n,i,j,m[100],count[100]={0},time1[100]={0},time2[100]={0};
	cin>>n; 
	for(i=1;i<=n;i++)
	{   
		cin>>m[i];
		if(m[i]==0)               //???????????????60?
		    count[i]=60;
		int per[20]={0};           //??????????
		for(j=1;j<=m[i];j++)           
		    cin>>per[j];
		for(j=1;j<=m[i];j++)
		{
			count[i]=per[j];           //????????
			time1[i]=count[i]+3*j;        //time1?????????????????
			time2[i]=time1[i]-3;            //time2??????????????
			/* ???????????????60??????*/
			if(time1[i]>=60&&time2[i]<60)         //????????????????
			{
				count[i]=per[j];              //??????????????????????
				break;
			}
			else if(time2[i]>=60)         //??????????????
			{
				count[i]=60-3*(j-1);      //???????????????????????????????????
				break;
			}
			/*?????????????????60??????*/
			count[i]=60-3*j;             
		}
	}
	for(i=1;i<=n;i++)
		cout<<count[i]<<endl;
	return 0;
}
int main()
{int a[100]={0};
int j,s,n,i,m;
cin>>n;/*????n???? 
????,?????????????m,??m??????????????*/
while(n>0)
{cin>>m;
s=0;
for(i=0;i<100;i++)
	a[i]=0;
if(m==0)
	s=0;
else
{for(i=0;i<m;i++)
	{cin>>j;
a[j+1+3*i]=1;
a[j+2+3*i]=1;
a[j+3+3*i]=1;
	}
for(i=1;i<=60;i++)
	s=s+a[i];
}
cout<<60-s<<endl;//?????????????????.
n--;}
return 0;
}
int main()
{
	int n;
	scanf("%d",&n);
	int i,m,j,p;
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		int time=0;
		for(j=1;j<=m;j++)
		{
			if(time<60)
			{
				scanf("%d",&p);
				time=p+3*j;
			}
			if(time>=60){break;}
		}
		if(time<=60)printf("%d\n",60-3*m);
		if(time>60)
		{
			if( p < ( 60-3*(j-2) ) )printf("%d\n",p);
			if( p >= ( 60-3*(j-2) ) )printf("%d\n",60-3*(j-1));
		}
	}

	return 0;
}
int main()
{
	int stu_num,stop_num,i,j;
	int stop[100][100]={0},sum[100]={0},time[100][100]={0};  
	scanf("%d",&stu_num);
	for(i=1;i<=stu_num;i++)
	{
		scanf("%d",&stop_num);
		if(stop_num==0)
		{
			sum[i]=60;
		}
		else
		{
			for(j=1;j<=stop_num;j++)
			{
				scanf("%d",&stop[i][j]);
			}
			for(j=stop_num;j>=1;j--)
			{
				time[i][j]=stop[i][j]+(j-1)*3;
				if(time[i][j]>60)
				{
					continue;
				}
				else if(time[i][j]<=57)
				{
					sum[i]=60-3*j;
				}
				else
				{
					sum[i]=time[i][j]-3*(j-1);
				}
				break;
			}
		}
	}
	for(i=1;i<=stu_num;i++)
	{
		printf("%d\n",sum[i]);
	}
	return 0;
}
main()
{
      int i,j,k,n;
      scanf("%d",&n);
      int **pp;
      pp=(int **)malloc(n*sizeof(int *));
      for(i=0;i<n;i++)
      pp[i]=(int *)malloc(20*sizeof(int));
      for(i=0;i<n;i++)
      {
          scanf("%d",&pp[i][0]);
          if(pp[i][0]!=0)
          for(j=1;j<=pp[i][0];j++)
              scanf("%d",&pp[i][j]);
      }
      for(i=0;i<n;i++)
      {
        if(pp[i][0]!=0)
         for(j=pp[i][0];;)
         {if(pp[i][j]+3*j<=60)
          {
               printf("%d\n",60-j*3);
               break;
          }
          else if(pp[i][j]+3*j-3<60)
          {
               printf("%d\n",pp[i][j]);
               break;
          }
          else j--;
         }
        else printf("60\n");
          
      }
}
int main() 
{ 
int n,m,c;

scanf("%d",&n);
for(int x=1;x<=n;x++)
{
scanf("%d",&m);
int*shuzu=(int*)malloc(sizeof(int)*m);
c=0;
for(int i=0;i<m;i++)
{
scanf("%d",&shuzu[i]);
if(c+shuzu[i]<60)
if(c+shuzu[i]+3<60)
c+=3;
else
c=60-shuzu[i];
}
free(shuzu);
printf("%d\n",60-c);
}
return 0; 
}
int main(){

	int n=0;
	cin>>n;
	int result[300];

	for(int i=0;i<n;i++){

		int s[30];
		int k=0;
		int times=0;
		int sum=60;

		do{
			cin>>s[k];
			k+=1;
		}
		while(cin.get()!='\n');
		
		for(int j=1;j<=s[0];j++){
			int sup=60-3*times-s[j];
			if(sup>0){
				times+=1;
				if(sup<3){
					sum-=sup;
				}
				else{
					sum-=3;
				}
			}
			else{
			break;
			}
		}

		result[i]=sum;

	}

	for(int i=0;i<n;i++){
		cout<<result[i];
		if(i<n-1){
		cout<<endl;
		}
	}

	return 0;
	
}
/*
 * qmfx05.cpp
 *
 *  Created on: 2011-1-1
 *      Author: Administrator
 */
int main()
{
	int n;
	cin>>n;
	const int n1=n;
	int a[n1][21];
	int i,j;
	for(i=0;i<n1;i++)
	{
		cin>>a[i][0];
		if(a[i][0]==0)
		{
			cout<<"60"<<endl;
			continue;
		}
		else
		{
			for(j=1;j<=a[i][0];j++)
			{
				cin>>a[i][j];
			}
			for(j=1;j<=a[i][0];j++)
			{
				if(j==a[i][0])
				{
					if((a[i][j]+3*j)<60)
					{
						cout<<60-3*j<<endl;
					}
				}
				if((a[i][j]+3*j)==60)
				{
					cout<<60-3*j<<endl;
					break;
				}
				if((a[i][j]+3*j)>60&&(a[i][j]+3*j<=63))
				{
					cout<<a[i][j]<<endl;
					break;
				}
				if((a[i][j]+3*j)>63)
				{
					cout<<63-3*j<<endl;
					break;
				}
			}
		}
	}
	return 0;
}
int main()
{
	int n,i,k,m[100],c[100],s[100];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&m[i]);
		if(m[i]==0)
		{
			s[i]=60;
		}
		else
		{
		    for(k=1;k<=m[i];k++)
			{
		    	scanf("%d",&c[k]);
			}
			for(k=1;k<=m[i];k++)
			{
				if((c[k]+(k-1)*3>=57)&&(c[k]+(k-1)*3<=60))
				{
					s[i]=c[k];
					k=k+m[i];
				}
				else
				{
				    if(c[k]+(k-1)*3>60)
					{
						s[i]=c[k]-(c[k]+(k-1)*3-60);
						k=k+m[i];
					}
					else
					{
						if(k==m[i])
						{
						s[i]=60-3*k;
						}
					}
				}
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		printf("%d\n",s[i]);
	}
	return 0;
}
int main() 
{ 
int n,m,k,c;

scanf("%d",&n);
while(n--)
{
scanf("%d",&m);
int*shuzu=(int*)malloc(sizeof(int)*m);
c=0;
for(int i=0;i<m;i++)
{
scanf("%d",&k);
if(c+k<60)
if(c+k+3<60)
c+=3;
else
c=60-k;
}
printf("%d\n",60-c);

}
return 0; 
}
int main()
{
	int i,j,n,f,brk[100],num[100],t[100],bkt[10];

	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%d",&brk[i]);
		if(brk[i]==0)
		{
			num[i]=60;
			continue;
		}
		num[i]=0;
		t[i]=0;
		f=0;
		for(j=0;j<brk[i];j++)
		{
			scanf("%d",&bkt[j]);
			if(f==0)
			{
				t[i]+=3+bkt[j];
				num[i]+=bkt[j];
				if(j!=0)
				{
					t[i]-=bkt[j-1];
					num[i]-=bkt[j-1];
				}
				if(t[i]>=63)
				{
					num[i]-=t[i]-63;
					f=1;
				}
				else if(t[i]>=60)
					f=1;
			}
		}
		if(t[i]<60)
		{
			num[i]+=60-t[i];
		}
	}
	for(i=0;i<n;i++)
	{
		printf("%d\n",num[i]);
	}

	return 0;
}
int main()
{
	int i,j,n,m,k[10],c;
	int l[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		c=60;
		for(j=0;j<m;j++)
		{
			scanf("%d",&k[j]);
			if(k[j]<=c)
				c=(k[j]+3>c)?k[j]:(c-3);
		}
		printf("%d\n",c);
	}
	return 0;
}
int main(){
	int n,m,num[N],i,j,k,count;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&m);
		if(m!=0)
		{
			for(k=0;k<m;k++)
			{
				scanf("%d",&num[k]);
			}
			if(num[m-1]+m*3<60){
				count=60-m*3;
			}
			else
			{
				for(j=0;j<m;j++)
				{
					if(num[j]+j*3<=60&&num[j]+(j+1)*3>=60)
					{
						count=num[j];
						break;
					}
					else if(num[j]+j*3>60)
					{
						count=60-j*3;
						break;
					}
				}
			}
		}
		else count=60;
		printf("%d\n",count);
	}
	return 0;
}
int main()
{
	struct tiao
	{
		int *ln;
		int k;
		int sumt;
	}*tiao1;
	int n;
	scanf("%d",&n);
	tiao1 = ( struct tiao *) malloc ( sizeof ( struct tiao ) * n );
	int i;
	int j;
	int f = 0;
	for ( i = 0 ; i < n ; i++ )
	{
		f = 0;
		scanf("%d",&tiao1[i].k);
		tiao1[i].ln = ( int * ) malloc ( sizeof ( int ) * tiao1[i].k );
		tiao1[i].sumt = 0;
		for ( j = 0 ; j < tiao1[i].k ; j++ )
		{
			scanf("%d",&tiao1[i].ln[j]);
		}
		if ( tiao1[i].k == 0 )
		{
			printf("60\n");
			continue;
		}
		for ( j = 0 ; j < tiao1[i].k ; j++ )
		{
			tiao1[i].sumt = ( tiao1[i].ln[j]+3*(j) );
			if ( tiao1[i].sumt >= 60 )
			{
				int tmp1;
				tmp1 =	tiao1[i].ln[j-1]+3*(j) ;
				if ( tmp1 >= 60 )
				{
					printf("%d\n",tiao1[i].ln[j-1]);
				}
				if ( tmp1 < 60 && 60 - tmp1 > 3 )
				{
					tmp1 = 60 - tmp1 + tiao1[i].ln[j-1];
					printf("%d\n",tmp1);
				}
				break;
			}
		}
		if ( tiao1[i].sumt < 57 )
		{
			tiao1[i].sumt += 3;
			j--;
			printf("%d\n",(60-tiao1[i].sumt+tiao1[i].ln[j]));
		}
		if ( tiao1[i].sumt < 60 && tiao1[i].sumt > 57 )
		{
			printf("%d\n",tiao1[i].ln[j-1]);
		}
	}
	return 0;
}
int main()
{
	int num;
	cin>>num;
	while(num--){
		int n;
		cin>>n;
		if(n==0) cout<<"60"<<endl;
		else{
			int a[20],i,sum=60,time=60;
			for(i=0;i<n;i++)
				cin>>a[i];
			for(i=0;i<n;i++){
				if(time-a[i]<=3){
					time=time-a[i];
					if(time>0) sum-=time;
					break;
				}
				else{
					time-=3;
					sum-=3;
				}
			}
			cout<<sum<<endl;
		}
	}
	return 0;
}
int main()
{
    int i,j,n,m,a,num,total=0;
    scanf("%d",&n);
    char chi[1000];
    for(i=0;i<n;i++)
    {
		scanf("%d",&m);
        for(j=1;j<=m;j++)
        {
			scanf("%d",&a);
            total=a+3*j;
            if(total>60)
            break;
        }
        gets(chi);
        if(total<=62 && total>=60)
		{
			num=total-3*j;
            printf("%d\n",num);
        }
        else if(total<60)
		{
			num=60-3*m;
            printf("%d\n",num);
        }
        else
        {
			num=60-3*(j-1);
            printf("%d\n",num);
        }
    }
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{int x;
	scanf("%d",&x);
	int s[20];
	for(int k=0;k<x;k++)
	{scanf("%d",&s[k]);}
	int t;
int m=x;
if(s[m-1]+m*3<=60)
t=60-3*m;
else 
{while(s[m-1]+m*3-3>60){
	m=m-1;}
if(s[m-1]+m*3-3>=57)
t=s[m-1];
else 
t=60-3*m;}
printf("%d\n",t);
	
	}return 0;
}
int main()
{
	int n,i,m,a[20],j,s,k,t;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>m;
		if(m==0)
		{
			s=60;
		}
		else
		{
		    for(j=0;j<m;j++)
		    {
			    cin>>a[j];
		    }
			for(k=m-1;;k--)
			{
				if(a[k]+3*(k+1)<=63)
				{
					break;
				}
			}
			t=a[k]+3*k;
			if(t<57)
			{
				s=a[k]+(57-t);
			}
			else
			{
				s=a[k];
			}
		}
		cout<<s<<endl;
	}
	return 0;
}
int main(){
	int n,m,i,j,flag=0,a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&m);
		int*shzu=(int*)malloc(sizeof(int)*m);
		for(j=0;j<m;j++){
			scanf("%d",&shzu[j]);
		}
		if(m==0){
			printf("%d\n",60);
		}
		else{
            for(j=m-1;j>=0;j--){
				flag=0;
			    if((shzu[j]+3*j<=60)&&((60-3*j-shzu[j])<=3)){
				    a=shzu[j];
				    flag=1;
				}
			    if((60-3*j-shzu[j])>3){
				    a=60-3*(j+1);
				    flag=1;
				}
		    	if(flag==1){
				    printf("%d\n",a);
				    break;
				}
			}
		}
		free(shzu);
	}
	return 0;
}
int main()
{
int n,i,m,k,a,s;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&m);
for(k=1;k<=m;k++){
scanf("%d",&a);
if((a+k*3)<=60){
s=a+(60-a-3*k);}
if((a+k*3)>60 && (a+k*3)<=63){
s=a;}
}
if(m==0)
s=60;
printf("%d\n",s);}
return 0;
}
int main()
{
  int a,a0,t,i,j,n,m;

  cin>>n;
  for(i=0;i<n;i++)
  { cin>>m;t=0;a=0;
    for(j=0;j<m;j++)
    { cin>>a;
      t+=3;//time not jumping
      a+=t;//the time that has passed so far
      if(a>60) break;
    }
	j++;
	while(j<m){cin>>a0;j++;}
    t=60-t;
    if(a>60)//it's already over when stop counting
      switch(a)
      { case 61:t++;break;
        case 62:t+=2;break;
        default:t+=3;//count one more pausing round
      }
    cout<<t<<endl;
  }
  return 0;
}
int main(){
	int n,i,m,j,s[100],t,total,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
scanf("%d",&m);
t=0;
k=0;
total=60;
if(m!=0){
for(j=0;j<m;j++){
	scanf("%d",&(s[j]));
}
for(j=0;j<m;j++){
	t=s[j]+k;
	if(t>60)
		break;
	if(t>57){
		total-=(60-t);
		break;
	}
	if(t<58){
total-=3;
k+=3;
	}

}
}
printf("%d\n",total);
	}
return 0;
}
/*
2011 01 08 ??

??
????????,?????????????.????????,???????,?????????????.
????????????????.??????????????????,??????????????.(?????????.)
????
????n???? 
????,?????????????m,??m??????????????.
????
?????????????????.

?? 1000012760
*/


int TimeUsed= 0, Jumps= 0, Time= 0;

void Jump(){
	TimeUsed++;
	Jumps++;
}
void Fail(){
	TimeUsed+= 3;
}

int main(){
	int kids, Failure, i, j, k;
	int FailTime[2][60];
	cin>>kids;
	for(i= 0; i< kids; i++){
		Jumps= 0;
		TimeUsed= 0;
		cin>>Failure;
		for(j= 0; j< Failure; j++){
			cin>>FailTime[0][j];
			FailTime[1][j]= 0;
		}
		while(1){
			Jump();
			for(k= 0; k< Failure; k++){
				if((Jumps== FailTime[0][k]) && (FailTime[1][k]== 0)){
					FailTime[0][k]= 1;
					Fail();
					break;
				}
			}
			if(TimeUsed>= 60)
				break;
		}
		cout<<Jumps<<endl;
	}
	return 0;
}
int main()
{
 	int n,m,i,k,sum,sum1,cs;
 	int js[20];
 	scanf("%d",&n);
 	for(i=0;i<n;i++){
			scanf("%d",&m);
			if(m==0) printf("60\n");
			else{
				for(k=0;k<m;k++) scanf("%d",&js[k]);					
				sum=0;
				for(k=0;k<m;k++){
					sum1=sum;
					sum=js[k]+3*(k+1);
					if(sum>60) break;
					}
				if(sum<60){
					cs=js[m-1]+60-sum;
					}
				else if(sum>=60&&sum<=63){
					cs=js[k];
					}
				else if(sum>63){
					cs=js[k-1]+60-sum1;
					}
				printf("%d\n",cs);
				}
			}
 	scanf("%d",&n);
    return 0;
}
int a[1000][1000];
int main(){
	int m[100],n,j,i,f,q;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&m[i]);
		for(j=0;j<m[i];j++){
			scanf("%d",&a[i][j]);
			}
	}
	for(i=0;i<n;i++){
		if(m[i]==0){
			f=1;
		}
		for(j=0;j<m[i];j++){
			if(a[i][j]+3*m[i]>60){
				f=0;
				q=j;
				break;
			}else{
			f=1;
			}
		}
		if(f==0){
			if(a[i][q]>(60-3*q)){
				printf("%d\n",(60-3*q));
			}else{
			printf("%d\n",a[i][q]);
			}
		}
		if(f==1){
			printf("%d\n",(60-3*m[i]));	
		}
		}
	
 return 0;   
}
int main()
{
    int n,i,j,m,a,p,q,k,sum=0,b=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
         scanf("%d",&m);
         if(m==0)
         {printf("60\n",a);
         }
         else if(m>0)
         {
         for(j=1;j<=m;j++)
         {
                          scanf("%d",&a);
                          q=a+3*j;
                          if(q<63)
                          {sum=q;
                         k=a;
                          b=j;}
                          }
                          if(sum>=60&&sum<=62)
                         { printf("%d\n",k);
                                
                                            }
                         else if(sum<60&&q>62)
                         {
                         p=60-3*b;
                         printf("%d\n",p);
                         
                          
                       }
                        
                        
                          
                            
                        if(q<60)
                          {   
                              sum=60-3*m;
                               printf("%d\n",sum);
                          }
              
              }
              }
       scanf("%D",&a);
       
             }
int main(int argc, char* argv[])
{
  int i,n,nn,k,t,j,c;  
  scanf("%d",&n);
  for (i=0;i<n;i++){
      scanf("%d",&nn);
	  if(nn==0){
		  printf("60\n");
	  }
	  else{
		  c=0;
		  t=0;

        for (j=1;j<=nn;j++){
           scanf("%d",&k);
		   if (k<60){
			   c=k;
			   t=k+j*3;
		   }
		}
		if (t>=63)
			c=c-(t-63);
		else if (t<60)
			c=c+(60-t);
		printf("%d\n",c);
	  }
  }
	return 0;
}
int main(){
	int n,i,k,j;
	int result;
	int zcs;
	int m,cs[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		result=0;
		scanf("%d",&m);
		if(m==0){
			zcs=60;
		}
		for(k=0;k<m;k++){
			scanf("%d",&cs[k]);
			for(j=m-1;j>=0;j--){
			result=cs[j]+(j+1)*3;
				if(result<=60){
				zcs=60-3*(j+1);
				break;
			}else if(result>60&&(result-3)<60){
					zcs=cs[j];
					break;
			}
			}
		}

				
		printf("%d\n",zcs);
	}
	return 0;
}
int main()
{
   int a[100],bre[100];
   int i,j,k,l,n,m;
   scanf("%d",&n);
   while(n--)
   {
	   for(i=1;i<=60;i++)
	   {a[i]=1;}
	   scanf("%d",&m);
	   if(m==0) 
	   {
		   printf("60\n");
		   continue;
	   }
	   else
	   {
		   for(i=1;i<=m;i++)
			   scanf("%d",&bre[i]);
		   for(i=1;i<=m;i++)
			   bre[i]=bre[i]+3*(i-1);
		   for(i=1;i<=m;i++)
		   {
			   a[bre[i]+1]=0;
			   a[bre[i]+2]=0;
			   a[bre[i]+3]=0;
		   }
		   l=0;
		  for(i=1;i<=60;i++)
            l=l+a[i];
		  printf("%d\n",l);
	   }
   }
   return 0;
}
// ?? ?? 1000062708
int main()
{
	int a, n, m, i, t, j, sum, flag;
	cin >> n;
	for(i = 0;i < n;i++)
	{
		flag = 0;
		cin >> m;
		for(j = 1;j <= m;j++)
		{
			cin >> a;
			if(flag == 0)
			{
				
				t =  a + 3 * j;
				if(t >= 63)
				{
					sum = 63 - 3 * j;
					flag = 1;
				}
				else if(t >= 60 && t < 63)
				{
					sum = a;
					flag = 1;
				}
				else 
				
					sum = 60 - 3 * j;
					
				
			}
		}
		if(m == 0) 
			sum = 60;
		cout << sum << endl;
	}
	return 0;
}
void main()
{
	int counts;int sum;
	int a[100];
	int n;int i,c;int m;
	scanf("%d",&n);
	while(n--)
	{
		c=0;
		sum=0;
		scanf("%d",&m);
		for(i=0;i<m;i++)
		{
			scanf("%d",&a[i]);
		}
		for(i=0;i<m;i++)
		{
			c=3*m;
			if(a[i]+i*3>60)
			{
				c=i*3;
				break;
			}
			else if(a[i]+(i+1)*3>60)
			{
				c=60-a[i];
				break;
			}
		}
		printf("%d\n",60-c);
	}
}
int main(){
	int n,cs[num][num],t,sum[num],k,j;
	scanf("%d",&n);
	for(j=0;j<n;j++){
		scanf("%d",&t);
		cs[j][0]=t;
		if(t>0){
	  for(k=1;k<=t;k++){
		  scanf("%d",&cs[j][k]);
	  }
		}
	}
	  for(j=0;j<n;j++){
		  if(cs[j][0]==0){
			  sum[j]=60;
		  }
		  else{
                             for(k=1;k<=cs[j][0];k++){
                                   if(cs[j][k]+3*k<=60){
				  sum[j]=60-3*k;
			  }
			  else if(cs[j][k]+3*k>60&&60-3*(k-1)-cs[j][k]<3&&60-3*(k-1)-cs[j][k]>0){
			      sum[j]=cs[j][k];
			  }
			  else if(cs[j][1]>60){
				 sum[j]=60;
			  }
		  }
		 }
	 }
	  for(j=0;j<n;j++){
		  printf("%d\n",sum[j]);
	  }
return 0;
}
int main()
{
	int n,a[100][60],i,m[100],j,s,t;//??????s,t,n,????a[100][60],??????i,j
	cin>>n;//????n
	for(i=0;i<n;i++)//?????????????????
	{
		cin>>m[i];
		if(m[i]!=0)
		{
			for(j=0;j<m[i];j++)
		 {
			cin>>a[i][j];
		 }
		}
	}
	for(i=0;i<n;i++)//???????
	{
		if(m[i]==0)//????????????
			{
				cout<<60<<endl;//????
		}
		if(m[i]>0)//????????????
		{
			j=m[i]-1;
			s=a[i][j]+m[i]*3;
			if(s>60)
			{  s=0,j=0;
			while(s<=60)
			{
				s=3*(j+1)+a[i][j];
				j++;
			}
			if(s-3>60)
				t=60-(j-1)*3;
			else
				t=60-(j-1)*3-(3-(s-60));
			}
			else
			{
				t=60-m[i]*3;
		
			}
			cout<<t<<endl;//????
		}
	}
				
	return 0;
}
main()
{
      int n, total[100] = {0}, broke, time, i, j, broke_time[61] = {0}, timer;
      
      scanf("%d", &n);
      for(i = 0; i <= n - 1; i++)
      {
            scanf("%d", &broke);
            
            for(j = 1;j <= broke;j ++)
            {
                  scanf("%d", &timer);
                  broke_time[timer] = 1;
            }
            
            for(time = 1;time <= 60; time ++)
            {
                     total[i] ++;
                     if(broke_time[total[i]] == 1)
                     {
                                         //printf("(%d)", time);
                                         time += 3;
                                         
                                         //printf("|%d|[%d]\n", total[i], time);
                     }
                     if (time > 60) break;
                     
            }


            for(j = 0;j <=60;j++)
            {
                  broke_time[j] = 0;
                  }

            
      }
      
      for(i = 0;i <= n-1; i ++)
      {
            printf("%d\n", total[i]);
            }
}
int main()
{
	int i,j,n,m,a[100],sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		if(m==0)
		{
			sum=60;
			printf("%d\n",sum);
			continue;
		}
		else
		{
			for(j=0;j<m;j++)
			{
				scanf("%d",&a[j]);
			}
			if(a[m-1]+m*3<=60)
			 		sum=a[m-1]+(60-a[m-1]-3*m);
			else if(60-(a[m-1]+(m-1)*3)<3 && 60-(a[m-1]+(m-1)*3)>=0)
				sum=a[m-1];
			else if(a[m-2]+(m-1)*3<=60)
				    sum=a[m-2]+(60-a[m-2]-3*(m-1));
		    else if(60-(a[m-2]+(m-2)*3)<3 && 60-(a[m-2]+(m-2)*3)>=0)
					sum=a[m-2];
			
			
		}
		printf("%d\n",sum);
	}

	return 0;
}
int main()
{
    int j,e,i,d,a[60];
	int m,n,k=1;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&m);
		for (j=0;j<m;j++)
			scanf("%d",&a[j]);
		for (j=0;j<m;j++)
		{
			
			if ((60-a[j]-j*3)*(59-a[j]-j*3)*(58-a[j]-j*3)==0)
			{
				printf("%d\n",a[j]);
				break;
			}
			if ((58-a[j]-j*3)<0)
			{
				printf("%d\n",(60-3*j));
				break;
			}
		}
		
		if ((58-a[j]-j*3)>0)
			printf("%d\n",(60-3*m));
	}
	

	return 0;
}