semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main(int argc, char* argv[])
{
	int n,i,j,a,b,c,m;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&a,&b,&c);
			if(b>c){
				int x;
				x=b;
				b=c;
				c=x;
			}
			if(a%400==0)
			{
				m=0;
			}
			else if(a%100==0&&a%400!=0)
			{				
				m=1;
			}			
			else if(a%100!=0&&a%4==0)
			{
				m=0;
			}
			else if(a%4!=0)
			{
				m=1;
			}
			int d=0;
			if(m==0)
			{
				int f[12]={31,29,31,30,31,30,31,31,30,31,30,31};
				for(j=(b-1);j<(c-1);j++)
				{
					d+=f[j];
				}
				
			}

	        else if(m==1)
			{
				int f[12]={31,28,31,30,31,30,31,31,30,31,30,31};
				for(j=(b-1);j<(c-1);j++)
				{
					d+=f[j];
				}
			}
			if(d%7==0)
			{
				printf("YES\n");
			}
			else if(d%7!=0)
			{
				printf("NO\n");
			}
	}
	return 0;	



}
int main(int argc, char* argv[])
{
	int n,year[200],m1[200],m2[200],i,j;//c????
	
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{   
		int c1=1,c2=1;
		int days[]={0,31,0,31,30,31,30,31,31,30,31,30,31};
		scanf("%d %d %d",&year[i],&m1[i],&m2[i]);
		if((year[i]%4==0)&&(year[i]%100!=0)||(year[i]%400==0))
		     days[2]+=29;
		else
			days[2]+=28;

		for(j=0;j<m1[i];j++)
			c1=c1+days[j];
		for(j=0;j<m2[i];j++)
			c2=c2+days[j];
		
		if ((c2-c1)%7==0)
			printf("YES\n");
		else
			printf("NO\n");
		
		
	}

	return 0;
}
int p(int a,int b,int c)
{
int i,x=0;
for(i=1;i<a;i++)
{
if((i%4==0&&i%100!=0)||(i%400==0))
x+=366;
else x+=365;
}
if((a%4==0&&a%100!=0)||(a%400==0))
switch(b)
{
case 2:x+=31;break;
case 3:x+=60;break;
case 4:x+=91;break;
case 5:x+=121;break;
case 6:x+=152;break;
case 7:x+=182;break;
case 8:x+=213;break;
case 9:x+=244;break;
case 10:x+=274;break;
case 11:x+=305;break;
case 12:x+=335;break;
}
else
switch(b)
{
case 2:x+=31;break;
case 3:x+=59;break;
case 4:x+=90;break;
case 5:x+=120;break;
case 6:x+=151;break;
case 7:x+=181;break;
case 8:x+=212;break;
case 9:x+=243;break;
case 10:x+=273;break;
case 11:x+=304;break;
case 12:x+=334;break;
}
x+=c;
return(x);
}
void main()
{int a,b,t,e,x,i,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
	scanf("%d%d%d",&a,&b,&e);
if(b>e)
{t=b;b=e;e=t;}
	x=p(a,e,1)-p(a,b,1);
	if(x%7==0)
		printf("YES\n");
	else printf("NO\n");
}
}
int main()
{
	int n,x,y,z,i,day,j,t;
	int md[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		day=0;
		if(y>z){t=y;y=z;z=t;}
		if((x%400==0)||(x%100!=0&&x%4==0))
		{
			if(y==1&&z==2)
			{day=31;}
			if(y<3&&z>2)
			{         
	for(j=y-1;j<z-1;j++)
				{ day=day+md[j];}
	           day=day+1;
			}
			if(y>=3)
			{
               for(j=y-1;j<z-1;j++)
				 day=day+md[j];
			}
		}
		else
		{
         for(j=y-1;j<z-1;j++)
				 day=day+md[j];
		}
        if(day%7==0)printf("YES\n");
		else printf("NO\n");
	}

	return 0;
}
int main(){
	int month1[12]={31,28,31,30,31,30,31,31,30,31,30,31},month2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int n, y, m1, m2, j, bigm, smallm;
	scanf("%d",& n);
	for(j=0; j<n; j++){
		int days=0, i;
		scanf("%d%d%d", &y, &m1, &m2);
		if (m1<= m2){
			smallm= m1;
			bigm= m2;
		}
		else{
			bigm=m1;
			smallm=m2;
		}
        if ((y%4==0 && y%100!= 0) || y%400 ==0){
		    for(i=smallm; i<bigm; i++){
				days+=month2[i-1];
			}
			if (days%7==0){
				printf("YES\n");
			}
			else{
			   	printf("NO\n");
			}
		}
	   else{
		    for(i=smallm; i<bigm; i++){
				days+=month1[i-1];
			}
		    if (days%7==0){
			    printf("YES\n");
			}
		    else{
			    printf("NO\n");
			}

	   }
	}
	
    return 0;

}
int main(int argc, char* argv[])
{
	int x[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int r[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    int y,p,q,n,i;
    int s=0;
	int t=0;
	scanf ("%d",&n);
	while (t<n)
	{ t++;s=0;
	scanf ("%d %d %d",&y,&p,&q);
	if (y%4!=0) {y=1;}
	else if ((y%100==0)&&(y%400!=0)) {y=1;}
	else {y=0;}
    if (y==1)
	{  
		if (p<q) 
		{
		 for (i=p-1;i<q-1;i++)
		 {
		 s=s+x[i];
		 }

		}
	    else 
		{
		for (i=q-1;i<p-1;i++)
		 {
		 s=s+x[i];
		 }
		
		}

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

	}




   if (y==0)
	{
	
	
	if (p<q) 
		{
		 for (i=p-1;i<q-1;i++)
		 {
		 s=s+r[i];
		 }

		}
	    else 
		{
		for (i=q-1;i<p-1;i++)
		 {
		 s=s+r[i];
		 }
		
		}

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

	return 0;
}
//*************************************
//????4.cpp                       *
//????? 1? 1200012895           *
//???2012?10?22?                *
//??????                        *
//*************************************
int main()
{
	int n, i, a, b, c, x = 0, sum = 0;                             //n????i??????a????b?c?????x??????sum????
	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))        //??a???
		{
			for (; b < c; b++)
			{
				if (b == 2)                                        //b?2??????29
					sum = sum + 29;
				else 
					if (b == 4 || b == 6 || b == 9 || b == 11)     //b?????30
						sum = sum + 30;
					else 
						sum = sum + 31;                            //b?????31
			}
		}
		else                                                       //??a???????2???b???28?????
		{
			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 )                                       //??????7??????YES
			cout << "YES" << endl;
		else 
			cout << "NO" << endl;                                 //????NO
		sum = 0;                                                  //??
		x = 0;
	}
	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 || b==4 || b==7) && (c==1 || c==4 ||c==7))
   {printf("YES\n");}
   else if ((b==9 || b==12) && (c==9 || c==12)){
   printf("YES\n");}
   else if ((b==2 || b==8) && (c==2 || c==8))
   {printf("YES\n");}
   else if ((b==3 || b==11) && (c==3 || c==11))
   {printf("YES\n");}
   else {printf("NO\n");}
   } 
   else{
   if ((b==2 || b==3 || b==11 )&& (c==2 || c==3||c==11))
   {printf("YES\n");}
   else if ((b==1 || b==10) && (c==1 || c==10))
   {printf("YES\n");}
   else if ((b==4 || b==7) && (c==4 || c==7))
   {printf("YES\n");}
   else if ((b==9 || b==12) && (c==9 || c==12))
   {printf("YES\n");}
   else {printf("NO\n");}
   } }
   return 0;
}
int main()
{
	int i,n;
	scanf("%d",&n);
	int p[12]={0,31,28,31,30,31,30,31,31,30,31,30};
	int r[12]={0,31,29,31,30,31,30,31,31,30,31,30};
	for(i=0;i<n;i++)
	{
		int y,m1,m2,d=0,j;
		scanf("%d %d %d",&y,&m1,&m2);
		if(m1>m2)
		{
			int t=m1;
			m1=m2;
			m2=t;
		}
		if((y%400==0)||((y%4==0)&&(y%100!=0)))
		{
			for(j=m1;j<m2;j++)
				d=d+r[j];
		}
		else
		{
			for(j=m1;j<m2;j++)
				d=d+p[j];
		}
		if(d%7==0)	printf("YES\n");
		else		printf("NO\n");
	}
}
int check(int y,int m)
{
    int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int i,c;
    if((y%4==0&&y%100!=0)||(y%100==0&&y%400==0))
    days[2]++;
    c=1;
    for(i=1;i<m;i++)
    c=c+days[i];
    return c;
}
main()
{
    int i,j,k,n,y,m1,m2;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d %d",&y,&m1,&m2);
        if(m1>m2)
        k=check(y,m1)-check(y,m2);
        else
        k=check(y,m2)-check(y,m1);
        if(k%7==0)
        printf("YES\n");
        else
        printf("NO\n");
    }
}
int main()
{
	int n,i,year[200],mon1[200],mon2[200];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&year[i],&mon1[i],&mon2[i]);
	}
	
	for(i=1;i<=n;i++)
	{
		if( (year[i]%100!=0) && (year[i]%4==0) || year[i]%400==0  )
		{
			
		if(mon1[i]==1) { mon1[i]=1; }
		if(mon1[i]==2) { mon1[i]=32; }
        if(mon1[i]==3) { mon1[i]=61; }
        if(mon1[i]==4) { mon1[i]=92; }
        if(mon1[i]==5) { mon1[i]=122; }
        if(mon1[i]==6) { mon1[i]=153; }
        if(mon1[i]==7) { mon1[i]=183; }
        if(mon1[i]==8) { mon1[i]=214; }
        if(mon1[i]==9) { mon1[i]=245; }
        if(mon1[i]==10) { mon1[i]=275; }
        if(mon1[i]==11) { mon1[i]=306; }
        if(mon1[i]==12) { mon1[i]=336; }
        if(mon2[i]==1) { mon2[i]=1; }
		if(mon2[i]==2) { mon2[i]=32; }
        if(mon2[i]==3) { mon2[i]=61; }
        if(mon2[i]==4) { mon2[i]=92; }
        if(mon2[i]==5) { mon2[i]=122; }
        if(mon2[i]==6) { mon2[i]=153; }
        if(mon2[i]==7) { mon2[i]=183; }
        if(mon2[i]==8) { mon2[i]=214; }
        if(mon2[i]==9) { mon2[i]=245; }
        if(mon2[i]==10) { mon2[i]=275; }
        if(mon2[i]==11) { mon2[i]=306; }
        if(mon2[i]==12) { mon2[i]=336; }
        if(((mon2[i]-mon1[i])%7==0) || ((mon1[i]-mon2[i])%7==0)) { printf("YES\n"); }
		else { printf("NO\n");}
		}
	    else
		{
        if(mon1[i]==1) { mon1[i]=1; }
		if(mon1[i]==2) { mon1[i]=32; }
        if(mon1[i]==3) { mon1[i]=60; }
        if(mon1[i]==4) { mon1[i]=91; }
        if(mon1[i]==5) { mon1[i]=121; }
        if(mon1[i]==6) { mon1[i]=152; }
        if(mon1[i]==7) { mon1[i]=182; }
        if(mon1[i]==8) { mon1[i]=213; }
        if(mon1[i]==9) { mon1[i]=244; }
        if(mon1[i]==10) { mon1[i]=274; }
        if(mon1[i]==11) { mon1[i]=305; }
        if(mon1[i]==12) { mon1[i]=335; }
        if(mon2[i]==1) { mon2[i]=1; }
		if(mon2[i]==2) { mon2[i]=32; }
        if(mon2[i]==3) { mon2[i]=60; }
        if(mon2[i]==4) { mon2[i]=91; }
        if(mon2[i]==5) { mon2[i]=121; }
        if(mon2[i]==6) { mon2[i]=152; }
        if(mon2[i]==7) { mon2[i]=182; }
        if(mon2[i]==8) { mon2[i]=213; }
        if(mon2[i]==9) { mon2[i]=244; }
        if(mon2[i]==10) { mon2[i]=274; }
        if(mon2[i]==11) { mon2[i]=305; }
        if(mon2[i]==12) { mon2[i]=335; }
        if(((mon2[i]-mon1[i])%7==0)||((mon1[i]-mon2[i])%7==0)){	printf("YES\n"); }
		else { printf("NO\n");}
		}
	}
	return 0;
}
int f(int y,int m);
main()
{
    int n;
    scanf("%d",&n);
    printf("\n");
    int i,y[200],m1[200],m2[200];
    for (i=0;i<n;i++)
    {    
       scanf("%d %d %d",&y[i],&m1[i],&m2[i]);
       if (f(y[i],m1[i])%7==f(y[i],m2[i])%7)
          printf("YES\n");
       else
          printf("NO\n");
    }
}
int f(int y,int m)
{
    int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};

    int i;


    if ((y%4==0)&&(y%100!=0)||(y%400==0))
        days[2]++;

    int f=1;
    for(i=1;i<m;i++)
       {
        f +=days[i];
        }

    return f;
}
int main()
{
	int n, year, a, b, c, i, j, day;
	cin >> n;
	for(i=1;i<=n;i++)
	{
		cin >> year >> a >> b;
		if (a > b)
		{
			c = a;
			a = b;
			b = c;
		}
		day = 0;
		for(j=a;j<b;j++)
		{
			day = day + 31;
			if(j == 4 ||j == 6||j == 9 ||j == 11)
				day = day -1;
			if(j == 2)
			{
				if((year % 4 ==0 && year % 100 != 0) || year % 400 == 0)
					day = day - 2;
				else
					day = day - 3;
			}
		}
		if(day % 7 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}
int main()
{
	int n,i,j,y,d[13],m1,m2,a,b;
	d[1]=31;
	d[2]=28;
	d[3]=31;
	d[4]=30;
	d[5]=31;
	d[6]=30;
	d[7]=31;
	d[8]=31;
	d[9]=30;
	d[10]=31;
	d[11]=30;
	d[12]=31;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int num=0;
		scanf("%d%d%d",&y,&m1,&m2);
		if(m1>m2)
		{
			a=m1;b=m2;
		}
		else
		{
			a=m2;b=m1;
		}
		if((y%4==0)&&(y%100!=0)||(y%400==0))
			d[2]++;
		for(j=b;j<a;j++)
			num+=d[j];
		if(num%7==0)
			printf("YES\n");
		else
			printf("NO\n");
		d[2]=28;
	}
		
	return 0;
}
int main()
{
	int y,m1,m2,i,j,n,e,c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&y,&m1,&m2);
		c=0;
		if(m1>m2)
		{
			e=m1;
			m1=m2;
			m2=e;
		}
		for(j=1;j<=12;j++)
		{
			if(j>=m1 && j<m2 && (j==1||j==3||j==5||j==7||j==8||j==10||j==12))	
				c=c+31;
			if(j>=m1 && j<m2 && (j==4||j==6||j==9||j==11))	
				c=c+30;
			if(j>=m1 && j<m2 && j==2)	
			{
				c=c+28;
				if(y%400==0 || (y%100!=0 && y%4==0))
					c=c+1;
			}
			

		}
		if(c%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	
	}
	return 0;
}
int main()
{
	int sz[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int n,a,b,c,i,j,t,day=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&a,&b,&c);
		if(b>c){
			t=b;
			b=c;
			c=t;
		}
		if((a%4==0&&a%100!=0)||a%400==0){
			if(b>2){
				for(j=b-1;j<c-1;j++){
					day+=sz[j];
				}
			}
				if(c<3){
					day=31;
				}
				if(b<3&&c>2){
					for(j=b-1;j<c-1;j++){
					day+=sz[j];
				}
					day+=1;
				}
			}
		else{
              for(j=b-1;j<c-1;j++){
					day+=sz[j];
				}
		}
		if(day%7==0)
			printf("YES\n");
		else
			printf("NO\n");
		day=0;
	}
	return 0;
}
int main()
{
    int i,j,n,t,N=0;
    int a,b,c;
    int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d %d",&a,&b,&c);

         if((a%100)==0)
         {
            if((a%400)==0)
            month[2]=29;
         }
         else
         {
             if((a)%4==0)
             month[2]=29;
         }
         if(b>c)
         {t=c;
         c=b;
         b=t;}
         for(j=b;j<c;j++)
             N=N+month[j];
             month[2]=28;
             if((N%7)==0)
             printf("YES\n");
             else
             printf("NO\n");
             N=0;
     }
     return 0;
}
int main()
{
	int w1=0,w2=0,i,j,k,n,a[200],b[200],c[200];
	int days[12]={0,31,28,31,30,31,30,31,31,30,31,30};
	scanf ("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf ("%d %d %d",&a[i],&b[i],&c[i]);
		{
			if 	(a[i]%4==0 && a[i]%100!=0)	
			
		{
			days[2]=29;
			for(j=0;j<b[i];j++)
			{w1=w1+days[j];}
			for(k=0;k<c[i];k++)
			{w2=w2+days[k];}
			}
              else if 	(a[i]%400==0)
			  {
			days[2]=29;
			for(j=0;j<b[i];j++)
			{w1=w1+days[j];}
			for(k=0;k<c[i];k++)
			{w2=w2+days[k];}
			}

		else {
		days[2]=28;
		
			for(j=0;j<b[i];j++)
			{w1=w1+days[j];}
			for(k=0;k<c[i];k++)
			{w2=w2+days[k];}
		}
	}
     
		  if ((w2-w1)%7==0)
			  printf ("YES\n");
		else 
		{printf("NO\n");}
		w1=0;
		w2=0;
	}
	
	return 0;
}
int main()
{
      int n,year,m1,m2,i,j,b,day;
      scanf("%d",&n);
      int days[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; //???;
      for(i=0;i<n;i++)
      {
          scanf("%d %d %d",&year,&m1,&m2);
          if (m1>m2)                                        //??m1<m2; 
          {
              b=m1;
              m1=m2;
              m2=b;
          }
          day=0;
          if ((year%4==0)&&(year%100!=0)||(year%400==0))    //????? 
          {
              days[1]++;
              for(j=m1-1;j<m2-1;j++) day=day+days[j];
              if (day%7==0) printf("YES\n");
              else printf("NO\n");
              days[1]=28;
          }
          else
          {
              for(j=m1-1;j<m2-1;j++) day=day+days[j];
              if (day%7==0) printf("YES\n");
              else printf("NO\n");
          }
      }

}
int f(int a)
{
    if(a%400==0||(a%4)==0&&a%100!=0)
    return 1;
    else 
    return 2;
    
}
main()
{
      int n;
      scanf("%d",&n);
      int i;
      for(i=0;i<n;i++)
      {
                      int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
                      int m;
                      scanf("%d",&m);
                      if(f(m)==1)
                      days[1]=29;
                      
                      else
                      days[1]==28;
                      
                      int a,b;
                      scanf("%d %d",&a,&b);
                      int t;
                      if(a>b)
                      {
                             t=a;
                             a=b;
                             b=t;
                      }
                      int j;
                      int s=0;
                      for(j=a;j<b;j++)
                      {
                                      s+=days[j-1];
                      }
                      if(s%7==0)
                      printf("YES\n");
                      else
                      printf("NO\n");
      }
      getchar();
      getchar();
      getchar();
}
struct point{
    int y;
    int m1;
    int m2;
};
int main(){
    int n,i,j,d,a[12]={31,29,31,30,31,30,31,31,30,31,30,31},b[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    struct point A[200];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        d=0;
        scanf("%d%d%d",&A[i].y,&A[i].m1,&A[i].m2);
        if(A[i].m1<A[i].m2){
         if(A[i].y%400==0||(A[i].y%4==0&&A[i].y%100!=0)){
            for(j=A[i].m1;j<A[i].m2;j++){
                d=d+a[j-1];
            }
         }else{
            for(j=A[i].m1;j<A[i].m2;j++){
               d=d+b[j-1]; 
            }      
         }
        }else{
            if(A[i].y%400==0||(A[i].y%4==0&&A[i].y%100!=0)){
            for(j=A[i].m2;j<A[i].m1;j++){
                d=d+a[j-1];
            }
         }else{
            for(j=A[i].m2;j<A[i].m1;j++){
               d=d+b[j-1]; 
            }      
         }
        }
        if(d%7==0){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}
int day(int y,int m)
{
int i,x=0;
int mon[12]={31,28,31,30,31,30,31,31,30,31,30,31};
if(y%4==0&&y%100!=0)
{
mon[1]=29;
}
else if(y%400==0)
{
mon[1]=29;
}
else
mon[1]=28;
for(i=0;i<m-1;i++)
	{
		x+=mon[i];
	}
return x;
}
int main()
{
int a,b,c,s[1000],p=0,q=0;
int n,j;
scanf("%d",&n);
for(j=0;j<n;j++)
{
scanf("%d%d%d",&a,&b,&c);
		p=day(a,b);
		q=day(a,c);
s[j]=(q-p)%7;
}
for(j=0;j<n;j++)
{
if(s[j]==0)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
int DiJiTian(int year,int month);
int main(int argc, char* argv[])
{
	int  n,year,m1,m2,c,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&year,&m1,&m2);
		c=abs(DiJiTian(year,m1)-DiJiTian(year,m2));
		if(c%7==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
		return 0;
}
int DiJiTian(int year,int month){
	int i,result;
	result=1;
	for(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(year%400==0||(year%100!=0&&year%4==0)){
				result+=29;
			}else{
				result+=28;
			}
		}
	}
			return result;
}
int main()
{
	int leap, day, i, n, y, dy, de, m, k = 0, z;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> y >> dy >> de;
		if (dy > de)
		{
			z = dy;
			dy = de;
			de = z;
		}
		leap = y % 4 == 0 && y % 100 != 0 || y % 400 == 0;
		for (m = dy; m <= de - 1; m++)
		{
			switch (m)
			{
				case 1:
					day = 31;break;
				case 2:
					day = 28 + leap;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;
			}
			k = k + day;
		}
		if (k % 7 == 0)
			cout << "YES" << endl;
		else 
			cout << "NO" << endl;
		k = 0;
	}
	return 0;
}
int main()
{
 struct
 {
    int y,m1,m2;
 }p[200];
 int n,i,j,t,day[13],sum=0;
 day[1]=31;day[3]=31;day[4]=30;day[5]=31;day[6]=30;day[7]=31;day[8]=31;day[9]=30;day[10]=31;day[11]=30;day[12]=31;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  scanf("%d%d%d",&p[i].y, &p[i].m1, &p[i].m2);

  if(p[i].y%4==0 && p[i].y%100!=0 ||p[i].y%400==0)
  day[2]=29;
  else day[2]=28;
  
  if(p[i].m1 > p[i].m2)
  {
     t=p[i].m1;
     p[i].m1=p[i].m2;
     p[i].m2=t;
  }
  for(j=p[i].m1;j<p[i].m2;j++)
  {
   sum+=day[j];
  }
  if(sum%7==0 ) printf("YES\n");
  else printf("NO\n");
  sum=0;
 }
  
 return 0;
}
int abs(int x)
{ if(x<0) x=-x;
  else x=x;
  return(x);
}
int main()
{
	int n,year,a,b,i,j,e,c[13],d[13],sum=0;
	cin>>n;
	c[0]=0;
	c[1]=c[3]=c[5]=c[7]=c[8]=c[10]=c[12]=31;
	c[4]=c[6]=c[9]=c[11]=30;
	for(i=0;i<n;i++)
	{cin>>year>>a>>b;
	 if((year%4==0&&year%100!=0)||year%400==0) c[2]=29;
	 else c[2]=28;
         for(j=0;j<13;j++)
        {sum+=c[j];
         d[j]=sum;
         }
         e=abs(d[a-1]-d[b-1]);
	 if(e%7==0) cout<<"YES"<<endl;
	 else cout<<"NO"<<endl;
	}
	return 0;
}
int main()
{
	int year,a,b,n=0,i,num1=0,j,m,num2=0;
	int A[12]={31,28,31,30,31,30,31,31,30,31,30,31},
		B[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	scanf("%d",&m);
	for(j=0;j<m;j++)
	{
		scanf("%d %d %d",&year,&a,&b);
		if((year%4==0&&year%100!=0)||year%400==0)
		{
			n=0;num1=0;
		 for(i=0;i<a-1;i++)
		 {
			 n=n+B[i];
		 }
		 num1=n+1;
		 
		}
		

		else
		{
			n=0;num1=0;
			for(i=0;i<a-1;i++)
			{
				n=n+A[i];
			}
			num1=n+1;
		}
		if((year%4==0&&year%100!=0)||year%400==0)
		{
			n=0;num2=0;
		 for(i=0;i<b-1;i++)
		 {
			 n=n+B[i];
		 }
		 num2=n+1;
		 
		}
		

		else
		{
			n=0;num2=0;
			for(i=0;i<b-1;i++)
			{
				n=n+A[i];
			}
			num2=n+1;
		}
		
		 
		if((num1-num2)%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}	
	return 0;
}
int main()
{
	int n, i, a, b, c, d, B, C;
	cin>>n;
	for ( i = 1; i <= n; i++ )
	{
		cin>>a>>b>>c;
		if ( ( a % 400 == 0 ) || ( a % 4 == 0 )
			 && ( a % 100 != 0 ) )
		{
			if ( b > c )
			{
				d = c; c = b; b = d;
			}
			switch ( b )
			{ case 1: B = 0;break;
			{ case 2: B = 31;break; }
			{ case 3: B = 60;break; }
			{ case 4: B = 91;break; }
			{ case 5: B = 121;break; }
			{ case 6: B = 152;break; }
			{ case 7: B = 182;break; }
			{ case 8: B = 213;break; }
			{ case 9: B = 244;break; }
			{ case 10: B = 274;break; }
			{ case 11: B = 305;break; }
			{ default: B = 335;break; }
			}
			switch ( c )
			{ case 1: C = 0;break; 
			{ case 2: C = 31;break; }
			{ case 3: C = 60;break; }
			{ case 4: C = 91;break; }
			{ case 5: C = 121;break; }
			{ case 6: C = 152;break; }
			{ case 7: C = 182;break; }
			{ case 8: C = 213;break; }
			{ case 9: C = 244;break; }
			{ case 10: C = 274;break; }
			{ case 11: C = 305;break; }
			{ default: C = 335;break; }
			}
			if ( ( C - B ) % 7 == 0 )
				cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
		else
		{
			if ( b > c )
			{
				d = c; c = b; b = d;
			}
			switch ( b )
			{ case 1: B = 0;break; 
			{ case 2: B = 31;break; }
			{ case 3: B = 59;break; }
			{ case 4: B = 90;break; }
			{ case 5: B = 120;break; }
			{ case 6: B = 151;break; }
			{ case 7: B = 181;break; }
			{ case 8: B = 212;break; }
			{ case 9: B = 243;break; }
			{ case 10: B = 273;break; }
			{ case 11: B = 304;break; }
			{ default: B = 334;break; }
			}
			switch ( c )
			{ case 1: C = 0;break;
			{ case 2: C = 31;break; }
			{ case 3: C = 59;break; }
			{ case 4: C = 90;break; }
			{ case 5: C = 120;break; }
			{ case 6: C = 151;break; }
			{ case 7: C = 181;break; }
			{ case 8: C = 212;break; }
			{ case 9: C = 243;break; }
			{ case 10: C = 273;break; }
			{ case 11: C = 304;break; }
			{ default: C = 334;break; }
			}
			if ( ( C - B) % 7 == 0 )
				cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
	}
	return 0;
}
int shirunnian(int a)
{
	if(a%4!=0){
		return 0;
	}
	else {
		if(a%100==0&&a%400!=0){
			return 0;
		}
		else{
			return 1;
		}
	}
}
int main()
{
    int n,i,b[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},
		c[13]={0,31,29,31,30,31,30,31,31,30,31,30,31},
		d,e,f,s,sum=0;
    scanf("%d",&n);
	while (n>0){
                  sum=0;
		scanf("%d%d%d",&d,&e,&f);
        if(e>f){
			s=e;
			e=f;
			f=s;
		}
		if(shirunnian(d)==1){
			for(i=e;i<f;i++){
            sum+=c[i];
			}
			if(sum%7==0){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
		else{
			for(i=e;i<f;i++){
            sum+=b[i];
			}
			if(sum%7==0){
				printf("YES\n");
			}
			else {
				printf("NO\n");
			}
		}
        n--;
	}
	return 0;
}
int main()
{
	int n,year,m1,m2,x=0,m,i,a,b;
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>year>>m1>>m2;
		{
			if (m1<m2) a=m1,b=m2;
			else if (m2<m1) a=m2,b=m1;
		}
		if((year%4==0 && year%100!=0)||(year%400==0))
		{
			for (m=a;m<b;m++)
			{
				switch(m)
				{
				case 1:     case 3:     case 5:     case 7:
				case 8:     case 10:     case 12:x+=31;break;    
				case 2:x+=29;break;
				default :x+=30;
				}
			}
			if (x%7==0) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
			x=0;
			
		}
		else
		{
			for (m=a;m<b;m++)
			{
				switch(m)
				{
				case 1:     case 3:     case 5:     case 7:
				case 8:     case 10:     case 12:x+=31;break;    
				case 2:x+=28;break;
				default :x+=30;
				}
			}
			if (x%7==0) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
			x=0;
			
		}
	}
	return 0;
}