semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
    int n,j;
    scanf("%d",&n);
    for(j=0;j<n;j++){
int days[] = { 0, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31 };
int y, m, d, i,c=0,q=0;
scanf("%d%d%d", &y,&m,&d);
if ((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0))
days[2]++;
for (i = 1; i < m; i++)
c += days[i];
for (i = 1; i < d; i++)
q += days[i];
if(c>q)
c=c-q;
else
c=q-c;
if(c%7==0)
printf("YES\n");
else
printf("NO\n");}
}
int main()
{
	int n, y, year, month1, month2, i, j, m;
	scanf ("%d",&n);
	for (j=0; j<n; j++){
		int total1=0, total2 =0;
		scanf("%d%d%d", &year, &month1, &month2);
		     for( i=1; i<month1; i++)
			 {
		         if ( i ==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)
				 {
				     total1 = total1 +31;
				 }
		         if ( i ==4 || i==6 || i==9 || i==11)
				 {
				     total1 = total1 +30;
				 }
		        if ( i ==2)
				{
				     if( (year%4==0&&year%100!=0) || year%400==0 ){
				        total1 = total1 +29;
					 }
				     else {
					   total1 = total1 +28;
					 }
				}
			 }
	         for( m=1; m<month2; m++)
			 {
		         if ( m ==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12)
				 {
				     total2 = total2 +31;
				 }
		         if ( m ==4 || m==6 || m==9 || m==11)
				 {
				     total2 = total2 +30;
				 }
		         if ( m ==2)
				 {
				    if( (year%4==0&&year%100!=0) || year%400==0 ){
					     total2 = total2 +29;
					}
				    else{
					     total2 = total2 +28;
					}
				 }
			 }
			 y=total1-total2;
	         if (y%7==0){
		         printf ("YES\n");
			 }
		     else {
		     printf ("NO\n");
			 }
	}
	return 0;
}
int main()
{
	int i,n,year,month1,month2,date=1,count1=0,count2=0,day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>n;
	while(n--)
	{
		count1=count2=0;
		cin>>year>>month1>>month2;
		for(i=1;i<month1;i++)
			count1+=day[i];
		count1+=date;
		if(month1>2)
			if((year%400==0)||((year%100!=0)&&(year%4==0)))
				count1++;
		for(i=1;i<month2;i++)
			count2+=day[i];
		count2+=date;
		if(month2>2)
			if((year%400==0)||((year%100!=0)&&(year%4==0)))
				count2++;
		if((count1-count2)%7==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}
int mon;
int day(),month[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int i,j,n,year,month1,month2,days1,days2,daysbetween;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
         scanf("%d %d %d",&year,&month1,&month2);
         if((year%4==0 && year%100!=0) || year%400==0)
               month[1]++;
         days1=day(month1);
         days2=day(month2);
         daysbetween=days1-days2;
         if(daysbetween%7==0)
               printf("YES\n");
         else
               printf("NO\n");
         month[1]=28;
    }
    return 0;
}

int day(int mon){
    int k,days=0;
    for(k=0;k<mon-1;k++)
       days+=month[k];
    return days;
}
int main()
{
int n;
scanf("%d",&n);
int i;
for(i=0;i<n;i++)          
{
        int a,b,c,d;
        d=0;
 scanf("%d %d %d",&a,&b,&c);   
 if((a%400==0)||(a%100!=0&&a%4==0))
 d=1;
 int A[12];
 A[0]=31;A[1]=28;A[2]=31;A[3]=30;A[4]=31;A[5]=30;A[6]=31;A[7]=31;A[8]=30;A[9]=31;A[10]=30;A[11]=31;
  int e;
 if(b>c)
 {int t;t=b;b=c;c=t;}
 e=c-b;
 int f=0;
 int j;
 if(d==1)
 A[1]=29;
 for(j=0;j<e;j++)
   {
     f=f+A[b+j-1];     
   }
   if(f%7==0)
   printf("YES\n");
   else
   printf("NO\n");
}
return(0);
}
int main()
{
	int n,i,a,b,c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		if((a%400==0)||(a%4==0&&a%100!=0))
		{
			if((b==1&&c==4)||(b==1&&c==7)||(b==4&&c==7)||(b==2&&c==8)||(b==9&&c==12)||(b==3&&c==11)
				||(c==1&&b==4)||(c==1&&b==7)||(c==4&&b==7)||(c==2&&b==8)||(c==9&&b==12)||(c==3&&b==11))
				printf("YES\n");
			else printf("NO\n");
		}
		else
		{
			if((b==2&&c==3)||(b==2&&c==11)||(b==3&&c==11)||(b==1&&c==10)||(b==9&&c==12)||(b==4&&c==7)
				||(c==2&&b==3)||(c==2&&b==11)||(c==3&&b==11)||(c==1&&b==10)||(c==9&&b==12)||(c==4&&b==7))
				printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;
}
int main(){
int n,i,j,y,m1,m2,d,day[]={0,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);
d=0;
if(m1>m2){
for(j=m2;j<m1;j++)
d+=day[j];
if(((y%4==0&&y%100!=0)||y%400==0)&&m2<=2)
d+=1;
if(d%7==0)
printf("YES\n");
else 
printf("NO\n");
}
else if(m1<m2){
for(j=m1;j<m2;j++)
d+=day[j];
if(((y%4==0&&y%100!=0)||y%400==0)&&m1<=2)
d+=1;
if(d%7==0)printf("YES\n");
else printf("NO\n");
}
}
return 0;
}
int runnian(int nian){
	if(nian%100==0){
		if(nian%400==0){
			return 1;
		}
		else return 0;
	}
	else {
		if(nian%4==0){
			return 1;
		}
		else return 0;
	}
}
int main(){
	int n;
	int s1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int s2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	cin>>n;
	for(int i=0;i<n;i++){
		int nian,yue1,yue2,days=0;
		cin>>nian>>yue1>>yue2;
		if(yue1>yue2){
			int temp;
			temp=yue1;
			yue1=yue2;
			yue2=temp;
		}
		if(runnian(nian)==0){
			for(int j=yue1-1;j<yue2-1;j++){
				days+=s1[j];
			}
			if(days%7==0){
				cout<<"YES"<<endl;
			}
			else cout<<"NO"<<endl;
		}
		else if(runnian(nian)==1){
			for(int j=yue1-1;j<yue2-1;j++){
							days+=s2[j];
						}
						if(days%7==0){
							cout<<"YES"<<endl;
						}
						else cout<<"NO"<<endl;
		}
		}
	return 0;
}
int main()
{
    int n,i,y,m1,m2,M1,M2;
    scanf("%d",&n);
    for(i=0;i<n;i++)
	{
	   scanf("%d%d%d",&y,&m1,&m2);
	   if((y%4==0&&y%100!=0)||y%400==0)
	   {
	       if(m1==1)
		   {M1=0;};
		   if(m1==2)
		   {M1=31;};
		   if(m1==3)
		   {M1=60;};
		   if(m1==4)
		   {M1=91;};
		   if(m1==5)
		   {M1=121;};
           if(m1==6)
		   {M1=152;};
		   if(m1==7)
		   {M1=182;};
		   if(m1==8)
		   {M1=213;};
		   if(m1==9)
		   {M1=244;};
           if(m1==10)
		   {M1=274;};
		   if(m1==11)
		   {M1=305;};
		   if(m1==12)
		   {M1=335;};

           if(m2==1)
		   {M2=0;};
		   if(m2==2)
		   {M2=31;};
		   if(m2==3)
		   {M2=60;};
		   if(m2==4)
		   {M2=91;};
		   if(m2==5)
		   {M2=121;};
           if(m2==6)
		   {M2=152;};
		   if(m2==7)
		   {M2=182;};
		   if(m2==8)
		   {M2=213;};
		   if(m2==9)
		   {M2=244;};
           if(m2==10)
		   {M2=274;};
		   if(m2==11)
		   {M2=305;};
		   if(m2==12)
		   {M2=335;};
	   }
       else
	   {
	       if(m1==1)
		   {M1=0;};
		   if(m1==2)
		   {M1=31;};
		   if(m1==3)
		   {M1=59;};
		   if(m1==4)
		   {M1=90;};
		   if(m1==5)
		   {M1=120;};
           if(m1==6)
		   {M1=151;};
		   if(m1==7)
		   {M1=181;};
		   if(m1==8)
		   {M1=212;};
		   if(m1==9)
		   {M1=243;};
           if(m1==10)
		   {M1=273;};
		   if(m1==11)
		   {M1=304;};
		   if(m1==12)
		   {M1=334;};

           if(m2==1)
		   {M2=0;};
		   if(m2==2)
		   {M2=31;};
		   if(m2==3)
		   {M2=59;};
		   if(m2==4)
		   {M2=90;};
		   if(m2==5)
		   {M2=120;};
           if(m2==6)
		   {M2=151;};
		   if(m2==7)
		   {M2=181;};
		   if(m2==8)
		   {M2=212;};
		   if(m2==9)
		   {M2=243;};
           if(m2==10)
		   {M2=273;};
		   if(m2==11)
		   {M2=304;};
		   if(m2==12)
		   {M2=334;};
	   }

       if((M1-M2)%7==0)
	   {printf("YES\n");}
	   else
	   {printf("NO\n");}
	}
    return 0;
}
int main()
{
	int n,i;
	cin>>n;                          //????  n=????
	for(i=0;i<n;i++)
	{	
		int year,m[12]={31,28,31,30,31,30,31,31,30,31,30,31},a,b,x=0,j;       //??????
		cin>>year>>a>>b;
		if((year%4==0 && year%100!=0) || year%400==0)                        
			m[1]=29;
		else 
			m[1]=28;                                   //????  ????2???

		if(a>b)
		{
			for(j=b-1;j<a-1;j++)
			{
				x=x+m[j];
			}
			if(x%7==0)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
		else if(a<b)
		{
			for(j=a-1;j<b-1;j++)
			{
				x=x+m[j];
			}
			if(x%7==0)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}                                                //???????????7??
	}
	return 0;
}
int main()
{
    int i,j,n,x,y,z,day=0;
    cin>>n;
    int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int b[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    while(n>0)
    {
       cin>>x>>y>>z;
       if((x%4==0&&x%100!=0)||x%400==0)
       {  if(y<z) { for(i=y;i<z;i++)
              day+=b[i];
           if(day%7==0) cout<<"YES"<<endl;
           else cout<<"NO"<<endl;}
           else { for(i=z;i<y;i++)
              day+=b[i];
           if(day%7==0) cout<<"YES"<<endl;
           else cout<<"NO"<<endl;}
       }
       else {  if(y<z) { for(i=y;i<z;i++)
              day+=a[i];
           if(day%7==0) cout<<"YES"<<endl;
           else cout<<"NO"<<endl;}
           else { for(i=z;i<y;i++)
              day+=a[i];
           if(day%7==0) cout<<"YES"<<endl;
           else cout<<"NO"<<endl;}
       }
       day=0;n--;
    }
    return 0;
}
int main()
{
    int n,a[1000],b[1000],c[1000],i,t[13]={0,31,29,31,30,31,30,31,31,30,31,30,31},q[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int y[1000],w,k,z;
    cin>>n;
    for(i=1;i<=n;i++)
    {
                     cin>>a[i]>>b[i]>>c[i];
                     if(b[i]>c[i])
                     {
                                  w=b[i];
                                  b[i]=c[i];
                                  c[i]=w;
                     }
                     y[i]=0;
    }
    for(i=1;i<=n;i++)
    {
    if(b[i]==c[i]){y[i]=0;}
    else{if((a[i]%4==0&&a[i]%100!=0)||(a[i]%400==0))
    {
                     for(k=b[i];k<=c[i]-1;k++)
                     {
                                            y[i]=y[i]+t[k];
                     }
    } 
     else{
          for(k=b[i];k<=c[i]-1;k++)
                     {
                                            y[i]=y[i]+q[k];
                     } 
          } }                                     
    }
    for(i=1;i<=n-1;i++)
    {
                     if(y[i]%7==0)
                     {
                         cout<<"YES"<<endl;
                     }
                     else{cout<<"NO"<<endl;}
    }
    if(y[n]%7==0)
    {
                      cout<<"YES"<<endl;
    } else{cout<<"NO"<<endl;}
    
    cin>>z;
    return 0;
}
int main()
{
int n,i,y,a,b,j,p,f,e;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&y,&a,&b);
if(a>b)
{
	e=a;
	a=b;
	b=e;
}
if((y%4==0&&y%100!=0)||(y%400==0))
{
p=0;
f=0;
for(j=a;j<b;j++)
{
if(j==1) p=p+31;
if(j==2) p=p+29;
if(j==3) p=p+31;
if(j==4) p=p+30;
if(j==5) p=p+31;
if(j==6) p=p+30;
if(j==7) p=p+31;
if(j==8) p=p+31;
if(j==9) p=p+30;
if(j==10) p=p+31;
if(j==11) p=p+30;
}
if(p%7==0) {printf("YES\n");f=1;}
}

else
{
p=0;
f=0;
for(j=a;j<b;j++)
{
if(j==1) p=p+31;
if(j==2) p=p+28;
if(j==3) p=p+31;
if(j==4) p=p+30;
if(j==5) p=p+31;
if(j==6) p=p+30;
if(j==7) p=p+31;
if(j==8) p=p+31;
if(j==9) p=p+30;
if(j==10) p=p+31;
if(j==11) p=p+30;
}
if(p%7==0) {printf("YES\n");f=1;}
}

if(f==0) printf("NO\n");
}
return 0;
}
int main()
{
	int n, i, j;
	int sum1=0, sum2=0;
	int A[200], B[200], C[200];
	int D[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int E[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	scanf("%d\n", &n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d", &A[i], &B[i], &C[i]);
	}
	for(i=0;i<n;i++)
	{
        sum1=0;
		sum2=0;
	    if(A[i]%4==0&&A[i]%100!=0||A[i]%400==0)
		{
		    for(j=0;j<B[i]-1;j++)
			{
              sum1+=E[j];
			}
		    for(j=0;j<C[i]-1;j++)
			{
		      sum2+=E[j];
			}
		}
	   else
	   {
		    for(j=0;j<B[i]-1;j++)
			{
               sum1+=D[j];
			}
		    for(j=0;j<C[i]-1;j++)
			{
			   sum2+=D[j];
			}
	   }
	
		if(sum1>sum2&&(sum1-sum2)%7==0||sum1<sum2&&(sum2-sum1)%7==0)
			printf("YES\n");
		else 
			printf("NO\n");
	}
	return 0;
}
int main()
{
	int n;
	cin>>n;
	int month[201][3];
	int day1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int day2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int i,j;
	for(i=0;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			cin>>month[i][j];
		}
	}
	int sum1;
	int sum2;
	for(i=0;i<n;i++)
	{
		if((month[i][0]%400==0)||((month[i][0]%4==0)&&(month[i][0]%100!=0)))
		{
			sum1=0;
			sum2=0;
			for(j=0;j<month[i][1]-1;j++)
			{
				sum1=sum1+day2[j];
			}
			for(j=0;j<month[i][2]-1;j++)
			{
				sum2=sum2+day2[j];
			}
			if((abs(sum2-sum1))%7==0)
			{
				cout<<"YES"<<endl;
			}
			else
			{
				cout<<"NO"<<endl;
			}
		}
		else
		{
			sum1=0;
			sum2=0;
			for(j=0;j<month[i][1]-1;j++)
			{
				sum1=sum1+day1[j];
			}
			for(j=0;j<month[i][2]-1;j++)
			{
				sum2=sum2+day1[j];
			}
			if((abs(sum2-sum1))%7==0)
			{
				cout<<"YES"<<endl;
			}
			else
			{
				cout<<"NO"<<endl;
			}
		}
	}
	return 0;
}
int main()
{
  int a,b,c,n,i;
  void f(int a,int b,int c);
  scanf("%d",&n);
  for(i=0;i<n;i++)
   {
    scanf("%d%d%d",&a,&b,&c);
    f(a,b,c);
   }
  
  return 0;
}
void f(int a,int b,int c)
{
 int t1,t2;
 if((a % 4 == 0 && a % 100 != 0) || (a % 400 == 0))
       {
       if(b==1)  t1=1;  if(c==1)  t2=1;
       if(b==2) t1=32;  if(c==2) t2=32;
       if(b==3) t1=61;  if(c==3) t2=61;
       if(b==4) t1=92;  if(c==4) t2=92;
       if(b==5) t1=122; if(c==5) t2=122;
       if(b==6) t1=153; if(c==6) t2=153;
       if(b==7) t1=183; if(c==7) t2=183;
       if(b==8) t1=214; if(c==8) t2=214;
       if(b==9) t1=245; if(c==9) t2=245;
       if(b==10)t1=275; if(c==10)t2=275;
       if(b==11)t1=306; if(c==11)t2=306;
       if(b==12)t1=336; if(c==12)t2=336;
       }
 else
   {
       if(b==1)  t1=1;  if(c==1)  t2=1;
       if(b==2) t1=32;  if(c==2) t2=32;
       if(b==3) t1=60;  if(c==3) t2=60;
       if(b==4) t1=91;  if(c==4) t2=91;
       if(b==5) t1=121; if(c==5) t2=121;
       if(b==6) t1=152; if(c==6) t2=152;
       if(b==7) t1=182; if(c==7) t2=182;
       if(b==8) t1=213; if(c==8) t2=213;
       if(b==9) t1=244; if(c==9) t2=244;
       if(b==10)t1=274; if(c==10)t2=274;
       if(b==11)t1=305; if(c==11)t2=305;
       if(b==12)t1=335; if(c==12)t2=335;
   }
 if(abs(t1-t2)%7==0) printf("YES\n");
 else printf("NO\n");
}
int main()
{
	int n, i, a, b, c, x = 0, sum = 0;
	cin >> n;
	for ( i = 1; i <= n; i ++ )
	{
		cin >> a >> b >> c;
		if ( b > c )
		{
			x = b;
			b = c;
			c = x;
		}
		if ( ( a % 400 == 0 ) || ( a % 100 != 0 && a % 4 == 0 ) )
		{
			for ( ; b < c; b ++ )
			{
				if ( b == 2 )
					sum = sum + 29;
				else if ( b == 4 || b == 6 || b == 9 || b == 11 )
					sum = sum + 30;
				     else sum = sum + 31;
			}
		}
		else 
		{
			for ( ; b < c; b ++ )
			{
				if ( b == 2 )
					sum = sum + 28;
				else if ( b == 4 || b == 6 || b == 9 || b == 11 )
					sum = sum + 30;
				     else sum = sum + 31;
			}

		}
		if ( sum % 7 == 0 )
			cout << "YES" << endl;
		else cout << "NO" << endl;
		sum = 0;
		x = 0;
		a = 0; b = 0; c = 0;
	}
	return 0;
}
/*
 * month.cpp
 *
 *  Created on: 2010-12-25
 *      Author: ???
 *      Function: ???
 */
int day1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};//????????
int day2[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};//???????
int bissextile(int year){//???????????????1?????0
	if(year%400==0||(year%4==0&&year%100!=0)) return 1;
	else return 0;
}
int relative(int month1,int month2,int year){
	int days=0;
	if(bissextile(year))//??????????????????
		for(int i=month1;i<month2;i++)
			days=days+day2[i];
	else//???????????????????
		for(int i=month1;i<month2;i++)
			days=days+day1[i];
	if(days%7==0) return 1;//??????1?????0
	else return 0;
}
int main()
{
	int n,year,month1,month2,relation;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>year>>month1>>month2;
		if(month1<month2) relation=relative(month1,month2,year);
		else if(month1>month2) relation=relative(month2,month1,year);
		else relation=1;
		if(relation) cout<<"YES"<<endl;//??????YES?????NO
		else cout<<"NO"<<endl;
	}
	return 0;
}
//******************************************************************
//*???????                                                  *
//*??????????????????                            *
//*??????                                                    *
//*???2010?10?25?                                            *
//******************************************************************
int main()
{
	int n, i, a, b, c, t, p, q;                                 //????
	cin >> n;                                                   //??n
	for ( i = 1; i <= n; i ++)                                  //?n??????????
	{
		while (cin >> a >> b >> c)                              //??a,b,c?????????
		{
		if (a % 4 == 0 && a % 100 != 0 || a % 400 == 0)         //???????
		p = 1;
		else p = 0;
			if ( b < c )
			{	t = b, b = c, c = t;}                           //??b,c???????????
			int s = 0;
				for ( i = c; i < b; i ++)                       //?b,c?????????????
				{  
					if ( i == 1 || i == 3 || i == 5             //???????????????
						|| i == 7 || i == 8 || i == 10 
						|| i == 12)
						q = 31;
					if ( i == 4 || i == 6 || i == 9 || i == 11)
						q = 30;
					if ( i == 2 && p == 0)
						q = 28;
					if ( i == 2 && p == 1)
						q = 29;
					s = s + q ;                                      //s??????????
				}
				if ( s % 7 == 0)                                     //?????7??????
					cout << "YES"<<endl;                             //????
				else if ( s% 7 != 0) cout << "NO"<<endl;
				}
	}
	
	return 0;
}
int main()
{
	int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int n,year,month1,month2,i,j,sum,begin,end;


	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&year,&month1,&month2);


		if( (year%4==0 && year%100!=0)||(year%400==0) )
		{ 
			days[2]=29; 
		}
		else 
		{
			days[2]=28;
		}


		if (month1>month2)
		{
			begin=month2;
			end=month1;
		}
		else 
		{
			begin=month1;
			end=month2;
		}



        sum=0;
		for (j=begin;j<end;j++)
		{
			sum=sum+days[j];
		}



		if(sum%7==0)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}



	return 0;
}
int main()
{
	int n,y,a[13],p,q,i,b,sum=0,c,temp=0;
	a[1]=31;a[3]=31;a[4]=30;a[5]=31;a[6]=30;a[7]=31;a[8]=31;a[9]=30;a[10]=31;a[11]=30;a[12]=31;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		 scanf("%d%d%d",&y,&p,&q);
		 if (y%4==0 && y%100!=0 || y%400==0)
		 {
			 a[2]=29;
			 if(p>q)
			 {
				 for(b=q;b<p;b++){sum+=a[b];};}
			 else {for(b=p;b<q;b++){sum+=a[b];};}
			 if(sum%7==0)
			 {
				 printf("YES\n");
			 }
			 else printf("NO\n");sum=0;
		 }
		 else
		 {
			 a[2]=28;
			 if(p>q)
			 {
				 for(c=q;c<p;c++){temp+=a[c];};}
			 else {for(c=p;c<q;c++){temp+=a[c];};}
			 if(temp%7==0)
			 {
				 printf("YES\n");
			 }
			 else printf("NO\n");temp=0;
		 }
	} 
	return 0;
}
void main()
{
	int c[200];
	int i,num,y,m,d,k,t;
	int a[12]={0,31,59,90,120,151,181,212,243,273,304,334};
	int b[12]={0,31,60,91,121,152,182,213,244,274,305,335};
	scanf("%d",&num);
	for(i=0;i<num;i++)
	{
		scanf("%d %d %d",&y,&m,&d);
		if(m>d)
		{
			t=m;
			m=d;
			d=t;

		}
		if(((y%4==0)&&(y%100!=0))||(y%400==0))
		{
			k=b[d-1]-b[m-1];
			k=k%7;
			if(k==0)
				c[i]=1;
			else
				c[i]=0;
		}
		else
		{
		
			k=a[d-1]-a[m-1];
			k=k%7;
			if(k==0)
				c[i]=1;
			else
				c[i]=0;
		}
	}
	for(i=0;i<num;i++)
	{
		if(c[i]==1)
			printf("YES\n");
		else
			printf("NO\n");
	}
}
int main()
{
 int m[12],a,b,c,d,i,sum,r,s;
 m[0]=0;
 m[1]=31;
 m[2]=28;
 m[3]=31;
 m[4]=30;
 m[5]=31;
 m[6]=30;
 m[7]=31;
 m[8]=31;
 m[9]=30;
 m[10]=31;
 m[11]=30;
 scanf("%d",&r);
 for(s=0;s<r;s++){
 scanf("%d %d %d",&a,&b,&c);
 sum=0;
 if(b>c){
	 d=b;
	 b=c;
	 c=d;
 }
 for(i=b;i<c;i++){
	 sum=sum+m[i];
 }
 if(b<3){
	  if(((a%4==0)&&(a%100!=0))||(a%400==0)){
		  sum=sum+1;
	  }
 }
 if((sum%7)==0)
	 printf("YES\n");
 else printf("NO\n");
 }
 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++){ 	//step1
		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;	//step2
	return result;	
}

int main(int argc, char* argv[])
{int n;
   int sz[200][3];
   scanf("%d",&n);
   int a=0;
   int b=0;

   for(int i=0;i<n;i++){
	   scanf("%d %d %d",&sz[i][0],&sz[i][1],&sz[i][2]);
	   a=DiJiTian(sz[i][0],sz[i][1],1)-DiJiTian(sz[i][0],sz[i][2],1);
       b=a%7;
	   if(b==0){
		   printf("YES\n");
	   }
	   else{
		   printf("NO\n");
	   }
	   
	   
   }
	return 0;
}
int main()
{
	int n,i,k;
    int year[200],month1[200],month2[200];
	int result1,result2,day;
	scanf("%d",&n);
	for(k=0;k<n;k++)
	{
		scanf("%d %d %d",&year[k],&month1[k],&month2[k]);
	}
	for(k=0;k<n;k++)
	{
		result1=0;
		result2=0;
	for( i = 1; i < month1[k]; i++)
	{ 	
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
		{
			result1+= 31;	
		} 
		else if (i == 4 || i ==6 || i == 9 || i==11)
		{
			result1+= 30;
		}
		else if(i == 2)
		{
			if(year[k]%400 == 0 ||(year[k]%4==0 && year[k]%100!=0))
			{
				result1+= 29;
			} 
			else 
			{
				result1+= 28;
			}	
		}
	}
	for( i = 1; i < month2[k]; i++)
	{ 	
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
		{
			result2+= 31;	
		} 
		else if (i == 4 || i ==6 || i == 9 || i==11)
		{
			result2+= 30;
		}
		else if(i == 2)
		{
			if(year[k]%400 == 0 ||(year[k]%4==0 && year[k]%100!=0))
			{
				result2+= 29;
			} 
			else 
			{
				result2+= 28;
			}	
		}
	}
	day=result1-result2;
if(day < 0){
		day = 0 - day;
}
if(day%7==0)
{
	printf("YES\n");
}
else{
	printf("NO\n");
}
	}

	return 0;
}
int main()
{
	 int total=0,y,m1,m2,i,j,n;
     int t1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	 int t2[12]={31,29,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((y%4==0 && y%100 !=0)||y%400==0)
		{
			if(m1>m2)
			{
				total=0;
			    for(j=m2;j<m1;j++)
				{
				  total+=t2[j-1];
				}
			    if(total%7==0){
			      printf("YES\n");
				}
			    else 
				  printf("NO\n");
				
			}
			else if(m1<m2)
			{
				total=0;			   
				for(j=m1;j<m2;j++)
				{
				  total+=t2[j-1];
				}
			    if(total%7==0){
			      printf("YES\n");
				}
			    else 
				  printf("NO\n");
				
			}
		}
		else 
		{	
			if(m1>m2)
			{
				total=0;
			    for(j=m2;j<m1;j++)
				{
				  total+=t1[j-1];
				}
			    if(total%7==0){
                  printf("YES\n");
				}
			    else {
				  printf("NO\n");
				}
			}
			else if(m1<m2)
			{
				total=0;			   
				for(j=m1;j<m2;j++)
				{
				  total+=t1[j-1];
				}
			    if(total%7==0){
			      printf("YES\n");
				}
			    else {
				  printf("NO\n");
				}
			}
		}
    }		
	return 0;
}
int f(int,int);
int main(){
	int n,i,e;
	scanf("%d",&n);
	int y[n],m1[n],m2[n];
    for(i=0;i<n;i++){
		scanf("%d %d %d",&y[i],&m1[i],&m2[i]);
	}
	for(i=0;i<n;i++){
		if(m1[i]<m2[i]){
			e=m1[i];
			m1[i]=m2[i];
			m2[i]=e;
		}
		if((f(y[i],m1[i])-f(y[i],m2[i]))%7==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
		
}
int f(int y,int m){
	int x=0;
	for(int i=1;i<m;i++){
		if(i==4||i==6||i==9||i==11){
			x+=30;
		}else if(i==2){
			if(y%400==0||(y%4==0&&y%100!=0)){
				x+=29;
			}else{
				x+=28;
			}
		}else{
			x+=31;
		}
	}
	return x;
}
int main(int argc, char* argv[])
{
	int n,i,j,k,l;
	int a[13];//mei gei yue de tian shu//
	int b[201];//nian fen//
	int c[201],d[201],sum[201];//diyigeyuefen   di er ge//
	
	scanf("%d",&n);
    for(l=1;l<=n;l++){
		sum[l]=0;}
	for(i=1;i<=n;i++){
		scanf("%d %d %d",&b[i],&c[i],&d[i]);
		if(((b[i]%4==0)&&(b[i]%100!=0))||(b[i]%400==0)){
			 a[1]=31,a[2]=29,a[3]=31,a[4]=30,a[5]=31,a[6]=30,a[7]=31,a[8]=31,a[9]=30,a[10]=31,a[11]=30,a[12]=31;}
		else{
             a[1]=31,a[2]=28,a[3]=31,a[4]=30,a[5]=31,a[6]=30,a[7]=31,a[8]=31,a[9]=30,a[10]=31,a[11]=30,a[12]=31;}
		if(c[i]>d[i]){
			for(j=d[i];j<c[i];j++){
				sum[i]=sum[i]+a[j];}}
		else{
			for(j=c[i];j<d[i];j++){
				sum[i]=sum[i]+a[j];}}
	
	}
	for(k=1;k<=n;k++){
		if(sum[k]%7==0){
			printf("YES\n");}
			
		else{
			printf("NO\n");}
	}
		
			
		
	return 0;
}
int main()
{
int year, mo1, mo2, i, j, n, temp, specialY, day, dayinMonth;
cin >> n;
for(i = 0; i < n; i++)
{
cin >> year >> mo1 >> mo2;
specialY = 0;
day = 0;
if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
specialY = 1;
if(mo1 > mo2)
{
temp = mo1;
mo1 = mo2;
mo2 = temp;
}
for(j = mo1; j < mo2; j++)
{
switch(j)
{
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12: dayinMonth = 31; break;
	case 2: if (specialY == 1) dayinMonth = 29;
		    else dayinMonth = 28; break;
	case 4:
	case 6:
	case 9:
	case 11: dayinMonth = 30; break;
	default:;
}
day += dayinMonth;
}
if(day % 7 == 0)
cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}