Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches.Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch.

The only line contains an integer n (1 ≤ n ≤ 10000).

Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches.

#include<stdio.h>
int main()
{
    int n,r,m,a,b;
    scanf("%d",&n);
    r=n/3;
    a=n%3;
    if(a==1||a==0)
    {
        m=r;
    }
    else
    {
        m=r+1;
    }
    b=m/12;
    r=m%12;
    printf("%d %d",b,r);
    return 0;
}

#include<stdio.h>

int main()
{
    int n,feet,rem,inch;
    scanf("%d",&n);
    feet=n/36;
    rem=n%36;
    inch=rem/3;
    if(rem%3==2)inch++;
    if(inch==12){feet++;
        inch=0;}

    printf("%d %d\n",feet,inch);
}

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<math.h>

main()
{
    int i,j, cm, feet, inch=0;
                                                        //1 feet= 12 inc
    scanf("%d", &cm);                                   //1 inch = 3 cm

    inch=(cm/3);
    if(cm%3==2){inch++;};
    feet=inch/12;
    inch-=feet*12;
    printf("%d %d",feet, inch);
}

#include<stdio.h>
int main()
{
    int n,feet,inch;
    scanf("%d",&n);

    if(n%3==0||n%3==1)
    {
        inch=n/3;
    }

    else if(n%3==2)
    {
        inch=n/3+1;
    }
    feet=inch/12;
    inch=inch%12;
    printf("%d %d",feet,inch);
    return 0;

}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int x;
    if(n%3 == 0 || n%3 == 1)
        x=n/3;
    else
        x=n/3+1;
    printf("%d %d", x/12, x%12);
    return 0;
}

#include<stdio.h>
int main()
{
	int n, i,feet, inch, cen,k,r, t;
	scanf("%d", &cen);
	inch=cen/3;
	r=cen%3;
	if(r==2)
	{
		inch=inch+1;
	}
	//printf("%d\n", inch);
	feet=inch/12;
	inch=inch-(feet*12);

	printf("%d %d ",feet, inch);
}

#include <stdio.h>
int main()
{
	long long int num,a,b,c;
	scanf("%lld",&num);
	a=num/36;
	if(num%36==35)
	a++;
	b=num-(a*36);
	c=b/3;
	if(b%3==2)
	{
		c++;
	}
	else
	c=c;

	printf("%lld %lld\n",a,c);
}

#include<stdio.h>
#define test 0.5

int main()
{
	double n,inch,temp;
	int feet;
	scanf("%lf",&n);
	inch = n/3;
	//printf("%lf\n",inch);
	feet = inch/12;
	inch = inch - (12*feet);
	//printf("%lf\n",inch);
	temp = inch - (int)inch;
	inch = (int)inch;
	//printf("%lf\n",temp);
	if(temp > test)
		inch += 1;
	if(inch == 12)
	{
		inch = inch-12;
		feet += 1;
	}
	printf("%d %.0lf\n",feet,inch);
	return 0;
}

#include<stdio.h>
main()
{
      int n,i,f;
      scanf("%d",&n);
      n=(float)n/3+.5;
      f=n/12;
      i=n-12*f;
      printf("%d %d",f,i);
      return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, a, b;
    scanf("%d",&n);
    a = n/36;
    n %= 36;
    b = (n + 1)/3;
    if (b == 12)
    {
        a++;
        b = 0;
    }
    printf("%d %d",a,b);
    return 0;
}

#include <stdio.h>

int main(){
int n,d,f;
scanf("%d",&n);
if(n%3==0 || n%3==1) d=n/3;
else d=n/3+1;
f=d/12;
d=d%12;
printf("%d %d",f,d);
return 0;
}

#include<stdio.h>
main()
{int n,inch,feet;
scanf("%d",&n);
feet=n/3;
if(n%3==2)
feet++;
printf("%d %d ",feet/12,feet%12);
return 0;
}

#include<stdio.h>
int main()
{
	int a,b,c,d,e;
	scanf("%d",&a);
	b=a/3;
	c=a%3;
	if(c==2)
		b=b+1;
	d=b/12;
	e=b%12;
	printf("%d %d",d,e);
	return 0;
}

#include<stdio.h>
int main()
{
 int n,i;
 scanf("%d",&n);
  i=n%3;
  n=n/3;
  if(i==2)
  n++;
  printf("%d %d",n/12,n%12);
          return(0);
}

#include<stdio.h>
int main()
{
    int n,a,b,in,in2;
    scanf("%d",&n);
    in=n%3;
    in2=n/3;
    if(in==1)in=0;
    else if(in==2) in=1;
    a=in2/12;
    b=in2%12+in;
    a=a+b/12;
    b=b%12;
    printf("%d %d\n",a,b);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d %d",(n+1)/36,(n+1)%36/3);
    return 0;
}

#include <stdio.h>

int main(void) {
	// your code goes here

	int n,i,j;
	scanf("%d",&n);
	j=n;
	n=n/3;
	i=j%3;
	if(i==1)i=0;
	else if(i==2) i=1;
	n=n+i;

	printf("%d %d",n/12,n%12);

	return 0;
}

#include<stdio.h>
//#include<conio.h>
int main()
 {
 int n,c,d,e;
 scanf("%d",&n);
 c=n%3;
 d=n/3;
 if(c==2) d++;
 e=d%12;
 d/=12;
 printf("%d %d",d,e);
 //getch();
 return 0;
 }

#include<stdio.h>

int main(void)
{
  int s, f;
  scanf("%d",&s);
  f = s / 3;
  if (s % 3 > 1) {
	  f++;
  }
  printf("%d %d\n", f / 12, f % 12);
  return 0;
}

#include<stdio.h>
int main()
{
    int n,feet,tmp,inch;
    scanf("%d",&n);
    inch=n/3;
    if(n%3==2)
    {
        inch++;
    }
    feet=inch/12;
    inch=inch%12;
    printf("%d %d\n",feet,inch);
    return 0;
}

#include<stdio.h>
int round(float);
main()
{
    int n;
    scanf("%d",&n);
    int f;
    int i=round(n/3.0);
    printf("%d %d",i/12,i%12);
    return 0;
}
int round(float k)
{
    int p;
    p=k;
    float t=k-p;
    if(t>=0.5) return (p+1);
    if(t<0.5) return (p);

}

//      Measuring Lengths in Baden.c
//
//      Copyright 2012 Administrator <cpy@ubuntu>
//
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.

#include <stdio.h>

void func(int n)
{
	int a, b = 0;
	a = n / 36;
	n %= 36;
	b = n / 3;
	n %= 3;
	if (n == 2)
	{
		b ++;
		if (b >= 12)
		{
			a += (b * 3) / 36;
			b = b - (b * 3) / 36 * 12;
		}
	}
	printf("%d %d\n", a, b);
}

int main(int argc, char **argv)
{
	int n;
	while (scanf("%d", &n) == 1)
	{
		func(n);
	}
	return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int feet = n/36;
    int remainer = n%36;
    int inches = 0;
    if(remainer >= 3){
        inches = remainer/3;
        remainer = remainer%3;
    }
    remainer = (remainer == 2) ? 1 : 0;
    inches += remainer;
    if (inches >= 12) {
        feet += inches/12;
        inches = inches%12;
    }
    printf("%d %d\n", feet, inches);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{int a,b,c,d,e,f;
scanf("%d",&a);
b=a/3;
c=a%3;
if(c==2)
    {d=b+1;}
else
    {d=b;}
    e=d/12;
    f=d%12;
    printf("%d %d",e,f);
    return 0;
}

int main(void)
{
    int n;
    scanf("%d", &n);
    int d = (n + 1) / 3, f = d / 12;
    d -= f * 12;
    printf("%d %d", f, d);
    return 0;
}

int main(void)
{
    int n;
    scanf("%d", &n);
    int d = (n + 1) / 3, f = d / 12;
    d %= 12;
    printf("%d %d", f, d);
    return 0;
}

#include <stdio.h>

int main(int argc, char *argv[])
{
	int n;

	scanf("%d", &n);

	printf("%d %d\n", (n + 1) / 3 / 12, (n + 1) / 3 % 12);

	return 0;
}

#include<stdio.h>
#include<math.h>
#include <string.h>
#define N 100011

char str[N];

int main()
{
    int n;
    int a,b;
    while(scanf("%d", &n) != EOF) {
        a = n / 3;
        if(n % 3 >= 2) a++;
        b = a / 12;
        a %= 12;
        printf("%d %d\n", b, a);
    }
    return 0;
}

#include<stdio.h>

int main()
{
	int n;
	int feet,inches;

	while(scanf("%d",&n) != EOF) {
		n += 1;
		inches = n / 3;
		printf("%d %d\n",inches / 12 ,inches % 12);
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main(void){
int a ,b,c ;
div_t op;
scanf("%d",&a);

op=div(a,36);
b=op.quot;

op=div(op.rem,3);
c=op.quot;
if(op.rem==2){c=c+1;}
if(c==12){b++;
c=0;}
    printf("%d  ",b);
    printf("%d",c);
    return 0;
}

#include <stdio.h>

int main(void) {
    int n,a,b,k;
    scanf("%d", &n);
    k = n / 3;
    if (n % 3 == 2)
        k++;
    a =  k / 12;
    n -= 36*a;
    b = n / 3;
    if (n % 3 == 2)
        b++;
    printf("%d %d", a, b);
    return 0;
}

#include<stdio.h>

int main() {

	int n;
	int foot, inch;

	scanf("%d",&n);

	foot = n/36;

	inch = (n-foot*36 +1)/3;

	if (inch == 12) {
		foot++;
		inch = 0;
	}

	printf("%d %d\n", foot,inch);

	return 0;
}

#include<stdio.h>
int round(float);
main()
{
    int n;
    scanf("%d",&n);
    int i=round(n/3.0);
    printf("%d %d",i/12,i%12);
    return 0;
}
int round(float k)
{
    int p;
    p=k;
    float t=k-p;
    if(t>=0.5) return (p+1);
    if(t<0.5) return (p);
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, a, b, c;
    scanf ("%d", &n);
    printf("%d ",a = (n+1) / 36);
    b = n - a * 36;
    c = b / 3;
    if (b - c * 3 > 1) c++;
    printf ("%d", c);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,a,b;
    scanf("%d",&n);
    b=n/3;
    if(n%3==2)
    ++b;
    a=b/12;
    b%=12;
    printf("%d %d",a,b);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
int cm,ft,inches;
scanf("%d",&cm);
inches=cm/3;
if(cm%3>1)
    inches++;
ft=inches/12;
inches=inches%12;

printf("%d %d",ft,inches);
//  system("Pause");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{

	int n;
	int feet;
	int inch;

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

		scanf("%d", &n);

		feet = n / 36;
		inch = n % 36;

		inch = (inch + 1 )/3;

		if (inch == 12)
		{
			feet++;
			inch = 0;
		}
		printf("%d %d\n", feet, inch);

	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    // read number
    int cm;
    scanf("%d", &cm);

    // figure out feet
    int ft = cm/36;

    // figure out inches
    int inch_in_cm = cm - ft*36;
    int inches = inch_in_cm/3;
    int rem_inches = (inch_in_cm - inches*3) % 3;

    if (rem_inches > 1)
        inches++;

    // in case ft rounds up
    if (inches == 12)
    {
        inches = 0;
        ft++;
    }

    printf("%d %d\n", ft, inches);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int N,d,f;
  scanf("%d",&N);
  d = N/3;
  if(N%3>1){
		d++;
	}
	f = d/12;
	d = d - f*12;
	printf("%d %d\n", f, d);
  //system("PAUSE");
  return 0;
}

#include <stdio.h>

int main()
{
   int cm, feet, inch ;

   scanf("%d", &cm) ;

   for(inch=0; cm>1; ++inch)
        cm = cm - 3 ;

    for(feet=0; inch>=12; ++feet)
        inch = inch - 12 ;

   printf("%d %d", feet, inch);

    return 0 ;
}

#include<stdio.h>

int main()
{
    int n,feet,rem,inch;
    scanf("%d",&n);
    feet=n/36;
    rem=n%36;
    inch=rem/3;
    if(rem%3==2)inch++;
    if(inch==12)feet++;

    printf("%d %d\n",feet,inch);
}

#include<stdio.h>

int main()
{
    int n,feet,rem,inch;
    scanf("%d",&n);
    feet=n/36;
    rem=n%36;
    inch=rem/3;
    if(rem%3==2)inch++;
    printf("%d %d\n",feet,inch);
}

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<math.h>

main()
{
    int i,j, cm, feet, inch;

    scanf("%d", &cm);

    feet=cm/36;

    inch=(int)ceil((double)(cm%36)/3);

    printf("%d %d",feet, inch);
}

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<math.h>

main()
{
    int i,j, cm, feet, inch;
                                                        //1 feet= 12 inc
    scanf("%d", &cm);                                   //1 inch = 3 cm

    feet=cm/36;

    inch=(cm%36)/3;

    inch=(int)ceil((cm%36)/3.0) ;

    printf("%d %d",feet, inch);
}

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<math.h>

main()
{
    int i,j, cm, feet, inch;

    scanf("%d", &cm);

    feet=cm/36;

    inch=round((cm%36)/3);

    printf("%d %d",feet, inch);
}

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<math.h>

main()
{
    int i,j, cm, feet, inch=0;
                                                        //1 feet= 12 inc
    scanf("%d", &cm);                                   //1 inch = 3 cm

    feet=cm/36;

    inch=(cm%36)/3;
    if(cm%3==2){inch++;};

    printf("%d %d",feet, inch);
}

#include <stdio.h>

int main()
{
    int f,i,c;
    scanf("%d",&c);
    f=c/36;
    c=c%36;
    i=c/3;
    c=c%3;
    if(c==2)
    i++;
    printf("%d %d",f,i);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,feet,inch;
    scanf("%d",&n);
    feet=n/36;
    n=n%36;

    if(n%3==0||n%3==1)
    {
        inch=n/3;
    }

    else if(n%3==2)
    {
        inch=n/3+1;
    }
    printf("%d %d",feet,inch);
    return 0;

}

#include<stdio.h>
int main()
{
    int n,r,f,i;
    scanf("%d",&n);
    r=n/3;
    n%=3;
    f=r/12;
    r%=12;

    if(n<2)
    n=0;
    else if(n>1)
    n=1;
    i=r+n;
    printf("%d %d",f,i);
}

#include<stdio.h>
int main()
{
	int n, i,feet, inch, cen,k,r, t;
	scanf("%d", &cen);
	inch=cen/3;
	r=cen%3;
	if(r==2)
	{
		inch=inch+1;
	}
	//printf("%d\n", inch);
	feet=inch/12;
	inch=inch%3;

	printf("%d %d ",feet, inch);
}

#include <stdio.h>
int main()
{
	long long int num,a,b,c;
	scanf("%lld",&num);
	a=num/36;
	b=num-(a*36);
	c=b/3;
	if(b%3==2)
	{
		c++;
	}
	else
	c=c;

	printf("%lld %lld\n",a,c);
}

#include <stdio.h>
int main()
{
	long long int num,a,b,c;
	scanf("%lld",&num);
	a=num/36;
	b=num-(a*36);
	c=b/3;
	if(b%3==0)
	{
		c=c;
	}
	else
	c++;

	printf("%lld %lld\n",a,c);
}

#include <stdio.h>

int main()

{
    int i,f,c,temp=0;
    scanf("%d", &c);

    f=c/36;

    if(c%36!=0)
        c%36==temp;
    temp==i;
    i=temp/3;
    printf("%d %d",f,i);
}

#include <stdio.h>

int main()

{
    int i,f,c,temp;
    scanf("%d", &c);

    f=c/36;

    if(c%36!=0)
        c%36==temp;
    temp==i;
    i=temp/3;
    printf("%d %d",f,i);
}

#include <stdio.h>

int main()

{
    int i,f,c,temp;
    scanf("%d", &c);

    f=c/36;

    if(c%36!=0)
        temp==c%36;
    temp=i;
    i=temp/3;
    printf("%d %d",f,i);
}

#include <stdio.h>

int main()

{
    int i,f,c,temp;
    scanf("%d", &c);

    f=c/36;

    if(c%36==0)
        c%36==temp;
    temp==i;
    i=temp/3;
    printf("%d %d",f,i);
    return 0;
}

#include <stdio.h>

int main()

{
    int i,f,c,temp;
    scanf("%d", &c);

    f=c/36;

    if(c%36!=0)
        c%36==temp;
    temp==i;
    i=temp/3;
    printf("%d %d",f,i);
    return 0;
}

#include<stdio.h>
#define test 0.5

int main()
{
	double n,inch,temp;
	int feet;
	scanf("%lf",&n);
	inch = n/3;
	//printf("%lf\n",inch);
	feet = inch/12;
	inch = inch - (12*feet);
	//printf("%lf\n",inch);
	temp = inch - (int)inch;
	inch = (int)inch;
	//printf("%lf\n",temp);
	if(temp > test)
		inch += 1;

	printf("%d %.0lf\n",feet,inch);
	return 0;
}

#include<stdio.h>
main()
{
      int n,i,f;
      scanf("%d",&n);
      f=(float)n/36+.5;
      n=n-f*36;
      i=(float) n/3+.5;
      printf("%d %d",f,i);
      return 0;
}

#include<stdio.h>
main()
{
      int n,i,f;
      scanf("%d",&n);
      f=n/36;
      n=n-f*36;
      i=(float) n/3+.5;
      printf("%d %d",f,i);
      return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, a, b;
    scanf("%d",&n);
    a = n/36;
    n %= 36;
    b = (n + 1)/3;
    printf("%d %d",a,b);
    return 0;
}

#include <stdio.h>
int main()
{
    int a,b,c,n;
    scanf("%d",&n);
    a=n / 36 ;
    c=n % 36;
    b=c / 3;
    if (c % 3 >= 2)
    {
        b++;}
    printf("%d %d",a,b);
    return 0;
}

#include<stdio.h>
int main()
{
 int n,i;
 float m;
 scanf("%d",&n);
 i=n/36;
 n=n%36;
 if(i==0)
 printf("0");
 else
 printf("%d",i);
         m=(float)n;
         m=m/3;
         n=n/3;
         if(m-n>0.5)
         printf(" %d",n+1);
         else
         printf(" %d",n);
          return(0);
}

#include<stdio.h>
int main()
{
	int S,N,K,T,Y;
	scanf("%d",&S);
	T=S;
	N=S/36;
	Y=S%36;
	S=S/36;
	if(T%3<2)
	K=(Y/3);
	else
	K=(Y/3)+1;
	printf("%d %d",N,K);
	return 0;
}

#include<stdio.h>
int main()
{
int n,feet,inch=0,t;
scanf("%d",&n);
feet=n/36;
t=n%36;
while(t>3)
{
t=t-3;
inch++;
}
if(t>=2)inch++;
printf("%d %d",feet,inch);
return 0;
}

#include<stdio.h>
int main()
{
long int n,feet,inch=0,t,p;
scanf("%ld",&n);
feet=n/36;
t=n%36;
inch=t/3;
p=t%3;
if(p>=2)inch++;
printf("%ld %ld",feet,inch);
return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d %d",n/36,n%36/3);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d %d",n/36,(n%36+1)/3);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d %d",n/36,(n%36)/3);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int s, d, f;
	scanf("%i",  &s);
	f = s / 36;
	d = (s - f*36) / 3;
	if ((s - f*36) - d*3 > 0) {
		d++;
	}
	printf("%d %d\n", f, d);
	return 0;
}

#include<stdio.h>
int main()
{
    int n,feet,tmp,inch;
    scanf("%d",&n);
    feet=n/36;
    tmp=n%36;
    inch=tmp/3;
    if(tmp%3==2)
                inch++;
    printf("%d %d\n",feet,inch);
    return 0;
}

//      Measuring Lengths in Baden.c
//
//      Copyright 2012 Administrator <cpy@ubuntu>
//
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.

#include <stdio.h>

void func(int n)
{
	int a, b;
	a = n / 36;
	n %= 36;
	b = n / 3;
	n %= 3;
	if (n == 2)
	{
		b ++;
	}
	printf("%d %d\n", a, b);
}

int main(int argc, char **argv)
{
	int n;
	while (scanf("%d", &n) == 1)
	{
		func(n);
	}
	return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int feet = n/36;
    int remainer = n%36;
    int inches = 0;
    if(remainer >= 3){
        inches = remainer/3;
        remainer = remainer%3;
    }
    remainer = (remainer == 2) ? 1 : 0;
    inches += remainer;
    printf("%d %d\n", feet, inches);
    return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int feet = n/36;
    int remainer = n%36;
    int inches = remainer/3;
    remainer = remainer%3;
    remainer = (remainer == 2) ? 1 : 0;
    inches += remainer;
    if (feet*36 + inches*3 < n) {
        inches++;
    }
    printf("%d %d\n", feet, inches);
    return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int feet = n/36;
    int remainer = n%36;
    int inches = remainer/3;
    remainer = remainer%3;
    remainer = (remainer == 2) ? 1 : 0;
    inches += remainer;
    printf("%d %d\n", feet, inches);
    return 0;
}

int main(void)
{
    int n;
    scanf("%d", &n);
    printf("%d %d", n / 36, (n % 36 + 1) / 3);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main(void){
int a ,b,c ;
div_t op;
scanf("%d",&a);

op=div(a,36);
b=op.quot;

op=div(op.rem,3);
c=op.quot;
if(op.rem==2){c=c+1;}
    printf("%d  ",b);
    printf("%d",c);
    return 0;
}

#include <stdio.h>

int main(void) {
	int n,a,b;
	scanf("%d", &n);
	b = n / 3;
	if (n % 3 == 2)
		b++;
	a = b / 12;
	printf("%d %d", a, b);
	return 0;
}

#include <stdio.h>

int main(void) {
    int n,a,b,k;
    scanf("%d", &n);
    k = n / 3;
    if (k % 3 == 2)
        k++;
    a =  k / 12;
    n -= 36*a;
    b = n / 3;
    if (b % 3 == 2)
        b++;
    printf("%d %d", a, b);
    return 0;
}

#include <stdio.h>

int main(void) {
    int n,a,b,k;
    scanf("%d", &n);
    k = n / 3;
    if (k % 3 == 2)
        k++;
    a =  k / 12;
    n -= 36*a;
    b = n / 3;
    if (n % 3 == 2)
        b++;
    printf("%d %d", a, b);
    return 0;
}

#include<stdio.h>

int main() {

	int n;
	int foot,inch;

	scanf("%d",&n);

	foot = n/36;

	inch = (n-foot*36 +1)/3;

	printf("%d %d\n", foot,inch);

	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, a, b, c;
    scanf ("%d", &n);
    printf("%d ",a = n+1 / 36);
    b = n - a * 36;
    c = b / 3;
    if (b - c * 3 > 1) c++;
    printf ("%d", c);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, a, b, c;
    scanf ("%d", &n);
    printf("%d ",a = n / 36);
    b = n - a * 36;
    c = b / 3;
    if (b - c * 3 > 1) c++;
    printf ("%d", c);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
int cm,ft,inches;
scanf("%d",&cm);
inches=cm/3;
ft=inches/12;
inches=inches%12;
if(cm%3>1)
    inches++;
printf("%d %d",ft,inches);
//  system("Pause");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{

	int n;
	int foot;
	int inch;

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

		scanf("%d", &n);

		foot = n / 36;
		inch = n % 36;

		inch = (inch + 1 )/3;

		printf("%d %d\n", foot, inch);

	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    // read number
    int cm;
    scanf("%d", &cm);

    // figure out feet
    int ft = cm/36;

    // figure out inches
    int inch_in_cm = cm - ft*36;
    int inches = inch_in_cm/3;
    int rem_inches = (inch_in_cm - inches*3) % 3;

    if (rem_inches > 1)
        inches++;

    printf("%d %d\n", ft, inches);
    return 0;
}

#include <stdio.h>

int main()
{
	int n,g,h,i,j;
	scanf("%d",&n);
	g=n/36;
	h=n%36;
	i=h/3;
	j=h%3;
	if (j==2){
		i=i+1;
	}
	printf("%d %d",g,i);
	return 0;
}


The Little Elephant loves chess very much. One day the Little Elephant and his friend decided to play chess. They've got the chess pieces but the board is a problem. They've got an 8 × 8 checkered board, each square is painted either black or white. The Little Elephant and his friend know that a proper chessboard doesn't have any side-adjacent cells with the same color and the upper left cell is white. To play chess, they want to make the board they have a proper chessboard. For that the friends can choose any row of the board and cyclically shift the cells of the chosen row, that is, put the last (rightmost) square on the first place in the row and shift the others one position to the right. You can run the described operation multiple times (or not run it at all).For example, if the first line of the board looks like that "BBBBBBWW" (the white cells of the line are marked with character "W", the black cells are marked with character "B"), then after one cyclic shift it will look like that "WBBBBBBW".Help the Little Elephant and his friend to find out whether they can use any number of the described operations to turn the board they have into a proper chessboard.

The input consists of exactly eight lines. Each line contains exactly eight characters "W" or "B" without any spaces: the j-th character in the i-th line stands for the color of the j-th cell of the i-th row of the elephants' board. Character "W" stands for the white color, character "B" stands for the black color. Consider the rows of the board numbered from 1 to 8 from top to bottom, and the columns — from 1 to 8 from left to right. The given board can initially be a proper chessboard.

In a single line print "YES" (without the quotes), if we can make the board a proper chessboard and "NO" (without the quotes) otherwise.

WBWBWBWB
BWBWBWBW
BWBWBWBW
BWBWBWBW
WBWBWBWB
WBWBWBWB
BWBWBWBW
WBWBWBWB

WBWBWBWB
WBWBWBWB
BBWBWWWB
BWBWBWBW
BWBWBWBW
BWBWBWWW
BWBWBWBW
BWBWBWBW

NoteIn the first sample you should shift the following lines one position to the right: the 3-rd, the 6-th, the 7-th and the 8-th.In the second sample there is no way you can achieve the goal.

#include<stdio.h>
#include<stdlib.h>
char s[8][9]={"WBWBWBWB","BWBWBWBW","WBWBWBWB","BWBWBWBW","WBWBWBWB","BWBWBWBW","WBWBWBWB","BWBWBWBW"};
int test(char s[],char x[]);
main()
{
    //freopen("input","r",stdin);
   int i,j,k,l=0,t;
   char x[12][12];
   for(i=0;i<8;i++)
    scanf("%s",x[i]);
   for(i=0;i<8;i++)
   {
       t=test(x[i],s[i]);
       if(t)
        l++;
   }
   if(l==8)
    printf("YES\n");
   else
    printf("NO\n");

    return 0;
}
int test(char x[],char s[])
{
    int i,j,k,l=0,pos=-99;
    for(i=0;i<8;i++)
    {
        if(s[0]==x[i])
        {
            pos=i;
            break;
        }
    }
    if(pos!=-99)
    {
        for(i=pos,j=0;i<8;i++,j++)
        {
            if(s[i]==x[j])
            l++;
        }
        for(i=0;i<pos;i++)
        {
            if(s[i]==x[j])
            l++;
        }
        if(l==8)
        return 1;
        else
        return 0;
    }
    else
        return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{
    int i,l,count=0,t=8;
    char a[10];
    while(t--){
    gets(a);
    if(count==0){for(i=0;i<7;i++){
        if(a[i]==a[i+1]){count++;}
    }}}
    if(count){printf("NO");}
    else{printf("YES");}
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
    int i,flag=0;
 char a[9]="BWBWBWBW",b[9]="WBWBWBWB",s[9];
 for(i=0;i<8;i++)
 {
 gets(s);
 if ((strcmp(s,a)!=0)&&(strcmp(s,b)!=0))
 {
    flag=1;
 }
 }
 if(flag==0)
   printf("YES");
else
    printf("NO");

return 0;
}

#include<stdio.h>
//#include<stdlib.h>
int main(){
    short i = 0,j = 0,k = 0;
    char a='a',b='a';
    for(i=0;i<8;i++){
    b='a';
        for(j=0;j<8;j++){
                         a=getchar();
                         if(a==b) k=1;
                         b=a;
        }
        getchar();
    }
    if(k==1) printf("NO\n");
    else printf("YES\n");
  //  system("pause");
    return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>

int main()
{
	int n=8,f=0;
        char a[n][n];
        for(int i=0;i<n;i++)
        {
                scanf("%s",a[i]);
        }
        for(int i=0;i<n;i++)
        {
                int c=0;
                for(int j=0;j<n-1;j++)
                {
                        if(a[i][j]==a[i][j+1])
                        {
                                c=1;
                                break;
                        }
                }
                if(c==1)
                {
                        f=1;
                        break;
                }
        }
        if(f==1)
        printf("NO");
        else
        printf("YES");
        return 0;
}

#include<stdio.h>
int main()
{
    char a[8][9];
    int i,j,flag=0;
    for(i=0;i<8;i++)
    {
        scanf("%s",a[i]);
        for(j=0;j<7;j++)
        {
            if(a[i][j]==a[i][j+1])
            {
                flag=1;
                break;
            }
        }
        if(flag)
         break;
    }
    if(flag)
    printf("NO\n");
    else
    printf("YES\n");
    return 0;
}

#include<stdio.h>
int main()
{
    int t=8,a=0,b=0;
    char x[10];
    while(t--)
    {
        scanf("%s",x);
        if(strcmp(x,"BWBWBWBW")==0)
        a++;
        else
        {if(strcmp(x,"WBWBWBWB")==0)
        b++;}
    }

    if(a==4 && b==4 || a+b==8 )
    {
        printf("YES");
    }
    else
    printf("NO");

    return 0;
}

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {
  int c, d, res = 1;
  for (d = EOF; c = getchar (), c != EOF; d = c)
    res &= c != d;
  printf ("%s\n", res ? "YES" : "NO");
  exit (EXIT_SUCCESS);
}

#include <stdio.h>

int main(){

    int j,i;
    char str[8][8];
    for(i=0; i<8; ++i)
        scanf("%s", str[i]);

    for(i=0; i<8; ++i)
    {
        for(j=0; j<7; ++j)
            if(str[i][j]==str[i][j+1])
            {
                printf("NO\n");
                return 0;
            }
    }

    printf("YES\n");

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
//#include <ctype.h>
//#include <string.h>
//#include <math.h>
int main()
{
   int i,j,f=0;
   char s[9][9];
   for(i=0;i<8;i++)
    gets(s[i]);
   for(i=0;i<8;i++)
   {
      // gets(s);
       for(j=0;j<7;j++)
       {
           if(s[i][0]==s[i][7] ||s[i][j]==s[i][j+1])
           {
               f=1;
               break;
           }

       }
       if(f==1)
        break;
   }
   if(f==0)
    printf("YES");
   else
    printf("NO");
    return 0;
}

#include<stdio.h>
int main()
{
    char ara[9][9];
    int i,j,s=0;
    for(i=0;i<8;i++){
        scanf("%s",ara[i]);
    }
    for(i=0;i<8;i++){
        for(j=0;j<7;j++){
            if(ara[i][j]==ara[i][j+1]){
                s=1;
                break;
            }
        }
    }
    if(s==0)printf("YES");
    else printf("NO");
    return 0;

}

#include<stdio.h>
int main()
{
    int t=8,a=0,b=0;
    char x[10];
    while(t--)
    {
        scanf("%s",x);
        if(strcmp(x,"BWBWBWBW")==0)
        a++;
        else
        {if(strcmp(x,"WBWBWBWB")==0)
        b++;}
    }

    if(a+b==8)
    {
        printf("YES");
    }
    else
    printf("NO");

    return 0;
}

#include<stdio.h>
int main()
{
    int flag=0,i;
    char ch[10];
    for(i=0;i<8;i++)
    {
        gets(ch);
        if(strcmp(ch,"WBWBWBWB") && (strcmp(ch,"BWBWBWBW")))
            return printf("NO\n"),0;
    }
    printf("YES\n");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j;
    char temp;
    char ch[8][8];

    for(i = 0; i < 8 ; i++)
    {
        temp = 'A';
        for(j = 0 ; j < 8 ; j++)
        {
            scanf("%c",&ch[i][j]);
            if(temp == ch[i][j])
            {
                printf("NO\n");
                return 0;
            }
            temp = ch[i][j];
        }
        scanf("%c",&temp);
    }
    printf("YES\n");
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, const char* argv[])
{
	int i;
	char line[10];
	for (i = 0; i < 8; i++) {
		fgets(line, sizeof(line), stdin);
		if (line[0] == line[2] && line[2] == line[4] && line[4] == line[6] &&
		    line[1] == line[3] && line[3] == line[5] && line[5] == line[7] &&
			line[0] != line[1])
			continue;
		printf("NO\n");
		return 0;
	}
	printf("YES\n");

    return 0;
}

#include <stdio.h>
#include <string.h>

typedef char string[80];

int IsSelangSeling(string Kata, int Idx)
{
	if (Kata[Idx] == '\0') return 1;
	else if ((Idx+1) % 8 == 0)
	{
		Idx = Idx + 1;
		return IsSelangSeling(Kata,Idx);
	}
	else
	{
		if (Kata[Idx] == Kata[Idx+1]) //bukan selang-seling
		{
			return 0;
		}
		else
		{
			Idx = Idx + 1;
			return IsSelangSeling(Kata,Idx);
		}
	}
}

int main()
{
	string Kata;
	char CC;
	int W = 0;
	int B = 0;
	int i=0;

	while (i <= 63)
	{
		scanf("%c",&CC);
		if (CC != '\n')
		{
			Kata[i] = CC;
			i++;
		}

	}
	Kata[i] = '\0';

	if (IsSelangSeling(Kata,0))
		printf("YES");
	else
		printf("NO");

	return 0;
}

#include<stdio.h>

void solve(char s[][10])
{
    int i,j;

    for(i=0;i<8;++i)
    {
        for(j=0;j<7;++j)
        {
            if(s[i][j]==s[i][j+1])
            {
                printf("NO\n");
                return;
            }
        }
    }
    printf("YES\n");
}

int main(void)
{
    char s[10][10];
    int i;
    while(scanf("%s",s[0])!=EOF)
    {
        for(i=1;i<8;++i)
            scanf("%s",s[i]);
        solve(s);
    }
}

#include<stdio.h>
#define FLUSH while(getchar()!='\n')
int main()
{
     char c;
     int f=0,j=0;
     char b[9];
     int i=0;
     for(i=0;i<8;i++)
     {

	  scanf("%s",b);
	  FLUSH;
	  c=b[0];
	for(j=0;j<7;j++)
	  if(b[j]==b[j+1])f=-1;
	if(b[0]==b[7])f=-1;
     }
     if(f==-1)printf("NO");
     else printf("YES");

     return 0;
}

#include<stdio.h>
#include<string.h>
int main() {
	int i,j,kont=1;
	char arr[8][8];
	for(i=0;i<8;i++)
		for(j=0;j<8;j++)
	scanf(" %c",&arr[i][j]);
	for(i=0;i<8;i++){
		for(j=1;j<8;j++)
		if(arr[i][j]==arr[i][j-1])
			kont=0;
	}
	if(kont)
		printf("YES");
	else printf("NO");
return 0 ;
}

#include <stdio.h>

int main() {
	int i, j, c1, c2, good;
	static char s[9];

	for (i = 0; i < 8; i++) {
		scanf("%s", s);
		c1 = s[0], c2 = s[1];
		good = 1;
		for (j = 0; j < 8; j += 2)
			if (s[j] != c1) {
				good = 0;
				break;
			}
		for (j = 1; j < 8; j += 2)
			if (s[j] != c2) {
				good = 0;
				break;
			}
		if (!good || c1 == c2) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

#include<stdio.h>

int main() {
	int i,j;
	char board[8][8];
	for(i=0;i<8;i++){
		for(j=0;j<8;j++){
			board[i][j]=getchar();
		}
		getchar();//去掉每一行的换行符号！
	}
	int is_ok=1;
	for(i=0;i<8 && is_ok;i++){
		for(j=0;j<8-1;j++){
			if(board[i][j]==board[i][j+1]){
				is_ok=0;
				break;
			}
		}
	}
	if(is_ok)printf("YES\n");
	else printf("NO\n");

	return 0;
}

#include<stdio.h>
char board[8][8];
int check_row(int row){
	int i;
	for(i=0;i<8-1;i++){
		if(board[row][i]==board[row][i+1])
			return 0;
	}
	return 1;
}
int main() {
	int i,j;
	for(i=0;i<8;i++){
		for(j=0;j<8;j++){
			board[i][j]=getchar();
		}
		getchar();//去掉每一行的换行符号！
	}
	int is_ok=1;
	for(i=0;i<8;i++){
		if(!check_row(i)){
			is_ok=0;
			break;
		}
	}
	if(is_ok)printf("YES\n");
	else printf("NO\n");

	return 0;
}

#include <stdio.h>
char a[10];
int main()
{
    int i,j,flag=1;
    for(i=0;i<8;i++)
    {
        scanf("%s",a);
        for(j=0;j<7;j++)
            if(a[j]==a[j+1])
                flag=0;
    }
    puts(flag?"YES":"NO");
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
    int i,flag=0;
 char a[9]="BWBWBWBW",b[9]="WBWBWBWB",s[9];
 for(i=0;i<8;i++)
 {
 gets(s);
 if ((strcmp(s,a)!=0)&&(strcmp(s,b)!=0))
 {
    flag=1;
 }
 }
 if(flag==0)
   printf("YES");
else
    printf("NO");

return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>

#define PI 3.141592653589793
#define max(a,b) (a < b) ? (b) : (a)
#define min(a,b) (a > b) ? (b) : (a)
#define FOR(i,a,b) for(i = a ; i <= b ; i++)
#define ROF(i,a,b) for(i = a ; i >= b ; i--)
#define RAD(x) ((x)*PI)/180
#define y1 y_1
#define ll long long
#define endl printf("\n")
#define MAX 105

int i, j;
char b[MAX][MAX];

int main () {
	scanf("%s %s %s %s %s %s %s %s",b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7]);
	FOR(i,0,7)
		FOR(j,0,6)
			if(b[i][j] == b[i][j+1]){
				printf("NO\n");
				return 0;
			}
	printf("YES\n");
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main (void) {
  int c, d, res = 1;
  for (d = EOF; c = getchar (), c != EOF; d = c)
    res &= c != d;
  printf ("%s\n", res ? "YES" : "NO");
  exit (EXIT_SUCCESS);
}

#include <stdio.h>
int main(int argc, const char * argv[]) {
    char a[8][8];
    int flag=1,i,j;
    for(i = 0 ; i < 8 ; i++){
        scanf("%s",a[i]);
        for( j=1;j<8;j++)
            if(a[i][j]==a[i][j-1]){
                flag=0;
            }
    }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int i,t,k;
    char s[8][8];

    for(i=0;i<8;i++)
    {
        scanf("%s",s[i]);
    }
    for(i=0;i<8;i++)
    {
        for(k=0;k+1<8;k++)
        {
            if(s[i][k]==s[i][k+1])
                {
                    printf("NO");
                    return 0;
                }

    else{
            t=0;

    }
        }

    }
    if(t==0)
    printf("YES");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,flag=0;
    char a[8][10];
    for(i=0;i<8;i++)
    {
                    scanf("%s",a[i]);
    }
    for(i=0;i<8;i++)
    {
                    if(strcmp(a[i],"BWBWBWBW")==0 || strcmp(a[i],"WBWBWBWB")==0)
                    {
                                                  continue;
                    }
                    else
                    {
                        flag=1;
                        break;
                    }
    }
    if(flag==0)
               printf("YES\n");
    else
               printf("NO\n");
    return 0;
}

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char cb[8][8];
    int i;
    for(i=0;i<8;i++)
    {
        gets(cb[i]);
    }
    int t,j;
    for(i=0;i<8;i++)
    {
        for(j=0;j+1<8;j++)
        {
            if(cb[i][j]==cb[i][j+1])
            {
                printf("NO");
                return 0;
            }
            else
                t=1;
        }
    }
    if(t>0)
        printf("YES");
    return 0;
}

#include<stdio.h>
int main()
{
    char a[8][9];
    int i,count,j;
    for(i=0;i<8;i++)scanf("%s",&a[i]);
    for(i=0;i<8;i++)
    {
        for(j=1;j<8;j++)
        {
            if(a[i][j]==a[i][j-1])
            {
                printf("NO");
                return 0;
            }
        }
    }
    printf("YES");
    return 0;

}

#include <stdio.h>
#include <string.h>
int main(){ //freopen("in.txt", "r", stdin);
    int i, j;
    char s[10];
    for(i = 0; i < 8; i++){
        scanf("%s", s);
        for(j = 1; j < 8; j++)
            if(s[j-1] == s[j]) {
                printf("NO\n");
                return 0;
            }
    }
    printf("YES\n");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char s[8][8];
    int i,flag=0,j;
    for(i=0;i<8;i++)
        scanf("%s",s[i]);
    for(i=0;i<8;i++)
    {
        for(j=0;j+1<8;j++)
        {
            if(s[i][j]==s[i][j+1])
                {
                    printf("NO");
                    return 0;
                }
            else
            flag=1;
        }

    }
    if(flag==1)
        printf("YES");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main(){
	int i,j;
	char arr[8][8];
	for(i=0;i<8;i++)
		for(j=0;j<8;j++)
		scanf(" %c",&arr[i][j]);
	int f=0;
	 for(i=0;i<8;i++)
		   for(j=0;j<7;j++)
		 if(arr[i][j]!=arr[i][j+1])
						 f=1;
		 else {
			 printf("NO");
       return 0;
		 }
	 if(f)
		 printf("YES");
}

#include<stdio.h>
int main()
{
    int t=8,a=0,b=0;
    char x[10];
    while(t--)
    {
        scanf("%s",x);
        if(strcmp(x,"BWBWBWBW")==0)
        a++;
        else
        {if(strcmp(x,"WBWBWBWB")==0)
        b++;}
    }

    if(a==4 && b==4 || a+b==8 )
    {
        printf("YES");
    }
    else
    printf("NO");

    return 0;
}

#include<stdio.h>
int main()
{
    char c[9][9];
    int f=0,i,j;
    for(i=0;i<8;i++)
    scanf("%s",c[i]);
    for(i=0;i<8;i++)
    {
        for(j=0;j<7;j++)
        {
            if(c[i][j]==c[i][j+1])
            {
                f=1;break;
            }
        }
        if(f==1)
        break;
    }
    if(f==1)
    printf("NO\n");
    else
    printf("YES\n");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char a[8];
    int i,j;
    for(i=0;i<8;i++)
    {
        scanf("%s",a);
        if(strcmp(a,"WBWBWBWB") && strcmp(a,"BWBWBWBW"))
        {
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;

}

#include<stdio.h>
int main()
{
    char a[8][9];
    int i,j,flag=0;
    for(i=0;i<8;i++)
    {
        scanf("%s",a[i]);
        for(j=0;j<7;j++)
        {
            if(a[i][j]==a[i][j+1])
            {
                flag=1;
                break;
            }
        }
        if(flag)
         break;
    }
    if(flag)
    printf("NO\n");
    else
    printf("YES\n");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,j;
    char str[8][9];
    for(i=0;i<8;i++)
    {
       gets(str[i]);
    }
    int k,flag=0;
    //if(str[0][0] == 'B')
      //flag=1;
    for(i=0;i<8;i++)
    {
       for(j=0,k=j+1;j<7 && k<8;j++,k++)
       {
             if(str[i][j] == str[i][k])
             {
                flag=1;
                break;
             }
       }
       if(flag==1)
         break;
    }
    if(flag==1)
      printf("NO");
    else
      printf("YES");
    return 0;
}

#include<stdio.h>
int main()
{
    char s[10],a=0,b=0;
    int i;
    for(i=0; i<8; i++)
    {
        scanf(" %s",s);
        for(int j=0; j<8-1; j++)
        {
            if(s[j]==s[j+1])
                a=1;
        }
    }
    if(a!=1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
             int i,j;
             char a[8][8];
             for(i=0;i<8;i++) scanf("%s",a[i]);
             for(i=0;i<8;i++)
                 for(j=1;j<8;j++) {
                      if(a[i][j-1]==a[i][j]) {
                           printf("NO");
                           exit(0);
                          }
                      }
             printf("YES");
             return 0;
}

#include<stdio.h>

int main()
{
	char str[10];
	int x;
	int y=8;
	int flag=0;
	char cl;

	while(y--)
	{
		scanf("%s",str);
		cl=str[0];
		for(x=1;x<8;x++)
		{
			if(cl==str[x])
				flag=1;
			cl=str[x];
		}
	}
	if(flag==1)
	printf("NO");
	else
	printf("YES");
	return 0;
}

#include <stdio.h>
#include <string.h>

char s[9][9] ;

int i , j , k ;
int main()
{
    for( i = 0 ; i < 8 ; i++)
    {
        scanf("%s", s[i] )  ;
    }
     for( i = 0 ; i < 8 ; i++)
    {
         k = 0 ;
         for( j = 0 ; j < 7 ; j ++)
    {
         if( s[i][j] == s[i][j+1] )
         {
                printf("NO" ) ;
                return 0 ;
         }
    }
    }

    printf("YES") ;

 return 0 ;
 }

#include <stdio.h>

int main(){

    int count=0;
    int j,i;
    char str[8][8];
    while(count<8){
        scanf("%s", str[count]);
        ++count;
    }
    for(i=0; i<8; ++i)
    {
        for(j=0; j<7; ++j)
            if(str[i][j]==str[i][j+1])
            {
                printf("NO\n");
                return 0;
            }
    }

    printf("YES\n");

    return 0;
}

#include <stdio.h>
#define n 8

int main()
{
	char b[9][9];
	int i;
	for(i=0;i<8;i++)
		scanf("%s",b[i]);
	int j;
	int flag = 0;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(b[i][j] == b[i][(j+1)%n])
				flag = 1;
		}
	}

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

#include <stdio.h>

int main(){

    int j,i;
    char str[8][8];
    for(i=0; i<8; ++i)
        scanf("%s", str[i]);

    for(i=0; i<8; ++i)
    {
        for(j=0; j<7; ++j)
            if(str[i][j]==str[i][j+1])
            {
                printf("NO\n");
                return 0;
            }
    }

    printf("YES\n");

    return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
	char map[10][10];
	int i,j;
	for (i = 0; i < 8; i++)
	{
		for (j = 0; j < 8; j++)
		{
			scanf("%c",&map[i][j]);
		}
		getchar();
	}

/*		printf("\n");
	for (i = 0; i < 8; i++)
	{
		for (j = 0; j < 8; j++)
		{
			printf("i:%d j:%d %c",i,j,map[i][j]);
		}
		printf("\n");
	}
	printf("\n");
	*/
	int flag = 0;
	for (i = 0; i < 8; i++)
	{
		if (map[i][0] == map[i][7])
		{
//			printf("%d\n",i);
			flag = 1;
			break;
		}
		for (j = 0; j < 7; j++)
		{
			if (map[i][j] == map[i][j+1])
			{
//				printf("%c",map[i][j]);
				flag = 1;
				break;
			}
		}
//		printf("\n");
		if (flag)
		  break;
	}
	if (flag)
	  printf("NO\n");
	else
	  printf("YES\n");
	return 0;
}

#include<stdio.h>
int main(){
    char map[10][10],tag;
    int i,j,flag=1,sum;
    for(i=0;i<8;i++)
        scanf("%s",map[i]);

    for(i=0;i<8;i++){
        sum=0;
        tag=0;
        for(j=1;j<8;j++)
            if(map[i][j]==map[i][j-1]){
                tag=1;
                break;
            }
        if(tag)break;
    }
    printf("%s\n",tag==0?"YES":"NO");
    return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
    char a [9] [9];
    int i, j;

    for (i = 0; i < 8; i ++) {
        for (j = 0; j < 8; j ++) {
            scanf(" %c", &a [i]  [j]);
        }
    }

    for (i = 0; i < 8; i ++) {
        for (j = 0; j < 8; j ++) {
            if (a [i] [j] == a [i] [j + 1]) {
                printf("NO");
                return 0;
            }
        }
    }

    printf("YES");

    return 0;
}

#include<stdio.h>
#define FLUSH while(getchar()!='\n')
int main()
{
     char c;
     int f=0,j=0;
     char b[9];
     int i=0;
     for(i=0;i<8;i++)
     {

	  scanf("%s",b);
	  FLUSH;
	  c=b[0];
	for(j=0;j<7;j++)
	  if(b[j]==b[j+1])f=-1;
	if(b[0]==b[7])f=-1;
     }
     if(f==-1)printf("NO");
     else printf("YES");

     return 0;
}

#include<stdio.h>

int main()
{
    int i, j, k;
    char a[9][9];
    for(i=0; i<8; i++){
        gets(a[i]);
    }
    for(i=0; i<8; i++){
        for(j=0; j<7; j++){
            if((a[i][j])==a[i][j+1]){
                printf("NO");
                return 0;
            }
        }
    }
    printf("YES");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char a[8];
    int i,j;
    for(i=0;i<8;i++)
    {
        scanf("%s",a);
        if(strcmp(a,"WBWBWBWB") && strcmp(a,"BWBWBWBW"))
        {
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;

}

#include<stdio.h>
char board[8][8];
int check_row(int row){
	int before=board[row][0];
	int i;
	for(i=1;i<8;i++){
		if(board[row][i]!=before){
			before=board[row][i];
		}else{
			return 0;
		}
	}
	return 1;
}
int main() {
	int i,j;
	for(i=0;i<8;i++){
		for(j=0;j<8;j++){
			board[i][j]=getchar();
		}
		getchar();//去掉每一行的换行符号！
	}
	int is_ok=1;
	for(i=0;i<8;i++){
		if(!check_row(i)){
			is_ok=0;
			break;
		}
	}
	if(is_ok)printf("YES\n");
	else printf("NO\n");

	return 0;
}

#include <stdio.h>
#include <string.h>

int main() {
	int i, yes;
	static char s[9];

	yes = 1;
	for (i = 0; i < 8; i++) {
		scanf("%s", s);
		if (strcmp(s, "WBWBWBWB") != 0 && strcmp(s, "BWBWBWBW") != 0) {
			yes = 0;
			break;
		}
	}
	printf("%s\n", yes ? "YES" : "NO");
	return 0;
}

#include<stdio.h>
int main(void)
{
	char box[8][8];
	int i,j,count=0;
	for(i=0;i<8;i++)
	scanf("%s",&box[i]);
	for(i=0;i<8;i++)
	{
		for(j=0;j<7;j++)
		{
			if(box[i][j]==box[i][j+1])
			count=1;
		}
	}
	if(count==0)
	printf("YES");
	else
	printf("NO");
	return 0;
}

#include <stdio.h>
#include <string.h>

unsigned validRow(char *s)
{
char chessEven[]="WBWBWBWB";
char chessOdd[]="BWBWBWBW";
unsigned i;

        if(strcmp(s,chessOdd)==0||strcmp(s,chessEven)==0)
            return 1;
        else
            return 0;

}
int main()
{  char s[9][9];
unsigned i=0;
       for(i=0;i<8;i++)
        scanf("%s",s[i]);
        i=0;
       while(i<8&&validRow(s[i]))
         i++;
        if(i<8)
        {
            printf("NO");
        }
        else
            printf("YES");
i=i;
    return 0;
}

#include <stdio.h>
#include <string.h>

int main() {
	int n;

	n = 8;
	while (n--) {
		static char s[9];

		scanf("%s", s);
		if (strcmp(s, "WBWBWBWB") && strcmp(s, "BWBWBWBW")) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

#include<stdio.h>

char s[111][111];

int check()
{
    int i,j;
    for(i=0;i<=7;i++)
      {
        for(j=0;j<=6;j++)
          if(s[i][j]==s[i][j+1])
            return 0;
      }
    return 1;
}

int main()
{
	int i,j;

	for(i=0;i<=7;i++)
	  scanf("%s",s[i]);
	printf("%s\n",check()?"YES":"NO");

	//system("pause");
	return 0;

}

#include <stdio.h>
#include <string.h>

char board[8][9] = {0};

int checkBoard() {
  int i;
  for(i = 0; i < 8; i++) {
    if(strcmp(board[i], "BWBWBWBW") != 0 && strcmp(board[i], "WBWBWBWB") != 0)
      return 0;
  }
  return 1;
}

int main() {
  int i, j;
  char row[20];
  for(i = 0; i < 8; i++) {
    scanf("%s\n", row);
    for(j = 0; j < 8; j++)
      board[i][j] = row[j];
  }

  if(checkBoard())
    printf("YES");
  else
    printf("NO");

  return 0;
}

#include<stdio.h>
#include<string.h>
int main ()
{
	char a[9],b[9],c[9];
	int i,flag=0;
	strcpy(a,"WBWBWBWB");
	strcpy(b,"BWBWBWBW");
	for(i=1;i<=8;i++)
	{
		scanf("%s",c);
		if(strcmp(a,c)!=0&&strcmp(b,c)!=0)
		{
			flag=1;
		}
	}
	if(flag==0)
	printf("YES");
	else printf("NO");
	return 0;
}

#include<stdio.h>
#include<string.h>
int main() {
	int i,j,kont=1;
	char arr[8][8];
	for(i=0;i<8;i++)
		for(j=0;j<8;j++)
	scanf(" %c",&arr[i][j]);
	for(i=0;i<8;i++){
		for(j=1;j<8;j++)
		if(arr[i][j]==arr[i][j-1])
			kont=0;
	}
	if(kont)
		printf("YES");
	else printf("NO");
return 0 ;
}

#include <stdio.h>

int main(void) {
    // your code goes here
    char s[9][9];
    int i;
    for(i=0;i<9;i++){
        scanf("%s",s[i]);
    }
    int j,c=0;
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            if(s[i][j]==s[i][j+1]){
                printf("NO\n");
                c=1;
                break;
            }
        }
        if(c==1)
        break;
    }
    if(c==0){
        printf("YES\n");
    }
    return 0;
}

#include <stdio.h>
#define n 8

int main()
{
	char b[9][9];
	int i;
	for(i=0;i<8;i++)
		scanf("%s",b[i]);
	int j;
	int flag = 0;
	for(i=0;i<n;i++)
	{
		if(b[i][0] == b[i][7])
			flag = 1;
		for(j=1;j<n;j++)
		{
			if(b[i][j] == b[i][j-1])
				flag = 1;
		}
	}

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

#include<stdio.h>
#include<stdlib.h>

int main()
{
	char ch[8][8];
	int i,j;
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
			scanf("%c",&ch[i][j]);
		scanf("%*C");
	}
	for(i=0;i<8;i++)
	{
		for(j=0;j<7;j++)
		{
			if(ch[i][j] == ch[i][j+1])
			{
				printf("NO\n");
				return 0;
			}
		}
	}
	printf("YES\n");
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	char box[8][8],ch='B',temp;
	int i,j,k,FLAG=0;
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			scanf("%c",&box[i][j]);
			if(box[i][j-1]==box[i][j]&&j!=0)
			FLAG=1;
		}
	}

	if(FLAG==1)
	{
	  printf("NO");
	  exit(0);
	}
	else
	{

	j=0;
	 for(i=1;i<8;i++)
	 {

		if(box[i-1][j]==box[i][j])
			{
				temp=box[i][7];
				for(k=7;k>0;k--)
				{
					box[i][k]=box[i][k-1];
				}
				box[i][0]=temp;
     		}

	 }
	}
	printf("YES");
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	char box[8][8],ch='B',temp;
	int i,j,k,FLAG;
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			scanf("%c",&box[i][j]);
			if(box[i][j-1]==box[i][j])
			FLAG=1;
		}
	}

	if(FLAG==1)
	{
	  printf("NO");
	  exit(0);
	}
	else
	{

	j=0;
	 for(i=1;i<8;i++)
	 {

		if(box[i-1][j]==box[i][j])
			{
				temp=box[i][7];
				for(k=7;k>0;k--)
				{
					box[i][k]=box[i][k-1];
				}
				box[i][0]=temp;
     		}

	 }
	}
	printf("YES");
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	char box[8][8],ch='B',temp;
	int i,j,k;
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			scanf("%c",&box[i][j]);
		}
	}
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			if(j==0)
			{
				if(ch!=box[i][j])
				{
					ch=box[i][j];
				}
				else
				{
					temp=box[i][7];
					for(k=7;k>0;k--)
					{
						box[i][k]=box[i][k-1];
					}
					box[i][0]=temp;
					ch=temp;
				}
			}
			if(j<7)
			{
				if(box[i][j]==box[i][j+1])
				{
					printf("NO");
					exit(0);
				}
			}
		}
	}
	printf("YES");
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	char box[8][8],ch='B',temp;
	int i,j,k,FLAG=0;
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			scanf("%c",&box[i][j]);
			if(box[i][j-1]==box[i][j])
			FLAG=1;
		}
	}

	if(FLAG==1)
	{
	  printf("NO");
	  exit(0);
	}
	else
	{

	j=0;
	 for(i=1;i<8;i++)
	 {

		if(box[i-1][j]==box[i][j])
			{
				temp=box[i][7];
				for(k=7;k>0;k--)
				{
					box[i][k]=box[i][k-1];
				}
				box[i][0]=temp;
     		}

	 }
	}
	printf("YES");
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	char box[8][8],ch='B',temp;
	int i,j,k,FLAG=0;
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			scanf("%c",&box[i][j]);
			if(box[i][j-1]==box[i][j]&&j!=0)
			FLAG=1;
		}
	}

	if(FLAG==1)
	{
	  printf("NO");
	  exit(0);
	}
	else if(FLAG==0)
	{

	j=0;
	 for(i=1;i<8;i++)
	 {

		if(box[i-1][0]==box[i][0])
			{
				temp=box[i][7];
				for(k=7;k>0;k--)
				{
					box[i][k]=box[i][k-1];
				}
				box[i][0]=temp;
     		}

	 }
	}
	printf("YES");
	return 0;
}

#include<stdio.h>
int main(){
    char map[10][10];
    int i,j,flag=1,sum,tag=1;
    for(i=0;i<8;i++)
        scanf("%s",map[i]);

    for(i=0;i<8;i++){
        sum=0;
        if(map[i][0]=='B'&&map[i][7]=='B'){tag=0;break;};
        for(j=0;j<8;j++)
            if(map[i][j]=='W')sum++;
        if(sum!=4){
            flag=0;
            break;
        }
    }
    printf("%s\n",tag&&flag?"YES":"NO");
    return 0;
}

#include <stdio.h>

int main()
{
    int i,j;
    char t,x;
    for(i=1;i<=8;i++){
        scanf("%c",&t);
        for(j=2;j<=8;j++){
            scanf("%c",&x);
            if(x==t){
                printf("NO");
                return 0;
            }
            else t=x;
        }
        printf("\n");
    }
    printf("YES");
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, const char* argv[])
{
	int i;
	char line[10];
	for (i = 0; i < 8; i++) {
		fgets(line, sizeof(line), stdin);
		if (line[0] == line[2] && line[2] == line[4] && line[4] == line[6] &&
		    line[1] == line[3] && line[3] == line[5] && line[5] == line[7])
			continue;
		printf("NO\n");
		return 0;
	}
	printf("YES\n");

    return 0;
}

#include<stdio.h>
int main()
{
    int t=8,a=0,b=0;
    char x[10];
    while(t--)
    {
        scanf("%s",x);
        if(strcmp(x,"BWBWBWBW")==0)
        a++;
        else
        {if(strcmp(x,"WBWBWBWB")==0)
        b++;}
    }

    if(a==4 && b==4)
    {
        printf("YES");
    }
    else
    printf("NO");

    return 0;
}

#include <stdio.h>
#include <string.h>

typedef char string[10];

int IsSelangSeling(string Kata, int Idx)
{
	if (Idx == 8) return 1;
	else
	{
		if (Kata[Idx] == Kata[Idx+1]) //bukan selang-seling
			return 0;
		else
		{
			Idx = Idx + 1;
			return IsSelangSeling(Kata,Idx);
		}
	}
}

int main()
{
	string Kata;
	int W = 0;
	int B = 0;
	int i;
	int IsValid; ///hanya true false

	IsValid = 1;

	for (i=1;i<=8;i++)
	{
		fgets(Kata,sizeof(Kata),stdin);
		Kata[strlen(Kata)-1] = '\0';
		IsValid = IsValid && IsSelangSeling(Kata,0);
		fflush(stdin);
	}

	if (IsValid)
		printf("YES");
	else
		printf("NO");

	return 0;
}

#include<stdio.h>
#include<string.h>
int main(){
	int i,j;
	char arr[8][8];
	for(i=0;i<8;i++)
		for(j=0;j<8;j++)
		scanf("%c",&arr[i][j]);
	int f=0;
	 for(i=0;i<8;i++)
		   for(j=0;j<7;j++)
		 if(arr[i][j]!=arr[i][j+1])
						 f=1;
		 else {
			 printf("NO");
       return 0;
		 }
	 if(f)
		 printf("YES");
}

#include <stdio.h>

int main(void) {
	// your code goes here
	int i,j;
	char arr[8];
	for(i=1;i<=8;i++)
	{
	    scanf("%s",arr);
	    for(j=0;j<7;j++)
	    {
	        if(arr[i]==arr[i+1]){  break;    }
	    }
	    if(j<7){printf("NO"); break;}

	} if(i>8)printf("YES");

	return 0;
}

#include <stdio.h>

int main(void) {
	// your code goes here
	int i,j;
	char arr[8];
	for(i=0;i<8;i++)
	{
	    scanf("%s",arr);
	    for(j=0;j<7;j++)
	    {
	        if(arr[i]==arr[i+1]){  break;    }
	    }
	    if(j<7){printf("NO"); break;}

	} if(i==8)printf("YES");

	return 0;
}

#include<stdio.h>
//#include<stdlib.h>
int main(){
    short i = 0,j = 0,k = 0;
    char a,b,c;
    for(i=0;i<8;i++){
        for(j=0;j<4;j++)
           if(getchar()==getchar()) k=1;
        getchar();
    }
    if(k==0) printf("YES\n");
    else printf("NO\n");
    //system("pause");
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main(){
    short i = 0,j = 0,k = 0;
    char a='a',b='a';
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
                         a=getchar();
                         if(a==b) k=1;
                         b=a;
        }
        getchar();
    }
    if(k==0) printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include<stdio.h>
int main(){
    short i = 0,j = 0,k = 0;
    for(i=0;i<8;i++){
        for(j=0;j<4;j++)
           if(getchar()==getchar()){
                                    printf("YES\n");
                                    return 0;
           }
        getchar();
    }
    printf("NO\n");
    return 0;
}

#include<stdio.h>
//#include<stdlib.h>
int main(){
    short i = 0,j = 0,k = 0;
    char a='a',b='a';
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
                         a=getchar();
                         if(a==b) k=1;
                         b=a;
        }
        getchar();
    }
    if(k==0) printf("YES\n");
    else printf("NO\n");
    return 0;
}

//Created by Pratik Paras Mandlecha
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
	int n=0,i,j;
	char s,a[8][8];
	for(i=0;i<8;i++)
	for(j=0;j<8;j++)
	scanf("%c",&a[i][j]);
	for(i=0;i<8;i++)
	for(j=1;j<8;j++)
		if(a[i][j]==a[i][j-1]) n++;
	if(n==0) printf("YES");
	else printf("NO");
	return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
	char map[9][9];
	int i,j;
	for (i = 0; i < 8; i++)
	{
		for (j = 0; j < 8; j++)
		{
			scanf("%c",&map[i][j]);
		}
	}
	int flag = 0;
	for (i = 0; i < 8; i++)
	{
		for (j = 0; j < 7; j++)
		{
			if (map[i][j] == map[i][j+1])
			{
				flag = 1;
				break;
			}
		}
		if (flag)
		  break;
	}
	if (flag)
	  printf("NO\n");
	else
	  printf("YES\n");
	return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
	char map[9][9];
	int i,j;
	for (i = 0; i < 8; i++)
	{
		for (j = 0; j < 8; j++)
		{
			scanf("%c",&map[i][j]);
		}
	}
	int flag = 0;
	for (i = 0; i < 8; i++)
	{
		if (map[i][7] == map[i][0])
		{
			flag = 1;
			break;
		}
		for (j = 0; j < 7; j++)
		{
			if (map[i][j] == map[i][j+1])
			{
				flag = 1;
				break;
			}
		}
		if (flag)
		  break;
	}
	if (flag)
	  printf("NO\n");
	else
	  printf("YES\n");
	return 0;
}

#include<stdio.h>
#include<string.h>
int main() {
	int i,j,kont=1;
	char arr[8][8];
	for(i=0;i<8;i++)
		for(j=0;j<8;j++)
	scanf(" %c",&arr[i][j]);
	for(i=0;i<8;i++){
		for(j=0;j<8;j++)
		if(arr[i][j]==arr[i][j+1])
			kont=0;
	}
	if(kont==1)
		printf("YES");
	else printf("NO");
return 0 ;
}

#include<stdio.h>
#include<string.h>
int main() {
	int i,j,kont=1;
	char arr[8][8];
	for(i=0;i<8;i++)
		for(j=0;j<8;j++)
	scanf(" %c",&arr[i][j]);
	for(i=0;i<8;i++){
		for(j=0;j<8;j++)
		if(arr[i][j]==arr[i][j+1])
			kont=0;
	}
	if(kont)
		printf("YES");
	else printf("NO");
return 0 ;
}

#include<stdio.h>

void solve(char s[][10])
{
    int i,j;

    for(i=0;i<8;++i)
    {
        for(j=0;j<7;++j)
        {
            if(s[i][j]==s[i][j+1])
            {
                printf("%s\n",s[i]);
                printf("NO\n");
                return;
            }
        }
    }
    printf("YES\n");
}

int main(void)
{
    char s[10][10];
    int i;
    while(scanf("%s",s[0])!=EOF)
    {
        for(i=1;i<8;++i)
            scanf("%s",s[i]);
        solve(s);
    }
}

#include<stdio.h>
#include<string.h>
int main()
{
	char str[8][9];
	int i, j, flag = 0;
	for(i=0; i<8; i++)
	{
		for(j=0; j<8; j++)
		{
			scanf(" %c", &str[i][j]);
			if((j!=0 && str[i][j-1] == str[i][j]))
				flag = 1;
			printf("%d %d\n", i, j);
		}
	}
	if(flag)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
	char str[8][9];
	int i, j, flag = 0;
	for(i=0; i<8; i++)
	{
		for(j=0; j<8; j++)
		{
			scanf("%c", &str[i][j]);
			if((j!=0 && str[i][j-1] == str[i][j]) || (j==7 && str[i][0]==str[i][7]))
				flag = 1;
		}
	}
	if(flag)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
	char str[8][9];
	int i, j, flag = 0;
	for(i=0; i<8; i++)
	{
		for(j=0; j<8; j++)
		{
			scanf("%c", &str[i][j]);
			if((j!=0 && str[i][j-1] == str[i][j]))
				flag = 1;
		}
	}
	if(flag)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}

#include <stdio.h>
#include <string.h>

char s[9][9] ;

int i , j , k ;
int main()
{
    for( i = 0 ; i < 8 ; i++)
    {
        scanf("%s", s[i] )  ;
    }
     for( i = 0 ; i < 8 ; i++)
    {
         k = 0 ;
         for( j = 0 ; j < 7 ; j ++)
    {
         if( s[i][j] == s[i][j+1] )
         {
             k++ ;
         }
    }
    if( k > 1)
    {
        printf("NO" ) ;
        return 0 ;
    }
    }
    printf("YES") ;

 return 0 ;
 }

#include <stdio.h>

int main() {
	int i, j, c1, c2, good;
	static char s[9];

	for (i = 0; i < 8; i++) {
		scanf("%s", s);
		c1 = s[0], c2 = s[1];
		good = 1;
		for (j = 0; j < 8; j += 2)
			if (s[j] != c1) {
				good = 0;
				break;
			}
		for (j = 1; j < 8; j += 2)
			if (s[j] != c2) {
				good = 0;
				break;
			}
		if (!good) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

#include <stdio.h>
#include <string.h>

int main ()
{
    int i, sum = 0;

    char str[100];
    char str1[] = "WBWBWBWB";
    char str2[] = "BWBWBWBW";

    for(i = 0; i < 8; i++)
    {
        scanf("%s", str);

        if(strcmp(str, str1) == 0 || strcmp(str, str2) == 0) sum++;
    }
    printf("%d\n", sum);

    if(sum == 8)
        printf("YES");

    else printf("NO");

    return 0;
}

int main(){
    int i,j,k;
    char str[8][8];
    for(i=0;i<8;i++)scanf("%s",str[i]);
    i=0;
    while(i<8){
        if(strstr(str[i],"AA")>0 && strstr(str[i],"BB")>0){
            printf("NO");
            return 0;
        }
        i++;
    }
    printf("YES");
    return 0;
}

int main(){
    int i,j,k;
    char str[8][8];
    for(i=0;i<8;i++)scanf("%s",str[i]);
    i=0;
    while(i<8){
        if(strstr(str[i],"WW")>0 && strstr(str[i],"BB")>0){
            printf("NO");
            return 0;
        }
        i++;
    }
    printf("YES");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char a[8];
    int i,j;
    for(i=0;i<8;i++)
    {
        scanf("%s",a);
        if(strcmp(a,"WBWBWBWB")==1 && strcmp(a,"BWBWBWBW")==1)
        {
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;

}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i, j;
    char s[10], a, b;
    for (i = 0; i < 8; i++){
        scanf("%s", &s);
        for (j = 0; j < 8; j++){
            if (j == 0) a = s[j];
            else if (j == 1) b = s[j];
            else if ((j % 2) && (s[j] != b)){
                printf("NO\n");
                return 0;
            }else if ((j % 2 == 0) && (s[j] != a)){
                printf("NO\n");
                return 0;
            }
        }
    }
    printf("YES\n");
    return 0;
}

#include<stdio.h>

int main()
{
    int i;
    char ch[8];
    for(i=0;i<8;i++)
    {
        scanf("%s",ch);
        if(strcmp(ch,"WBWBWBWB") || strcmp(ch,"BWBWBWBW"))
            return printf("NO\n"),0;
    }
    printf("YES\n");
    return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main()
{
	char ch[8][8];
	int i,j;
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
			scanf("%c",&ch[i][j]);
	}
	for(i=0;i<8;i++)
	{
		for(j=0;j<7;j++)
		{
			if(ch[i][j] == ch[i][j+1])
			{
				printf("NO\n");
				return 0;
			}
		}
	}
	printf("YES\n");
	return 0;
}

#include <stdio.h>
#include <string.h>
int main()
{
    char S[9];
    int W,B;
    int i,j;
    int Wrong;
    W=0;B=0;
    Wrong=0;
    for (i=1;i<=8;i++)
    {
        scanf("%s",S);
        if (S[0]=='W')
        {
            W++;}
        else
        {
            B++;}
        j=1;
        while ((Wrong==0) && (j<=8))
        {
            if (S[j]=='W' && S[j-1]!='B')
            {
                Wrong=1;}
            else if (S[j]=='B' && S[j-1]!='W')
            {
                Wrong=1;}
            j++;
        }
    }
    if (Wrong==1)
    {
        printf("NO");}
    else
    {
        if (W==B)
        {
            printf("YES");}
        else
        {
            printf("NO");}
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	char box[8][8],ch='B',temp;
	int i,j,k;
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			scanf("%c",&box[i][j]);
		}
		printf("\n");
	}
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			if(j==0)
			{
				if(ch!=box[i][j])
				{
					ch=box[i][j];
				}
				else
				{
					temp=box[i][7];
					for(k=7;k>0;k--)
					{
						box[i][k]=box[i][k-1];
					}
					box[i][0]=temp;
					ch=temp;
				}
			}
			if(j<7)
			{
				if(box[i][j]==box[i][j+1])
				{
					printf("NO");
					exit(0);
				}
			}
		}
	}
	printf("YES");
	return 0;
}

#include<stdio.h>
#include<string.h>
int main ()
{
	char a[9],b[9],c[9];
	int i,flag=0;
	strcpy(a,"wbwbwbwb");
	strcpy(b,"bwbwbwbw");
	for(i=1;i<=8;i++)
	{
		scanf("%s",c);
		if(strcmp(a,c)!=0&&strcmp(b,c)!=0)
		{
			flag=1;
		}
	}
	if(flag==0)
	printf("YES");
	else printf("NO");
	return 0;
}

#include<stdio.h>
#include<string.h>
int main(){
    char *str1="WBWBWBWB";
    char *str2="BWBWBWBW";
    char s[9][9];
    int n=0,m=0,i;
    for(i=0;i<8;++i)
        scanf("%s",s[i]);
    for(i=0;i<8;++i){
        if(strcmp(s[i],str1)==0)
            n++;
        if(strcmp(s[i],str2)==0)
            m++;
    }
    //printf("%d %d",m,n);
    if(n==4&&m==4)
        printf("YES\n");
    else
        printf("NO\n");
return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j;
    char temp;
    char ch[8][8];

    for(i = 0; i < 8 ; i++)
    {
        temp = 'A';
        for(j = 0 ; j < 8 ; j++)
        {
            scanf("%c",&ch[i][j]);
            if(temp == ch[i][j])
            {
                printf("NO\n");
                return 0;
            }
            temp = ch[i][j];
        }
    }
    printf("YES\n");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>

char M[16][16];
int Old, New;
int x, y, Ans;

int main(){
    while(~scanf("%s", M[0])){
        for (y=1; y<8; y++) scanf("%s", M[y]);
        Ans = 0;
        for (x=0; x<8; x++) if (M[0][x]=='W'){
            Ans = 1;
            Old = x;
            break;
        }
        if (Ans==0){
            printf("NO\n");
            continue;
        }

        for (y=0; y<8; y++) for (x=0; x<8; x++) M[y][x+8] = M[y][x];

        for (y=1; y<8; y++){
            for (New=0; New<8; New++){
                Ans = 1;
                for (x=0; x<8; x++) if (M[y][New+x]==M[y-1][Old+x]) Ans = 0;
                if (Ans) break;
            }

            if (Ans){
                Old = New;
                continue;
            }

            break;
        }
        if (Ans) printf("YES\n");
        else printf("NO\n");

    }

    return 0;
}

#include<stdio.h>

char s[111][111];

int check()
{
    int i,j,count;
    for(i=0;i<=7;i++)
      {
        count=0;
        for(j=0;j<=7;j++)
          if(s[i][j]=='W')
            count++;
        if(count!=4)
          return 0;
      }
    for(i=0;i<=7;i++)
      {
        count=0;
        for(j=0;j<=7;j++)
          if(s[j][i]=='W')
            count++;
        if(count!=4)
          return 0;
      }
    return 1;
}

int main()
{
	int i,j;

	for(i=0;i<=7;i++)
	  scanf("%s",s[i]);
	printf("%s\n",check()?"YES":"NO");

	//system("pause");
	return 0;

}

#include<stdio.h>
int main()
{
    char a,b,c,d,e,f,g,h;
    int i,flag;
    freopen("inp.txt","r",stdin);
    for(i=0;i<8;i++)
    {
        scanf("%c%c%c%c%c%c%c%c",&a,&b,&c,&d,&e,&f,&g,&h);
        if(!((a!=b)&&(b!=c)&&(c!=d)&&(d!=e)&&(e!=f)&&(f!=g)&&(g!=h)))
            {printf("NO");return 0;}
        getchar();
    }
    printf("YES");
    return 0;
}

#include <stdio.h>

int main()
{
	int a, b, d, e;
	char c;
	char ZA[] = {'W', 'B'};

	e = 0;
	for (a = 0; e == 0 && a < 8; ++a) {
		scanf("%c", &c);
		if (c == 'W')
			d = 1;
		else
			d = 0;
		for (b = 0; b < 7; ++b) {
			scanf("%c", &c);
			if (c != ZA[d]) {
				e = 1;
				break;
			} else {
				d = 1 - d;
			}
		}
		scanf("\n");
	}
	if (a == 8)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}

#include <stdio.h>

int main()
{
	int a, b, d, e;
	char c, ZA[] = {'W', 'B'};

	e = 0;
	for (a = 0; e == 0 && a < 8; ++a) {
		scanf("\n%c", &c);
		if (c == 'W')
			d = 1;
		else
			d = 0;
		for (b = 1; b < 8; ++b) {
			scanf("%c", &c);
			if (c == ZA[d]) {
				d = 1 - d;
			} else {
				e = 1;
				break;
			}
		}
	}
	if (a == 8)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,flag=0;
    char a[8][8];
    for(i=0;i<8;i++)
    {
                    for(j=0;j<8;j++)
                    {
                                    scanf("%c",&a[i][j]);
                    }
    }
    for(i=0;i<8;i++)
    {
                    for(j=0;j<7;j++)
                    {
                                    if(a[i][j]==a[i][j+1])
                                    {
                                                          flag=1;
                                                          break;
                                    }
                    }
                    if(flag==1)
                               break;
    }
    if(flag==0)
               printf("YES\n");
    else
               printf("NO\n");
    return 0;
}

#include<stdio.h>
int main()
{
    int i,j,flag=0;
    char a[8][8];
    for(i=0;i<8;i++)
    {
                    for(j=0;j<8;j++)
                    {
                                    scanf("%c",&a[i][j]);
                    }
    }
    for(i=0;i<8;i++)
    {
                    for(j=0;j<7;j++)
                    {
                                    if(a[i][j]==a[i][j+1])
                                    {
                                                          flag=1;
                                                          break;
                                    }
                                    if(flag==1)
                                               break;
                    }
    }
    if(flag==0)
               printf("YES\n");
    else
               printf("NO\n");
    return 0;
}

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {
  int freq[1 << CHAR_BIT] = {0}, c;
  while (c = getchar (), c != EOF) {
    ++freq[c];
  }
  printf ("%s\n", freq['W'] == freq['B'] ? "YES" : "NO");
  exit (EXIT_SUCCESS);
}

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {
	int freq[1 << CHAR_BIT] = {0}, c;
	while (c = getchar (), c != EOF) {
		++freq[c];
	}
	printf ("%s\n", freq['W'] == freq['B'] ? "YES" : "NO");
	exit (EXIT_SUCCESS);
}

#include<stdio.h>
#include<string.h>
int main()
{
    char c[8][8];
    int i,j,k=0;
    for(i<0;i<8;i++)
    {
        scanf("%s",c[i]);
    }
    for(i<0;i<8;i++)
    {
        for(j=0;(j+1)<8;j++)
        {
            if(c[i][j]==c[i][(j+1)])
            {
                printf("no");
                return 0;
            }
            else
                k=1;
        }
    }
    if(k==1)
    {
        printf("yes");
        return 0;
    }

}

#include<math.h>
#include<stdio.h>
char c[8][8];
main()
{
    int i,j,k,flag=0;
    for(i=0;i<8;i++)
    scanf("%s",&c[i][0]);
    for(i=0;i<8;i++)
    {
        for(j=0;j<7;j++)
        {
            if(c[i][j]==c[i][j+1])
            {
                flag=1;
                break;
            }

        }
        if(flag==1)
            break;

    }
    if(flag==1)
    printf("N0\n");
    else
    printf("YES\n");
    return 0;
}

#include<stdio.h>
#include<string.h>

main()
{
freopen("b.txt","r",stdin);
int t=8,j,k,flag=0,i;
char a[20];
for(k=0;k<8;k++)
{
scanf("%s",a);
a[8]=a[0];
for(i=0;i<8;i++){if(a[i]==a[i+1])flag=1;}
}
if(flag)printf("NO\n");
else printf("YES\n");
return 0;

}

#include<stdio.h>
int main () {
	char str[8][8];
	int j,i;

	for(i=0;i<8;i++)
		for(j=0;j<8;j++)
			scanf("%c",&str[i][j]);

	for(i=0;i<8;i++){
		for(j=0;j<7;j++)
			if(str[i][j]==str[i][j+1]){
				printf("NO");
				return 0;
			}
		}
			printf("YES");
}

#include <stdio.h>
#include <string.h>
int main(){ //freopen("in.txt", "r", stdin);
    int i;
    char a[10];
    for(i = 1; i <= 8; i++){
            scanf("%s", &a[i]);
    }
    if(a[1] == a[8]){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,j;
    char str[8][9];
    for(i=0;i<8;i++)
    {
       gets(str[i]);
    }
    int k,flag=0;
    if(str[0][0] == 'B')
      flag=1;
    for(i=0;i<8;i++)
    {
       for(j=0,k=j+1;j<7 && k<8;j++,k++)
       {
             if(str[i][j] == str[i][k])
             {
                flag=1;
                break;
             }
       }
       if(flag==1)
         break;
    }
    if(flag==1)
      printf("NO");
    else
      printf("YES");
    return 0;
}

#include<stdio.h>
int main()
{
    int i,j;
    int c=0;
    char arra[8][8];
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            scanf("%c",&arra[i][j]);
        }}
    for(i=0;i<8;i++){
        for(j=0;j<7;j++){
            if(arra[i][j]==arra[i][j+1]){
                c=1;
                break;

            }

        }
        if(c==1){
            printf("NO");
            break;}
    }
    if(i==8 && j==6)printf("YES");
    else printf("NO");
    return 0;
}

#include <stdio.h>

int main(){
    char mat[8][8];
    for(int i=0;i<8;i++){
        for(int j=0;j<8;j++){
            scanf(" %c", &mat[i][j]);
        }
    }
    for(int i=0;i<8;i++){
        for(int j=0;j<8;j++){
            printf("%c ", mat[i][j]);
        }printf("\n");
    }
    for(int i=0;i<8;i++){
        char c = mat[i][0];
        for(int j=1;j<8;j++){
            if(c==mat[i][j]){printf("NO");return 0;}
            c=mat[i][j];
        }
    }
    printf("YES");
    return 0;
}

#include <stdio.h>

char s[8][9];
int i, j;

int main()
{
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            scanf("%c",&s[i][j]);
            if(j>0)
            {
                if(s[i][j]==s[i][j-1])
                {
                    printf("NO");
                    return 0;
                }
            }
        }
    }
    printf("YES");
    return 0;
}

#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<string.h>
#include<windows.h>

#define swap( dtype , a , b) {dtype c; c=a ; a=b ; b=c;}
#define mini(a,b) ((a)<(b)? (a):(b))
#define maxi(a,b) ((a)>(b)? (a):(b))
#define show(x,format) printf(#x "=%" #format "\n",x)
#define clr system("cls")
# define rev(a) a%10*10+a/10

void gxy(short col, short row)
{
	HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD position = { col,row };
	SetConsoleCursorPosition(h, position);
}
int main()
{
	int i,j,w=0,b=0,c=0;
	char str[8];
	for(i=0;i<8;i++){
		scanf("%s" ,&str);
		for(j=0;j<8;j++){
			if(str[j]=='W'){
				if(str[j+1]=='W') c++;
			w++;
			}
			else if(str[j]=='B'){
				if(str[j+1]=='B') c++;
			c++;
			}
		}
	}
	//printf("w=%d\tb=%d" ,w ,b);
	if(w==b&&c==0) printf("YES");
	else printf("NO");
	return 0;
}

#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<string.h>
#include<windows.h>

#define swap( dtype , a , b) {dtype c; c=a ; a=b ; b=c;}
#define mini(a,b) ((a)<(b)? (a):(b))
#define maxi(a,b) ((a)>(b)? (a):(b))
#define show(x,format) printf(#x "=%" #format "\n",x)
#define clr system("cls")
# define rev(a) a%10*10+a/10

void gxy(short col, short row)
{
	HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD position = { col,row };
	SetConsoleCursorPosition(h, position);
}
int main()
{
	int i,j,w=0,b=0,w1=0,b1=0;
	char str[8];
	for(i=0;i<8;i++){
		scanf("%s" ,&str);
		if(str[0]=='W') w1++;
		else b1++;
		for(j=0;j<8;j++){
			if(str[j]=='W') w++;
			else b++;
		}
	}
	//printf("w=%d\tb=%d" ,w ,b);
	if(w==b&&w1==b1) printf("YES");
	else printf("NO");
	return 0;
}

#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<string.h>
#include<windows.h>

#define swap( dtype , a , b) {dtype c; c=a ; a=b ; b=c;}
#define mini(a,b) ((a)<(b)? (a):(b))
#define maxi(a,b) ((a)>(b)? (a):(b))
#define show(x,format) printf(#x "=%" #format "\n",x)
#define clr system("cls")
# define rev(a) a%10*10+a/10

void gxy(short col, short row)
{
	HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD position = { col,row };
	SetConsoleCursorPosition(h, position);
}
int main()
{
	int i,j,w=0,b=0;
	char str[8];
	for(i=0;i<8;i++){
		scanf("%s" ,&str);
		for(j=0;j<8;j++){
			if(str[j]=='W') w++;
			else b++;
		}
	}
	//printf("w=%d\tb=%d" ,w ,b);
	if(w==b) printf("YES");
	else printf("NO");
	return 0;
}


This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any sleep this night at all.In the morning, Vasya was waiting the bus to the university on the bus stop. Vasya's thoughts were hazy and so he couldn't remember the right bus' number quite right and got onto the bus with the number $$$n$$$.In the bus, Vasya thought that he could get the order of the digits in the number of the bus wrong. Futhermore, he could "see" some digits several times, but the digits he saw were definitely in the real number of the bus. For example, if Vasya saw the number 2028, it could mean that the real bus number could be 2028, 8022, 2820 or just 820. However, numbers 80, 22208, 52 definitely couldn't be the number of the bus. Also, real bus number couldn't start with the digit 0, this meaning that, for example, number 082 couldn't be the real bus number too.Given $$$n$$$, determine the total number of possible bus number variants.

The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^{18}$$$) — the number of the bus that was seen by Vasya. It is guaranteed that this number does not start with $$$0$$$.

Output a single integer — the amount of possible variants of the real bus number.

#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <complex.h>
#include <errno.h>
#include <time.h>
int i,d[25],f[25],l;
long long a[25],ans;
char s[25];

void dfs(int x)
{
	int i,sum;
	long long res;

	if (x>=10)
	{
		for (i=0,sum=0;i<=9;i++) sum+=d[i];
		res=(long long) a[sum-1]*(sum-d[0]);
		for (i=0;i<=9;i++) res/=a[d[i]];
		ans+=res;
		return;
	}
	if (!f[x]) dfs(x+1);
	else
	{
		for (i=1;i<=f[x];i++)
		{
			d[x]=i;
			dfs(x+1);
		}
	}
}

int main()
{
	memset(f,0,sizeof(f));
	memset(d,0,sizeof(d));
	scanf("%s",s);
	l=strlen(s);
	for (i=ans=0;i<l;i++) f[s[i]-'0']++;
	for (i=1,a[0]=1;i<=20;i++) a[i]=(long long) a[i-1]*i;
	dfs(0);
	printf("%lld\n",ans);
	return 0;
}

#include <stdio.h>
#include <math.h>
long long fact(long long int n)
{
    long long int ans = 1;
    for (long long int i = 2; i<=n; i++)
        ans*=i;
    return ans;
}

int main()
{
    int h[10] = {},f[10] = {},p,f0,fn0;
    long long int n,temp,ctr = 0;
    scanf("%I64d",&n);
    while(n>0)
    {
        h[n%10]++;
        n/=10;
    }
    outer :while(1)
    {
        f0 = 0, fn0 = 0,p = 9;
        f[9]++;
        while(f[p] > h[p] && p>0)
        {
            f[p] = 0;
            f[--p]++;
        }
        printf("\n");
        if (f[0] > h[0])
            break;
        f0 = f[0];
        for (int i = 1; i<10; i++)
            fn0+=f[i];
        temp = fn0 * fact(fn0 + f0 -1);
        for (int i = 0; i<10; i++)
        {
            if (f[i] == 0 && h[i]!=0)
            {
                temp = 0;
                break;
            }
            temp/=(f[i] > 0)?fact(f[i]) : 1;
        }
        ctr+=temp;
    }
    printf("%I64d",ctr);
    return 0;
}

#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <complex.h>
#include <errno.h>
#include <time.h>
int i,d[25],f[25],l;
long long a[25],ans;
char s[25];

void dfs(int x)
{
	int i,sum;
	long long res;

	if (x>=10)
	{
		for (i=0,sum=0;i<=9;i++) sum+=d[i];
		res=(long long) a[sum-1]*(sum-d[0]);
		for (i=0;i<=9;i++)
		if (d[i]) res/=d[i];
		ans+=res;
		return;
	}
	if (!f[x]) dfs(x+1);
	else
	{
		for (i=1;i<=f[x];i++)
		{
			d[x]=i;
			dfs(x+1);
		}
	}
}

int main()
{
	memset(f,0,sizeof(f));
	memset(d,0,sizeof(d));
	scanf("%s",s);
	l=strlen(s);
	for (i=ans=0;i<l;i++) f[s[i]-'0']++;
	for (i=2,a[1]=1;i<=20;i++) a[i]=(long long) a[i-1]*i;
	dfs(0);
	printf("%lld\n",ans);
	return 0;
}

#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <complex.h>
#include <errno.h>
#include <time.h>
int i,d[25],f[25],l;
long long a[25],ans;
char s[25];

void dfs(int x)
{
	int i,sum;
	long long res;

	if (x>=10)
	{
		for (i=0,sum=0;i<=9;i++) sum+=d[i];
		res=(long long) a[sum-1]*(sum-d[0]);
		for (i=0;i<=9;i++)
		if (d[i]) res/=d[i];
		ans+=res;
		return;
	}
	if (!f[x]) dfs(x+1);
	else
	{
		for (i=1;i<=f[x];i++)
		{
			d[x]=i;
			dfs(x+1);
		}
	}
}

int main()
{
	memset(f,0,sizeof(f));
	memset(d,0,sizeof(d));
	scanf("%s",s);
	l=strlen(s);
	for (i=ans=0;i<l;i++) f[s[i]-'0']++;
	for (i=1,a[0]=1;i<=20;i++) a[i]=(long long) a[i-1]*i;
	dfs(0);
	printf("%lld\n",ans);
	return 0;
}

#include <stdio.h>
#include <math.h>
long long fact(long long int n)
{
    long long int ans = 1;
    for (long long int i = 2; i<=n; i++)
        ans*=i;
    return ans;
}

int main()
{
    int h[10] = {},f[10] = {},p,f0,fn0;
    long long int n,temp,ctr = 0;
    scanf("%I64d",&n);
    while(n>0)
    {
        h[n%10]++;
        n/=10;
    }
    outer :while (1)
    {
        f0 = 0, fn0 = 0,p = 9;
        f[9]++;
        while(f[p] > h[p] && p>0)
        {
            f[p] = 0;
            f[--p]++;
        }
        if (f[0] > h[0])
            break;
        f0 = f[0];
        for (int i = 1; i<10; i++)
            fn0+=f[i];
        temp = fn0 * fact(fn0 + f0 -1);
        for (int i = 0; i<10; i++)
        {
            if (f[i] == 0 && h[i]!=0)
            {
                temp = 0;
                break;
            }
            temp/=(f[i] > 0)?f[i] : 1;
        }
        ctr+=temp;
    }
    printf("%I64d",ctr);
    return 0;
}

#include <stdio.h>
#include <math.h>
long long fact(long long int n)
{
    long long int ans = 1;
    for (long long int i = 2; i<=n; i++)
        ans*=i;
    return ans;
}

int main()
{
    int h[10] = {},f[10] = {},p,f0,fn0;
    long long int n,temp,ctr = 0;
    scanf("%I64d",&n);
    while(n>0)
    {
        h[n%10]++;
        n/=10;
    }
    while (1)
    {
        f0 = 0, fn0 = 0,p = 9;
        f[9]++;
        while(f[p] > h[p] && p>0)
        {
            f[p] = 0;
            f[--p]++;
        }
        if (f[0] > h[0])
            break;
        f0 = f[0];
        for (int i = 1; i<10; i++)
            fn0+=f[i];
        temp = fn0 * fact(fn0 + f0 -1);
        for (int i = 0; i<10; i++)
        {
            temp/=(f[i] > 0)?f[i] : 1;
        }
        ctr+=temp;
    }
    printf("%I64d",ctr);
    return 0;
}


Arkadiy has lots square photos with size a × a. He wants to put some of them on a rectangular wall with size h × w. The photos which Arkadiy will put on the wall must form a rectangular grid and the distances between neighboring vertically and horizontally photos and also the distances between outside rows and columns of photos to the nearest bound of the wall must be equal to x, where x is some non-negative real number. Look on the picture below for better understanding of the statement.  Arkadiy haven't chosen yet how many photos he would put on the wall, however, he want to put at least one photo. Your task is to determine the minimum value of x which can be obtained after putting photos, or report that there is no way to put positive number of photos and satisfy all the constraints. Suppose that Arkadiy has enough photos to make any valid arrangement according to the constraints.Note that Arkadiy wants to put at least one photo on the wall. The photos should not overlap, should completely lie inside the wall bounds and should have sides parallel to the wall sides.

The first line contains three integers a, h and w (1 ≤ a, h, w ≤ 109) — the size of photos and the height and the width of the wall.

Print one non-negative real number — the minimum value of x which can be obtained after putting the photos on the wall. The absolute or the relative error of the answer must not exceed 10 - 6. Print -1 if there is no way to put positive number of photos and satisfy the constraints.

NoteIn the first example Arkadiy can put 7 rows of photos with 5 photos in each row, so the minimum value of x equals to 0.5.In the second example Arkadiy can put only 1 photo which will take the whole wall, so the minimum value of x equals to 0.In the third example there is no way to put positive number of photos and satisfy the constraints described in the statement, so the answer is -1.

#include <stdio.h>
#include <assert.h>

typedef long long ll;
typedef struct pll { ll first,second; } pll;

// a*x+b*y=g, x==0&&y==1||x==1&&y==0||1<=abs(x)<b/g&&1<=abs(y)<a/g&&x*y<0
ll min(ll x,ll y) { return x<y?x:y; }
ll egcd(ll a,ll b,ll *x,ll *y) {
	if(b==0) { *x=1,*y=0; return a; }
	ll g=egcd(b,a%b,x,y);
	ll z=*x; *x=*y; *y=z; *y-=(*x)*(a/b); return g;
}

pll solve(ll a,ll b,ll MOD) { // a*x=b (mod MOD)
	a=(a%MOD+MOD)%MOD;
	b=(b%MOD+MOD)%MOD;
	ll x,y,g=egcd(a,MOD,&x,&y);
	if(x<0) x+=MOD/g,y-=a/g;
	if(b%g!=0) return (pll){-1LL,-1LL};
	return (pll){x*(b/g)%(MOD/g),MOD/g};
}

int a,h,w;
void run() {
	scanf("%d%d%d",&a,&h,&w);
	//(a+h)*nhor = w-h mod (w+a)
	pll nhor=solve(a+h,w-h,w+a);
	if(nhor.first==-1&&nhor.second==-1) { printf("-1\n"); return; }
	pll nvert={((a+h)*nhor.first+h-w)/(w+a),(a+h)*nhor.second/(w+a)};
	//printf("(%lld,%lld) (%lld,%lld)\n",nhor.first,nhor.second,nvert.first,nvert.second);
	assert(((a+h)*nhor.first+h-w)%(w+a)==0); assert((a+h)%nhor.second/(w+a)==0);
	if(nhor.first==0) nhor.first+=nhor.second,nvert.first+=nvert.second;
	if(nvert.first<=0) { ll t=(1-nvert.first+nvert.second-1)/nvert.second; nhor.first+=t*nhor.second,nvert.first+=t*nvert.second; }
	if(w-nhor.first*a<0||h-nvert.first*a<0) { printf("-1\n"); return; }
	ll t=min((w-nhor.first*a)/(nhor.second*a),(h-nvert.first*a)/(nvert.second*a));
	nhor.first+=t*nhor.second,nvert.first+=t*nvert.second;
	//printf("%lld -> %.9lf / %lld -> %.9lf\n",nhor.first,1.0*(w-nhor.first*a)/(nhor.first+1),nvert.first,1.0*(h-nvert.first*a)/(nvert.first+1));
	printf("%.9lf\n",1.0*(w-nhor.first*a)/(nhor.first+1));
}

int main() {
	run();
    return 0;
}