semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int runnian(int n);
int day(int m);
int main()
{
	int n,y,m1,m2;
	int i;
	int e,da;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&y,&m1,&m2);
		if(m1>m2)
		{
			e=m1;
			m1=m2;
			m2=e;
		}
		if((m1==1||m1==2)&&(m2!=1&&m2!=2)&&runnian(y)==1)
		{
			da=day(m2)-day(m1)+1;
		}
		else 
			da=day(m2)-day(m1);
	if(da%7==0)
		printf("YES\n");
	else printf("NO\n");
	}
	return 0;
}
int runnian(int n)
{
	if(n%400==0)
		return 1;
	else if(n%100==0)
		return 0;
	else if(n%4==0)
		return 1;
	else return 0;
}
int day(int m)
{
	int num;
	if(m==1)
		num=0;
	else if(m==2)
		num=31;
	else if(m==3)
		num=59;
	else if(m==4)
		num=90;
	else if(m==5)
		num=120;
	else if(m==6)
		num=151;
	else if(m==7)		
		num=181;
	else if(m==8)
		num=212;
	else if(m==9)
		num=243;
	else if(m==10)
		num=273;
	else if(m==11)
		num=304;
	else if(m==12)
		num=334;
	return num;
}
int main(int argc, char* argv[])
{
	int i,n,a[200],b[200],c[200];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		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)||(b[i]==1&&c[i]==7)||(b[i]==7&&c[i]==1)||(b[i]==2&&c[i]==8)||(b[i]==8&&c[i]==2)||(b[i]==3&&c[i]==11)||(b[i]==11&&c[i]==3)||(b[i]==4&&c[i]==7)||(b[i]==7&&c[i]==4)||(b[i]==9&&c[i]==12)||(b[i]==12&&c[i]==9))
				printf("YES\n");
			else
			printf("NO\n");
		}
		else
		{
			if((b[i]==1&&c[i]==10)||(b[i]==10&&c[i]==1)||(b[i]==2&&c[i]==3)||(b[i]==3&&c[i]==2)||(b[i]==2&&c[i]==11)||(b[i]==11&&c[i]==2)||(b[i]==3&&c[i]==11)||(b[i]==11&&c[i]==3)||(b[i]==4&&c[i]==7)||(b[i]==7&&c[i]==4)||(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;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        int y,m1,m2,m=0,j,sum=0;
        scanf("%d%d%d",&y,&m1,&m2);
        if(m1>m2)
        {
            m=m1;
            m1=m2;
            m2=m;
        }                    
        
        if((y%4==0&&y%100!=0)||(y%400==0))
        {
            int mon[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
            for(j=m1;j<=m2-1;j++)
            {
                sum=sum+mon[j];
            }
            if(sum%7==0)
            printf("YES\n");
            else
            printf("NO\n");
        }
        else if((y%4!=0)||(y%100==0&&y%400!=0))
        {
            int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
            for(j=m1;j<=m2-1;j++)
            {
                sum=sum+mon[j];
            }
            if(sum%7==0)
            printf("YES\n");
            else
            printf("NO\n");
        }
    }
    //int a;
    //scanf("%d",&a);
    //printf("%d",a);
    return 0;
}
//???????????????????????????????????????????????????????????????????????????????????????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
void main()
{
	int a,b,c,d,e,f,i,j,k,sum=0,x,n,ex;
	scanf("%d",&n);
	for(x=1;x<=n;x++){
	sum=0;
	scanf("%d%d%d",&a,&b,&e);
	d=a;
	c=f=1;
	if(b>e){
		ex=b;
		b=e;
		e=ex;
	}
	for(i=a;i<=d;i++)
	{
		if((i%4==0&&i%100!=0)||(i%400==0)) 
			sum=sum+366;
		else
			sum=sum+365;
	}
	for(j=1;j<=b-1;j++)
	{
		if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
			sum=sum-31;
		else if(j==4||j==6||j==9||j==11)
				sum=sum-30;
			else if((a%4==0&&a%100!=0)||(a%400==0))
					sum=sum-29;
				else
					sum=sum-28;
	}
	for(j=e+1;j<=12;j++)
	{
		if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
			sum=sum-31;
		else if(j==4||j==6||j==9||j==11)
				sum=sum-30;
			else if((d%4==0&&d%100!=0)||(d%400==0))
					sum=sum-29;
				else
					sum=sum-28;
	}
	j=e;
	if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
			sum=sum+f-31;
		else if(j==4||j==6||j==9||j==11)
				sum=sum+f-30;
			else if((j%4==0&&j%100!=0)||(j%400==0))
					sum=sum+f-29;
				else
					sum=sum+f-28;
	sum=sum-c;
	//printf("%d",sum);
	if(x==1)
		if(sum%7==0)
			printf("YES");
		else
			printf("NO");
	else
		if(sum%7==0)
			printf("\nYES");
		else
			printf("\nNO");
	}
}
int main()
{
    int a,b,c,i,n;
    scanf("%d\n",&n);
    for(i=1;i<=n;i++){
        scanf("%d %d %d\n",&a,&b,&c);
        if((b==3&&c==11)||(b==11&&c==3)||(b==4&&c==7)||(b==7&&c==4)||(b==9&&c==12)||(b==12&&c==9)){
            printf("YES\n");}
        else if(((a%4==0&&a%100!=0)||(a%400==0))&&((b==1&&c==4)||(b==4&&c==1)||(b==1&&c==7)||(b==7&&c==1)||(b==2&&c==8)||(b==8&&c==2))){
            printf("YES\n");}
        else if(((a%4!=0||a%100==0)&&(a%400!=0))&&((b==1&&c==10)||(b==10&&c==1)||(b==2&&c==3)||(b==3&&c==2)||(b==2&&c==11)||(b==11&&c==2))){
            printf("YES\n");}
        else{
            printf("NO\n");}
    }
    return 0;
}
int main()
{
	int n,m,a,b,c;
	cin>>n;
	for(int i=0;i<n;i++)
		{cin>>m>>a>>b;
	     c=0;
	    if(a<b)
			for(int j=a;j<b;j++)
				{if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
				 {c=c+31;}
				else  if(j==4||j==6||j==9||j==11)
				       {c=c+30;}
				       else if(j==2&&(m%4==0&&m%100!=0)||m%400==0)
					   {c=c+29;}
					   else
			             c=c+28;}
				
		else
			for(int j=b;j<a;j++)
				{if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
				       {c=c+31;}
				else  if(j==4||j==6||j==9||j==11)
				         {c=c+30;}
				      else if(j==2&&(m%4==0&&m%100!=0)||m%400==0)
					  {c=c+29;}
					  else
			             c=c+28;}
				
		if(c%7==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;}
		return 0;
}
int RN(int y)
{
	int z;
	if(y%400==0||(y%4==0&&y%100!=0))
		z=1;
	else z=0;
	return z;
}
int PD(int N,int Y1,int Y2)
{
	int RN(int y),i,j,k=0,m=0;
	if(RN(N)==1)
	{
		if(Y1>Y2)
		{
			for(i=Y2;i<Y1;i++)
			{
				if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
					k=31;
				else if(i==4||i==6||i==9||i==11)
					k=30;
				else k=29;
				m=m+k;
			}
		}
		if(Y1<Y2)
		{
			for(i=Y1;i<Y2;i++)
			{
				if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
					k=31;
				else if(i==4||i==6||i==9||i==11)
					k=30;
				else k=29;
				m=m+k;
			}
		}
	}
	else
	{
		if(Y1>Y2)
		{
			for(i=Y2;i<Y1;i++)
			{
				if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
					k=31;
				else if(i==4||i==6||i==9||i==11)
					k=30;
				else k=28;
				m=m+k;
			}
		}
		if(Y1<Y2)
		{
			for(i=Y1;i<Y2;i++)
			{
				if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
					k=31;
				else if(i==4||i==6||i==9||i==11)
					k=30;
				else k=28;
				m=m+k;
			}
		}
	}
	if(m%7==0)j=1;
	else j=0;
	return j;
}
void main()
{
	int *a,*A,m,n,b,c,d,i;
	int PD(int N,int Y1,int Y2);
	int RN(int y);
	scanf("%d",&n);
	a=(int*)malloc(n*sizeof(int));
	A=a;
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&b,&c,&d);
		*a=PD(b,c,d);
		a++;
	}
	for(i=0;i<n;i++,A++)
	{
		if(*(A)==1)
			printf("YES\n");
		else
			printf("NO\n");
	}
}
int day(int y,int m)
{
	int flag,days=0,i;
	if((y%100!=0&&y%4==0)||y%400==0)
		flag=1;
	else flag=0;
	int month[13]={0,31,28+flag,31,30,31,30,31,31,30,31,30,31};
	for(i=1;i<m;i++)
		days+=month[i];
	return days;
}

int main()
{
   int n;
   cin>>n;
   while(n--)
   {
   int y,m1,m2,s;
   cin>>y>>m1>>m2;
   s=abs(day(y,m1)-day(y,m2));
   if(s%7==0)
        cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
   }
   return 0;
}
void main()
{
	int y,m,n,i,e,k;
	int day=0;
	int t;
	scanf("%d",&t);
	for(k=1;k<=t;k++){
		{
	scanf("%d%d%d",&y,&m,&n);
		}
	if(m>n)
	{
		e=m;
	m=n;
	n=e;
	}
		for(i=m;i<n;i++){
			if(i==1||i==3||i==5||i==7||i==8||i==10)
			{
				day=day+31;
			}
			if(i==4||i==6||i==9||i==11)
			{
				day=day+30;
			}
			if(i==2&&(y%400==0||((y%4==0)&&(y%100!=0))))
			    day=day+29;
			if(i==2&&(y%4!=0||(y%100==0&&(y%400!=0))))
				day=day+28;
	
		}
	
	
		if(day%7==0)
			printf("YES\n");
		else
			printf("NO\n");
		day=0;
	}
}
int main()
{int n,d,a[200][3],i,j,r,b[12]={31,28,31,30,31,30,31,31,30,31,30,31},k;//???????????????a???????b
cin>>n;//?????
for(i=1;i<=n;i++)//?????????
{for(j=1;j<=3;j++)
cin>>a[i][j];}
for(i=1;i<=n;i++)//?????????????
	{if(a[i][2]>a[i][3])
       {k=a[i][2];a[i][2]=a[i][3];a[i][3]=k;}}
for(i=1;i<=n;i++)//?????????
 {d=0;
	 for(r=a[i][2]-1;r<a[i][3]-1;r++)
	 {d=d+b[r];}//??????????
  if ((a[i][2])<=2&&(a[i][3]>=3)&&((a[i][1]%4==0&&a[i][1]%100!=0)||(a[i][1]%400==0)))//????
	  d=d+1; 
if(d%7==0)cout<<"YES"<<endl;//????????????
else cout<<"NO"<<endl;}
return 0;}
int main()
{
    int a[12]={1,32,60,91,121,152,182,213,244,274,305,335},
        b[12]={1,32,61,92,122,153,183,214,245,275,306,336},
        y,i,j,n,t,s;
        scanf("%d",&n);
        for(t=0;t<n;t++)
        {scanf("%d %d %d",&y,&i,&j);
        if((y%4!=0)||((y%100==0)&&(y%400!=0)))
        {s=a[i-1]-a[j-1];
        if(s%7==0)
        printf("YES\n");
        else
        printf("NO\n");}
        else
        {s=b[i-1]-b[j-1];
        if(s%7==0)
        printf("YES\n");
        else
        printf("NO\n");
        }}
        return 0;
        }
int DiJiTian(int year, int month);
int isRunNian(int year);

int main(){
	int n,i;
	int year[200],mon1[200],mon2[200],a[200];

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d %d %d",&year[i],&mon1[i],&mon2[i]);
	}

	for(i=0;i<n;i++){
		a[i]=DiJiTian(year[i],mon1[i])-DiJiTian(year[i],mon2[i]);
		a[i]=(a[i]>=0?a[i]:(0-a[i]));
	}

	for(i=0;i<n;i++){
		if(a[i]%7==0){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}

	return 0;
}



int DiJiTian(int year, int month){
	int result = 0;
	int day=1;
	for(int i = 1; i < month; i++){ 
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result += 31;	
		} else if (i == 4 || i ==6 || i == 9 || i==11){
			result += 30;
		} else if(i == 2){
			if(isRunNian(year)){
				result += 29;
			} else {
				result += 28;
			}	
		}
	}
	result += day;
	return result;	
}



int isRunNian(int year){
	int result;
	if(year%400 == 0 ||(year%4==0 && year%100!=0)){
		result = 1;
	} else{
		result = 0;
	}
      return result;	
}
int main()
{ 
int i,j,n,y,m1,m2,b,t,s,a[12]={0,31,28,31,30,31,30,31,31,30,31,30,31};
scanf("%d",&n);
for(i=1;i<=n;i++)
{b=0;
scanf("%d%d%d",&y,&m1,&m2);
if(y%4==0&&y%100!=0||y%400==0)
{b=1;}
if(m1>m2)
{t=m1;
m1=m2;
m2=t;}
s=0;
for(j=m1;j<=m2-1;j++)
{s+=a[j];
if(j==2&&b==1)
{s++;}}
if(s%7==0)
{printf("YES\n");}
else
{printf("NO\n");}}
return 0;
}
int f(int y, int m1, int m2)
{
	int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int sum=0,i;
	for(i=m1;i<=m2-1;i++)
		{
		sum=sum+a[i];
	}

		if(m1<=2 &&((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)))
			sum=sum+1;

		if(sum%7==0)
			return 1;
		else
			return 0;

	
}

void main()
{
	int n,y,m1,m2,m,i;
	scanf("%d",&n);

	for(i=0;i<=n-1;i++)
	{
		scanf("%d%d%d",&y,&m1,&m2);
		if(m1>m2)
		{
			m=m1;
			m1=m2;
			m2=m;
		}
		if(f(y,m1,m2))
			printf("YES\n");
		else
			printf("NO\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};
int judge[100];
int main()
{
    memset(judge,0,sizeof judge);
    int n,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        int year,month1,month2;
        cin>>year>>month1>>month2;
        if(month1>month2)
        {
            int temp=month1;
            month1=month2;
            month2=temp;
        }
        int day=0,j;

        if(month1==month2) day=0;
        else if((year%4==0&&year%100!=0)||year%400==0)
        {
            for(j=month1;j<month2;j++)  day+=b[j];
        }
        else
        {
            for(j=month1;j<month2;j++) day+=a[j];
        }
        if(day%7==0) judge[i]=1;
        else judge[i]=0;


    }
    for(i=1;i<=n;i++)
    {

        if(judge[i]==1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }


    return 0;
}
/*
 * 1.cpp
 *
 *  Created on: 2012-11-2
 *      Author: 99003
 */

int luna(int year)
{
	if (year%400==0) return 1;
	if(year%100==0) return 0;
	if(year%4==0) return 1;
	else return 0;}
int main(){
	int year,month1,month2,day;
	int n;
	int mon[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>n;
	for(;n>=1;n--){
		day=0;
		cin>>year>>month1>>month2;
		mon[2]=mon[2]+luna(year);
		if(month1-month2>0)
		{
			for(;month2<month1;month2++)
			{
				day=day+mon[month2];
			}
		}
		if(month1-month2<0)
				{
					for(;month1<month2;month1++)
					{
						day=day+mon[month1];
					}
				}
		if(day%7==0) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
		mon[2]=28;
	}
	return 0;
}
int main()
{
	int n,a[200][3],i,b[11],t;
	cin>>n;
	b[0]=31;b[2]=31;b[3]=30;b[4]=31;b[5]=30;b[6]=31;b[7]=31;b[8]=30;b[9]=31;b[10]=30;
	int year,mon_1,mon_2;
	for(i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	for(i=0;i<n;i++)
	{
		int sum=0;
		year=a[i][0];
		mon_1=a[i][1];
		mon_2=a[i][2];
		if(a[i][1]>=a[i][2]) 
		{int temp;
		temp=mon_1;
		mon_1=mon_2;
		mon_2=temp;
		}
		if((year%4==0&&year%100!=0)||((year%400)==0))
		{
			b[1]=29;
			for(t=(mon_1-1);t<(mon_2-1);t++)
				{sum=sum+b[t];
			}
			if(sum%7==0) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
		else
		{
			b[1]=28;
			for(t=(mon_1-1);t<(mon_2-1);t++)
				{sum=sum+b[t];
			}
			if(sum%7==0) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
	}
	return 0;
}
main()
{
int c[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int n,m,j,a,b,s,i,t;
scanf("%d",&m);
getchar();
for(j=1;j<=m;j++)
{
c[2]=28;
s=0;
scanf("%d %d %d",&n,&a,&b);
if((n%4==0&&n%100!=0)||n%400==0)
{
c[2]=29;
}
if(a>b)
{
    t=a;
    a=b;
    b=t;
}
for(i=a;i<b;i++)
s+=c[i];
if(s%7==0)
{
printf("YES\n");
}
else
printf("NO\n");
}
getchar();
getchar();
}
int Run(int);
int DI(int,int); 
int main()
{ 
	int n,j,m;
	int year[200],month[200][2],a[200];
		scanf("%d",&n);
	for(m=0;m<n;m++){
		scanf("%d %d %d",&year[m],&month[m][0],&month[m][1]);
		if((DI(year[m],month[m][1])-DI(year[m],month[m][0]))%7==0)
			a[m]=1;
		else 
			a[m]=0;
	}	
	for( j=0;j<n;j++){
		if(a[j]==1)
	printf("YES\n");
		else
	printf("NO\n");}
return 0;
}

	

	int DI(int year,int month)
	{
		int i;
		int Run(int);
	int total=1;
	for(i=1;i<month;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
			total+=31;
		else if(i==4||i==6||i==9||i==11)
			total+=30;
		else if(i==2){
			if(Run(year)){
				total+=29;
			}else {
				total+=28;
			}
	}}
		
		return total;
	

}
int Run(int year){
		
		
		int result=0;
		if(year%400==0||(year%4==0&&year%100!=0)){
			result=1;
		}else {
			result=0;
	}
	return result;
	}
int run(int a)
{ int day;
if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)
	day=3;
else if(a==2)
	day=1;
else day=2;
return(day);
}


int feirun(int a)
{ int day;
if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)
	day=3;
else if(a==2)
	day=0;
else day=2;
return(day);
}


int main()
{
	int n,sum;
	cin>>n;
	int year[300],mon1[300],mon2[300];
	int i,j;
	for(i=0;i<n;i++)
	{
		cin>>year[i]>>mon1[i]>>mon2[i];
	}
	
	
	for(i=0;i<n;i++)
	{         
		sum=0;
		if(year[i]%400==0||year[i]%4==0&&year[i]%100!=0)
		{
			if(mon1[i]>mon2[i])
			{
				for(j=mon2[i];j<mon1[i];j++)
				{
					sum=sum+run(j);
				}			
			}
			else
			{
				for(j=mon1[i];j<mon2[i];j++)
				{
					sum=sum+run(j);
				}			
			}
		}
		else
			{
			if(mon1[i]>mon2[i])
			{
				for(j=mon2[i];j<mon1[i];j++)
				{
					sum=sum+feirun(j);
				}	
		
			}
			else
			{
				for(j=mon1[i];j<mon2[i];j++)
				{
					sum=sum+feirun(j);
				}			
		
			}
		}
		if(sum%7==0)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;	
	}
	return 0;
}
int main ( )
{
	int n,year,a,b,i,j,Temp,days=0;
	int Month1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int Month2[13]={0,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",&year,&a,&b);
		if (a>b){
                           Temp=a;
			a=b;
			b=Temp;
		}
		if( year%400==0 || (year%4==0 && year%100!=0))
		{
			days=0;
			for(j=a;j<b;j++)
				days=days +Month2[j];
		}
		else
		{
			days=0;
			for(j=a;j<b;j++)
				days=days +Month1[j];
		}
		if(days%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}
int leap(int a)
{
    if (((a % 4 == 0) && (a % 100 != 0)) || a % 400 == 0) return 1;
    else return 0;
}

int bigger(int a, int b)
{
    if (a >= b) return a;
    else return b;
}

int main()
{
    int n, year, month1, month2, big, small, countdays;
    int days[2][12] = {{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
                       {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> year >> month1 >> month2;
        big = bigger(month1, month2);
        small = month1 + month2 - big;
        countdays = 0;
        for (int j = small - 1; j < big - 1; j++)
        {
            countdays += days[leap(year)][j];
        }
        if (countdays % 7 == 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}
int main()
{
	int year,m1,n,m2,d1=0,d2=0,i,j,k;
	int	month1[12]={0,31,28,31,30,31,30,31,31,30,31,30};
	int month2[12]={0,31,29,31,30,31,30,31,31,30,31,30};
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&year,&m1,&m2); 
		if ((year%400==0)||(year%4==0&&year%100!=0))//???//
		{
			for (j=1;j<=m1;j++)
			{
				d1+=month2[j-1];
			}
			for (j=1;j<=m2;j++)
			{
				d2+=month2[j-1];
			}
			if((d1-d2)%7==0)
				printf("YES\n");
			else printf("NO\n");
		}
		else 
		{
			for (j=1;j<=m1;j++)
			{
				d1+=month1[j-1];
			}
			for (j=1;j<=m2;j++)
			{
				d2+=month1[j-1];
			}
			if((d1-d2)%7==0)
				printf("YES\n");
			else printf("NO\n");
		}
		d1=0;d2=0;
	}
	return 0;
}
main()
{
    int n,i,j,a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        int year,m1,m2;
        scanf("%d %d %d",&year,&m1,&m2);
        int sum;
        if((year%4==0)&&(year%100)!=0||(year%400==0))
        {
             a[2]=29;
        }
        else a[2]=28;
        if(m1<m2)
        {for(j=m1,sum=0;j<m2;j++)
        {
            sum=sum+a[j];
        }}
        else
        {for(j=m2,sum=0;j<m1;j++)
        {
            sum=sum+a[j];
        }}
        if(sum%7==0)
        printf("YES\n");
        else
        printf("NO\n");
        
    }
}
int main()
{
	int year[200],m1,m2,i,n;
	scanf("%d", &n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d\n",&year[i],&m1,&m2);
		if(year[i]%400 == 0 ||(year[i]%4==0 && year[i]%100!=0)){
			if((m1==4&&m2==7)||(m1==7&&m2==4)||(m1==9&&m2==12)||(m1==12&&m2==9)||(m1==1&&m2==4)||(m1==4&&m2==1)||(m1==11&&m2==3)||(m1==3&&m2==11)||(m1==1&&m2==7)||(m1==7&&m2==1)||(m1==2&&m2==8)||(m1==8&&m2==2)){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
		else{
			if((m1==4&&m2==7)||(m1==7&&m2==4)||(m1==9&&m2==12)||(m1==12&&m2==9)||(m1==2&&m2==3)||(m1==3&&m2==2)||(m1==11&&m2==3)||(m1==3&&m2==11)||(m1==1&&m2==10)||(m1==10&&m2==1)||(m1==2&&m2==11)||(m1==11&&m2==2)){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
	}
	return 0;
}
int main()
{
	int n, k, year, mon, mona, monb, monc, leap, days;
	cin >> n;
	for (k = 1; k <= n; k++)
	{
		days = 0;
		cin >> year >> mona >> monb;
		leap = ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
		if (mona < monb)
		{
		}
			else
			{
				monc = mona;
				mona = monb;
				monb = monc;
			}
			for (mon = mona; mon <= monb - 1; mon++)
			{
				switch (mon)
				{
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
				case 12:
					{
						days += 31;
						break;
					}
				case 4:
				case 6:
				case 9:
				case 11:
					{
						days += 30;
						break;
					}
				case 2:
					{
						days += 28 + leap;
						break;
					}
				}
			}
			//cout << "days=" << days << endl;
			if (days % 7 == 0)
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
	}
	return 0;
	
}
int main()
{
	int n, year, a, b, k, i, t, sum;
	int x[12]={3,1,3,2,3,2,3,3,2,3,2,3};
	int y[12]={3,0,3,2,3,2,3,3,2,3,2,3};
	cin >> n;
	for(i=0;i<n;i++)
	{
		cin >> year >> a >> b;
		sum = 0;
		if(a>b)
		{
			k = a;
			a = b;
			b = k;
		}
		if((year%4==0&&year%100!=0)||(year%400==0))
		{
			for(t=a-1;t<b-1;t++)				//?????!?a?????x[a-1]!!!
				sum = sum + x[t];
		}
		else
		{
			for(t=a-1;t<b-1;t++)
			
				sum = sum + y[t];
		}
		if(sum%7==0)
			cout << "YES" << endl;
		else 
			cout << "NO" << endl;
	}
	return 0;
}
int main()
{
	int a[13];
	int n;
	scanf("%d",&n);
	a[1]=31;
	a[2]=0;
	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 i;
	int year,y1,y2,tmp;
	int sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&year,&y1,&y2);
		if(y1>y2)
		{
			tmp=y1;
			y1=y2;
			y2=tmp;
		}
		if((year%4==0&&year%100!=0)||year%400==0)
		{
			a[2]=29;
			for(;y1<y2;y1++)
			{
				sum+=a[y1];
			}
			if(sum%7==0)
			{
				printf("YES\n");
			}
			else 	printf("NO\n"); 

			sum=0;
		}

		else
		{
			a[2]=28;
			for(;y1<y2;y1++)
			{
				sum+=a[y1];
			}
			if(sum%7==0)
			{
				printf("YES\n");
			}
			else 	printf("NO\n"); 

			sum=0;
		}
	}
	return 0;
}
int main()
{
	int i,j,n,h=0,y[200],n1[200],n2[200];
	int m1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int m2[13]={0,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[i],&n1[i],&n2[i]);
		if(((y[i]%4==0)&&(y[i]%100!=0))||y[i]%400==0){
			h=0;
			if(n1[i]<n2[i]){
				for(j=n1[i];j<n2[i];j++){
					h+=m2[j];
				}
				if(h%7==0)
					printf("YES\n");
				else if(h%7!=0)
					printf("NO\n");
			}
			else if(n1[i]>n2[i]){
				for(j=n2[i];j<n1[i];j++){
					h+=m2[j];
				}
				if(h%7==0)
					printf("YES\n");
				else if(h%7!=0)
					printf("NO\n");
			}
		}
		else{
			h=0;
			if(n1[i]<n2[i]){
				for(j=n1[i];j<n2[i];j++){
					h+=m1[j];
				}
				if(h%7==0)
					printf("YES\n");
				else if(h%7!=0)
					printf("NO\n");
			}
			else if(n1[i]>n2[i]){
				for(j=n2[i];j<n1[i];j++){
					h+=m1[j];
				}
				if(h%7==0)
					printf("YES\n");
				else if(h%7!=0)
					printf("NO\n");
			}
		}
	}
	return 0;
}
int main()
{
	int n,i,j;
	scanf("%d",&n);
	int m[n][3];
	for(i=0;i<n;i++){
		scanf("%d %d %d",&m[i][1],&m[i][2],&m[i][3]);
	}
	for(j=0;j<n;j++){
		if(((m[j][2]==9&&m[j][3]==12)||(m[j][3]==9&&m[j][2]==12))||((m[j][2]==4&&m[j][3]==7)||(m[j][3]==4&&m[j][2]==7))||((m[j][2]==3&&m[j][3]==11)||(m[j][3]==3&&m[j][2]==11)))
			printf("YES\n");
		else {
			if(((m[j][1]%4==0&&m[j][1]%100!=0)||(m[j][1]%400==0))&&(((m[j][2]==1&&m[j][3]==4)||(m[j][3]==1&&m[j][2]==4))||((m[j][2]==1&&m[j][3]==7)||(m[j][3]==1&&m[j][2]==7))||((m[j][2]==2&&m[j][3]==8)||(m[j][3]==2&&m[j][2]==8))))
				printf("YES\n");
			else {
				if((m[j][1]%4!=0||(m[j][1]%100==0)&&(m[j][1]%400!=0))&&(((m[j][2]==1&&m[j][3]==10)||(m[j][3]==1&&m[j][2]==10))||((m[j][2]==2&&m[j][3]==3)||(m[j][3]==2&&m[j][2]==3))||((m[j][2]==2&&m[j][3]==11)||(m[j][3]==2&&m[j][2]==11))))
					printf("YES\n");
				
				else
					printf("NO\n");
			}
		}
	}
	return 0;
}
int main()
{
	int n,i,k,j,d;
	scanf("%d\n",&n);
	int y,m1,m2;
	int sum1=0;
	for(k=0;k<n;k++)
	{
		scanf("%d %d %d",&y,&m1,&m2);
		int temp;
		if(m1>m2)
		{
			temp=m1;
			m1=m2;
			m2=temp;}
		int sum1=0;
		for(j=m1;j<m2;j++)
		{
			if(j==1||j==3||j==5||j==7||j==8||j==10) {
            sum1+=3;
			}
			 if(j==4||j==6||j==9||j==11) {
            sum1+=2;}
			if(j==2&&((y%4==0)&&(y%100!=0)||(y%400==0))) 
			{sum1+=1;}
		}
				d=sum1%7;
				if(d==0)
				{printf("YES\n");}
				else printf("NO\n");
			
	}
	return 0;
}
int leapyear(int year)
{
	if (year%400==0 || (year%4==0 && year%100!=0))
		return 1;
	return 0;
}

int daycount(int year,int month)
{
	int i, sum=0;
	for (i=1;i<month;i++)
		if (i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)
			sum+=31;
		else if (i==4 || i==6 || i==9 || i==11)
			sum+=30;
		else if (i==2 && leapyear(year))
			sum+=29;
		else sum+=28;
	return sum;
}
int main()
{
	int n,i;
	int year[200],month1[200],month2[200];
	scanf("%d",&n);
	for (i=0;i<n;i++)
		scanf("%d%d%d",&year[i],&month1[i],&month2[i]);

	for (i=0;i<n;i++)
		if (abs(daycount(year[i],month1[i])-daycount(year[i],month2[i]))%7==0)
			printf("YES\n");
		else printf("NO\n");
	return 0;
}
int main()
{
	int i,j,n,a,b,c,p,m,q;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		p=0;
		scanf("%d %d %d",&a,&b,&c);
		m=(b>c)?b:c;
		q=(b<c)?b:c;
        if((a%4==0)&&(a%100!=0)||(a%400==0)){
           if(q<=2&&m>2){
           	  p=p+1; 
           }
		      	
        }
        for(j=q;j<m;j++)
		{
        	if(j==1||j==3||j==5||j==7||j==8||j==10)
	           p+=31;	
	        if(j==2)
	           p+=28;		        
	        if(j==4||j==6||j==9||j==11)
	           p+=30;	           
        }
        if(p%7==0)
        	printf("YES\n");
		if(p%7!=0)
		    printf("NO\n");         		
	}
	
}