semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void main(){
	int leap_or_not(int year);
    int daysnotleap(int month);
    int daysleap(int month);
	int data[201][3],i,j,sum[201]={0},num,temp;
	scanf("%d",&num);
	for (i=1;i<=num;i++){
		for (j=0;j<3;j++)
			scanf("%d",&data[i][j]);
	}
	for (i=1;i<=num;i++){
		if (data[i][1]>data[i][2]){
				temp=data[i][1];
				data[i][1]=data[i][2];
				data[i][2]=temp;
			}
		}
	for (i=1;i<=num;i++){
		if (leap_or_not(data[i][0])==0){
		for (j=data[i][1];j<data[i][2];j++)
			sum[i]+=daysnotleap(j);
		}
		else {
			for(j=data[i][1];j<data[i][2];j++) 
				sum[i]+=daysleap(j);
		}
	}
	for (i=1;i<=num;i++)
	{if (sum[i]%7==0) printf("YES\n");
	else printf("NO\n");
	}
}

int leap_or_not(int year){
	 int leap;
	 if (year%4==0){
		 if (year%100==0){
			 if (year%400==0)
				 leap=1;
			 else leap=0;
		 }
		 else leap=1;
	 }
	 else leap=0;
	return leap;
}

int daysnotleap(int month){
	int day;
    if (month==1||month==3||month==5||month==7||month==8||month==10||month==12)
		day=31;
	else if (month==4||month==6||month==9||month==11)
		day=30;
	else day=28;
    return (day);
}
int daysleap(int month){
	int day;
    if (month==1||month==3||month==5||month==7||month==8||month==10||month==12)
		day=31;
	else if (month==4||month==6||month==9||month==11)
		day=30;
	else day=29;
    return (day);
}
int main()
{
	int n, i, year, days, mon1, mon2, tmon1, tmon2,
		month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> year >> tmon1 >> tmon2;
		mon1 = tmon1 < tmon2 ? tmon1 : tmon2;
		mon2 = tmon1 > tmon2 ? tmon1 : tmon2;
		if (mon1 <= 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
			days = 1;
        else 
			days = 0;
		for (; mon1 < mon2; mon1++)
		{
			days += month[mon1 - 1];
		}
		
		if (days % 7 == 0)
			cout << "YES" << endl;
		else 
			cout << "NO" << endl;
	}
	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,a,b,c;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a,&b,&c);
		if((DiJiTian(a,b,1)-DiJiTian(a,c,1))%7==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}
int main()
{
    int n,i,j,year,m1,m2;
    int day[13];
    int sum;
    int run(int x); 
    scanf("%d",&n);
    day[1]=31; 
    day[3]=31; 
    day[5]=31; 
    day[7]=31; 
    day[8]=31;
    day[10]=31; 
    day[12]=31; 
    day[4]=30; 
    day[6]=30; 
    day[9]=30; 
    day[11]=30;
    for (i=1;i<=n;i++)
        {
                      scanf("%d %d %d",&year,&m1,&m2);
                      if (run(year)==1)
                         day[2]=29;
                         else
                         day[2]=28;
                      sum=0;
                      if (m1>m2)
                         {
                                j=m1;
                                m1=m2;
                                m2=j;
                         }
                      for (j=m1;j<=m2-1;j++)
                          sum=sum+day[j];
                      if (sum%7==0)
                         printf("YES\n");
                         else
                         printf("NO\n");
        }
    
}
int run(int x)
{
    if (x%4!=0)
       return 0;
       else
       {
       if (x%100!=0)
          return 1;
          else
          {
          if (x%400==0)
             return 1;
             else return 0;
          }
       }
}
int is_leapyear(int y);
int main(){
	int n;
	cin>>n;
	const int md[12]={
		31,28,31,30,31,30,31,31,30,31,30,31
	};
	for(int i=0;i<n;i++){
		int yy,m1,m2;
		cin>>yy>>m1>>m2;
		int d=0;
		for(int i=min(m1,m2);i<max(m1,m2);i++) d+=md[i-1];
		if((m1<=2||m2<=2)&&is_leapyear(yy)) d++;
		if(!(d%7)) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}
int is_leapyear(int y){
	if(!(y%100)){
		if(!(y%400)) return 1;
		else return 0;
	}
	else if(!(y%4)) return 1;
	else return 0;
}
int run(int y)
{
	if((y%4 == 0) && (y%100 != 0)) return 1;
	else if(y%400 == 0) return 1;
	else return 0;	
}

int main()
{
	int n, i, j, y, temp, m1, m2, mark, a[13];
	a[1] = a[3] = a[5] = a[7] = a[8] = a[10] = a[12] = A;
	a[4] = a[6] = a[9] = a[11] = B;
	scanf("%d", &n);

	for(i=0;i<n;i++)
	{
		a[2] = C;
		a[0] = 0;
		scanf("%d%d%d", &y, &m1, &m2);
		mark = run(y);
		if(mark == 1) a[2] = C+1;
		if(m1<m2)
		{
loop:
			for(j=m1;j<m2;j++)
			{
				a[0] += a[j];
			}
			if(a[0]%7 == 0) printf("YES\n");
			else printf("NO\n");
		}
		else
		{
			temp = m1;
			m1 = m2;
			m2 = temp;
			goto loop;
		}
	}
	return 0;
}
int runyue(int n)
{
	int c=n;
	int a;
	if((n==12)||(n==9))a=6;
	if((n==1)||(n==4)||(n==7))a=7;
	if((n==11)||(n==3))a=4;
	if((n==2)||(n==8))a=3;
	if((n==5))a=2;
	if((n==6))a=5;
	if(n==10)a=1;
	return(a);
}
int burun(int n)
{int c=n;
 int a;
 if((n==1)||(n==10))a=2;
 if((n==2)||(n==3)||(n==11))a=5;
 if((n==4)||(n==7))a=1;
 if(n==5)a=3;
 if(n==6)a=6;
 if(n==8)a=4;
 if((n==9)||(n==12))a=7;
 return(a);
}
int run(int n)
{
int a=n;
int b;

if((a%100)==0) {if((a%400)==0)
b=1;
else b=0;}
else
{
if((a%4)==0)
b=1;
else b=0;}
return b;
}
int main()
{
int k;
cin>>k;
for(int i=0;i<k;i++)
{
int a;
cin>>a;
a=run(a);
int d,e;
cin>>d>>e;
//cout<<d<<e;
	if(a==1)//runnian
	{
		d=runyue(d);
		e=runyue(e);
		if((d-e)==0)cout<<"YES";
		else cout<<"NO";
		cout<<endl;
	}
	if(a==0)//bushirunnian
	{
		d=burun(d);
		e=burun(e);
		if((d-e)==0)cout<<"YES";
		else cout<<"NO";
		cout<<endl;
	
	}

}
return 0;
}
int main()
{
	int n;
	cin >> n;
	int year, month1, month2;
	for (int i= 1; i <= n; i++)
	{
		cin >> year >> month1 >> month2;
		int difference = month1 - month2;
		if (difference > 0)
		{
			month1 -= difference;
			month2 += difference;
		}
		int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 
		if (((!(year % 4)) && (year % 100)) || !(year % 400))
			m[2] = 29;
		int d = 0;
		for (int j = month1; j < month2; j++)
			d += m[j];
		if (d % 7)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
	}

	return 0;
}
int main()
{
	int i,n,a,b,c;
	cin >> n;
	for(i=1;i<=n;i++)
	{
		cin>>a>>b>>c;
		if(a%4!=0 || (a%100==0 & a%400!=0))
		{
            if(b==3 & c==11)
			    cout << "YES"<<endl;
		    else if(b==4 & c==7)
				cout << "YES"<<endl;
			else if(b==9 & c==12)
				cout << "YES"<<endl;
			else if(b==7 & c==4)
				cout << "YES"<<endl;
			else if(b==12 & c==9)
				cout << "YES"<<endl;
			else if(b==11 & c==3)
				cout << "YES"<<endl;
			else if(b==1 & c==10)
				cout << "YES"<<endl;
			else if(b==10 & c==1)
				cout << "YES"<<endl;
			else if(b==2 &c==11)
				cout << "YES"<<endl;
			else if(b==11 & c==2)
				cout << "YES"<<endl;
			else if(b==3 & c==2)
				cout << "YES"<<endl;
			else if(b==2 & c==3)
				cout << "YES"<<endl;
			else cout << "NO"<<endl;
		}
		else
		{
			if(b==3 & c==11)
			    cout << "YES"<<endl;
		    else if(b==4 & c==7)
				cout << "YES"<<endl;
			else if(b==9 & c==12)
				cout << "YES"<<endl;
			else if(b==7 & c==4)
				cout << "YES"<<endl;
			else if(b==12 & c==9)
				cout << "YES"<<endl;
			else if(b==11 & c==3)
				cout << "YES"<<endl;
			else if(b==1 & c==4)
				cout << "YES"<<endl;
			else if(b==1 & c==7)
				cout << "YES"<<endl;
			else if(b==7 & c==1)
				cout << "YES"<<endl;
			else if(b==4 & c==1)
				cout << "YES"<<endl;
			else if(b==2 & c==8)
				cout << "YES"<<endl;
			else if(b==8 & c==2)
				cout << "YES"<<endl;
			else cout << "NO"<<endl;
		}
	}
	return 0;
}
int ren(int x)
{
    if((x%400)==0||((x%100)!=0&&(x%4)==0))
		return 1;
	else
		return 0;
}

int dijitian(int year,int mon,int day)
{
    int i,d=0;
    if(ren(year))
	{
	    for(i=1;i<mon;i++)
		{
	        if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
			    d+=31;
		    else if(i==4||i==6||i==9||i==11)
			    d+=30;
		    else
			    d+=29;
		}
	}
	else
	{
	    for(i=1;i<mon;i++)
		{
	        if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
			    d+=31;
		    else if(i==4||i==6||i==9||i==11)
			    d+=30;
		    else
			    d+=28;
		}
	}
	d+=day;

	return d;
}

int main()
{
    int n,i,j,x[210][3]={0},a,b;

	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
	    scanf("%d%d%d",&x[i][0],&x[i][1],&x[i][2]);
	}

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

	if((total1-total2)%7==0)
	{
		printf("YES\n");
		continue;
	}
	else
	{
		printf("NO\n");
		continue;
	}

	}
	
	return 0;
}
int main ()
{
	int n, i, year, m1, m2, leap, days;
	cin >> n;
	for (i = 1; i <= n; i++ )
	{
		cin >> year >> m1 >> m2;
		days = 0;
		leap = year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
		if (m1 > m2)
		{
			int c = m1;
			m1 = m2;
			m2 = c;
		}
		for ( ; m1 < m2; m1++ )
		{
			switch(m1)
			{
				case(2):
					days += 28 + leap;
					break;
				case(4):
				case(6):
				case(9):
				case(11):
					days += 30;
					break;
				case(1):
				case(3):
				case(5):
				case(7):
				case(8):
				case(10):
				case(12):
					days += 31;
					break;
			}
		}
		if (days % 7 == 0)
		{
			cout << "YES" << endl;
		}
		else 
		{
			cout << "NO" << endl;
		}
	}

	return 0;
}
int dijitian(int y,int m,int d);
int main(){
    int n,k,year,month1,month2,cha;
	scanf("%d",&n);
	for(k=0;k<n;k++){
	   scanf("%d %d %d",&year,&month1,&month2);
       cha=dijitian(year,month1,1)-dijitian(year,month2,1);
	   if(cha<0){
	      cha=-cha;
	   }
	   if(cha%7==0){
	      printf("YES\n");
	   }else{
	      printf("NO\n");
	   }
	}
return 0;
}
int dijitian(int y,int m,int d){
    int sum=0;
	int i;
	for(i=1;i<m;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
		    sum+=31;
		}else if(i!=2){
		    sum+=30;
		}else{
			if((y%400==0)||(y%100!=0&&y%4==0)){
			   sum+=29;
			}else{
			   sum+=28;
			}
		}
	}
    sum+=d;
	return sum;
}
int main(){
	int n,i,k,y,m1,m2,m,d=0;
	scanf("%d",&n);
	for(k=0;k<n;k++){
		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){
		    for(i=m1;i<m2;i++){
			    if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
				    d+=31;
				}else if(i==4||i==6||i==9||i==11){
				    d+=30;
				}else if(i==2){
				    d+=29;
				}
			}
		}else{
			for(i=m1;i<m2;i++){
			    if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
				    d+=31;
				}else if(i==4||i==6||i==9||i==11){
				    d+=30;
				}else if(i==2){
				    d+=28;
				}
			}
		}
		if(d%7==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
		d=0;
	}
	return 0;
}
int run ( int x )
{
	if ( (x % 400 ==0) || ( (x % 4 == 0 )&& (x % 100 != 0 )) )
		return 0 ;
	else return 1 ;
}
int main()
{
	int i , n , j , day = 0 ;
	scanf("%d", &n);
	for ( i = 0 ; i < n ; i ++)
	{
		int year , mona ,monb , max , min;
		int run(int x);
		scanf ("%d %d %d" , &year , &mona , &monb);
		if (mona > monb)
		{
			max = mona ;
			min = monb ;
		}
		else 
		{
			max = monb ;
			min = mona ;
		}
		if ( run(year) == 0 )
		{
			for ( j = min ; j < max ; j ++)
			{
				if ( j == 2)
				{
					day += 29;
				}
				else if ( j == 4 || j == 6 || j == 9 || j == 11) 
				{day += 30 ;}
				else {day += 31;}
				
			}	
		}
		if ( run(year) == 1 )
		{
			for ( j = min ; j < max ; j ++)
			{
				if ( j == 2)
				{
					day += 28;
				}
				else if ( j == 4 || j == 6 || j == 9 || j == 11) 
				{day += 30 ;}
				else {day += 31;}
				
			}	
		}

		if ( day % 7 == 0 )  printf("YES\n");
		else printf("NO\n");
		day = 0 ;




	}
	return 0 ;
}
int xgy(int year,int month1,int month2){
	int i,m,days=0;
	if(month1>month2){
		m=month1;
		month1=month2;
		month2=m;
	}
	for(i=month1;i<month2;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			days+=31;
		}
		else if(i==4||i==6||i==9||i==11){
			days+=30;
		}
		else if(i==2){
			if(year%400==0||(year%4==0&&year%100!=0)){
				days+=29;
			}
			else{
				days+=28;
			}
		}
	}
	if(days%7==0){return 1;}
	if(days%7!=0){return 0;}
}
int main(){
	int i,n,year,month1,month2;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&year,&month1,&month2);
		if(xgy(year, month1, month2)){
			printf("YES\n");
		}
		else{printf("NO\n");}
	}
return 0;
}
int main()
{
	int i,n,a[3],b[13];
    b[0]=0;b[1]=31;b[2]=59;b[3]=90;b[4]=120;b[5]=151;b[6]=181;b[7]=212;b[8]=243;b[9]=273,b[10]=304;b[11]=334;b[12]=365;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		 scanf("%d%d%d",&a[0],&a[1],&a[2]);
		 if((a[0]%100!=0&&a[0]%4==0)||(a[0]%400==0))
		 {
			 if(a[1]>2&&(b[a[2]-1]-b[a[1]-1])%7==0&&a[2]>2)
                  printf("YES\n");
			 else if(a[1]<3&&(b[a[2]-1]-b[a[1]-1]+1)%7==0&&a[2]>=3)
                  printf("YES\n");
			 else if((b[a[2]-1]-b[a[1]-1])%7==0&&a[1]<3&&a[2]<3)
				 printf("YES\n");
			 else if(a[2]<3&&(b[a[1]-1]-b[a[2]-1]+1)%7==0&&a[1]>=3)
				 printf("YES\n");
			 else
				 printf("NO\n");
		 }
		 else
		 {
			  if((b[a[2]-1]-b[a[1]-1])%7==0)
                  printf("YES\n");
		 else
				 printf("NO\n");
		 }
	}	
	return 0;
}
int main()
{
	int n,i,j,y,m1,m2,temp,d=0;
	int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	scanf("%d",&n);
	for (j=0;j<n;j++)
	{
        scanf("%d%d%d",&y,&m1,&m2);
		d=0;
		if(m1>m2){temp=m1;m1=m2;m2=temp;}
		for (i=m1;i<=m2-1;i++)
		{
		    d=d+a[i];
		}
		if (y%100==0&&y%400==0&&m1<=2&&m2>2)
		{
		    d=1;
			for (i=m1;i<=m2-1;i++)
			{
				d=d+a[i];
			}
		}
		else if (y%100!=0&&y%4==0&&m1<=2&&m2>2)
		{
		    d=1;
			for (i=m1;i<=m2-1;i++)
			{
				d=d+a[i];
			}
		}
		if (d%7==0){printf("YES\n");}
		else {printf("NO\n");}
	}
	return 0;
}
int main()
{
	int m[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int n,i,y,a,b,c;
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%d",&y);
		scanf("%d",&a);
		scanf("%d",&b);

		if(y%400==0||(y%100!=0&&y%4==0))
			m[1]=29;
		else m[1]=28;

		if(a>b)
		{
			c=a-b;
			a=b;
		}
		else c=b-a;

		b=0;
		for(;c>0;c--)
		{
			b+=m[a-1];
			a++;
		}
		if(b%7==0)
			printf("YES\n");
		else printf("NO\n");       
	}
	return 0;
}
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int run(int year)
{
	if(year%4!=0)
		return 0;
	if(year%4==0)
	{
		if(year%100==0)
		{
		
		    if(year%400==0)
				return 1;
			else
 
			return 0;
		}
		else
			return 1;
	}
}



int main()
{



	int n,i,j,year,date1,date2,tem;
	int day[201]={0};
	
	scanf("%d",&n);
	for(i=1;i<n+1;i++)
	{
		scanf("%d%d%d",&year,&date1,&date2);
		month[2]=28;
		if(run(year))
			month[2]=29;
		if (date1>date2)
		{

			tem=date1;
			date1=date2;
			date2=tem;
		}
		for(j=date1;j<date2;j++)
		{
			day[i]+=month[j];
		}
	}
	
	for(i=1;i<n+1;i++)
	{
	
		if(day[i]%7==0)
			printf("YES\n");

			
		else
		
			printf("NO\n");
	}
	
	
	return 0;





}
int main(int argc, char* argv[])
{
    int y,m1,m2,i,n,j,k,d1,d2;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf ("%d%d%d",&y,&m2,&m1);
		if ((y%4==0)&&(y%100!=0)||(y%400==0))
		{
		   if ((m1==1&&m2==4)||(m1==4&&m2==1))
			   printf ("YES\n");
		   else if ((m1==1&&m2==7)||(m1==7&&m2==1))
			   printf ("YES\n");
		   else if ((m1==7&&m2==4)||(m1==4&&m2==7))
			   printf ("YES\n");
		   else if ((m1==2&&m2==8)||(m1==8&&m2==2))
			   printf ("YES\n");
		   else if ((m1==3&&m2==11)||(m1==11&&m2==3))
			   printf ("YES\n");
		   else if ((m1==9&&m2==12)||(m1==12&&m2==9))
			   printf ("YES\n");

		   else
			   printf("NO\n");
		}
		else 
		{
			if ((m1==1&&m2==10)||(m1==10&&m2==1))
			   printf ("YES\n");
			else if ((m1==3&&m2==11)||(m1==11&&m2==3))
			   printf ("YES\n");
			else if ((m1==2&&m2==11)||(m1==11&&m2==2))
			   printf ("YES\n");
			else if ((m1==3&&m2==2)||(m1==2&&m2==3))
			   printf ("YES\n");
			else if ((m1==4&&m2==7)||(m1==7&&m2==4))
			   printf ("YES\n");
			else if ((m1==9&&m2==12)||(m1==12&&m2==9))
			   printf ("YES\n");
			else printf ("NO\n");

		}

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

int hash[13][32];

int main()
{
    int Data;scanf("%d\n",&Data);
    while (Data--) {
          int year,m1,m2;
          scanf("%d %d %d\n",&year,&m1,&m2);
          if (year % 4==0 && (year % 100!=0 || year % 400==0)) month[2]=29;
             else month[2]=28;
          int cnt=0;if (m1>m2) swap(m1,m2);
          for (int i=1;i<=12;i++)  
              for (int j=1;j<=month[i];j++)
                  hash[i][j]=++cnt;
          if ((hash[m2][1]-hash[m1][1])%7==0) printf("YES\n");
             else printf("NO\n");
    } 
    return 0;
}
int max(int b,int c);
int min(int b,int c);
int main(void)
{
	int i,j,k;
	int n,m;
	int a,b,c;
	scanf("%d",&n);
	int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	while(n--)
	{
		m=0;
		scanf("%d%d%d",&a,&b,&c);
		if(a%4==0&&(a%100)!=0||a%400==0)
		{
			if(b==1&&c==2||b==2&&c==1)
			{
				printf("NO\n");
				continue;
			}
			else if(c<=2&&b>2||c>2&&b<=2)
			{
				for(i=min(b,c);i<max(b,c);i++)
				    m+=day[i];
				    m++;
				if(m%7==0)
				{
					 printf("YES\n");
					 continue;
				}
				else
				{
					printf("NO\n");
					continue;
				}
			}
			else if(c==b)
		{
				printf("NO\n");
					continue;
		}
			else
			{
				for(i=min(b,c);i<max(b,c);i++)
				    m+=day[i];
				if(m%7==0)
				{
					 printf("YES\n");
					 continue;
				}
				else
				{
					printf("NO\n");
					continue;
				}
			}
		}
		else if(c!=b)
		{
			for(i=min(b,c);i<max(b,c);i++)
				    m+=day[i];
				if(m%7==0)
				{
					 printf("YES\n");
					 continue;
				}
				else
				{
					printf("NO\n");
					continue;
				}
		}
		else if(c==b)
		{
				printf("NO\n");
					continue;
		}
	}
	return 0;
}
int max(int b,int c)
{
	if(b>c)
	    return b;
	return c;
}
int min(int b,int c)
{
	if(b<c)
	    return b;
	return c;
}
/*
 * 3.cpp
 *
 *  Created on: 2010-12-24
 *      Author: 10082
 */
int main(){
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int b[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int n,i,M=0,N=0;
	cin>>n;
	while(n>0){
		int year,m1,m2,m;
		cin>>year>>m1>>m2;
		M=0;
		N=0;
		if(m1>m2){
			m=m1;
			m1=m2;
			m2=m;
		}
		if(year%400==0||(year%100!=0&&year%4==0)){
			for(i=0;i<m1-1;i++)
				M=M+b[i];
			for(i=0;i<m2-1;i++)
				N=N+b[i];
			if((N-M)%7==0)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
		else{
			for(i=0;i<m1-1;i++)
				M=M+a[i];
			for(i=0;i<m2-1;i++)
				N=N+a[i];
			if((N-M)%7==0)
				cout<<"YES"<<endl;
			else
				cout<<"NO"<<endl;
		}
		n--;
	}
}
void main()
{
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
 int n,k,i,year,mon1,mon2,day1,day2,day,temp;
 scanf("%d",&n);
 for(k=0;k<n;k++)
 {
	 day1=day2=0;
	 scanf("%d%d%d",&year,&mon1,&mon2);
	 if(mon1>mon2)
	 {
		 temp=mon1;
	     mon1=mon2;
	     mon2=temp;
	 }
	 for(i=0;i<mon1-1;i++)
		 day1=day1+a[i];
	 for(i=0;i<mon2-1;i++)
		 day2=day2+a[i];
	 if((year%4==0&&year%100!=0)||year%400==0)
	 {
		 if(mon1>2)
			 day1++;
		 if(mon2>2)
			 day2++;
	 }
	 day=day2-day1;
	 if(day%7==0)
		 printf("YES\n");
	 else
		 printf("NO\n");
 }

}
int main(int argc, char* argv[])
{
	int n;
	int i;
	int a,b,c;
	int m[]={0,31,60,91,121,152,182,213,244,274,305,335};
	int k[]={0,31,59,90,120,151,181,212,243,273,304,334};
	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((m[b-1]-m[c-1])%7==0)
			{
				printf("YES\n");
			}
			else 
				printf("NO\n");
		}
		else 
		{
			if((k[b-1]-k[c-1])%7==0)
			{
				printf("YES\n");
			}
			else 
				printf("NO\n");
		}
	}
	return 0;
}
//********************************************************
//*  ?  ?: ???                                      *
//*  ?  ?: ???  1200012861                          *
//*  ?  ?: 2012?10?21?                              *
//********************************************************
int main()
{
	int n, i, j, y, m1, m2, min, max, sum, month[12]={31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> y >> m1 >> m2;
		min = m1 < m2 ? m1 : m2;
		max = m1 > m2 ? m1 : m2;
		if (((y % 100 != 0) && (y % 4 == 0)) || (y % 400 == 0))
			                                         //?????????
		{
			sum = 0;                                 //???????????sum
			month[1] = 29;                           //???2????????29
			for (j = min; j < max; j++)
				sum = sum + month[j - 1];            //??????????sum
			if (sum % 7 == 0)                        //??sum??7???????
				cout << "YES" << endl;               //???YES
			else 
				cout << "NO" << endl;                //????NO
		}
		else                                         //?????????
		{
			sum = 0;                                 //???????????sum
			month[1] = 28;                           //???2????????28
			for (j = min; j < max; j++)
				sum = sum + month[j - 1];            //??????????sum
			if (sum % 7 == 0)                        //??sum??7???????
				cout << "YES" << endl;               //???YES
			else 
				cout << "NO" << endl;                //????NO
		}
	}
	return 0;
}
//**************************
//* author ??           **
//* date 2012.10.24       **
//* description ???    **
//**************************

int main()
{
	//cout << "?????????n" << endl;
	int n, a, b, c, y, x, z;     //n????????a,b,c???,y??????x??????
	cin>>n;
	for (int i = 1; i <= n; i++)         //n???
	{
		x = 0;
		y = 0;
		cin >> a >> b >> c;
		if (b > c)                       //?b??c
		{
			z = c;
			c = b;
			b = z;
		}
		if ((a % 4 == 0 && a % 100 != 0) || (a % 400 == 0))   //????
		{
			y = 1;
		}
		for (; b <= c - 1; b++)                     //??????
		{
			switch (b)
			{
			case 1 :
			case 3 :
			case 5 :
			case 7 :
			case 8 :
			case 10 :
			case 12 : x = x + 31; break;
			case 4 :
			case 6 :
			case 9 :
			case 11 : x = x + 30; break;
			case 2 : x = x + 28 + y; break;
			}
		}
		if (x % 7 == 0)                       //??????????
		{
			cout << "YES" << endl;
		}
		else 
		{
			cout << "NO" << endl;
		}
	}

	return 0;
}