semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int daytable[][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 daynum(int year,int month,int day){   /*??????????*/
	int leap,i,day1;
	day1=day;
    if(year%4!=0)
		leap=0;
	else if(year%100==0 && year%400!=0||year%3200==0)
		      leap=0;
	     else 
			 leap=1;                 /*???????*/
	for(i=0;i<month-1;i++)
		day1+=daytable[leap][i];
	return day1;
}
int main()
{
	int i,k,n,y,m1,m2;
	cin>>n;
    for(i=0;i<n;i++){
		cin>>y>>m1>>m2;
		k=daynum(y,m1,1)-daynum(y,m2,1);
		k=abs(k);
		if(k%7==0)
			cout<<"YES"<<endl;
		else
		    cout<<"NO"<<endl;
	}
	return 0;
}
int day(int n,int y)
{
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31},i,d=0;
	for(i=0;i<n-1;i++)
	{
			d+=a[i];
		if(i==1&&((y%4==0&&y%100!=0)||y%400==0))
			d+=1;
	}
	return(d);
}
void main()
{
	int n,i,a,b,c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&a,&b,&c);
		if((day(b,a)-day(c,a))%7==0)printf("YES\n");
		else printf("NO\n");
	}
}
// ???.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
int main()
{
	int i,n,year,runfou,er,mon1,mon2,k,j,day;
	scanf("%d", &n);
	for (i=0;i<n;i++)
	{
		day=0;
		scanf("%d%d%d", &year,&mon1,&mon2);
		if (year%4==0)
			if (year%100==0)
				if (year%400==0)
					runfou=1;
				else
					runfou=0;
			else
				runfou=1;
		else
			runfou=0;
		if (runfou==0)
			er=28;
		else
			er=29;
		if (mon1>mon2)
		{
			k=mon2;
			j=mon1;
		}
		else if (mon1<mon2)
		{
			k=mon1;
			j=mon2;
		}
		else
			printf("YES\n");
		for (;k<j;k++)
		{
			switch (k)
			{
			case 1:day+=31;break;
			case 2:day+=er;break;
			case 3:day+=31;break;
			case 4:day+=30;break;
			case 5:day+=31;break;
			case 6:day+=30;break;
			case 7:day+=31;break;
			case 8:day+=31;break;
			case 9:day+=30;break;
			case 10:day+=31;break;
			case 11:day+=30;break;
			case 12:day+=31;break;
			}
		}
	//	printf(":%d\n", day);
		if (day%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}
struct mem
{
    int year;
    int month1;
    int month2;    
} mem[205];
int find(int n)
{
    int flag=0;
    if(n%4==0)
    {
        if(n%100==0)
        {
            if(n%400==0)
            {
                flag=1;
            }
            else
            {
                flag=0;
            }
        }
        else flag=1;
    }
    return flag;
}
int spp1(int n)
{
    int p=0;
    if(n==1) p=31;
    if(n==2) p=28; 
    if(n==3) p=31; 
    if(n==4) p=30; 
    if(n==5) p=31; 
    if(n==6) p=30; 
    if(n==7) p=31; 
    if(n==8) p=31; 
    if(n==9) p=30; 
    if(n==10) p=31; 
    if(n==11) p=30; 
    if(n==12) p=31;
    return p;  
}
int spp2(int n)
{
    int p=0;
    if(n==1) p=31;
    if(n==2) p=29; 
    if(n==3) p=31; 
    if(n==4) p=30; 
    if(n==5) p=31; 
    if(n==6) p=30; 
    if(n==7) p=31; 
    if(n==8) p=31; 
    if(n==9) p=30; 
    if(n==10) p=31; 
    if(n==11) p=30; 
    if(n==12) p=31;
    return p;  
}
int main()
{
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d%d%d",&mem[i].year,&mem[i].month1,&mem[i].month2);
        if(find(mem[i].year)==0)//???????
        {
            int p=0;
            if(mem[i].month1>mem[i].month2)
            {
                for(j=mem[i].month2;j<mem[i].month1;j++)
                {
                    p+=spp1(j);
                }
            }
/*
            else if(mem[i].month1==mem[i].month2)
            {
                printf("YES\n");
            }
*/
            else
            {
                for(j=mem[i].month1;j<mem[i].month2;j++)
                {
                    p+=spp1(j);
                }
            }
            if(p%7==0)
            {
                printf("YES\n");    
            }
            else
            {
                printf("NO\n");
            }
        }
        else
        {
            int p=0;
            if(mem[i].month1>mem[i].month2)
            {
                for(j=mem[i].month2;j<mem[i].month1;j++)
                {
                    p+=spp2(j);
                }
            }
/*
            else if(mem[i].month1==mem[i].month2)
            {
                printf("YES\n");
            }
*/
            else
            {
                for(j=mem[i].month1;j<mem[i].month2;j++)
                {
                    p+=spp2(j);
                }
            }
            if(p%7==0)
            {
                printf("YES\n");    
            }
            else
            {
                printf("NO\n");
            }
        }
    }
    return 0;
}
int main()
{
    int nian,yue1,yue2;
    int turn,i,j,days=0,temp;
    int szp[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    int szr[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    scanf("%d",&turn);
   
                   
    for(i=0;i<turn;i++){
                        scanf("%d%d%d",&nian,&yue1,&yue2);
                        if(yue1 >yue2){
                                       temp=yue1;
                                       yue1=yue2;
                                       yue2=temp;
                                       }
                        if( (nian%4 !=0) || ( (nian%400 !=0) && (nian%100 == 0) ) ){
                                     days=szp[yue1-1];
                                     for(j=yue1;j<yue2-1;j++)
                                                           days+=szp[j];
                                     if(days%7 == 0)
                                               printf("YES\n");
                                     else
                                               printf("NO\n");
                        }else{
                               days=szr[yue1-1];
                               for(j=yue1;j<yue2-1;j++)
                                                           days+=szr[j];
                                     if(days%7 == 0)
                                               printf("YES\n");
                                     else
                                               printf("NO\n");
                               }
                        }
   
        return 0;                      
 }
int judge(int a)
{
    if (((a%100!=0)&&(a%4==0))||(a%400==0)) return 1;
    else return 0;
}
main()
{     int d[12]={31,28,31,30,31,30,31,31,30,31,30,31};
      int a,b,c,i,j,x,n,day;
      scanf("%d",&n);
      for (i=0;i<n;i++)
      {
          scanf("%d %d %d",&a,&b,&c);
          if (b>c){x=b; b=c; c=x;}
          x=judge(a);
          day=0;
          for (j=b;j<=c-1;j++)
          {
              day=day+d[j-1];
              if ((j==2)&&(x==1)) day++;
              }
          if (day%7==0) printf("YES\n");
          else printf("NO\n");
          /*printf("%d\n",day);*/
      }
    
}
int pd(int a)
{
    if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)
       return 31;
    else if(a==2)
       return 28;
    else
       return 30;
}
main()
{
       int i,y,a,b,n,l,m,s,t;
       scanf("%d",&n);
       for(i=1;i<=n;i++)
       {
          scanf("%d %d %d",&y,&a,&b);
          if(a<b)
          {
             t=a;
             a=b;
             b=t;
          }
          if((y%4==0&&y%100!=0)||y%400==0)
          {
             s=0;
             if(b>=3)
             {
                for(b;b<a;b++)
                   s=s+pd(b);
                if(s%7==0)
                   printf("YES\n");
                else
                   printf("NO\n");
             }
             else if(b<=2&&a>2)
             {
                for(;b<a;b++)
                   s=s+pd(b);
                s++;
                if(s%7==0)
                   printf("YES\n");
                else
                   printf("NO\n");
             }
             else
                printf("NO\n");
          }
          else
          {
             s=0;
             for(;b<a;b++)
                   s=s+pd(b);
                if(s%7==0)
                   printf("YES\n");
                else
                   printf("NO\n");
          }
       }     
}
int main(int argc, char* argv[])
{
	int days[11]={31,0,31,30,31,30,31,31,30,31,30},year=0,month1=0,month2=0,i=0,j=0,n=0,mid=0,total=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&year,&month1,&month2);
		if((year%400==0)||((year%4==0)&&(year%100!=0)))
			days[1]=29;
		else days[1]=28;
		if(month1>month2)
		{
			mid=month1;
			month1=month2;
			month2=mid;
		}
		total=days[month1-1];
		for(j=0;j<month2-month1-1;j++)
		{
			total+=days[month1+j];
		}
		if(i!=n-1)
		{
			if(total%7==0)
			{
				printf("YES\n");
			}
			else printf("NO\n");
		}
		if(i==n-1)
		{
			if(total%7==0)
			{
				printf("YES");
			}
			else printf("NO");
		}
	}
	return 0;
}
int main()
{
	int k, yyyy, nn, mm, i, j, c;
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int b[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int  n, m;
	scanf("%d",&k);
	for(i=1;i<=k;i++)
	{
		scanf("%d%d%d",&yyyy,&nn,&mm);
		if(mm>nn)
		{
           n=mm;
		   m=nn;
		}
		else
		{
			n=nn;m=mm;
		}
		if(yyyy%400==0||(yyyy%100!=0&&yyyy%4==0))
		{ 
			c=0;
          for(j=m;j<n;j++)
		  {
             c=c+b[j-1];
		  }
		  if(c%7==0) printf("YES\n");
		  else printf("NO\n");
		}
		else
		{
          c=0;
          for(j=m;j<n;j++)
		  {
             c=c+a[j-1];
		  }
		  if(c%7==0) printf("YES\n");
		  else printf("NO\n");
		}
	}
	
	return 0;
}
int f(int x)
{
	int y;
	y=(((x%4==0)&&(x%100!=0))||(x%400==0))?1:0;
	return (y);
}
int main()
{
	int a=0,b=0,c=0,p=0,n=0;
	int q=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d %d",&a,&b,&c);
		if(b>c)
		{
			q=b;
			b=c;
			c=q;
		}
		if(f(a)== 1 && b<=2 && c>2 )
					p+=1;
		for(b;b<c;b++)
		{
			switch(b)
			{
			case(2):p+=28;break;
			case(4):p+=30;break;
			case(6):p+=30;break;
			case(9):p+=30;break;
			case(11):p+=30;break;
			default:p+=31;break;
			}
		}
		if(p%7==0)
			printf("YES\n");
		else 
			printf("NO\n");
		p=0;
	}
	return 0;
}
int main()
{
    int i,j,k,m,n;
    int *y,*m1,*m2;
    y=(int *)malloc(200*sizeof(int));
    m2=(int *)malloc(200*sizeof(int));
    m1=(int *)malloc(200*sizeof(int));
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                    scanf("%d %d %d",y+i,m1+i,m2+i);
    }
    void judge(int x,int y,int z);
    for(i=0;i<n;i++)
    {
                    if(i>0)
                    {
                           printf("\n");
                    }
                    judge(*(y+i),*(m1+i),*(m2+i));
    }
    return 0;
}

void judge(int x,int y,int z)
{
     int i,j,a;
     int p(int x);
     int r(int x);
     if((x%4==0&&x%100!=0)||x%400==0)
     {
                                     i=r(y);
                                     j=r(z);
     }
     else
     {
         i=p(y);
         j=p(z);
     }
     if(i>j)
     {
            a=(i-j)%7;
     }
     else
     {
         a=(j-i)%7;
     }
     if(a==0)
     {
             printf("YES");
     }
     else
     {
         printf("NO");
     }
}

int p(int x)
{
     int i;
     switch(x)
     {
               case 1:i=0;break;
               case 2:i=31;break;
               case 3:i=59;break;
               case 4:i=90;break;
               case 5:i=120;break;
               case 6:i=151;break;
               case 7:i=181;break;
               case 8:i=212;break;
               case 9:i=243;break;
               case 10:i=273;break;
               case 11:i=304;break;
               case 12:i=334;break;
     }
     return i;
}

int r(int x)
{
     int i;
     switch(x)
     {
               case 1:i=0;break;
               case 2:i=31;break;
               case 3:i=59+1;break;
               case 4:i=90+1;break;
               case 5:i=120+1;break;
               case 6:i=151+1;break;
               case 7:i=181+1;break;
               case 8:i=212+1;break;
               case 9:i=243+1;break;
               case 10:i=273+1;break;
               case 11:i=304+1;break;
               case 12:i=334+1;break;
     }
     return i;
}
int main()
{
	int n,year,m1,m2,i,tmp,sum,k,q;
	scanf("%d",&n);
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int b[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&year,&m1,&m2);
		if(m1>m2)
		{
			tmp=m1;
			m1=m2;
			m2=tmp;
		}
		else q=1;

		if((year%4==0&&year%100!=0)||(year%400==0))
		{
			sum=0;
			for(k=m1;k<m2;k++)
			{
				sum+=b[k-1];
			}
			if(sum%7==0)printf("YES\n");
			else printf("NO\n");
		}
		else 
			{
			sum=0;
			for(k=m1;k<m2;k++)
			{
				sum+=a[k-1];
			}
			if(sum%7==0)printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;


}
int main(int argc, char* argv[])
{
	int n;
	scanf("%d", &n);
	int a, b, c, l, i;
	for(i=0; i<n; i++){
		scanf("%d%d%d", &a, &b, &c);
		if((a%400==0)||(a%4==0&&a%100!=0))
			l=29;
		else
			l=28;
		if(b>c){
			int x=b;
			b=c;
			c=x;
		}
		int j, sum=0;
		for(j=b; j<c; j++){
			switch(j){
			case 1:
			case 3:	
			case 5:
			case 7:
			case 8:
			case 10:sum=sum+31;continue;
			case 4:
			case 6:
			case 9:
			case 11:sum=sum+30;continue;
			case 2:sum=sum+l;
			}
		}
		if(sum%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}
void judge(int, int, int);
int main()
{
	int n, year, m1, m2;
	cin >> n;
	for(; n > 0; n--)
	{
		cin >> year >> m1 >> m2;
		judge(year, m1, m2);
	}
	return 0;
}

void judge(int year, int m1, int m2)
{
	int i, s = 0, sum[11] = {3, 0, 3, 2, 3, 2, 3, 3, 2, 3, 2};
	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
		sum[1] = 1;
	if (m2 < m1)
	{
		i = m2;
		m2 = m1;
		m1 = i;
	}
	for (i = m1 - 1; i < m2 - 1; i++)
		s += sum[i];
	if (s % 7 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
int main()
{   
     int n,year[200],m1[200],m2[200],i,j,t,a;
     int run[]={0,31,29,31,30,31,30,31,31,30,31,30,31},feirun[]={0,31,28,31,30,31,30,31,31,30,31,30,31};   //??????????????
      cin>>n;
      for(i=0;i<200;i++)
	{
              cin>>year[i]>>m1[i]>>m2[i];
	 if(m1[i]<m2[i])
	{
	  t=m1[i];
             m1[i]=m2[i];
	  m2[i]=t;
	}                                   //?m1[i]??????
     if((year[i]%4==0)&&(year[i]%100!=0)||(year[i]%400==0))    //???????
	{   
	    a=0;
	    for(j=m2[i];j<m1[i];j++)
	    a=a+run[j];                                       //???????
		if(a%7==0)                             //??????????
			cout<<"YES"<<endl;
		else
		         cout<<"NO"<<endl;
	}
   else
				{                                                        //?????
		a=0;
		for(j=m2[i];j<m1[i];j++)
		       a=a+feirun[j];
		if(a%7==0)
		cout<<"YES"<<endl;
	         else
		cout<<"NO"<<endl;
			}
	}
	return 0;
}
int main()
{
	int fun(int x,int y);
	int value(int x,int y);
	int n,year,month1,month2,i,a,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&year,&month1,&month2);
		a=fun(year,month1);
		b=fun(year,month2);
		if((value(a,b))%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

int fun(int x,int y)
{
	int k=0,days;
	if((x%4==0&&x%100!=0)||x%400==0)
		k=1;
	if(y==1)
		days=0;
	if(y==2)
		days=31;
	if(y==3)
		days=31+28+k;
	if(y==4)
		days=31+28+31+k;
	if(y==5)
		days=31+28+31+30+k;
	if(y==6)
		days=31+28+31+30+31+k;
	if(y==7)
		days=31+28+31+30+31+30+k;
	if(y==8)
		days=31+28+31+30+31+30+31+k;
	if(y==9)
		days=31+28+31+30+31+30+31+31+k;
	if(y==10)
		days=31+28+31+30+31+30+31+31+30+k;
	if(y==11)
		days=31+28+31+30+31+30+31+31+30+31+k;
	if(y==12)
		days=31+28+31+30+31+30+31+31+30+31+30+k;
	return(days);
}

int value(int x,int y)
{
	int c;
	if(x>y)
		c=x-y;
	else
		c=y-x;
	return(c);
}
int a[20];
main()
{
	void run(int x,int y);
	void ping(int x,int y);
	int n,i,j,k,year,y,r;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&year,&y,&r);
		if(year%400==0||(year%4==0&&year%100!=0))
		run(y,r);
		else ping(y,r);
	} 
}
void run(int x,int y)
{
	a[1]=a[3]=a[5]=a[7]=a[8]=a[10]=a[12]=31;
	a[4]=a[6]=a[9]=a[11]=30;
	a[2]=29;
	int m,n,i,j,k=0;
	m=x>y?x:y;
	n=x<y?x:y;
	for(i=n;i<m;i++)
	k=k+a[i];
	if(k%7==0)printf("YES\n");
	else printf("NO\n");
}
void ping(int x,int y)
{
	a[1]=a[3]=a[5]=a[7]=a[8]=a[10]=a[12]=31;
	a[2]=28;
	a[4]=a[6]=a[9]=a[11]=30;
	int m,n,i,j,k=0;
	m=x>y?x:y;
	n=x<y?x:y;
	for(i=n;i<m;i++)
	k=k+a[i];
	if(k%7==0)printf("YES\n");
	else printf("NO\n");
}
main()
{
      int x,y,z,n,i,t,s;
      int a[13];
      a[1]=31;
      a[3]=31;
      a[5]=31;
      a[7]=31;
      a[8]=31;
      a[10]=31;
      a[12]=31;
      a[4]=30;
      a[6]=30;
      a[9]=30;
      a[11]=30;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {  t=0;
         scanf("%d %d %d",&x,&y,&z);
         if(y>z){s=y;y=z;z=s;}
         a[2]=((x%400==0)||(x%100!=0&&x%4==0))?29:28;
         for(int j=y;j<z;j++)
            t=t+a[j];
         if(t%7==0)printf("YES\n");
         else printf("NO\n");
      }
      
}
int main(){
    int ans,i,N,y,a,b,sum1[13],sum2[13],mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    sum1[0]=sum2[0]=0;
    for(i=1;i<=12;i++){
        sum1[i]=sum1[i-1]+mon[i];
        sum2[i]=sum2[i-1]+mon[i];
        if(i==2)sum2[i]++;
       }
    scanf("%d",&N);
    while(N--){
       scanf("%d%d%d",&y,&a,&b);
       ans=0;
       if(a>b){a^=b;b^=a;a^=b;}
       if((y%100==0&&y%400==0)||(y%100&&y%4==0))ans=(sum2[b-1]-sum2[a-1])%7;
       else ans=(sum1[b-1]-sum1[a-1])%7;
       
        if(!ans)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}
void main()
{
int n;
scanf("%d",&n);
int i,j;
int b[2];
int month[200][2];
int year[200];
for(i=0;i<n;i++){
scanf("%d %d %d",&year[i],&month[i][1],&month[i][2]);
}
int a1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int a2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
for(i=0;i<n;i++){
if((year[i]%400)!=0&&(year[i])%4!=0){
int m1=month[i][1];
int m2=month[i][2];
b[0]=0;
b[1]=0;
int sum1=0;
int sum2=0;
for(j=1;j<m1;j++){
sum1=sum1+a1[j-1];
}
for(j=1;j<m2;j++){
sum2=sum2+a1[j-1];
}
b[0]=sum1+1;
b[1]=sum2+1;
if((b[0]-b[1])%7==0){
printf("YES\n");}
else{
printf("NO\n");
}
}
else if((year[i]%100)!=0&&(year[i])%4==0){
int m1=month[i][1];
int m2=month[i][2];
b[0]=0;
b[1]=0;
int sum1=0;
int sum2=0;
for(j=1;j<m1;j++){
sum1=sum1+a2[j-1];
}
for(j=1;j<m2;j++){
sum2=sum2+a2[j-1];
}
b[0]=sum1+1;
b[1]=sum2+1;
if((b[0]-b[1])%7==0){
printf("YES\n");}
else{
printf("NO\n");
}
}


else if((year[i]%400)==0){
int m1=month[i][1];
int m2=month[i][2];
b[0]=0;
b[1]=0;
int sum1=0;
int sum2=0;
for(j=1;j<m1;j++){
sum1=sum1+a2[j-1];
}
for(j=1;j<m2;j++){
sum2=sum2+a2[j-1];
}
b[0]=sum1+1;
b[1]=sum2+1;
if((b[0]-b[1])%7==0){
printf("YES\n");}
else{
printf("NO\n");
}
}

else if((year[i]%400)!=0){
int m1=month[i][1];
int m2=month[i][2];
b[0]=0;
b[1]=0;
int sum1=0;
int sum2=0;
for(j=1;j<m1;j++){
sum1=sum1+a1[j-1];
}
for(j=1;j<m2;j++){
sum2=sum2+a1[j-1];
}
b[0]=sum1+1;
b[1]=sum2+1;
if((b[0]-b[1])%7==0){
printf("YES\n");}
else{
printf("NO\n");
}
}


}


}
int main(int argc, char* argv[])
{
	int n,i,y,j,mf,ms,d=0,yue[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	scanf("%d",&n);
	for(i = 0;i<n;i++)
	{
		d=0;yue[1]=28;
		scanf("%d%d%d",&y,&mf,&ms);
		if(((y%4==0)&&(y%100!=0))||(y%400==0)) {yue[1]=29;}
		if(mf>ms)
		{
			for(j=ms-1;j<mf-1;j++)
			{
				d += yue[j];

			}

		}
        else if(mf<ms)
		{
			for(j=mf-1;j<ms-1;j++)
			{
				d += yue[j];

			}

		}
		if(d%7==0) {printf("YES\n");}
		else {printf("NO\n");}
		
	}
	return 0;
}
int main()
{
	int x,a[200],b[200],c[200],f[200],g[200],h[200],i,j;
	int d[12]={3,0,3,2,3,2,3,3,2,3,2,3};
	int e[12]={3,1,3,2,3,2,3,3,2,3,2,3};
	cin>>x;
	for(i=0;i<x;i++)
		cin>>a[i]>>b[i]>>c[i];
	for(i=0;i<x;i++)
		h[i]=0;
	for(i=0;i<x;i++)
		{
			if(b[i]>c[i])
			{
				f[i]=b[i];
				g[i]=c[i];
			}
			else
			{
				g[i]=b[i];
				f[i]=c[i];
			}
	}
	for(i=0;i<x;i++)
	for(j=g[i]-1;j<f[i]-1;j++)
	{
		if((a[i]%4==0&&a[i]%100!=0)||a[i]%400==0)
		h[i]=h[i]+e[j];
		else
		h[i]=h[i]+d[j];
	}
	for(i=0;i<x;i++)
	{
		if(h[i]%7==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}
int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int is_leap_year(int y)
{
    if ((y%400==0) || (y%4==0 && y%100!=0))
        return 1;
    else
        return 0;
}
int main()
{
    int i, n, j;
    int year, m1, m2, max, min, sum;

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d%d%d", &year, &m1, &m2);
        max = (m1 > m2) ? m1 : m2;
        min = (m1 < m2) ? m1 : m2;
        sum = 0;
        if (is_leap_year(year)) days[1] ++; // ???2?????
        for (j=min-1; j<max-1; j++)
            sum += days[j];
        if (sum % 7 == 0)
            printf("YES\n");
        else
            printf("NO\n");
        if (is_leap_year(year)) days[1] --; // ???2?????
}
return 0;
}
int main(){
	int n,i,j;
	scanf("%d",&n);
	int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	for(i=0;i<n;i++){
		int y,m1,m2;
		int cha=0;
		scanf("%d%d%d",&y,&m1,&m2);
		if((y%4==0&&y%100!=0)||(y%400==0)){
			if((m1<3)&&(m2>=3)){
				for(j=m1;j<m2;j++){
					cha+=days[j];
				}
				cha++;
			}
			else if((m2<3)&&(m1>=3)){
				for(j=m2;j<m1;j++){
					cha+=days[j];
				}
				cha++;
			}
			else if(m2>m1){
				for(j=m1;j<m2;j++){
					cha+=days[j];
				}
			}
			else if(m1>m2){
				for(j=m2;j<m1;j++){
					cha+=days[j];
				}
			}
		}
		else{
			if(m2>m1){
				for(j=m1;j<m2;j++){
					cha+=days[j];
				}
			}
			else{
				for(j=m2;j<m1;j++){
					cha+=days[j];
				}
			}
		}
		if(cha%7==0){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}
int main()
{
	int n,y,m1,m2,i,a,j,b=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&y,&m1,&m2);
		if(m1>m2){
			a=m1;
			m1=m2;
			m2=a;
		}
		for(j=m1;j<m2;j++){
			if(j==1||j==3||j==5||j==7||j==8||j==10){
				b +=31;
			}
			else if(j==4||j==6||j==9||j==11){
				b +=30;
			}
			else if(j==2&&(y%4==0&&y%100!=0||y%400==0)){
				b +=29;
			}
			else if(j==2&&(y%4!=0||y%400!=0)){
				b +=28;
			}
		}
		if(b%7==0){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
		b=0;
	}
	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 m1,int m2){
	int result = 0;
	for(int i = m1; i < m2; 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;
			}	
		}
	}
	if(result%7==0) return 1;
	else return 0;
}


int main()
{
	int n,i,year[1000],m1[1000],m2[1000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&year[i],&m1[i],&m2[i]);
	}
	for(i=0;i<n;i++){
		if(m1[i]<m2[i]){
			if(DiJiTian(year[i],m1[i],m2[i])) printf("YES\n");
			else printf("NO\n");
		}
		else{
			if(DiJiTian(year[i],m2[i],m1[i])) printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;
}
int main()
{
 int n,j,s[250];
 int year,month1,month2,p;
 int monthday[12]={31,28,31,30,31,30,31,31,30,31,30,31};
 scanf("%d",&n);
 for(j=1;j<=n;j++)
{
 scanf("%d %d %d",&year,&month1,&month2);
 int i;
 int sum1=0;
 for(i=1;i<month1;i++)
 {sum1=sum1+monthday[i-1];}
 sum1=sum1+1;
 int k;
 int sum2=0;
for(k=1;k<month2;k++)
 {sum2=sum2+monthday[k-1];}
 sum2=sum2+1;
 int a;
 a=year%4;
 if(month1>2&&(a==0&&year%100!=0||year%400==0))
 {sum1=sum1+1;}
 if(month2>2&&(a==0&&year%100!=0||year%400==0))
 {sum2=sum2+1;}
 p=sum2-sum1;
 if(p%7==0)
 s[j]=1;
 else s[j]=0;
}
for(j=1;j<=n;j++)
{if(s[j]==1)
 printf("YES\n");
 else printf("NO\n");
}
 return 0;
}