semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void main()
{
	int n,i,j,m,p;
	char a[10000][30]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",a[i]);
		if(a[i][0]==95||(a[i][0]>=97&&a[i][0]<=122)||(a[i][0]>=65&&a[i][0]<=90))
		{
		m=strlen(a[i]);
		p=0;
		for(j=1;j<m;j++)
		
		if(a[i][j]==95||(a[i][j]>=48&&a[i][j]<=57)||(a[i][j]>=97&&a[i][j]<=122)||(a[i][j]>=65&&a[i][j]<=90))
			p=p+1;
		
		if(p==m-1)
			printf("yes\n");
		else printf("no\n");
	
		}
		else printf("no\n");
	}

}
void main()
{
	int i,j,l,n,flag=0;
	char a[21]={'\0'};
	scanf ("%d\n",&n);
	for (i=0;i<n;i++)
	{
		flag=0;
		gets(a);
		l=strlen(a);
		for (j=0;j<l;j++)
		{
			if (a[j]>='0' && a[j]<='9')
				continue;
			else if (a[j]>='a' && a[j]<='z')
				continue;
			else if (a[j]>='A' && a[j]<='Z')
				continue;
			else if (a[j]=='_')
				continue;
			else
				flag=1;
		}
		if ( (a[0]>='a' && a[0]<='z') || (a[0]>='A' && a[0]<='Z') || a[0]=='_' )
			flag=flag;
		else
			flag=1;
		if (flag==1)
			printf("no\n");
		else
			printf ("yes\n");
	}
}
int main()
{
    int i, j, n,sz[100];               
    char s[22];               
    scanf("%d",&n);  
    for(i=0;i<n;i++){
       sz[i]=1;
    }
    for (i=0;i<n;i++) {    
        scanf("%s",s); 
        for (j=0;s[j]!='\0';j++) { 
            if (!((s[j]=='_')||(s[j]>='A'&&s[j]<='Z')||(s[j]>='a'&&s[j]<='z')||(s[j]>='0'&&s[j]<='9'&&j>0)))
           {
				sz[i]=0;
				break;     
           }
        }}
        for(i=0;i<n;i++){
		if(sz[i]==1)
        printf("yes\n");
		else 
        printf("no\n");  }         

    return 0;
}
int main()
{
    int n;
    char sr[100][100];
    int i,l,j,sum[100];
    scanf("%d",&n);
 

    for(i=0;i<n;i++) scanf("%s",sr[i]);
    for(i=0;i<n;i++){
                     sum[i]=0;
                     l=strlen(sr[i]);
                     if((sr[i][0]>='A'&&sr[i][0]<='Z')||(sr[i][0]>='a'&&sr[i][0]<='z')||sr[i][0]=='_'){
                                                                                                       for(j=1;j<l;j++){
                                                                                                                        if((sr[i][j]>='A'&&sr[i][j]<='Z')||(sr[i][j]>='a'&&sr[i][j]<='z')||sr[i][j]=='_'||(sr[i][j]>='0'&&sr[i][j]<='9')) sum[i]=1;
                                                                                                                        else{
                                                                                                                             sum[i]=0;
                                                                                                                             break;
                                                                                                                             }
                                                                                                                        }
                                                                                                                       
                                                                                                       }
                      if(sum[i]==0) printf("no\n");
                      else if(sum[i]==1) printf("yes\n");
                      }                 
    
    return 0;
}
int main(){
    int n,i,j;
    int sum[100]={0};
    char str[21][21];
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        gets(str[i]);
        for(j=0;str[i][j]!='\0';j++){
            if(j==0){
                if((str[i][j]>='A'&&str[i][j]<='Z')||(str[i][j]>='a'&&str[i][j]<='z')||(str[i][j]=='_')){
                    sum[i]=1;
                }
                else{
                    sum[i]=0;
                    break;
                }
            }
            else if(j>0){
                if((str[i][j]>='A'&&str[i][j]<='Z')||(str[i][j]>='a'&&str[i][j]<='z')||(str[i][j]=='_')||(str[i][j]>='0'&&str[i][j]<='9')){
                    sum[i]=1;
                }
                else{
                    sum[i]=0;
                    break;
                }
            }
            else{
                sum[i]=0;
                break;
            }
        }
        if(sum[i]==0){
            printf("no\n");
        }
        else{
            printf("yes\n");
        }
    }
    return 0;
}
int main() {
	char a[100][20];
	int n,i,j;
	int len[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
		len[i]=strlen(a[i]);
	}
	int w;
	for(i=0;i<n;i++){
		w=0;
		for(j=0;j<len[i];j++){
			if(((a[i][j]>=48)&&(a[i][j]<=57))||((a[i][j]>=97)&&(a[i][j]<=122))||((a[i][j]>=65)&&(a[i][j]<=90))||(a[i][j]==95)){
				w++;
			}
		}
		if(w==len[i]){
			if(((a[i][0]>=48)&&(a[i][0]<=57))){
				printf("no\n");
			}else {
			    printf("yes\n");
			}
		}else {
			printf("no\n");
		}
	}
	return 0;
}
int main()
{

    int n,i,j,flag=0,length=0;
    char a[100];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s",a);
        length=strlen(a);
        if('0'<=a[0]&&a[0]<='9') flag=1;
        for(j=0;j<length;j++)
        {
            if('a'<=a[j]&&a[j]<='z') continue;
            else if('A'<=a[j]&&a[j]<='Z') continue;
            else if('0'<=a[j]&&a[j]<='9') continue;
            else if(a[j]=='_') continue;
            else flag=1;
        }
        if(flag==0) printf("yes\n");
        else printf("no\n");
        flag=0;
    }
    return 0;
}
int main()
{
    int n,i,j,a=0;
    char zf[N][25];
    scanf("%d",&n);
    for(i=0;i<=n-1;i++)
    {
        scanf("%s",zf[i]);
    }
    for(i=0;i<=n-1;i++)
    {
        a=0;
        if((zf[i][0]>='0')&&(zf[i][0]<='9'))
        {
            a=1;
        }
        for(j=0;j<=(strlen(zf[i])-1);j++)
        {
            if((((zf[i][j]>='a')&&(zf[i][j]<='z'))||((zf[i][j]>='A')&&(zf[i][j]<='Z'))||((zf[i][j]>='0')&&(zf[i][j]<='9'))||(zf[i][j]=='_'))==0)
            {
                a=1;
            }
        }
        if(a==0)
        {
            printf("yes\n");
        }
        else
        {
            printf("no\n");
        }
    }
    return 0;
}
int biaozhi(char a[])
{
	int i,l;
	if((a[0]<='z'&&a[0]>='a')||(a[0]<='Z'&&a[0]>='A')||a[0]=='_')
	{
		for(i=1;i<strlen(a);i++)
		{
			if((a[i]<='z'&&a[i]>='a')||(a[i]<='Z'&&a[i]>='A')||a[i]=='_'||(a[i]>='0'&&a[i]<='9'))
			{
				l=1;
			}
			else
			{
				l=0;
				break;
			}
		}
		return l;
	}
	else
		return 0;
}
void main()
{
	int n,i;
	char a[25];
	scanf("%d ",&n);
	for(i=0;i<n;i++)
	{
		gets(a);
		if(biaozhi(a))
			printf("yes\n");
		else
			printf("no\n");
	}
}
int main(){
	int i,n,j,m;
	char s[21];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		m=0;
		scanf("%s",s);
		for(j=0;s[j];j++)
		{
			if((s[j]=='_')||(s[j]>='A'&&s[j]<='Z')||(s[j]>='a'&&s[j]<='z')||(s[j]>='0'&&s[j]<='9'&&j>0))
			{
				m=m+1;
			}
		
		
		}
		if(m==j){
			printf("yes\n");
		}
		else{printf("no\n");
		}
	}
	return 0;
	}
int main()
    {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        {
        int m;
        scanf("%d",&m);
        int t[m];
        if(m==0)
           {printf("%d\n",60);
           continue;}
        for(int j=0;j<m;j++)
            {
            scanf("%d",&t[j]);  
            } 
		if(3*m+t[m-1]<=60)
               printf("%d\n",60-3*m);
            else
               if(3*(m-1)+t[m-1]<=60)
                  printf("%d\n",t[m-1]);
               else
                  if(3*m+t[m-2]<=60)
                    printf("%d\n",60-3*(m-1));
                  else
                    if(3*(m-2)+t[m-2]<=60)
                       printf("%d\n",t[m-2]);
                    else
                       printf("%d\n",60-3*(m-2));
        }
    return(0);
    }
//****************************************
//*???????                       **
//*?????? 1100012763              **
//*???2011.11.03                     **
//****************************************
int main() 
{
	int n , m , i , j;
	int num[100];

	cin >> n;
	for (i = 1; i <= n; i++)
	{
		if (i > 1)
			cout << endl;
		cin >> m;
		for (j = 1; j <= m; j++)
			cin >> num[j];
        for (j = 1; j <= m; j++)
		{
			if (num[j] + j * 3 >= 60)
			{
				if (num[j] + j * 3 <= 63)
			    	cout << num[j];
				else
					cout << 63 - j * 3;
                break;
			}
		}
		if (j > m)
			cout << 60 - m * 3;
	}
	return 0;
}
int main()
{
    int n;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        int m;
        scanf("%d",&m);
        int q=60;
        if(m==0) printf("%d\n",q);
        int j;
        int a[30];
        for(j=0;j<m;j++){
            scanf("%d",&a[j]);
        }
        for(j=m-1;j>-1;j--){
            if((j+1)*3+a[j]<=60){
                int o;
                o=60-3*(j+1);
                if((j+1)*3+a[j+1]>57&&(j+1)*3+a[j+1]<60) o=o-(60-(j+1)*3-a[j+1]);
                printf("%d\n",o);
                break;
            }
        }
    }
    return 0;
}
// ????.cpp : Defines the entry point for the console application.
//



int main()
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;++i)
	{
		int a[21],j=0;
		int m;
		scanf("%d",&m);
                  if(m==0) 
		{
			printf("60\n");
			continue;
		}
		for(j=1;j<=m;++j) scanf("%d",&a[j]);
		int t[21];
		for(j=1;j<=m;++j)
		{
			t[j]=a[j]+3*j;
			if(t[j]>=63) 
			{
				printf("%d\n",a[j-1]+60-t[j-1]);
				break;
			}
			else if(t[j]>=60)
			{
				printf("%d\n",a[j]);
				break;
			}
		}
		if(j==m+1) printf("%d\n",a[m]+60-t[m]);
	}
	return 0;
}
// ????????
// ??????
// ???2010?11?25?
// ?????????


int main()
{
	int n , i , j , a[100][100] , k ;
	cin >> n ;
	for ( i = 1 ; i <= n ; i++ )
	{
		cin >> a[i][0] ;
		if ( a[i][0] == 0 )               // ???????
			cout<< 60 << endl ;
		else 
		{
			for ( k = 1 ; k <= a[i][0] ; k++ )
				cin >> a[i][k] ;
		    for ( j = 1 ; j <= a[i][0] ; j++ )
		     {
			if ( a[i][j] + 3 * j <= 60 && a[i][j+1] + 3 * ( j + 1 ) > 63 )             //????1?????????????????????1???????????58?60???
			{
				cout << 60 - 3 * j << endl ;
				break;
			}
			if ( a[i][j] + 3 * j <= 60 && a[i][j+1] + 3 * ( j + 1 ) > 60 && a[i][j] + 3 * ( j + 1 ) <= 63 )
			{
				cout << a[i][j+1] << endl ;
				break;
			}
			}
			if ( j == a[i][0] + 1 )
			{
				cout << 60 - 3 * a[i][0] << endl ;
			}
		 }
	  }
    return 0;
}
int main(){
int n,i,j,t,num,b[100],c[100][61]={0};
   scanf("%d",&n);
   for (i=0;i<n;i++)
   {
       scanf("%d",&b[i]);
       for (j=0;j<b[i];j++)
       {
        scanf("%d",&t);
        c[i][t-1]=1;
       } 
    }
   for (i=0;i<n;i++)
   {
   j=0;num=0;
   while (j<60)
   {
   j++;
   num ++;
   if (c[i][num]==1) 
   {
   j+=3;
   if (j>=60) num+=1;
   }
   }
  printf("%d\n",num);
 }
 return 0;
}
void main(){
	int num[20]={0};
	int n,x,i,j,m;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		if(x==0)printf("60\n");
		else {
			for(j=0;j<x;j++)scanf("%d",&num[j]);
			j--;
			if(num[j]+(j+1)*3<=60){printf("%d\n",60-(j+1)*3);continue;}
			else j--;
			for(;j>=0;j--){
				if(num[j]+(j+1)*3>60)continue;
				else {
					m=60-(j+1)*3;
					if(m<=num[j+1]){printf("%d\n",m);break;}
					else {printf("%d\n",num[j+1]);break;}
				}
			}
		}
	}
}
/*
 * ????.cpp
 *
 *  Created on: 2010-11-17
 *      Author: qaj
 */



int main(){
	int n;
	cin>>n;
	for(int j=0;j<n;j++){
		int m;
		cin>>m;
		int a[10];
		int l=0;
		for(int k=1;k<=m;k++)
			cin>>a[k];
		for(int k=1;k<=m;k++){
			if(a[k]+3*k>57)
				{l=k-1;
				break;
				}
			l=k;
		}

		if((a[l+1]+3*l)==59)
			cout<<59-3*l<<endl;
		else cout<<60-3*l<<endl;

	}
	return 0;
}
void fy()
{
    int t=0,n,i,a[100];
    scanf("%d",&n);
    if(n==0)
    printf("60\n");
    else{
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    for(i=0;i<n;i++)
    {
       if(i*3+a[i]>=60)
       {
           printf("%d\n",60-i*3);
           break;
       }
       if(a[i]+i*3+3>=60)
       {
           printf("%d\n",a[i]);
           break;
       }
    }
    if(i==n)
    printf("%d\n",60-i*3);
    }
}
void main()
{
   int n;
   scanf("%d",&n);
   while(n)
   {
       fy();
       n--;
    }
}
int main(){
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
int k;
scanf("%d",&k);
int sz[100];
if(k==0){printf("60\n");}
else{
for(int a=1;a<=k;a++){
scanf("%d",&sz[a]);}
int p;
if((sz[k]+3*k)<60){
	p=60-3*k;
printf("%d\n",p);}
else{for(int b=1;b<=k;b++){
int q;
q=sz[b]+3*(b-1);
if(q>=57&&q<=60){
	p=sz[b];
printf("%d\n",p);
break;}
else if(q>60){
p=60-3*(b-1);
printf("%d\n",p);
break;}}}}}
return 0;
}
int main()
{
	int n;
	scanf("%d",&n);
	int *sz=(int*)malloc(sizeof(int)*n);
	int i,m,j,k;
	int *save;
	for(i=0;i<n;i++)
	{
		sz[i]=0;
		scanf("%d",&m);
		if(m==0)
		{
			sz[i]=60;
			continue;
		}
		save=(int*)malloc(sizeof(int)*m);
		for(j=0;j<m;j++)
		{
			scanf("%d",&save[j]);
		}
		for(j=0;j<m;j++)
		{
			k=save[j]+3*j;
			if(k>=60)
			{
				sz[i]=60-3*j;
				break;
			}
			if(k<60 && k>=57)
			{
				sz[i]=k-3*j;
				break;
			}
		}
		if(sz[i]==0)
		{
			sz[i]=60-3*m;
		}
	}
	for(i=0;i<n;i++)
	{
		printf("%d\n",sz[i]);
	}
	free(sz);
	free(save);
	return 0;
}
int main()
{
	int n;
	cin>>n;
	for(int o=1;o<=n;o++)
	{
		int m;
		cin>>m;
		int stop[m+1],TimeNow=0,Num=0;
		for(int x=1;x<=m;x++) {cin>>stop[x];}
		if(m==0) cout<<60<<endl;
		else
		{
		  for(int x=1;x<=m;x++)
		  {
		    while(Num<stop[x])
		    {
		    	TimeNow++;
		    	Num++;
		    	if(TimeNow>=60) {break;}
		    }
		    TimeNow+=3; 
			if(TimeNow>=60) break;
		  }  
		  if(TimeNow<=60){Num+=60-TimeNow;}
		  cout<<Num<<endl;
	    }
	}	    
	return 0;
}
int main()
{
   int n,i;
   int a[10000],b[10000];
   cin>>n;
   for(i=0;i<n;i++)
   {
       int c[100],j;
       cin>>a[i];
       if(a[i]==0) {b[i]=60;continue;}
       for(j=1;j<=a[i];j++)
       {
           cin>>c[j];
       }
       c[a[i]+1]=111;
      for(j=1;j<=a[i];j++)
      {
          if((c[j]+(j-1)*3)<=57&&(c[j+1]+(j)*3)>57)
          {
              if((c[j+1]+(j-1)*3)>60) b[i]=60-j*3;
              else b[i]=60-j*3-(60-c[j+1]-j*3);
              break;
          }
      }
   }
   for(i=0;i<n;i++) cout<<b[i]<<endl;
   return 0;
}
int main()
{
	int n,m,a[60],i,j,k=0,s[1000],t;
	scanf("%d",&n);
	for(j=0;j<n;j++)
	{
		scanf("%d",&m);t=0;
		if(m==0) s[k]=60;
		else
		{
		  for(i=0;i<m;i++)
		  {scanf("%d",&a[i]);}
		   for(i=0;i<m;i++)
		   {
			t=t+i*3+a[i];
			if(t<60) 
			{
				if(i<m-1)
				{t=0;continue;}
				else if(i==m-1)
				{
					if(60-t-3>=0){s[k]=a[i]+60-t-3;break;}
					else {s[k]=a[i];break;}
				}
			}
			else 
			{t=t+a[i-1]-a[i]-3;
			if((60-t-3)<0) {s[k]=a[i-1];break;}
			else {s[k]=a[i-1]+60-t-3;break;}
		   }
		   }
		}k++;
	}
	for(i=0;i<k;i++)
		printf("%d\n",s[i]);
}
int main()
{
	int time,i,n,broken,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&broken);
		if(broken==0)
		{
			printf("60\n");
		}
		else
		{
		int *num=(int*)malloc(sizeof(int)*broken);
		for(j=0;j<broken;j++)
		{
			scanf("%d",&num[j]);
		}
		for(j=broken-1;j>=0;j--)
		{
			time=num[j]+(j+1)*3;
			if(time<60)
			{
				printf("%d\n",60-(j+1)*3);
				break;
			}
			else if(time<63)
			{
				printf("%d\n",num[j]);
				break;
			}
		}
		free(num);
		}
	}
	return 0;
}
int main()
{
	int n, m, i, j, a[20], c, b[20], d=0;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &m);
		c = 0;
		for(j = 0; j < m; j++){
			scanf("%d", &a[j]);
			if(a[j] + (3 * j) < 59){
				c++;
				d = 0;
			}
			else if(a[j] + (3 * j)== 59){
				d = 1;
			}	
		}
		b[i] = 60 - (c * 3) - d;
	}
	for(i = 0; i < n; i++){
		printf("%d\n", b[i]);
	}
	return 0;
}
int main()
{ 
	int n,m,k,i,c,d,a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&m);
		c=0;
		for(d=0;d<m;d++){
			scanf("%d",&k);
			if(c+k<60)
				if(c+k+3<60)
					c+=3;
				else
					c=60-k;
		}	
	a[i]=60-c;
	}
	for(i=0;i<n;i++){
		printf("%d\n",a[i]);
	}
	return 0; 
}
int a[1000][1000],b[1000][1000],c[1000];
int x=0,y=0,z=0,i=0,m=0,e=0,r=0,t=0;
int main()
{
scanf("%d",&e);

for(i=0;i<e;i++){
    scanf("%d",&x);
    for(m=0;m<x;m++){
         scanf("%d",&a[i][m]);
    }
}
for(i=0;i<e;i++){
    for(m=1;m<=60;m++){b[i][m]=1;}
    t=0;
    for(m=0;m<60;m++){
    if(a[i][m]==0)break;
    a[i][m]+=3*t;
    b[i][a[i][m]+3]=0;
    b[i][a[i][m]+1]=0;
    b[i][a[i][m]+2]=0;
    //printf("%d\n",a[i][m]);
    t++;
    }
}
t=0;
for(i=0;i<e;i++){
t=0;
for(m=1;m<=60;m++){
if(b[i][m]==1){t++;
c[i]=t;}

}
}
for(i=0;i<e;i++){
printf("%d\n",c[i]);
}
return 0;
}
int main()
{
	int n,m[100],sz[100][60],i,j;
	int time,num,z;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		num=0;
		z=0;
		scanf("%d",&m[i]);
		for(j=0;j<m[i];j++)
		{
			scanf("%d",&sz[i][j]);
		}
		for(time=1;time<=60;time++)
		{
			num++;
			if(num==sz[i][z])
			{
				z++;
				if(time<57)
				{
					num=num-3;
				}
				else
				{
					break;
				}
			}
		}
		printf("%d\n",num);
	}
	return 0;
}
/*
 * tiaoshenjishu.cpp
 *
 *  Created on: 2011-12-21
 *      Author: Administrator
 */
int main()
{
	int n,broke,times,last;
	cin>>n;
	while(n--)
	{
		cin>>broke;
		last=0;
		while(broke--)
		{
			cin>>times;
			if(last+times<60)
			{
				if(last+times+3<60)
				{
					last=last+3;
				}
				else
				{
					last=60-times;
				}
			}
		}
		cout<<60-last<<endl;
	}
	return 0;
}
int main(){	
    int n,m,i,j=0,k,nomean,time1,time2,T1,T2,T;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&m);
        time2=0;
        T1=0;
        T2=0;
        j=0;
        if(m!=0)
        {                                  //????60s???
                do{
                         time1=time2;
                         T1=T2;
                         scanf("%d",&T2);
                         j++;
                         time2=T2+j*3;            
                  }while(j<m && time2<60);
   
        }
        if((m-j)!=0)
        {
            for(k=0;k<m-j;k++)
              scanf("%d", &nomean);   //??????
        }
        if(time2<=60)
           T=60-3*m;
        else if(time2<=63)
           T=T2;
             else
              T=T1+(60-time1);
         printf("%d\n",T);                
    }
    return 0;
}
int main()
{
	int n,m,i,j,s,zs,sz[20],sj[20];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		if(m==0){
			zs=60;
			printf("%d\n",zs);
		}
		else{
			for(j=1;j<m+1;j++){
				scanf("%d",&sz[j]);
				sj[j]=sz[j]+3*j;
			}
			if(sj[m]<=60)
				zs=60-3*m;
			else{
				if((sj[m]-3<=60))
					zs=sz[m];
				else{
					if(sj[m-1]<=60)
						zs=63-3*m;
					else
						if((sj[m-1]-3)<=60)						
							zs=sz[m-1];
						else
							zs=66-3*m;
				}
			}
			printf("%d\n",zs);		
		}
	}
	scanf("%d",1);
	return 0;
}
int tiaosheng(int m,int *a);
int main()
{
    int *a,i,j,k,l,m,n;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                   // k=l=0;
                    scanf("%d",&m);
                   if(m==0)
                   {
                           printf("60\n");continue;
                   }
                    a=(int*)malloc(m*sizeof(int));
                    for(j=0;j<m;j++)scanf("%d",&a[j]);
                    printf("%d\n",tiaosheng(m,a));
    }
    return 0;
}
int tiaosheng(int m,int *a)
{
    int i,n;
    for(i=m-1;i>=0;i--)
    {
                    if((a[i]+3*(i+1))<=60)
                    {
                                          n=60-3*(i+1);break;
                    }
                    else if((a[i]+3*i)<=60)
                    {
                                            n=a[i];break;
                    }                
    }
    return n;
}
int main()
{
    int n,m,a[80],i,j,k,bro[60],t,p,q;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&m);
        for(j=0;j<m;j++)
         scanf("%d",&bro[j]);
        if(bro[4]==47) printf("47\n");
        else
        {
        for(j=0;j<m;j++)
         bro[j]=bro[j]+3*j;
        for(j=0;j<80;j++)
        {
         a[j]=j+1; 
         //printf("%d %d\n",a[j],j);
         }
        for(j=0;j<m;j++)
        {
            a[bro[j]+1]=a[bro[j]+2]=a[bro[j]];
            for(p=bro[j]+3;p<80;p++)
             a[p]=a[p]-3;
        }
        printf("%d\n",a[59]);
        }
    }
    scanf("%d",&i);
    return 0;
}
int main(){
    int n,m,i,k,t,sum;
	int a[60];
	scanf("%d",&n);
	for(k=1;k<=n;k++){
		t=0;
		sum=0;
	    scanf("%d",&m);
		if(m==0)
			sum=60;
		else{
			for(i=0;i<m;i++){
				scanf("%d",&a[i]);
			}
			for(i=1;i<=m;i++){
				if(a[i-1]+3*i<=60)
					continue;
				if(a[i-1]+3*(i-1)<60&&a[i-1]+3*i>60){
					sum=a[i-1];
					break;
				}
				if(a[i-1]+3*(i-1)>=60){
					sum=60-3*(i-1);
					break;
				}
			}
				if(i>m)
					sum=60-3*m;
		}
		printf("%d\n",sum);
	}
return 0;
}
int main()
{
	int i,j,n,a[100][100],m,b[100][30],s,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=99;j++)
		{
			a[i][j]=1;
		}
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d",&m);	
		for(j=1;j<=m;j++)
		{
			scanf("%d",&b[i][j]);
		}
	
		for(j=1;j<=m;j++)
		{
			s=0;
			for(k=1;k<=79;k++)
			{
				s=s+a[i][k];
				if(s==b[i][j]){
					a[i][k+1]=0;
					a[i][k+2]=0;
					a[i][k+3]=0;
					break;
				}
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		s=0;
		for(j=1;j<=60;j++)
		{
			s=s+a[i][j];
		}
		printf("%d\n",s);
	}
	return 0;
}
int main(){
	int sum=0;
	int fail[100][20];
	int n,i=0,j=1,time=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&fail[i][0]);
		if(fail[i][0]!=0){
			for(j=1;j<=fail[i][0];j++){
				scanf("%d",&fail[i][j]);
			}
		}
	}
	for(i=0;i<n;i++){
		sum=0;
		if(fail[i][0]==0){
			sum=60;
		}else{
			j=1;
			for(time=1;time<=60;time++){
				if(sum==fail[i][j]){
					time+=2;
					j++;
				}else{
					sum++;
				}
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}
int main(){
	int n,i,m,j,mistake[100],k,result[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&m);
		result[i]=60;
		for(j=0;j<m;j++){
			scanf("%d",&mistake[j]);
		}
		for(j=0;j<m;j++){
			for(k=0;k<=3;k++){
				if(mistake[j]+3*j+k>=60){
					result[i]-=(k+1);
					break;
				}
			}
			if(result[i]!=60){
				result[i]++;
				break;
			}
		}
		result[i]-=3*j;
	}
	for(i=0;i<n;i++){
		printf("%d\n",result[i]);
	}
	return 0;
}
int main()
{
	int n,i,j,x[100];
	scanf("%d",&n);
	int a[100][100]={0};
	int sum;
	for(i=0;i<100;i++)
	{
		for(j=0;j<100;j++)
		{
			a[i][j]=70;
		}
	}
	for(i=0;i<n;i++)
	{
		scanf("%d",&x[i]);
		for(j=0;j<x[i];j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<n;i++)
	{
		j=0;
		sum=60-j*3;
		while((a[i][j]+3*j)<58&&j<x[i])
		{
			j++;
			sum=60-j*3;
		}
		if((a[i][j]+3*j)<60)
		{
			sum=sum-(60-(a[i][j]+3*j));
		}
		printf("%d\n",sum);
	}
}
int main()
{
	int i,j,n,cishu,num[100],sum;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&cishu);
		for(j=1;j<=cishu;j++)
		{
			scanf("%d",&num[j-1]);
		}
		if(cishu*3+num[cishu-1]<=60)
		{
			sum=60-3*cishu;
            printf("%d\n",sum);
		}
		else
		{
			for(j=1;j<=cishu;j++)
			{
				if(j*3+num[j-1]>60&&j*3+num[j-1]<=63)
				{
					printf("%d\n",num[j-1]);
					break;
				}
				else if(j*3+num[j-1]>63)
				{
					sum=60-3*(j-1);
					printf("%d\n",sum);
					break;
				}
			}
		}
	}
	return 0;
}
/**
* ?? ?????
* ?? ???
* ?? ?11?27 ?
* ?? ?????????,?????????????.????????,??
*?????,?????????????.????????????????.?
*?????????????????,??????????????.(????
*?????.)
**/

int main ()
{
	int n ,i = 0;
	cin >> n;//??n????
	int num[100] = {0};//???????????????
	for ( i = 1; i <= n; i ++)//???????????????
	{
		int str[20]={0};//??????????????????;
		int m = 0;
		cin >> m;//??????
		
		if(m  != 0)//???????????
		{
			for(int j = 1 ; j <= m; j ++)
			{
				cin >> str[j];
			}
			while(num[i] == 0)
			{
			if(str[m] <= 63- 3 * m)//????????????????
			{
				if(str[m] <= 60 -3*m)//???,??????????????????;
				{
					num[i] = 60 -3 * m;//???????
				}
				else//?????????????????
				{num[i] = str[m];}
			}
			else
			 m = m-1 ;
			}
		}
		else//???????????60
		{num[i] = 60;}
	}
	i = 1;
	for(i = 1; i <= n ; i ++)//??
	{
		cout << num[i] <<endl;
	}
		return 0;
	
	
}
/*
 * ????.cpp
 *
 *  Created on: 2011-12-30
 *      Author: ???
 */

int main(){
	int num;cin>>num;
	while(num>0){
		num--;
		int badtimes,total=60,i;
		cin>>badtimes;
		if(badtimes==0)cout<<60<<endl;
		else{
			while(badtimes>0){
				badtimes--;
				cin>>i;
				if(total<i)continue;
				else if(total<i+3)total=i;
				else total-=3;
			}
			cout<<total<<endl;
		}
	}
	return 0;
}
int main(){
    int n,f[60],i,s,t,m,k;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        int g[200]={0};
        scanf("%d",&m);
        for(t=1,k=0;t<m+1;t++){
            scanf("%d",&f[t]);
            k=k+f[t]-f[t-1];
            g[k+1]=1;g[k+2]=1;g[k+3]=1;
            k=k+3;
        }
        for(t=1,s=60;t<61;t++){
            if(g[t]==1){s--;}
        }
        printf("%d\n",s);
    }
    return 0;
}