semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int normal_months[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leap_months[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int is_leap(int year) {
	if (year % 100 == 0)
		return year % 400 == 0;
	
	return year % 4 == 0;
}

int day_of_year(int year, int month, int day) {
	int *months = is_leap(year) ? leap_months : normal_months;
	
	int days = 0;
	int i;
	for ( i = 0; i < month - 1; i++)
		days += months[i];
	
	days += day;

	return days;
}

int main() {
	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++) {
		int year, month1, month2;
		scanf("%d%d%d", &year, &month1, &month2);
		int days1 = day_of_year(year, month1, 1);
		int days2 = day_of_year(year, month2, 1);
		
		if ((days1 - days2) % 7 == 0)
			printf("YES\n");
		else
			printf("NO\n");
	}
}
int main(int argc, char* argv[])
{
	int const month1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int const month2[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	int year[200],yue1[200],yue2[200];
	int n,day;
	int i,j,t;

	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&year[i],&yue1[i],&yue2[i]);
		if(year[i]%400==0||year[i]%4==0&&year[i]%100!=0)//??
		{
			if(yue1[i]>yue2[i])
			{
				t=yue1[i];
				yue1[i]=yue2[i];
				yue2[i]=t;
			}
			day=0;
			for(j=yue1[i];j<yue2[i];j++)
			{
				day+=month2[j];
			}
			if(day%7==0)
			{
				printf("YES\n");
			}
			else
				printf("NO\n");
			
			
		}
		else//??
		{
				if(yue1[i]>yue2[i])
			{
				t=yue1[i];
				yue1[i]=yue2[i];
				yue2[i]=t;
			}
			day=0;
			for(j=yue1[i];j<yue2[i];j++)
			{
				day+=month1[j];
			}
			if(day%7==0)
			{
				printf("YES\n");
			}
			else
				printf("NO\n");
		}

	}
	return 0;
}
main()
{ 
	int n,i,j,y,m1,m2,temp,sum=0;
	int run(int x);
	int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{		scanf("%d%d%d",&y,&m1,&m2);
			
			if(run(y)==1)
			day[1]=29;
			else
			day[1]=28;
			
			if(m1>m2)
			{temp =m1;
			m1=m2;
			m2=temp;}
			for(j=m1-1;j<m2-1;j++)
			sum=sum+day[j];
			
			if(sum%7==0)
			printf("YES\n");
			else
			printf("NO\n");
			
			sum=0;
			temp=0;
	 								
									 
									 
									 }
		 
			 }
int run(int x)
{
 		if(x%4==0)
		{		if(x%100==0)
				{		if(x%400==0)
						return 1;
			 			else return 0;
		 						 }
		else return 1;		 					
							 } 		
		else return 0; 
		 
		 
		 }
int main(){
int N;
    cin>>N;
    int Y,M1,M2;
for (int i=0;i<N;i++){
    cin>>Y>>M1>>M2;
    int a[13]={0,3,0,3,2,3,2,3,3,2,3,2,3};
    if (Y%400==0||(Y%100!=0&&Y%4==0)) a[2]++;
    int S=0;
    for (int i=M1;i<M2;i++)S+=a[i];
    for (int i=M2;i<M1;i++)S+=a[i];
    if (S%7==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    }
    return 0;
    }
int main()
{
	int n,i,j,t,s;
	int b[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	struct {
		int y,m1,m2;
	}an[200];
	scanf ("%d\n",&n);
	s=0;
		

	for (i=0;i<n;i++)
	{
	
		scanf ("%d%d%d",&an[i].y,&an[i].m1,&an[i].m2);
		if ((an[i].y%4==0&&an[i].y%100!=0)||(an[i].y%400==0)) {b[2]=29;}
		else b[2]=28;
		if (an[i].m2<an[i].m1)
		{
			t=an[i].m1;
			an[i].m1=an[i].m2;
			an[i].m2=t;
		}
	
		for(j=an[i].m1;j<an[i].m2;j++)
		{
			
			s=s+b[j];
		}
		if (s%7==0)
		{
			printf("YES\n");
		}
		if (s%7!=0) printf ("NO\n");
		s=0;
	}
	
	return 0;
}
int main()
{
	int y[2][12]={31,28,31,30,31,30,31,31,30,31,30,31,31,29,31,30,31,30,31,31,30,31,30,31};
	int n,i,j,temp,year[200],mon1[200],mon2[200],total;
	  scanf("%d",&n);
	    for(i=0;i<n;i++)
		{
		   scanf("%d %d %d",&year[i],&mon1[i],&mon2[i]);
		}
		  for(i=0;i<n;i++)
		  {
		     if((year[i]%4==0&&year[i]%100!=0)||(year[i]%4==0&&year[i]%400==0))
                      j=1;
			 else
				      j=0;
			    if(mon1[i]>mon2[i])
				{
				           temp=mon1[i];
						   mon1[i]=mon2[i];
						   mon2[i]=temp;
				}
                       for(total=0;mon1[i]<mon2[i];mon1[i]++)
					   {
					      total+=y[j][mon1[i]-1];
					   }
					      if(total%7==0)
							  printf("YES\n");
						  else
							  printf("NO\n");
                       
		}
	return 0;
}
int days(int m1,int m2,int e[])
{
	int sum=0;
	for(int i=m2;i<m1;i++)
		sum+=e[i];
	return sum;
}


int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		int y,m1,m2;
		cin>>y>>m1>>m2;
		int e[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
		if(((y%4==0)&&(y%100!=0))||(y%400==0))
			e[2]=29;
		int sum;
		if(m1>m2)
			sum=days(m1,m2,e);
		else
			sum=days(m2,m1,e);
		if(sum%7==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
 return 0;

}
int main ()
{
	int s,i,j,t,k,num;
	cin >> s;
	int y,n,m;
	for (i=0;i<s;i++)
	{
		num=0;
		cin >> y >> n >> m;
		if ((y%100!=0 && y%4==0)||(y%400==0))
		t=1;
		else
		t=0;
		if (n>m)
		{
			k=n;
			n=m;
			m=k;
		}
		for (j=n;j<m;j++)
		{
			if (j==1||j==3||j==5||j==7||j==8||j==10||j==12)
			num+=31;
			if (j==4||j==6||j==9||j==11)
			num+=30;
			if (j==2)
			{
				if (t==1)
				num+=29;
				else 
				num+=28;
			}
		}
		if (num%7==0)
		cout << "YES" <<endl;
		else 
		cout << "NO" <<endl;
	}
	return 0;
}
/**
* @file 1000012800_1.cpp
* @author ??
* @date 2010-10-27
* @description
* ??????:???
*/

int main()
{
	int n, i;

	cin >> n;
	for (i = 0; i < n; i ++)
	{
		int year, month1, month2, t, sum = 0;
		cin >> year >> month1 >> month2;
		if (month1 > month2)
		{
			t = month1;
			month1 = month2;
			month2 = t;
		}
		for ( int j = month1; j < month2; j++)
		{
			if ( (j == 1) || (j == 3) || (j == 5) || (j == 7) || (j == 8) || (j == 10) || (j == 12) )
				sum += 31;
			else if (  (j == 4) || (j == 6) || (j == 9) || (j == 11) )
				sum += 30;
			else
			{
				if ( !(year % 400) || ((year % 100) && !(year % 4)))
					sum += 29;
				else
					sum += 28;
			}
		}
		if (sum % 7)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
	}

	return 0;
}
int main(){
	int n,nian,yue1,yue2,i,j;/*n????????nian???yue1????????yue2????????i?j?????*/
	int ti,sum;	      /*???????????ti????????sum??????1??????*/
	int yue[11]={31,28,31,30,31,30,31,31,30,31,30};
                         /*????????????1~11?????12?????*/
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&nian,&yue1,&yue2);
		if(yue1>yue2){/*if???????yue1??????yue2?????*/
			ti=yue2;
			yue2=yue1;
			yue1=ti;
		}
		sum=0;	/*?????????????????sum???0*/
		for(j=yue1;j<yue2;j++){
			sum+=yue[j-1];
		}		/*?????????*/
		if((yue1<=2)&&(yue2>=3)){
			if((nian%4==0)&&(nian%100!=0)||(nian%400==0)){
				sum++;}		/*???????????????????????????1?*/
		}
		if(sum%7==0){		/*??????????7??*/
			printf("YES\n");
		}else{
			printf("NO\n");}

	}


	return 0;
}
int main()
{
	int i,n;
	int a[200],b[200],c[200];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	for(i=0;i<n;i++)
	{
		if((a[i]%100!=0&&a[i]%4==0)||(a[i]%400==0))
		{
			if((b[i]==1||b[i]==4||b[i]==7)&&(c[i]==1||c[i]==4||c[i]==7))
				printf("YES\n");
			else
				if((b[i]==2||b[i]==8)&&(c[i]==2||c[i]==8))
					printf("YES\n");
				else
					if((b[i]==3||b[i]==11)&&(c[i]==3||c[i]==11))
						printf("YES\n");
					else
						if((b[i]==9||b[i]==12)&&(c[i]==9||c[i]==12))
							printf("YES\n");
						else
							printf("NO\n");
		}
		else
				{
			if((b[i]==4||b[i]==7)&&(c[i]==4||c[i]==7))
				printf("YES\n");
			else
				if((b[i]==2||b[i]==3||b[i]==11)&&(c[i]==2||c[i]==3||c[i]==11))
					printf("YES\n");
				else
					if((b[i]==1||b[i]==10)&&(c[i]==1||c[i]==10))
						printf("YES\n");
					else
						if((b[i]==9||b[i]==12)&&(c[i]==9||c[i]==12))
							printf("YES\n");
						else
							printf("NO\n");
		}
	}
	return 0;
}
int main()
{
	int sz[200][3];
	int ping[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int run[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int n;
	int a,b,m,p;
	int sum;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d %d",&sz[i][0],&sz[i][1],&sz[i][2]);
	}
	for(int q=0;q<n;q++){
		if((sz[q][0]%400==0)||(sz[q][0]%100!=0&&sz[q][0]%4==0)){
			if(sz[q][1]>sz[q][2]){
				sum=0;
				for(p=sz[q][2];p<sz[q][1];p++){
					sum=sum+run[p-1];
				}
			}
			else{
				sum=0;
				for(m=sz[q][1];m<sz[q][2];m++){
					sum=sum+run[m-1];
				}
			}
		}
		else{
			if(sz[q][1]>sz[q][2]){
				sum=0;
				for(p=sz[q][2];p<sz[q][1];p++){
					sum=sum+ping[p-1];
				}
			}
			else{
				sum=0;
				for(m=sz[q][1];m<sz[q][2];m++){
					sum=sum+ping[m-1];
				}
			}
		}
		if(sum%7==0){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}
//?????
int main()
{
	int y[10000],m1[10000],m2[10000],n,i=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>y[i]>>m1[i]>>m2[i];
	}
	for(int i=0;i<n;i++)
	{
		if(y[i]%4==0&&y[i]%100!=0||y[i]%400==0)
		{
			switch(m1[i])
			{
			case 1:m1[i]=1;break;
			case 2:m1[i]=31+1;break;
			case 3:m1[i]=31+29+1;break;
			case 4:m1[i]=31+29+31+1;break;
			case 5:m1[i]=31+29+31+30+1;break;
			case 6:m1[i]=31+29+31+30+31+1;break;
			case 7:m1[i]=31+29+31+30+31+30+1;break;
			case 8:m1[i]=31+29+31+30+31+30+31+1;break;
			case 9:m1[i]=31+29+31+30+31+30+31+31+1;break;
			case 10:m1[i]=31+29+31+30+31+30+31+31+30+1;break;
			case 11:m1[i]=31+29+31+30+31+30+31+31+30+31+1;break;
			case 12:m1[i]=31+29+31+30+31+30+31+31+30+31+30+1;break;
			}
			switch(m2[i])
			{
			case 1:m2[i]=1;break;
			case 2:m2[i]=31+1;break;
			case 3:m2[i]=31+29+1;break;
			case 4:m2[i]=31+29+31+1;break;
			case 5:m2[i]=31+29+31+30+1;break;
			case 6:m2[i]=31+29+31+30+31+1;break;
			case 7:m2[i]=31+29+31+30+31+30+1;break;
			case 8:m2[i]=31+29+31+30+31+30+31+1;break;
			case 9:m2[i]=31+29+31+30+31+30+31+31+1;break;
			case 10:m2[i]=31+29+31+30+31+30+31+31+30+1;break;
			case 11:m2[i]=31+29+31+30+31+30+31+31+30+31+1;break;
			case 12:m2[i]=31+29+31+30+31+30+31+31+30+31+30+1;break;
			}
			if((m1[i]-m2[i])%7==0)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
		else
		{
			switch(m1[i])
		{
			case 1:m1[i]=1;break;
			case 2:m1[i]=31+1;break;
			case 3:m1[i]=31+28+1;break;
			case 4:m1[i]=31+28+31+1;break;
			case 5:m1[i]=31+28+31+30+1;break;
			case 6:m1[i]=31+28+31+30+31+1;break;
			case 7:m1[i]=31+28+31+30+31+30+1;break;
			case 8:m1[i]=31+28+31+30+31+30+31+1;break;
			case 9:m1[i]=31+28+31+30+31+30+31+31+1;break;
			case 10:m1[i]=31+28+31+30+31+30+31+31+30+1;break;
			case 11:m1[i]=31+28+31+30+31+30+31+31+30+31+1;break;
			case 12:m1[i]=31+28+31+30+31+30+31+31+30+31+30+1;break;
		}
			switch(m2[i])
			{
			case 1:m2[i]=1;break;
			case 2:m2[i]=31+1;break;
			case 3:m2[i]=31+28+1;break;
			case 4:m2[i]=31+28+31+1;break;
			case 5:m2[i]=31+28+31+30+1;break;
			case 6:m2[i]=31+28+31+30+31+1;break;
			case 7:m2[i]=31+28+31+30+31+30+1;break;
			case 8:m2[i]=31+28+31+30+31+30+31+1;break;
			case 9:m2[i]=31+28+31+30+31+30+31+31+1;break;
			case 10:m2[i]=31+28+31+30+31+30+31+31+30+1;break;
			case 11:m2[i]=31+28+31+30+31+30+31+31+30+31+1;break;
			case 12:m2[i]=31+28+31+30+31+30+31+31+30+31+30+1;break;
			}
			if((m1[i]-m2[i])%7==0)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
	}
	return 0;
}
int main(int argc, char* argv[])
{
	int i,j,n,y,m1,m2,t,sum=0,a[N];
	//int md[]={31,28,31,30,31,30,31,31,30,31,30,31};
	int md[N];
	md[1]=28;md[2]=31;md[3]=30;md[4]=31;md[5]=30;md[6]=31;
	md[7]=31;md[8]=30;md[9]=31;md[10]=30;md[11]=31;md[0]=31;
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&y,&m1,&m2);
		if(m1==m2)
		{
			printf("YES\n");
			continue;
		}
		if(m1>m2)
		{
			t=m1;
			m1=m2;
			m2=t;
		}
	//	printf("%d %d\n",m1,m2);
		for(j=m1-1;j<=m2-2;j++)
		{
			sum+=md[j];
		}
	//	printf("%d\n",sum);
		if(((y%4==0)&&(y%100!=0)||(y%400==0))&&(((m1==1)&&(m2>=3))||m1==2))
		{
			sum++;
		}
	//	printf("%d\n",sum);
		if(sum%7==0){
			a[i]=1;}
		else{
			a[i]=0;}
		sum=0;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==1)
			printf("YES\n");
		else if(a[i]==0)
			printf("NO\n");

	}
	return 0;
}
main()
{
      int i,j,k=0,n,m,a,b,c;
      int pm[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},rm[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
      scanf("%d",&n);
      for(i=1;i<=n;i++)
      {
k=0;
                       scanf("%d %d %d",&a,&b,&c);
                       if(c<b)
                       {
                              m=c;
                              c=b;
                              b=m;
                              }
                              
                       if((a%4==0&&a%100!=0)||(a%4==0&&a%400==0))
                       { 
                                        for(j=b;j<c;j++)
                                        k=k+rm[j];
                                        if(k%7==0)
                                        printf("YES\n");
                                        else
                                        printf("NO\n");   
                                 
                                           }
                      
                       if(a%4!=0||(a%4==0&&a%100==0&&a%400!=0))
                       {
                             for(j=b;j<c;j++)
                             k=k+pm[j];
                             if(k%7==0)
                                        printf("YES\n");
                                        else
                                        printf("NO\n"); 
                                                          
                       }
      
      }
      
      }
int runnian(int y)
{
     int t=0;
    if(y%400==0||y%4==0&&y%100!=0) t=1;
    return t;
}
int main()
{
    int i,j,n,y,m1,m2,t,days;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
       scanf("%d %d %d",&y,&m1,&m2);
       days=0; 
      if(m1>m2)
       {t=m2;
        m2=m1;
        m1=t;
       }
         if(runnian(y)==1)
         {
           for(j=m1;j<m2;j++)
            {  if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
                days+=31;
                if(j==2)
                days+=29;
                if(j==4||j==6||j==9||j==11)
                days+=30;
          }
         }
          if(runnian(y)==0)
         {
            for(j=m1;j<m2;j++)
          {
            if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
             days+=31;
             if(j==2)
             days+=28;
             if(j==4||j==6||j==9||j==11)
             days+=30;
           }
          }
          if(days%7==0)
          printf("YES\n");
          if(days%7!=0)
          printf("NO\n");
       }
       getchar();
       getchar();
       return 0;
}
int main()
{
	int n,i,k,l,m,a,b;
	scanf("%d",&n);
	int max(int x,int y);           //??????????????
	int min(int x,int y);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&k);
		scanf("%d",&l);
		scanf("%d",&m);
		a=min(l,m);
		b=max(l,m);
		if(k%4==0&&k%100!=0||k%400==0)   //???????
		{
			if((a==1&&b==4)||(a==1&&b==7)||(a==4&&b==7)||(a==2&&b==8)||(a==3&&b==11)||(a==9&&b==12))
				if(i==1)
				    printf("YES");
				else printf("\nYES");
			else
				if(i==1)
				    printf("NO");
				else printf("\nNO");
		}
		else
		{
			if((a==1&&b==10)||(a==2&&b==3)||(a==2&&b==11)||(a==3&&b==11)||(a==4&&b==7)||(a==9&&b==12))
				if(i==1)
				    printf("YES");
				else printf("\nYES");
			else
				if(i==1)
					printf("NO");
				else printf("\nNO");
		}
	}
	return 0;
}
int max(int x,int y)  //??max??
{
	int z;
	if(x>y) z=x;
	else z=y;
	return(z);
}
int min(int x,int y)   //??min??
{
	int z;
	if(x>y) z=y;
	else z=x;
	return(z);
}
//??(10.5) ???
int main()
{
	int n,y,m1,m2,i,j,sum,t;
	int x[24]={31,28,31,30,31,30,31,31,30,31,30,31,
	31,29,31,30,31,30,31,31,30,31,30,31};             //x?????????
	cin>>n;
	for (i=0;i<=n-1;i++)                              //????????????
	{
		sum=0;
		cin>>y>>m1>>m2;
		if (m1>m2)                                    //?m1>m2???
		{
			t=m1;
			m1=m2;
			m2=t;
		}
		if ((y%4==0&&y%100!=0)||y%400==0)             //???????x??12???
			for (j=11+m1;j<=10+m2;j++)
				sum+=x[j];
		else                                          //????x??12?????
			for (j=m1-1;j<=m2-2;j++)
				sum+=x[j];
		if (sum%7==0)                                 //????
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}
int isRunNian(int year){
    int result;
    if(year%400==0||year%4==0&&year%100!=0){
       result=1;
    }
    else{
       result=0;
    }
    return result;
}
int DijiTian(int year,int month,int day){
    int result=0;
    for(int i=1;i<month;i++){
        if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
            result+=31;
        }else if(i==4||i==6||i==9||i==11){
            result+=30;
        }else if(i==2){
            if(isRunNian(year)){
                result+=29;
            }else{
                result+=28;
            }
        }
    }
    result+=day;
    return result;
}  
void swap(int*a,int*b){
     int e;
     e=*a;
     *a=*b;
     *b=e;
}
int DijiTian(int year,int month,int day);
int isRunNian(int year);
void swap(int*a,int*b);
int main()
{
    int n,year,month1,month2;
    int a,i,sz[200];
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d",&year,&month1,&month2);
        if(month1>month2){
            swap(&month1,&month2);
        }
        a=DijiTian(year,month2,1)-DijiTian(year,month1,1);
        if(a%7==0){
           printf("YES\n");
        }
        else printf("NO\n");
    }
    return 0;
}
int run(int x)       /*??????2???????*/
{
	int z;
	if (x % 100 == 0)
	{
		if (x % 400 == 0)
			z = 29;
		else z = 28;
	}
	else if (x % 4 == 0)
		z = 29;
	else z = 28;
	return (z);
}
int main ( )
{
	int n, a[200][3], b[12], i, j, num, p, q, aa, bb, cc;
	b[0] = 31;b[2] = 31;b[3] = 30;b[4] = 31;b[5] = 30;b[6] = 31;b[7] = 31;b[8] = 30;b[9] = 31;b[10] = 30;b[11] = 31;/*?????????,????12???????*/
	cin >>n;
	for (i = 0;i < n;i++)/*??n???*/
	{
		cin >>aa >>bb >>cc;
		a[i][0] = aa;
		a[i][1] = bb;
		a[i][2] = cc;
	}
	for (j = 0;j < n;j++)
	{
		b[1] = run(a[j][0]);/*??run???b[1]??,??2?????*/
		num = 0;
		if (a[j][1] < a[j][2])/*???????????????*/
		{
			p = a[j][1];
		    q = a[j][2];
		}
		else 
		{
			p = a[j][2];
		    q = a[j][1];
		}
		for (;p < q;p++)             /*???????????*/
			num = num + b[p-1 ];
		if (num % 7 == 0)            /*?????7???,???????*/
			cout <<"YES"<<endl;
		else cout <<"NO"<<endl;
	}
	return 0;
}
int main()
{
    int n;
    int year;
    int month1,month2;
    int pingnian[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
    int runnian[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int buffer;

    cin >> n;

    for (int i = 0; i< n; i++) {
        cin >> year >> month1 >> month2;
        if (month1 > month2) {
            buffer = month1;
            month1 = month2;
            month2 = buffer;
        }

        buffer = 0;
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            for (int j = month1; j < month2; j++)
                buffer = buffer + runnian[j - 1];
            if (buffer % 7 == 0)
                cout << "YES" << endl;
            else
                cout << "NO" << endl;
        }

        else {
            for (int j = month1; j < month2; j++)
                buffer = buffer + pingnian[j - 1];
            if (buffer % 7 == 0)
                cout << "YES" << endl;
            else
                cout << "NO" << endl;
        }

    }
    return 0;
}
/*#include "iostream"
int main()
{
	int A[13],X,B;
	char C[8][10];
	char c1,c2;
	int N,Sum = 0;
	cin >> N >> X >> B;
	for (int I = 1; I < N; I ++)
	{
		if (I%100)
			if (I%4 == 0) Sum = (Sum + 366) % 7; else Sum = (Sum + 365) % 7;
		else if (I%400 == 0) Sum = (Sum + 366) % 7; else Sum = (Sum + 365) % 7;
	}
	int S = B;
	if (N%100)
		if (N%4 == 0) A[2] = 29; else A[2] = 28;
	else if (N%400 == 0) A[2] = 29; else A[2] = 28;
	A[1] = A[3] = A[5] = A[7] = A[8] = A[10] = A[12] = 31;
	A[4] = A[6] = A[9] = A[11] = 30;
	for (int I = 1; I < X; I ++) S += A[I];
	Sum = (Sum + S) % 7;
	if ( Sum == 1 ) cout << "Mon." << endl;
	if ( Sum == 2 ) cout << "Tue." << endl;
	if ( Sum == 3 ) cout << "Wed." << endl;
	if ( Sum == 4 ) cout << "Thu." << endl;
	if ( Sum == 5 ) cout << "Fri." << endl;
	if ( Sum == 6 ) cout << "Sat." << endl;
	if ( Sum == 0 ) cout << "Sun." << endl;
}*/

int main()
{
	int N,M,X,Y,A[31];
	cin >> N;
	for (int I = 1; I <= N; I ++)
	{
		cin >> M >> X >> Y;
		if (M%100)
			if (M%4 == 0) A[2] = 29; else A[2] = 28;
		else if (M%400 == 0) A[2] = 29; else A[2] = 28;
		A[1] = A[3] = A[5] = A[7] = A[8] = A[10] = A[12] = 31;
		A[4] = A[6] = A[9] = A[11] = 30;
		int S = 0,T;
		if (X > Y)
		{
			T = X; X = Y; Y = T;
		}
		for (int I = X; I < Y; I ++) S += A[I];
		if (S%7) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
}
int isRunNian(int year){
    int result;
    if(year%400 == 0 ||(year%4==0 &&year%100!=0)){
        result = 1;
	} 
    else{
        result = 0;
	}
return result;
}
int DiJiTian(int year, int month, int day){
    int result = 0;
    for(int i = 1; i < month; i++){
        if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
            result += 31;
		} 
        else if (i == 4 || i ==6 || i == 9 ||i==11){
            result += 30;
		} 
        else if(i == 2){
            if(isRunNian(year)){
				result += 29;
			} 
			else {
				result += 28;
			}
		}
	}
	result += day;
return result;
}
int main(){
    int n,i,y,m1,m2;
	int d1,d2;
	int cha;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    scanf("%d%d%d",&y,&m1,&m2);
		d1=DiJiTian(y,m1,1);
		d2=DiJiTian(y,m2,1);
		if((d1-d2)<0)
			cha=d2-d1;
		else
			cha=d1-d2;
		if(cha%7==0)
			printf("YES\n");
		else 
			printf("NO\n");
	}
return 0;
}
/*??5 ??
  ?? ???
  ?? ??? ?? 1300012989*/
int main()
{
	int n,i,j;//n?????
	cin>>n;
	int year,mon1,mon2,days,m;//year????mon1,mon2????days??????m??????
	int a[]={0,31,28,31,30,31,30,31,31,30,31,30,31};//???????
	for(i=1;i<=n;i++)//n???????
	{
		cin>>year>>mon1>>mon2;//????
		days=0;//?????????0
		if((year%400==0)||((year%4==0)&&(year%100!=0)))//???????????????
			a[2]=29;
		else
			a[2]=28;
		if(mon1>mon2)//????????
			m=mon1,mon1=mon2,mon2=m;
		else 
			mon1=mon1,mon2=mon2;
		for(j=0;j<(mon2-mon1);j++)//??????
			days+=a[mon1+j];
		if(days%7==0)//??????????????
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}
main()
{
    int year,m,n,i,t,a[13];
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
    scanf("%d %d %d",&year,&m,&n);
    if(year%400==0||year%4==0&&year%100!=0)   
    {
    	 a[0]=0;
    	 a[1]=0;
    	 a[2]=31;
    	 a[3]=60;
    	 a[4]=91;
    	 a[5]=121;
    	 a[6]=152;
    	 a[7]=182;
    	 a[8]=213;
    	 a[9]=244;
    	 a[10]=274;
    	 a[11]=305;
    	 a[12]=335;
    	 if((a[m]-a[n])%7==0)
    	 printf("YES\n");
    	 else
    	 printf("NO\n");
    }
    else
    {
    	a[0]=0;
    	 a[1]=0;
    	 a[2]=31;
    	 a[3]=59;
    	 a[4]=90;
    	 a[5]=120;
    	 a[6]=151;
    	 a[7]=181;
    	 a[8]=212;
    	 a[9]=243;
    	 a[10]=273;
    	 a[11]=304;
    	 a[12]=334;
    	 if((a[m]-a[n])%7==0)
    	 printf("YES\n");
    	 else
    	 printf("NO\n");
    }
    }
    return 0;
}
int main()
{
	int sz[200][3];
	int n;
	scanf("%d\n",&n);
	int i,j;
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			scanf("%d",&sz[i][j]);
		}
	}
	
	int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	
	int k;
	for(i=0;i<n;i++){
		
        
		int total=0;
	
		if(sz[i][1]<sz[i][2]){
			if(sz[i][0]%400==0||(sz[i][0]%4==0&&sz[i][0]%100!=0)){
		    month[1]=29;
		}
		    else{
			month[1]=28;
		}
			
			for(k=sz[i][1]-1;k<sz[i][2]-1;k++){
				total+=month[k];
			}
			
		
		
			
			if(total%7==0)
					printf("YES\n");
				else
					printf("NO\n");
		}
			
		
		else{
            if(sz[i][0]%400==0||(sz[i][0]%4==0&&sz[i][0]%100!=0)){
		         month[1]=29;
		}
	      	else{
			    month[1]=28;
		}
             for(k=sz[i][2]-1;k<sz[i][1]-1;k++){
				 total+=month[k];
			 }
		
				 if(total%7==0)
					printf("YES\n");
				else
					printf("NO\n");
		}
			
	}
	
    return 0;
}
int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int is_year(int x)
{

	if(x%4!=0)
	   return 0;
      else if((x%4==0)&&(x%100!=0))
		return 1;
      else
    	  if(x%400==0)
    		  return 1;
    	  else return 0;
}
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
	  int year,month1,month2,day1=1,day2=1;
      cin>>year>>month1>>month2;
      if(is_year(year))
    	  m[2]=29;
      for(int i=1;i<month1;i++)
    	  day1+=m[i];
      for(int i=1;i<month2;i++)
    	  day2+=m[i];
      m[2]=28;
      if((abs(day2-day1))%7==0)
    	  cout<<"YES"<<endl;
      else
    	  cout<<"NO"<<endl;




  }

return 0;
}