semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int min(int m1,int m2)
{
    if(m1<m2)
    {
             return m1;
    }
    else
    {return m2;}
} 
int max(int m1,int m2)
{
    if(m1>m2)
    {return m1;}
    else
    {return m2;}
}
int main()
{
    int n,i,b,j;
    scanf("%d",&n);
    int a[n],m1[n],m2[n];
    for(i=0;i<n;i++)
    {
    scanf("%d%d%d",&a[i],&m1[i],&m2[i]);
    }
    for(i=0;i<n;i++)
    {
         b=0; 
         if(a[i]%4!=0||(a[i]%100==0&&a[i]%400!=0))
         {
             for(j=min(m1[i],m2[i]);j<max(m1[i],m2[i]);j++)
             {
                  if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
                  {
                       b+=31; 
                  } 
                  else
                  {
                      if(j==2)
                      {
                               b+=28;
                      }
                      else
                      {
                          b+=30;
                      } 
                  } 
             } 
             b=b%7;
             if(b==0)
             {printf("YES\n");}
             else
             {printf("NO\n");} 
         }
         else
         {
             for(j=min(m1[i],m2[i]);j<max(m2[i],m1[i]);j++)
             {
                  if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
                  {
                       b+=31; 
                  } 
                  else
                  {
                      if(j==2)
                      {b+=29;}
                      else
                      {b+=30;} 
                  } 
             }
             b=b%7;
             if(b==0)
             {printf("YES\n");}
             else
             {printf("NO\n");} 
         } 
    }
    return 0; 
}
int main()
{
	int n,i;
	scanf("%d\n",&n);
    int a[200],b[200],c[200];
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
    for(i=0;i<n;i++)
	{

	     if((b[i]==3&&c[i]==11)||(b[i]==11&&c[i]==3))  printf("YES\n");
		else if((b[i]==9&&c[i]==12)||(b[i]==12&&c[i]==9)) printf("YES\n");
		else if((b[i]==4&&c[i]==7)||(b[i]==7&&c[i]==4)) printf("YES\n");
		else if((a[i]%4==0 && a[i]%100!=0) || a[i]%400==0) 
		{
		
			if((b[i]==1 && c[i]==4)||(b[i]==4 && c[i]==1)||(b[i]==1&&c[i]==7)||(b[i]==7&&c[i]==1)) printf("YES\n");
			else if((b[i]==2&&c[i]==8)||(b[i]==8&&c[i]==2)) printf("YES\n");
			else printf("NO\n");
		}
		else if((b[i]==2&&c[i]==3)||(b[i]==3&&c[i]==2)||(b[i]==1&&c[i]==10)||(b[i]==10&&c[i]==1)) printf("YES\n");
        else if ((b[i]==2&&c[i]==11)||(b[i]==11&&c[i]==2)) printf("YES\n");
		else printf("NO\n");     
	}
	return 0;
}
//*************************************
//* ????4.cpp *
//* ??????1200012844 *
//* ?????2012?10?23? *
//* ???????? *
//**************************************

int main()
{
	int year, month1, month2, month, leap, days, n, k;
	cin >> n;//??????n
	for(k = 0; k < n; k++)
	{
		days = 0;//???????0
		cin >> year >> month1 >> month2;//?????????
		leap = (year % 4==0 && year % 100 != 0) || year % 400 == 0;//???????
		if ( month1 < month2 )
			month = month1;
		else
			{month = month2;
			month2 = month1;
			}//????????????
		while( month < month2 )
		{
			switch (month)
			{
				case 2 : 
					days += 28 + leap; break;//2???????1
				case 1 :
				case 3 :
				case 5 :
				case 7 :
				case 8 :
				case 10 :
				case 12 : 
					days += 31; break;
				case 4 :
				case 6 :
				case 9 :
				case 11 : days += 30; break;
			}
			month++;
		}//???????????
		if ( days % 7 == 0 )
			cout << "YES" << endl;//?????7????????
		else
			cout << "NO" << endl;//?????
	}
	return 0;
}
int run(int n)
{
    if(n%4==0&&n%100!=0)
        return 1;
    else if(n%400==0)
        return 1;
    else
        return 0;
}
main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int y,m1,m2,t,day=0;
        int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
        scanf("%d %d %d",&y,&m1,&m2);
        if(run(y)==1)
            a[1]=29;
        if(m1>m2)
        {
            t=m1;
            m1=m2;
            m2=t;
        }
        for(int j=m1;j<m2;j++)
        {
            day+=a[j-1];
        }
        if(day%7==0)
            printf("YES\n");
        else
            printf("NO\n");
    }
}
int day(int m)
{
	int d=0;
	switch (m) {
	case 12: d+=30;
	case 11: d+=31;
	case 10: d+=30;
	case 9: d+=31;
	case 8: d+=31;
	case 7: d+=30;
	case 6: d+=31;
	case 5: d+=30;
	case 4: d+=31;
	case 3: d+=28;
	case 2: d+=31;
	}
	return d;
}
int main ()
{
	int n, y, m1, m2, d1, d2;
	scanf("%d", &n);
	while(n--) {
		scanf("%d%d%d", &y, &m1, &m2);
		d1=day(m1);
		d2=day(m2);
		if (y%4==0&&y%100!=0||y%400==0) {
			if (m1>2) d1++;
			if (m2>2) d2++;
		}
		if ((d1-d2)%7==0) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
void main()
{
	int y , m1 , m2;
	int x = 0 , i , x1 , x2 ;
	int p,q;
	scanf("%d",&p);
	for(q=0;q<p;q++){
	scanf( "%d %d %d", &y, &m1, &m2 );
	i = ( y - 1 ) / 400 * 400 ;
	for( ; i + 100 < y ; i += 100 )
		x = x + 36524 % 7 ;
	i = ( y - 1 ) / 100 * 100 + 1 ;
	for( ; i < y ; i ++ )
	{
		if( i % 4 != 0 )
			x = x + 365 ;
		else
			x = x + 366 ;
	}
	x1 = x;
	for( i = 1 ; i < m1 ; i ++ )
		if( 1 == i || 3 == i || 5 == i || 7 == i || 8 == i || 10 == i || 12 == i )
				x1 = x1 + 31;
		else if( 4 == i || 6 == i || 9 == i || 11 == i )
				x1 = x1 + 30;
		else if( y % 4 != 0 || ( y % 400 != 0 && y % 100 == 0) )
				x1 = x1 + 28;
		else x1 = x1 + 29;
	x1 = ( x1 + 1 ) % 7 ;
	x2 = x;
	for( i = 1 ; i < m2 ; i ++ )
		if( 1 == i || 3 == i || 5 == i || 7 == i || 8 == i || 10 == i || 12 == i )
				x2 = x2 + 31;
		else if( 4 == i || 6 == i || 9 == i || 11 == i )
				x2 = x2 + 30;
		else if( y % 4 != 0 || ( y % 400 != 0 && y % 100 == 0) )
				x2 = x2 + 28;
		else x2 = x2 + 29;
	x2 = ( x2 + 1 ) % 7 ;
	if(x1==x2) printf("YES\n");
	if(x1!=x2) printf("NO\n");
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	int y;
	int m1,m2;
	int e;
         int d;
	int j;
	for(i=1;i<=n;i++)
	{
	    scanf("%d%d%d",&y,&m1,&m2);
		if(m1>m2) {
			e=m1;
			m1=m2;
			m2=e;
		}
		d=0;
        for(j=m1;j<m2;j++)
		{
			if((j==1)||(j==3)||(j==5)||(j==7)||(j==8)||(j==10)||(j==12)) 
			{d+=31;
			}
			if((j==4)||(j==6)||(j==9)||(j==11)) {
				d+=30;
			}
			if(j==2){
				if((y%4==0&&y%100!=0)||y%400==0) d+=29;
				else d+=28;
			}
		}
		if(d%7==0) printf("YES\n");
		else {
                  printf("NO\n");}
	}
	return 0;
}
int main()
{
int n, allday1=1,month1[1000],month2[1000],allday2=1,monthday11[12]={31,28,31,30,31,30,31,31,30,31,30,31},monthday22[12]={31,29,31,30,31,30,31,31,30,31,30,31}, i, year[1000],k;
             scanf("%d\n", &n);
             for(k=0;k<n;k++)
             {
	       scanf("%d %d %d\n", &year[k], &month1[k],&month2[k]);
              }
             for(k=0;k<n;k++)	
            {
             if(year[k]%4==0&&year[k]%100!=0||year[k]%400==0)
	    {
		allday1=1;
                   allday2=1;
                   for(i=0;i<month1[k]-1;i++)
		{
		      allday1+=monthday22[i];
		}
		for(i=0;i<month2[k]-1;i++)
		{
		      allday2+=monthday22[i];
		}
		if((allday1-allday2)%7==0)
		{
			printf("YES\n");
		}
		else if((allday1-allday2)%7!=0)

		{
			printf("NO\n");
		}
	}
    else if(year[k]%4!=0||year[k]%100==0&&year[k]%400!=0)
	{
		allday1=1;
                    allday2=1;
                  for(i=0;i<month1[k]-1;i++)
		{
			allday1+=monthday11[i];
		}
		for(i=0;i<month2[k]-1;i++)
		{
			allday2+=monthday11[i];
		}
		if((allday1-allday2)%7==0)
		{
			printf("YES\n");
		}
		else if((allday1-allday2)%7!=0)
		{
			printf("NO\n");
		}
	}
}
return 0;
}
//********???????******************
//********?????2012?10?22?********
//********????????****************
//********???1200062701***************



int main()
{
	int a, b, c, e, n, y, d = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> y;
		cin >> a >> b;
		if(a > b) e = a, c = b, a = c, b = e;
		for (int e = a ; e < b; e++)
		{
			if ((y % 400 == 0) || ((y % 100 != 0) && (y % 4 == 0)))
		    {
				switch(e)
				{
					case 1 : d = d + 31; break;
					case 2 : d = d + 29; break;
					case 3 : d = d + 31; break;
					case 4 : d = d + 30; break;
					case 5 : d = d + 31; break;
					case 6 : d = d + 30; break;
					case 7 : d = d + 31; break;
					case 8 : d = d + 31; break;
					case 9 : d = d + 30; break;
					case 10 : d = d + 31; break;
					case 11 : d = d + 30; break;
				}
			}
			else 
			{
				switch(e)
				{
					case 1 : d = d + 31; break;
					case 2 : d = d + 28; break;
					case 3 : d = d + 31; break;
					case 4 : d = d + 30; break;
					case 5 : d = d + 31; break;
					case 6 : d = d + 30; break;
					case 7 : d = d + 31; break;
					case 8 : d = d + 31; break;
					case 9 : d = d + 30; break;
					case 10 : d = d + 31; break;
					case 11 : d = d + 30; break;
				}
			}	
		}
		if (d % 7 == 0) cout << "YES" << endl;
		else cout << "NO" << endl;
		d = 0;
	}
	return 0;
}
int main()
{
  int n,a;
  scanf("%d",&n);
  int year,mon1,mon2,day[12]={0};
  for (a=0;a<n;a++)
  {
    scanf("%d %d %d",&year,&mon1,&mon2);
    int i,j,sum;
    if ((year%4==0&&year%100!=0)||year%400==0)
    {
     int month1[12]={0,31,29,31,30,31,30,31,31,30,31,30};
     for (i=1;i<=12;i++)
     {
       sum=0;
       for (j=0;j<i;j++) sum+=month1[j];
       day[i]=sum+1;
      }
    }
    else 
    {
     int month2[12]={0,31,28,31,30,31,30,31,31,30,31,30};
     for (i=1;i<=12;i++)
     {
       sum=0;
       for (j=0;j<i;j++) sum+=month2[j];
       day[i]=sum+1;
      }
    }
     if ((day[mon2]-day[mon1])%7==0||(day[mon1]-day[mon2])%7==0) printf("YES\n");
     else printf("NO\n");
   }
}
/*
 *  ???:???
 *  ??: 2010-12-17
 *  ??: ???
 *  ??: ???????????????YES?
			?????NO?
 */


int is_Runnian(int year){				//??????
	if(year%4 != 0) return 0;
	else{
		if(year%100 == 0 && year%400 != 0)
			return 0;
	}
	return 1;
}

int main(){
	int monthday[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

	int n;
	cin >> n;

	int i=0;
	while(i < n){
		int year, month1, month2, month1day=0, month2day=0;
		cin >> year >> month1 >> month2;

		if(is_Runnian(year)) monthday[1] = 29;		//????? ????29?
		for(int j=0; j<month1-1; j++){
			month1day += monthday[j];
		}
		for(int j=0; j<month2-1; j++){
			month2day += monthday[j];
		}

		int p = (month2day-month1day>0 ? (month2day-month1day) : (month1day-month2day));

		if(p%7 == 0)				//??7??
			cout << "YES" << endl;
		else
			cout << "NO" << endl;

		if(monthday[1] == 29)
			monthday[1] = 28;
		i++;
	}
}
int f(int n,int a,int b)
{
   int x=0,y,i;
   int m[13];
   if((n%4==0&&n%100!=0)||(n%400==0))
   {   
	   if(a>b)
		   y=f(n,b,a);
	   else
	   {
	   m[1]=31;
	   m[2]=29;
	   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;
       for(i=a;i<b;i++)
	   {
		   x=x+m[i];
	   }
       if(x%7==0)
		   y=1;
	   else y=0;
	   }
   }
   else 
   {
	   if(a>b)
		   y=f(n,b,a);
	   else
	   {
	   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;
       for(i=a;i<b;i++)
	   {
		   x=x+m[i];
	   }
       if(x%7==0)
		   y=1;
	   else y=0;
	   }
   }
   return(y);
}
int main()
{
	int n,m,a,b,y,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&m,&a,&b);
		y=f(m,a,b);
		if (y==1)
			printf("YES\n");
		if(y==0)
             printf("NO\n");
	}
	return 0;
}
int main()
{
	int i, j, x, p[3] = {0}, m[3] = {0}, year, n;
	cin >> n;
	for (i = 1; i <= n; i ++)
	{
		cin >> year;
		cin >> m[1];
		cin >> m[2];
		if ((year % 400 == 0) || ((year % 100 != 0) && (year % 4 == 0)))
		{
			for (j = 1; j <= 2; j ++)
			{
				if (m[j] == 1)
				{
					p[j] = 1;
				}
				if (m[j] == 2)
				{
					p[j] = 31 + 1;
				}
				if ((m[j] <= 7) && (m[j] >= 3))
				{
					x = (m[j]- 2) / 2;
					p[j] = x * 31 + 29 + 31 + (m[j] - 3 - x) * 30 + 1;
					x = 0;
				}
				if (m[j] >= 8)
				{
					x = (m[j] - 7) / 2;
					p[j] = x * 31 + (29 + 31 * 4 + 30 * 2) + (m[j] - 8 - x) *30 + 1;
				}
			}	
		}
		else
		{
			for (j = 1; j <= 2; j ++)
			{
				if (m[j] == 1)
				{
					p[j] = 1;
				}
				if (m[j] == 2)
				{
					p[j] = 31 + 1;
				}
				if ((m[j] <= 7) && (m[j] >= 3))
				{
					x = (m[j]- 2) / 2;
					p[j] = x * 31 + 28 + 31 + (m[j] - 3 - x) * 30 + 1;
					x = 0;
				}
				if (m[j] >= 8)
				{
					x = (m[j] - 7) / 2;
					p[j] = x * 31 + (28 + 31 * 4 + 30 * 2) + (m[j] - 8 - x) *30 + 1;
				}
			}
		}
		int	t;
		t = fabs(p[1] - p[2]);
		if (t % 7 == 0)
		{
			cout << "YES" << endl; 
		}
		else
		{
			cout << "NO" << endl; 
		}
	}
return 0;
}
int main ( )
{
	int i, j, n = 0, year = 0, month1 = 0, month2 = 0, num = 0,
		a[12] = {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int min(int x, int y);
	int max(int x, int y);
	cin >> n;
	for(i = 0;i < n;i++)
	{
		num = 0;
		cin >> year >> month1 >> month2;
		if((year % 400 == 0)||((year % 100 != 0)&&(year % 4 == 0)))/*????*/
			a[1] = 29;
		else a[1] = 28;
		for(j = min(month1, month2)-1;j < max(month1, month2)-1;j++)/*???????????*/
			num += a[j];
		if(num % 7 == 0)
			cout << "YES" << endl;
		else cout <<"NO"<<endl;
	}
	return 0;
}
int min (int x, int y)/*?????*/
{
	if(x > y)
		return(y);
	else return(x);
}
int max(int x, int y)/*?????*/
{
	if(x > y)
		return(x);
	else return(y);
}
int main()
{
	int i, n, year, mon1, mon2, 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}, day1, day2, day3, day4, i1, i2, k1, k2;
	scanf("%d", &n);
	for(i=1; i<=n; i++)
	{
		day1=0;
		day2=0;
		day3=0;
		day4=0;
		scanf("%d", &year);
		scanf("%d%d", &mon1, &mon2);
		if((year%4==0 && year%100!=0)||(year%400==0))
		{
			if(mon1<mon2)
			{
				for(i1=mon1; i1<mon2; i1++)
				{
					day1=day1+b[i1-1];
				}
				if(day1%7==0)
					printf("YES\n");
				else
					printf("NO\n");
			}
			else
			{
				for(k1=mon2; k1<mon1; k1++)
				{
					day2=day2+b[k1-1];
				}
				if(day2%7==0)
					printf("YES\n");
				else
					printf("NO\n");
			}
		}
		else
		{
			if(mon1<mon2)
			{
				for(i2=mon1; i2<mon2; i2++)
				{
					day3=day3+a[i2-1];
				}
				if(day3%7==0)
					printf("YES\n");
				else
					printf("NO\n");
			}
			else
			{
				for(k2=mon2; k2<mon1; k2++)
				{
					day4=day4+a[k2-1];
				}
				if(day4%7==0)
					printf("YES\n");
				else
					printf("NO\n");
			}
		}
	}
	return 0;
}
int dijitian(int Y,int M,int D);
int main(){
	int n;
	scanf("%d",&n);
	int Y[200];
	int M[200];
	int m[200];
	int i;
	for(i=0;i<n;i++){
		scanf("%d%d%d",&Y[i],&M[i],&m[i]);
	}
	for(i=0;i<n;i++){
		if((dijitian(Y[i],M[i],1)-dijitian(Y[i],m[i],1))%7==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}

		}
	
	return 0;
}
int dijitian(int Y,int M,int D){
	int run(int Y);
	int i;
	int result=0;
	for(i=1;i<M;i++){
		if(i==1||i==3||i==5||i==7||i==8||i==10){
			result+=31;
		}if(i==4||i==6||i==9||i==11){
			result+=30;
		}if(i==2){
			if(run(Y)){
				result+=29;
			}else{
				result+=28;
			}
		}
	}result=result+D;
	return result;
}
int run(int Y){
	int Q;
	if(Y%400==0||(Y%4==0&&Y%100!=0)){
		Q=1;
	}else {
		Q=0;
	}
return Q;
}
int main()
{
  int a[13];
  a[1]=a[3]=a[5]=a[7]=a[8]=a[10]=a[12]=31;
  a[2]=28;
  a[4]=a[6]=a[9]=a[11]=30;
  int n;
  int y,m1,m2;
  int i,j,x,k;
  scanf ("%d",&n);
  for (i=0;i<n;i++)
  {
    k=0;
    scanf ("%d %d %d",&y,&m1,&m2);
    if ((y%400==0)||(y%4==0&&y%100!=0))
      a[2]=29;
    else
      a[2]=28;
    if (m2<m1)
    {
      x=m2;
      m2=m1;
      m1=x;
    } 
    for (j=m1;j<m2;j++)
      k+=a[j];
    if (k%7==0)
      printf ("YES\n");
    else 
      printf ("NO\n");
}
}
int main()
{
	int i,n,y,m1,m2,j;
    int days[] = {   0, 31, 28, 31, 30, 31, 30,
                    31, 31, 30, 31, 30, 31    };
	scanf("%d",&n);
	for(j=0;j<n;j++)
	{int t=0,d1=1,
		d2=1;
		scanf("%d%d%d",&y,&m1,&m2);
		if ((y%4==0)&&(y%100!=0)||(y%400==0))
		{days[2]=29;}
		else
		{days[2]=28;}
		
		for (i=0;i<m1;i++)
		{
			d1=d1+days[i];
		}
		for (i=0;i<m2;i++)
		{
			d2=d2+days[i];
		}
		t=d2-d1;
		if(t%7==0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}
int main()
{
	int a,b,c,i,t,sum=0,n,m;
	int A[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};//??????
	int B[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};//??
	cin>>n;
	for(m=0;m<n;m++)
	{
	cin>>a>>b>>c;//???  ?????
	if(b>c)//??????????????
	{
		t=b;b=c;c=t;
	}
	sum=0;
	if(((a%4==0&&a%100!=0)||((a%400)==0))==1)//??????
		for(i=b;i<c;i++)
			sum+=A[i];
	else
		for(i=b;i<c;i++)
			sum+=B[i];
	if(sum%7==0)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	}
	return 0;
}
//?????
int main()
{
   int year,c,d,n,j,i,a[13],sum=0;//c,d????a[12]?12??????sum????????
   a[1]=a[3]=a[5]=a[7]=a[8]=a[10]=a[12]=31;
   a[4]=a[6]=a[9]=a[11]=30;
   cin>>n;
   for(j=1;j<=n;j++)
   {
     cin>>year;
	 if(year%4==0&&year%100!=0||year%400==0)
		 a[2]=29;
	 else a[2]=28;//??2????
	 cin>>c>>d;
         sum=0;
	 if(c<d)
	{       
		for(i=c;i<d;i++)
        sum=sum+a[i];
	 
	 }
	else if(c>d)
	 {
           
	   for(i=d;i<c;i++)
        sum=sum+a[i];
         }
	 if(sum%7==0)//????????
		 cout<<"YES"<<endl;
	 else cout<<"NO"<<endl;
	 

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

}
int day(int year,int month)
{
	int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int i,c;
	if(year%4==0&&(year%100!=0)||(year%400==0)){days[2]++;}
	c=0;
	for(i=1;i<month;i++){c+=days[i];}
	return c;
}
/* title:???*
 * author:???*
 * time:2011.9.28*/

   


int main()
{
	int n, year, month1, month2, i, j, t, day;
	int month[13]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int rmonth[13]={0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    cin >> n;
	for(i = 1; i <= n; i++)
	{
		cin >> year >> month1 >> month2;
                  day = 0;
		if (month1 > month2)
		{
			t = month1;
			month1 = month2;
			month2 = t;
		}
		if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
		{
			for (j = month1; j < month2; j++)
			{
				day = day + rmonth[j];
			}
		}
		else
		{
            for (j = month1; j < month2; j++)
			{
				day = day + month[j];
			}
		}
		if(day % 7 == 0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}
int main()
{
int n,year,leap,i,m,d,re,q,s;
scanf("%d",&n);
for(int j=0;j<n;j++)
{
scanf("%d%d%d",&year,&m,&d);
if(m>d)
{s=m;
m=d;
d=s;}
if(year%4==0)
{    if(year%100==0)
{         if(year%400==0)
             leap=1;
            else leap=0;}
                else leap=1;}
                    else leap=0;
               if(leap==1)
			   {int month[12]={31,29,31,30,31,30,31,31,30,31,30,31};
                 
                       for(int k=m;k<d;k++)
					   {   
						   q+=month[k-1];
					   }
                  if(q%7==0)
				  {re=1;}
                   else 
	                 re=0;}
                  else 
				  {int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
                         	 
                       for(int k=m;k<d;k++)
					   {   
						   q+=month[k-1];
					   }
                       if(q%7==0)
					   {re=1;}
                           else 
	                        re=0;}
				            q=0;
if(re==1)
printf("YES\n");
else
printf("NO\n");
}
return 0;}
int main() {
	int n;
	cin >> n;
	for ( int i = 1; i <= n; i ++ ) {
	int year, month1, month2;
	int sum = 0;
	cin >> year >> month1 >> month2;
	int m1[12] ={ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int m2[12] ={ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	if ( month1 > month2 ) swap( month1, month2 );
	for ( int i = month1; i <= month2 - 1; i ++ ) {
		if ( year % 4 == 0 && year % 100 != 0 || year % 400 == 0 ) {
			sum += m2[i - 1];
		}
		else sum += m1[i - 1];
	}
	if ( sum % 7 == 0 ) cout << "YES" << endl;
	else cout << "NO" << endl;
	}
	return 0;
}
int MM[13]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void YY(int x)
{
	if(x % 400 == 0 || (x % 4 == 0 && x % 100 != 0))
	{
		MM[2] = 29;
		return;
	}
	MM[2] = 28;
}

int main()
{
	int n, yy, m1, m2, i, s;
	cin >> n;
	while(n--)
	{
		cin >> yy >> m1 >> m2;
		s = 0;
		YY(yy);
		if(m1 > m2)
		{
			m1 = m1 ^ m2;
			m2 = m1 ^ m2;
			m1 = m1 ^ m2;
		}
		for(i = m1;i < m2;i++)
			s += MM[i];
		if(s % 7 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}
int main()
{
	int n,i,j,y[200],m1[200],m2[200],d;
	int d1[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	int d2[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",&y[i],&m1[i],&m2[i]);
	}
	for(i=0;i<n;i++){
		d=0;
		if((y[i]%4==0&&y[i]%100!=0)||(y[i]%100==0&&y[i]%400==0)){
			if(m1[i]<m2[i]){
				for(j=m1[i];j<m2[i];j++){
					d+=d1[j];
				}
			}
			else{
				for(j=m2[i];j<m1[i];j++){
					d+=d1[j];
				}
			}
		}
		else{
            if(m1[i]<m2[i]){
				for(j=m1[i];j<m2[i];j++){
					d+=d2[j];
				}
			}
			else{
				for(j=m2[i];j<m1[i];j++){
					d+=d2[j];
				}
			}
		}
        if(d%7==0)  printf("YES\n");
		else  printf("NO\n");
        }
     return 0;
}
int main()
{
	int n,y,m1,m2,k,t=0,i;
	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};
	cin>>n;
	while(n>0)
	{
		cin>>y>>m1>>m2;
		if(m1>m2){k=m1;m1=m2;m2=k;}
		if(y%4!=0||((y%100==0)&&((y%400)!=0)))
			{for(i=m1;i<m2;i++)
				t+=a[i];
			if(t%7==0)cout<<"YES"<<endl;
			else cout<<"NO"<<endl;}
		else{
			for(i=m1;i<m2;i++)
			t+=b[i];
			if(t%7==0)cout<<"YES"<<endl;
			else cout<<"NO"<<endl;}
		t=0;
	n--;
	}
	return 0;

}
int main()
{
	int m1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int m[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int n,i,y,a,b,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int c=0;
		scanf("%d%d%d\n",&y,&a,&b);
		if((y%4==0&&y%100!=0)||y%400==0)
		{
			if(a>b)
			{
				for(j=0;j<a-b;j++)
				{
					c+=m[b+j-1];
				}
				if(c%7==0)printf("YES\n");
				else printf("NO\n");
			}
			else if(a<b)
			{
				for(j=0;j<b-a;j++)
				{
					c+=m[a+j-1];
				}
				if(c%7==0)printf("YES\n");
				else printf("NO\n");
			}
		}
		else
		{
			if(a>b)
			{
				for(j=0;j<a-b;j++)
				{
					c+=m1[b+j-1];
				}
				if(c%7==0)printf("YES\n");
				else printf("NO\n");
			}
			else if(a<b)
			{
				for(j=0;j<b-a;j++)
				{
					c+=m1[a+j-1];
				}
				if(c%7==0)printf("YES\n");
				else printf("NO\n");
			}
		}
	}
	return 0;
}