semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main(int argc, char* argv[])
{
	int n,a,i;
	int b,c,d,e,f;
	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)
			   d=1;
		    else if(b==2)
               d=31+1;
            else if(b==3)
               d=31+29+1;
            else if(b==4)
                d=31+29+31+1;
            else if(b==5)
               d=31+29+31+30+1;
            else if(b==6)
               d=31+29+31+30+31+1;
            else if(b==7)
                d=31+29+31+30+31+30+1;
           else if(b==8)
               d=31+29+31+30+31+30+31+1;
            else if(b==9)
                d=31+29+31+30+31+30+31+31+1;
           else if(b==10)
               d=31+29+31+30+31+30+31+31+30+1;
           else if(b==11)
               d=31+29+31+30+31+30+31+31+30+31+1;
           else if(b==12)
               d=31+29+31+30+31+30+31+31+30+31+30+1;
	
		    if(c==1)
			e=1;
		else if(c==2)
            e=31+1;
        else if(c==3)
            e=31+29+1;
        else if(c==4)
            e=31+29+31+1;
        else if(c==5)
            e=31+29+31+30+1;
        else if(c==6)
            e=31+29+31+30+31+1;
        else if(c==7)
            e=31+29+31+30+31+30+1;
        else if(c==8)
            e=31+29+31+30+31+30+31+1;
        else if(c==9)
            e=31+29+31+30+31+30+31+31+1;
        else if(c==10)
            e=31+29+31+30+31+30+31+31+30+1;
        else if(c==11)
            e=31+29+31+30+31+30+31+31+30+31+1;
        else if(c==12)
            e=31+29+31+30+31+30+31+31+30+31+30+1;
		}
		else
		{
        if(b==1)
			d=1;
		else if(b==2)
            d=31+1;
        else if(b==3)
            d=31+28+1;
        else if(b==4)
            d=31+28+31+1;
        else if(b==5)
            d=31+28+31+30+1;
        else if(b==6)
            d=31+28+31+30+31+1;
        else if(b==7)
            d=31+28+31+30+31+30+1;
        else if(b==8)
            d=31+28+31+30+31+30+31+1;
        else if(b==9)
            d=31+28+31+30+31+30+31+31+1;
        else if(b==10)
            d=31+28+31+30+31+30+31+31+30+1;
        else if(b==11)
            d=31+28+31+30+31+30+31+31+30+31+1;
        else if(b==12)
            d=31+28+31+30+31+30+31+31+30+31+30+1;
		if(c==1)
			e=1;
		else if(c==2)
            e=31+1;
        else if(c==3)
            e=31+28+1;
        else if(c==4)
            e=31+28+31+1;
        else if(c==5)
            e=31+28+31+30+1;
        else if(c==6)
            e=31+28+31+30+31+1;
        else if(c==7)
            e=31+28+31+30+31+30+1;
        else if(c==8)
            e=31+28+31+30+31+30+31+1;
        else if(c==9)
            e=31+28+31+30+31+30+31+31+1;
        else if(c==10)
            e=31+28+31+30+31+30+31+31+30+1;
        else if(c==11)
            e=31+28+31+30+31+30+31+31+30+31+1;
        else if(c==12)
            e=31+28+31+30+31+30+31+31+30+31+30+1;
		}
		f=e-d;
		if(f%7==0)
		{
	       printf("YES\n");
		   
		}
		else
			printf("NO\n");



	}

	
	return 0;
}
int main()
{
	int n, i, leap, j, month;
	int year, m1, m2, d=0;

	cin >> n;
	for(i = 1;i <= n;i++)
	{
                d = 0;
		cin >> year >> m1 >> m2;

		if((year % 400 == 0)||(year % 100 != 0 && year % 4 == 0)) leap = 1;
		else leap = 0;
		if(m1 > m2)
		{
			month = m2;
			m2 = m1;
			m1 = month;
		}
		for(j = m1;j < m2;j++)
		{
			switch(j)
			{
			case 1 :
			case 3 :
			case 5 :
			case 7 :
			case 8 :
			case 10 :
			case 12 : d += 31;break;

        	case 4 :
			case 6 :
			case 9 :
			case 11 : d += 30;break;

        	case 2 : d = d + 28 + leap;break;
			}
		}
		if(d % 7 == 0)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}
int main()
{
	int n,i,j,sum,a[200][3],yue[13];
	cin>>n;
	yue[1]=yue[3]=yue[5]=yue[7]=yue[8]=yue[10]=yue[12]=31;
	yue[4]=yue[6]=yue[9]=yue[11]=30;
	for(i=0;i<n;i++)
	{
		sum=0;
		yue[2]=28;
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		if(a[i][0]%400==0||a[i][0]%100!=0&&a[i][0]%4==0)
			yue[2]=29;
		for(j=a[i][1];j<a[i][2];j++)
			sum+=yue[j];
		for(j=a[i][2];j<a[i][1];j++)
			sum+=yue[j];
		if(sum%7==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}
int rn(int y);
int main ()
{
  int n, i;
   scanf("%d", &n);
   for(i=0;i<n;i++){
	int  y=0, m1, m2, a, b, d=0;
	scanf ("%d %d %d", &y, &m1, &m2);
         if(m1>m2) {a=m2;m2=m1;m1=a;}
         if(rn(y)==1) {for(b=m1;b<m2;b++)
              {
			   if(b==1||b==3||b==5||b==7||b==8||b==10){d+=31;}
               if(b==2){d+=29;}
               if(b==4||b==6||b==9||b==11){d+=30;}
              }
		 }
         if (rn(y)==0) {for(b=m1;b<m2;b++)
              {
			   if(b==1||b==3||b==5||b==7||b==8||b==10){d+=31;}
               if(b==2){d+=28;}
               if(b==4||b==6||b==9||b==11){d+=30;}
		 }
               }
         if(d%7==0){ printf("YES\n"); }
         else {printf("NO\n");} 
                    }       

	
	return 0;
}
	int rn (int y)
	{
		if(y%4==0&&y%100!=0){return 1;}
		if(y%400==0){return 1;}
		else return 0;
	}
int main(int argc, char* argv[])
{
	int n,i;
	int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		int e,d,j,sum=0;
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		if(b>c){
			d=b;
			b=c;
			c=d;
		}
		if(((a%4==0)&&(a%100!=0))||(a%400==0)){
			day[2]=29;
		}
		else{
			day[2]=28;
		}
		for(j=b;j<c;j++){
			sum=sum+day[j];
		}
		e=sum%7;
		if(e==0){
			printf("YES\n");
		}
		else
			printf("NO\n");
	}
	return 0;
}
void main()
{
	void func(int,int,int);
	int y,x,z,n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&y,&x,&z);
		func(y,x,z);
	}
}
void func(year,m1,m2)
{
	int judge(int);
	int p,q;
	if(judge(year)==1)
	{
		switch(m1)
		{
		case 1:p=1;break;
		case 2:p=32;break;
		case 3:p=61;break;
		case 4:p=92;break;
		case 5:p=122;break;
		case 6:p=153;break;
		case 7:p=183;break;
		case 8:p=214;break;
		case 9:p=245;break;
		case 10:p=275;break;
		case 11:p=306;break;
		default:p=336;break;
		}
		switch(m2)
		{
		case 1:q=1;break;
		case 2:q=32;break;
		case 3:q=61;break;
		case 4:q=92;break;
		case 5:q=122;break;
		case 6:q=153;break;
		case 7:q=183;break;
		case 8:q=214;break;
		case 9:q=245;break;
		case 10:q=275;break;
		case 11:q=306;break;
		default:q=336;break;
		}
		if((p-q)%7==0)
		{
			printf("YES\n");
		}
		else printf("NO\n");
	}
	else if(judge(year)==2)
	{
		switch(m1)
		{
		case 1:p=1;break;
		case 2:p=32;break;
		case 3:p=60;break;
		case 4:p=91;break;
		case 5:p=121;break;
		case 6:p=152;break;
		case 7:p=182;break;
		case 8:p=213;break;
		case 9:p=244;break;
		case 10:p=274;break;
		case 11:p=305;break;
		default:p=335;break;
		}
		switch(m2)
		{
		case 1:q=1;break;
		case 2:q=32;break;
		case 3:q=60;break;
		case 4:q=91;break;
		case 5:q=121;break;
		case 6:q=152;break;
		case 7:q=182;break;
		case 8:q=213;break;
		case 9:q=244;break;
		case 10:q=274;break;
		case 11:q=305;break;
		default:q=335;break;
		}
		if((p-q)%7==0)
		{
			printf("YES\n");
		}
		else printf("NO\n");
	}
}
int judge(year)
{
	int f;
	if((year%4==0&&year%100!=0)||year%400==0) f=1;
	else f=2;
	return f;
}
int DiJiTian(int, int, int);
int main(){
	int n;
	int nian;
	int x,y;
	int i;
	int e;
	int day;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	         scanf("%d %d %d", &nian, &x, &y);
	         if(x<y){
	                        e=x;
		                    x=y;
		                    y=e;
			 }
	         day=DiJiTian(nian,x,1)-DiJiTian(nian,y,1);
	         if(day%7==0){
		              printf("YES\n");
			 }else {
	                	printf("NO\n");
			 }
	}
	return 0;
}


int DiJiTian(int year, int month, int day){
	int result = 0;
	for(int i = 1; i < month; i++){ 	//step1
		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 += day;	//step2
	return result;	
}
main()
{
      int n,i,j;
      scanf("%d",&n);
      int a[n],b[n],c[n];
      for(i=0;i<n;i++)
      {
                      scanf("%d %d %d",&a[i],&b[i],&c[i]);
      }
      int d[12]={31,28,31,30,31,30,31,31,30,31,30,31};
       int p,q;
      int s;
      for(i=0;i<n;i++)
      {
                      if((a[i]%4==0&&a[i]%100!=0)||a[i]%400==0)
                      {
                                   d[1]=29;
                      }
                      
                      p=b[i];
                      q=c[i];
                      if(p>q)
                      {
                             int temp;
                             temp=p;
                             p=q;
                             q=temp;
                      }
                      int s=0;      
                      for(j=p;j<q;j++)
                      {
                                      s=d[j-1]+s;
                      }
                      if(s%7==0)
                      printf("YES\n");
                      else
                      printf("NO\n");
                      d[1]=28;
      }
     
}
int run(int x)
{
    if(x%4!=0)
        return 0;
    if(x%100!=0)
        return 1;
    if(x%400==0)
        return 1;
    return 0;
}
main()
{
    int n,y,mon1,mon2;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d %d %d",&y,&mon1,&mon2);
        if(mon1>mon2)
        {
            int temp=mon1;
            mon1=mon2;
            mon2=temp;
        }
        if(run(y)==1)
        {
            int d=0;
            for(int j=mon1;j<mon2;j++)
            {
                if(j==2)
                    d+=29;
                else if(j==4||j==6||j==9||j==11)
                    d+=30;
                else
                    d+=31;
            }
            if(d%7==0)
                printf("YES\n");
            else
                printf("NO\n");
        }
        else
        {
            int d=0;
            for(int j=mon1;j<mon2;j++)
            {
                if(j==2)
                    d+=28;
                else if(j==4||j==6||j==9||j==11)
                    d+=30;
                else
                    d+=31;
            }
            if(d%7==0)
                printf("YES\n");
            else
                printf("NO\n");
        }        
    }
    getchar();
    getchar();getchar();
}
int y(int year)
{
	if(((year%4==0)&&(year%100!=0))||((year%400==0)&&(year%100==0)))
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
int main()
{
	int a[12]={3,0,3,2,3,2,3,3,2,3,2,3};
	int day;
	int i,j=0;
	int time;
	int year,m1,m2;
	scanf("%d",&time);
	for(;time>0;time--)
	{
		scanf("%d %d %d",&year,&m1,&m2);
		a[1]=y(year);
		if(m1>m2)
		{
			day=m1;
			m1=m2;
			m2=day;
		}
		day=0;
		for(i=m1;i<m2;i++)
		{
			day+=a[i-1];
		}
		if(day%7==0)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
		j++;
	}
}
int main()                             //?????
{ 
  int N,n,m1,m2;                       //??????n,m1,m2?????
  int a[12]={31,28,31,30,31,30,31,31,30,31,30,31}; 
                                      //????a?????12????
  cin>>N;                             //??????
  for(;N>0;N--)                       //????????
  { 
      a[1]=28;                        //?2?????28         
      int d=0;                        //??d????????
      cin>>n>>m1>>m2;                 //?????
      if(n%4==0&&n%100!=0||n%400==0)  //???????
      a[1]+=1;                        //??2??????
      if(m1>m2)                       //??m1>m2??????
      {
          m1=m1^m2;
          m2=m1^m2;
          m1=m1^m2;
      }                   
      for(;m1<m2;m1++)               //?????????????
      d+=a[m1-1];                    //?????7?????????
      if(d%7==0) 
          cout<<"YES";
      else cout<<"NO"; 
      cout<<endl;                               
  }
  return 0;
}
int year(int y);
void main()
{
	int i,m1,m2,n,c,s,y;
	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};
	scanf("%d",&n);
	while(n--){
		scanf("%d%d%d",&y,&m1,&m2);
		if(m1>m2){
			c=m1;
			m1=m2;
			m2=c;
		}
		s=0;
		if(year(y))
			for(i=m1-1;i<m2-1;i++)
				s+=b[i];
		else
			for(i=m1-1;i<m2-1;i++)
				s+=a[i];
		if(s%7)
			printf("NO\n");
		else
			printf("YES\n");
	}
}
int year(int y)
{
	if(!(y%4)&&y%100)
		return 1;
	if(!(y%400))
		return 1;
	return 0;
}
int main()
{
	int n,i,j,total1[200],total2[200];
	scanf("%d",&n);
	int year[200],mon1[200],mon2[200];
	for(i=0;i<n;i++){
    scanf("%d %d %d",&(year[i]),&(mon1[i]),&(mon2[i]));
}
	for(i=0;i<n;i++){
 total1[i]=0;
}
    for(i=0;i<n;i++){
                     total2[i]=0;
                     }                 
    for(i=0;i<n;i++){
    for( j = 1; j < mon1[i]; j++){ 	
		if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
			total1[i] += 31;	
		else if (j == 4 || j ==6 || j == 9 || j==11)
			total1[i] += 30;
		else if(j == 2)
			if(year[i]%400==0||(year[i]%4==0&&year[i]%100!=0))
				total1[i] += 29;
			else 
				total1[i] += 28;
			}	
	total1[i] +=1;
}
    
    for(i=0;i<n;i++){
    for( j = 1; j < mon2[i]; j++){ 	
		if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
			total2[i] += 31;	
		else if (j == 4 || j ==6 || j == 9 || j==11)
			total2[i] += 30;
		else if(j == 2)
			if(year[i]%400==0||(year[i]%4==0&&year[i]%100!=0))
				total2[i] += 29;
			else 
				total2[i] += 28;
			}	
	total2[i] +=1;
}
    for(i=0;i<n;i++){
    if((total1[i]-total2[i])%7==0)
    printf("YES\n");
    else
    printf("NO\n");

}
    return 0;
}
int main()
{
	int i,n,year,a,b;
	scanf ("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf ("%d %d %d",&year,&a,&b);
		if ((year%4==0&&year%100!=0)||year%400==0)
		{
			if(a==1||a==4||a==7)
				a=1;
			else if(a==2||a==8)
				a=2;
			else if(a==3||a==11)
				a=3;
			else if(a==9||a==12)
				a=9;
			
			if(b==1||b==4||b==7)
				b=1;
			else if(b==2||b==8)
				b=2;
			else if(b==3||b==11)
				b=3;
			else if(b==9||b==12)
				b=9;
		}
		else
		{
				if(a==1||a==10)
				a=1;
			else if (a==2||a==3||a==11)
				a=2;
			else if (a==4||a==7)
				a=4;
			else if (a==9||a==12)
				a=9;
			
			if(b==1||b==10)
				b=1;
			else if (b==2||b==3||b==11)
				b=2;
			else if (b==4||b==7)
				b=4;
			else if (b==9||b==12)
				b=9;
		}


			if(a==b)
			{
				printf("YES\n");
			}
			else 
			{
				printf("NO\n");
			}
	}
	return 0;
}
int main(){
	int n,y,m1,m2,d;
	scanf("%d",&n);
	int i,t,j;
	for(i=0;i<n;i++){
		scanf("%d%d%d",&y,&m1,&m2);
		d=0;
		if(m1<m2){
			t=m1;m1=m2;m2=t;
		}
        for(j=m2;j<m1;j++){
			if(j==1||j==3||j==5||j==7||j==8||j==10){
				d+=31;
			}else if(j==4||j==6||j==9||j==11){
				d+=30;
			}else{
				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 DATE0(int M0)
{
	int DATE0;
    switch(M0)
	{
	    case 1:
			DATE0=1;
			break;
		case 2:
			DATE0=32;
			break;
		case 3:
			DATE0=61;
			break;
		case 4:
			DATE0=92;
		    break;
		case 5:
			DATE0=122;
			break;
		case 6:
			DATE0=153;
			break;
		case 7:
			DATE0=183;
			break;
		case 8:
			DATE0=214;
			break;
		case 9:
			DATE0=245;
			break;
		case 10:
			DATE0=275;
			break;
		case 11:
			DATE0=306;
			break;
		case 12:
			DATE0=336;
			break;
	}
	return DATE0;
}

int DATE1(int M1)
{
	int DATE1;
    switch(M1)
	{
	    case 1:
			DATE1=1;
			break;
		case 2:
			DATE1=32;
			break;
		case 3:
			DATE1=60;
			break;
		case 4:
			DATE1=91;
			break;
		case 5:
			DATE1=121;
			break;
		case 6:
			DATE1=152;
			break;
		case 7:
			DATE1=182;
			break;
		case 8:
			DATE1=213;
			break;
		case 9:
			DATE1=244;
			break;
		case 10:
			DATE1=274;
			break;
		case 11:
			DATE1=305;
			break;
		case 12:
			DATE1=335;
			break;
	}
	return DATE1;
}

int main()
{
	int i,n,YEAR[210],MONTH1[210],MONTH2[210],P[210],Q[210],A[210],B[210];
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&YEAR[i],&MONTH1[i],&MONTH2[i]);
	    if(YEAR[i]%4!=0)
		{
			P[i]=1;
		}
		else if(YEAR[i]%4==0&&YEAR[i]%100!=0)
		{
			P[i]=0;
		}
		else if(YEAR[i]%100==0&&YEAR[i]%400!=0)
		{
			P[i]=1;
		}
		else
		{
			P[i]=0;
		}
		if(P[i]==0)
		{
			A[i]=DATE0(MONTH1[i]);
			B[i]=DATE0(MONTH2[i]);
			if((A[i]-B[i])%7==0)
			{
				Q[i]=1;
			}
			else
			{
				Q[i]=0;
			}
		}
		else
		{
			A[i]=DATE1(MONTH1[i]);
			B[i]=DATE1(MONTH2[i]);
			if((A[i]-B[i])%7==0)
			{
				Q[i]=1;
			}
			else
			{
				Q[i]=0;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		if(i!=0)
		{
			printf("\n");
		}
		if(Q[i]==1)
		{
			printf("YES");
		}
		else
		{
			printf("NO");
		}
	}
    return 0;
}
int main(int argc, char* argv[])
{
    int n,i,j,k,f;
    int	year[200],mon1[200],day,mon2[200],t1,t2;
	scanf("%d",&n);
    for (i=0;i<n;i++)
	{
		scanf("%d%d%d",&year[i],&mon1[i],&mon2[i]);
	}
	for (i=0;i<n;i++)
	{	
		if(((year[i]%4==0)&&(year[i]%100!=0))||(year[i]%400==0))
		{
			f=29;
		}
		else{f=28;}

        t1=0;
		t2=0;
		for (j=1;j<mon1[i];j++)
		{
			if(j==1||j==3||j==5||j==7||j==8||j==10){
				day=31;}
			else 
			{
				if(j==2){
				day=f;}
			    else{day=30;}
			}
			t1=t1+day;
		}
        for (k=1;k<mon2[i];k++)
		{
			if(k==1||k==3||k==5||k==7||k==8||k==10){
				day=31;}
		    else 
			{
				if (k==2){
				day=f;}
			    else{ day=30;}
			}
			t2=t2+day;
		}
		if(((t2-t1)%7==0)||((t1-t2)%7==0)){
			printf("YES\n");}
		else{
			printf("NO\n");}

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

  return 0;
}
int main(int argc, char* argv[])
{ int days[13] = {0, 31, 28, 31, 30, 31, 30,
                    31, 31, 30, 31, 30, 31 };
   int y, m1,m2, d, i,j, n,t;
   scanf("%d",&n);
   for(i=1;i<=n;i++){d=0;days[2]=28;
	   scanf("%d%d%d", &y, &m1, &m2);

       if ((y % 4 == 0 && y % 100 !=0) || (y % 400 == 0))
        days[2]++;
	   if(m1>12||m1<1||m2>12||m2<1)printf("NO");
	   else if(m1>m2){t=m1;m1=m2;m2=t;}
	   for(j=m1;j<m2;j++){
		   d=d+days[j];
	   }
	   if(d%7==0)printf("YES\n");
	   else printf("NO\n");
   }

	
	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 main()
{

	int year,month,day=1,m1,d1=1,t1,a,total,i=1,n,s;
	scanf("%d",&n);
	for(a=0;a<n;a++){
	scanf("%d%d%d",&year,&month,&m1);
	total=0;
	for(i=1;i<month;i++){ 	//step1
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			total+=31;	
		} else if(i==4||i==6||i==9||i==11){
			total+=30;
		} else if(i==2){
			if(isRunNian(year)){
				total+=29;
			} else{
				total+=28;
			}	
		}
	}
	total+=day;
	t1=0;
	for(i=1;i<m1;i++){ 	//step1
		if(i==1||i==3||i==5||i==7||i==8||i==10||i==12){
			t1+=31;	
		} else if(i==4||i==6||i==9||i==11){
			t1+=30;
		} else if(i==2){
			if(isRunNian(year)){
				t1+=29;
			} else{
				t1+=28;
			}	
		}
	}
	t1+=d1;
		s=total-t1;
		if(s%7==0||(0-s)%7==0){
			printf("YES\n");
		}
		else{printf("NO\n");
		}
	}
	return 0;
}
int main()
{
	int n,y,m1,m2,i,j,t,s1,s2;
	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(i=1;i<=n;i++)
	{cin>>y>>m1>>m2;
     if(m1<m2)
	 { if(y%4!=0||(y%100==0&&y%400!=0))
		{ for(s1=1,j=0;j<=m1-1;j++) s1=s1+b[j];
          for(s2=1,j=0;j<=m2-1;j++) s2=s2+b[j]; 
		}
	   else 
	   { for(s1=1,j=0;j<=m1-1;j++) s1=s1+a[j];
         for(s2=1,j=0;j<=m2-1;j++) s2=s2+a[j];
	   }
	 }
	 else
     { if(y%4!=0||(y%100==0&&y%400!=0))
		{ for(s1=1,j=0;j<=m2-1;j++) s1=s1+b[j];
          for(s2=1,j=0;j<=m1-1;j++) s2=s2+b[j]; 
		}
	   else 
	   { for(s1=1,j=0;j<=m2-1;j++) s1=s1+a[j];
         for(s2=1,j=0;j<=m1-1;j++) s2=s2+a[j];
	   }
	 }
	 if((s2-s1)%7==0) cout<<"YES"<<'\n';
	 else cout<<"NO"<<'\n';
	}
	return 0;
}
int main()
{
    int m[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    int n,i,j,s,y,m1,m2;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        m[1]=28;
        s=0;
        scanf("%d%d%d",&y,&m1,&m2);
        if (y%4==0 && (y%100!=0 || y%400==0))
            m[1]=29;
        if (m1>m2) 
        {
            j=m1;
            m1=m2;
            m2=j;
        }
        for(j=m1;j<m2;j++)
            s=s+m[j-1];
        if (s%7==0)
            printf("YES\n");
        else 
            printf("NO\n");
    }
    return 0;
}
int main()
{
    int n,i,j,a,b,c,e;
    scanf("%d",&n);
    int month[13]={0,3,0,3,2,3,2,3,3,2,3,2,3};
    for(i=0;i<n;i++){
         scanf("%d %d %d",&a,&b,&c);
         int d=0;
         if(b>c){
               e=b;
               b=c;
               c=e;
         }
         for(j=b;j<c;j++){
               d+=month[j];
         }
         if(((a%4==0&&a%100!=0)||a%400==0)&&b<=2){
               d++;
         }
         if(d%7==0){
               printf("YES\n");
         }
         else{
               printf("NO\n");
         }
    }
    return 0;
}
int main()
{   
	int i,max,min,j,k,n,y,a,b,s,day1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},day2[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	scanf("%d",&n);
	for(i=0;i<n;i++){s=0;
		scanf("%d%d%d",&y,&a,&b);
		if(a>b){max=a;min=b;}
		else if(a<b){max=b;min=a;}
		if((y%4==0)&&(y%100!=0)||(y%400==0)){
			for(j=min;j<max;j++){s+=day2[j];}
			}
		else {
			for(k=min;k<max;k++){s+=day1[k];}
		}
		if(s%7==0){printf("YES\n");}
		else if(s%7!=0){printf("NO\n");}
		}
		return 0;
	}
int main()
{
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int n,i,c,d,e,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&c,&d,&e);
		int y=0;
		if(d<e)
        {
			for(j=d-1;j<e-1;j++)
			{
			      y=y+a[j];
			}
		}
		else
		{
			for(j=e-1;j<d-1;j++)
			{
				y=y+a[j];
			}
		}
		if(((c%4==0&&c%100!=0)||c%400==0)&&((d<e&&d<=2&&e>2)||(d>e&&e<=2&&d>2)))
		{
			
				y=y+1;
				
		}
		
		if(y%7==0)
			printf("YES\n");
		else
			printf("NO\n");
		
	}
	
	return 0;
}