semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main() {
	int a[12];
	a[1]=31;
	a[2]=28;
	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 n;
	cin>>n;
	int b[n];
	int p1=0;
	int p2=0;
	int p3=0;
	int a1,a2,t;
	int sum=0;
	int p4=0;
	for(int i=1;i<=n;i=i+1)
	{
		cin>>b[i];
		p1=b[i]%4;
		p2=b[i]%100;
		p3=b[i]%400;
		if(p3==0)
			a[2]=29;
		else
		{
			if((p2!=0)&&(p1==0))
				a[2]=29;
		}
		cin>>a1>>a2;
		if(a1>a2)
		{
			t=a1;
			a1=a2;
			a2=t;
		}
		for(int j=a1;j<a2;j++)
			sum=sum+a[j];
		p4=sum%7;
		if(p4==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		sum=0;
		a[2]=28;
	}
	return 0;
}
int main()
{
	int n,sum=0,a,b,c,A[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int sum=0;
		cin>>a>>b>>c;
		if(b>c)
		{A[0]=b;
		b=c;
		c=A[0];
		}
		if(a%4==0&&a%100!=0||a%400==0)
		{
			A[2]=A[2]+1;
			for(int j=b;j<c;j++)
			{
				sum+=A[j];
			}
			//cout<<sum<<" "<<b<<" "<<c;
			if(sum%7==0)
			{	cout<<"YES";}
			else
			{	cout<<"NO";}
			A[2]--;
		}
		else
		{
			for(int j=b;j<c;j++)
			{
				sum+=A[j];
			}
			if(sum%7==0)
				cout<<"YES";
			else
				cout<<"NO";
		}
		
cout<<endl;
	}
	return 0;
}
int main()
{
	int n,k=0;
	int y,m1,m2;
	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};
		cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>y>>m1>>m2;
		k=0;
		if(y%4!=0||(y%100==0&&y%400!=0))
		{
			if(m1>m2)
			{
				for(int j=m2;j<m1;j++)
					k+=a[j-1];
			}
			else
				for(int j=m1;j<m2;j++)
					k+=a[j-1];
		}
		else
		{
			if(m1>m2)
			{
				for(int j=m2;j<m1;j++)
					k+=b[j-1];
			}
			else
				for(int j=m1;j<m2;j++)
					k+=b[j-1];
		}
		if(k%7==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}
int main()
{
    int d[12];
    d[0]=0;
    d[1]=31;
    d[2]=28;
    d[3]=31;
    d[4]=30;
    d[5]=31;
    d[6]=30;
    d[7]=31;
    d[8]=31;
    d[9]=30;
    d[10]=31;
    d[11]=30;
    int n,i,y,m1,m2,j1,j2,day1,day2;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        day1=0;
        day2=0;
        scanf("%d %d %d",&y,&m1,&m2);
        if((y%400==0)||((y%100!=0)&&(y%4==0)))
        {
            d[2]=29;
            for(j1=0;j1<m1;j1++)
            day1=day1+d[j1];
            for(j2=0;j2<m2;j2++)
            day2=day2+d[j2];
            if(day2>day1)
            {
                day2=day2+day1;
                day1=day2-day1;
                day2=day2-day1;
            }
            if((day1-day2)%7==0)
            {
                printf("YES");
                if(i!=n-1)
                printf("\n");
            }
            else
            {
                printf("NO");
                if(i!=n-1)
                printf("\n");
            }
        }
        else
        {
            d[2]=28;
            for(j1=0;j1<m1;j1++)
            day1=day1+d[j1];
            for(j2=0;j2<m2;j2++)
            day2=day2+d[j2];
            if(day2>day1)
            {
                day2=day2+day1;
                day1=day2-day1;
                day2=day2-day1;
            }
            if((day1-day2)%7==0)
            {
                printf("YES");
                if(i!=n-1)
                printf("\n");
            }
            else
            {
                printf("NO");
                if(i!=n-1)
                printf("\n");
            }
        }
    }
}
int main()
{
	int n;
	cin>>n;	
	int judge=0;
	int dayofmonth[13]={31,28,31,30,31,30,31,31,30,31,30,31};
  int year,month1,month2;
for(int inputtime=1;inputtime<=n;inputtime++)
{judge=0;
  cin>>year>>month1>>month2;
  dayofmonth[1]=28;
  if(year%4==0&&year%100!=0||year%400==0)
	  dayofmonth[1]=29;
 for(int i=min(month1,month2)-1;i<max(month1,month2)-1;i++)
	 judge+=dayofmonth[i];
 
 if(judge%7==0)
	 cout<<"YES"<<endl;
 else
	 cout<<"NO"<<endl;
}
 
  return 0;
}
int mo1=31,mo2=28,mo3=31,mo4=30,mo5=31,mo6=30,mo7=31,mo8=31,mo9=30,mo10=31,mo11=30,mo12=31;
int f(int x)
{
    if(x==1) return 0;
    if(x==2) return (mo1);
    if(x==3) return (mo1+mo2);
    if(x==4) return (mo1+mo2+mo3);
    if(x==5) return (mo1+mo2+mo3+mo4);
    if(x==6) return (mo1+mo2+mo3+mo4+mo5);
    if(x==7) return (mo1+mo2+mo3+mo4+mo5+mo6);
    if(x==8) return (mo1+mo2+mo3+mo4+mo5+mo6+mo7);
    if(x==9) return (mo1+mo2+mo3+mo4+mo5+mo6+mo7+mo8);
    if(x==10) return (mo1+mo2+mo3+mo4+mo5+mo6+mo7+mo8+mo9);
    if(x==11) return (mo1+mo2+mo3+mo4+mo5+mo6+mo7+mo8+mo9+mo10);
    if(x==12) return  (mo1+mo2+mo3+mo4+mo5+mo6+mo7+mo8+mo9+mo10+mo11);
}
int main()
{
    int n,m;
    scanf("%d",&n);
    int y,m1,m2;
    while(n--)
    {
    scanf("%d %d %d",&y,&m1,&m2);
    mo2=28;
    if (y%400==0||(y%4==0)&&(y%100!=0))
    mo2=29;
    if(m1>m2)
    m=f(m1)-f(m2);
    else m=f(m2)-f(m1);
    if(m%7==0)
    printf("YES\n");
    else printf("NO\n");
    }
}
void main()
{int y,a,b,i,j,n,days,day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  scanf("%d",&n);
  for (i=1;i<=n;i++)
  {days=0;
  scanf("%d",&y);
   if ((y%400==0)||(y%4==0&&y%100!=0))
	   day[2]=29;
   else day[2]=28;
   scanf("%d%d",&a,&b);
   if (a<b)
   {for (j=a;j<b;j++)
        days=days+day[j];
    if (days%7==0)
        printf("YES\n");
	else printf("NO\n");
   }
   if (a>b)
   {for (j=b;j<a;j++)
        days=days+day[j];
    if (days%7==0)
        printf("YES\n");
	else printf("NO\n");
  }
 }
 }
int main()
{
	int n, year[200], a[200], b[200], e;
	int i, j, k;
	int x = 1;
	int y = 1;
	int day[12] = {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", &year[i], &a[i], &b[i]);
	}
	for(i = 0; i < n; i++){
                  x = 1;
		y = 1;
		day[1] = 28;
		if(((year[i] % 4 == 0) && (year[i] % 100 != 0)) || ( year[i] % 400 == 0)){
			day[1] = 29;
		}
		for(j = 1; j < a[i]; j++){
			 x = x + day[j-1];
	    }
		for(k =1; k < b[i]; k++){
			y = y + day[ k-1];
		}	
		e = (x - y) % 7;
		if(e == 0){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}	
	return 0;
}
void main()
{
   int n,i;
   int a,b,c,x,y,m;
   scanf("%d",&n);
   for(i=1;i<=n;i++)
   {
	   scanf("%d %d %d",&a,&b,&c);
	   if((a%4==0&&a%100!=0)||a%400==0)
       {
		   if(b==1) x=0;
		   else if(b==2) x=31;
		   else if(b==3) x=60;
		   else if(b==4) x=91;
		   else if(b==5) x=121;
		   else if(b==6) x=152;
		   else if(b==7) x=182;
		   else if(b==8) x=213;
		   else if(b==9) x=244;
		   else if(b==10) x=274;
		   else if(b==11) x=305;
		   else x=335;
		   if(c==1) y=0;
		   else if(c==2) y=31;
		   else if(c==3) y=60;
		   else if(c==4) y=91;
		   else if(c==5) y=121;
		   else if(c==6) y=152;
		   else if(c==7) y=182;
		   else if(c==8) y=213;
		   else if(c==9) y=244;
		   else if(c==10) y=274;
		   else if(c==11) y=305;
		   else y=335;
		   if(x<=y) m=y-x;
		   else m=x-y;
		   if(m%7==0) printf("YES\n");
		   else printf("NO\n");
	   }
	   else
	   {
           if(b==1) x=0;
		   else if(b==2) x=31;
		   else if(b==3) x=59;
		   else if(b==4) x=90;
		   else if(b==5) x=120;
		   else if(b==6) x=151;
		   else if(b==7) x=181;
		   else if(b==8) x=212;
		   else if(b==9) x=243;
		   else if(b==10) x=273;
		   else if(b==11) x=304;
		   else x=334;
		   if(c==1) y=0;
		   else if(c==2) y=31;
		   else if(c==3) y=59;
		   else if(c==4) y=90;
		   else if(c==5) y=120;
		   else if(c==6) y=151;
		   else if(c==7) y=181;
		   else if(c==8) y=212;
		   else if(c==9) y=243;
		   else if(c==10) y=273;
		   else if(c==11) y=304;
		   else y=334;
		    if(x<=y) m=y-x;
		   else m=x-y;
		   if(m%7==0) printf("YES\n");
		   else printf("NO\n");
	   }
   }

}
int runnian(int a)
{
	if((a%4==0&&a%100!=0)||a%400==0)
		return 1;
	else return 0;
}

void main()
{
	int n,i,j,y,m1,m2,result1=0,result2=0;
	int month[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(j=1;j<=n;j++)
	{
		scanf("%d%d%d",&y,&m1,&m2);
		for(i=0;i<m1-1;i++)
			result1+=month[runnian(y)][i];
		for(i=0;i<m2-1;i++)
			result2+=month[runnian(y)][i];
		if(abs(result2-result1)%7==0)
			printf("YES\n");
		else printf("NO\n");
		result1=result2=0;
	}
}
int main()
{
	int x,n,m1,m2,d,i,j,counter,counter1=0,counter2=0,month1[12]={31,28,31,30,31,30,31,31,30,31,30,31},month2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	cin>>x;
	for(j=0;j<x;j++)
	{
	counter=0;counter1=0;counter2=0;
	cin>>n>>m1>>m2;
	if((n%4==0&&n%100!=0)||(n%400==0))
	{
		for(i=0;i<m1-1;i++)
			counter1+=month2[i];
		counter1+=1;
	}
	else 
	{
		for(i=0;i<m1-1;i++)
			counter1+=month1[i];
		counter1+=1;
	}
	if((n%4==0&&n%100!=0)||(n%400==0))
	{
		for(i=0;i<m2-1;i++)
			counter2+=month2[i];
		counter2+=1;
	}
	else 
	{
		for(i=0;i<m2-1;i++)
			counter2+=month1[i];
		counter2+=1;
	}
	if(counter1>counter2)
		counter=counter1-counter2;
	else
		counter=counter2-counter1;
	if(counter%7==0)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	}
	return 0;
}
int main()
{
	int n=0,a=0,i,b=0,c=0;
	
		scanf("%d",&n);
	for(i=0;i<n;i++){
scanf("%d%d%d",&a,&b,&c);
if((a%4==0&&a%100!=0)||(a%400==0)){
	if((b==1&&c==4)||(b==9&&c==12)||(b==4&&c==1)||(b==12&&c==9)
		||(b==4&&c==7)||(b==7&&c==4)
		||(b==1&&c==7)||(b==7&&c==1)||(b==2&&c==8)||(b==8&&c==2)
	||(b==3&&c==11)||(b==11&&c==3)	)//(b==2&&c==11)||(b==7&&c==1))
printf("YES\n");
	else printf("NO\n");}
else {if((b==2&&c==3)||(b==9&&c==12)||(b==3&&c==2)||(b==12&&c==9)||
		 (b==3&&c==11)||(b==11&&c==3)
		||(b==1&&c==10)||(b==10&&c==1) ||(b==4&&c==7)||(b==7&&c==4)
		||(b==2&&c==11)||(b==11&&c==2)||(b==3&&c==11)||(b==11&&c==3))
printf("YES\n");
	else printf("NO\n");}
	}
	return 0;
}
int main(int argc, char* argv[])
{
	int year,m1,m2,date=1,n,x,day,day2;
	int a,b,c,e,g,h,j;
	int d,f,i,k;

    a=c=e=g=h=j=31;
    d=f=i=k=30;
    scanf("%d",&n);
	for(x=0;x<n;x++)
	{
	scanf("%d%d%d",&year,&m1,&m2);

	if((year%4!=0)||(year%100==0&&year%400!=0))
		b=28;
	else
		b=29;
   
	switch(m1){
	case 1:day=date;break;
	case 2:day=a+date;break;
	case 3:day=a+b+date;break;
	case 4:day=a+b+c+date;break;
	case 5:day=a+b+c+d+date;break;
	case 6:day=a+b+c+d+e+date;break;
	case 7:day=a+b+c+d+e+f+date;break;
	case 8:day=a+b+c+d+e+f+g+date;break;
	case 9:day=a+b+c+d+e+f+g+h+date;break;
	case 10:day=a+b+c+d+e+f+g+h+i+date;break;
	case 11:day=a+b+c+d+e+f+g+h+i+j+date;break;
	case 12:day=a+b+c+d+e+f+g+h+i+j+k+date;break;}

	switch(m2){
	case 1:day2=date;break;
	case 2:day2=a+date;break;
	case 3:day2=a+b+date;break;
	case 4:day2=a+b+c+date;break;
	case 5:day2=a+b+c+d+date;break;
	case 6:day2=a+b+c+d+e+date;break;
	case 7:day2=a+b+c+d+e+f+date;break;
	case 8:day2=a+b+c+d+e+f+g+date;break;
	case 9:day2=a+b+c+d+e+f+g+h+date;break;
	case 10:day2=a+b+c+d+e+f+g+h+i+date;break;
	case 11:day2=a+b+c+d+e+f+g+h+i+j+date;break;
	case 12:day2=a+b+c+d+e+f+g+h+i+j+k+date;break;}

	if((day-day2)%7==0)
	printf("YES\n");
	else
	printf("NO\n");}
	return 0;
}
/*
 * file    competition 1_4
 * author  ??
 * date    2010-10-22
 * description
           ?????
*/



int main()
{
	int n, i, y, m1, m2, t, j, m;
	int a[12];
	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;
	cin >> n;
	for (i = 1; i <= n; i ++)
	{
		cin >> y >> m1 >> m2;
     	if ( y % 4 != 0) t = 0;
     	else 
	      	if ( y % 100 == 0 && y % 400 != 0 ) t = 0;
	        else t = 1;
		if (t == 0) a[2] = 28;
		else a[2] = 29;
		if (m1 > m2) 
		{
			m = m1;
			m1 = m2;
			m2 = m;
		}
		m = 0;
		for (j = m1; j < m2; j ++)
			m = m + a[j];
		if (m % 7 == 0) cout << "YES" << endl;
		else cout << "NO" << endl;	
	}
	return 0;
}
void main()
{
  int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
  int n,i,y,m1,m2,j;
  scanf("%d",&n);
  for (i=0;i<n;i++)
  { 
  	int x=0,m=0;
  	scanf("%d%d%d",&y,&m1,&m2);
  	if ((y%400==0)||(y%4==0&&y%100!=0))
  	   a[1]=29;
  	if (m1>m2) {
  		m=m1;
  		m1=m2;
  		m2=m;
  	}
  	  for (j=m1-1;j<m2-1;j++)
      {
  	   x+=a[j];
      }
      if (x%7==0) printf("YES\n");
      else printf("NO\n");
    a[1]=28;
  }
}
int DiJiTian(int year,int mon);
int main(){
int i,n,mon1,mon2,year,result;
int sz[200];
   scanf("%d",&n);
   for(i=0;i<n;i++){
   sz[i]=0;
   }   
   for(i=0;i<n;i++){
	scanf("%d %d %d", &year, &mon1, &mon2);
    result=DiJiTian(year,mon1)-DiJiTian(year,mon2);
	if(result<0){
		result=0-result;
	}
    if((result%7)==0){
	sz[i]=1;}
   }
   for(i=0;i<n;i++){
	   if(sz[i]==1){
   printf("YES\n");
	   }else{
		   printf("NO\n");}
   }
	   return 0;
}
int DiJiTian(int year, int mon){
	int result=0;
	int i;
	for(i=1;i<mon;i++){ 
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			result+=31;	
		} else if(i==4||i==6||i==9||i==11){
			result+= 30;
		} else if(i == 2){
			if(year%400==0||(year%4==0&&year%100!=0)){
				result += 29;
			} else {
				result += 28;
			}	
		}
	}
	result+=1;	
	return result;	
}
/*
 * fuxi008_xiangguanyue.cpp
 * name:???
 *  Created on: 2011-12-23
 *      Author: zhujile
 */
int sday[12]={1,32,61,92,122,153,183,214,245,275,306,336}; //??????????
int nday[12]={1,32,60,91,121,152,182,213,244,274,305,335}; //????
void spe()                          //????
{
	int a,b;
	cin>>a>>b;
	if ((sday[a-1]-sday[b-1])%7==0) //??7??
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}
void nor()                          //???
{
	int a,b;
	cin>>a>>b;
	if ((nday[a-1]-nday[b-1])%7==0) //??7??
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}
int main(){
	int n,year;
	cin>>n;                         //????
	while (n--)
	{
		cin>>year;                  //????
		if ((year%4==0&&year%100!=0)||(year%400==0)) //????
			spe();
		else
			nor();
	}
	return 0;
}
int main ()
{
	int dijitian(int,int,int);
	
	int y[200],m1[200],m2[200],n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d %d",&y[i],&m1[i],&m2[i]);
	}for(int j=0;j<n;j++){
		if((dijitian(y[j],m1[j],1)-dijitian(y[j],m2[j],1))%7==0){
			printf("YES\n");
		}else {
			printf("NO\n");
		}
	}
	return 0;
}
int dijitian(int y,int m,int day)
{
	int d=0;
	for(int k=0;k<m;k++){
		if(k==1||k==3||k==5||k==7||k==8||k==10){
			d+=31;
		}else if(k==4||k==6||k==9||k==11){
			d+=30;
		}else if(k==2){
			if (y%4==0&&y%100!=0 || y%400==0){
				d+=29;
			}else{
				d+=28;
			}
		}
	}
	d+=day;
	return d;
}
int checkyear(int a)//?????1 
{
	if(	(a%4==0&&a%100!=0)	||	(a%400==0))
		return 1;
	else
	{
		return 0;
	}
}

int main()
{int i,n,a[1000],b[1000],c[1000];
double x ;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&a[i],&b[i],&c[i]);
for(i=0;i<n;i++)
{if(checkyear( a[i]))
{int x[14]={0,0,31,31+29,31+29+31,31+29+31+30,31+29+31+30+31,31+29+31+30+31+30,31+29+31+30+31+30+31,31+29+31+30+31+30+31+31,31+29+31+30+31+30+31+31+30,31+29+31+30+31+30+31+31+30+31,31+29+31+30+31+30+31+31+30+31+30,31+29+31+30+31+30+31+31+30+31+30+31}
 ;if((x[b[i]]-x[c[i]])%7==0)
 printf("YES\n");
 else printf("NO\n");}
 else {int x[14]={0,0,31,31+28,31+28+31,31+28+31+30,31+28+31+30+31,31+28+31+30+31+30,31+28+31+30+31+30+31,31+28+31+30+31+30+31+31,31+28+31+30+31+30+31+31+30,31+28+31+30+31+30+31+31+30+31,31+28+31+30+31+30+31+31+30+31+30,31+28+31+30+31+30+31+31+30+31+30+31}
; if((x[b[i]]-x[c[i]])%7==0)
 printf("YES\n");
 else printf("NO\n");}
                }




getchar();getchar();getchar();

    }
int runnian(int y)
{
	if(y%400==0||(y%100!=0&&y%4==0))
	{return 1;}
	else
	{return 0;}
}
int main()
{
	int n,j,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int a[200],b[200],c[200];
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		int yue[12]={31,28,31,30,31,30,31,31,30,31,30,31};	
		int sum=0;
		if(runnian(a[i]))
		{
			yue[1]=29;
		}
		int max,min;
		if(b[i]<c[i])
		{max=c[i];min=b[i];}
		if(b[i]>c[i])
		{max=b[i];min=c[i];}
		for(j=min-1;j<max-1;j++)
		{
			sum+=yue[j];
		}
		if(sum%7==0)
		{
			printf("YES\n");
		}
		else
		{printf("NO\n");}
	}
	return 0;
}
main()
{
	int i,n,j,a[200],b[200],c[200],k,l,z;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		l=0;
		k=0;
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		if(a[i]%4==0)
			k=1;
		if(a[i]%400!=0&&a[i]%100==0)
			k=0;
		if(c[i]<b[i])
		{
			z=b[i];
			b[i]=c[i];
			c[i]=z;
		}
		for(j=b[i];j<c[i];j++)
		{
			if(j==1) l=l+31;
			if(j==2) l=l+28+k;
			if(j==3) l=l+31;
			if(j==4) l=l+30;
			if(j==5) l=l+31;
			if(j==6) l=l+30;
			if(j==7) l=l+31;
			if(j==8) l=l+31;
			if(j==9) l=l+30;
			if(j==10) l=l+31;
			if(j==11) l=l+30;
		}
		if(l%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
}
int main(int argc, char* argv[])
{
	int n,a,b,c,i,m[13]={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",&a,&b,&c);
		if((a%4==0&&a%100!=0)||(a%400==0))
			m[2]=29;
		else
			m[2]=28;
		
		if(b>c)
		{
			int j,s=0;
			for(j=c;j<b;j++)
			{
				s=s+m[j];
			
			}
			if(s%7==0)
					printf("YES\n");
				else
					printf("NO\n");
		}
		if(c>b)
		{
			int j,s=0;
			for(j=b;j<c;j++)
			{
				s=s+m[j];
			
			}
			if(s%7==0)
					printf("YES\n");
				else
					printf("NO\n");
		}
	}
	return 0;
}
int main ()
{
	int n,i,j,k,l;
	int a,b[13],c[13];
	scanf ("%d",&n);
	for (k=1;k<=n;k++)
	{
		scanf ("%d%d%d",&a,&i,&j);
		if (i>j)
		{
			l=i;
			i=j;
			j=l;
		}
		if (a%4==0&&a%100!=0||a%400==0)
		{
			b[1]=c[1]=0;
			b[2]=c[2]=31;
			b[3]=c[3]=60;
			b[4]=c[4]=91;
			b[5]=c[5]=121;
			b[6]=c[6]=152;
			b[7]=c[7]=182;
			b[8]=c[8]=213;
			b[9]=c[9]=244;
			b[10]=c[10]=274;
			b[11]=c[11]=305;
			b[12]=c[12]=335;
			if ((c[j]-b[i])%7==0)
			{
				printf ("YES\n");
			}
			else
			{
				printf ("NO\n");
			}
		}
		else
		{
			b[1]=c[1]=0;
			b[2]=c[2]=31;
			b[3]=c[3]=59;
			b[4]=c[4]=90;
			b[5]=c[5]=120;
			b[6]=c[6]=151;
			b[7]=c[7]=181;
			b[8]=c[8]=212;
			b[9]=c[9]=243;
			b[10]=c[10]=273;
			b[11]=c[11]=304;
			b[12]=c[12]=334;
			if ((c[j]-b[i])%7==0)
			{
				printf ("YES\n");
			}
			else
			{
				printf ("NO\n");
			}
		}
	}
		return 0;
}
/*
 * exercise37.cpp
 *
 *  Created on: 2013-11-7
 *      Author: st
 */
int main()
{
	int n,i,k,year,month1,month2,days=0;
	cin>>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 min,max;
	for(i=1;i<=n;i++)
		{
		 cin>>year>>month1>>month2;
		 if(month1>month2)
		 { max=month1;
		     min=month2;}
		 else
		 { max=month2;
		   min=month1;}
		 if(((year%4==0)&&(year%100!=0))||(year%400==0))
			{
			for(k=min;k<max;k++)
			days+=b[k];
		    if(days%7==0)
			cout<<"YES"<<endl;
		    else
			cout<<"NO"<<endl;
			}
		else
			{
			for(k=min;k<max;k++)
            days+=a[k];
		    if(days%7==0)
		    cout<<"YES"<<endl;
			else
			cout<<"NO"<<endl;
			}
		 days=0;

		}



}
main()
{
    int n,i,y,m1,m2,t,sum;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d %d",&y,&m1,&m2);
        sum=0;
        if(m1>m2)
        {
            t=m1;
            m1=m2;
            m2=t;
        }
        if(y%400==0||(y%4==0&&y%100!=0))
        {
            if(1>=m1&&1<m2)
            sum=sum+31;
            if(2>=m1&&2<m2)
            sum=sum+29;
            if(3>=m1&&3<m2)
            sum=sum+31;
            if(4>=m1&&4<m2)
            sum=sum+30;
            if(5>=m1&&5<m2)
            sum=sum+31;
            if(6>=m1&&6<m2)
            sum=sum+30;
            if(7>=m1&&7<m2)
            sum=sum+31;
            if(8>=m1&&8<m2)
            sum=sum+31;
            if(9>=m1&&9<m2)
            sum=sum+30;
            if(10>=m1&&10<m2)
            sum=sum+31;
            if(11>=m1&&11<m2)
            sum=sum+30;
            if(12>=m1&&12<m2)
            sum=sum+31;
            if(sum%7==0)
            printf("YES\n");
            else
            printf("NO\n");
        }
        else
        {
            if(1>=m1&&1<m2)
            sum=sum+31;
            if(2>=m1&&2<m2)
            sum=sum+28;
            if(3>=m1&&3<m2)
            sum=sum+31;
            if(4>=m1&&4<m2)
            sum=sum+30;
            if(5>=m1&&5<m2)
            sum=sum+31;
            if(6>=m1&&6<m2)
            sum=sum+30;
            if(7>=m1&&7<m2)
            sum=sum+31;
            if(8>=m1&&8<m2)
            sum=sum+31;
            if(9>=m1&&9<m2)
            sum=sum+30;
            if(10>=m1&&10<m2)
            sum=sum+31;
            if(11>=m1&&11<m2)
            sum=sum+30;
            if(12>=m1&&12<m2)
            sum=sum+31;
            if(sum%7==0)
            printf("YES\n");
            else
            printf("NO\n");
        }
    }
}
int run_check(int year)
{
	if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
		return 1;
	return 0;
}

int t[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int y, a, b, s = 0;
		cin >> y >> a >> b;
		if (a > b) swap(a, b);
		if (run_check(y))
			t[2]++;
		for (int j = a; j < b; j++)
			s += t[j];
		if(s % 7) cout << "NO\n";
		else cout << "YES\n";
		if (run_check(y))
			t[2]--;
	}
	
    return 0;
}
int main()
{
	int n,i,j,k,a[200],b[200][13],c[200][13];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	    if((a[i]%4==0&&a[i]%100!=0)||a[i]%400==0)
		{
			b[i][1]=0;
			b[i][2]=31;
	        b[i][3]=60;
            b[i][4]=91;
	        b[i][5]=121;
	        b[i][6]=152;
	        b[i][7]=182;
	        b[i][8]=213;
	        b[i][9]=244;
	        b[i][10]=274;
	        b[i][11]=305;
	        b[i][12]=335;
	        c[i][1]=0;
			c[i][2]=31;
         	c[i][3]=60;
	        c[i][4]=91;
        	c[i][5]=121;
			c[i][6]=152;
            b[i][10]=274;
	        b[i][11]=305;
	        b[i][12]=335;
	        c[i][1]=0;
			c[i][2]=31;
         	c[i][3]=60;
	        c[i][4]=91;
        	c[i][5]=121;
			c[i][6]=152;
            c[i][7]=182;
            c[i][8]=213;
        	c[i][9]=244;
       	    c[i][10]=274;
	        c[i][11]=305;
	        c[i][12]=335;
			scanf("%d %d",&j,&k);
			if((c[i][k]-b[i][j])%7==0)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
		else
		{
			b[i][1]=0;
			b[i][2]=31;
	        b[i][3]=59;
            b[i][4]=90;
	        b[i][5]=120;
	        b[i][6]=151;
	        b[i][7]=181;
	        b[i][8]=212;
	        b[i][9]=243;
	        b[i][10]=273;
	        b[i][11]=304;
	        b[i][12]=334;
	        c[i][1]=0;
	        c[i][2]=31;
         	c[i][3]=59;
	        c[i][4]=90;
        	c[i][5]=120;
			c[i][6]=151;
			c[i][7]=181;
			c[i][8]=212;
        	c[i][9]=243;
       	    c[i][10]=273;
	        c[i][11]=304;
	        c[i][12]=334;
			scanf("%d%d",&j,&k);
			if((c[i][k]-b[i][j])%7==0)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
	}
	return 0;
}
int main()
{
	int n,i,a,b,c,s,t;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&a,&b,&c);
		if(((a%4==0)&&(a%100!=0))||((a%100==0)&&(a%400==0)))
		{
			if(b==1)
				s=1;
			if(b==2)
				s=1+31;
			if(b==3)
				s=1+31+29;
			if(b==4)
				s=1+31+29+31;
			if(b==5)
				s=1+31+29+31+30;
			if(b==6)
				s=1+31+29+31+30+31;
			if(b==7)
				s=1+31+29+31+30+31+30;
			if(b==8)
				s=1+31+29+31+30+31+30+31;
			if(b==9)
				s=1+31+29+31+30+31+30+31+31;
			if(b==10)
				s=1+31+29+31+30+31+30+31+31+30;
			if(b==11)
				s=1+31+29+31+30+31+30+31+31+30+31;
			if(b==12)
				s=1+31+29+31+30+31+30+31+31+30+31+30;
			if(c==1)
				t=1;
			if(c==2)
				t=1+31;
			if(c==3)
				t=1+31+29;
			if(c==4)
				t=1+31+29+31;
			if(c==5)
				t=1+31+29+31+30;
			if(c==6)
				t=1+31+29+31+30+31;
			if(c==7)
				t=1+31+29+31+30+31+30;
			if(c==8)
				t=1+31+29+31+30+31+30+31;
			if(c==9)
				t=1+31+29+31+30+31+30+31+31;
			if(c==10)
				t=1+31+29+31+30+31+30+31+31+30;
			if(c==11)
				t=1+31+29+31+30+31+30+31+31+30+31;
			if(c==12)
				t=1+31+29+31+30+31+30+31+31+30+31+30;
			if((s-t)%7==0)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
		else
		{
			if(b==1)
				s=1;
			if(b==2)
				s=1+31;
			if(b==3)
				s=1+31+28;
			if(b==4)
				s=1+31+28+31;
			if(b==5)
				s=1+31+28+31+30;
			if(b==6)
				s=1+31+28+31+30+31;
			if(b==7)
				s=1+31+28+31+30+31+30;
			if(b==8)
				s=1+31+28+31+30+31+30+31;
			if(b==9)
				s=1+31+28+31+30+31+30+31+31;
			if(b==10)
				s=1+31+28+31+30+31+30+31+31+30;
			if(b==11)
				s=1+31+28+31+30+31+30+31+31+30+31;
			if(b==12)
				s=1+31+28+31+30+31+30+31+31+30+31+30;
			if(c==1)
				t=1;
			if(c==2)
				t=1+31;
			if(c==3)
				t=1+31+28;
			if(c==4)
				t=1+31+28+31;
			if(c==5)
				t=1+31+28+31+30;
			if(c==6)
				t=1+31+28+31+30+31;
			if(c==7)
				t=1+31+28+31+30+31+30;
			if(c==8)
				t=1+31+28+31+30+31+30+31;
			if(c==9)
				t=1+31+28+31+30+31+30+31+31;
			if(c==10)
				t=1+31+28+31+30+31+30+31+31+30;
			if(c==11)
				t=1+31+28+31+30+31+30+31+31+30+31;
			if(c==12)
				t=1+31+28+31+30+31+30+31+31+30+31+30;
			if((s-t)%7==0)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
	}
	return 0;
}