semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
main()
{
int i,j,k,n,m,s,ans;
int a,b,c,d;
int h[30];
scanf("%d\n",&n);
for(i=1;i<=n;i++)
{
                 s=0;
                 scanf("%d",&m);
                 for(j=0;j<m;j++)
                 scanf("%d",&h[j]);
                 for(j=0;j<m;j++)
                 {s=0;
                 k=h[j];
                 if((k+3*j)>=57)
                 {if((k+3*j-57)<3)
                 {s=3-(k+3*j-57);
                 break;}
                 else
                 break;
                }
                }
                ans=60-3*j-s;
                printf("%d\n",ans);                 
                 }

}
int main()
{
	int n,m,a[60],b[100];
	int i,j,time=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		if(m==0)
		{
			b[i]=60;
			continue;
		}
		for(j=0;j<m;j++)
			scanf("%d",&a[j]);
		for(j=0;j<m;j++)
		{
		     time=a[j]+3*(j+1);
			 if(time<60&&j==m-1)
			 {
			     b[i]=60-3*m;
				 break;
			 }
			 if(time>=60&&time<63)
			 {   
				 b[i]=a[j];
				 break;
			 }
			 if(time>=63)
			 {
				 b[i]=60-3*j;
				 break;
			 }
		}
	}
	for(i=0;i<n;i++)
		printf("%d\n",b[i]);
	return 0;
}
int main(int argc, char* argv[])
{
	int i,j,n,m,a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&m);
		a=0;
		if(m==0){
			printf("60\n");
			continue;
		}
		for(j=0;j<m;j++){
			scanf("%d",&a);
			if(a+j*3<57)
				continue;

			if(a+j*3<=63){
				printf("%d\n",a);
				break;
			}else{
				printf("%d\n",60-3*j);
				break;
			}
		}
		if(j == m)
			printf("%d\n",60-3*m);
	}
	return 0;
}
int main()
{
	int n,m,i,j,k,time,sum;
	cin>>n;
	int x[n+1];
	for(i=1;i<=n;i++)
	{
		time=0,sum=0;
		cin>>m;
		int a[m+1];
		for(j=1;j<m+1;j++)
		{
			cin>>a[j];
		}
			for(j=1;j<m+1;j++)
		{
			time=a[j]+3*j;
			if(time<=63)
			{
				sum=a[j];
			}
			if(time>=60&&time<63)
			{break;
			}
			else if(time>63)
			{
				time=a[j-1]+3*(j-1);
				sum=a[j-1]+60-time;
				time=a[j]+3*j;
			    break;
			}
		}
	
		if(time<60)
		{
			sum=sum+60-time;
		}
		x[i]=sum; 
	}
	for(i=1;i<=n;i++)
	{
		cout<<x[i]<<endl;
	}
	return 0;
}
int main()
{
	int n,k,a[60],i;
	cin>>n;
	while(n>0)
	{
		cin>>k;
		for(i=1;i<=k;i++)
			cin>>a[i];
		if(k==0)cout<<60<<endl;
		else if(a[k]+k*3<=60)cout<<60-3*k<<endl;
		else for(i=1;i<=k;i++)
				if((a[i]+i*3<=60)&&(a[i+1]+i*3>60)){cout<<60-i*3<<endl;break;}
				else if((a[i]+(i-1)*3<=60)&&(a[i]+i*3>60)){cout<<a[i]<<endl;break;}
		n--;

	}
	return 0;
}
int main()

{
    int count;
    int sum = 0;
    int num;
    int n;
    int i;
    int j, k, l;
    int a[1000];
    cin >> count;
    for(l = 1; l <= count; l++)
    {
          sum = 0;
          cin >> n;
          if (n == 0)
          {
              cout << "60" <<endl;
              continue;
          }
          for (i = 0; i <= 999; i++)
          {
              a[i] = 1;
          }
          for (i = 0;i < n; i++)
          {
              cin >> num;
              a[num + 1 + 3 * i] = 0;
              a[num + 2 + 3 * i] = 0;
              a[num + 3 + 3 * i] = 0;
          }
          for (i = 1; i <= 60; i++)
          {
              sum = sum + a[i];
          }
          cout << sum <<endl;
    }
    return 0;
}
int main()
{
	int n,a[100][60],i,t;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		int sum=0;
		cin>>a[i][1];
		if(a[i][1]==0) cout<<60<<endl;
		else
		{
		for(t=1;t<=a[i][1];t++)
		{
			cin>>a[i][t+1];
		}
        for(t=1;t<=a[i][1];t++)
		{
			if(a[i][t+1]+(t-1)*3<=60&&a[i][t+1]+t*3>=60) sum=a[i][t+1];
			else if(a[i][t+1]+t*3<=60) sum=60-t*3;
		}
		cout<<sum<<endl;
				
		}
	}

		return 0;
}
int main()
{
    int n,a[20],t,i;
    cin >> n;
	while ( n -- )
	{
		cin>>a[0];
		for ( i = 1 ; i <= a[0] ; i ++ )
		cin>>a[i];
		t = 1;
		 while ( ( a[0] + 1 - t ) * 3 + a[a[0] - t + 1] > 63 )
             t++;
          if ( ( a[0] + 1 - t ) * 3 + a[a[0] - t + 1] >= 60 ) 
                cout<<a[a[0]-t + 1]<<endl;
          else  
			  cout<<(60 - (a[0]-t+1) * 3)<<endl;
	}
	return 0;
}
//????
//2010?11?19?
//1000012753 ???
int main()
{
	int n, m, i, sum, stop, a[200] = {0};
	cin >> n;
	while (n--)
	{
		cin >> m;
		for (i = 0; i < m; i++)
			cin >> a[i];
		while (1)
		{
			if (m == 0)
			{
				sum = 60;
				break;
			}
			if (a[m - 1] + (m - 1) * 3 > 60)
				m--;
			else if (a[m - 1] + (m - 1) * 3 >= 57 && a[m - 1] + (m - 1) * 3 <= 60)
			{
				sum = a[m - 1];
				break;
			}
			else
			{
				sum = 60 - m * 3;
				break;
			}
		}
		
		cout << sum << endl;
	}
	return 0;
}
int main(){
	int n;
	cin>>n;
	while(n!=0){
		n--;
		int x,i;
		cin>>x;
		if(x==0){
			cout<<60<<endl;
			continue;
		}
		int s[x];
		for(i=0;i<x;i++)
			cin>>s[i];
		if(s[x-1]+3*x<=60){
			cout<<60-3*x<<endl;
			continue;
		}
		else if(s[x-1]+3*x>60&&s[x-1]+3*x-3<=60){
			cout<<s[x-1]<<endl;
			continue;
		}
		else
		for(i=0;i<x;i++){
			if(s[i]+3*i+3>60){
				if(s[i]+3*i<=60){
					cout<<s[i]<<endl;
					break;
				}
				else{
					cout<<60-3*i<<endl;
					break;
				}
			}
		}
	}
	return 0;
}
void main()
{
 int n,i,j,breaks[100],times[100][10],sum[100];
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  scanf("%d",&breaks[i]);
  for(j=0;j<breaks[i];j++)
   scanf("%d",&times[i][j]);
 }
 for(i=0;i<n;i++)
 {
  if(breaks[i]==0) 
  {
   sum[i]=60;goto end;
  }
  if((times[i][breaks[i]-1]+breaks[i]*3)<=60)
  {
   sum[i]=60-breaks[i]*3;
   goto end;
  }
  for(j=0;j<breaks[i];j++)
  {
   if((times[i][j]+3*j)>=57&&(times[i][j]+j*3)<=60)
   {
    sum[i]=times[i][j];
    goto end;
   }
  }
  for(j=0;j<breaks[i]-1;j++)
  {
   if((times[i][j]+j*3)<=60&&(times[i][j+1]+j*3+3)>=60)
   {
    sum[i]=60-3*j-3;
    goto end;
   }
  }
  end:;
 }
 for(i=0;i<n;i++)
	 printf("%d\n",sum[i]);
}
int abc(int p,int *x){
	if(*x==0){ printf("60\n");return 0;}
	if(*x==1){
		if(p>57) printf("%d\n",p);
		else printf("57\n");
		return 0;
	}
	else if(p+3*(*x-1)>60){
		*x=*x-1;
		return 1;
	}
	else if(p+3*(*x-1)<=60){
		if(p>60-3*(*x)) printf("%d\n",p);
		else printf("%d\n",60-3*(*x));
		return 0;
	}
}

int main(int argc, char* argv[])
{
	int i,k,n,d;
	scanf("%d",&k);
	for(i=0;i<k;i++){
		int *p,j;
		scanf("%d",&n);
		p=(int *)malloc(sizeof(int)*n);
		for(j=0;j<n;j++){
			scanf("%d",p+j);
		}
		d=abc(*(p+n-1),&n);
		while(d==1){
			d=abc(*(p+n-1),&n);
		}
	}
	return 0;
}
int main()
{
	int n,bad[10],badnum[10],i,j,k,time,goodnum[10];
	cin >>n;
	for (j=0;j<n;j++)
	{
		cin >>bad[j];
		if (bad[j]==0)
			goodnum[j]=60;
		for (i=0;i<bad[j];i++)
		{
			cin >>badnum[i];
		}
		for (i=0;i<bad[j];i++)
		{
			time=badnum[i]+3*(i+1);
			if (time>=60 && badnum[i]+3*i<60)
			{
				goodnum[j]=badnum[i];
				break;
			
			}
			if (badnum[i]+3*i>=60)
			{
				goodnum[j]=60-3*i;
				break;
			}
			else if (i==bad[j]-1)
				goodnum[j]=60-3*(i+1);

		}
		
	}

	for (j=0;j<n;j++)
	{	
		cout <<goodnum[j]<<endl;
	}
	return 0;
}
int min(int a, int b)
{
	if (a<b) return a;
	else return b;
}

int main()
{
	int n,m,s,t;
	cin>>n;
	for (int i=1; i<=n; ++i)
	{
		cin>>m;
		s=60;
		for (int j=1; j<=m; ++j)
		{
			cin>>t;
			t+=j+j+j-3;
			if (t<=60) s-=min(3,60-t);
		}
		cout<<s<<endl;
	} 
	return 0;
}
int main(){
    int n,i,m,j;
    cin>>n;
    int s[n],b[n];
    for(i=1;i<=n;i++){
       cin>>m;
       int a[m];
       for(j=0,s[i]=60,b[i]=0;j<m;j++){
                        cin>>a[j];
       b[i]=a[j]+3*j+3;
       if(b[i]<=60){s[i]-=3;}
       else if(b[i]>=63){s[i]=s[i];}
       else{s[i]=a[j];}}
       printf("%d\n",s[i]);
       }
       return 0;
       }
int main()
{
	int population,m;
	int num[10];
	int i,j;
	int time=0,duandian=1,sum=0;
	scanf("%d",&population);

	for(i=0;i<population;i++)
	{
		scanf("%d",&m);
		if(m==0)
		{
			printf("60\n");
			continue;
		}
		for(j=0;j<m;j++)
		{
			scanf("%d",&num[j]);
		}
		time=num[m-1]+3*m;
		if(time<=60)
		{
			sum=60-3*m;
		}
		else
		{
			time=num[0]+3;
			for(j=1;j<m;j++)
			{
				time=time-num[j-1]+num[j];
				if(time>60)
				{
					sum=60-3*duandian;
					break;
				}
				time+=3;
				if(time>=60)
				{
					sum=time-3-3*duandian;
					break;
				}
				duandian++;
			}
		}
		printf("%d\n",sum);
		sum=0;
		time=0;
		duandian=1;
	}
	return 0;
}
/*
 * tiaosheng.cpp
 *
 *  Created on: 2011-12-23
 *      Author: 11161
 */

int main()
{
	int n;
	cin>>n;
	for(int j=1;j<=n;j++)
	{
		int m;
		cin>>m;
		if(m==0){cout<<60<<endl;continue;}
		int times,sum1=0,sum2=0,w=0;int i=1;
		for(;i<=m;i++)
		{
			cin>>times;
			sum1=3*(i-1)+times;sum2=times;
			if(sum1>57)
			{
			if(sum1>60){cout<<60-(i-1)*3<<endl;}
			else{ cout<<times<<endl;}
			w=1;break;}	//sum1=sum1+3;
		}
		if(w==0){
			if(times>57){cout<<times<<endl;}
		else cout<<60-m*3<<endl;}
		else
		{
			for(int j=i+1;j<=m;j++)
			{
				cin>>times;
			}

		}
	}
	return 0;
}
int main()
{
	int n,i,b[100],j,t,m;
	scanf("%d",&m);
	for(int l=0;l<m;l++)
	{
	scanf("%d",&n);
		int *a=(int*)malloc(sizeof(int)*(n+2));
		for(i=0; i<n; i++)
		{
			scanf("%d",&a[i]);
		}
		a[i]=60;
		i=0;
		t=0;
		for(j=1;j<=70;j++)
		{
			b[j]=t+1;
			t=b[j];
			if(b[j]==a[i])
			{
				i++;
				for(int k=0;k<3; k++)
					b[++j]=t;
			}
		}
		printf("%d\n", b[60]);
	}
	return 0;
}
/*??:1000012904-3.cpp
  ??????????????????
  ?????
  ???2010?11?25?
 */
int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		int count[20], fail, j, sum = 0;//???????????????????????????????
		cin >> fail;
		if(fail == 0)
			sum = 60;//?????????????60?
		else
		{
			for(j = 1; j <= fail; j++)
				cin >> count[j];//???????????????????
			for( j = 1; j <= fail; j++)
			{
				if(count[j] + j * 3 >= 60)//???????????????
				{
					if(count[j] + (j - 1) * 3 < 60)
					{
						sum = count[j];
						break;
					}//???60?????????????????????????60?????????????
					else
					{
						sum = 60 - (j - 1) * 3; 
						break;
					}//??60?????????????????????60???60?????????
				}
				else //??????????????????
					sum = 60 - j * 3 ;//???????????60??????????
			}//
		}
		cout << sum << endl;
	}
	
	return 0;
}
// ????.cpp : Defines the entry point for the console application.
//



int main()
{
	int n = 0;
	int cut[100] = {0};
	int sum[100][100] = {0};
	int num = 0;
	int i = 0;
	int t = 0;
	int time1 = 0;
	int time2 = 0;
	int q = 0;

	cin >> n;

	for( i = 1;i <= n;i++ )
	{
		cin >> cut[i];
		

		if( cut[i] == 0)
			continue;

		else
			for( t = 1;t <= cut[i];t ++ )
			{
				cin >> sum[i][t];
				
			}
	}

	for( i = 1;i <= n;i++ )
	{
		q = cut[i];

		if( cut[i] == 0)
		{
			num = 60;
			cout << num << endl;
		}

		else
			for( t = 1; t <= q;t++ )
			{
				time1 = sum[i][t] + 3 * ( t - 1 );
				time2 = time1 + 3;

				if( t == q && time2 <= 60 ) 
				{
					num = 60 - q * 3;
					cout << num << endl;
				}

				if( time1 <= 60 && time2 > 60 && time2 <= 63 )
				{
					num = sum[i][t];
					cout << num << endl;
					break;
				}

				if( time1 > 60 )
				{
					num = 60 - 3 * ( t - 1 );
					cout << num << endl;
					break;
				}

			}

	}


	return 0;

}
int main()
{
int i,j;
int n;
int a,b,c,d,e;
int f[20];
cin>>n;
for (i=1;i<=n;i++)
	{        
	 cin>>a;
	 if (a==0) cout<<60<<endl;
	 else
	 	 {
	  	 
	       for (j=1;j<=a;j++)	cin>>f[j];		 
 	       for (j=1;j<=a;j++)
	 	 	    {	
				if ((f[j]+3*j)>=60 && (f[j]+3*j)<=62) 
				    {cout<<f[j]<<endl;
				     break;
					}
				if ((f[j]+3*j)>62 ) 
				    {cout<<63-j*3<<endl;
				     break;
					}
 				 if (j==a) 
				   {cout<<60-a*3<<endl;
 				    break;
				   }
 			
				 }
		 }
	}	

}
int main()
{
	int i, j, n, a[100] = {0};
	cin >> n;
	int k, sum;
	while(n != 0)
	{
		n--;
		cin >> k;
		for (i = 1; i <= k; i++)
			cin >> a[i];
		if (a[k] + 3*k <= 60)
			sum = 60 - 3*k;
		if (a[k] + 3*k > 60)
		{
			for (j = 1; j <= k; j++)
				if ((a[j] + 3*j <= 60) && (a[j+1] + 3*(j+1) > 60))
				{
				if ((60 - 3*j) > a[j+1])
					sum = a[j+1];
				if ((60 - 3*j) <= a[j+1])
					sum = 60  - 3*j;
			}
		}
			cout << sum << endl;
	}
	return 0;
}
int main()
{
	int n,m,no[20]={0},i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		if(m==0)
			printf("60\n");
		else
		{
			for(j=0;j<m;j++)
				scanf("%d",&no[j]);
			if(no[m-1]+3*m<=60)
				printf("%d\n",60-3*m);
			else
			{
				for(j=0;j<m;j++)
				{
					if(no[j]+3*(j+1)>63)
					{
						if(no[j-1]+3*j<=60)
							printf("%d\n",60-3*j);
						else
							printf("%d\n",no[j-1]);
						break;
					}
					if(no[j]+3*(j+1)>60&&no[j]+3*(j+1)<=63)
					{
						printf("%d\n",no[j]);
						break;
					}
				}
			}
			
		}
	}
	return 0;
}
//???2010?11?24?
//???1000010586_???
//???????

int main()
{
	int n , i , j , k ;
	int m , stu[20];
	cin >> n;
	for ( i = 0 ; i <= n - 1 ; i ++ )
	{
		cin >> m;
		if ( m == 0 )
		{
			cout << 60 << endl;
			continue;
		}
		for ( k = 0 ; k <= m - 1 ; k ++ )
			cin >> stu[k];
		for ( j = 0 ; j <= m - 1 ; j ++ )
		{
			if ( stu[j] + 3 * j > 60 )
				break;
		}
		if ( stu[j - 1] + 3 * j > 60 )
			cout << stu[j - 1] << endl;
		else
			cout << 60 - 3 * j << endl;
	}
	return 0;
}
int main(){
	int n,m;
	int k,i,j,l,s[100],r;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&m);
		if(m==0) printf("60\n");
		if(m!=0){
			k=0;
		    for(j=0;j<m;j++){
			    scanf("%d",&s[j]);
		        if(s[j]<=60-(j+1)*3) continue;                       
			    if((s[j]>60-(j+1)*3) && k==0){
                    k=1;
					l=j;
				}
			}
		    if(k==0) r=60-j*3;
		    if(k==1){
                if(s[l]>60-(l+1)*3+3){
			    	r=60-l*3;
			   }
			   if(s[l]>60-(l+1)*3 && s[l]<=60-(l+1)*3+3){
				    r=s[l];
			   }
			}
		    printf("%d\n",r);
		}
	}
    return 0;
}
int aa[20];

int main()
{
    //freopen("1.in","r",stdin);
    //freopen("1.out","w",stdout);
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++)
    {
            cin>>m;
            for(int i=0;i<m;i++)
              cin>>aa[i];
            if(m==0) 
            {
                     cout<<"60"<<endl;
                     continue;
            }
            for(int j=0;j<m;j++)
            {
                    if((aa[j]+3*j)>=57 && (aa[j]+3*j)<=60)
                    {cout<<aa[j]<<endl; break;}
                    if((aa[j]+3*j)>60)
                    {
                                      int x=60-3*j;
                                      cout<<x<<endl;
                                      break;
                    }
                    else if(j==m-1)
                    {cout<<60-3*m<<endl;break;}
            }
            
    }
    return 0;
}
void main()
{
	int n,i,j,m,k,y,w;
	int a[100][60],sum[100][60];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		for(j=0;j<m;j++)
		{
			scanf("%d",&a[i][j]);
		}
		if(m==0)
			printf("60\n");
		else
		{
			for(k=0;k<m;k++)
			{
				sum[i][k]=a[i][k]+3*k;
				if(sum[i][k]>=57)
				{
					w=60-sum[i][k];
					if(w<0)
					{
						printf("%d\n",60-3*k);
					    break;
					}
					else
					{
						printf("%d\n",60-3*k-w);
						break;
					}

				}
				else
					if(k==m-1)
						printf("%d\n",60-(k+1)*3);
					
				
			}
			
		}
	}
}
int main ()
 {
	 int n;
	 scanf("%d",&n);
	 int i;
	 int *s,*r;
	 s=(int *)malloc(sizeof(int)*n);                         
	 r=(int *)malloc(sizeof(int)*n);
	 for (i=0;i<n;i++)
	 {
		 scanf("%d",&s[i]);
		 if (s[i]==0)r[i]=60;
		 else 
		 {
			 int j;
			 int *e;
			 e=(int *)malloc(sizeof(int)*s[i]);
			 for (j=0;j<s[i];j++)
			 {
				 scanf("%d",&e[j]);
			 }
			 if (3*s[i]+e[j-1]<=60)
				 r[i]=60-3*s[i];
			 else if (3*s[i]+e[j-1]<=63&&3*s[i]+e[j-1]>=57)
				 r[i]=e[j-1];
			 else if (3*s[i]+e[j-1]>60&&3*(s[i]-1)+e[j-2]<=63&&3*(s[i]-1)+e[j-2]>=57)
				 r[i]=e[j-2];
			 else if (3*(s[i]-1)+e[j-2]<=57)
				 r[i]=60-3*(s[i]-1);
			 else if (3*(s[i]-1)+e[j-2]>60&&3*(s[i]-2)+e[j-3]<60)
				 r[i]=60-3*(s[i]-2);
		 }
	 }
	 for (i=0;i<n;i++)
	 {
		 printf("%d\n",r[i]);
	 }
	 return 0;
 }
int main()
{
    int n,i,j;
    cin>>n;
    int a[n][60],b1[n];
    for(i=0;i<n;i++)
    {
        int m,k=0;cin>>m;
        int b[m];
        for(j=0;j<m;j++)
        cin>>b[j];
        for(j=m-1;j>0;j--)
        b[j]=b[j]-b[j-1];
        for(j=0;j<m;j++)
        {
           for(;b[j]>0&&k<60;k++,b[j]--)
           {
           a[i][k]=1;
           }
           a[i][k]=0;k++;a[i][k]=0;k++;a[i][k]=0;k++;
        }
        int mn;
        for(mn=k;mn<60;mn++)
        a[i][mn]=1;
        b1[i]=0;
      for(j=0;j<60;j++)
      if(a[i][j]==1)
      b1[i]++;
    }
    for(i=0;i<n;i++)
    cout<<b1[i]<<endl;
 
    return 0;
}
int main()
{
 int n,i;
 cin>>n;
 for(i=1;i<=n;i++)
  {
   int a[20],j;
   cin>>a[0];
   for(j=1;j<=a[0];j++)
   cin>>a[j];
   if(a[a[0]]+3*a[0]<=60)
    cout<<60-3*a[0]<<endl;
   else
   {
    for(j=a[0];j>=1;j--)
     {
      if(a[j]+3*j<=60)
        {
         if((a[j+1]+3*j)<=60)
           cout<<a[j+1]<<endl;
         else
         cout<<60-3*j<<endl;
         break;
        }
      }
    }
  }
return 0;
}
/**
 * ???11.cpp
 * ???????
 * ??????
 * ???2010?11?14?
 */
int main()
{
	int n,i,j,k,m,find,c;
	int a[1000][20],b[1000],sum[1000];/*????a??????????????????
                                         ??b?????????????????????
	                                     ??sum?????????????*/
	cin>>n;
	for(i=0;i<n;i++) 
	{
		find=0;                      //?????find????0
		cin>>m;
		for(j=0;j<m;j++)              //??????????????
		{
			cin>>a[i][j];
			b[i]=a[i][j]+3*(j+1);    //???j+1?????????????
			if(b[i]>60)
			{
				find=1;           //?????60????????1?????
			    c=j;
				if(c<m-1)       //?????????
				{
					for(k=c+1;k<m;k++)
					{cin>>a[i][k];}
				}
			    break;
			}
		}
		if(find==0)              //???????????????????
		{
			sum[i]=60-3*m;  
		}
		else
		{
			if(b[i]==61)
				sum[i]=60-3*c-2;
			else if(b[i]==62)
				sum[i]=60-3*c-1;
			else if(b[i]==60)
				sum[i]=60-3*c-3;
			else
				sum[i]=60-3*c;
		}
	}
	for(i=0;i<n;i++)               
	{cout<<sum[i]<<endl;}
	return 0;
}
int main()
{
	int n;
	cin>>n;
	for (int t=0;t<n;t++)
	{
		int time=0,ans=0,m;
		cin>>m;
		int point[100];
		for (int i=0;i<m;i++)
			cin>>point[i];
		for (int i=0;i<m;i++)
		{
			time+=point[i]-ans;        //??????
			if (time>60)               //?????????
			{
				ans=point[i]-(time-60);
				break;
			}
			else ans=point[i];          //??????
			time+=3;                    //????????
			if (time>60) break;         //?????????
		}
		if (time<60) ans+=60-time;           //??????????
		cout<<ans<<endl;
	}
	return 0;
}
void main ()
{
	int n,i,j,a[100][50];;
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i][0]);
		for(j=1;j<=a[i][0];j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<n;i++)
	{  if(a[i][0]==0)printf("60\n");else{
		for(j=1;j<=a[i][0]&&a[i][j]+j*3-3<=60;j++);
		j--;
		if(60-a[i][j]-j*3<=3)
			printf("%d\n",a[i][j]);
			else 
				printf("%d\n",60-j*3);}
	}
}
//*************************************************************
//*  ????1000012846_6.cpp *********************************
//*  ????? ***********************************************
//*  ?????2010?11? *************************************
//*  ????????? ***************************************
//*************************************************************
int main()
{
	int i , j , n , a[100][20] , b[100] = {0} , c[100] , d[100] ;    
	//??????i,j??????n;??a,b,c,d
	cin >> n ; 
	for ( i = 0 ; i < n ; i++ )       //???????????
	{
		cin >> b[i] ;
		for ( j = 0 ; j < b[i] ; j++ )
			cin >> a[i][j] ;
	}
	for ( i = 0 ; i < n ; i++ ) 
		//???????????????????????c[];??????d[];       
	{
		d[i] = b[i] ;
		c[i] = a[i][b[i]-1] ;
		for ( j = 0 ; j < b[i] ; j++ )
		{
			if ( a[i][j] + j * 3 > 60 )
			{
				c[i] = a[i][j-1] ;
				d[i] = j ;
				break ;
			}
		}
	} 
	for ( i = 0 ; i < n ; i++ )     //?3?????
	{
		if ( b[i] == 0 )    //??????????
			cout << "60" << endl ;
		else if ( c[i] + d[i] * j > 60 )   //??????????????????????
			cout << c[i] << endl ;
		else           //?????????????????????60???
			cout << 60 - d[i] * 3 << endl ;
	}
	return 0;
}
int main(){
    int i,j,n,sum,m,f;
    scanf("%d",&n);
    for(i=0;i<n;i++){f=1;
                     scanf("%d",&m); 
                     for(j=0;j<m;j++){
                     scanf("%d",&sum);                                          
    if(((sum+3*j)>=60)&&(f)){
         f=0;
         sum=60-3*j;
         printf("%d\n",sum);
         }
    else if(((sum+3*j+3)>=60)&&(f)){
         f=0;      
         printf("%d\n",sum);
         }
         }
     if(f){
          sum=60-3*m;
         printf("%d\n",sum);
         }
         }     
    return 0;   
 }
int main()
{
	int i,j,n,m,k[10],u=0,c,sum;
	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);
		}
		l[i]=c;
	}
	for(i=0;i<n;i++)
		printf("%d\n",l[i]);
	return 0;
}
int main()
{
	int n,m,i,j,a[100],count[100];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>m;
		for(j=0;j<m;j++)
		{
			cin>>a[j];
			if((a[j]+j*3>=57)&&(a[j]+j*3<=60))
				count[i]=a[j];
			else if((a[j]+j*3>60)&&(a[j-1]+(j-1)*3<57))
				count[i]=60-j*3;
			else continue;
		}
        if(m==0)
			count[i]=60;
		else if(a[m-1]+m*3<=60)
			count[i]=60-m*3;
		
	
        cout<<count[i]<<endl;
	}
	return 0;
}
int main()
{
	int n,i,j=1,k,m[20],x,time1;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x;
		if(x==0)//??????
			cout<<60<<endl;
		else
		{
		for(j=1;j<=x;j++)
		    {
				cin>>m[j];
				time1=m[j]+3*(j-1);//??????
				if(time1>=57&&time1<=60)
			    {
						  cout<<m[j]<<endl;
						  break;
			    }
				if(time1>60)
				{
					cout<<m[j]-(time1-60)<<endl;
					break;
				}

		    }
        if(j<x)
        	for(k=j;k<x;k++)
        		cin>>m[k];//????????????????
		if(time1<=57)
			{
				cout<<60-(time1+3)+m[x]<<endl;
			 }
		}
	}

	return 0;
}
int main()
{
	int n,c;
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>c;
		int w,t,r=-1,rs=0;
		for (int j=0;j<c;j++)
		{
			cin>>w;
			t=w+j*3;
			if (t<=60&&t+3>=60)
			{
				r=w;
			}
			else if(t<60)
			{
				rs++;
			}
		}
		if (r!=-1)
		{
			cout<<r<<endl;
		}
		else
		{
			cout<<60-rs*3<<endl;
		}
	}
	return 0;
}
int main()
{
	int n,i,j,m,t,x,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&m);
		k=60;
		t=0;
	if(m!=0)
		{
			for(j=1;j<=m;j++)
			{
				scanf("%d",&x);
					k=k-3;
				    t=t+3;
				if(x+t>=60)
				{
					if(x+t<=65)
					{
					    k=x;
						break;
					}
					else
					{
						k=63-t;
				        break;
					}
				}
		    }   
	   }
	if(i==1)
		printf("%d",k);
	else
		printf("\n%d",k);
	}
 return 0;
}
int main(){
	int i,n,m,x[110],ctr,time;
	scanf("%d",&n);
	while(n--){
		ctr=0;
		time=0;
		scanf("%d",&m);
		for(i=1;i<=m;i++){
			scanf("%d",&x[i]);
			if(time+x[i]-ctr<=60)
			{
				time+=x[i]-ctr+3;
				ctr=x[i];
			}
		}
		if(time<60)
			ctr+=60-time;
		printf("%d\n",ctr);
	}
	return 0;
}
//******************************//
 //*     ?????				*//
 //*     ???1000012711		*//
 //*     ???????			*//
 //*     ???2010.11.24		*//
 //******************************// 
int main()
{
	int i, j, n, m, sum, time, a[50] = {0};
	cin >> n;
	for (i = 1; i <= n; i ++)
	{
		sum = 0;
		time = 0;
		cin >> m;
		for (j = 1; j <= m; j ++)
		{
			cin >> a[j];
		}
		for (j = 1; j <= m; j ++)
		{
			if (a[j] - sum + time > 60)
				break;
			time += a[j] - a[j - 1] + 3;
			sum += a[j] - a[j - 1];
		}
		if (time <= 60)
			sum += 60 - time;
		cout << sum << endl;
		for (j = 0; j < 50; j ++)
		{
			a[j] = 0;
		}
	}
	return 0;
}
int main(){
int n,j,i,m,k,s[100],t,sum;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&m);
for(j=0;j<m;j++)
scanf("%d",&s[j]);
if(m==0)printf("60\n");
else
{
k=sum=0;
for(t=1;t<=60;t++)
{
//printf("%d %d %d\n",sum,k,t);
sum++;
if(sum==s[k]){t+=3;if(k<m-1)k++;}
}
printf("%d\n",sum);
}
}
}
int main()
{
   
	int n,i;
	int m,k;
	int a[60];
	int count[100]={60};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		count[i]=60;
		scanf("%d",&m);
		if(m!=0) 
		{
			for(k=1;k<=m;k++)
			{
				scanf("%d",&a[k]);
				if((a[k]+3*k-3)<57)
					count[i]=count[i]-3;
				else if((a[k]+3*k-3)<63)
				{
					count[i]=a[k];
				}
			}
		}
		printf("%d\n",count[i]);
	}
	return 0;
}
int main()
{
	int n, i, j, a[100][60];
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%d", &a[i][0]);
		for(j = 1; j <= a[i][0]; j++)
		{
			scanf("%d", &a[i][j]);
		}
		int num = 60;
		if(a[i][0] == 0)
			printf("60\n");
	    for(j = a[i][0]; j >= 1; j--)
		{
			if(a[i][j] + j * 3 <= 60)
			{
				printf("%d\n", 60 - j * 3 );
				break;
			}
			else if(a[i][j] + j * 3 <= 63)
			{
				printf("%d\n", 60 - (j - 1) * 3 - 63 + a[i][j] + j * 3);
				break;
			}
		}
	}
	return 0;
}