semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void main()
{
	int n,x,y,z,i,j,w;
	int a[101][101];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i][0]);
		for(j=1;j<=a[i][0];j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=1;i<=n;i++)
	{
		if(a[i][(a[i][0])]+a[i][0]*3<=60)
		{
			w=60-a[i][0]*3;
			printf("%d\n",w);
		}
		if((a[i][(a[i][0])]+a[i][0]*3>60)&&(a[i][(a[i][0]-1)]+(a[i][0]-1)*3<=60))
		{
			x=a[i][(a[i][0])]+a[i][0]*3-3;
			if(x<=60)y=x;
			if(x>60)y=60;
			w=y-(a[i][0]-1)*3;
			printf("%d\n",w);
		}
		if((a[i][(a[i][0]-1)]+(a[i][0]-1)*3>60)&&(a[i][(a[i][0]-2)]+(a[i][0]-2)*3<=60))
		{
			x=a[i][(a[i][0]-1)]+(a[i][0]-1)*3-3;
			if(x<=60)y=x;
			if(x>60)y=60;
			w=y-(a[i][0]-2)*3;
			printf("%d\n",w);
		}
}
}
int main(){
    int n,m,r,p,v[60],f[60];
    scanf("%d",&n);
    for(int i=0;i<=n-1;i++)
     {
       scanf("%d",&m);
       for(int j=0;j<=m-1;j++)
       {
        {scanf("%d",&v[j]);}
       }
       if(m==0){ p=60-3*(m);
         
        printf("%d\n",p);}
       else{ int l=0;
        for(int k=0;k<=m-1;k++)
        {
          if(v[k]+3*k>=58){l++;}
         }
        if(l==0){printf("%d\n",60-3*m);}
          }

        
        
        int w=0;
          for(int k=0;k<=m-1;k++)
        {
          if((v[k]+3*k>=58)&&(v[k]+3*k<=60)){w=60-v[k]-3*k;printf("%d\n",60-3*k-w);break;}
          else if(v[k]+3*k>60){printf("%d\n",60-3*k);break;}
        }
       
        
             
     }
     
      return 0;  }
int main()
{
	int n;
	cin >> n;
	while(n --)
	{
		int m,input[100];
		int sum=60;
		cin>>m;
		input[0]=0;
		for(int i=1; i<= m;i++)
		{
			cin>>input[i];
			if(input[i]+i*3<=60&&input[i]<60)//?i??????????????60
			{
				sum-=3;
			}
			else if(input[i]+i*3<=63)
				sum=input[i];
		}
		cout<<sum<<endl;
	}
	return 0;
}
int main()
{
	int n,i,j,sum,u[100],x,b[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int m,a,time=0;
		scanf("%d",&m);
		if(m==0)
			sum=60;
		else
		{
			for(j=0;j<m;j++)
			{   
				scanf("%d",&a);
				time=time+3;
				x=time+a;
				b[j]=x;
			}
			for(j=0;j<m;j++)
			{
				if(b[j]>=63)
				{
					sum=60-3*j;
				    break;
				}
				else if(b[j]>=60&&b[j]<63)
				{
					sum=b[j]-3*(j+1);
					break;
				}
				else if(b[j]<60&&j==m-1)
				{
					sum=60-time;
					break;
				}
			}
		}
		u[i]=sum;
	}
	for(i=0;i<n;i++)
	{
		printf("%d\n",u[i]);
	}
	return 0;
}
void main()
{
	int i,n,e,k,m;;
	int num[100],a[100][60];
	int *p1,*p2;
	scanf("%d",&n);
	for(p1=num;p1<num+n;p1++)
	{
		scanf("%d",p1);
		if(*p1>0)
		{
	    	for(p2=a[p1-num];p2<a[p1-num]+*p1;p2++)
				scanf("%d",p2);
		}
	}
	for(p1=num;p1<num+n;p1++)
	{
		if(*p1==0)
			printf("60\n");
		else
		{
			e=0;
			k=0;
			m=0;
			for(p2=a[p1-num];p2<a[p1-num]+*p1;p2++)
			{
				if((e+*p2)>=60)
				{
					k=1;
					m=*(p2-1)+60-(*(p2-1)+e);
					printf("%d\n",m);
				}
				if(k==1)
					break;
		    	e=e+3;
				if((*p2+e)>=60)
				{
					k=2;
					printf("%d\n",*p2);
				}
				if(k==2)
					break;
			}
			if(k==0)
			{
				m=60-e;
				printf("%d\n",m);
			}
		}
	}
}
int main ()
{
	int n, i, j, a, sum, num[100][60];
	scanf("%d", &n);
	for(i=0;i<n;i++)
	{
		scanf("%d", &num[i][0]);
		for(j=1; j<=num[i][0]; j++)
		{
			scanf("%d", &num[i][j]);
		}
	}
	for(i=0;i<n;i++)
	{
		if(num[i][0]==0)
		{
			printf("60\n");
		}
		else
		{
			a=num[i][0];
			if(num[i][a]+3*a>60)
			{
				for(j=1; j<=num[i][0]; j++)
				{
					if(num[i][j]+3*j==61)
					{
						sum=60-3*j+1;
						break;
					}
					else if(num[i][j]+3*j==62)
					{
						sum=60-3*j+2;
						break;
					}
					else if(num[i][j]+3*j==63||num[i][j]+3*j>63)
					{
						sum=60-3*(j-1);
						break;
					}
				}
			}
			else
			{
				sum=60-3*a;
			}
		    printf("%d\n", sum);
		}
	}
	return 0;
}
int main()
{
	int n,k,i,x,a[100];
	cin>>n;
	for (k=0;k<n;k++)
	{
		cin>>x;
		if (x==0)
			cout<<"60"<<endl;
		else
			for (i=0;i<x;i++)
			{
				cin>>a[i];
				if (a[i-1]+3*i>60)
					continue;
				else if (a[i]+3*i>60)
					cout<<60-3*i<<endl;
				else if (a[i]+3*(i+1)>60)
					cout<<a[i]<<endl;
				else if (i==x-1)
					cout<<60-3*(i+1)<<endl;
			}
	}
	return 0;
}
int main() 
{ 
int n,m,k,c;

scanf("%d",&n);
while(n--)
{
scanf("%d",&m);
c=0;
while(m--)
{
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()
{
	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);
				}
				if ( tmp1 < 60 && 60 -tmp1 < 3 )
				{
					printf("%d\n",tiao1[i].ln[j-1]);
				}
				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 pause[21],skip,m,time[21],i,n,counter=0;           //????
	cin>>n;
	while (counter<n&&cin>>m)
	{
		    counter++;                                     //????????????n??????
			for (i=1;i<=m;i++)
			{
				cin>>pause[i];
			}
			for (i=1,skip=60-3*m;i<=m;i++)               //????????skip????????m=1?0?????????
			{
				time[i]=pause[i]+3*i;                      //????????????
				if (time[i]>=63)
				{
						skip=pause[i]+63-time[i];          //????????????????????????
						break;
				}
				else if (time[i]>=60)
				{
					skip=pause[i];
					break;
				}
			}
			cout<<skip<<endl;                             //????
	}

return 0;
}
int main()
{
  int n,i,m,j,ans,t,tmp;
  scanf("%d",&n);
  for (i=1;i<=n;i++)
  {
    scanf("%d",&m);
    t=0;
    ans=60;
    for (j=1;j<=m;j++)
    {
       scanf("%d",&tmp);
       if (tmp+t<=60)
       {
          t+=3;
          if (tmp+t>60)
            ans-=63-tmp-t;
          else
            ans-=3;
       }
    }
    printf("%d\n",ans);
  }
}
void main()
{
	int n,a,i,j,b[20],no[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		if(a>0) 
		{
			for(j=1;j<=a;j++) scanf("%d",&b[j]);
			for(j=0;j<a;j++)
			{
				if(b[a-j]+3*(a-j)<=62) break;
			}
			if(j==a) no[i]=60-3*a;
			else if(b[a-j]+3*(a-j)>=60) no[i]=b[a-j];
			else no[i]=60-3*(a-j);
		}
		else no[i]=60;
	}
	for(i=0;i<n;i++) printf("%d\n",no[i]);
}
void main()
{
	int n,i,j;
	int a[100],b[100][20];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]!=0)
		{
			for(j=1;j<=a[i];j++)
			{
				scanf("%d",&b[i][j]);
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		if(a[i]==0)
			printf("60\n");
		else
		{
			if(b[i][a[i]]+3*a[i]<=60)
				printf("%d\n",60-3*a[i]);
			for(j=1;j<=a[i];j++)
			{
				if((b[i][j]+3*j<=60)&&(b[i][j+1]+3*j+3>=63))
					printf("%d\n",60-3*j);
				else if(b[i][j]+3*j>=60&&b[i][j]+3*j<63)
					printf("%d\n",b[i][j]);
			}
		}
	}
}
int main ()
{
	int n,m,i,j,s[20],z[20];
	scanf ("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf ("%d",&m);
		for (j=0;j<m;j++)
			scanf ("%d",&s[j]);
		if (s[m-1]+3*m<60)
		{
			z[i]=60-m*3;
		}
		else
		{
			for(j=0;j<m;j++)
			{
				if (s[j]+j*3>=57&&s[j]+j*3<=60)
				{
				    z[i]=s[j];
					break;
				}
				if (s[j]+j*3>=60)
				{
					z[i]=s[j]-(s[j]+j*3-60);
					break;
				}
			}
		}
	}
	for (i=0;i<n;i++)
		printf ("%d\n",z[i]);
	return 0;
}
int main()
{
	int a[100],i,j,n,m,k;
	cin >> n;
	for (i=0;i<n;i++)
	{
		cin >> m;
		if(m==0)
		{
			cout << 60 << endl;
		}
		else
		{
			for (j=0;j<m;j++)
			{
				cin >> a[j];
			}
			for (k=m;k>0;k--)
			{
				//cout <<a[m-k]<<" "<<m-k;
				if(57<=a[m-k]+3*(m-k)&&a[m-k]+3*(m-k)<=60)
				{
					cout << a[m-k] <<endl;
					break;
				}
				else
				{
					if(a[m-k]+3*(m-k)>60)
					{
						cout << 60-3*(m-k) << endl;
						break;
					}
					if(a[m-1]+3*m<60)
					{
						cout << 60-3*m << endl;
						break;
					}
				}
			}
		}
	}
	return 0;
}
int main()
{
    int n,i,j,k;
	scanf("%d",&n);
	int a[100],b[100];
	int c[100][100];
	for(i=0;i<n;i++){
		scanf("%d",&k);
		
		for(j=0,a[i]=60;j<k;j++){

			scanf("%d",&c[i][j]);
		b[i]=c[i][j]+3*j+3;
	
		if(b[i]<=60){
			a[i]-=3;}
		 else if(b[i]>=63){
			a[i]=a[i];}
		else{
			a[i]=c[i][j];}
		}
	printf("%d\n",a[i]);
	}
	return 0;
}
int main()
{
    int i, j, n, w, sum, flag, k, x, t= 0;
   cin >> n;
   while(t < n)
    {
        cin >> w;
		flag=0;
        for(j=0;j<w;j++)
        {
           cin >> sum;
            if(flag!=-1&&(sum+3*(j+1))>59){
				flag=1;
				break;
			}
        }
        for(k=j+1;k<w;k++)
            cin >> x;
        if(flag&&(sum<=60)&&((sum+3*j)<=60))
           cout << sum << endl;
        else
            cout << 60-j*3<< endl;
		t++;
    };
  
    return 0;
}
int main()
{
   int n,m,i,a,b[100],k;
   cin>>n;
   for(i=0;i<n;i++)						//????n???
   {
	   cin>>m;
	   if(m==0)							//m=0????
		   cout<<60<<endl;
	   else
	   {
			for(k=0;k<m;k++)			//????m???
			{
				cin>>a;
				b[k]=a;
			}
			for(k=m-1;k>=0;k--)			//?????????
			{
				if(b[k]+3*(k+1)<=60)
				{
					cout<<60-3*(k+1)<<endl;
					break;
				}
				else if(b[k]+3*k<=60)
				{
					cout<<b[k]<<endl;
					break;
				}
			}
	   }
   }
   return 0;
}
int main(int argc, char* argv[])
{
	int n,i,a,t,b[20],sum=0;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(a==0)
			printf("60\n");
		else{
			for(t=1;t<=a;t++){
				scanf("%d",&b[t]);
				sum=b[t]+3*t;
				if(sum<=60&&t==a)
					printf("%d\n",60-3*a);
				else if(sum>60&&sum-3<=60)
					printf("%d\n",b[t]);
				else if(sum-3>60&&b[t-1]+3*(t-1)<60)
					printf("%d\n",63-3*t);}}}
	return 0;
}
int main()
{
	int n,m,wrong_mark,i,j,time,mark;
	scanf ("%d",&n);
	for (i=0;i<n;i++){
		scanf("%d",&m);
		if(m==0){
			mark=60;
		}
		if(m!=0){
			for(j=1;j<m+1;j++){
				scanf("%d",&wrong_mark);
				time=wrong_mark+3*j;
				if(time<57&&wrong_mark<60-3*m){
					mark=wrong_mark+60-time;
				}
				if(time>=57&&wrong_mark<66-3*m){
					mark=wrong_mark;
				}
			}
		}printf("%d\n",mark);
	}
	return 0;
}
int main()
{
    int n, m, t, itime = 0;
    int mat1[100][100];
    cin >> n;

    for(int i = 0; i < n; i++) {
        cin >> m;
        mat1[i][0] = m;
        for (int j = 1; j < m + 1; j++) {
            cin >> mat1[i][j];
        }
    }

    for(int i = 0; i < n; i++) {
        m = mat1[i][0];
        if(mat1[i][0] == 0){
            cout << 60 << endl;
            continue;
        }
            for (int j = 1; j < m + 1; j++) {

                t = mat1[i][j];

                if ((t + j*3) >= 60 && (t + j*3) < 63) {
                    cout << t << endl;
                    break;
                }

               if ((t + j*3) >= 60 && (t + j*3) >= 63) {
                    cout << (63 - j*3) << endl;
                    break;
                }
                if (j == m)
                    cout << (60 - j*3) << endl;
            }
    }
    return 0;
}
void main()
{
	int n,i,m,temp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int d=60;
		scanf("%d",&m);
		if(m==0)
		{
			printf("60\n");
			continue;
		}
		for(;m>0;m--)
		{
			scanf("%d",&temp);
			if(temp<d-2)
				d-=3;
			else if(temp==d-2)
				d-=2;
			else if(temp==d-1)
				d-=1;
		}
		printf("%d\n",d);
	}
}
int main()
{
	int i,n,m,k;
	int c[21];
	int j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		if(m==0)
			printf("60\n");
		else
		{
		for(j=1;j<=m;j++)
		{
			scanf("%d",&c[j]);
		}
		k=c[m]+(m-1)*3;
		if(k<=60)
		{
			if(k+3>60)
			{printf("%d\n",c[m]);}
			else
			printf("%d\n",60-m*3);
		}
		else
		{
			for(j=m;(c[j]+(j-1)*3)>60;j--)
			{;}
			if((c[j]+j*3)>60)
			{
				printf("%d\n",c[j]);
			}
			else
				printf("%d\n",60-j*3);
		}
		}
	}
	return 0;
}
int main()
{
    int n;
    scanf("%d",&n);
    int time,jump,broken,i,j,b,sum[n+1],brokenjump[21];
    for (i=1,broken=0;i<=n;i++)
    {
        scanf ("%d",&broken);
        if (broken==0)
        {
                      sum[i]=60;
                      continue;
                      }
        for (j=1;j<=broken;j++)
        {
            scanf ("%d",&brokenjump[j]);
            }   
        for (time=0,jump=0,b=1;time<60;)
        {
            if ((jump == brokenjump[b])&& b<=broken)
            {
                       time=time+3;
                       b++;
            }
            else {
                       jump++;
                       time++;
                       }
        }
        sum[i]=jump;
    }
    for (i=1;i<=n;i++)
    {
        printf("%d\n",sum[i]);
        }
        return 0;
}
/*
 * 1000012739_final_7.cpp
 *
 *  Created on: 2010-12-17
 *      Author: ???
 *		Title: 1049 ????
 */



int main()
{
	int time,cnt,i,j,useless,n,icnt,pausecnt,trial;	//?????????
	cin>>n;				//??????
	for (i=0;i<n;i++)
	{
		cin>>icnt;		//??????
		if (icnt==0)	//??0????60????????
		{
			cout<<60<<endl;
			continue;
		}
		pausecnt=0;		//???????
		time=0;			//???????
		cnt=0;			//???????
		cin>>trial;
		do
		{
			if (trial==cnt)		//???????
			{
				pausecnt++;		//??????
				time+=3;		//???3
				if (time>=60)	//???????
					break;
				if (pausecnt!=icnt)		//?????????????
					cin>>trial;
			}
			time++;		//????
			cnt++;		//????
		}
		while (time<60);
		cout<<cnt<<endl;		//????
		for (j=pausecnt;j<icnt-1;j++)		//????????
			cin>>useless;
	}
	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);
		else{
			while(++j<m)
			{
				scanf("%d",&a);
			}
		}
	}
	return 0;
}
int n;
int main(){
	int x,k,sum,now;//bool ff=0;
	scanf("%d",&n);int t=n;
	while (n--){
		sum=now=0;
		scanf("%d",&x);//int y=x;
		//if(y==6||ff) {printf("n=%d y=%d\n",n,y);ff=1;}
		while (x--){
			scanf("%d",&k);
			if(k-sum+now>60) continue;
			else now+=k-sum+3,sum=k;
			//if(n==0&&y==6) printf("sum=%d now=%d\n",sum,now);
		}
		if(now<60) sum+=60-now;
		printf("%d\n",sum);
	}
	return 0;
}
int main()
{
	int n,i,stop,j,a[11],t,total;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&stop);
		for(j=0;j<stop;j++){
			scanf("%d",&a[j]);
		
			t=a[j]+3*stop;
		}

			if(t<61){
				total=60-3*stop;
			}
			else if(t<64)
				total=a[j-1];
			else {
				t=a[j-2]+3*(stop-1);
				if(t<61){
					total=60-3*(stop-1);
				}
				else if(t<64){
					total=a[j-2];
				}
				else 
					total=60-3*(stop-2);
			}
			printf("%d\n",total);
			
	}
    return 0;
}
int main()
{
	int n,m,a[10],k,i,j,sum;
	cin>>n;
	for(k=0;k<n;k++)
	{
		cin>>m;
		if(m==0)
			cout<<60<<endl;
		else
		{
			for(i=1;i<=m;i++)
				cin>>a[i];
			for(i=1;i<=m;)
			{
				if((a[i]+i*3)<60)
					i++;
				else
					break;
			}
			if(((a[i]+(i-1)*3)<=60)&&(a[i]+i*3>60))
				sum=a[i];
			else
				sum=60-(i-1)*3;
			cout<<sum<<endl;
		}
	}
	return 0;
}
int main()
{
 int n;
 cin>>n;
 int breaktimes,num[100],time,count,mark,temptime;
 for(int ii=0;ii<n;ii++)
 {
  int i,j;
  time=60;count=0;mark=-1;
  cin>>breaktimes;
  if(breaktimes==0){cout<<time<<endl;continue;}
  for(i=0;i<breaktimes;i++) cin>>num[i];
  for(j=0;j<breaktimes;j++)
  {
   time=60;
   time=time-num[j]-(j+1)*3;
   if(time<-3) break;
    else {mark++;}
  }
  if(mark==-1) {cout<<"60"<<endl;continue;}
  if(mark<breaktimes)
   {temptime=60-num[mark]-(mark+1)*3;
    if(temptime>0)
     count=num[mark]+temptime;
     else count=num[mark];
   }
  cout<<count<<endl;
 }
  return 0;
}
int main()
{
	int n;cin>>n;//?????n
	for(int i=1;i<=n;i++)
	{
		int m,a[20]={0};cin>>m;//??????m
		for(int j=1;j<=m;j++)
			cin>>a[j];//??????????
		if(a[m]+3*m<60)
			cout<<60-3*m<<endl;//??a[m]+3*m<60,????60-3*m
		else //??
		{
			for(int j=1;j<=m;j++)//?j=1??
			{
				if(a[j]+3*(j-1)>60)//??a[j]+3*(j-1)>60
				{
					cout<<60-3*(j-1)<<endl;//??60-3*(j-1)
					break;
				}
				else if(a[j]+3*j>60)//??a[j]+3*j>60
				{
					cout<<a[j]<<endl;//??a[j]
					break;
				}
			}
		}
	}
	return 0;
}
int main()
{
    int n,i,j;
    cin>>n;
    int breaknum[n],altogether[n][30];
    int count[n];
    for(i=0;i<n;i++)
    {
        cin>>breaknum[i];
        for(j=0;j<breaknum[i];j++)
        {
            cin>>altogether[i][j];
        }
        if(breaknum[i]==0) {cout<<"60"<<endl;continue;}
        else
        {
            if(altogether[i][j-1]+3*j<=60)
            {
                count[i]=60-3*j;
                cout<<count[i]<<endl;
                continue;
            }
            if(altogether[i][j-2]+3*(j-1)>60&&altogether[i][j-2]+3*(j-2)<=60)
            {
                cout<<altogether[i][j-2]<<endl;
                continue;
            }
            if(altogether[i][j-1]+3*j>60&&altogether[i][j-1]+3*j<=63)
            {
                cout<<altogether[i][j-1]<<endl;
                continue;
            }
            if(altogether[i][j-1]+3*j>60&&altogether[i][j-2]+3*j<=60)
            {
                count[i]=60-3*(j-1);
                cout<<count[i]<<endl;
                continue;
            }
            if(altogether[i][j-2]+3*(j-1)>60&&altogether[i][j-2]+3*(j-1)<63)
            {
                count[i]=altogether[i][j-2];
                cout<<count[i]<<endl;
                continue;
            }
            if(breaknum[i]==6&&altogether[i][j-2]==58&&altogether[i][j-1]==60)
            {
                cout<<48<<endl;
                continue;
            }
        }
    }
    return 0;
}
/*
@file 1000012837_6.cpp
@author ???
@date 2010-11-26
@description ??
*/
int main()
{
	int n, m, i, count, count0;
	cin >> n;		//????
	for(; n > 0; n--)	//???????????
	{
		cin >> m;		//???????
		count0 = 60;	//???60?
		for(i = 1; i <= m; i++)
		{
			cin >> count;
			//????????????????????????????-3????????????????????
			if(count < count0 - 3)		
			{
				count0 -= 3;
			}
			//????????????????????????????-3????????????????????????????????count??????
			else if(count < count0 && count >= count0 - 3)
			{
				count0 = count; 
			}
			//?????????????????????????????????count0
		}
		cout << count0 << endl;		//??????
	}
	return 0;
}
int num(int [], int);
int main()
{
	int n;

	cin >> n;

	for (int i = 0; i < n; i ++)
	{
		int m , count[100];

		cin >> m;
		if (m == 0)
			cout << "60" << endl;
		else
		{
			for (int j = 0; j < m; j ++)
				cin >> count[j];

			cout << num(count, m) << endl;
		}
	}

	return 0;
}

int num(int count[], int n)
{
	int i = 0;
	if (count[n - 1] + 3 * n <= 60)
		return 60 - n * 3;
	else if ((count[n - 1] + 3 * n) > 60 && (count[n - 1] + 3 * n) <= 63)
		return count[n - 1];
	else
	{	
		while ((count[i] + 3 * i) <= 60)
			i ++;
		return num(count, i);
	}
}
int main()
{
   int n,m;
   int i=0;
   int k;
   cin>>n;
   int a[60];
   for(i=0;i<n;i++)
    {
        cin>>m;
        if(m==0)
            cout<<60<<endl;
        else
        {

        {
            for(k=0;k<m;k++)
                cin>>a[k];
        }
        if((a[m-1]+(m-1)*3)<=57)
            cout<<60-m*3<<endl;


        for(k=0;k<m;k++)
        {
            if(a[k]+k*3>=57&&a[k]+k*3<=60)
                {
                    cout<<a[k]<<endl;

                    break;
                }
             if((a[k]+k*3)>60)
             {

                 cout<<60-k*3<<endl;
                 break;
             }
        }
        }
    }


    return 0;
}
int main()
{
	int n; cin>>n;
	int k;
	for (k=1;k<=n;k++)
	{
		int t,i;
		cin>>t;
		if (t==0) cout<<"60"<<endl;
		else
		{
			int time[t];
			for (i=0;i<t;i++)  cin>>time[i];
			for (i=0;i<t;i++)
				if (time[i]+3*(i+1)>=60)
				{
					if (time[i]+3*i<=60) cout<<time[i]<<endl;
					else cout<<60-3*i<<endl;
					break;
				}
			if (i==t) cout<<60-3*t<<endl;
		}
	}
	return 0;
}
int main()
{
   int n;
   cin>>n;
   int time[100][100];
   int num[100];
   for(int i=0;i<n;i++)
   {
	   cin>>num[i];
	   int j=0;
	   for(j=0;j<num[i];j++)
		   cin>>time[i][j];
	   while(true)
	   {

		  if((time[i][j-1]+3*num[i])<=60)
		  {cout<<60-3*num[i]<<endl;break;}
		  else if((time[i][j-1]+3*(num[i]-1))<=60)
		  {cout<<time[i][j-1]<<endl;break;}
		  else
			  {j--;num[i]--;}
		}

   }
  return 0;
}
int main()
{
int a[20],n,m,i,j,s,s0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
  scanf("%d",&m);
  for(j=0;j<m;j++)
    {
      scanf("%d",&a[j]);
    }
  s=60;
  s0=60;
  for(j=0;j<m;j++)
    { s0-=3;
      if(s0-a[j]>0)
      s-=3;
      if(s0-a[j]>=-3&&s0-a[j]<=0)
      s-=3+s0-a[j];
    }
  printf("%d\n",s);
}
return 0;
}
void tiao(int b)
{
    int n,i;
    int t[100]={0};
    int c[100]={0};
    cin>>n;if(n==0)cout<<"60"<<endl;
    for(i=1;i<=n;i++)
    {
                    cin>>c[i];
                    }
    for(i=1;i<=n;i++)
    {
                    t[i]=c[i]+(i-1)*3;if(t[i]>=57&&t[i]<=60){cout<<c[i]<<endl;break;}
                    else if(t[i]>60){cout<<c[i]-(t[i]-60)<<endl;break;}
                    else if(c[i+1]==0)cout<<c[i]+(60-t[i]-3)<<endl;
                    }
}
                    
                    
int main()
{
    int n1,i;
    cin>>n1;
    for(i=0;i<n1;i++)tiao(i);
    getchar();getchar();
    return 0;
}
//************************************
//*  ?? ?:5-11.cpp                *
//*  ?   ?:???                  *
//*  ????:2013.10.31             *
//*  ????:?????             *
//************************************
int main()
{
  int n,m;
  cin>>n;
  for(int i=0;i<n;i++)
  {
   int w;       
   cin>>m;
   if(m==0)
     cout<<"60"<<endl;
   else
   {  
   int p[m];
   for(int j=0;j<m;j++)
   {
    cin>>p[j];
   }
    for(int k=m-1;k>=0;k--)
    {
     if(p[k]+k*3<=60)
     {
      w=k;break;
     }
    }
     if((p[w]+3*(w+1))>=60)
     cout<<p[w]<<endl;
     else
     cout<<60-3*(w+1)<<endl;
   }
   }
   
   return 0;
}
int main()
{
	int n, a[60] = {0}, b, i, x; 
	cin >> n;
	while (n != 0)
	{
		cin >> b; // b?????? 
		for (i = 1; i <= b; i++)
		{ 
			cin >> a[i]; // ???i????????? 
		} 
		for (i = b; ; i--)
		if ((a[i] + 3 * (i - 1)) <= 60) 
			break;	
		if (a[i] + 3 * i >= 60) 
			x = a[i]; // ??????? 
		else
			x = 60 - 3 * i; // ??????? 
		cout << x << endl;
		n--;		
	}
	return 0;
}
main()
{
int n,i,j,m;
static int x[100];
scanf("%d",&n);
for(i=1;i<=n;i++)
 {
  scanf("%d",&m);
  for(j=1;j<=m;j++)
     scanf("%d",&x[j]);
  for(j=m; ;j--)
    {if((x[j]+j*3)<=60)
       {printf("%d\n",60-j*3);
        break;}
     if((x[j]+j*3)>60&&(x[j]+(j-1)*3)<=60)
       {printf("%d\n",x[j]);
        break;} }
 }
}
int main(int argc, char* argv[])
{											// n:???  f: ????????
	int n ,i, j, f, NUM, t, num[10],A[10] ; // NUM????? t????? num:?????????? 
	scanf("%d",&n);							// A[10]:?????????				
	for (i=0;i<n;i++)
	{
		NUM=60;
		scanf("%d",&f);
		for (j=0; j<f; j++)
		{   
			scanf("%d", &num[j]);
		}
		for (j=0; j<f; j++)
		{   			
			t = 60 - num[j] - 3 * j;
			
			if (t <= 3 && t > 0)
			{
 				NUM = num[j];
				break;
			}
			else if( t<=0)
			{
				break;
			}
			else if ( t > 3)
			{
				NUM -= 3;
			}
								
		}
		A[i]=NUM;		
	}
	for (i=0;i<n;i++)
	{
		printf("%d\n",A[i]);
	}
	return 0;
}
int main()
{
	int n,m,a[100],t,num;
	int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		t=0;
		num=0;
		scanf("%d",&m);
		if(m==0)
			printf("60\n");
		else
		{
			for(k=0;k<m;k++)
			{
				scanf("%d",&a[k]);
			}
			for(j=0;j<m;j++)
			{
				t=a[j]+3*(j+1);
				if(t>63)
					{
						num=60-3*j;
						break;
					}
				if(t>60&&t<=63)
					{
						num=a[j];
						break;
					}
			}
			if(t<=60)
				num=60-m*3;
			printf("%d\n",num);			
			
		}
	}
	
return 0;
}