semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
    int n;
    scanf("%d",&n);
    int time,jump,broken,i,j,b,sum[101],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;
}
int main()
{
	int sum[21];
	int n,cishu,standred;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&cishu);
	
	    sum[cishu]=60;
	    for(int k=0;k<cishu;k++){
		    scanf("%d",&sum[k]);
	    }
	    for(int t=0;t<cishu+1;t++){
		    standred=60-sum[t]-3*t;
		    if(standred<0){
			    printf("%d\n",60-3*t);
			    break;
		    }else if(standred>-1 && standred<4 ){
		    	printf("%d\n",sum[t]);
		        break;
		    }
	
		}
	}
	return 0;
}
// ????.cpp : ??????????????
//



int main()
{
	int n,i;
	int m,j,a[100],s;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	  s=0;
	  scanf("%d",&m);
	  for(j=0;j<m;j++)
	  {
	    scanf("%d",&a[j]);
	  }
	  if(m==0){printf("60");}
	  else if(m==1)
	  {
	    if(a[m-1]+3*m<=60)
	    {
	      s=60-3*m;
		  printf("%d",s);
	    } 
		else{printf("%d",a[0]);}
	  }
	  else
	  { 
		 if(a[m-1]+3*m<=60)
	     {
	       s=60-3*m;
		   printf("%d",s);
	     }
	     else if(a[m-1]+3*m>60&&a[m-1]+3*(m-1)<=60)
		 {
		   s=a[m-1];
		   printf("%d",s);
		 }
		 else if(a[m-1]+3*(m-1)>60&&a[m-2]+3*(m-1)<=60)
		 {
			 s=60-3*(m-1);
			 printf("%d",s);
		 }
		 else if(a[m-2]+3*(m-1)>60&&a[m-2]+3*(m-2)<=60)
		 {
		   printf("%d",a[m-2]);
		 }
		 else if(a[m-2]+3*(m-2)>60&&a[m-3]+3*(m-2)<=60)
		 {
		   s=60-3*(m-2);
		   printf("%d",s);
		 }
	  }
	  printf("\n");
	}
	return 0;
}
int main()
{
	int n;
	cin>>n;
	int m;
	int a[21];
	a[0]=0;//????????0?
	int i;
	int times;
	while(n--){
		cin>>m;
		for(i=1;i<=m;i++)cin>>a[i];
		a[m+1]=70;//?????????????????
		for(i=0;i<=m+1;i++){
			if(a[i]+i*3>=60)//??????i???
			{
				break;//??a[m+1]=70???????break
			}
		}//?i-1?????????
		i--;
		times=60-i*3;
		if(times<=a[i+1]);
		else times=a[i+1];
		cout<<times<<endl;
	}
	return 0;
}
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int m;
		scanf("%d",&m);
		if(m==0)
			printf("60\n");
		else
		{
			int *p,j;
			p=(int *)malloc(sizeof(int)*m);
			for(j=0;j<m;j++)
				scanf("%d",&p[j]);
			for(j=m-1;j>=0;j--)
			{
				if((p[j]+3*(j+1))>63)
					continue;
				else if((p[j]+3*(j+1))<60)
				{
					printf("%d\n",60-3*(j+1));
					break;
				}
				else
				{
					printf("%d\n",p[j]);
					break;
				}

			}
			free(p);
		}
		
	}



	
	return 0;
}
int main() 
{ 
int n,m,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",&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;
	cin>>n;
	for (int i=0;i<n;i++)
	{
		int m;
		cin>>m;
		int time=60;
		int temp;
		for (int i=0;i<m;i++)
		{
			cin>>temp;
			if (time-3>=temp)
				time-=3;
			else if (time-3<temp&&time>temp) time=temp;
		}
		cout<<time<<endl;
	}
	return 0;
}
int main() {
	int n,k,bre,i,bPoint,times,time;
	cin>>n;
	for(k=0;k<n;k++){
		cin>>bre;
		times=0;
		bPoint=0;
		time=0;
		for(i=0;i<bre;i++){
			cin>>bPoint;
			if(bPoint+3*i<=60){
				time=bPoint+3*(i+1);
				times=bPoint;
			}
		}
		if(time<=60){
			times+=60-time;
		}
		cout<<times<<endl;
	}
	return 0;
}
int main()
{
	int n,i,j,count,time,k,a[20];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		time=0;
		count=0;
		scanf("%d",&k);
		if(k==0)
			printf("60\n");
		else
		{
			for(j=0;j<k;j++)
			{
				scanf("%d",&a[j]);
			}
			for(j=0;j<k;j++)
			{
				count=a[j];
				time=count+3*j;
				if(time>=57)
					break;
			}	
            if(time>=57 && time<=60)
			{
			    printf("%d\n",count);
			}
			else if(time>60)
			{
                count=count-(time-60);
				printf("%d\n",count);
			}
			else if(time<57)
			{
				count=count+57-time;
				printf("%d\n",count);
			}
		}

	}
	return 0;
}
//**********************************************************
//*   ?  ?   ?: ????.cpp                            *
//*   ?       ?: ? ?                                   *
//*   ? ? ? ?: 2010?10?12?                          *
//**********************************************************
int main()
{
	int n=0,i=0,j=0,a[100][100];
		cin>>n;
	for(i=0;i<n;i++)
	{
		for(j=0;j<100;j++)
			a[i][j]=0;
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<=a[i][0];j++)
			cin>>a[i][j];
	}
	for(i=0;i<n;i++)
	{
		for(j=99;j>=1;j--)
		{
			if(a[i][0]==0)
			{
				cout<<60<<endl;
			    break;
			}
			else if(a[i][j]!=0)
			{
				if(((a[i][j]+j*3)<=60)&&(a[i][j+1]==0))
				{
				    cout<<60-j*3<<endl;
				    break;
				}
				else if(((a[i][j]+j*3)<=60)&&((a[i][j+1]+j*3)>=60)&&a[i][j+1]!=0)
				{
				    cout<<60-j*3<<endl;
				    break;
				}
				else if(((a[i][j]+j*3)<=60)&&((a[i][j+1]+j*3)<60))
				{
					cout<<a[i][j+1]<<endl;
				    break;
				}
			}
		}
	}
	return 0;
}
int main()
{
	int n,a,b=0,i=0;
	int m[1000];
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		if(a==0)
			cout<<60<<endl;
		else
		{
			for(b=0;b<a;b++)
		
				cin>>m[b];

			for(b=0;b<a;b++)
			{
				if((m[b]+(b+1)*3)>=60 ) 
				{	cout<<m[b];
				break;}
				if(((m[b]+(b+1)*3)<60)&&((m[b+1]+(b+2)*3)>60))

				{    if((m[b+1]+(b+1)*3)<=60)
				{   cout<<m[b+1]<<endl; break;}
				else
				{cout<<(60-(b+1)*3)<<endl;
				break;};}
			}
			if((m[a-1]+a*3)<60)
				cout<<(60-a*3)<<endl;
		
		}
	}
	return 0;
}
int main()
{
    int n;
    cin >> n;
    const int kMaxSeconds = 60;
    
	for (int i = 0; i < n; ++i)
    {
        int interuptCount;				// ??????   
        int interuptNum;				// ???????????
        cin >> interuptCount;
        
		// lostNum: ???????????
        int lostNum = 0;
        for (int j = 0; j < interuptCount; ++j)
        {
            cin >> interuptNum;             // ??????????????0???? = ??????? + ????????
            int sec = interuptNum + lostNum;
            // ???????????
            //     ??????60???????
            //     ??????60?
            
			if (sec < kMaxSeconds)
                if ((kMaxSeconds - sec) > 3)
					lostNum += 3;
				else
					lostNum += kMaxSeconds - sec;
        }
        cout << kMaxSeconds - lostNum << endl;
    }
	 return 0;
}
int main (){
	int n,m,sum,t,shen,d;
	int ci[100];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&m);
		if(m==0){
			printf("60\n");
		}else {
		for(int a=0;a<m;a++){
			scanf("%d",&ci[a]);
		}
		for(int b=0;b<m;b++){
			sum=b+1;
			t=ci[b]+3*sum;
			if(t>63){
				shen=60-3*b;
				printf("%d\n",shen);
				break;
			}else if(b==m-1&&t<=60){
				shen=60-3*sum;
				printf("%d\n",shen);
			}else if(t>60&&t<=63){
				d=t-60;
				shen=60-3*sum+d;
                printf("%d\n",shen);
				break;
			}
		}
	}
	}
	return 0;
}
int main()
{
    int n,i,j;
    scanf("%d", &n);
    int a[21],b[100];
    for(i=0;i<n;i++){
       scanf("%d",&a[0]);
       for(j=1;j<a[0] + 1;j++){
           scanf("%d",&a[j]);
       }
       a[a[0] + 1] = MORE; 
    int sum = 0;    
    int time = 0; 
    int k = 0;    
    while(true)
    {
           k ++;
           if (k > 1)
              time += 3;
           if (time >= MIN)
              break;
           time = 3 * (k - 1) + a[k];
           if (time >= MIN)
           {
              sum = MIN - 3 * (k -1);
              break;
           }
           sum = a[k];
       }
        b[i] = sum;    
    }
    for (int i = 0; i < n; i++)
       printf("%d\n", b[i]);
}
int main()
{
	int n,i,a[100],b[100],j,t,m;
	scanf("%d",&m);
	for(int l=0;l<m;l++)
	{
	scanf("%d",&n);
		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;
}
int main ()
{
    int n;
    cin >>n;
    for (int j=1;j<=n;j++)
    {
        int m;
        int ans=60;
        int a[30];
        cin >>m;
        for (int i=1;i<=m;i++)
            cin >>a[i];
        for (int i=1;i<=m;i++)
        {
            if (a[i]+3*(i-1)>=60)
                break;
            if (a[i]+3*i>=60)
            {
                ans=a[i];
                break;
            }
            ans=ans-3;
        }
        cout <<ans<<endl;
    }
    return 0;
}
/*
 * 123.cpp
 *
 *  Created on: 2010-12-18
 *      Author: 378073652
 */


int main(){
	int n,m,i,j,a,s=0,num=60;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>m;
		for(j=1;j<=m;j++){
			cin>>a;
			if(a+s<=57) {s=s+3;num=num-3;}
			if(a+s==58||a+s==59||a+s==60) num=a;
			
			
		}
		cout<<num<<endl;
		num=60;
		s=0;
	}
}
int main()
{  
	int n,m;
    scanf("%d",&n);
	int i,j;
	int a[100];  int b[100]={0};  int c[100]={0};
	int d[100]={0};
	int e,f,h;
	for(i=0;i<n;i++)
	{ 
		scanf("%d",&m);
		if(m==0)
			printf("60\n");
		else
		{
		for(j=0;j<m;j++)
		{
        scanf("%d",&a[j]);
        e=a[j]+3*j;
		h=e+3;
        
	  
		if(e<= 60 && h < 60)
					
			{
				
				f=60-3*(j+1);
				continue;
			}

		if(e <= 60 && h >= 60)
		{
		f =a[j];
	   
		}   continue;
		if(e>60)
        {
		f=60-3*j;
		continue;
		}	


			
		}
		printf("%d\n",f);
			

		
	}
	}

	return 0;
}
int main()
{
    int n,m,s,p,i,j,c;
    scanf("%d",&n);
    for(c=1;c<=n;c++)
    {
        s=0; 
        scanf("%d",&m);
        for(i=0;i<=m;i++)
        {
            if(m==0) p=60;
            else if(i==0&&m!=0) continue;
            if(i>0) scanf("%d",&p); 
            if(3*(i-1)+s<60&&i<m)
            {
                if(3*(i-1)+p<=60) s=p;
                else s=60-3*(i-1);
            }
            else
            {
                if(3*(i-1)+p<=60&&i==m)
                {
                    if(3*i+p<=60)s=60-3*i;
                    else s=60-3*(i-1)-(3-(3*i+p-60));
                }
                else
                if(3*(i-1)+p>60&&i==m)
                {
                    if(3*i+s<=60)s=60-3*(i-1);
                    else s=60-3*(i-1)-(3-(3*i+s-60));
                } 
            } 
        }
        printf("%d",s);
        if(c<n) printf("\n"); 
    }

    return 0;
}
int main(int argc, char* argv[])
{
	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]=1;
		}
	}
    for (i=0;i<n;i++){
		j=0;num=0;
		while (j<60){
			j+=1;
            num+=1;
            if(count[i][num-1]==1) {
				j+=3;
				
			};
		}
		printf("%d\n",num);
	}
	return 0;
}
int main()
{
	int n , i , j , jump[ 20 ] = { 0 } , m ;

	cin >> n ;

	for( i = 1 ; i <= n ; i ++ )
	{
		memset( jump , 0 , sizeof( jump ) ) ;

		cin >> m ;

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

			if( 3 * m + jump[ m - 1 ] <= 60 )
				cout << 60 - 3 * m << endl;
			else
			{
				j = 0 ;
				
				for( j = 0 ; 3 * ( j + 1 ) + jump[ j ] <= 60 ; j ++ ) ;
				
			//	cout << "j=" << j << endl ;

				if( 3 * ( j + 1 ) + jump[ j ] > 63 )
					cout << 60 - 3 * j << endl ;
				else
					cout << jump[ j ] << endl ;
			}
		}
	}
	return 0 ;
}
int main(){
  int n,i,m,j,x=60;
  scanf("%d",&n);
  for(i=0;i<n;i++,x=60){
    scanf("%d",&m);if(m==0){printf("60\n");continue;}
    int p[m];
    for(j=0;j<m;j++){
      scanf("%d",&p[j]);
    }
    for(j=0;j<m;j++){
      if(p[j]>=x){printf("%d\n",x);break;}
      if(p[j]<x&&p[j]>=x-3){printf("%d\n",p[j]);break;}
      if(p[j]<x-3){x-=3;}
    }
    if(j==m){printf("%d\n",x);}
  }
  return 0;
}
int main()
{
	int n,t,i,tem,sum,p=0;
	scanf("%d",&n);
	while (n-->0)
	{
		scanf("%d",&t);
		if (t==0)
		{
			printf("60\n");
			continue;
		}
		sum=0;
		p=0;
		for (i=0;i<t;i++)
		{
			scanf("%d",&tem);
			sum=(i+1)*3+tem;
			if (sum>=60&&p==0)
				if (sum<=63&&p==0)
				{
					printf("%d\n",tem);
					p=1;
				}
				else
				{
					printf("%d\n",60-i*3);
					p=1;
				}
		}
		if (p==0) 
			if (tem+t*3>=60)
                printf("%d\n",tem);
			else
				printf("%d\n",60-3*t);
	}
	return 0;
}
int main()
{
   int x,a[100],b[100][100],i,j,m[100];
   cin>>x;
   for(i=0;i<x;i++)
   m[i]=60;   
   for(i=0;i<x;i++)
   {
	   cin>>a[i];
	   for(j=0;j<a[i];j++)
		   cin>>b[i][j];
   }
   for(i=0;i<x;i++)
   for(j=0;j<a[i];j++)
   {
	   if(b[i][j]<=57-3*j)m[i]=m[i]-3;
	   else if(b[i][j]==58-3*j)m[i]=m[i]-2;
       else if(b[i][j]==59-3*j)m[i]=m[i]-1;
	   else if(b[i][j]==60-3*j)m[i]=m[i];
   }
   for(i=0;i<x;i++)
	   cout<<m[i]<<endl;
}
int main()
{
	int i,j,m,n,t=0,s=0;
	int a[20];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		s=0;
		t=0;
		memset(a,0,sizeof(a));
		scanf("%d",&m);
		for(j=0;j<m;j++)
		{
			scanf("%d",&a[j]);
		}
		for(j=0;j<m;j++)
		{
			s=a[j]+j*3;
			t=a[j];
			if(s>60)
			{
				t=60-j*3;
				break;
			}
			s=s+3;
			if(s>60)
			{
				break;
			}
		}
		if(s<60)
		{
			t=t+60-s;
		}
		printf("%d\n",t);
	}
	return 0;
}
/*
 * ????.cpp
 *
 *  Created on: 2011-12-24
 *      Author: Administrator
 */

int main()
{
	int n,i,m,num[60]={0};
	cin>>n;
	while(n>0){
		n--;
		cin>>m;
		for(i=0;i<=m;i++)num[i]=60;
		for(i=0;i<m;i++){
			cin>>num[i];

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

		cout<<num[m]<<endl;
	}
	return 0;
}
int main()
{
	int n, cs[999], num[99], result = 60;
	int i, j;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &cs[i]);
		for(j = 0; j < cs[i]; j++){
			scanf("%d", &num[j]);
			if(num[j] < (result - 3)){
				result -= 3;
			}
else if(num[j] >= (result - 3) && num[j] < result){
				result = num[j];
			}
		}
		cs[i] = result;
		result = 60;
	}
	for(i = 0; i < n; i++){
		printf("%d\n", cs[i]);
	}
	return 0;
}
int main()
{
	int n,m;
	int a[10000];
	int i,j,k,cs[10000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		for(j=0;j<m;j++)
		{
			scanf("%d",&a[j]);
		}
		if(a[m-1]+3*m<60)
			cs[i]=60-3*m;
		if(a[m-1]+3*m>=60)
		{
			for(k=m-1;k>=0;k--)
			{
				if((a[k]+3*(k+1))<=60)
					break;
			}
			if(60-(a[k]+3*(k+1))+a[k]>a[k+1])
				cs[i]=60-3*(k+1)-1;
			else cs[i]=60-3*(k+1);

		}
			
	}
	for(i=0;i<n;i++)
		printf("%d\n",cs[i]);




	return 0;

}
int main()
{
	int n,i,t;
	cin>>n;
	while(n!=0)
	{
		n--;
		int time=0,num=0,count=0;
		cin>>t;

		if(t==0)
			cout<<60<<endl;
		else
		{
			int *p=&t;
			int a[*p];
			for(i=0;i<t;i++)
				cin>>a[i];
			//cout<<"t="<<t<<' ';
			for(i=0;i<t;i++)
			{
				if((a[i]+3*(count+1))>=60)
				{
					//cout<<"********"<<"a[i]="<<a[i]<<' ';
					if((a[i]+3*count)>=60)
					{
						num=a[i-1]+60-time;
						break;
					}
					else
					{
						num=a[i];
						break;
					}
				}
				count++;
				time=a[i]+3*count;
				//cout<<"time="<<time<<' ';
				num=a[i];
				if(i==t-1)
					num+=60-time;
				//cout<<"i="<<i<<' '<<a[i]<<' ';
			}
			cout<<num<<endl;
		}
	}
	return 0;
}
int main()
{
	int n,i,j,k;
	struct sutdent
	{
		int faulttimes,fault[100],total,timespace[200];
	}data[100];
	for(i=0;i<100;i++)
	{
		data[i].faulttimes=0;
		for(j=0;j<100;j++)
		{
			data[i].fault[j]=0;
		}
		data[i].total=60;
		for(j=1;j<200;j++)
		{
			data[i].timespace[j]=1;
		}
	}
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&data[i].faulttimes);
		if(data[i].faulttimes==0)
		{
			continue;
		}
		else
		{
		    for(j=0;j<data[i].faulttimes;j++)
			{
			    scanf("%d",&data[i].fault[j]);
			}
		}
	}
	for(i=0;i<n;i++)
	{
		if(data[i].faulttimes==0)
		{
			continue;
		}
		else
		{
			for(j=0;j<data[i].faulttimes;j++)
			{
			    data[i].timespace[data[i].fault[j]+1+3*j]=0;
				data[i].timespace[data[i].fault[j]+2+3*j]=0;
				data[i].timespace[data[i].fault[j]+3+3*j]=0;
			}
			for(k=1;k<=60;k++)
			{
				if(data[i].timespace[k]==0)
				{
					data[i].total--;
				}
			}
		}
	}
	for(i=0;i<n;i++)
	{
		printf("%d\n",data[i].total);
	}
	
	return 0;
}
int main()
{
	int n,times,a[60],k,i;
	scanf("%d",&n);
	while(n>0)
	{
		n--;
		scanf("%d",&k);
		for(i=0;i<k;i++)
			scanf("%d",&a[i]);
		times=60;i=0;
		while(i<k&&a[i]<times)
		{
			if(times-3<a[i]) times=a[i];
			else times=times-3;
			i++;
		}
		printf("%d\n",times);
	}
}
int main(){
	int num;
	cin>>num;
	while(num){
	int fail;
	cin>>fail;
	if (fail==0) cout<<"60"<<endl;
	else{
	int n[fail];
	for(int i=0;i<fail;i++)
		cin>>n[i];
	int t=0;
	for(int i=0;i<fail;i++){
		t=n[i]+3*(i+1);
		if (63>t&&t>60){
			cout<<n[i]<<endl;
			break;//????3????
		}
		else if(t>=63){
			cout<<60-3*i<<endl;
			break;//??
		}
		else if (i==fail-1) cout<<60-3*(i+1)<<endl;//???????
	}
	}
	num--;
	}
	return 0;
}
int main()
{
	int n,i=0,b[100],j=1,t,m,k=0,l;//b[]????
	scanf("%d",&m);
	for(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]);
		}
		i=0;
		t=0;
		for(j=1;j<=100;j++)
		{
			b[j]=t+1;
			t=b[j];
			if(b[j]==a[i])//???
			{
				i++;
				for(k=0;k<3; k++)//b??????????????
					b[++j]=t;
			}
		}
		printf("%d\n", b[60]);
	}
	return 0;
}
int main()
{
	int n,i,j,m,k[100]={0},count=0,tt;
	cin>>n;
	for(i=0;i<n;i++)
	{
		count=0;
		cin>>m;
		for(j=0;j<m;j++)
		{
			cin>>k[j];
		}
		if(m==0)
			tt=60;
		else if(k[j-1]+3*j<=60)
		{
		tt=60-j*3;	
		}
		else if(k[0]>=60)
			tt=60;
		else
		{
			for(j=0;j<m;j++)
			{
				if(k[j]+3*(j+1)>=60 && k[j]+3*j<=60)
				{
					tt=k[j];
					break;
				}
				else if(k[j]+3*(j+1)<60 && k[j+1]+3*(j+1)>60)
				{
					tt=60-3*(j+1);
					break;
				}
			}
		}
		cout<<tt<<endl;
	}
	return 0;
}
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int m,j;
		scanf("%d",&m);
		int*sz
			=(int*)malloc(sizeof(int)*m);
		for(j=0;j<m;j++)
		{
			scanf("%d",&sz[j]);
		}
		int sum;
		for(j=0;j<m;j++)
		{
			sum=sz[j]+3*(j+1);
	        if((63-sum)<=3&&(63-sum)>=0)
			{printf("%d\n",sz[j]);
			break;}
			if(sum>63)
			{
				printf("%d\n",60-3*j);
				break;
			}
		}
	    if((sz[m-1]+3*m)<60)
		{printf("%d\n",60-3*m);}
	}
	return 0;
}
/*????:????
 *??:???
 *??:2010/11/26
 *??:1000010449
 */
int main()
{
	int n, i, j, count, x[20];

	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> count;
		if (count == 0)
			cout << 60 << endl;
		else
		{
			x[0] = 0;
			for (j = 0; j < count; j++)
				cin >> x[j];
		
			for (j = 0; j < count; j++)
			{
				if (x[j] + 3 * j > 60)
					break;
			}
			j--;

			if (60 - x[j] - 3 * (j + 1) <= 0)
				cout << x[j] << endl;
			else
				cout << 60 - 3 * (j + 1) << endl;
		}
	}

	return 0;
}
int main()
{
	int n,i,j,m,t[10],s,k=60;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		if(m==0)
			printf("%d\n",k);
		else if(m>0)
		{
			for(j=0;j<m;j++)
			{
				scanf("%d",&t[j]);
				if((t[j]+3*(j+1))<=60)
					s=t[j]+60-(t[j]+3*(j+1));
				else if((t[j]+3*j)<=60)
					s=t[j];
			}
			printf("%d\n",s);
		}
	}
	return 0;
}
int main()
{
	int n,m,t,sum,num[10000],a[10000],i,j;
	scanf("%d",&n);
	for(i=1;i<=10000;i++){
		num[i]=0;
		a[i]=1;
	}
	for(i=1;i<=n;i++){
		scanf("%d",&m);
		if(m==0){
			printf("60\n");
		}else{
			sum=0;
			for(j=1;j<=m;j++){
				scanf("%d",&num[j]);
			}
			for(j=1;j<=m;j++){
				num[j]+=3*(j-1);
				t=num[j];
				a[t+1]=0;
				a[t+2]=0;
				a[t+3]=0;
			}
			for(j=1;j<=60;j++){
				sum+=a[j];
			}
			printf("%d\n",sum);
			for(j=1;j<=10000;j++){
				num[j]=0;
				a[j]=1;
			}
		}
	}
	return 0;
}
int main(){
    int n,i,j;
    cin>>n;
    int aa[n+100][60],bb[n+100];
    for(i=1;i<=n;i++){
     cin>>aa[i][0];
     if(aa[i][0]==0)
       bb[i]=60;
       else{
      for(j=1;j<=aa[i][0];j++)
         cin>>aa[i][j];
         j--;
         if(aa[i][j]+3*j<60)
         bb[i]=60-j*3;
         else{   
                 for(j=1;j<=aa[i][0];j++){
                 if(aa[i][j]+3*j>63){
                     bb[i]=63-j*3;
                     break;
                     }
                  if(aa[i][j]+3*j>=60&&aa[i][j]+3*j<=63)
                   { bb[i]=aa[i][j];
                    break;
                    }
                    }
                    }
                    }
                    }
         for(i=1;i<=n;i++)
         cout<<bb[i]<<endl;
             return 0;
         }
int main(){
    int m;
    scanf("%d",&m);
    int*n=(int*)malloc(sizeof(int)*m);
    int a,i;
    for(i=0;i<m;i++){
        scanf("%d",&a);
        int*b=(int*)malloc(sizeof(int)*a);
        if(a==0){
            n[i]=60;
            printf("\n");
        }
        else{

            int j;
            for(j=0;j<a;j++){
                scanf("%d",&b[j]);
            }
     int sum=61;
     int k;
     for(k=a;k>=0&&sum==61;k--){
         if(60<(k*3+(b[k-1]))&&(k*3+(b[k-1]))<+63){
             sum=b[k-1];
         }
         else if((k*3+(b[k-1]))<=60){
             sum=60-k*3;
         }
     }
     n[i]=sum;
     free(b);
     printf("\n");
     }
   }
     int c;
     for(c=0;c<m;c++){
         printf("%d\n",n[c]);
     }
     free(n);
     return 0;
}
int main()
{
	int n,i;
	cin >> n;
	for(i=0;i<n;i++)
	{
		int a[10];
		int j;
		cin >> a[0];
		for(j=1;j<=a[0];j++)
			cin >> a[j];
		if(a[0]==0)
			cout << 60 << endl;
		else
		{
			for(j=1;j<=a[0];j++)
				if(a[j]+3*j>=60 && a[j]+3*j<=63)
				{cout << a[j] << endl;break;}
				else
					if(a[j]+3*j>63)
					{cout << 63-3*j << endl;break;}
			if(j==a[0]+1)
				cout << 60-3*a[0] << endl;		
		}
	}
	return 0;
}
int main()
{ 
int m,n,i,j,k,p,a[240],b[240],sum[100];
cin>>n;
for(i=0;i<100;i++)
{sum[i]=0;
}
  for(k=0;k<n;k++)
  {
	   for(i=0;i<240;i++)
	{
		a[i]=0;
	}
	    
	   cin>>m;
	   for(i=0;i<m;i++)
	{
		cin>>b[i];
			p=b[i];
			a[p-1]=1;
	}
	for(i=0;i<237;i++)
	{
		if(a[i]!=0)
		{
			for(j=237;j>=i+3;j--)
			{
				a[j]=a[j-3],a[j+1]=a[j-2],a[j+2]=a[j-1];
			}
			a[i+1]=1,a[i+2]=1,a[i+3]=1,a[i]=0;
			i=i+3;
		}
	}
	for(i=0;i<60;i++)
	{
		sum[k]=sum[k]+a[i];
	}
	sum[k]=60-sum[k];
	
   }
  cout<<sum[0];
  for(k=1;k<n;k++)
	  cout<<endl<<sum[k];
}
/*
 *????1049 ????
 *?????
 *??: 2010-12-15
 */


int main (){
    int num,i;//??????
    int m,n=0,t=0;//m???????n?????t????
    int j[20];
    cin>>num;
    while(num>0){
    	cin>>m;
    	if(m==0) cout<<60<<endl;//????????60
    	else{
    		for(i=0;i<m;i++)
    			cin>>j[i];
    		for(i=0;i<m;i++){
    			if(j[0]>60){
    				cout<<60<<endl;
    				break;
    			}
    			n=j[i];
    			t=3*i+j[i];
    			if(t+3>60){//??????????60,????????
    				cout<<n<<endl;//??
    				break;//??
    			}
    			t=t+3;
    			if(i==m-1){
    				n=n+(60-t);//????????
    				cout<<n<<endl;//??
    				break;//??
    			}
    			else {
    				if(t+j[i+1]-j[i]>60){//????????????????
    					n=n+(60-t);
    					cout<<n<<endl;//??
    					break;//??
    				}
    			}
    		}
    	}
    	num--;
    }
	return 0;
}
int main(){
	int n;
	cin>>n;
	int sum[n];
	for(int i=0;i<n;i++){
		int m=0;
		cin>>m;
		if(m==0){
			sum[i]=60;
			continue;
		}
		int a[m];
		for(int j=0;j<m;j++)
			cin>>a[j];
		for(int j=0;j<m;j++){
			if(a[j]+3*j<=60&&a[j]+3*(j+1)>=60){
				sum[i]=a[j];break;}
			else if(a[j]+3*j<=60&&a[j]+3*(j+1)<60&&j==m-1){
				sum[i]=60-3*(j+1);break;}
			else if(a[j]+3*j>60){
				sum[i]=60-3*j;break;}

		}
	}
	for(int i=0;i<n;i++){
		cout<<sum[i]<<endl;
	}
	return 0;
}
int main()
{
    int d,c,n,m,i,j,k,a[20],b[100];
	cin>>n;
    for(i=0;i<n;i++)
		{cin>>m;
	    if(m==0) {b[i]=60;continue;}
		for(j=0;j<m;j++)
		    {cin>>a[j];}
		if(a[m-1]<=(60-m*3))
		    {b[i]=(60-m*3);}
		else 
			{ {for(k=m-1;;k--)
			 if(a[k]+(k+1)*3<=60) break;}
		      c=60-((k+1)*3);
			  if(c<=a[k+1]) b[i]=c;
			  else b[i]=a[k+1];}
	       }
	  for(i=0;i<n;i++) cout<<b[i]<<endl;
	return 0;
}