semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
    int n, m1, m2, d, y, m, sum;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        sum = 0;
        d = 0;
        cin >> y >> m1 >> m2;
        if(m1 > m2)
        {
            m = m1;
            m1 = m2;
            m2 = m;
        }
        m = m1;
        while(m < m2)
        {
            switch(m)              //???????? 
            {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    d = 31; break;
                case 4:
                case 6:
                case 9:
                case 11:
                    d = 30; break;
                case 2:
                {
                    if((y % 400 == 0) || ((y % 100 != 0) && (y % 4 == 0)))
                        d = 29;       //?????2??29? 
                    else
                        d = 28;
                } break;
            }
            sum += d;                  //????? 
            m++;
        }
        if(sum % 7 == 0)                  //???????? 
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }

    return 0;
}
int main(int argc, char* argv[])
{
	int n, y[200], m1[200], m2[200], i, j, x[12], s;
	scanf("%d", &n);
	for (i=0;i<n;i++)
	{
		scanf("%d%d%d", &y[i], &m1[i], &m2[i]);
	}
	x[1]=31;
	x[3]=31;
	x[4]=30;
	x[5]=31;
	x[6]=30;
	x[7]=31;
	x[8]=31;
	x[9]=30;
	x[10]=31;
	x[11]=30;
	x[12]=31;
    for (i=0;i<n;i++)
	{
		s=0;
		if (y[i]%400==0||(y[i]%4==0&&y[i]%100!=0))
		{
			x[2]=29;
		}
		else x[2]=28;
		if (m1[i]<m2[i])
		{
			for (j=m1[i];j<m2[i];j++)
			{
				s=s+x[j];
			}
			if (s%7==0)
			{
				printf("YES\n");
			}
			else printf("NO\n");
		}
		else 
		{
			for (j=m2[i];j<m1[i];j++)
			{
				s=s+x[j];
			}
			if (s%7==0)
		{
			printf("YES\n");
		}
		else printf("NO\n");
		}
	}
	return 0;
}
int main()
{
	int n,y[200],m1,m2,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d\n",&y[i],&m1,&m2);
		if(m1>m2){
			int t;
		    t=m1;
		    m1=m2;
		    m2=t;
		}
	if((y[i]%4==0&&y[i]%100!=0)||(y[i]%100==0&&y[i]%400==0)){
       if((m1==1&&m2==4)||(m1==1&&m2==7)||(m1==2&&m2==8)||(m1==3&&m2==11)||(m1==4&&m2==7)||(m1==9&&m2==12))
		   printf("YES\n");
       else printf("NO\n");
	   }
    else{
       if((m1==1&&m2==10)||(m1==2&&m2==3)||(m1==2&&m2==11)||(m1==3&&m2==11)||(m1==4&&m2==7)||(m1==9&&m2==12))
		   printf("YES\n");
       else printf("NO\n");
	   }
	}
	return 0;
}
int main()
{
	int n,i,b[200],c,e,k,a[13],y;
	scanf("%d",&n);
	a[0]=a[1]=0;
	a[5]=a[7]=a[10]=a[12]=30;
    a[2]=a[4]=a[6]=a[8]=a[9]=a[11]=31;
	a[3]=28;
	for(k=3;k<=12;k++){
	             a[k]+=a[k-1];
			 }
	
	for(i=0;i<n;i++){
	     scanf("%d",&y);
		 if((y%4==0&&y%100!=0)||y%400==0){
             for(k=3;k<13;k++){
				 a[k]+=1;
			 }
		 }
		 scanf("%d%d",&c,&e);
		 if(c<e){
			 int t;
			 t=c;
			 c=e;
			 e=t;
		 }
		 if((a[c]-a[e])%7==0)
            b[i]=0;
		 else b[i]=1;
         if((y%4==0&&y%100!=0)||y%400==0){
             for(k=3;k<13;k++){
				 a[k]-=1;
			 }
		 }
		 }

     for(i=0;i<n;i++){
	     if(b[i]==0)
		printf("YES\n");
		 else printf("NO\n");
	 }
	return 0;
}
int judge(int x)
{
if(x%400==0) return 1;
if(x%100==0 && x%400!=0) return 0;
if(x%4==0) return 1;
else return 0;
}
int main()
{
    int n,year,month0,month1,mark;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    mark=0;
    cin>>year>>month0>>month1;
    if(month0>month1){int temp;temp=month0;month0=month1;month1=temp;}
    if(judge(year)==0)
    {
     if(month0==1&&month1==10) mark=1;
     if(month0==2&&month1==3) mark=1;
     if(month0==2&&month1==11) mark=1;
     if(month0==3&&month1==11) mark=1;
     if(month0==4&&month1==7) mark=1;
     if(month0==9&&month1==12) mark=1;
     }
     else
     {
     if(month0==1&&month1==4) mark=1;
     if(month0==1&&month1==7) mark=1;
     if(month0==2&&month1==8) mark=1;
     if(month0==3&&month1==11) mark=1;
     if(month0==4&&month1==7) mark=1;
     if(month0==9&&month1==12) mark=1;  
     }
     if(mark==1) cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
      } 
    return 0;
    }
void main()
{		
	int tianshucha(int m, int y1,int r1,int y2,int r2);
	int n;
	int m[200],y1[200],y2[200];
	int i,d;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&m[i],&y1[i],&y2[i]);
	}
	for(i=0;i<n;i++)
	{
		d=tianshucha(m[i],y1[i],1,y2[i],1);
		if(d%7==0)printf("YES\n");
		else printf("NO\n");
	}


}


int tianshucha(int m,int y1,int r1,int y2,int r2)
{
	int d1,d2,d,i;
	d1=r1;d2=r2;
	for(i=1;i<y1;i++)
	{
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)d1=d1+31;
		else
		{
			if(i==2)d1=d1+28;
			else d1=d1+30;
		}
	}
	for(i=1;i<y2;i++)
	{
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)d2=d2+31;
		else
		{
			if(i==2)d2=d2+28;
			else d2=d2+30;
		}
	}
	if(d1>d2)d=d1-d2;
	else d=d2-d1;
	if(((m%4==0)&&(m%100!=0))||(m%400==0))
	{
		if((y1<=2&&y2<=2)||(y1>2&&y2>2))
			return d;
		else return d+1;
	}
	return d;
	
}
int main(){
	int n,year,month1,month2,i,day1,day2;
	int isRunNian(int year);
	int DiJiTian(int year, int month);
	int sz[200],jg;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&year,&month1,&month2);
		if((DiJiTian(year,month2)-DiJiTian(year,month1))<0){
			jg=-(DiJiTian(year,month2)-DiJiTian(year,month1));
		}
		else jg=(DiJiTian(year,month2)-DiJiTian(year,month1));
		if(jg%7==0){
			sz[i]=1;
		}
		else{
			sz[i]=0;
		}
	}
	for(i=0;i<n;i++){
		if(sz[i]==1){
			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 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;
			}	
		}
	}
	
	return result;	
}
int isRunNian(int year);
int DiJiTian(int year, int month, int day);
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int year,m1,m2,chazhi;	
		scanf("%d%d%d", &year,&m1,&m2);
		chazhi=DiJiTian(year,m2,1)-DiJiTian(year,m1,1);
		if (chazhi%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,i;
	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(isRunNian(year))
			{
				result+=29;
			}
			else
			{
				result+=28;
			}
		}
	}
	result+=day;
	return result;
}
int s(int year,int month,int date){
	int s=0;
	int i;
	if ((year%400==0)||((year%100!=0)&(year%4==0)))
	{
	   int n[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	   for (i=0;(i+1)<month;i++)
	   {
		 s+=n[i];
	   }
	   s=s+date;
	}
	else
	{
	   int n[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	   for (i=0;(i+1)<month;i++)
	   {
		 s+=n[i];
	   }
	   s=s+date;
	}
	
	return s;
}




int main(int argc, char* argv[])
{
	int n,i,year,month1,month2,a,b;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&year,&month1,&month2);
		a=s(year,month1,1);
		b=s(year,month2,1);
		if((a-b)%7==0)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
int M,y,m1,m2,i,s;
scanf("%d",&M);
while(M>0){M--;
	s=0;
	scanf("%d%d%d",&y,&m1,&m2);
	if(m1==m2){printf("YES\n");continue;}
	if(m1>m2){i=m1;m1=m2;m2=i;}
	if((1==m1&&2!=m2)||2==m1)if((y%400==0)||(y%4==0&&y%100!=0))s=1;
	for(i=m1;i<m2;i++)s+=mon[i];
	if(s%7==0)printf("YES\n");
	else printf("NO\n");
}
return 0;
}
int main()
{
	int i,n,s,p,y;
	int d[100];
	int m[2];
	scanf("%d",&n);
	for(p=0;p<n;p++)
	{
		scanf("%d %d %d", &y, &m[0], &m[1]);
		if ((y%4==0 && y%100!=0) || y%400==0)
		{
			for(i=0;i<2;i++)
			{
				if(m[i]==1)
				{
					d[i]=0;
				}
				if(m[i]==2)
				{
					d[i]=31;
				}
				if(m[i]==3)
				{
					d[i]=60;
				}
				if(m[i]==4)
				{
					d[i]=91;
				}
				if(m[i]==5)
				{
					d[i]=121;
				}
				if(m[i]==6)
				{
					d[i]=152;
				}
				if(m[i]==7)
				{
					d[i]=182;
				}
				if(m[i]==8)
				{
					d[i]=213;
				}
				if(m[i]==9)
				{
					d[i]=244;
				}
				if(m[i]==10)
				{
					d[i]=274;
				}
				if(m[i]==11)
				{
					d[i]=305;
				}
				if(m[i]==12)
				{
					d[i]=335;
				}
			}
		}
		else
		{			
			for(i=0;i<2;i++)
			{
				if(m[i]==1)
				{
					d[i]=0;
				}
				if(m[i]==2)
				{
					d[i]=31;
				}
				if(m[i]==3)
				{
					d[i]=59;
				}
				if(m[i]==4)
				{
					d[i]=90;
				}
				if(m[i]==5)
				{
					d[i]=120;
				}
				if(m[i]==6)
				{
					d[i]=151;
				}
				if(m[i]==7)
				{
					d[i]=181;
				}
				if(m[i]==8)
				{
					d[i]=212;
				}
				if(m[i]==9)
				{
					d[i]=243;
				}
				if(m[i]==10)
				{
					d[i]=273;
				}
				if(m[i]==11)
				{
					d[i]=304;
				}
				if(m[i]==12)
				{
					d[i]=334;
				}
			}
		}

		if(d[0]>d[1])
		{
			s=d[0]-d[1];
				if (s%7==0)
				{
					printf("YES\n");
				}
				else
				{
					printf("NO\n");
				}
		}
		else
		{
			s=d[1]-d[0];
				if (s%7==0)
				{
					printf("YES\n");
				}
				else
				{
					printf("NO\n");
				}
		}
		}
		return 0;
		}
int main()
{
	int i,j,n,year,m1,m2,a,b,sum=0;
	scanf("%d",&n);
	int month1[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int month2[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	for(i=0;i<n;i++)
	{
		sum=0;

		scanf("%d%d%d",&year,&m1,&m2);
		if(m1>m2)
		{
			a=m2;
			b=m1;
		}
		else 	
		{
			a=m1;
			b=m2;
		}
			for(j=a;j<b;j++)
			{
				if(year%400==0||year%4==0&&year%100!=0)
				{
					sum+=month1[j-1];
				}
				else
				{
					sum+=month2[j-1];
				}
			}
				if(sum%7==0)
					printf("YES\n");
				else 
					printf("NO\n");
		
	}
		return 0;
}
//**********************************
//????????
//???2013.10.17
//**********************************
int main()
{
	 int a[200],b[200],c[200],n=0,i=0,j=0,k=0;
	 cin>>n;
	 for(i=0;i<n;i++)
	 {
		 cin>>a[i]>>b[i]>>c[i];
		 k=0;j=0;
		 if(c[i]<b[i])

		    { j=c[i];
		     c[i]=b[i];
			 b[i]=j;}
		 for(;b[i]<c[i];b[i]++)
		 {
			 if(b[i]==1||b[i]==3||b[i]==5||b[i]==7||b[i]==8||b[i]==10||b[i]==12)
			 {  k=k+31; }
			 else if(b[i]==2)
			 {	 
				 if(a[i]%100==0&&a[i]%400==0)
			       k=k+29;
				 else if(a[i]%(100)!=0&&a[i]%4==0)
					k=k+29;
				 else
				   k=k+28;
			 }
			 else
			 {  k=k+30; }
		 }
	   if(k%7==0)
		   cout<<"YES"<<endl;
	   else
		   cout<<"NO"<<endl;
	 }
   return 0;
}
int year(int y)
{
    
    if(y%400==0) return 0;
    else if(y%4==0&&y%100!=0) return 0;
    else return 1;
}
main()
{
      int n;
      scanf("%d",&n);
      int i,j,k;
      int a[100];
         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;
      int y,m1,m2;
      for(i=0;i<n;i++)
      {
                      int sum=0;
         scanf("%d %d %d",&y,&m1,&m2);
        
         if(year(y)==0) a[2]=29;
         else a[2]=28;
         if(m2<m1)
         { 
                  k=m1;
                  m1=m2;
                  m2=k;
         }
         for(j=m1;j<=m2-1;j++)
         {
               sum=sum+a[j];           
         }
         if(sum%7==0) printf("YES\n");
         else printf("NO\n");
         
      }
      }
int main()
{
	int n,i,j,year,m1,m2,temp,s[12]={0},h=0;
	scanf("%d",&n);
	for(i=1;i<=12;i++)
		{
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
	    	s[i-1]=31;
        else 
			if(i!=2)
			s[i-1]=30;
		}
	for(j=0;j<n;j++)
	{
		scanf("%d%d%d",&year,&m1,&m2);
		if(m1>m2)
		{
			temp=m2;
			m2=m1;
			m1=temp;
		}
		if(year%400==0||(year%4==0&&year%100!=0))
			s[1]=29;
		else
			s[1]=28;
		for(i=m1;i<m2;i++)
			h=h+s[i-1];
		if(h%7==0)
			printf("YES\n");
		else
			printf("NO\n");
		h=0;
	}
	return 0;
}
int main ()
{
	int n,i,a[200],b[200],c[200];
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d\n",&a[i],&b[i],&c[i]);
	}
	for(i=0;i<n;i++)
	{
	       if(a[i]%4!=0)
		   {
		         if(b[i]==1&&c[i]==10 || b[i]==10&&c[i]==1)
					 printf("YES\n");
				 else if(b[i]==2&&c[i]==3 || b[i]==3&&c[i]==2)
                     printf("YES\n");
                 else if(b[i]==2&&c[i]==11 || b[i]==11&&c[i]==2)
                     printf("YES\n");
                 else if(b[i]==3&&c[i]==11 || b[i]==11&&c[i]==3)
					 printf("YES\n");
				 else if(b[i]==4&&c[i]==7 || b[i]==7&&c[i]==4)
                     printf("YES\n");
                 else if(b[i]==9&&c[i]==12 || b[i]==12&&c[i]==9)
                     printf("YES\n");
				 else
					 printf("NO\n");
		   }
		   else if(a[i]%100==0&&a[i]%400!=0)
		   {
                 if(b[i]==1&&c[i]==10 || b[i]==10&&c[i]==1)
					 printf("YES\n");
				 else if(b[i]==2&&c[i]==3 || b[i]==3&&c[i]==2)
                     printf("YES\n");
                 else if(b[i]==2&&c[i]==11 || b[i]==11&&c[i]==2)
                     printf("YES\n");
                 else if(b[i]==3&&c[i]==11 || b[i]==11&&c[i]==3)
					 printf("YES\n");
				 else if(b[i]==4&&c[i]==7 || b[i]==7&&c[i]==4)
                     printf("YES\n");
                 else if(b[i]==9&&c[i]==12 || b[i]==12&&c[i]==9)
                     printf("YES\n");
				 else
					 printf("NO\n");
		   }
		   else if(a[i]%4==0&&a[i]%100!=0 || a[i]%400==0)
		   {
                 if(b[i]==1&&c[i]==4 || b[i]==4&&c[i]==1)
					 printf("YES\n");
				 else if(b[i]==1&&c[i]==7 || b[i]==7&&c[i]==1)
                     printf("YES\n");
                 else if(b[i]==2&&c[i]==8 || b[i]==8&&c[i]==2)
                     printf("YES\n");
                 else if(b[i]==3&&c[i]==11 || b[i]==11&&c[i]==3)
					 printf("YES\n");
				 else if(b[i]==4&&c[i]==7 || b[i]==7&&c[i]==4)
                     printf("YES\n");
                 else if(b[i]==9&&c[i]==12 || b[i]==12&&c[i]==9)
                     printf("YES\n");
				 else
					 printf("NO\n");
		   }
	}
	return 0;
}
int main()
{
	int n,i,j;
	int year[201];
	int month1[201];
	int month2[201];
	int huan[201];
	huan[201]=0;
	int days[201];

	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&year[i],&month1[i],&month2[i]);	
	
		if (month1[i]>month2[i])
		{
			huan[i]=month1[i];
			month1[i]=month2[i];
			month2[i]=huan[i];
		}
		days[i]=0;
	}

	for (i=0;i<n;i++)
	{
		
		for(j=month1[i];j<month2[i];j++)
		{
			if(j==1||j==3||j==5||j==7||j==8||j==10)
			{
				days[i]+=31;
			}
			else if (j==4||j==6||j==9||j==11)
			{
				days[i]+=30;
			}
			else if(j==2)
			{
				if(year[i]%400==0||(year[i]%4==0&&year[i]%100!=0))
				{
					days[i]+=29;
				}
				else
				{
					days[i]+=28;
				}
			}
		}
		if (days[i]%7==0)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}


	
		

	return 0;
}
int main()
{
	int n,i,j;
	int year,month1,month2;
	scanf("%d",&n);
	for(j=0;j<n;j++)
	{
		scanf("%d %d %d",&year,&month1,&month2);
		{
			if((year%4==0&&year%100!=0)||year%400==0)
			{
				int days[12]={0,31,29,31,30,31,30,31,31,30,31,30};
				int day1=0,day2=0;
				for(i=0;i<month1;i++)
					day1+=days[i];
				for(i=0;i<month2;i++)
					day2+=days[i];
				if((day2-day1)%7==0)
					printf("YES\n");
				else
					printf("NO\n");
				
			}
			else
			{
				int days[12]={0,31,28,31,30,31,30,31,31,30,31,30};
				int day1=0,day2=0;
				for(i=0;i<month1;i++)
					day1+=days[i];
				for(i=0;i<month2;i++)
					day2+=days[i];
				if((day2-day1)%7==0)
					printf("YES\n");
				else
					printf("NO\n");
			}
		}
		
		
	
	}
	return 0;
}
void main()
{
	int n,i,j,y[200],m1[200],m2[200],mon[12],sum=0,t;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&y[i],&m1[i],&m2[i]);
	}
	for(i=0;i<n;i++){
		sum=0;
	
		if(m2[i]>m1[i]){t=m2[i];m2[i]=m1[i];m1[i]=t;}
		
		if(m2[i]>2){
			for(j=m2[i];j<m1[i];j++){
				if(j==3||j==5||j==7||j==8||j==10||j==12){mon[j]=31;}
				else {mon[j]=30;}
				sum+=mon[j];
			}
			if(sum%7==0){printf("YES\n");}
			else {printf("NO\n");}
		}
		else if(m1[i]==2&&m2[i]==1){printf("NO\n");}
		else if(m2[i]<=2&&m1[i]>2){
			if((y[i]%100!=0&&y[i]%4==0)||(y[i]%400==0)){
		    for(j=m2[i];j<m1[i];j++){
				if(j==1||j==3||j==5||j==7||j==8||j==10||j==12){mon[j]=31;}
				else if(j==2){mon[j]=29;}
				else {mon[j]=30;}
			     sum+=mon[j];
			}
	         if(sum%7==0){printf("YES\n");}
			 else {printf("NO\n");}
			}

		   else{
			  for(j=m2[i];j<m1[i];j++){
				 if(j==1||j==3||j==5||j==7||j==8||j==10||j==12){mon[j]=31;}
				 else if(j==2){mon[j]=28;}
			     else {mon[j]=30;}
			     sum+=mon[j];
				}
				if(sum%7==0){printf("YES\n");}
			    else {printf("NO\n");}
			}
		}
	}



}
int main()
{
	int i,j,n,k,year[200],month1[200],month2[200],month[12]={31,28,31,30,31,30,31,31,30,31,30,31},day[200];
	scanf("%d\n",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d\n",&year[i-1],&month1[i-1],&month2[i-1]);
		//scanf("\n");
	}
	for(i=1;i<=n;i++)
	{
		day[i-1]=0;
		if(month1[i-1]>month2[i-1])
		{
			k=month1[i-1];
			month1[i-1]=month2[i-1];
			month2[i-1]=k;
		}

		for(j=month1[i-1];j<month2[i-1];j++)
		{
			day[i-1]+=month[j-1];
		}
		/*for(j=1;j<=month1[i-1]-1;j++)
		{
			day[i-1]-=month[j-1];
		}*/
		if(((year[i-1]%4==0&&year[i-1]%100!=0)||year[i-1]%400==0)&&month1[i-1]<3&&month2[i-1]>=3)
		{
			day[i-1]++;
		}
		if(day[i-1]%7==0)
			printf("YES\n");
			else printf("NO\n");
	}
	return 0;
}
int main()
{
	int n, i, j, t, leap, day, year, m1, m2;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> year >> m1 >> m2;
		day = 0;
		if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
			leap = 1;
		else
			leap = 0;
		if (m1 > m2)
		{
			t = m2;
			m2 = m1;
			m1 = t;
		}
		for (j = m1; j < m2; j++)
		{
			switch (j)
			{
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
				day += 31;
				break;
			case 2:
				day += 28 + leap;
				break;
			default:
				day += 30;
				break;
			}
		}
		if ( day % 7 == 0)
			cout << "YES" <<endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}
int main()
{
	int n,i,j,k,day1=0,day2=0,cha=0;
	int nian,y1,y2,mont[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; ;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		
		day1=0;
		day2=0;
		cha=0;
		scanf("%d %d %d",&nian,&y1,&y2);
		if ((nian%4==0 && nian%100!=0)||nian%400==0) 
			mont[2]=29; 
        else  
            mont[2]=28;
		for(j=0;j<y1;j++)	
			day1+=mont[j];
		for(k=0;k<y2;k++)
			day2+=mont[k];
		cha=day1-day2;
		if((day1-day2)<0)
			cha=day2-day1;
		if((cha%7)==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}
/*
?? - ??(10.5) ???   
 
?? ???????????08????? 
?? 
?????????????????????????????????????????????????????????????????????
??????????????????7?????????????????????????????????????????28????7???????4
??????????????????????????????????????29??????????????????????
 ???? 
?????????n?n?200?? 
??n??????????????????????????????????
 ???? 
???n???????????????????? 
???????????????YES? 
?????NO?
 ???? 
5
1994 10 9
1935 12 1
1957 1 9
1917 9 12
1948 1 4
 ???? 
NO
NO
NO
YES
YES
 
?? 
????????????????????????????? 
???????????????????????????????????? 
*/
void main()
{
	int f(int,int);
	int n,i,y,m1,m2,M1,M2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&y,&m1,&m2);
		M1=f(y,m1);
		M2=f(y,m2);
		if((M1-M2)%7==0)
			printf("YES\n");
		else 
			printf("NO\n");
	}
}

int f(int year,int month)
{
	int re;
	if((year%4)!=0||(year%100==0&&year%400!=0))
	{
		switch(month)
			{
			case 1:re=1;break;
			case 2:re=32;break;
			case 3:re=60;break;
			case 4:re=91;break;
			case 5:re=121;break;
			case 6:re=152;break;
			case 7:re=182;break;
			case 8:re=213;break;
			case 9:re=244;break;
			case 10:re=274;break;
			case 11:re=305;break;
			case 12:re=335;break;
			default: break;
	};}
	else
		switch(month)
			{
			case 1:re=1;break;
			case 2:re=32;break;
			case 3:re=61;break;
			case 4:re=92;break;
			case 5:re=122;break;
			case 6:re=153;break;
			case 7:re=183;break;
			case 8:re=214;break;
			case 9:re=245;break;
			case 10:re=275;break;
			case 11:re=306;break;
			case 12:re=336;break;
			default: break;
			};
	return re;
}
int day0[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int day1[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
void judge(int i,int x,int y){
	if(x==y) cout<<"Data Error"<<endl;
	int ds=0;
	if(i==1){
		if(x<y){
			for(int j=x;j<y;j++)
				ds=ds+day1[j];
		}
		else{
			for(int j=y;j<x;j++)
				ds=ds+day1[j];
		}
		if(ds%7==0) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	else{
		if(x<y){
			for(int j=x;j<y;j++)
				ds=ds+day0[j];
			}
		else{
			for(int j=y;j<x;j++)
				ds=ds+day0[j];
		}
		if(ds%7==0) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}
int main(){
	int n,year,month1,month2;
	cin>>n;
	while(n!=0){
		cin>>year>>month1>>month2;
		if((year%4==0&&year%100!=0)||year%400==0) judge(1,month1,month2);
		else judge(0,month1,month2);
		n--;
	}
	return 0;
}
int main(int argc, char* argv[])
{
	int i,j,n,k,t1=0,t2=0;
	struct p{
		int year;
		int month1;
		int month2;
	}p[200];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d%d%d",&p[i].year,&p[i].month1,&p[i].month2);
	for(i=0;i<n;i++)
	{t1=0,t2=0;
		for(j=0;j<p[i].month1;j++)
		{
			if((j==1)||(j==3)||(j==5)||(j==7)||(j==8)||(j==10)||(j==12))
				t1+=31;
			else if((j==4)||(j==6)||(j==9)||(j==11))
				t1+=30;
			else if(j==2)
			{
				if(p[i].year%400 == 0 ||(p[i].year%4==0 &&p[i].year%100!=0))
					t1+=29;
				else
					t1+=28;
			}
		}
		for(k=0;k<p[i].month2;k++)
		{
			if((k==1)||(k==3)||(k==5)||(k==7)||(k==8)||(k==10)||(k==12))
				t2+=31;
			else if((k==4)||(k==6)||(k==9)||(k==11))
				t2+=30;
			else if(k==2)
			{
				if(p[i].year%400 == 0 ||(p[i].year%4==0 &&p[i].year%100!=0))
					t2+=29;
				else
					t2+=28;
			}
		}
		if(((t2-t1)%7==0)||((t1-t2)%7==0))
			printf("YES\n");
		else
			printf("NO\n");
	}
	
	return 0;
}
main()
{
  int i,n,y,m1,m2;char year;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    int a[7]={1,3,5,7,8,10,12};
    int s=0;int t=0;
    scanf("%d %d %d",&y,&m1,&m2);
    if((y%4==0&&y%100!=0)||y%400==0) year='t';
    else year='f';
    if(year=='f')
    {
       if(m1>m2) 
       {
         for(int k=m2;k<m1;k++)
         {
            for(int j=0;j<7;j++) 
            {
              if(a[j]==k) t=1;
            }
            if(t==1) s=s+31;
              else if(k==2) s=s+28;
                   else s=s+30;
            t=0;
         }
       }
       else
       {
         for(int k=m1;k<m2;k++)
         {
            for(int j=0;j<7;j++) 
            {
              if(k==a[j]) t=1;
            }
            if(t==1) s=s+31;
              else if(k==2) s=s+28;
                   else s=s+30;
              t=0;
         }
       }
    }
    else
    {
       if(m1>m2) 
       {
         for(int k=m2;k<m1;k++)
         {
            for(int j=0;j<7;j++) 
            {
              if(a[j]==k) t=1;
            }
            if(t==1) s=s+31;
              else if(k==2) s=s+29;
                   else s=s+30;
                   t=0;
         }
       }
       else
       {
         for(int k=m1;k<m2;k++)
         {
           for(int j=0;j<7;j++) 
            {
              if(a[j]==k) t=1;
            }
            if(t==1) s=s+31;
              else if(k==2) s=s+29;
                   else s=s+30;
                   t=0;
         }
       }
    }
   if(s%7==0)    printf("YES\n");
   else  printf("NO\n");
  }
  getchar();
  getchar();
  getchar();
}