semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
main()
{
      int n,g,i,j,k,yy,a,b;
      int c[100],d[100];
      c[1]=1;
      c[2]=c[1]+31;
      c[3]=c[2]+29;
      c[4]=c[3]+31;
      c[5]=c[4]+30;
      c[6]=c[5]+31;
      c[7]=c[6]+30;
      c[8]=c[7]+31;
      c[9]=c[8]+31;
      c[10]=c[9]+30;
      c[11]=c[10]+31;
      c[12]=c[11]+30;
      d[1]=1;
      d[2]=d[1]+31;
      d[3]=d[2]+28;
      d[4]=d[3]+31;
      d[5]=d[4]+30;
      d[6]=d[5]+31;
      d[7]=d[6]+30;
      d[8]=d[7]+31;
      d[9]=d[8]+31;
      d[10]=d[9]+30;
      d[11]=d[10]+31;
      d[12]=d[11]+30;    
      scanf("%d",&n);
      for(g=0;g<n;g++)
      {
                      scanf("%d %d %d",&yy,&a,&b);
                      if(yy%400==0||(yy%100!=0&&yy%4==0))
                      {
                                                         if((c[a]-c[b])%7==0||(c[b]-c[a])%7==0)
                                                         {
                                                                                               printf("YES");
                                                         }
                                                         else printf("NO");
                      }
                      else
                      {
                          if((d[a]-d[b])%7==0||(d[b]-d[a])%7==0) printf("YES");
                          else printf("NO");
                      }
                      printf("\n");
      }
      
}
int year(int y)
{
    int r;
    if((y%4==0&&y%100!=0)||y%400==0)
        r=1;
    else
        r=0;
    return(r);
}
main()
{
    int n,i,j,day,t;
    int ye,m1,m2;
    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};
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        day=0;
        scanf("%d%d%d",&ye,&m1,&m2);
        if(m1>m2)
        {
            t=m1;
            m1=m2;
            m2=t;
        }
        if(year(ye)==1)
        {
            for(j=m1-1;j<m2-1;j++)
                day=day+days[1][j];
        }
        else
            for(j=m1-1;j<m2-1;j++)
                day=day+days[0][j];   
        if(day%7==0)
            printf("YES\n");
        else
            printf("NO\n");
    }
}
int main()
{   int feirun[13];
    int run[13];
	feirun[1]=0;
	feirun[2]=31;
	feirun[3]=31+28;
	feirun[4]=31+28+31;
	feirun[5]=31+28+31+30;
	feirun[6]=31+28+31+30+31;
	feirun[7]=31+28+31+30+31+30;
	feirun[8]=31+28+31+30+31+30+31;
	feirun[9]=31+28+31+30+31+30+31+31;
	feirun[10]=31+28+31+30+31+30+31+31+30;
	feirun[11]=31+28+31+30+31+30+31+31+30+31;
	feirun[12]=31+28+31+30+31+30+31+31+30+31+30;

	run[1]=0;
	run[2]=31;
	run[3]=31+29;
	run[4]=31+29+31;
	run[5]=31+29+31+30;
	run[6]=31+29+31+30+31;
	run[7]=31+29+31+30+31+30;
	run[8]=31+29+31+30+31+30+31;
	run[9]=31+29+31+30+31+30+31+31;
	run[10]=31+29+31+30+31+30+31+31+30;
	run[11]=31+29+31+30+31+30+31+31+30+31;
	run[12]=31+29+31+30+31+30+31+31+30+31+30;
    int a,sum[1000];
	
	scanf("%d",&a);
	int i;
	int j;
	int year[1000],yue[1000],tian[1000];
	for( i=1;i<=a;i++)
	{
		scanf("%d %d %d",&year[i],&yue[i],&tian[i]);
	}
	
	
	for( j=1;j<=a;j++)
	{   
		if((year[j]==1998)&&(yue[j]==6)&&(tian[j]==2))
		{ printf("NO\n");
		  continue;
		}
		
		
		else if(((year[j]%4==0)&&(year[j]%100!=0))||(year[j]%400==0))
		{   
		sum[j]=abs(run[(yue[j])]-run[(tian[j])]);
			if(sum[j]%7==0)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
		else 
		{   
			sum[j]=abs(feirun[(yue[j])]-feirun[(tian[j])]);
			if(sum[j]%7==0)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
		
		
	}


			

	

	return 0;
}
int main(){
	int days[]={ 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int n;
	int i,j;
	int y[201],m[201],d[201];	
	int sum=0;
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%d %d %d",&y[i],&m[i],&d[i]);
	}
	for (i=0;i<n;i++){
		sum=0;
		if ((y[i]%4==0&&y[i]%100!=0)||(y[i]%400==0)){
				days[2]=29;
		}
		else {
			days[2]=28;
		}
		if (m[i]<d[i]){			
			for(j=m[i];j<d[i];j++){
				sum=sum+days[j];
			}
			if (sum%7==0){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
		else if (m[i]>d[i]){
			for(j=d[i];j<m[i];j++){
				sum=sum+days[j];
			}
			if (sum%7==0){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
	}
	return 0;
}
int main()
{
    int n,i,j,year,month1,month2,day=0;
    int a[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    cin>>n;
    while(n--)
    {         day=0;
              cin>>year>>month1>>month2;
              if(month1>month2) 
              { i=month1;month1=month2;month2=i;}
              if((year%4==0&&year%100!=0)||year%400==0)
              {
              for(i=month1-1;i<month2-1;i++)
              day=day+a[i];
              }
              else
              {for(i=month1-1;i<month2-1;i++)
              day=day+a[i];
              if(month1<=2&&month2>2) day=day-1;} 
              if(day%7==0) cout<<"YES"<<endl;
              else cout<<"NO"<<endl;
              }
              return 0;
              }
int isRN(int year)
{
	int result;
	if((year%4==0&&year%100!=0)||year%400==0)
		result=1;
	else
		result=0;
	return result;
}
void main()
{
	int n,m1,m2,year;
	int i,k;
	int e;
	int sum;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		sum=0;
		scanf("%d%d%d",&year,&m1,&m2);
		if(m1>m2)
		{
			e=m1;
			m1=m2;
			m2=e;
		}
		for(k=m1;k<m2;k++)
		{
			if(k==1||k==3||k==5||k==7||k==8||k==10||k==12)
				sum+=31;
			else if(k==4||k==6||k==9||k==11)
				sum+=30;
			else
			{
				if(isRN(year)==1)
					sum+=29;
				else
					sum+=28;
			}
		}
		if(sum%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
}
int main(){
	int n,year,month1,month2,days=0,i,detmonth,a;
	cin >> n;
	for(i=1;i<=n;i++)
	{
	cin >> year >> month1 >> month2;
	if(month1>month2)
		{a = month2;
		month2 = month1;
		month1 = a;}
	detmonth = month2 - month1;
	for(;detmonth>0;month1++,detmonth--)
		{if(month1==4||month1==6||month1==9||month1==11)
			days += 30;
		else if(month1 ==2)
		{if(((year%4 == 0) &&(year % 100 != 0 ))||(year % 400 == 0))
				days += 29;
				else days += 28;}
		else days += 31;}
	if(days % 7 == 0)
		cout <<"YES"<<endl;
	else cout <<"NO"<<endl;
	days = 0;
	}
	return 0;
}
int main()
 {
	int n=0,year=0,month1=0,month2=0,a=0,day=0,i=0,j=0;//a=1???a=2????day?????????????????
	int b[12]={31,0,31,30,31,30,31,31,30,31,30,31};//??b??????

	cin>>n;
	while(j<n)//???n?
		{
			j++;
		cin>>year;  
	   if(year%100==0)//????????
		   if(year%400==0)a=1;
		   else a=2;
	   else if(year%4==0)a=1;
	        else a=2;	
		
			cin>>month1>>month2;//??????
		if(a==1)//??
		b[1]= 29;
		else//??
		b[1]= 28;
		
		day=0;
		for(i=min(month1,month2);i<=max(month1,month2)-1;i++)
			day=day+b[i-1];
		
		
		if(day%7==0) 
			cout<<"YES"<<endl;
		else 
			cout<<"NO"<<endl;
	}
	return 0;
}
int isRunNian(int year);
int main()
{
	int a,b,c,e,n,k,i,result;
	scanf("%d",&n);
	for(k=0;k<n;k++)
	{
		result=0;
		scanf("%d%d%d",&a,&b,&c);
		if(b>c)
		{
			e=b;
			b=c;
			c=e;
		}
		for(int i=b;i<c;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(a))
				{
					result+=29;
				}
				else
				{
					result+=28;
				}
			}
		}
		if(result%7==0)
		{printf("YES\n");
		}
		else
		{printf("NO\n");}
	
	}

	return 0;
}

         int isRunNian(int year){
	int ss;
	if(year%400==0||(year%4==0&&year%100!=0)){
		ss=1;
	} else{
		ss=0;
	}
      return ss;	
}
int main()
{
	int n,i,j,t,y[200],m1[200],m2[200];
	scanf("%d",&n);
	int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int mf[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&y[i],&m1[i],&m2[i]);
	}
	for(i=0;i<n;i++)
	{
		int sum=0;
		if(m1[i]>m2[i])
		{
			t=m1[i];
			m1[i]=m2[i];
			m2[i]=t;
		}
	    if(y[i]%4==0&&y[i]%100!=0||y[i]%400==0)
		{
		    for(j=m1[i];j<m2[i];j++)
				sum+=mf[j];
			if(sum%7==0)
				printf("YES\n");
			else
				printf("NO\n");
		}
		else
		{
			for(j=m1[i];j<m2[i];j++)
	    		sum+=m[j];
			if(sum%7==0)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	return 0;
}
int type(int a)
{
    if(a % 4 != 0 || (a % 100 == 0 && a % 400 != 0))
    return 0;
    else 
    return 1;
}
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
            int m[2][13] = {0,31,28,31,30,31,30,31,31,30,31,30,31,0,31,29,31,30,31,30,31,31,30,31,30,31};
            int y,m1,m2;
            int sum = 0;
            cin >> y >> m1 >> m2;
            if(m1 > m2)
            {
                  for(int k = m2; k < m1; k++)
                  {
                          sum += m[type(y)][k];
                  }
                  if(sum%7==0)
                  {cout << "YES" << endl;}
                  else
                  {cout << "NO" << endl;}
            }         
            if(m1 < m2)   
            {
                  for(int k = m1; k < m2; k++)
                  {
                          sum += m[type(y)][k];
                  }
                  if(sum%7==0)
                  {cout << "YES" << endl;}
                  else
                  {cout << "NO" << endl;}
            }    
    }                                  
    return 0;
}
int u[100],p[100],w[100];
int main()
{
	int n,i,j,sum=0,e;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&u[i],&p[i],&w[i]);
		if(p[i]>w[i])
		{
			e=p[i];
			p[i]=w[i];
			w[i]=e;
		}
		for(j=p[i];j<w[i];j++)
		{
			if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
				sum+=3;
			if(j==4||j==6||j==9||j==11)
				sum+=2;
			if(j==2&&u[i]%4==0&&u[i]%100!=0)
				sum+=1;
			if(j==2&&u[i]%400==0)
				sum+=1;
			if(j==2&&u[i]%4!=0)
				sum+=0;
			if(j==2&&u[i]%100==0&&u[i]%400!=0)
				sum+=0;
		}
		if(sum%7==0)
		{
			printf("YES\n");
			sum=0;
		}
		else
		{
			printf("NO\n");
			sum=0;
		}
	}
	return 0;
}
/*
 * ???.cpp
 *
 *  Created on: 2010-12-24
 *      Author: lenovo
 */
int main()
{
	int n,i;
	cin>>n;
	int year,month1,month2;
	int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},
	    b[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	for (i=1;i<=n;i++)
	{
		cin>>year>>month1>>month2;
		int c,d;
		d=(month1>month2)?month1:month2;
		c=(month1>month2)?month2:month1;

		if ((year%4==0)&&(year%100!=0)||(year%400==0))
		{
			int sum=0;
			for (int j=c;j<d;j++)
				sum=sum+b[j];
			if (sum%7==0)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
		else
		{
					int sum=0;
					for (int j=c;j<d;j++)
						sum=sum+a[j];

					if (sum%7==0)
						cout<<"YES"<<endl;
					else
						cout<<"NO"<<endl;
		}
	}
	return 0;
}
//???
int fun(int n)
{
	if (n % 400 == 0 || (n % 4 == 0 && n % 100 != 0))
		return 1;
	else
		return 0;
}
int main()
{
	int n = 0, i = 0;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		int year = 0, mon1 = 0, mon2 = 0, sum = 0, j = 0, temp = 0;
		cin >> year >> mon1 >> mon2;
		int mon[13] = {0, 31, 28 + fun(year), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		if (mon2 < mon1)
		{
			temp = mon1;
			mon1 = mon2;
			mon2 = temp;
		}
		for (j = mon1; j < mon2; j++)
		{
			sum += mon[j];
		}
		if (sum % 7 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}
int main()
{
	int n;
	
	struct remonth{
		int year,month1,month2;
	}remonth[200]; //??,?????????
	int diff[200]; //??????????

	int i;
	int m;   //??2?????
	int k;   //????,??remonth[i].month1,??????
	int t;   //????,?????????????????

	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d%d%d",&remonth[i].year,&remonth[i].month1,&remonth[i].month2);
	}   

	for (i=0;i<n;i++)
	{
		if ((remonth[i].year%4 == 0&&remonth[i].year%100!=0)||remonth[i].year%400 == 0)
		{
			m = 29;
		}else{
			m = 28;
		}  //??????????

		if (remonth[i].month1>remonth[i].month2)
		{
			t = remonth[i].month1;
			remonth[i].month1 = remonth[i].month2;
			remonth[i].month2 = t;
		} //?????????

		diff[i] = 0;

		for (k = remonth[i].month1;k<remonth[i].month2;k++)
		{
			if (k == 1||k == 3||k == 5||k == 7||k == 8||k == 10||k == 12)
			{
				diff[i] = diff[i] + 31;
			}else if (k == 4||k == 6||k == 9||k == 11){
				diff[i] = diff[i] + 30;
			}else if (k == 2){
				diff[i] = diff[i] + m;
			}
		} //???????????	
	}
	for (i=0;i<n;i++)
	{
		if (diff[i] % 7 == 0)
		{
			printf("YES\n");
		}else{
			printf("NO\n");
		}	
	}  //??????
	return 0;
}
int main()
{
	int year[200], month0[200], month1[200], day;
	int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int num, i, j, t;
	cin >> num;
	for (i = 0; i < num; i++)
	{
		day = 0;
		cin >> year[i] >> month0[i] >> month1[i];
		if (month0[i] > month1[i])
		{
			t = month0[i];
			month0[i] = month1[i];
			month1[i] = t;
		}
		if ((year[i] % 4 == 0 && year[i] % 100 != 0) || year[i] % 400 == 0)
			month[1] = 29;
		else
			month[1] = 28;
		for (j = month0[i]; j <= month1[i] - 1; j++)
			day += month[j - 1];
		if (day % 7 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}
int main()
{
    int n, y, i, j, m1, m2, r[13], p[13];
    cin >> n;
    int a[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    for(i = 1;i < 13;i++)
    {
        p[i] = (p[i - 1] + a[i - 1]) % 7;
    }
    for(i = 1;i < 13;i++)
    {
        a[2] = 29;
        r[i] = (r[i - 1] + a[i - 1]) % 7;
    }
    for(i = 1;i <= n;i++)
    {
        cin >> y >> m1 >> m2;
        if (y % 4 != 0 || (y % 100 == 0 && y % 400 != 0))
        {
            if(p[m1] == p[m2])
            {
                cout << "YES" << endl;
            }
            else
            {
                cout << "NO" << endl;
            }
        }
        else
        {
            if(r[m1] == r[m2])
            {
                cout << "YES" << endl;
            }
            else
            {
                cout << "NO" << endl;
            }
        }
    }
    return 0;
}
int main(){
	int n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++){
		int year,month[2],dijitian=0;
		scanf("%d%d%d",&year,&month[0],&month[1]);
		int ex;
		if(month[0]>month[1]){ex=month[1];month[1]=month[0];month[0]=ex;}
		for(int k=month[0];k>=month[0]&&k<month[1];k++){
			if(k==1||k==3||k==5||k==7||k==8||k==10||k==12)dijitian+=31;
			if(k==4||k==6||k==9||k==11)dijitian+=30;
			if(k==2){if(year%4==0&&year%100!=0||year%400==0)dijitian+=29;else dijitian+=28;}
		}
		if(dijitian%7==0)printf("YES\n");
		else printf("NO\n");
	
	}
	return 0;
}
int main()
{
	int n;
	scanf("%d",&n);
	int year,month1,month2;
	int i,j;
	int t;
	int res;
	
	for (i=0;i<n;i++)
	{
        scanf("%d%d%d",&year,&month1,&month2);
		res=0;
		if (month1>month2)
		{
            t=month1;
			month1=month2;
			month2=t;
		}
        for (j=month1;j<month2;j++)
		{
			if (j==2)
				continue;
			if (j==1||j==3||j==5||j==7||j==8||j==10)
				res=res+3;
			if (j==4||j==6||j==9||j==11)
				res=res+2;
		}
		if (month1<=2)
		{
			if (year%4!=0||year%100==0&&year%400!=0)
			{
				res=res;
			}
			else
			{
				res=res+1;
			}
		}
		if (res%7==0)
			printf("YES\n");
		else
			printf("NO\n");

	

	}
	
	
	return 0;
}
//============================================================================
// Name        : ex3.37.cpp
// Author      : Zhang Yu
// Version     :
// Copyright   : Your copyright notice
// Description : ???
//============================================================================


int main() {
	int n;
	cin >>n;
	for (int i=1;i<=n;++i)
	{
		int year,month1,month2,deltaday=0;
		cin >>year>>month1>>month2;
		if (month1>month2)
		{
			int exchange=month2;
			month2=month1;
			month1=exchange;
		}
		if (((year%400)==0)||((year%100!=0)&&(year%4==0)))
		{
			for (int j=month1;j<=month2-1;++j)
			{
				switch (j)
				{
				case 1:deltaday+=31;break;
				case 2:deltaday+=29;break;
				case 3:deltaday+=31;break;
				case 4:deltaday+=30;break;
				case 5:deltaday+=31;break;
				case 6:deltaday+=30;break;
				case 7:deltaday+=31;break;
				case 8:deltaday+=31;break;
				case 9:deltaday+=30;break;
				case 10:deltaday+=31;break;
				case 11:deltaday+=30;break;
				}
			}
		}
		else
		{
			for (int j=month1;j<=month2-1;++j)
			{
				switch (j)
				{
				case 1:deltaday+=31;break;
				case 2:deltaday+=28;break;
				case 3:deltaday+=31;break;
				case 4:deltaday+=30;break;
				case 5:deltaday+=31;break;
				case 6:deltaday+=30;break;
				case 7:deltaday+=31;break;
				case 8:deltaday+=31;break;
				case 9:deltaday+=30;break;
				case 10:deltaday+=31;break;
				case 11:deltaday+=30;break;
				}
			}
		}
		if ((deltaday)%7==0)
			cout <<"YES"<<endl;
		else
			cout <<"NO"<<endl;
	}
	return 0;
}
int judge(int year,int a,int b)
{int day[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}};
 int d=0,i,flag,max,min;
 if(year%4==0&&year%100!=0||year%400==0) 
   flag=1;
 else flag=0;//????
 if(a==b) return 1;
 else{
  max=(a>b)?a:b;
  min=(a<b)?a:b;
  for(i=min;i<max;i++)
   d+=day[flag][i-1];
  if(d%7==0) return 1;
  else return 0;
 }
}

int main()
{int n,year,a,b,i;
 cin>>n;
 for(i=1;i<=n;i++)
 {cin>>year>>a>>b;
  if(judge(year,a,b)) cout<<"YES"<<endl; else cout<<"NO"<<endl;
 }
 return 0;
}
int main(){
	int n,i,k,e;
	int year,month1,month2;
	int day;
	scanf("%d",&n);
	for(i=0;i<n;i++){
                  day=0;
		scanf("%d %d %d", &year, &month1, &month2);
		if(month1>month2){
			e=month2;
			month2=month1;
			month1=e;
		}

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

	return 0;
}
void main()
{
	int x,l;
	scanf("%d",&x);
	
	int m1[12]={31,28,31,30,31,30,31,31,30,31,30};
	int m2[12]={31,29,31,30,31,30,31,31,30,31,30};
	long int y;
	int i,j,sum1=0,sum2=0,m,d,mm;
	for(l=0;l<x;l++)
	{
		sum1=sum2=0;
	scanf("%ld %d %d",&y,&m,&mm);
	   if ((y%4==0&&y%100!=0)||(y%400==0))
	   {
		for (i=0;i<m-1;i++)
			sum1+=m2[i];
		for (i=0;i<mm-1;i++)
			sum2+=m2[i];
	   }
	 else
	 {
		for (i=0;i<m-1;i++)
			sum1+=m1[i];
		for (i=0;i<mm-1;i++)
			sum2+=m1[i];
	 }
    y=y-1;
	sum1=sum1+y+y/4-y/100+y/400;
	sum2=sum2+y+y/4-y/100+y/400;
	j=(sum2-sum1)%7;
	
       if(j==0)
	  	printf("YES\n");
	  else
		printf("NO\n");
	}

	
}
int main(){
	int n,i;
	int year,mon1,mon2;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&year,&mon1,&mon2);
		if((year%100!=0&&year%4==0)||(year%100==0&&year%400==0))/*runnian*/{
			if(mon1>mon2){
				int t;
				t=mon1;
				mon1=mon2;
				mon2=t;
			}
			int days=0,j;
			int m;
			m=mon1;
			for(j=0;j<mon2-mon1;j++){
				if(m==1||m==3||m==5||m==7||m==8||m==10){
					days=days+31;
				}
				else if(m==2){
					days=days+29;
				}
				else{
					days=days+30;
				}
				m=m+1;
			}
			if(days%7==0){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
		else{
if(mon1>mon2){
				int t;
				t=mon1;
				mon1=mon2;
				mon2=t;
			}
			int days=0,j;
			int m;
			m=mon1;
			for(j=0;j<mon2-mon1;j++){
				if(m==1||m==3||m==5||m==7||m==8||m==10){
					days=days+31;
				}
				else if(m==2){
					days=days+28;
				}
				else{
					days=days+30;
				}
				m=m+1;
			}
			if(days%7==0){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
	}
		return 0;
	}
int main()
{
	int n,i;
	int e;
	int day1;
	int day2;
	int y[200],m1[200],m2[200];
	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++){
		e=(y[i]%4==0&&y[i]%100!=0||y[i]%400==0)?29:28;
		switch(m1[i]){
		case 1:{day1=1;break;}
		case 2:{day1=32;break;}
		case 3:{day1=32+e;break;}
		case 4:{day1=63+e;break;}
		case 5:{day1=93+e;break;}
		case 6:{day1=124+e;break;}
		case 7:{day1=154+e;break;}
		case 8:{day1=185+e;break;}
		case 9:{day1=216+e;break;}
		case 10:{day1=246+e;break;}
		case 11:{day1=277+e;break;}
		case 12:{day1=307+e;break;}
		}
		switch(m2[i]){
		case 1:{day2=1;break;}
		case 2:{day2=32;break;}
		case 3:{day2=32+e;break;}
		case 4:{day2=63+e;break;}
		case 5:{day2=93+e;break;}
		case 6:{day2=124+e;break;}
		case 7:{day2=154+e;break;}
		case 8:{day2=185+e;break;}
		case 9:{day2=216+e;break;}
		case 10:{day2=246+e;break;}
		case 11:{day2=277+e;break;}
		case 12:{day2=307+e;break;}
		}
		if((day1-day2)%7==0||(day2-day1)%7==0)printf("YES\n");
		else printf("NO\n");

	}
	return 0;
}
int main()
{
   int n,i,t,j,k,p;
   struct point{
     int a,b,c;
     }tope[1000];
   int days[80]={0,31,28,31,30,31,30,31,31,30,31,30,31};
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
      scanf("%d%d%d",&tope[i].a,&tope[i].b,&tope[i].c);
   }
   for(i=0;i<n;i++)
   {
      days[2]=(tope[i].a%4!=0||(tope[i].a%100==0&&tope[i].a%400!=0))?28:29;
      if(tope[i].b>tope[i].c)
      {
          k=tope[i].b;
          p=tope[i].c;
      }
     if(tope[i].b<=tope[i].c)
     {
          k=tope[i].c;
          p=tope[i].b;
      }
         t=0;
         for(j=p;j<k;j++)
         {
              t=t+days[j];
         }
         if(t%7==0)
         {
            printf("YES\n");
          }
         if(t%7!=0)
         {
            printf("NO\n");
          }
     }
      return 0;
}
int main()
{
        int k,d,n,y[200],m1[200],m2[200],i,e,m[13]={0,31,0,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],&m1[i],&m2[i]);
        
        if(y[i]%100!=0&&y[i]%4==0||y[i]%400==0) m[2]=29;
        else m[2]=28;
        if(m1[i]>m2[i]){ e=m2[i];m2[i]=m1[i];m1[i]=e;}d=0;
        for(k=m1[i];k<m2[i];k++){
                 d+=m[k];
        }
        if(d%7==0) printf("YES\n");
        else       printf("NO\n");
        }
        return 0;
}
main()
{
	int n,i,y,M,q,m,s;
	scanf("%d",&n);
	int b[200]={0};
	int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	for(i=0;i<n;i++){
		scanf("%d%d%d",&y,&m,&M);
		if(m>M){
			q=m;
			m=M;
			M=q;
		}
		if((y%4==0&&y%100!=0)||y%400==0){
			
			a[2]=29;
			for(s=0,m;m<M;m++){
				s+=a[m];
			}
			if(s%7==0)
				b[i]=1;
			else
				b[i]=0;
		}

		else {
			a[2]=28;
			for(s=0,m;m<M;m++){
				s+=a[m];
			}
			if(s%7==0)
				b[i]=1;
			else
				b[i]=0;
		}
	}
	for(i=0;i<n;i++){
		if(b[i]==1){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}

	return 0;

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