semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
/**
* @file homework.cpp
* @author ??
* @date 2010?11?26
* @description
* ??????:1049 ???? 
*/
int main()
{
	int n, i, j, m, sum=0 ;
	cin >> n;
	int a[100];
	for (i=0;i<n;i++)
	{
		cin >> m;
		sum = 0;
		if (m==0)
			cout << "60" << endl;
		else
		{
		for (j=0;j<m;j++)
		{
			cin >> a[j];
		}
		for (j=0;j<m;j++)
		{
			if (a[j] < 59)
				sum += 3;
			if (a[j]+sum > 63)
			{
				sum -= 3;
				cout << 60 - sum << endl;
				break;
			}
			else 
			{
				if (a[j]+sum > 60)
				{
					
				cout << a[j] << endl;
				break;
				}
				if (j==m-1)
				 cout << 60 - sum <<endl;
			}
		}
		}		
	}
	return 0;

}
int main()
{
	int n, m, time=0, i, x, j, mark;
	scanf("%d", &n);
	for(i=0;i<n;i++)
	{
		scanf("%d", &m);
		if(m!=0)
		{
		for(j=1;j<m+1;j++)
		{
			scanf("%d", &x);
			if(time<60&&x+3*(j-1)>=60)
			{
				mark=60-3*(j-1);
			}
			if(time<60&&x+3*(j-1)<60&&x+3*(j-1)>57)
			{
				mark=x;
			}
			if(time<60&&x+3*j<60)
			{
				mark=60-j*3;
			}
			time=x+j*3;
		}
		}
		if(m==0)
		{
			mark=60;
		}
		printf("%d\n", mark);
	}
		return 0;
}
int main()
{
	int n,i,j;
	int m,*p;
	int sum=60;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		sum=60;
		scanf("%d",&m);
		if(m>0)
		{
			p=(int*)malloc(sizeof(int)*m);
			for(j=0;j<m;j++)
			{
				p[j]=0;
				scanf("%d",&p[j]);
				if(p[j]+3*j<58)
					sum-=3;
				if(p[j]+3*j == 58|| p[j]+3*j == 59|| p[j]+3*j == 60)
					sum = p[j];	
			}
			printf("%d\n",sum);
			free(p);
		}
		else
			printf("%d\n",sum);
	}
	return 0;
}
void main()
{
	int i,j,n,m[100],k,num[100],f[100][100],count[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&m[i]);
		for(j=0;j<m[i];j++)
			scanf("%d",&f[i][j]);
	}
	for(i=0;i<n;i++)
	{
		count[i]=0;
		num[i]=0;
		for(j=1;j<=60-count[i];j++)
		{
			for(k=0;k<m[i];k++)
				if(j==f[i][k])
					{
						count[i]+=3;
						break;
					}
			num[i]++;
		}
	}
	for(i=0;i<n;i++)
		printf("%d\n",num[i]);
}
void main()
{
	int n, i, j, k=0, fake[100], count[100][100];
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d", &fake[i]);
		for(j=0;j<fake[i];j++){
			scanf("%d", &count[i][j]);
		}
	}
	for(i=0;i<n;i++){
		if(fake[i] == 0){
			printf("60\n");
		}
		else{
			for(j=0;j<fake[i];j++){
				if((count[i][j]+(j+1)*3)>=60){
					if(count[i][j]<(60-3*j)){
						printf("%d\n", count[i][j]);
						break;
					}
					else{
						if(j != 0){
							printf("%d\n", 60-3*j);
							break;
						}
						else{
							printf("60\n");
							break;
						}
					}
				}
				k+=1;
			}
			if(k == fake[i])
			printf("%d\n", 60-3*fake[i]);
			k = 0;
		}
	}
}
int main()
{
    int n,k,i,j;
    int a[100];
    for(i=0;i<100;i++)
        a[i]=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        int m=0;
        scanf("%d",&m);
        if(m==0)
            a[i]=60;
        else
        {
             for(j=0;j<m;j++)
        {
            scanf("%d",&k);
            if((k+(j+1)*3)<=60)
            {
                a[i]=60-(j+1)*3;
            }
            else if((k+(j+1)*3)>60)
            {
                if(k<a[i])
                {
                    a[i]=k;
                }
            }
        }
        }
    }
    for(i=0;i<n;i++)
    {
        printf("%d\n",a[i]);
    }
   
    return 0;
}
int main ()
{
	struct point 
	{
		int m;
		int a[20];
	}p[80];
	int x[80];
	int n;
	scanf ("%d",&n);
	int i,j;
	for (i=0;i<n;i++)
	{
		scanf ("%d",&p[i].m);
		if (p[i].m==0){x[i]=60;}
		if (p[i].m!=0)
		{
			for (j=0;j<p[i].m;j++)
			{
				scanf ("%d",&p[i].a[j]);
				if ((j==p[i].m-1)&&((p[i].a[j]+j*3)<60))
				{
					if ((p[i].a[j]+j*3+3)<=60)
					{
						x[i]=60-3*p[i].m;
					}
					if ((p[i].a[j]+j*3+3)>60)
					{
						x[i]=p[i].a[j];
					}
				}
				if (((p[i].a[j]+j*3)>=60)&&((p[i].a[j-1]+j*3-3)<60))
				{
					if ((p[i].a[j]+j*3)==60){x[i]=p[i].a[j];}
					if ((p[i].a[j]+j*3)>60)
					{
						if ((p[i].a[j-1]+j*3)<60){x[i]=60-(p[i].a[j-1]+j*3)+p[i].a[j-1];}
						if ((p[i].a[j-1]+j*3)>=60){x[i]=p[i].a[j-1];}
					}
				}
			}
		}
	}
	for (i=0;i<n;i++)
	{
		printf ("%d\n",x[i]);
	}
	return 0;
}
int main()
{
	int n;
	cin>>n;
	int k;
	int a[61];
	while(n--)
	{
		cin>>k;
		if(k==0)  {cout<<"60\n";continue;}
		for(int i=1;i<=k;i++)
			cin>>a[i];
		int num=0;
		for(int i=k;i>=1;i--)
		{
			if( a[i]+i*3-3>60 ) continue;
			if(a[i]+i*3>=60) {num=a[i];break;}
			else {num=60-i*3;break;}
		}
		cout<<num<<endl;
	}
  return 0;
}
void main(){
	int i,j,num,count[10]={0};
	int stopskip[10][21]={0};
	scanf("%d",&num);
	for (i=1;i<=num;i++){
	    for (j=0;j<=stopskip[i][0];j++)
		   scanf("%d",&stopskip[i][j]);
	}
	for (i=1;i<=num;i++){
		if (stopskip[i][0]==0)
		count[i]=time;
	else if (stopskip[i][0]==1){
		if (stopskip[i][1]>=time)
			count[i]=time;
		else if (stopskip[i][1]<time&&stopskip[i][1]>=time-3)
			count[i]=stopskip[i][1];
		else count[i]=time-3;
	}
	}
	for (i=1;i<=num;i++){
		for (j=stopskip[i][0];j>1;j--){
	        if (((stopskip[i][j]+3*(j-1))>time)||(stopskip[i][j]==0))
	            continue;
		    else if ((stopskip[i][j]+3*(j-1)>time-3)&&(stopskip[i][j]+3*(j-1)<=time)){
				count[i]=stopskip[i][j];
				break;
			}
		    else{
				count[i]=(time-(stopskip[i][j]+3*j)+stopskip[i][j]);
	       break;
			}
		}
	}
for (i=1;i<=num;i++)
printf("%d\n",count[i]);
}
int main(){
    int n,m,i,l,x;
    int a[20];
    scanf("%d",&n);
    for(l=0;l<n;l++){
                     x=0;
                     scanf("%d",&m);
                     for(i=0;i<m;i++){
                                      scanf("%d",&a[i]);                 
                     }
                     for(i=0;i<m;i++){
                                      if((60-a[i]-x)>=3){
                                                        x+=3;               
                                      }
                                      if(((60-a[i]-x)<3)&&((60-a[i]-x)>0)){
                                                                           x=60-a[i];                                     
                                      }                 
                     }  
                     printf("%d\n",60-x);               
    }
    return 0;
    }
int main()
{
	int a[60];
	int n,m, i = 0, j = 0, count = 60;
	scanf("%d", &m);
	for (j = 0; j < m; j++)
	{
		count = 60;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	for (i = 0; i < n; i++)
	{
		if (a[i] < count)
		{
			if (a[i] < count - 3)
			{
				count -= 3;
			}
			else
			{
				count = a[i];
				break;
			}
		}
		else
			break;
	}

	printf("%d\n", count);
	}
	return 0;
}
int main()
{
	int m,n,a,c,t,i,j,b[50],d;
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d",&n);
		t=0;
		c=60;
		for(j=0;j<n;j++)
		{
			scanf("%d",&a);
			t=a+(j+1)*3;
			if(t>59){
				j++;
				break;
			}
			c-=3;
		}
		for(;j<n;j++){
			scanf("%d",&d);
		}
		if(t>59&&t<64)
			b[i]=a;
		else
			b[i]=c;
	}
	for(i=0;i<m;i++)
		printf("%d\n",b[i]);
	return 0;
}
int main()
{
	int n,t,a[100],i;
	scanf("%d",&n);
	
	while(n--){
		scanf("%d",&t);
		for(i=1;i<=t;i++)
			scanf("%d",&a[i]);
		if((a[t]+t*3)<60)
			printf("%d\n",60-t*3);
		else{
			for(i=1;i<=t;i++){
				if((a[i]+i*3>62)&&(a[i-1]+i*3-3<60))
					printf("%d\n",63-3*i);
				if(((a[i]+i*3<=62)&&(a[i]+i*3>=60))&&((a[i-1]+i*3-3)<60))
					printf("%d\n",a[i]);
			}
		}
	}
	return 0;
}
int main()
{
	int iCase,n,i,count,a[20];
	cin>>iCase;
	while(iCase--)
	{
		count=60;
		cin>>n;
		for(i=0;i<n;i++) 
		{
			cin>>a[i];
		}
		for(i=0;i<n;i++)
		{
			if(a[i]+3*i>60) break;
			if(a[i]+3*(i+1)<=60) count-=3;
			if(a[i]+3*(i+1)>60) count=a[i];
		}
		cout<<count<<endl;
	}
	return 0;
}
int main()
{
        int n;
        int fail[60];

        cin>>n;

        while(n--)
        {
                int m;
                int i;
                cin>>m;
                for(i=0;i<m;i++)
                        cin>>fail[i];

                int count;

                if(m==0)
                {
                        cout<<60<<endl;
                        continue;
                }
                for(i=0;i<m;i++)
                {
                        if(fail[i]+3*i>=60)
                        {
                                cout<<60-3*i<<endl;
                                break;
                        }
                        if(fail[i]+3*(i+1)>60)
                        {
                                cout<<fail[i]<<endl;
                                break;
                        }
                }

                if(i==m)
                        cout<<60-3*m<<endl;
        }
        return 0;
}
int main()
{
	int n,m[100],p[20],i,j,t[100];
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%d",&m[i]);
		if(m[i]==0)
		{
			t[i]=60;
		}
		else{
		for(j=0;j<m[i];j++)
		{
			scanf("%d",&p[j]);
			if((p[j]+(j+1)*3)<=60&&(60-p[j])<=3)
			{
				t[i]=60-j*3;
				
			}
			else if((p[j]+(j+1)*3)<=60&&(60-p[j])>3)
			{
				t[i]=60-(j+1)*3;
			
			}
			else if((p[j]+3*j)<60)
			{
				t[i]=p[j];
				
			}
			else if((60-p[j-1]-3*(j-1))<=3&&(60-p[j-1]-3*(j-1))>=0)
			{
				t[i]=p[j-1];
				
			}
			else if((p[j-1]+j*3)>60)
			{
				t[i]=60-3*(j-1);
			}
			else
			{
				t[i]=60-j*3;
				

			}
				
		}
			
		
		}
	}
	for(i=0;i<n;i++)
	{
		printf("%d\n",t[i]);
	}
	return 0;
}
int main(){
 int ts[100]={0};
 int n,a,b,i,j;
 int dj=0,sum=0;
 scanf("%d",&n);
 for(i=0;i<n;i++){
 scanf("%d",&a);
 for(j=0;j<a;j++){
 scanf("%d",&b);
 ts[dj+b]=1;
 ts[dj+b+1]=1;
 ts[dj+b+2]=1;
 dj+=3;
 }
 dj=0;
 for(j=0;j<60;j++){
 if(ts[j]==0)
 sum++;
 }
 printf("%d\n",sum);
 sum=0;
 for(j=0;j<100;j++){
 ts[j]=0;
 }
 }
 return 0;
}
int main()
{
	int n=0,i=0,j=0,a[60],m=0,l=0;
	cin>>n;
 	for(i=1;i<=n;i++)
	{
		cin>>m;
		if (m==0)
			cout<<"60"<<endl;
		else
		{
			for(j=1;j<=m;j++)
			{
				cin>>a[j];
				if(a[j]<(64-3*j))
					l=j;
			}
			if(a[l]<=(60-3*l))
				cout<<60-3*l<<endl;
			else if(a[l]>(60-3*l)&&a[l]<(64-3*l))
				cout<<a[l]<<endl;
		}
	}
	return 0;
}
//
//  main.cpp
//  ds
//
//  Created by Love on 12-12-27.
//  Copyright (c) 2012? Love. All rights reserved.
//

int main(){
    int n;
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        int m;
        scanf("%d",&m);
      
        if (m==0) {
            printf("60\n");
            continue;
        }
        int num[100]={0};
        for (int j=1; j<=m; j++) {
            scanf("%d",&num[j]);
            
        }
       
            if (num[m]+3*m<=60) {
                printf("%d\n",(60-3*m));
                
            }else{
                int c=1;
                for (int k=m; k>1; k--) {
                    if (num[k]+3*(k-1)<=60&&num[k]+3*k>60) {
                        printf("%d\n",num[k]);
                        c=0;
                        break;
                        
                    }else if(num[k-1]+3*(k-1)<60&&num[k]+3*(k-1)>60){
                        printf("%d\n",(60-3*(k-1)));
                        c=0;
                        break;
                        
                    }
                    
                }
               
                
                
            
            }
    }
    return 0;
    
}
int main(){
	int nCases, n, t;
	int wasteTime;
	
	cin >> nCases;
	while (nCases--){
		cin >> n;
		wasteTime = 0;
		for (int i = 0; i < n; i++){
			cin >> t;
			t += i * 3;
			if (t + 3 <= 60)
				wasteTime += 3;
			else if (t < 60 && t + 3 > 60)
				wasteTime += (60 - t);
		}
		
		cout << 60 - wasteTime << endl;
	}
	return 0;
}
int main()
{
	int n,m,i,j,b[100][100],a[100],t;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>m;
		for(j=0;j<m;j++)
		{
			cin>>b[i][j];
		}
		if(b[i][m-1]+3*m>60)
		{
			for(j=0;j<m;j++)
			{
				if(b[i][j]+3*(j+1)>60 && b[i][j]+3*j<=60)
				{
					t=60-3*j-(3-(b[i][j]+3*(j+1)-60));
					cout<<t<<endl;
					break;
				}
			else if(b[i][j]+3*(j+1)<=60 && b[i][j+1]+3*(j+1)>60)
				{
					t=60-3*(j+1);
					cout<<t<<endl;
					break;
				}
			}
		}
		else 
		{
			t=60-m*3;
			cout<<t<<endl;
		}
	}
	return 0;
}
int main(int argc, char* argv[])
{
	int n,p[1000][60],q[1000];
	scanf("%d",&n);
	for(int m=0;m<n;m++){
		scanf("%d",&p[m][0]);
		int t;
		t=p[m][0];
		if(t==0) printf("60\n");
		else{
		for(int j=1;j<=t;j++){
			scanf("%d",&p[m][j]);
		}
		int b;
		b=60-3*t-p[m][t];
		if(b>=0){
		q[m]=b+p[m][t];
		printf("%d\n",q[m]);
		}
		else{
			int s,z,h1,h2,l;
			for(int f=1;f<=t;f++){
				s=p[m][f]+3*f;
				if(s>60){
                    h1=p[m][f];
					h2=p[m][f-1];
					z=f;
					for(int g=0;g<=t;g++){
						p[m][g]=-60;
					}
				}
			}
				l=60-3*(z-1)-h2-(h1-h2);
				if(l>=0) q[m]=h1;
				else q[m]=60-3*(z-1);
				printf("%d\n",q[m]);
			}
		}
	}
	return 0;
}
void main()
{
  int z,i,j,n,t,count,time,tem,pre,go;
  char dd='0';
  scanf("%d",&t);
  for(z=0;z<t;z++)
{
	for(;;)
	{
   scanf("%c",&dd);
   if(dd=='\n') break;
    scanf("%d",&go);
	}
  scanf("%d",&n);
  if(n==0) {printf("60\n");continue;} 
  count=0;time=0;tem=0;pre=0;
  for(i=0;i<n;i++)
{
  scanf("%d",&tem);
  pre=time;
  time=tem+3*(i+1);
  if(time<60) count=tem;
 else
{
  if(time>=63) {count=count+60-pre;break;}
  else
{
   count=tem;
  break;  
}
}
}
if(time<=60) count=count+60-time;
printf("%d\n",count);
}
}
int main(){
	int n,m,i,j,k,cs[10001],a[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]);
    scanf("%d",&n);
	return 0;
}
int main()
{
	int n,num[20],m,sum;
	cin>>n;
	while(n)
	{
		sum=0;
		cin>>m;
		for(int i=0;i<m;i++)
		{
			cin>>num[i];
		}
		for(int i=0;i<m;i++)
		{
			if((num[i]+3*(i+1))>63)
			{
				sum=num[i-1]+60-num[i-1]-3*i;
				break;
			}
			else if((num[i]+3*(i+1))>=60)
			{
				sum=num[i];
				break;
			}
		}
		if(sum==0)
		{
			sum=60-m*3;
		}
		if(m==0)
		cout<<60<<endl;
		else
		cout<<sum<<endl;
		n--;
	}
	 
	return 0;
}
/*???????*/
struct information
{
	int t;
	int s[20];
}children[N];

void main()
{
	int n,i,j,p;
	int num[N];
	scanf("%d",&n);
	/*???????*/
	for(i=0;i<n;i++)
	{
				scanf("%d",&children[i].t);
		for(j=0;j<children[i].t;j++)
		{
			scanf("%d",&children[i].s[j]);
		}
	}
	/*????????????*/
	for(i=0;i<n;i++)
	{
		p=children[i].t;
		if(p==0)
			num[i]=60;
		else
		{
			for(j=0;j<p;)
			{
				if((children[i].s[j]+3*j)<57)
					j++;
				else
					break;
			}
		        if((children[i].s[j]+3*j)<=60&&(children[i].s[j]+3*j>57))
				num[i]=children[i].s[j];
			else 
				num[i]=60-3*j;
		}
	}

		for(i=0;i<n;i++)
	{
		printf("%d\n",num[i]);
	}
}
int main(){
	int n,m,k,i,j,mid,judge,timer,l[100],r[100],stop;
	mid=0;
	judge=0;
	scanf("%d",&n);
	for(k=0;k<n;k++){
		scanf("%d",&m);
		if(m==0){
			r[k]=60;
		}
		for(i=0;i<m;i++){
			scanf("%d",&l[i]);
		}
		l[m]=60-l[m-1];
		for(i=m-1;i>0;i--){
			l[i]=l[i]-l[i-1];
		}
		for(i=0;i<m;i++){
			if(mid<60){
				mid+=l[i];
			}
			if(mid>=60){
				judge=10000;
				timer=i;
				break;
			}
			if(mid<60){
				mid+=3;
			}
			if(mid>=60){
				judge=33333;
				timer=i;
				break;
			}
		}
	//	printf("judge=%d\n",judge);
		if(judge==10000){
			r[k]=60-3*(i);
		}else if(judge==33333){
			r[k]=60-3*(i)-(3-(mid-60));
		}else if(judge==0){
			r[k]=60-3*i;
		}
		mid=0;
	}
	for(k=0;k<n;k++){
		if(k<n-1){
			printf("%d\n",r[k]);
		}else{
			printf("%d",r[k]);
		}
	}
	scanf("%d",&stop);
	return 0;
}
int main(){
int n,time,cs,num;
int a[1000],b[1000][60];
scanf("%d",&n);
for (int i=0;i<n;i++){
            scanf ("%d",&a[i]);
     for (int j=0;j<a[i];j++){
             scanf("%d",&b[i][j]);
     }    
}
for (int k=0;k<n;k++){
     time=60;
     cs=0;
     num=0;
     if (a[k]==0){
            printf("60\n");
            continue;
     }
     for (int m=0;m<=a[k];m++){
        for (int t=0;t<60;t++){
            if (cs==b[k][m]){
                 time-=3;
                 break;
            }
            if(time<=0){
                 printf("%d\n",cs);
                  num=1;
                 break;
            }
            time--;
            cs++;
        }
     if (num==1){
        break;
     }
    }
} 
return 0;
}
int main()
{
    int n,i,j,k,a[100],sum[100];
    scanf("%d",&n);
    for(i=1;i<=n;i++){scanf("%d",&k);for(j=1;j<=k;j++){scanf("%d",&a[j]);
    }if(60<=a[k]+3*(k-1)&&58<=a[k-1]+3*(k-2)&&a[k-1]+3*(k-2)<=60)sum[i]=a[k-1];
    else if(60<=a[k]+3*(k-1)&&a[k-1]+3*(k-2)<=57)sum[i]=60-3*(k-1);
    else if(58<=a[k]+3*(k-1)&&a[k]+3*(k-1)<=60)sum[i]=a[k];
    else if(a[k]+3*(k-1)<=57)sum[i]=60-3*k;
    else sum[i]=60-3*(k-2);
    printf("%d\n",sum[i]);}
    return 0;
}
int main()
{
 int n,i,m,s,k;
 scanf("%d",&n);
 for(i=0;i<n;i++)
{
     scanf("%d",&m);
     if(m==0)
      {
         s=60;
         printf("%d\n",s);
         continue;
       }
        int*a=(int*)malloc(sizeof(int)*m);
    for(k=0;k<m;k++)
    {
       scanf("%d",&a[k]);
     }
    for(k=0;k<m;k++){
         if(a[k]+3*k<=60&&a[k]+3*(k+1)>=60){
          s=a[k];
          printf("%d\n",s);
          break;
                                            }
                 }
    if(a[0]>60){
       s=60;
       printf("%d\n",s);
       continue;
               }
   if(a[m-1]+3*m<60){
       s=60-3*m;
       printf("%d\n",s);
      continue;
                   }
for(k=0;k<m;k++){
   if(a[k]+3*(k+1)<60&&a[k+1]+3*(k+1)>60){
        s=60-3*(k+1);
        printf("%d\n",s);
       continue;
                                         }
                }           
          free(a);
                                          }
 return 0;
   }
int main()
{   
    int n=0,i=0;
	int minnum=60;
	scanf("%d",&n);
	for(i=0;i<n;i++){
        int m;
	    scanf("%d",&m);
		int p=0;
		for(p=0;p<m;p++){
			int number;
			scanf("%d",&number);
			if((number+3*p)<=60){
				if((60-number-(3*p)-3)>=0)
					minnum=60-(3*p)-3;
				else if((60-number-(3*p)-3)<0)		
                    minnum=number;
			}
		}
		printf("\n%d\n",minnum);
	}
	return 0;
}
/**
* @file 1000010424_6.cpp
* @author ???
* @date 2010?11?24
* @description
* ??????:1049 ????    
*/



int main()
{
	int n, badNum;								//?????????????
	int i, j;									//?????
	int badTotal, time, place, lastPlace;		//??????????????????

	cin >> n;

	for(i = 1; i <= n; i++)
	{
		cin >> badNum;							//????????
		time = 0;
		badTotal = 0;
		lastPlace = 0;

		for(j = 1; j <= badNum; j++)
		{
			cin >> place;

			time += place - lastPlace;			//???????????

			if(time < 60)						//??????
			{
				if(time <= 57)
				{
					time += 3;					//time????????
					badTotal += 3;
				}
				else
				{
					badTotal += 60 - time;
					time += 3;
				}
			}
			else
				;

			lastPlace = place;
		}

		cout << 60 - badTotal << endl;
	}

	return 0;
}
int main()
{
	int i,j,m,n,k,e=0,t=0,a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{	
		e=0;
		t=0;
		scanf("%d",&m);
		for(j=0;j<m;j++)
		{
			scanf("%d",&a[j]);
		}
		for(j=0;j<m;j++)
		{
			t=3*j+a[j];
			if(t>=57&&t<=60)
			{
			    printf("%d\n",a[j]);
				break;	
			}
			if(t>60)
			{
				a[j]-=t-60;
				printf("%d\n",a[j]);
				break;
			}
		}
		if(t<57)
		{
			printf("%d\n",60-3*m);
		}
	
	}
	
	return 0;
}
int main()
{
	int n,i,j,a[100],b,m,y[200];
	scanf ("%d",&n);
	for (j=0;j<n;j++){
		scanf("%d",&m);
		y[j]=60;
		b=0;
		for(i=0;i<m;i++){
			scanf("%d",&a[i]);
		    if (a[i]<(59-3*i)){
                b++;
			    y[j]=60-3*b;
		    }
		    if (a[i]==(59-3*i)){
			    y[j]=59-3*i;
            }
	    }
	}
    for (j=0;j<n;j++){		
         printf ("%d\n",y[j]);
    }
	return 0;
}
int main(int argc, char* argv[])
{
	int a[999][10]={{0}};
	int n;
	scanf("%d",&n);
	int i,j;
	int N=0;
	int total=0;
	for(i=1;i<n+1;i++){
		scanf("%d",&a[i][0]);
		for(j=1;j<=a[i][0];j++){
			scanf("%d",&a[i][j]);
		}
	}
	int total1;
	for(i=1;i<n+1;i++){
		if(a[i][0]==0){
			printf("60\n");
		}
		else if(a[i][0]!=0){
			j=a[i][0];
			total1=a[i][j]+j*3;
			if(total1>63){
				do{
					total1=a[i][j-1]+j*3-3;
					if(total1>63)
						j--;
				}while(total1>63);
				N=a[i][j-1]+j*3-3;
				if(N<60){
					total=60-N+a[i][j-1];
				}
				else if(N>=60&&N<=63)
					total=a[i][j-1];
				else if(N>63){
					total=a[i][j-1]-N+60;
				}
				printf("%d\n",total);
			}
			else if(total1<=63){
				if(total1<60)
					total=60-j*3;
				else 
					total=a[i][j];
				printf("%d\n",total);
			}
		}
	}
	return 0;
}
int main()
{
	int n,k,a[60],sum=0,p;
	cin>>n;
	for(int i=1;i<=n;i++)
	{memset(a,0,sizeof(a));
		cin>>k;
		if(k==0) cout<<"60"<<endl;
		else{
		for(int j=0;j<k;j++)
			cin>>a[j];
		for(int j=k-1;j>0;j--)
		{
			a[j]=a[j]-a[j-1];

		}
		for(p=0;p<k;p++)
		{if(sum+a[p]+3<=60)
			sum+=a[p]+3;
		else if(sum+a[p]<=60)
			{
			cout<<sum+a[p]-3*p<<endl;
			break;}
		else {
			cout<<60-3*p<<endl;
		break;}
		}
		if(p==k) cout<<60-3*p<<endl;
		sum=0;


		}

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


	return 0;
}
int main()
{
 int i,j,n,a[100],m,time;
 cin>>n;
 for(i=0;i<n;i++)
 {
    cin>>m;
    if(m==0)
	    cout<<60;
    else 
	 {
	  for(j=0;j<m;j++)              
       {
	    cin>>a[j];
	    
	   }
	 for(j=0;j<m;j++)  
	   {
		  time=3*j+a[j];
		  if(time+3>=60)
	      {  
		   if(time<=60)
		     {
			  cout<<a[j];break;   //??break?????????
		     }
		   time=3*(j-1)+a[j-1];
	       
		   
		   break;
		  }
	   }
	   if(time+3<60)
	   cout<<60-3-time+a[j-1];
    }
   cout<<endl;
 
 }
 
 return 0;
}
/*
 * 1.cpp
 *
 *  Created on: 2011-12-19
 *      Author: 1100012870
 */
int main()
{
	int i,j,n,m,time,num,x,y;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>m;
		time=0;
		num=0;
		x=0;
		for(j=1;j<=m;j++){
			cin>>x;
			num=x;
			if(x+time>=60){
				break;
			}else{
				time+=3;
				if(x+time>=60){
					time=60-x;
					break;
				}
			}
		}
		for(int k=j+1;k<=m;k++)cin>>y;
		num+=60-(x+time);
		cout<<num<<endl;
	}
	return 0;
}
int main()
{
    int n,m,i,j,sum,temp,k,f,d,e; 
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                    sum=0;
                    temp=0;
                    f=0;
                    d=0;
                    e=0;
                    scanf("%d",&m);
                    for(j=0;j<m;j++)
                    {
                                    scanf("%d",&k);
                                    if((k+d*3+1)<59)
                                    {
                                                    d++;
                                    }
                                    if((k+d*3+1)==59)
                                    {
                                                     temp++;                
                                    }
                                    if((k+d*3+1)==60)
                                    {
                                                     f++;
                                    }
                                    if((k+d*3+1)>60)
                                    {
                                                    e++;
                                    }
                    }
                    sum=60-(3*m)+temp+(2*f)+3*e;
                    printf("%d\n",sum);
    }
    return 0;
}
int main(){
	int i,j,k=0,n,nt,total,flag;
	scanf("%d",&k);
	for(i=0;i<k;i++){
		scanf("%d",&n);
		flag = 0;
		for(j=0;j<=n;j++){
			if(j<n){
				scanf("%d",&nt);
				if((nt+3*j)>=57&&(nt+3*j)<=60){
					total = nt;
					flag = 1;
				}
				if((nt+3*(j+1))>60){
					if(!flag){
						total = 60-j*3;
						flag = 1;
					}
				}
			}
			else{
				if(!flag){
					total = 60-j*3;
				}
			}
		}
		printf("%d\n",total);
	}
}
int main()
{
	int n, brea[100], num[100][100] ,mark[100], i, j;
	scanf("%d", &n);
	for (i=1;i<=n;i++){
		scanf("%d", &brea[i]);
		mark[i] = 60;
		for (j=1;j<=brea[i];j++){
			scanf("%d", &num[i][j]);
			if (num[i][j]+j*3 < 60) mark[i] = 60-j*3;
			if (num[i][j]+j*3 == 61) mark[i] = 61-j*3;
			if (num[i][j]+j*3 == 62) mark[i] = 62-j*3;
		}
	}
	for (i=1;i<=n;i++){
		printf("%d\n", mark[i]);
	}
	return 0;
}