semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n,i, y[300],m1[300],m2[300];
	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++)
	{
		if((y[i]%4==0&&y[i]%100!=0)||y[i]%400==0)
		{
			
			switch(m1[i])
			{
			case 1:m1[i]=0;break;
				case 2:m1[i]=31;break;
					case 3:m1[i]=31+29;break;
						case 4:m1[i]=31+29+31;break;
							case 5:m1[i]=31+29+31+30;break;
								case 6:m1[i]=31+29+31+30+31;break;
									case 7:m1[i]=31+29+31+30+31+30;break;
										case 8:m1[i]=31+29+31+30+31+30+31;break;
											case 9:m1[i]=31+29+31+30+31+30+31+31;break;
												case 10:m1[i]=31+29+31+30+31+30+31+31+30;break;
													case 11:m1[i]=366-30-31;break;
														case 12:m1[i]=366-31;break;
			}
				switch(m2[i])
			{
			case 1:m2[i]=0;break;
				case 2:m2[i]=31;break;
					case 3:m2[i]=31+29;break;
						case 4:m2[i]=31+29+31;break;
							case 5:m2[i]=31+29+31+30;break;
								case 6:m2[i]=31+29+31+30+31;break;
									case 7:m2[i]=31+29+31+30+31+30;break;
										case 8:m2[i]=31+29+31+30+31+30+31;break;
											case 9:m2[i]=31+29+31+30+31+30+31+31;break;
												case 10:m2[i]=31+29+31+30+31+30+31+31+30;break;
													case 11:m2[i]=366-30-31;break;
														case 12:m2[i]=366-31;break;
			}
				
			if((m2[i]-m1[i])%7==0||(m1[i]-m2[i])%7==0)
				printf("YES\n");
			else printf("NO\n");
		}
		else
		{
			switch(m1[i])
			{
			case 1:m1[i]=0;break;
				case 2:m1[i]=31;break;
					case 3:m1[i]=31+29-1;break;
						case 4:m1[i]=31+29+31-1;break;
							case 5:m1[i]=31+29+31+30-1;break;
								case 6:m1[i]=31+29+31+30+31-1;break;
									case 7:m1[i]=31+29+31+30+31+30-1;break;
										case 8:m1[i]=31+29+31+30+31+30+31-1;break;
											case 9:m1[i]=31+29+31+30+31+30+31+31-1;break;
												case 10:m1[i]=31+29+31+30+31+30+31+31+30-1;break;
													case 11:m1[i]=366-30-31-1;break;
														case 12:m1[i]=366-31-1;break;
			}
			
				switch(m2[i])
			{
			case 1:m2[i]=0;break;
				case 2:m2[i]=31;break;
					case 3:m2[i]=31+29-1;break;
						case 4:m2[i]=31+29+31-1;break;
							case 5:m2[i]=31+29+31+30-1;break;
								case 6:m2[i]=31+29+31+30+31-1;break;
									case 7:m2[i]=31+29+31+30+31+30-1;break;
										case 8:m2[i]=31+29+31+30+31+30+31-1;break;
											case 9:m2[i]=31+29+31+30+31+30+31+31-1;break;
												case 10:m2[i]=31+29+31+30+31+30+31+31+30-1;break;
													case 11:m2[i]=366-30-31-1;break;
														case 12:m2[i]=366-31-1;break;
			}
				
			if((m2[i]-m1[i])%7==0||(m1[i]-m2[i])%7==0)
				printf("YES\n");
			else printf("NO\n");

			
		
		
		}
	}
	

	
	return 0;
}
int main()
{
    int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	int n,i,j,k,t;
	int b,c,d;
		scanf("%d",&n);
	for(i=1;i<=n;i++) {
		k=0;
			 scanf("%d%d%d",&b,&c,&d);
			 if(c>d) {
                 j=c;
				 c=d;
				 d=j;
			 }
			 
			 for(j=c;j<d;j++) {
				 k=k+days[j];
				 if((j==2)&&(((b%4==0)&&(b%100!=0))||(b%400==0))) {
					 k++;
				 }
			 }
			 if(k%7==0) {
				 printf("YES\n");
			 }
			 else printf("NO\n");
			 }
	return 0;
}
int main()
{
	int n,i,x,y,A[200],B[200],C[200];
	scanf("%d",&n);
	0 < n <= 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]==1)x=1;
         else if(B[i]==2)x=31+1;
         else if(B[i]==3)x=31+28+1;
         else if(B[i]==4)x=31+28+31+1;
         else if(B[i]==5)x=31+28+31+30+1;
         else if(B[i]==6)x=31+28+31+30+31+1;
         else if(B[i]==7)x=31+28+31+30+31+30+1;
         else if(B[i]==8)x=31+28+31+30+31+30+31+1;
         else if(B[i]==9)x=31+28+31+30+31+30+31+31+1;
         else if(B[i]==10)x=31+28+31+30+31+30+31+31+30+1;
         else if(B[i]==11)x=31+28+31+30+31+30+31+31+30+31+1;
         else if(B[i]==12)x=31+28+31+30+31+30+31+31+30+31+30+1;
         if( (( (A[i]%4==0)&&(A[i]%100!=0) ) ||(A[i]%400==0))&&(B[i]>2))x=x+1;
		 else x=x;
		 if(C[i]==1)y=1;
         else if(C[i]==2)y=31+1;
         else if(C[i]==3)y=31+28+1;
         else if(C[i]==4)y=31+28+31+1;
         else if(C[i]==5)y=31+28+31+30+1;
         else if(C[i]==6)y=31+28+31+30+31+1;
         else if(C[i]==7)y=31+28+31+30+31+30+1;
         else if(C[i]==8)y=31+28+31+30+31+30+31+1;
         else if(C[i]==9)y=31+28+31+30+31+30+31+31+1;
         else if(C[i]==10)y=31+28+31+30+31+30+31+31+30+1;
         else if(C[i]==11)y=31+28+31+30+31+30+31+31+30+31+1;
         else if(C[i]==12)y=31+28+31+30+31+30+31+31+30+31+30+1;
         if( (( (A[i]%4==0)&&(A[i]%100!=0) ) ||(A[i]%400==0))&&(C[i]>2))y=y+1;
		 else y=y;
		 if((x-y)%7==0)
		 printf("YES\n");
		 else
		 printf("NO\n");
	}
	return 0;
}
int f(int nian,int yue ,int ri){
	int z=0,i;
	int d[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	if(nian%400==0||(nian%4==0&&nian%100!=0)){
		d[1]=29;
	}
	for(i=0;i<yue-1;i++){
		z=z+d[i];
	}
	z=z+ri;
	return(z);
}
int main(int argc, char* argv[])
{	int nian,yue1,yue2;
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%d%d%d",&nian,&yue1,&yue2);
	if((int)(fabs(f(nian,yue1,1)-f(nian,yue2,1)))%7==0)printf("YES\n");
	else printf("NO\n");
	}
	
	return 0;
}
int main()
{
   
    int days[] = {   0, 31, 28, 31, 30, 31, 30,
                    31, 31, 30, 31, 30, 31    };
    int i, n, y, m, d,x1;

    scanf("%d", &n);
	for (i = 0; i < n; i++) {
        scanf("%d %d %d", &y, &m, &d);
        days[2] = (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) ? 29 : 28;
		if(m>d){
			x1=d;
			d=m;
			m=x1;
		}
			int j,sum=0;
			for(j=m;j<d;j++)
             sum+=days[j];
			 if(sum%7==0)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}
int RN(int);
int RN(int year){
	if(year%400 == 0 ||(year%4==0 && year%100!=0)){
	return 1;
	} else{
		return 0;
	}
}
int main(){
	int n;
	int i,k;
	int a,b,c,e;
	
	scanf("%d",&n);
	for(k=0;k<n;k++){
		scanf("%d %d %d",&a,&b,&c);
int total=0;
		if(b>c){
			e=c;
			c=b;
			b=e;
		}
		for(i=b;i<c;i++){
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(RN(a)){
				total += 29;
			} else {
				total += 28;
			}
		}
		}
		if(total%7==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
		}
		return 0;
	}
const int a[13]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int b[13]={0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

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

int main()
{
    int f1[13][13], f2[13][13];
    int i, j, k, n, year, mon1, mon2, sum;
    memset(f1, 0, sizeof(f1));
    memset(f2, 0, sizeof(f2));
    for(i=1; i<=12; i++)
        for(j=i+1; j<=12; j++)
            {
                sum=0;
                for(k=i; k<=j-1; k++)
                    sum+=a[k];
                if(sum%7==0) f1[i][j]=1;
            }
    for(i=1; i<=12; i++)
        f1[i][i]=1;
    for(i=1; i<=12; i++)
        for(j=1; j<=i-1; j++)
            f1[i][j]=f1[j][i];
    for(i=1; i<=12; i++)
        for(j=i+1; j<=12; j++)
            {
                sum=0;
                for(k=i; k<=j-1; k++)
                    sum+=b[k];
                if(sum%7==0) f2[i][j]=1;
            }
    for(i=1; i<=12; i++)
        f2[i][i]=1;
    for(i=1; i<=12; i++)
        for(j=1; j<=i-1; j++)
            f2[i][j]=f2[j][i];
    scanf("%d", &n);
    for(i=1; i<=n; i++)
    {
        scanf("%d %d %d", &year, &mon1, &mon2);
        if(is_run(year)==1)
        {
            if(f2[mon1][mon2]==1)
                printf("YES\n");
            else
                printf("NO\n");
        }
        else
        {
            if(f1[mon1][mon2]==1)
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    return 0;
}
int main()
{
	int n,a[10000],b[10000],c[10000],i=0,s,m;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
		if(a[i]%4!=0||a[i]%100==0&&a[i]%400!=0)
		{
			switch(b[i])
			{
			case 1:s=1;break;
			case 2:s=32;break;
			case 3:s=60;break;
			case 4:s=91;break;
			case 5:s=121;break;
			case 6:s=152;break;
			case 7:s=182;break;
			case 8:s=213;break;
			case 9:s=244;break;
			case 10:s=274;break;
			case 11:s=305;break;
			case 12:s=335;break;
			default :;
			}
			switch(c[i])
			{
				case 1:m=1;break;
			case 2:m=32;break;
			case 3:m=60;break;
			case 4:m=91;break;
			case 5:m=121;break;
			case 6:m=152;break;
			case 7:m=182;break;
			case 8:m=213;break;
			case 9:m=244;break;
			case 10:m=274;break;
			case 11:m=305;break;
			case 12:m=335;break;
			default :;
			}
		}
		else
		{
				switch(b[i])
			{
			case 1:s=1;break;
			case 2:s=32;break;
			case 3:s=61;break;
			case 4:s=92;break;
			case 5:s=122;break;
			case 6:s=153;break;
			case 7:s=183;break;
			case 8:s=214;break;
			case 9:s=245;break;
			case 10:s=275;break;
			case 11:s=306;break;
			case 12:s=336;break;
			default :;
			}
			switch(c[i])
			{
				case 1:m=1;break;
			case 2:m=32;break;
			case 3:m=61;break;
			case 4:m=92;break;
			case 5:m=122;break;
			case 6:m=153;break;
			case 7:m=183;break;
			case 8:m=214;break;
			case 9:m=245;break;
			case 10:m=275;break;
			case 11:m=306;break;
			case 12:m=336;break;
			default :;
			}
		}
		if((abs(s-m))%7==0)
			cout<<"YES";
		else
			cout<<"NO";
		cout<<endl;
		s=0;
		m=0;
	}
	return 0;
}
int main()
{
    int year, m1, m2;
    int i, m, n, diff;
    
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        /* ?????? */
        scanf("%d%d%d", &year, &m1, &m2);
        /* ???????? */
        if (m1 > m2) {
            int t = m1;
            m1 = m2;
            m2 = t;
        }
        /* ??????? */
        diff = 0;
        for (m=m1; m<m2; m++) {
            switch (m) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
                diff = diff + 31;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                diff = diff + 30;
                break;
            case 2:
                if ((year%4==0)&&(year%100!=0)||(year%400==0)) {
                    diff = diff + 29;
                }
                else {
                    diff = diff + 28;
                }
                break;
            }
        }
        /* ????????7?? */
        if (diff % 7 == 0) {
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
    return 0;
}
void main()
{
	int n, i, j, a[200], b[200], c[200], d; 
	int totalb = 0, totalc = 0;
	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++){
		for(j=1;j<b[i];j++){
			if((j == 1) || (j == 3) || (j == 5) || (j == 7) || (j == 8) || (j == 10) || (j == 12))
				totalb+=31;
			else if((j == 4) || (j == 6) || (j == 9) || (j == 11))
				totalb+=30;
			else{
				if(((a[i]%4==0) && (a[i]%100!=0)) || (a[i]%400==0))
					totalb+=29;
				else
					totalb+=28;
			}
		}
		for(j=1;j<c[i];j++){
			if((j == 1) || (j == 3) || (j == 5) || (j == 7) || (j == 8) || (j == 10) || (j == 12))
				totalc+=31;
			else if((j == 4) || (j == 6) || (j == 9) || (j == 11))
				totalc+=30;
			else{
				if(((a[i]%4==0) && (a[i]%100!=0)) || (a[i]%400==0))
					totalc+=29;
				else
					totalc+=28;
			}
		}
		d=fabs(totalb-totalc);
		if(d%7==0)
			printf("YES\n");
		else
			printf("NO\n");
		totalb = totalc = 0;
	}
}
int main()

{
	int n;
	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};
	cin>>n;
	int y,m1,m2,sum;
	for(int i=1;i<=n;i++)
	{
		sum=0;
		int temp;
		cin>>y>>m1>>m2;
		if(m1>m2)
		{
			temp=m1;
			m1=m2;
			m2=temp;

		}
		if((y%4==0 && y%100!=0) || y%400==0)
		{
			for(int s=m1-1;s<=m2-2;s++)
			{
				sum=sum+b[s];
			}
		}
		else
		{
			for(int s=m1-1;s<=m2-2;s++)
			{
				sum=sum+a[s];
			}
		}
		if(sum%7==0)
			cout<<"YES"<<endl;
		else 
			cout<<"NO"<<endl;
	}
	return 0;
}
int f(int a)
{
    if((a%4==0&&a%100!=0)||(a%400==0))
    return 0;
    else
    return 1;
}
main()
{
      int n;
      scanf("%d",&n);
      int a,b,c,d=0,k;
      for(int i=1;i<=n;i++)
      {
              d=0;
              scanf("%d %d %d",&a,&b,&c);
              if(f(a)==0)
              {
              if(c>b)
              {k=c;c=b;b=k;}
                      while(b>c)
                      {
                                if(c==11)
                                {d=d+2;}
                                if(c==10)
                                {d=d+3;}
                                if(c==9)
                                {d=d+2;}
                                if(c==8)
                                {d=d+3;}
                                if(c==7)
                                {d=d+3;}
                                if(c==6)
                                {d=d+2;}
                                if(c==5)
                                {d=d+3;}
                                if(c==4)
                                {d=d+2;}
                                if(c==3)
                                {d=d+3;}
                                if(c==2)
                                {d=d+1;}
                                if(c==1)
                                {d=d+3;}
                                c++;
                      }
                      if(d%7==0)
                      printf("YES\n");
                      else
                      printf("NO\n");                 
              }
                   if(f(a)==1)
              {
              if(c>b)
              {a=c;c=b;b=a;}
                      while(b>c)
                      {
                                if(c==11)
                                {d=d+2;}
                                if(c==10)
                                {d=d+3;}
                                if(c==9)
                                {d=d+2;}
                                if(c==8)
                                {d=d+3;}
                                if(c==7)
                                {d=d+3;}
                                if(c==6)
                                {d=d+2;}
                                if(c==5)
                                {d=d+3;}
                                if(c==4)
                                {d=d+2;}
                                if(c==3)
                                {d=d+3;}
                                if(c==1)
                                d=d+3;
                                c++;
                      }
                      if(d%7==0)
                      printf("YES\n");
                      else
                      printf("NO\n");                 
              }
              
      }
}
int main(int argc, char* argv[])
{
	int n,i,j;
	scanf("%d",&n);
	int a,b,c,sum;
	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<c)
			{
				for(j=b,sum=0;j<c;j++)
				{
					if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
						sum=sum+31;
					else if(j==4||j==6||j==9||j==11)
						sum=sum+30;
					else
						sum=sum+29;
				}
				if(sum%7==0)
					printf("YES\n");
				else
				    printf("NO\n");
			}
			else if(b>c)
			{
				for(j=c,sum=0;j<b;j++)
				{
					if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
						sum=sum+31;
					else if(j==4||j==6||j==9||j==11)
						sum=sum+30;
					else
						sum=sum+29;
				}
				if(sum%7==0)
					printf("YES\n");
				else
				    printf("NO\n");
			}
			else if(b==c)
				printf("YES\n");
		}
		else 
		{
            if(b<c)
			{
				for(j=b,sum=0;j<c;j++)
				{
					if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
						sum=sum+31;
					else if(j==4||j==6||j==9||j==11)
						sum=sum+30;
					else
						sum=sum+28;
				}
				if(sum%7==0)
					printf("YES\n");
                else
				    printf("NO\n");
			}
            else if(b>c)
			{
				for(j=c,sum=0;j<b;j++)
				{
					if(j==1||j==3||j==5||j==7||j==8||j==10||j==12)
						sum=sum+31;
					else if(j==4||j==6||j==9||j==11)
						sum=sum+30;
					else
						sum=sum+28;
				}
				if(sum%7==0)
					printf("YES\n");
                else
				    printf("NO\n");
			}
			else if(b==c)
				printf("YES\n");
		}
	}
	return 0;
}
int main()
{
     int n, i, j, y, m1, m2, a;
     int pn[13]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
     int rn[13]={0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
     scanf("%d", &n);
     for(i=1; i<=n; i++)
     {
    a=0;
           scanf("%d%d%d", &y, &m1, &m2);
           if((y%4==0 && y%100!=0) || (y%400==0))
           {
                if(m1<m2)
                     for(j=m1; j<=(m2-1); j++)
                     {
                           a += rn[j];
                     }
                else
                     for(j=m2; j<=(m1-1); j++)
                     {
                           a += rn[j];
                     }
                if(a%7==0)
                     printf("YES\n");
                else
                     printf("NO\n");
           }
           else
           {
                if(m1<m2)
                     for(j=m1; j<=(m2-1); j++)
                     {
                           a += pn[j];
                     }
                else
                     for(j=m2; j<=(m1-1); j++)
                     {
                           a += pn[j];
                     }
                if(a%7==0)
                     printf("YES\n");
                else
                     printf("NO\n");
           }
           a=0;
     }
     return 0;
}
int main()
{
	int n,i,y,m1,m2,a,b,c;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		a=0;
		scanf("%d%d%d", &y, &m1, &m2);
		if(m1>m2){
			c=m2;
			m2=m1;
			m1=c;}
		if(y%4!=0||(y%100==0&&y%400!=0)){
			for(b=m1;b<m2;b++){
				if(b==1||b==3||b==5||b==7||b==8||b==10||b==12){
					a=a+31;}
				else if(b==2) a=a+28;
				else a=a+30;}
		}
		else{
			for(b=m1;b<m2;b++){
				if(b==1||b==3||b==5||b==7||b==8||b==10||b==12){
					a=a+31;}
				else if(b==2) a=a+29;
				else a=a+30;}
		}
		if (a%7==0) 
			printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
int main()
{
	int  y[200],m,s=0,n,i,p=0,a[200],b[200],q;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%d %d %d",&y[i],&a[i],&b[i]);
	}
for(i=0;i<n;i++){
		
			for(m=1;m<a[i];m++)
			{
				if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
				{
					s+=31;
				}
				else if(m==2)
				{

                    if((y[i]%400==0)||((y[i]%100!=0)&&(y[i]%4==0)))
					{
						s+=29;
					}
					else
					{
						s+=28;
					}
				}
				else
				{
					s+=30;
				}
			}
for(m=1;m<b[i];m++)
			{
				if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
				{
					p+=31;
				}
				else if(m==2)
				{

                    if((y[i]%400==0)||((y[i]%100!=0)&&(y[i]%4==0)))
					{
						p+=29;
					}
					else
					{
						p+=28;
					}
				}
				else
				{
					p+=30;
				}
}
q=s-p;
if(q%7==0){
	printf("YES\n");
}
else{
	printf("NO\n");
}
	s=0;p=0;
}
	return 0;
}
int main()
{
int n,a,b,c,i;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a>>b>>c;
if(a%4==0&&(a%100!=0||a%400==0))
{
int m[12]={0,3,4,7,9,12,14,17,20,22,25,27};
if((m[b-1]-m[c-1])%7==0) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
else
{
int p[12]={0,3,3,6,8,11,13,16,19,21,24,26};
if((p[b-1]-p[c-1])%7==0) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
return 0;
}
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,year,month1,month2,l,sum;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
	    cin>>year>>month1>>month2;
		sum=0;
		if(month1>month2)
		{
			l=month2;
			month2=month1;
			month1=l;
		}
		if (year%400==0||(year%4==0&&year%100!=0))
		{
			for (int j=month1;j<month2;j++)
			{
				sum+=b[j-1];
			}
		}
		else 
		{
			for (int j=month1;j<month2;j++)
			{
				sum+=a[j-1];
			}
		}
		if (sum%7==0)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}
	}
}
int rn(int n)
{
    if(n%400==0||(n%4==0&&n%100!=0))
    return 1;
    else return 0;
}
int day(int a,int b)
{
    int c,d;
    d=(b>=8)?(b+1)/2:b/2;
    if(b==1)  c=1;
    if(b==2)  c=32;
    if(rn(a)==1)
      if(b>2)   c=61+31*(d-1)+30*(b-2-d);
    if(rn(a)==0)
      if(b>2)   c=60+31*(d-1)+30*(b-2-d);
      return(c);
      }
main()
{
      int n,i,p,q,a,b,c;
      scanf("%d",&n);
      for(i=1;i<=n;i++)
      {
          scanf("%d %d %d",&a,&b,&c);
          p=day(a,b);
          q=day(a,c);
          if((p-q)%7==0)
          printf("YES\n");
          else
          printf("NO\n");
      } 
      getchar();getchar();
      }
int main()
{
	int n;
	int i,j;
	int year,m1,m2;
	int length1=0,length2=0;
	int length;
	int A[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	int B[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>n;
	for(i=0;i<n;i++)
	{
        length1=0;length2=0;
		cin>>year>>m1>>m2;
		
	if(year%4==0&&year%100!=0||year%400==0)
	{
		for(j=1;j<m1;j++)
			length1=A[j]+length1;
		for(j=1;j<m2;j++)
            length2=A[j]+length2;
		length=abs(length1-length2);
	}
	else
	{
		for(j=1;j<m1;j++)
			length1=B[j]+length1;
		for(j=1;j<m2;j++)
            length2=B[j]+length2;
		length=abs(length1-length2);
	}
	if(length%7==0)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	}
	
	return 0;
}
int main()
{
    int n,i,j,s,m;
    int an[200][3]={0};
    int t[12]={0};
    scanf("%d",&n);
    m=0;
    for (i=0;i<n;i++){
      for (j=0;j<=2;j++)
         scanf("%d",&an[i][j]);
         }
    for (i=0;i<n;i++) {
        t[i]=0;          
       if (an[i][1]<an[i][2]){
            m=an[i][1];
            an[i][1]=an[i][2];
            an[i][2]=m;
            }                   
           while (an[i][1]>an[i][2]){
              s=an[i][1]-1;
             if ((s==11)||(s==9)||(s==6)||(s==4))
                t[i]=t[i]+30;
                                    
             if((s==10)||(s==8)||(s==7)||(s==5)||(s==3)||(s==1))
                t[i]=t[i]+31;
             
             if (s==2){
                if ((an[i][0]%4==0)&&(an[i][0]%100!=0)||an[i][0]%400==0)
                  t[i]=t[i]+29;
                 else 
                  t[i]=t[i]+28;
                }      
             an[i][1]=an[i][1]-1; 
             }
     }
     for (i=0;i<n;i++)
       if (t[i]%7==0){
         printf("YES");
         printf("\n");
         }
       else {
         printf("NO");
         printf("\n");
         }
     
     return 0;
}
void main()
{
    int n;
    int a[201][10];
    int i,j;
    int g,b,c,x,y,m,d,e,f;
    
    scanf("%d\n",&n);
    for(i=1;i<=n;i++)
    {
    	scanf("%d ",&a[i][1]);
    	scanf("%d ",&a[i][2]);
    	scanf("%d",&a[i][3]);
    }
    
    for(i=1;i<=n;i++)
    {
    	g=a[i][1]-(a[i][1]/4)*4;
    	b=a[i][1]-(a[i][1]/100)*100;
    	c=a[i][1]-(a[i][1]/400)*400;
    	if(b!=0&&g==0)
    	{
    		a[i][4]=1;
    	}
    	else if(b==0&&c==0)
    	{
    		a[i][4]=1;
    	}
    	else
    	{
    		a[i][4]=0;
    	};
    	
    	if(a[i][2]>a[i][3])
    	{
    		x=a[i][3];
    		y=a[i][2];
    	}
    	else
    	{
    		x=a[i][2];
    		y=a[i][3];
    	};
    	
    	
    	if(x==1)
    	m=0;
    	else if(x==2)
    	m=31;
    	else if(x==3)
    	m=31+28+a[i][4];
    	else if(x==4)
    	m=31+28+a[i][4]+31;
    	else if(x==5)
    	m=31+28+a[i][4]+31+30;
    	else if(x==6)
    	m=31+28+a[i][4]+31+30+31;
    	else if(x==7)
    	m=31+28+a[i][4]+31+30+31+30;
    	else if(x==8)
    	m=31+28+a[i][4]+31+30+31+30+31;
    	else if(x==9)
    	m=31+28+a[i][4]+31+30+31+30+31+31;
    	else if(x==10)
    	m=31+28+a[i][4]+31+30+31+30+31+31+30;
    	else if(x==11)
    	m=31+28+a[i][4]+31+30+31+30+31+31+30+31;
    	
    	if(y==2)
    	d=31;
    	else if(y==3)
    	d=31+28+a[i][4];
    	else if(y==4)
    	d=31+28+a[i][4]+31;
    	else if(y==5)
    	d=31+28+a[i][4]+31+30;
    	else if(y==6)
    	d=31+28+a[i][4]+31+30+31;
    	else if(y==7)
    	d=31+28+a[i][4]+31+30+31+30;
    	else if(y==8)
    	d=31+28+a[i][4]+31+30+31+30+31;
    	else if(y==9)
    	d=31+28+a[i][4]+31+30+31+30+31+31;
    	else if(y==10)
    	d=31+28+a[i][4]+31+30+31+30+31+31+30;
    	else if(y==11)
    	d=31+28+a[i][4]+31+30+31+30+31+31+30+31;
    	else if(y==12)
    	d=31+28+a[i][4]+31+30+31+30+31+31+30+31+30;
    	
    	e=d-m;
    	f=e-(e/7)*7;
    	
    	if(f==0)
    	printf("YES\n");
    	else
    	printf("NO\n");
    }
    
}