semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int max(int x,int y)
{
	int z;
	if(x>y)z=x;
	else z=y;
	return(z);
}

int min(int x,int y)
{
	int z;
	if(x<y)z=x;
	else z=y;
	return(z);
}

int main()
{
	int n,i,x,y,z,j,m,b[200];
	cin>>n;
	for(i=1;i<=n;i++)
	{
		m=0;
		cin>>x>>y>>z;
		if((x%100==0&&x%400==0)||(x%100!=0&&x%4==0))
		{
			int a[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
			for(j=min(y,z);j<max(y,z);j++)m+=a[j];
			b[i]=m;
		}
		else if((x%100==0&&x%400!=0)||(x%4!=0))
		{
			int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
			for(j=min(y,z);j<max(y,z);j++)m+=a[j];
			b[i]=m;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(b[i]%7==0)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}
int main()
{
	int n, i, a;
	int year, month1, month2;
	int day = 0;

	scanf("%d",&n);
	for (i = 0; i < n; i++){
		day=0;
		scanf("%d%d%d",&year,&month1,&month2);
		if (month1 > month2){
			a = month1;
			month1 = month2;
			month2 = a;
		}

		for (;;){
			if (month1 == month2){
				break;
			}
			
			if(month1 == 1 || month1 == 3 || month1 == 5 || month1 == 7 || month1 == 8 || month1 == 10 || month1 == 12){
				day = day + 31;
				month1++;
				continue;
			}
			if (month1 == 4 || month1 == 6 || month1 == 9 || month1 == 11){
				day = day + 30;
				month1++;
				continue;
			}
			if (month1 == 2){
				if ((year % 4 == 0 && year % 100 != 0) || year % 400 ==0){
					day = day + 29;
					month1++;
					continue;
				}
				else {
					day = day + 28;
					month1++;
					continue;
				}
			}
		}
		if(day % 7 == 0){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}
int main()
{
	int n,i;
	scanf("%d",&n);
	int y,a,b;
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&y,&a,&b);
		if(y%400==0||(y%4==0&&y%100!=0))
		{
			if(a==12&&b==9||a==8&&b==2||a==7&&b==4||a==7&&b==1||a==4&&b==1||a==11&&b==3||b==12&&a==9||b==8&&a==2||b==7&&a==4||b==7&&a==1||b==4&&a==1||b==11&&a==3)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
		else
		{
			if(a==12&&b==9||a==10&&b==1||a==7&&b==4||a==11&&b==2||a==11&&b==3||a==3&&b==2||b==12&&a==9||b==10&&a==1||b==7&&a==4||b==11&&a==2||b==11&&a==3||b==3&&a==2)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
	}
	return 0;
}
int main(int argc, char *argv[])
{
    int n,year[200],month1[200],month2[200],t,i,j,sum=0;
    int a[12];
    a[1]=31;
    a[3]=31;
    a[5]=31;
    a[7]=31;
    a[8]=31;
    a[10]=31;
    a[12]=31;
    a[4]=30;
    a[6]=30;
    a[9]=30;
    a[11]=30;
    scanf("%d",&n);
    for(j=1;j<=n;j++)
       scanf("%d%d%d",&year[j],&month1[j],&month2[j]);
   for(j=1;j<=n;j++){ 
       sum=0;
       t=0;
       if((year[j]%4==0&&year[j]%100!=0)||year[j]%400==0)
         a[2]=29;
       else
         a[2]=28;
       if(month1[j]>month2[j]){
         t=month1[j];
         month1[j]=month2[j];
         month2[j]=t;
       }             
       for(i=month1[j];i<month2[j];i++){
          scanf("%d",&a[i]);
          sum+=a[i];
       }
       if(sum%7==0)
          printf("YES\n");
       else
          printf("NO\n");    
    }
   return 0;
}
int main()
{
	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};          
	int y,m1,m2,n,day,i,j,max;                                //????????y???m1?m2???n?????day???????i?j?????max
	scanf("%d",&n);                                           //????n
	for(i=1;i<=n;i++)                                         //??n?
	{
		day=0;
		scanf("%d%d%d",&y,&m1,&m2);                           //??????
		if((y%4==0&&y%100!=0)||(y%400==0))                    //?????
		{
			if(m1<m2)                                         //???????
			{
				j=m1;
				max=m2;
			}
			else 
			{
				j=m2;
				max=m1;
			}
			for(;j<max;j++)                                   //??????
				day+=b[j-1];
		}
		else                                                  //?????
		{
			if(m1<m2)                                         //???????
			{
				j=m1;
				max=m2;
			}
			else 
			{
				j=m2;
				max=m1;
			}
			for(;j<max;j++)                                   //??????
				day+=a[j-1];
		}
		if(day%7==0)                                         //????????                                      
			printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
int main()
{
	int rnfeb(int year);
	int n,year,month1,month2,e,i,j,day,num=0;
	scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d %d",&year,&month1,&month2);
			if(month1<month2){
				e=month1;
				month1=month2;
				month2=e;
			}
			num=0;
			for(j=month2;j<month1;j++){
				if(j==1||j==3||j==5||j==7||j==8||j==10||j==12){
					day=31;
				}
				else if(j==4||j==6||j==9||j==11){
					day=30;
				}
				else if(j==2){
					day=rnfeb(year);
				}
				num+=day;
			}
			if(num%7==0){
				printf("YES\n");
			}else{
				printf("NO\n");
			}
		}
	return 0;
}
int rnfeb(int year){
	int z;
	if((year%4==0&&year%100!=0)||(year%400==0)){
		z=29;
	}else{
		z=28;
	}
	return (z);
}
int main()
{
	int n,i,m,j,x,y;
	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);
	for (i=0;i<n;i++)
	{
		scanf ("%d",&a[i]);
		scanf ("%d",&b[i]);
		scanf ("%d",&c[i]);
	}
	for (i=0;i<n;i++)
	{
		m=0;
		if ((a[i]%4==0)&&(a[i]%100!=0)||(a[i]%400==0))
		{
			if (b[i]>=c[i])
			{
				x=c[i];
				y=b[i];
			}
			else
			{
				y=c[i];
				x=b[i];
			}
			for (j=x;j<y;j++)
			{
				m=m+e[j-1];
			}
			if (m%7==0)
			{
				printf ("YES\n");
			}
			else
			{
				printf ("NO\n");
			}
		}
		else
		{
			if (b[i]>=c[i])
			{
				x=c[i];
				y=b[i];
			}
			else
			{
				y=c[i];
				x=b[i];
			}
			for (j=x;j<y;j++)
			{
				m=m+d[j-1];
			}
			if (m%7==0)
			{
				printf ("YES\n");
			}
			else
			{
				printf ("NO\n");
			}
		}
	}
	return 0;
}
int main()
{	
int i,j,y,n,m1,m2;
int e1[12]={31,29,31,30,31,30,31,31,30,31,30,31},e2[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int f1[12]={0,0,0,0,0,0,0,0,0,0,0,0},f2[12]={0,0,0,0,0,0,0,0,0,0,0,0};
for(i=0;i<12;i++){
	for(j=0;j<i;j++){
			f1[i]+=e1[j];
			f2[i]+=e2[j];
	}
}
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&y,&m1,&m2);
		if(y%400==0||(y%4==0&&y%100!=0)){
			int t1=(f1[m1-1]-f1[m2-1]>=0)?(f1[m1-1]-f1[m2-1]):(f1[m2-1]-f1[m1-1]);
			if(t1%7==0) printf("YES\n");
			else printf("NO\n");
		}
		else{
			int t2=(f2[m1-1]-f2[m2-1]>=0)?(f2[m1-1]-f2[m2-1]):(f2[m2-1]-f2[m1-1]);
			if(t2%7==0) printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;
	}
int main()
{
	int y, a, b, p, m, s;
	int i, t;
	int l, k;
	cin >> k;
	for (l=1;l<=k;l++)
	{
		cin >> y >> a >> b;
		if(a < b)
		{
			p = a;
			a = b;
			b = p;
		}
		m = 0;
		i = 0;
		t = a - b;
		s = b - 1;
		do
		{
			s = s + 1;
			if(s==1)
				m = m + 31;
			if(s==2)
			{
				if (y % 100!=0)
				{
					if(y % 4!=0)
						m = m + 28;
					else
						m = m + 29;
				}
				else
				{
					if(y % 400!=0)
						m = m + 28;
					else
						m = m + 29;
				}
			}
			if(s==3)
				m = m + 31;
			if(s==4)
				m = m + 30;
			if(s==5)
				m = m + 31;
			if(s==6)
				m = m + 30;
			if(s==7)
				m = m + 31;
			if(s==8)
				m = m + 31;
			if(s==9)
				m = m + 30;
			if(s==10)
				m = m + 31;
			if(s==11)
				m = m + 30;
			if(s==12)
				m = m + 31;
			i = i + 1;
		}while (i < t);
		if (m % 7 !=0)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
	}
	return 0;
}
/*
 * 1000012889_3.cpp
 *
 *  Created on: 2010-12-24
 *      Author: ???
 *        ??? ???
 */



int main(){
	int n,i,j,year,month1,month2,day1=0,day2=0;
	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};       //????????
	cin>>n;
	for(i=0;i<n;i++,day1=0,day2=0){
		cin>>year>>month1>>month2;
		if(year%4!=0||(year%400!=0&&year%100==0)){           //????
			for(j=1;j<month1;j++)                            //?????????
				day1+=a[j];
			for(j=1;j<month2;j++)                            //?????????
				day2+=a[j];
		}
		else{                                                //????
			for(j=1;j<month1;j++)                            //?????????
				day1+=b[j];
			for(j=1;j<month2;j++)                            //?????????
				day2+=b[j];
		}
		if((day1-day2)%7==0)                                 //????????
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}
//???
int main()
{
	int n,year,m1,m2,i,j,days;
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};//????a[12]???12?????
	cin>>n;
	for (i=1;i<=n;i++)
		{cin>>year>>m1>>m2;//?????????
		a[1]=28;
		days=0;
		if (year%4==0&&year%100!=0||year%400==0) a[1]=29;//??????????????2????
		if (m1<m2) 
			{for (j=m1-1;j<=m2-2;j++) days=days+a[j];//??????1??????
			}
		else 
			{for (j=m2-1;j<=m1-2;j++) days=days+a[j];
			}
		if (days%7==0) cout<<"YES"<<endl;//???????
		else cout<<"NO"<<endl;
		}
	return 0;
}
//****************************************************
//*  ? ? ?: homework.cpp                          *
//*  ?    ?: ???                                *
//*  ????: 2012?10?22?                        *
//*  ????: ???                                *
//****************************************************

int main()
{
	int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; //??????(???) 
	int c[13]={0,31,29,31,30,31,30,31,31,30,31,30,31}; //??????(??) 
	int i, j, n, l, sd1, sd2, y, m1, m2;
	int b[2][145]; //???????,b[0]????,b[1]??? 
	for (i = 1; i <= 144; i++)
	{
		b[0][i] = 0;
		b[1][i] = 0;
	} //??? 
	for (i = 1; i <= 11; i++)
	{
		j = i;
		sd1 = 0;
		sd2 = 0;
		while (j < 12)
		{
			sd1 = sd1 + a[j];
			sd2 = sd2 + c[j];
			j++;
			b[0][(i - 1) * 12 + j] = b[0][(j - 1) * 12 + i] = (sd1 % 7 == 0); 
			b[1][(i - 1) * 12 + j] = b[1][(j - 1) * 12 + i] = (sd2 % 7 == 0); 
			//?????????????? 
			 
		}
	}
	
	cin >> n; 
	while (n--)
	{ 
		cin >> y >> m1 >> m2;
		l = (y % 400 == 0) || ((y % 4 ==0) && (y % 100 !=0)); //??????
		if (b[l][(m1 - 1) * 12 + m2]) cout << "YES" << endl;
			else cout << "NO" << endl; 	//??????? 
	}
	
	return 0;
}
int main()
{
	int max, min, k, day = 0, n, y, m1, m2, i, month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 
	cin >> n;
	while (n != 0)
	{
		day = 0;
		cin >> y >> m1 >> m2;
		if (y % 400 == 0 || (y % 100 != 0 && y % 4 == 0))
			month[2] = 29;
		else
			month[2] = 28;
		max = m1 > m2 ? m1 : m2;
		min = m1 < m2 ? m1 : m2;
		for(i = min; i < max; i++)
			day += month[i];
	if(day % 7 == 0)
		cout << "YES"<<endl;
	else
		cout << "NO"<<endl;	
		n--;
	}

	

	return 0;
}
int main(int argc, char* argv[])
{
	int days[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
	int n,y,m1,m2,i,c1,c2,j,k,cha;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		days[2]=28;
		scanf("%d %d %d",&y,&m1,&m2);
		
		if((y%4==0)&&(y%100!=0)||(y%400==0))
		{days[2]++;}
		
		c1=0;c2=0;
		
		for(j=1;j<m1;j++){
			c1=c1+days[j];}

		for(k=1;k<m2;k++){
			c2=c2+days[k];}
		
		cha=c1-c2;
		if(cha%7==0)
		printf("YES\n");
		else
		printf("NO\n");	
	}	
	return 0;
}
int main() 
{
	int n,rem,mon1,mon2,i,k,year,mon,sum,j;//???? 
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};//??????? 
	int b[200];//??????? 
	cin>>n;  //?????? 
	for(i=0;i<n;i++)//????????? 
	{
			sum=0;//sum?? 
		cin>>year>>mon1>>mon2;//??????? 
		if(mon2<mon1)//??????????????????????????? 
		{
			mon=mon2;
			mon2=mon1;
			mon1=mon;
		}
		if(year%400==0)//?????? 
		{a[1]=29;}
		else if((year%4==0)&&(year%100!=0))
		{a[1]=29;}
		else
		{a[1]=28;} 
		if(mon1==mon2)
		{b[i]=1;}
		for(j=mon1;j<mon2;j++) //?????????? 
		{
			sum=sum+a[j-1];
		}
		rem=sum%7; // ?????? 
		if(rem==0)//??????????????????? 
		{
		 b[i]=1;
		}
		else
		{b[i]=0;
		}
	}
	for(k=0;k<n;k++)//??????? 
	{
		if(b[k]==1)
		{
		cout<<"YES"<<endl;}
		else if(b[k]==0)
 	   {
		cout<<"NO"<<endl;}
  }
	return 0;//???? 
}
int main()
{
	int n,i,k,e,month[200],y[200],m[200],a,d[200],day[12]={31,28,31,30,31,30,31,31,30,31,30,31},
		dayy[12]={31,29,31,30,31,30,31,31,30,31,30,31},sum[200];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		sum[i]=0;
		scanf("%d%d%d",&y[i],&month[i],&m[i]);
		if(month[i]>m[i]){
		e=month[i];
		month[i]=m[i];
		m[i]=e;
		}
        if(y[i]%400==0||(y[i]%100!=0&&y[i]%4==0))
		{
		for(k=month[i]-1;k<m[i]-1;k++)
		{
			sum[i]+=dayy[k];
		}
		}
		else{
			for(k=month[i]-1;k<m[i]-1;k++)
			{
				sum[i]+=day[k];
			}
	}}
	for(i=0;i<n;i++)
	{
		if(sum[i]%7==0)
		{
			printf("YES\n");
		}
		else{printf("NO\n");}
	}
	return 0;
}
int Run(int year)
{
	if(year%400==0||(year%100!=0&&year%4==0))
	{
		return 1;
	}
	else{
		return 0;
	}
}
int Day(int year,int month1,int month2,int j,int day)
{
	if(month1>month2)
	{
		day=month1;
		month1=month2;
		month2=day;
	}
	day=0;
	for(j=month1;j<month2;j++)
	{
		if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
		{
			day+=31;
		}else if((j==4||j==6||j==9||j==11)){
			day+=30;
		}else{
			if(Run(year)==0)
			{
				day+=28;	
			}else{
				day+=29;
			}
		}
	}
	return day;
}

int main(int argc, char* argv[])
{

	int i,j=1,n,year,month1,month2,day;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&year,&month1,&month2);
		day=Day(year,month1,month2,j,day);
		if(day%7==0)
		{
			printf("YES\n");
		}else{
			printf("NO\n");		
		}
	}
	return 0;
}
int main()
{
	int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int y,m1,m2,n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int sum=0;
		scanf("%d%d%d",&y,&m1,&m2);
		if((y%100!=0&&y%4==0)||(y%400==0))
		{
			m[2]=29;
			if(m1<m2)
			{
				for(j=m1;j<m2;j++)
				{
					sum=sum+m[j];
				}
				if(sum%7==0)
				{
					printf("YES\n");
				}
				else if(sum%7!=0)
				{
					printf("NO\n");
				}
			}
			else if(m1>m2)
			{
				for(j=m2;j<m1;j++)
				{
					sum=sum+m[j];
				}
				if(sum%7==0)
				{
					printf("YES\n");
				}
				else if(sum%7!=0)
				{
					printf("NO\n");
				}
			}
			else if(m1==m2)
			{
				printf("YES");
			}
		}
		else 
		{
			m[2]=28;
			if(m1<m2)
			{
				for(j=m1;j<m2;j++)
				{
					sum=sum+m[j];
				}
				if(sum%7==0)
				{
					printf("YES\n");
				}
				else if(sum%7!=0)
				{
					printf("NO\n");
				}
			}
			else if(m1>m2)
			{
				for(j=m2;j<m1;j++)
				{
					sum=sum+m[j];
				}
				if(sum%7==0)
				{
					printf("YES\n");
				}
				else if(sum%7!=0)
				{
					printf("NO\n");
				}
			}
			else if(m1==m2)
			{
				printf("YES");
			}
		}
	}
	return 0;
}
int main()
{
	int n;
	cin>>n;
	while ( n -- )
	{
		int y,m1,m2;
		cin>>y>>m1>>m2;
		if ( y % 4 != 0 || ( y % 4 == 0 && y % 100 == 0 && y % 400 != 0 ))
		{
	         int zz[12]={0,31,59,90,120,151,181,212,243,273,304,334};
			 if ( ( zz[m1-1] - zz[m2-1] ) % 7 == 0)
				 cout<<"YES"<<endl;
			 else cout<<"NO"<<endl;
		}
		else
		{
			int zz[12]={0,31,60,91,121,152,182,213,244,274,305,335};
			 if ( ( zz[m1-1] - zz[m2-1] ) % 7 == 0)
				 cout<<"YES"<<endl;
			 else cout<<"NO"<<endl;
		}
	}
}
int main()
{
	int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},n,i,a,b,c,d,e,j,x=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a>>b>>c;
m[2]=28;
		if((a%4==0&&a%100!=0)||a%400==0)
		 m[2]=29;
		
		d=(b<c)?b:c;
		e=(b>c)?b:c;
		x=0;
		for(j=d;j<e;j++)
		x=x+m[j];
		
		if(x%7==0) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}
int main()
{
    int a[13],n;//n:?????????
    cin>>n;
    int year[n+1],month1[n+1],month2[n+1];
    for(int i=1;i<=n;i++)
    {
            cin>>year[i]>>month1[i]>>month2[i];
    }
    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 i=1;
    int k,s1,s2,sum=0;
    for(i=1;i<=n;i++)
    {
                     if(year[i]%4==0&&year[i]%100!=0||year[i]%400==0)
                     a[2]=29;
                     else
                     a[2]=28;
                     if(month1[i]>month2[i])
                     s1=month1[i],s2=month2[i];
                     else
                     s1=month2[i],s2=month1[i];
                     for(k=s2;k<=(s1-1);k++)
                     sum=sum+a[k];
                     if(sum%7==0)
                     cout<<"YES"<<endl;
                     else
                     cout<<"NO"<<endl;
                     sum=0;
    }
    return 0;
}
int isrunnian(int year){
	int result;
	if(year%400==0||(year%4==0&&year%100!=0)){
		result=1;
	}
	else{
		result=0;
	}
	return result;
}
int dijitian(int year,int month,int day){
	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;
			}
		}
	}
	result+=day;
	return result;
}
int main(){
	int n,i;
	int year,month1,month2,a,b,day=1;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%d ",&year);
		scanf("%d ",&month1);
		scanf("%d\n",&month2);
		a=dijitian(year,month1,day);
		b=dijitian(year,month2,day);
		if((b-a)%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}
int main()
{
	int n;
	int i;
	int a[500],b[500],c[500];
	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]==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)
				||(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))
				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;
}
/*
 * Author : houchenglong
 * 2014.1.5
 *
 */
int main()
{
	int n,year,month1,month2,sum=0,i,j;
	int Mon[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>year>>month1>>month2;
		if(year%400==0||(year%100!=0&&year%4==0))
		{
			Mon[1]=Mon[1]+1;
			if(month1>month2)
			{
				for(j=month2;j<month1;j++)
					sum=sum+Mon[j-1];
				if(sum%7==0)
					cout<<"YES"<<endl;
				else
					cout<<"NO"<<endl;
			}
			else
			{
				for(j=month1;j<month2;j++)
					sum=sum+Mon[j-1];
				if(sum%7==0)
					cout<<"YES"<<endl;
				else
					cout<<"NO"<<endl;
			}
		}
		else
		{
			if(month1>month2)
			{
				for(j=month2;j<month1;j++)
					sum=sum+Mon[j-1];
				if(sum%7==0)
					cout<<"YES"<<endl;
				else
					cout<<"NO"<<endl;
			}
			else
			{
				for(j=month1;j<month2;j++)
					sum=sum+Mon[j-1];
				if(sum%7==0)
					cout<<"YES"<<endl;
				else
					cout<<"NO"<<endl;
			}
		}
		sum=0;
		Mon[1]=28;
	}
	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

 ????
 NO
 NO
 NO
 YES
 YES*/
int main() {
	int i, j, n, a[200][3], b[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31,
			30, 31 },
			c[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, x, y, z;
	cin >> n;
	for (i = 0; i < n; i++) {
		for (j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	for (i = 0; i < n; i++) {
		if ((a[i][0] % 4 == 0 && a[i][0] % 100 != 0) || a[i][0] % 400 == 0) {
			if (a[i][1] > a[i][2]) {
				x = a[i][1];
				y = a[i][2];
			} else {
				x = a[i][2];
				y = a[i][1];
			}
			z = 0;
			for (j = (y - 1); j < (x - 1); j++) {
				z = z + c[j];
			}
			if (z % 7 == 0) {
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
			}
		} else {
			if (a[i][1] > a[i][2]) {
				x = a[i][1];
				y = a[i][2];
			} else {
				x = a[i][2];
				y = a[i][1];
			}
			z = 0;
			for (j = (y - 1); j < (x - 1); j++) {
				z = z + b[j];
			}
			if (z % 7 == 0) {
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
			}
		}
	}
	return 0;
}
int main(){
	int n,i,flag[300],r[300];
	int year[300],m1[300],m2[300];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&year[i],&m1[i],&m2[i]);
		if(year[i]%4==0&&year[i]%100!=0||year[i]%400==0)
			flag[i]=1;
		else flag[i]=0;
		if(m1[i]==1)
			m1[i]=1;
		if(m1[i]==2)
			m1[i]=32;
		if(m1[i]==3)
			m1[i]=60;
		if(m1[i]==4)
			m1[i]=91;
		if(m1[i]==5)
			m1[i]=121;
		if(m1[i]==6)
			m1[i]=152;
		if(m1[i]==7)
			m1[i]=182;
		if(m1[i]==8)
			m1[i]=213;
		if(m1[i]==9)
			m1[i]=244;
		if(m1[i]==10)
			m1[i]=274;
		if(m1[i]==11)
			m1[i]=305;
		if(m1[i]==12)
			m1[i]=335;
		if(m2[i]==1)
			m2[i]=1;
		if(m2[i]==2)
			m2[i]=32;
		if(m2[i]==3)
			m2[i]=60;
		if(m2[i]==4)
			m2[i]=91;
		if(m2[i]==5)
			m2[i]=121;
		if(m2[i]==6)
			m2[i]=152;
		if(m2[i]==7)
			m2[i]=182;
		if(m2[i]==8)
			m2[i]=213;
		if(m2[i]==9)
			m2[i]=244;
		if(m2[i]==10)
			m2[i]=274;
		if(m2[i]==11)
			m2[i]=305;
		if(m2[i]==12)
			m2[i]=335;
	}
	for(i=0;i<n;i++){
		if(flag[i]==1){
			if(m1[i]>32)
				m1[i]++;
			if(m2[i]>32)
				m2[i]++;
		}
		if(m1[i]>m2[i]){
		    r[i]=m1[i]-m2[i];
		}
		else
			r[i]=m2[i]-m1[i];
		if(r[i]%7==0)
			  printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
int main()
{
    int n, e, i, j, y, m1, m2, rlt;
    scanf("%d", &n);
    for(i=0;i<n;i++)
    {
        int d1=0, d2=0;
        scanf("%d %d %d", &y, &m1, &m2);
        
        if(m1<m2)
        {
            e=m1;
            m1=m2;
            m2=e;
        }
        
        if(m1>1)
        {
            for(j=1;j<m1;j++)
            {
                if(j==4||j==6||j==9||j==11)
                    d1+=30;
                else if(j==2)
                {
                    if((y%4==0&&y%100!=0)||y%400==0)
                    {
                        d1+=29;
                    }else{
                        d1+=28;
                    }
                }else{
                    d1+=31;
                }
            }
        }
        
        if(m2>1)
        {
            for(j=1;j<m2;j++)
            {
                if(j==4||j==6||j==9||j==11)
                {
                    d2+=30;
                }else if(j==2){
                    if((y%4==0&&y%100!=0)||y%400==0)
                    {
                        d2+=29;
                    }else{
                        d2+=28;
                    }
                }else{
                    d2+=31;
                }
            }
        }
        
        rlt=(d1-d2)%7;
        if(rlt==0)
        {
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }

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

}