Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?Please help Kolya answer this question.

The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.

Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).

NoteIn the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.

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

int main () {
long long int n;
long long int house = 1234567;
long long int car = 123456;
long long int computer = 1234;
scanf("%lld",&n);
long long int sum = n;

for (int i=0;i<n+1;i = i + house)
	for (int j=0; j<=n-i;j=j+car) {
		if ((n-i - j)%1234==0){
			printf("YES\n");
			return 0;
		}
	}

printf("NO\n");

return 0;
}

#include<stdio.h>

	int main()
	{
		long long int n;
		long long int i,j,z;
		long long int flag = 0;
		scanf("%lld",&n);

		   for(i=0;i< 100000001; i = i + 1234567 )
		       {
				 for(j=i;j< 100000001; j = j + 123456 )
        				 {

						if(n>=j){

						 long long int temp = n-j;
		              	//printf("%d\n",temp);
				        if(temp%1234 == 0)
		                    flag = 1;
				    }

			}
			  if(flag == 1)
			    break;
			}

		if(flag == 1)
		 printf("YES");
		else
		 printf("NO");

		 return 0;
	}

#include<stdio.h>
#include<stdlib.h>
typedef unsigned u;
u ok;
void H(u n)
{
	if(n%1234==0)ok=1;
	return;
}
void G(u n)
{
	u x=123456;
	n+=x;
	do
	{
		if(n>=x)n-=x;
		H(n);
	}
	while(n>=x);
	return;
}
void F(u n)
{
	u x=1234567;
	n+=x;
	do
	{
		if(n>=x)n-=x;
		G(n);
	}
	while(n>=x);
	return;
}
int main()
{
	u n;
	scanf("%u",&n);
	F(n);
	printf(ok?"YES\n":"NO\n");
	return 0;
}

#include <stdio.h>
int main()
{
	int ch=0;
    long long int a=1234567;
    long long int b=123456;
    long long int c=1234;
    long long int i,j;
    long long int n;
    scanf("%I64d",&n);
    for(i=0;i<=1000;i++)
        for(j=0;j<=10000;j++)
        {
            long long int temp=n-a*i-b*j;
            if(temp%1234==0 && temp>=0)
            {
                ch=1;
            }
        }
    if(ch) printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include <stdio.h>

int main()
{
    int N;
    scanf("%d", &N);
    for(int i = 0; i < 100; ++i) {
        for(int j = 0; j < 1000; ++j) {
            int remain = N - i * 1234567 - j * 123456;
            if(remain >= 0 && remain % 1234 == 0) {
                puts("YES");
                return 0;
            }
        }
    }
    puts("NO");
    return 0;
}

#include <stdio.h>
int main()
{
    //printf("Hello World!\n");
    long long int n, a, b;
    scanf("%lld", &n);
    for(a=0; a<=n; a+=1234567)
    {
        for(b=0; b<=n-a; b+=123456)
        {
            if((n-a-b)%1234==0)
            {
                printf("YES");
                return 0;
            }
        }
    }
    printf("NO");
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<limits.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
char arr[2500];

int main(){
	long long a,b,c,d,e; int flag =0;
	long long input; scanf("%lld",&input);
	for(a=0;a<=8200;a++){
		for(b=0;b<=8200;b++){
			int res = (input - ((a*1234567)+(b*123456)) );
			if( (res % 1234 )==0 && (((res/1234)*1234) + a*1234567 + b*123456) == input && res/1234 >=0 ){
				//printf("%lld %lld %lld --%lld %lld\n",a,b,(input - ((a*1234567)+(b*123456)) ) ,a,b );
				printf("YES");
				return 0;
			}
		}
	}
	printf("NO");
}

#include <stdio.h>
const int a=1234567;
const int b=123456;
const int c=1234;
int n;
int main()
{
    scanf("%d",&n);
    for (int i=0;i<=n/a;i++)
        for (int j=0;j<=(n-i*a)/b;j++)
    {
        if ((n-i*a-j*b)%c==0)
        {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

#include<stdio.h>

#define ll long long

int main()
{
    //freopen("in.txt", "r", stdin);

    ll a=1234567, b = 123456, c= 1234;

    ll n, ans, ans2, i, j;
    int flag = 0;

    scanf("%I64d", &n);

    if(n%a == 0 || n%b==0 || n%c == 0) flag = 1;

    ans = 0;

    for(i=1; flag == 0 && ans<=n ; i++) {

        ans2 = ans;

        if( ans2>0 && n%ans2 == 0) flag = 1;

        for(j=1; ans2 <= n && flag == 0 ; j++){

            if( ( n-ans2 ) % c == 0) {
                flag = 1;
                break;
            }

            ans2 = ans + j*b;
            if(n%ans2 == 0) flag = 1;
        }

        ans = i*a;
        if(n%ans==0) flag = 1;
    }

    if(flag == 1) printf("YES\n");
    else printf("NO\n");
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	long int n,a,b;
	scanf("%ld",&n);
	for(a=0;a<=n;a+=1234567)
		for(b=0;b<=n-a;b+=123456)
			if((n-a-b)%1234==0){
				printf("YES\n");
				return 0;
			}
	printf("NO\n");
	return 0;
}

#include <stdio.h>

int n, x, y, z, r;

void input();
int solve();
void output();

int GCD(int a, int b) {
	if (!b) return a;
	else return GCD(b, a%b);
}

int main() {
	input();
	output();
}

void input() {
	scanf("%d", &n);
}

int solve() {
	x = n / 1234567;
	y = n / 123456;

	for(int i=0; i<=x; i++)
		for (int j = 0; j <= y; j++)
			if (n - i * 1234567 - j * 123456 >= 0 && (n - i * 1234567 - j * 123456) % 1234 == 0)
				return 1;

	return 0;
}

void output() {
	if (solve()) printf("YES\n");
	else printf("NO\n");
}

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

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int main(){
    int flag;
    long long n, a, b, c, x, y, z, r, i, j, k;

    while (scanf("%lld", &n) != EOF){
        flag = 0;
        x = 1234567, y = 123456, z = 1234;

        for (a = 0; (a * x) <= n; a++){
            for (b = 0; ((a * x) + (b * y)) <= n; b++){
                r = n - (a * x) - (b * y);
                if ((r % z) == 0) flag = 1;
            }
        }

        if (flag) puts("YES");
        else puts("NO");
    }
    return 0;
}

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

int main()
{
   int64_t n, t;
   scanf("%I64d", &n);

   do
   {
      t = n;
      do
      {
         if(t % 1234 == 0)
         {
            printf("YES\n");
            return 0;
         }
         t -= 123456;
      }
      while(t >= 0);

      n -= 1234567;
   }
   while(n >= 0);

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

#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int n2 = n+1;
    int ans = 0;
    for(;n2 > 0;n2 -= 1234567)
    {
        int n3 = n2;
        for(;n3 > 0;n3 -= 123456)
        {
            if(n3 % 1234 == 1)
            {
                ans = 1;
                goto mark;
            }
        }
    }
mark:if(ans == 1)
        printf("YES");
     else
        printf("NO");
    return 0;
}

#include<stdio.h>

int main()
{
    long long int n;
    long long int i,j,k,a,b,c;
    a=1234567;
    b=123456;
    c=1234;
    int flag=0;
    long long int p;
    scanf("%lld",&n);
    for(i=0;;i++)
    {
        if(i*a>n){break;}
        for(j=0;;j++)
        {
            p=i*a+j*b;
            if(i*a+j*b>n){break;}
            if((n-p)%c==0){flag=1;break;}
        }
    }

    if(flag==1){printf("YES");}
    else printf("NO");

    return 0;
}

#include<stdio.h>
int main()
{
	long int n;
	scanf("%ld",&n);
	int i,j;
	for(i=0;i<=n;i+=1234567)
	{
		for(j=0;j<=n-i;j+=123456)
			if((n-i-j)%1234==0)
			{
				printf("YES\n");
				return 0;
			}
	}
	printf("NO\n");
	return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    for(int a=0;a<=n;a+=1234567)
    {
        for(int b = 0;b<=n-a;b+=123456)
        {
            if((n-a-b)%1234==0)
            {
                printf("YES\n");
                return 0;
            }
        }
    }printf("NO\n");
    return 0;
}

#include <stdio.h>

int main(void) {

	int n,flag=0;
	long long i=0;

	scanf("%d ",&n);

	while(i*1234567<=n)
	{
		long long j=0;

		while(i*1234567+j*123456<=n)
		{
			if((n-i*1234567-j*123456)%1234==0) flag=1;
			j++;
		}

		i++;
	}

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

#include<stdio.h>

int main() {

    int n; scanf("%d",&n);
    int i=0,j=0;
    int rest = n, flag = 0;
    for(i=0; i*1234567<=n;i++)
    {
        rest = n -  i * 1234567;
        for(j=0;j*123456<=rest;j++)
        {
            if( (rest - j*123456)%1234==0) {
                flag=1 ;//Yes
                break;
            }

        }

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

#include <stdio.h>
const int a=1234567;
const int b=123456;
const int c=1234;
int main()
{
	int n,i,j,k;
	scanf("%i",&n);
	for(i=0;i<(n/a+1);i++)
		for(j=0;j<(n/b+1);j++){
			k=n-a*i-b*j;
			if(!(k%1234||k<0)){
				puts("YES");
				return 0;
			}
		}
	puts("NO");
	return 0;
}

#include <stdio.h>

int main(void) {
	long long int n,i,j,k;
	int c=0;
	scanf("%lld",&n);
	for(i=0;i<=n;i=i+1234567)
	 { //printf("i=%lld",i);
	     for(j=0;j<=n;j=j+123456)
	  {//printf("j=%lld",j);
	      k=n-i-j;
	     //k=k/1234;
	   //printf("k=%lld\n",k);
	     if(k>=0&&k%1234==0)
	     {//printf("YES");
	       c=1;
	         break;
	     }
	  }
	  }
	  //printf("c=%d",c);
	  if(c==1)
	    printf("YES");
	   else
	     printf("NO");
	return 0;
}

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

//681B Economy Game.
main()
{
    int n,i,j,flag=0;
    scanf("%d",&n);
    int house=1234567,car=123456,computer=1234;

    int x=n/house;
    int clone=n,c_copy=0;

    for(i=x; house*i>=0;i--)
    {
        clone=n-house*i;
        for(j=0;j*car<=clone;j++)
            {
                c_copy=clone-car*j;
                if(c_copy%computer==0)
                {
                    flag=1;
                    break;
                }
            }

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

#include <stdio.h>
 //Compiler version gcc 6.3.0

 int main(void)
 {
 	int n;
 	scanf("%d", &n);
 	int l1=n/1234567, l2=n/123456;
 	for(int i=0;i<=l1;i++) {
 		for(int j=0; j<=l2; j++) {
 			int s=i*1234567+j*123456;
 			if(s>n) break;
 			if((n-s)%1234==0) {
 				printf("YES");
 				return 0;
 			}
 		}
 	}
 	printf("NO");
 	return 0;
 }

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

int main()
{
   int n,i,j;
   long int r ;
   int flag =0 ;
   scanf("%d",&n);
for (i=0 ; i<=(n/1234567) ; i++)
{

    for (j=0 ; j<=(n/123456) ; j++)
        {
    r=n-i*1234567-j*123456;
    if(r>=0 && r%1234 == 0 ){
        printf("YES");
        flag =1;
        break;
    }
}
if (flag)
break;
}
if (flag == 0 )
printf("NO");
    return 0;
}

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

int main()
{
    long long int sum, a, b;
    scanf("%I64d", &sum);
    for (a = 0; a <= sum/1234567; a++){
        for (b = 0; b <= sum/123456; b++){
            long long int x = (sum - a*1234567 - b*123456);
            if ((x >= 0) && (x % 1234 == 0)){
                printf("YES\n"); return 0;
            }
        }
    }
    printf("NO\n");
    return 0;
}

#include <stdio.h>
const int a=1234567;
const int b=123456;
const int c=1234;
int n;
int main()
{
    scanf("%d",&n);
    for (int i=0;i<=n/a;i++)
        for (int j=0;j<=(n-i*a)/b;j++)
    {
        if ((n-i*a-j*b)%c==0)
        {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

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

int main()
{long long int n;
    scanf("%lld",&n);
for(long long int i=0;i<=n;i+=1234567)
{for(long long int j=0;j<=(n-i);j+=123456)
{if((n-i-j)%(1234)==0)
{printf("YES");
exit(0);}

}}
printf("NO");

return 0;}

#include <stdio.h>
const int House = 1234567;
const int Car = 123456;
const int Computer = 1234;
int main()
{
#ifdef LOCAL
	freopen("test.txt", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    int a = n / House;
    for(int i = 0; i <= a; i++)
    {
        int b = (n - i * House) / Car;
        for(int j = 0; j <= b; j++)
        {
            int c = n - (i * House + j * Car);
            if(c >= 0 && c % Computer == 0)
            {
                puts("YES");
                return 0;
            }
        }
    }
    puts("NO");
}

#include <stdio.h>

int main()
{
	long long n,i,j;
	scanf("%lld",&n);
	for(i=0;i<=n;i+=1234567)
	for(j=0;j<=n-i;j+=123456)
	if((n-i-j)%1234==0)
	{
		printf("YES\n");
		return 0;
	}

	printf("NO\n");

	return 0;
}

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

int main()
{
    long long int i,a,b,j,y,x,m,cur=0,n,t,c1,c2,n1,n2,m1,m2,te,tem,temp;

    long long int sum=0,max=0,ans=0,tl=1,k,w=0,on=0,z=0,wh=0;

        scanf("%lld",&n);
       a=n/1234567;
       b=n/123456;
        for(i=0;i<=a;i++)
            for(j=0;j<=b;j++)
                {
                    te=n-(i*1234567+j*123456);
                    if(te%1234==0&&te>-1)
                    w=1;

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

    return 0;
}

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

int main()
{
   int64_t n, t;
   scanf("%I64d", &n);

   do
   {
      t = n;
      do
      {
         if(t % 1234 == 0)
         {
            printf("YES\n");
            return 0;
         }
         t -= 123456;
      }
      while(t >= 0);

      n -= 1234567;
   }
   while(n >= 0);

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

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
	int a;
	scanf("%d", &a);
	for (int i = 0; i <= a; i += 1234567) {
		for (int j = 0; j <= a - i; j += 123456) {
			if ((a - i - j) % 1234 == 0) {
				printf("YES");
				return 0;
			}
		}
	}
	printf("NO");
	return 0;
}
/* Mon Dec 30 2019 01:14:18 GMT+0300 (MSK) */

#include <stdio.h>

int hcf(long int n1,long int n2)
{
    if (n2!=0)
       return hcf(n2, n1%n2);
    else
       return n1;
}
int main(void) {
	long int n,i,j,a,b,flag=0;
	scanf("%ld",&n);
	a=811;
	b=8101;
	for(i=0;i<=811;i++)
	{
	    for(j=0;j<=8101;j++)
	    {
	        if((n-i*1234567-j*123456)<0)
	        break;
	        if((n-i*1234567-j*123456)%1234==0)
	        {
	            flag=1;
	            break;
	        }
	    }
	    if(flag==1)
	    break;
	}
	if(flag==1)
	printf("YES");
	else
	printf("NO");
	return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int n2 = n+1;
    int ans = 0;
    for(;n2 > 0;n2 -= 1234567)
    {
        int n3 = n2;
        for(;n3 > 0;n3 -= 123456)
        {
            if(n3 % 1234 == 1)
            {
                ans = 1;
                goto mark;
            }
        }
    }
mark:if(ans == 1)
        printf("YES");
     else
        printf("NO");
    return 0;
}

#include <stdio.h>

int main()
{
    long long int a,b,c,n,i,j,flag;
    a = 1234567;
    b = 123456;
    c = 1234;

    while(scanf("%I64d",&n) == 1)
    {
        flag = 0;
        for(i=0;i<=n;i+=a)
        {
            for(j=0;j<=n-i;j+=b)
            {
                if((n-(i+j))%c == 0)
                {
                    printf("YES\n");
                    flag = 1;
                    break;
                }
            }
            if(flag == 1)
                break;
        }
        if(flag == 0)
            printf("NO\n");
    }
    return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    for(int a=0;a<=n;a+=1234567)
    {
        for(int b = 0;b<=n-a;b+=123456)
        {
            if((n-a-b)%1234==0)
            {
                printf("YES\n");
                return 0;
            }
        }
    }printf("NO\n");
    return 0;
}

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

#define HOUSE    (1234567)
#define CAR      (123456)
#define COMPUTER (1234)

int main() {
  bool ok = false;
  int n,nh,ncr,i,j;

  scanf("%d", &n);
  for ( nh = n / HOUSE, i=0; i <= nh; ++i )
    for ( ncr = (n-i*HOUSE) / CAR, j=0; j <= ncr; ++j )
      if ( (n - i*HOUSE - j*CAR) % COMPUTER == 0 )
        ok = true;
  printf("%s\n", ok ? "YES" : "NO");
  return EXIT_SUCCESS;
}

#include<stdio.h>
int main()
{
    int a=1234567,b=123456,c=1234,sum,n,flag=0,i,j,m;
    scanf("%d",&n);
    sum=n;
    if(n%a==0 || n%b==0 || n%c==0) printf("YES\n");
    else{
    for(i=0; flag==0 ;i++)
    {
        sum=n;
        sum=sum-i*a;
        m=sum;
        if(sum<0) break;

        for(j=0; flag==0 ; j++)
        {   //printf("i= %d  j=%d\n",i,j);
            sum=m;
            sum=sum-j*b;
            if(sum<0) break;

            if(sum%c==0) { flag=1; printf("YES\n"); }
            //printf("%d %d\n",sum,sum%c);
        }
    }
    //printf("%d %d\n",i,j);
    if(flag==0) printf("NO\n");
    }

    return 0;
}

#include <stdio.h>
const int a=1234567;
const int b=123456;
const int c=1234;
int main()
{
	int n,i,j,k;
	scanf("%i",&n);
	for(i=0;i<(n/a+1);i++)
		for(j=0;j<(n/b+1);j++){
			k=n-a*i-b*j;
			if(!(k%1234||k<0)){
				puts("YES");
				return 0;
			}
		}
	puts("NO");
	return 0;
}

#include <stdio.h>

int main()
{
    int n;
    int i;
    int j;
    scanf("%d",&n);
    for(i=0;i<=n;i=i+1234567)
    {
        for(j=0;j<=n-i;j=j+123456)
        {
            if((n-i-j)%1234 == 0)
            {
                printf("YES");
                return 0;
            }
        }
    }
    printf("NO");
    return 0;
}

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

#define SET(a,b) memset(a,b,sizeof(a))
#define scan(n) scanf("%d",&n)
#define print(n) printf("%d\n",n)
#define scanl(n) scanf("%lld",&n)
#define printl(n) printf("%lld\n",n)

//stacks
/*void push(int n,int ar[],int i)
{
        ar[i]=n;
        i++;
}
void pop(int ar[],int i)
{
        if(i>0)
        {
                ar[i-1]=0;
                i--;
        }
}*/

//queues
/*void qpush(int ar[],int val,int head,int tail,int range)
{
        if(head==tail)
        {
                ar[head]=val;
                if(tail+1==range)
                        tail=0;
                else
                        tail++;
        }
        else
        {
                ar[tail]=val;
                if(tail+1==range)
                        tail=0;
                else
                        tail++;
        }
        if(tail==head)
        {
                if(head+1==range)
                        head=0;
                else
                        head++;
        }
}

void qpop(int head,int tail,int range)
{
        if(head+1==range)
                head=0;
        else
                head++;
}*/

//pow
/*int fun(int a,int b,int m)
{
        if(b==0)
                return 1;
        int d,x;
        d=fun(a,b/2,m);
        x=(d*d)%m;
        if(b%2==0)
                return x;
        else
                return (x*a%m)%m;
}
*/
//bst
/*typedef struct tree
{
        int val;
        struct tree *l;
        struct tree *r;
}node;
//node *head;
node *insert(int x,node *root)
{
        if(root==NULL)
        {
                root=(node *)malloc(sizeof(node));
                root->val=x;
        }
        else
        {
                if(x<=root->val)
                {
                        if(root->l==NULL)
                        {
                                root->l=(node *)malloc(sizeof(node));
                                root->l->val=x;
                        }
                        else
                                root->l=insert(x,root->l);
                }
                else
                {
                        if(root->r==NULL)
                        {
                                root->r=(node *)malloc(sizeof(node));
                                root->r->val=x;
                        }
                        else
                        {
                                root->r=insert(x,root->r);
                        }
                }
        }
        return root;
}
node *find(int x,node *root)
{
        if(root==NULL)
        {
                return 0;
        }
        else
        {
                if(x==root->val)
                        return root;
                else if(x<root->val)
                {
                        if(root->l==NULL)
                        {
                                return 0;
                        }
                        else
                        {
                                find(x,root->l);
                        }
                }
                else
                {
                        if(root->r==NULL)
                        {
                                return 0;
                        }
                        else
                        {
                                find(x,root->r);
                        }
                }
        }
}

void inorder(node *root)
{
        if(root==NULL)
        {
                return;
        }
        if(root->l==NULL)
        {
                printf("%d",root->val);
                if(root->r==NULL)
                        return;
                else
                        inorder(root->r);
        }
        else
        {
                inorder(root->l);
                printf("%d",root->val);
                if(root->r==NULL)
                        return;
                else
                        inorder(root->r);
        }
}
void preorder(node *root)
{
        if(root==NULL)
        {
                return;
        }
        else
        {
                printf("%d",root->val);
                preorder(root->l);
                preorder(root->r);
        }
}

void postorder(node *root)
{
        if(root==NULL)
        {
                return;
        }
        else
        {
                postorder(root->l);
                postorder(root->r);
                printf("%d",root->val);
        }
}
*/
//adjacency list
/*typedef struct ll
{
        int val;
        struct ll *next;
}nd;

//n *ar[100001];
void insert(int a,int b)
{
        if(ar[a]==NULL)
        {
                ar[a]=(nd *)malloc(sizeof(nd));
                ar[a]->val=b;
                ar[a]->next=NULL;
        }
        else
        {
                nd *temp=(nd *)malloc(sizeof(nd)),*t;
                temp->val=b;
                temp->next=ar[a];
                ar[a]=temp;
        }
}

//dfs
//int state[100001];
void dfs(int a)
{
        state[a]=1;
        count++;
        nd *temp=ar[a];
        while(temp!=NULL)
        {
                if(state[temp->val]!=1)
                        dfs(temp->val);
                temp=temp->next;
        }
        return;
}*/

//dijkstra + heaps
/*typedef struct ll2
{
        int val;
        int weight;
        struct ll2 *next;
}nde;
*/
//nde *ar[500005];
//int state[500005];

/*void insert(int a,int b,int w)//insert to adjacency list
{
	if(ar[a]==NULL)
  	{
 	 	ar[a]=(node *)malloc(sizeof(node));
 	 	ar[a]->val=b;
 	 	ar[a]->weight=w;
 	 	ar[a]->next=NULL;
 	}
 	else
  	{
  		node *temp=(node *)malloc(sizeof(node)),*t;
  		temp->val=b;
  		temp->weight=w;
  		temp->next=ar[a];
  		ar[a]=temp;
  	}
}*/

//int pt[500005],d[500005];
//int heap[500005][2];
//int ptr;
/*void decpty(int val,int pos)//decrease priority
{
        heap[pos][0]=val;
        int x=pos;
        while(x>0)
        {
                if(heap[x][0]>=heap[x/2][0])
                        break;
                else
                {
                        pt[heap[x][1]]=x/2;
                        pt[heap[x/2][1]]=x;
                        int temp=heap[x][0],t2=heap[x][1];
                        heap[x][0]=heap[x/2][0];
                        heap[x][1]=heap[x/2][1];
                        heap[x/2][0]=temp;
                        heap[x/2][1]=t2;
                        x=x/2;
                }
        }
}

void hinsert(int val,int val2)//insert to heap
{
        heap[ptr][0]=val;
        heap[ptr][1]=val2;
        pt[val2]=ptr;
        int x=ptr;
        ptr++;
        while(x>0)
        {
                if(heap[x][0]>=heap[x/2][0])
                        break;
                else
                {
                        pt[heap[x][1]]=x/2;
                        pt[heap[x/2][1]]=x;
                        int temp=heap[x][0],t2=heap[x][1];
                        heap[x][0]=heap[x/2][0];
                        heap[x][1]=heap[x/2][1];
                        heap[x/2][0]=temp;
                        heap[x/2][1]=t2;
                        x=x/2;
                }
        }
}

int hdeletemin()//delete min elem from heap
{
        int ret;
        ret=heap[1][1];
        pt[heap[1][1]]=-1;
        pt[heap[ptr-1][1]]=1;
        heap[1][0]=heap[ptr-1][0];
        heap[1][1]=heap[ptr-1][1];
        ptr--;
        int x=1;
        while(x<ptr)
        {
                if(2*x+1>=ptr)
                {
                        if(2*x<ptr)
                        {
                                if(heap[2*x][0]<heap[x][0])
                                {
                                        pt[heap[x][1]]=2*x;
                                        pt[heap[2*x][1]]=x;
                                        int temp=heap[x][0];
                                        int temp2=heap[x][1];
                                        heap[x][0]=heap[2*x][0];
                                        heap[x][1]=heap[2*x][1];
                                        heap[2*x][0]=temp;
                                        heap[2*x][1]=temp2;
                                        x=2*x;
                                }
                                else
                                        break;
                        }
                        else
                                break;
                }
                else if(heap[x][0]<=heap[2*x][0] && heap[x][0]<=heap[2*x+1][0])
                        break;
                else
                {
                        if(heap[2*x][0]<=heap[2*x+1][0])
                        {
                                pt[heap[x][1]]=2*x;
                                pt[heap[2*x][1]]=x;
                                int temp=heap[x][0];
                                int temp2=heap[x][1];
                                heap[x][0]=heap[2*x][0];
                                heap[x][1]=heap[2*x][1];
                                heap[2*x][0]=temp;
                                heap[2*x][1]=temp2;
                                x=2*x;
                        }
                        else
                        {
                                pt[heap[x][1]]=2*x+1;
                                pt[heap[2*x+1][1]]=x;
                                int temp=heap[x][0];
                                int temp2=heap[x][1];
                                heap[x][0]=heap[2*x+1][0];
                                heap[x][1]=heap[2*x+1][1];
                                heap[2*x+1][0]=temp;
                                heap[2*x+1][1]=temp2;
                                x=2*x+1;
                        }
                }
        }
        return ret;
}

void dikstra(int u,int v)
{
        while(ptr!=1)
        {
                int v=hdeletemin();
                node *temp=ar[v];
                while(temp!=NULL)
                {
                        int w=temp->val;
                        if(d[v]+temp->weight < d[w])
                        {
                                d[w]=d[v]+temp->weight;
                                decpty(d[w],pt[w]);
                        }
                        temp=temp->next;
                }
        }
}*/

/*int main()
{
  	int n,m,u,v,w,i;
  	scanf("%d%d",&n,&m);
  	for(i=0;i<=n;i++)
  	state[i]=0;
  	while(m--)
  	{
  		scanf("%d%d%d",&u,&v,&w);
  		insert(u,v,w);
  	}
  	scanf("%d%d",&u,&v);
  	ptr=1;
  	hinsert(0,u);
  	d[u]=0;
  	for(i=1;i<=n;i++)
  	{
  		if(i!=u)
  		{
  			hinsert(1000000000,i);
  			d[i]=1000000000;
  		}
  	}
  	dikstra(u,v);
  	if(d[v]==1000000000)
  	printf("NO\n");
  	else
  	printf("%d\n",d[v]);
  	return 0;
}*/

//kruskal + dsu

//int dsu[N];
/*int find(int x)
{
        if(dsu[x]==x)return x;
        return dsu[x] = find(dsu[x]);
}

void Union(int a,int b)
{
        if(a==b)
                return;
        dsu[a] = b;
}

typedef struct edge
{
        int u,v;
        int weight;
}edge;
*/
//edge e[N];
/*int cmp(const void *a,const void *b)
{
	return ((edge*)a)->weight - ((edge*)b)->weight;
}*/
/*int main()
{
  	int i;
  	int n,m;
  	scanf("%d %d\n",&n,&m);
  	for(i=0;i<m;i++)
	scanf("%d %d %d",&e[i].u,&e[i].v,&e[i].weight);
	for(i=1;i<=n;i++)
	dsu[i]=i;
	qsort(e,m,sizeof(edge),cmp);
	long long int sum=0;
	for(i=0;i<m;i++)
	{
	 	int a,b;
	 	if((a=find(e[i].u))!=(b=find(e[i].v)))
	 	{
	 		sum+=e[i].weight;
	  		Union(a,b);
	  	}
	}
	printf("%lld\n",sum);
	return 0;
}*/

//max
/*int max(int a,int b)
{
    if(a>b)
        return a;
    else
        return b;
}
*/
//qsort

/*int cmpfunc(const void *a,const void *b)
{
        return (*(int *)a - *(int *)b);
}*/
//qsort(ar,n,sizeof(int),cmpfunc);

//-------------------------------------------------------------------------------------------------------------------------------------

int main()
{
       int n,ans=0;
       scan(n);
       if(n/1234567>=1)
       {
              n=n%1234567;
              if(n/123456>0)
              {
                     n=n%123456;
                     if(n/1234>0)
                     {
                            n=n%1234;
                            if(n==0)
                            {
                                   printf("YES\n");
                                   return 0;
                            }
                     }
              }
       }
       printf("NO\n");
       return 0;
}

#include <stdio.h>
#include <string.h>
/*int count( long long int S[], int m, long long int n )
{
    if (n == 0)
        return 1;
    if (n < 0)
        return 0;
    if (m <=0 && n >= 1)
        return 0;
    return count( S, m - 1, n ) + count( S, m, n-S[m-1] );
}*?
/*int count( int S[], int m, int n )
{
    int i, j, x, y;
    int table[n+1][m];
    for (i=0; i<m; i++)
        table[0][i] = 1;
    for (i = 1; i < n+1; i++)
    {
        for (j = 0; j < m; j++)
        {
            x = (i-S[j] >= 0)? table[i - S[j]][j]: 0;
            y = (j >= 1)? table[i][j-1]: 0;
            table[i][j] = x + y;
        }
    }
    return table[n][m-1];
}*/
/*int count( int S[], int m, int n )
{
    int table[n+1];
    memset(table, 0, sizeof(table));
    table[0] = 1;
    for(int i=0; i<m; i++)
        for(int j=S[i]; j<=n; j++)
            table[j] += table[j-S[i]];
    return table[n];
}*/
int main()
{
	int n,i,j,k,sum;
	scanf("%d",&n);
	int arr[] = {1234567,123456,1234};
    int m = 3;
    for(i=0;i<10;i++)
    	for(j=0;j<10;j++)
    		for(k=0;k<10;k++)
    		{
    			sum = 1234567*i + 123456*j + 1234*k;
    			if(sum == n)
    				{
    					printf("YES\n");
    					return 0;
    				}
       		}
    printf("NO\n");
    /*if(count(arr,m,n) == 0)
    	printf("NO\n");
    else
    	printf("YES\n");
    return 0;*/
    return 0;
}

#include <stdio.h>
int main()
{
	long long int n,i,j,sum,flag=0;
	scanf("%d",&n);
    for(i=0;i<1000;i++)
    	for(j=0;j<1000;j++)
    		{
    			long long int sum = n - 1234567*i - 123456*j;
    			if(sum % 1234 == 0 && sum >= 0)
    				{
    					flag = 1;
    				}
       		}

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

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <inttypes.h>
#include <math.h>
int main()
{
	int64_t a;
	scanf("%"PRId64"", &a);
	if (a == 0)
	{
		printf("NO");
		return 0;
	}
	while (a >= 1234567)
		a = a - 1234567;
	while (a >= 123456)
		a = a - 123456;
	while (a >= 1234)
		a = a - 1234;
	printf("%"PRId64"\n", a);
	if (a == 0)
		printf("YES");
	else
		printf("NO");
	return 0;
}
/* Sat Dec 21 2019 20:41:17 GMT+0300 (MSK) */

#include<stdio.h>
#define A 1234567
#define B 123456
#define C 1234
int main()
{
          int n,count=0,i,j,k,m;
          scanf("%d",&n);
                    if(n%A==0||n%B==0||n%C==0)
                    {
                              printf("YES");
                              return 0;
                    }
                    for(i=1;i<=(n/C);i++)
                    {
                          k=C*i;
                          m=n-k;
                          if((m%A)%B==0||m%B==0)
                          {
                                printf("YES");
                                return 0;
                          }

                    }
                    printf("NO");
}

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

long long n, a, b, c, i, j, k, ver;

int main(){

	scanf("%lld" , &n);

	a = n/1234567;
	b = n/123456;
	c = n/1234;

	for(i = 0 ; i <= c ; i++){
		for(j = 0 ; j <= b ; j++){
			if((n - k*1234567 - j*123456)%1234 == 0){
				ver = 1;
				break;
			}
			if(ver == 1) break;
		}
		if(ver == 1) break;
	}

	if(ver == 1) printf("YES\n");
	else printf("NO\n");

	return 0;
}

#include<stdio.h>
#define A 1234567
#define B 123456
#define C 1234
int main()
{
          int n,count=0,i,j,k,m,t,s;
          scanf("%d",&n);
                    if(n%A==0||n%B==0||n%C==0)
                    {
                              printf("YES");
                              return 0;
                    }
                    for(i=1;i<=(n/C)+1;i++)
                    {
                          k=C*i;
                          m=n-k;
                          if((m%A)%B==0||m%B==0)
                          {
                                printf("YES");
                                return 0;
                          }
                          t=m/A;
                          s=m%A;
                          for(j=1;j<=t+1;j++)
                          {
                                if(s%B==0)
                                {
                                      printf("YES");
                                      return 0;
                                }
                                s+=A;
                          }

                    }
                    printf("NO");
}

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

int main () {
long long int n;
long long int house = 1234567;
long long int car = 123456;
long long int computer = 1234;
scanf("%lld",&n);
long long int sum = n;
if (n%house==0 || n%car==0 || n%computer==0){
	printf("YES\n");
}
else {
while(sum >= computer || sum >=car || sum >= house ) {
	if(sum>=house)
		sum-=house;
	 if(sum>=car)
		sum-=car;
	 if(sum>=computer)
		sum-=computer;
}
//printf("%lld",sum);
if (sum!=0){
	sum = n;
	while(sum>=house || sum>=car) {
		if(sum>=house)
			sum-=house;
		if(sum>=car)
			sum-=car;
	}
}
if (sum!=0){
	sum = n;
	while(sum>=house || sum>=computer) {
		if(sum>=house)
			sum-=house;
		if(sum>=computer)
			sum-=computer;
	}
}
if (sum!=0){
	sum = n;
	while(sum>=car || sum>=computer) {
		if(sum>=car)
			sum-=car;
		if(sum>=computer)
			sum-=computer;
	}
}

if(sum==0)
	printf("YES\n");
else
	printf("NO\n");
}
//printf("%d\n",pos);

return 0;
}

#include<stdio.h>
int main()
{
    long int n;
    scanf("%ld",&n);
    while(n!=0)
    {
        if(n>0)
        n=n-1234567;
        else if(n<=0)
        break;

        if(n>0)
        n=n-123456;
        else if(n<=0)
        break;

        if(n>0)
        n=n-1234;
        else if(n<=0)
        break;

    }
    if(n==0)
    printf("YES");
    else
    printf("NO");

    return 0;
}

#include <stdio.h>
const int a=1234567;
const int b=123456;
const int c=1234;
int main()
{
	int n,k;
	scanf("%i",&n);
	k=n%a;
	if(k){
		k=k%b;
		if(k)
			k=k%c;
	}
	if(k)
		puts("NO");
	else
		puts("YES");
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <inttypes.h>
#include <math.h>
int main()
{
	int64_t a;
	scanf("%"PRId64"", &a);
	if (a == 0)
	{
		printf("NO");
		return 0;
	}
	while (a >= 1234567)
		a = a - 1234567;
	while (a >= 123456)
		a = a - 123456;
	while (a >= 1234)
		a = a - 1234;
	if (a == 0)
		printf("YES");
	else
		printf("NO");
	return 0;
}
/* Sat Dec 21 2019 20:42:56 GMT+0300 (MSK) */

#include <stdio.h>
#include <string.h>
/*int count( long long int S[], int m, long long int n )
{
    if (n == 0)
        return 1;
    if (n < 0)
        return 0;
    if (m <=0 && n >= 1)
        return 0;
    return count( S, m - 1, n ) + count( S, m, n-S[m-1] );
}*?
/*int count( int S[], int m, int n )
{
    int i, j, x, y;
    int table[n+1][m];
    for (i=0; i<m; i++)
        table[0][i] = 1;
    for (i = 1; i < n+1; i++)
    {
        for (j = 0; j < m; j++)
        {
            x = (i-S[j] >= 0)? table[i - S[j]][j]: 0;
            y = (j >= 1)? table[i][j-1]: 0;
            table[i][j] = x + y;
        }
    }
    return table[n][m-1];
}*/
/*int count( int S[], int m, int n )
{
    int table[n+1];
    memset(table, 0, sizeof(table));
    table[0] = 1;
    for(int i=0; i<m; i++)
        for(int j=S[i]; j<=n; j++)
            table[j] += table[j-S[i]];
    return table[n];
}*/
int main()
{
	int n,i,j,k,sum;
	scanf("%d",&n);
	int arr[] = {1234567,123456,1234};
    int m = 3;
    for(i=0;i<100000;i++)
    	for(j=0;j<100000;j++)
    		for(k=0;k<100000;k++)
    		{
    			sum = 1234567*i + 123456*j + 1234*k;
    			if(sum == n)
    				{
    					printf("YES\n");
    					return 0;
    				}
       		}
    printf("NO\n");
    /*if(count(arr,m,n) == 0)
    	printf("NO\n");
    else
    	printf("YES\n");
    return 0;*/
    return 0;
}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,a,b,count1=0,a2,b2,k;

scanf("%lld",&n);
for(i=0;i<n/1234567+1;i++){
    for(j=0;j<n/123456+1;j++){
        if((n-a*1234567-b*123456)>=0 && (n-a*1234567-b*123456)%1234==0 ){
            printf("Yes");
            return 0;
        }
    }
}//
printf("No");
return 0;
}

#include <stdio.h>
 //Compiler version gcc 6.3.0

 int main(void)
 {
 	int n;
 	scanf("%d", &n);
 	int l1=n/1234567, l2=n/123456;
 	for(int i=0;i<=l1;i++) {
 		for(int j=0; j<l2; j++) {
 			int s=i*1234567+j*123456;
 			if(s>n) break;
 			if((n-s)%1234==0) {
 				printf("YES");
 				return 0;
 			}
 		}
 	}
 	printf("NO");
 	return 0;
 }

#include <stdio.h>
#include <string.h>
/*int count( long long int S[], int m, long long int n )
{
    if (n == 0)
        return 1;
    if (n < 0)
        return 0;
    if (m <=0 && n >= 1)
        return 0;
    return count( S, m - 1, n ) + count( S, m, n-S[m-1] );
}*?
/*int count( int S[], int m, int n )
{
    int i, j, x, y;
    int table[n+1][m];
    for (i=0; i<m; i++)
        table[0][i] = 1;
    for (i = 1; i < n+1; i++)
    {
        for (j = 0; j < m; j++)
        {
            x = (i-S[j] >= 0)? table[i - S[j]][j]: 0;
            y = (j >= 1)? table[i][j-1]: 0;
            table[i][j] = x + y;
        }
    }
    return table[n][m-1];
}*/
/*int count( int S[], int m, int n )
{
    int table[n+1];
    memset(table, 0, sizeof(table));
    table[0] = 1;
    for(int i=0; i<m; i++)
        for(int j=S[i]; j<=n; j++)
            table[j] += table[j-S[i]];
    return table[n];
}*/
int main()
{
	int n,i,j,k,sum;
	scanf("%d",&n);
	int arr[] = {1234567,123456,1234};
    int m = 3;
    for(i=0;i<10;i++)
    	for(j=0;j<10;j++)
    		for(k=0;k<10;k++)
    		{
    			sum = 1234567*i + 123456*j + 1234*k;
    			if(sum == n)
    				{
    					printf("YES\n");
    					return 0;
    				}
       		}
    /*if(count(arr,m,n) == 0)
    	printf("NO\n");
    else
    	printf("YES\n");
    return 0;*/
}

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

int main () {
long long int n;
long long int house = 1234567;
long long int car = 123456;
long long int computer = 1234;
scanf("%lld",&n);
long long int sum = n;
if (n%house==0 || n%car==0 || n%computer==0){
	printf("YES\n");
}
else {

if (sum!=0){
	sum = n;
	while(sum>=car || sum>=computer) {
		if(sum>=car)
			sum-=car;
		if(sum>=computer)
			sum-=computer;
	}
printf("%lld\n",sum);
}
 if (sum!=0){
	sum = n;
	while(sum>=house || sum>=computer) {
		if(sum>=house)
			sum-=house;
		if(sum>=computer)
			sum-=computer;
	}
printf("%lld\n",sum);
}

 if (sum!=0){
	sum = n;
	while(sum>=house || sum>=car) {
		if(sum>=house)
			sum-=house;
		if(sum>=car)
			sum-=car;
	}
printf("%lld\n",sum);
}
 if(sum!=0) {
sum = n;
while(sum >= house || sum >=car || sum >= computer ) {
	if(sum>=house)
		sum-=house;
	 if(sum>=car)
		sum-=car;
	 if(sum>=computer)
		sum-=computer;
}
printf("%lld\n",sum);
}

if(sum==0)
	printf("YES\n");
else
	printf("NO\n");
}
//printf("%d\n",pos);

return 0;
}

#include<stdio.h>
int main()
{
    int i,flag=0;
    long long n,item;
    scanf("%I64d",&n);
    item=n;
        while(item>=1234567)
        {
            item-=1234567;
        }
        while(item>=123456)
        {
            item-=123456;
        }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }

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

#include <stdio.h>
#include <string.h>
int main()
{
	int n,i,j,sum,flag=0;
	scanf("%d",&n);
    for(i=0;i<1000;i++)
    	for(j=0;j<1000;j++)
    		{
    			int sum = n- 1234567*i + 123456*j;
    			if(sum % 1234)
    				{
    					flag = 1;
    				}
       		}

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

#include<stdio.h>

#define ll long long

int main()
{
    freopen("in.txt", "r", stdin);

    ll a=1234567, b = 123456, c= 1234;

    ll n, ans, ans2, i, j;
    int flag = 0;

    scanf("%I64d", &n);

    if(n%a == 0 || n%b==0 || n%c == 0) flag = 1;

    ans = 0;

    for(i=1; flag == 0 && ans<=n ; i++) {

        ans2 = ans;

        if( ans2>0 && n%ans2 == 0) flag = 1;

        for(j=1; ans2 <= n && flag == 0 ; j++){

            if( ( n-ans2 ) % c == 0) {
                flag = 1;
                break;
            }

            ans2 = ans + j*b;
            if(n%ans2 == 0) flag = 1;
        }

        ans = i*a;
        if(n%ans==0) flag = 1;
    }

    if(flag == 1) printf("YES\n");
    else printf("NO\n");
}

#include<stdio.h>
int main()
{
    int a=1234567,b=123456,c=1234,sum,n,flag=0,i,j;
    scanf("%d",&n);
    sum=n;
    if(n%a==0 || n%b==0 || n%c==0) printf("YES\n");
    else{
    for(i=0; flag==0 ;i++)
    {
        sum=n;
        sum=sum-i*a;
        if(sum<0) break;

        for(j=0; flag==0 ; j++)
        {
            sum=sum-j*b;
            if(sum<0) break;

            if(sum%c==0) { flag=1; printf("YES\n"); }
        }
    }
    //printf("%d %d\n",i,j);
    if(flag==0) printf("NO\n");
    }

    return 0;
}

#include <stdio.h>
#include <string.h>
/*int count( long long int S[], int m, long long int n )
{
    if (n == 0)
        return 1;
    if (n < 0)
        return 0;
    if (m <=0 && n >= 1)
        return 0;
    return count( S, m - 1, n ) + count( S, m, n-S[m-1] );
}*?
/*int count( int S[], int m, int n )
{
    int i, j, x, y;
    int table[n+1][m];
    for (i=0; i<m; i++)
        table[0][i] = 1;
    for (i = 1; i < n+1; i++)
    {
        for (j = 0; j < m; j++)
        {
            x = (i-S[j] >= 0)? table[i - S[j]][j]: 0;
            y = (j >= 1)? table[i][j-1]: 0;
            table[i][j] = x + y;
        }
    }
    return table[n][m-1];
}*/
/*int count( int S[], int m, int n )
{
    int table[n+1];
    memset(table, 0, sizeof(table));
    table[0] = 1;
    for(int i=0; i<m; i++)
        for(int j=S[i]; j<=n; j++)
            table[j] += table[j-S[i]];
    return table[n];
}*/
int main()
{
	int n,i,j,k,sum;
	scanf("%d",&n);
	int arr[] = {1234567,123456,1234};
    int m = 3;
    for(i=0;i<1000000;i++)
    	for(j=0;j<1000000;j++)
    		for(k=0;k<1000000;k++)
    		{
    			sum = 1234567*i + 123456*j + 1234*k;
    			if(sum == n)
    				{
    					printf("YES\n");
    					return 0;
    				}
       		}
    printf("NO\n");
    /*if(count(arr,m,n) == 0)
    	printf("NO\n");
    else
    	printf("YES\n");
    return 0;*/
    return 0;
}

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

int main () {
long long int n;
long long int house = 1234567;
long long int car = 123456;
long long int computer = 1234;
scanf("%lld",&n);
long long int sum = n;
if (n%house==0 || n%car==0 || n%computer==0){
	printf("YES\n");
}
else {

if (sum!=0){
	sum = n;
	while(sum>=car || sum>=computer) {
		if(sum>=car)
			sum-=car;
		if(sum>=computer)
			sum-=computer;
	}
//printf("%lld\n",sum);
}
 if (sum!=0){
	sum = n;
	while(sum>=house || sum>=computer) {
		if(sum>=house)
			sum-=house;
		if(sum>=computer)
			sum-=computer;
	}
//printf("%lld\n",sum);
}

 if (sum!=0){
	sum = n;
	while(sum>=house || sum>=car) {
		if(sum>=house)
			sum-=house;
		if(sum>=car)
			sum-=car;
	}
//printf("%lld\n",sum);
}
 if(sum!=0) {
sum = n;
while(sum >= house || sum >=car || sum >= computer ) {
	if(sum>=house)
		sum-=house;
	 if(sum>=car)
		sum-=car;
	 if(sum>=computer)
		sum-=computer;
}
//printf("%lld\n",sum);
}

if(sum==0)
	printf("YES\n");
else
	printf("NO\n");
}
//printf("%d\n",pos);

return 0;
}

#include <stdio.h>

int main()
{
	long long n;
	scanf("%lld",&n);
	if(n%1359257==0) printf("YES\n");
	else printf("NO\n");

	return 0;
}

#include<stdio.h>
int main()
{

          int n,a=1234567,b=123456,c=1234,sum;
          scanf("%d",&n);
          sum=a+b+c;
          while(1)
          {
                    if(n>=sum)
                    {
                              n=n-sum;
                              if(n<sum&&n>=(b+c))
                              {
                                        n=n-(b+c);
                                        if(n<(b+c)&&n>=c)
                                        {
                                                  n=n-c;
                                                  if(n<c)
                                                  break;
                                        }
                              }
                    }
                    else
                    break;
          }
          if(n==0)
          printf("YES");
          else
          printf("NO");
          return 0;
}

#include <stdio.h>

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

	int n,a,b,c,temp=1;
	scanf("%d",&n);
	for(a=0;a<=(n/1234567);a++)
	{
	    for(b=0;b<=(n/123456);b++)
	   { int k=1234567*a + 123456*b;
	   // printf("%d ",k);
	    k=n-k;
	    if(k<0){printf("NO"); temp=0; break;}
	    if(k%1234==0){printf("YES"); temp=0; break;}
	   }
	    if(temp==0)break;
	}

	if(temp!=0)printf("NO");
	return 0;
}

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

#define HOUSE    (1234567)
#define CAR      (123456)
#define COMPUTER (1234)

int main() {
  bool ok = false;
  int n,nh,ncr,i,j;

  scanf("%d", &n);
  for ( nh = n / HOUSE, i=0; i <= nh; ++i )
    for ( ncr = (n-i*HOUSE) / CAR, j=0; j <= ncr; ++j )
      if ( (n - nh*HOUSE - ncr*CAR) % COMPUTER == 0 )
        ok = true;
  printf("%s\n", ok ? "YES" : "NO");
  return EXIT_SUCCESS;
}

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

int main () {
int n;
int house = 1234567;
int car = 123456;
int computer = 1234;
scanf("%d",&n);
int sum = n;
if (n%house==0 || n%car==0 || n%computer==0){
	printf("YES\n");
}
else {
while(sum> computer || sum >car || sum > house ) {
	if(sum>=house)
		sum-=house;
	 if(sum>=car)
		sum-=car;
	 if(sum>=computer)
		sum-=computer;
}
//printf("%d",sum);
if(sum==0)
	printf("YES\n");
else
	printf("NO\n");
}
//printf("%d\n",pos);

return 0;
}

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

int main()
{

    long long unsigned int a,temp,i,j,k;
    scanf("%I64d",&a);
    temp=a;
    for(i=1;i!=1000;i++)
    {
        temp=temp-1234567;
        if(temp<=1234567)
        {
            for(j=1;j!=1000;j++)
            {
                             if(temp==0)
                {
                    printf("NO");
                    return 0;
                }
                if (temp>=123456)
                temp=temp-123456;

                if(temp<=123456)
                {
                    for(k=1;k!=1000;k++)
                    {
                                      if(temp==0)
                {
                    printf("NO");
                    return 0;
                }
                        if(temp>=1234)
                        temp=temp-1234;
                        {
                            if(temp==0)
                            {
                                printf("YES");
                                return 0;
                            }
                        }
                    }
                }

            }
            break;
        }
    }

        printf("NO");

    return 0;
}

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

//681B Economy Game.
main()
{
    int n,i,j,flag=0;
    scanf("%d",&n);
    int house=1234567,car=123456,computer=1234;

    int x=n/house,y=n/car,z=n/computer;
    int clone=n,c_copy=0;

    for(i=x; house*i>=0;i--)
    {
        clone=n-house*i;
        for(j=0;j<=y;j++)
            {
                c_copy=clone-car*j;
                if(c_copy%computer==0)
                {
                    flag=1;
                    break;
                }
            }

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

#include<stdio.h>
int main()
{
    long long n,item;
    scanf("%I64d",&n);
    item=n;
        while(item>=1234567)
        {
            item-=1234567;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=123456)
        {
            item-=123456;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=123456)
        {
            item-=123456;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=1234567)
        {
            item-=1234567;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    printf("NO\n");
    return 0;
}

#include<stdio.h>

int main()
{
    long long int a,b,c;
    a=1234567;
    b=123456;
    c=1234;
    long long int rem,n;
    scanf("%lld",&n);
    rem=n%a;
    rem=rem%b;
    rem=rem%c;

    if(rem==0){printf("YES"); }
    else printf("NO");

return 0;
}

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

int main()
{
    long long int i,a,b,j,y,x,m,cur=0,n,t,c1,c2,n1,n2,m1,m2,te,tem,temp;

    long long int sum=0,max=0,ans=0,tl=1,k,w=0,on=0,z=0,wh=0;

        scanf("%lld",&n);
       a=n/1234567;
       b=n/123456;
        for(i=0;i<=a;i++)
            for(j=0;j<=b;j++)
                {
                    te=n-(i*1234567+j*123456);
                    if(te%1234==0)
                    w=1;

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

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define max 1000000000
typedef long long ll;
int main(){
	ll n,i,j,flag,c;
	flag=-1;
	scanf("%I64d",&n);
	for(i=0;i<=100;i++){
		if((i*1234567)>n){
				continue;
			}
		for(j=0;j<=1000;j++){
			if(((i*1234567)+(j*123456))>n){
				continue;
			}
			c=n-((i*1234567)+(j*123456));
			if(c>0){
				flag=c%1234;
			}
			if(flag==0){
				break;
			}
		}
		if(flag==0){
			break;
		}
	}
	if(flag==0){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

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

long long n, a, b, c, i, j, k, ver;

int main(){

	scanf("%lld" , &n);

	a = n/1234567;
	b = n/123456;

	for(i = 0 ; i <= a ; i++){
		for(j = 0 ; j <= b ; j++){
			if((n - i*1234567 - j*123456)%1234 == 0){
				ver = 1;
				break;
			}
			if(ver == 1) break;
		}
		if(ver == 1) break;
	}

	if(ver == 1) printf("YES\n");
	else printf("NO\n");

	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <inttypes.h>
#include <math.h>
int main()
{
	int64_t a;
	scanf("%"PRId64"", &a);
	while (a >= 1234567)
		a = a - 1234567;
	while (a >= 123456)
		a = a - 123456;
	while (a >= 1234)
		a = a - 1234;
	if (a == 0)
		printf("YES");
	if (a != 0)
		printf("NO");
	return 0;
}
/* Sat Dec 21 2019 20:24:26 GMT+0300 (MSK) */

#include<stdio.h>
int main()
{
    int i,flag=0;
    long long n,item;
    scanf("%I64d",&n);
    item=n;
        while(item>=1234567)
        {
            item-=1234567;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=123456)
        {
            item-=123456;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=123456)
        {
            item-=123456;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=1234567)
        {
            item-=1234567;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        printf("NO\n");
    return 0;
}

#include <stdio.h>
#include <string.h>
int main()
{
	int n,i,j,sum,flag=0;
	scanf("%d",&n);
    for(i=0;i<1000;i++)
    	for(j=0;j<1000;j++)
    		{
    			int sum = n- 1234567*i + 123456*j;
    			if(sum % 1234 == 0)
    				{
    					flag = 1;
    				}
       		}

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


In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painted white. Your task is to repaint at most one cell the other color so that the picture has a 2 × 2 square, completely consisting of cells of the same color. If the initial picture already has such a square, the person should just say so and the test will be completed. Your task is to write a program that determines whether it is possible to pass the test. You cannot pass the test if either repainting any cell or no action doesn't result in a 2 × 2 square, consisting of cells of the same color.

Four lines contain four characters each: the j-th character of the i-th line equals "." if the cell in the i-th row and the j-th column of the square is painted white, and "#", if the cell is black.

Print "YES" (without the quotes), if the test can be passed and "NO" (without the quotes) otherwise.

NoteIn the first test sample it is enough to repaint the first cell in the second row. After such repainting the required 2 × 2 square is on the intersection of the 1-st and 2-nd row with the 1-st and 2-nd column.

#include<stdio.h>

char grid[4][4];

int isBlack(int i,int j)
{
    if(grid[i][j] == '#')
        return 1;
    else
        return 0;
}

int find(int i,int j)
{
    if(isBlack(i,j) && isBlack(i,j+1) && isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && !isBlack(i,j+1) && isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(!isBlack(i,j) && isBlack(i,j+1) && isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && isBlack(i,j+1) && !isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && isBlack(i,j+1) && isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;

    if(!isBlack(i,j) && !isBlack(i,j+1) && !isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    if(!isBlack(i,j) && !isBlack(i,j+1) && !isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(!isBlack(i,j) && !isBlack(i,j+1) && isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    if(!isBlack(i,j) && isBlack(i,j+1) && !isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && !isBlack(i,j+1) && !isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    return 0;
}

int solve()
{
    int i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if(find(i,j)==1)
                return 1;
        }
    }
    return 0;
}

int main()
{
    int i,j;
    char s[5];
    for(i=0;i<4;i++)
    {
        scanf("%s",s);
        for(j=0;j<4;j++)
            grid[i][j] = s[j];
    }

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

#include<stdio.h>
#include<stdlib.h>
int main ()
{
    int tab[4][4]={0};
    int i,j,flag=0;
    char ch;

    for (i=0;i<4;i++){
        for(j=0;j<4;j++){
            scanf(" %c",&ch);
            if (ch=='#') tab[i][j]=1;
            else tab[i][j]=0;
        }
    }

    for (i=1;i<4;i++){
        for(j=1;j<4;j++){
                if (tab[i][j]+tab[i-1][j]+tab[i-1][j-1]+tab[i][j-1]!=2)
                        flag=1;
        }
    }
    if(flag==1) printf("YES");
    else printf("NO");
    return 0;
}

#include<stdio.h>
#include<stdbool.h>

char tab[5][5];
bool contour(int i,int j);

int main()
{
    int k=0;
    int i,j;

    for(i=0;i<4;i++)scanf("%s",tab[i]);

//main
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if (contour(i,j)){printf("YES \n"); k++; break; }

        }
        if(k!=0)break;
    }
    if(k==0)printf("NO \n");

    return 0;
}

bool contour(int i,int j)
{
    if     ((tab[i][j]==tab[i][j+1])&&(tab[i][j]==tab[i+1][j])){return 1;}
    else if((tab[i][j]==tab[i][j+1])&&(tab[i][j]==tab[i+1][j+1])){return 1;}
    else if((tab[i][j]==tab[i+1][j])&&(tab[i][j]==tab[i+1][j+1])){return 1;}
    else if((tab[i][j+1]==tab[i+1][j])&&(tab[i][j+1]==tab[i+1][j+1])){return 1;}
    else return 0;
}

/* بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ */
/* رَّبِّ زِدْنِى عِلْمًا */

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

#define OUTPUT freopen("myfile.txt","w",stdout);
#define INPUT freopen("input.txt","r",stdin);

int main()
{
    int i,j,cnt,test;
    char mat[20][20];

    while(gets(mat[0]))
    {
        gets(mat[1]);
        gets(mat[2]);
        gets(mat[3]);

        cnt=0;
        test=0;

        for(i=0;i<3;i++)
        {
            for(j=0;j<3;j++)
            {
                cnt=0;

                if(mat[i][j]=='#')
                    cnt++;
                if(mat[i][j+1]=='#')
                    cnt++;
                if(mat[i+1][j]=='#')
                    cnt++;
                if(mat[i+1][j+1]=='#')
                    cnt++;

                if(cnt>=3)
                    {
                        test=1;
                        goto ans;

                    }

                cnt=0;

                if(mat[i][j]=='.')
                    cnt++;
                if(mat[i][j+1]=='.')
                    cnt++;
                if(mat[i+1][j]=='.')
                    cnt++;
                if(mat[i+1][j+1]=='.')
                    cnt++;

                if(cnt>=3)
                    {
                        test=1;
                        goto ans;

                    }
            }
        }

        ans:
            if(test==1)
                printf("YES\n");
            else
                printf("NO\n");

    }

    return 0;

}

#include<stdio.h>

struct string
{
    char s[4];
};
int main()
{
    int i,j,sum=0,temp=0;
    char a[4][4];
    for(i=0;i<4;i++)
    scanf("%s",a[i]);
    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
        {
            temp=1;
            if(a[i][j+1]==a[i][j])
            temp++;
            if(a[i+1][j]==a[i][j])
            temp++;
            if(a[i+1][j+1]==a[i][j])
            temp++;
            sum=sum>temp?sum:temp;
        }
    j==3;
    if(sum>=3);
    else
    for(i=0;i<3;i++)
    {
        temp=1;
        if(a[i][j]==a[i+1][j])
        temp++;
        if(a[i][j]==a[i+1][j-1])
        temp++;
        sum=sum>temp?sum:temp;
    }
    if(sum>=3)
    printf("YES");
    else
    printf("NO");
    return 0;
}

//       In the name of         ****                      God                     ****

/*

Copyright (C)          oofMan

                                   Morocco

created : 30/3/2019

*/
#include <stdio.h>
#include <stdbool.h>
//#include <bits/stdc++.h>

//using namespace std;

/*inline void oofMan() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}*/

char m[4][4];
int main(void) {
    //oofMan();
    bool flag=false;
    int xc[3]={1,0,1};
    int yc[3]={0,1,1};
    for(int i=0 ;i<4 ;i++)
        for(int j=0 ; j<4 ;j++)
            scanf(" %c",&m[i][j]);

    for(int i=0 ;i<3 ;i++)
        for(int j=0 ; j<3 ;j++){
            int counter=0;
            for(int k=0;k<3;k++){
                if(i+xc[k]<4 && j+yc[k]<4)
                    if(m[i][j]!=m[i+xc[k]][j+yc[k]])
                        counter++;
            }
            if(counter==3 || counter<=1){
                flag=true;
                break;
            }

        }

    printf("%s",(flag?"YES":"NO"));

}

#include <stdio.h>
int test(char a[4][4],int i,int j){
	int count1=0,count2=0,k,l;
	for(k=0;k<2;k++){
		for(l=0;l<2;l++){
			if(a[i+k][j+l]=='#'){
				count1++;
			}
			else{
				count2++;
			}
		}
	}
	if(count1>=3){
		return 1;
	}
	else if(count2>=3){
		return 1;
	}
	else{
		return 0;
	}
}
int main(){
	int i,j;
	char arr[4][4];
	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			scanf(" %c",&arr[i][j]);
			//printf("aa\n");
		}
	}

	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			if(test(arr,i,j)){
				printf("YES\n");
				return 0;
			}
		}
	}
	printf("NO\n");
	return 0;
}

#include <stdio.h>

int main(void) {
	char square[4][4];
	char garb;
	for(int i = 0; i < 4; i++) {
		for(int j = 0; j < 4; j++) {
			scanf("%c", &square[i][j]);
			//printf("I scanned %c", square[i][j]);
		}
		scanf("%c", &garb);
	}
	int tru = 0;
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) {
			int dots = 0;
			if (square[i][j] == '.') {
				dots++;
			}
			if (square[i][j+1] == '.') {
				dots++;
			}
			if (square[i+1][j] == '.') {
				dots++;
			}
			if (square[i+1][j+1] == '.') {
				dots++;
			}
			if (dots != 2) {
				tru = 1;
				//printf("square at (%d, %d). dots == %d\n", i, j, dots);
				//printf("(%d, %d) = %c, (%d, %d) = %c, (%d, %d) = %c, (%d, %d) = %c.\n", i, j, square[i][j], i, j + 1, square[i][j+1], i + 1, j, square[i+1][j], i + 1, j + 1, square[i+1][j+1]);
			}
		}
	}
	if (tru == 1) {
		printf("YES");
	} else {
		printf("NO");
	}
	return 0;
}

#include<stdio.h>
int main(){
    char squareArray[4][4];
    int i,flagHash=0,flagDot=0,j,countHash,countDot;
    for(i=0;i<4;i++){
        scanf("%s",squareArray[i]);
    }
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            countHash = 0;
            countDot = 0;
            if(squareArray[i][j]=='#')countHash++;
            else if(squareArray[i][j]=='.')countDot++;

            if(squareArray[i][j+1]=='#')countHash++;
            else if(squareArray[i][j+1]=='.')countDot++;

            if(squareArray[i+1][j]=='#')countHash++;
            else if(squareArray[i+1][j]=='.')countDot++;

            if(squareArray[i+1][j+1]=='#')countHash++;
            else if(squareArray[i+1][j+1]=='.')countDot++;

            if(countHash>=3){
                flagHash=1;
                break;
            }
            else if(countDot>=3){
                flagDot=1;
                break;
            }
        }
        if(flagHash^flagDot)break;
    }
    if(flagHash^flagDot)printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

int main()
{
    int i, j, isWhite = 0, isBlack = 0, stat = 0;
    char s[10];
    char arr[4][4];
    for (i = 0; i < 4; i++){
        scanf("%s", &s);
        for (j = 0; j < 4; j++) arr[i][j] = s[j];
    }
    for (i = 0; i < 3; i++){
        for (j = 0; j < 3; j++){
            isWhite = 0; isBlack = 0;
            if (arr[i][j] == '#') isBlack++; else isWhite++;
            if (arr[i][j+1] == '#') isBlack++; else isWhite++;
            if (arr[i+1][j] == '#') isBlack++; else isWhite++;
            if (arr[i+1][j+1] == '#') isBlack++; else isWhite++;
            if ((isWhite >= 3) || (isBlack >= 3)) stat = 1;
            if (stat) break;
        }
        if (stat) break;
    }
    printf((stat)?"YES\n":"NO\n");
    return 0;
}

#include <stdio.h>
#include <stdbool.h>

int main(void) {
    int n = 4;
    int m = 0;
    bool found = false;
    char arr[n][n];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%c", *(arr + i) + j);
        }
        scanf("%c", &m);
    }

    for (int i = 0; i < (n - 1); i++) {
        for (int j = 0, k = 0; j < (n - 1); j++, k = 0) {
            for (int r = 0; r < 2; r++) {
                for (int c = 0; c < 2; c++) {
                    if (arr[i + r][j + c] == '.') {
                        k++;
                    }
                }
            }

            if (k != 2) {
                found = true;
                goto done;
            }
        }
    }

    done:

    if (found == true) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

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

int main()
{
	char **square;
	square=(char **)malloc(sizeof(char *)*4);
	int i,j;
	for(i=0;i<4;i++)
	{
		*(square+i)=(char *)malloc(sizeof(char)*4);
	}
	for(i=0;i<4;i++)
	{
		scanf(" %s",*(square+i));
	}
	//
	int *check=(int *)malloc(sizeof(int)*2);
	//in check...
	//position 1 will be used for #
	//and 2 for .
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			*(check)=*(check+1)=0;
			//# check
			if(square[i][j]=='#')
			{
				(*(check))++;
			}
			if(square[i][j+1]=='#')
			{
				(*(check))++;
			}
			if(square[i+1][j]=='#')
			{
				(*(check))++;
			}
			if(square[i+1][j+1]=='#')
			{
				(*(check))++;
			}
			// . check
			if(square[i][j]=='.')
			{
				(*(check+1))++;
			}
			if(square[i+1][j]=='.')
			{
				(*(check+1))++;
			}
			if(square[i][j+1]=='.')
			{
				(*(check+1))++;
			}
			if(square[i+1][j+1]=='.')
			{
				(*(check+1))++;
			}
			//checking possibility of passing
			if(*(check+1)==3 && *(check)==1 || *(check+1)==1 && *(check)==3 || *(check+1)==4 || *(check)==4)
			{
				printf("YES\n");
				return 0;
			}
		}
	}
	printf("NO\n");
	return 0;
}

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

int main()
{
    int i,j;
    char ch;
    int f=0;
    char arr[4][4];
    for(i=0;i<4;i++)
        {for(j=0;j<4;j++)
            {scanf("%c",&arr[i][j]);}
        scanf("%c",&ch);}
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            //printf("%c ",arr[i][j]);
            if(arr[i][j]==arr[i][j+1] && arr[i][j]==arr[i+1][j])
            {
                printf("YES ");
                f=1;
                break;
            }
            else if(arr[i][j]==arr[i][j+1] && arr[i][j]==arr[i+1][j+1])
            {
                printf("YES ");
                f=1;
                break;
            }
            else if(arr[i][j]==arr[i+1][j] && arr[i][j]==arr[i+1][j+1])
            {
                printf("YES ");
                f=1;
                break;
            }
            else if(arr[i+1][j]==arr[i+1][j+1] && arr[i+1][j]==arr[i][j+1])
            {
                printf("YES");
                f=1;
                break;
            }
        }
        //printf("\n");
        if(f==1)
        break;
    }
    if(f==0)
    printf("NO");
    return 0;
}

#include<stdio.h>
//#include<conio.h>
int main()
{
 char str[4][4],temp;
 int i,j,found=0,count;
 for(i=0;i<4;i++)
 {
  scanf("%s",str[i]);
 }
 for(i=0;i<3 && found==0;i++)
 {
  for(j=0;j<3 && found==0;j++)
  {
   count=1;
   temp=str[i][j];
   if(str[i][j+1]==temp)
    count++;
   if(str[i+1][j]==temp)
    count++;
   if(str[i+1][j+1]==temp)
    count++;
   if(count==4 || count==3 || count==1)
    found=1;
  }
 }
 if(found==1)
  printf("YES");
 else
  printf("NO");
//  getch();
//  clrscr();
return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define fill(a,v)                   memset(a, v, sizeof(a))
int intcmp(const void *f,const void *s)
{
   return (*(int *)f -*(int *)s);
}
int gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}

#define MAX 4
#define MODBY 1000000007

typedef long long int lld;
typedef long double Lf;
int preprocess()
{
   return 0;
}
char board[MAX][MAX+1];

int main()
{
   int cases;
   int i,j,n;
   int a[MAX];
   preprocess();
   for(i=0;i<4;++i)
      ss(board[i]);
   for(i=0;i<3;++i)
      for(j=0;j<3;++j){
         //printf("i j %d %d\n",i,j);
         int cnt=0;
         cnt+=(board[i][j]=='#');
         cnt+=(board[i+1][j]=='#');
         cnt+=(board[i][j+1]=='#');
         cnt+=(board[i+1][j+1]=='#');
         if(cnt!=2){
            printf("YES\n");
            exit(0);
         }
      }
   printf("NO\n");
   return 0;
}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,x1,y1,k,sum2,min,f,r,o,sum1,sum=0,y,count1, a[26]={0};
char a1[10][10];
for(i=0;i<4;i++){
    scanf("%s",a1[i]);
}
for(i=0;i<=2;i++){
    for(j=0;j<=2;j++){
        x1=0;

        if(a1[i][j]=='#'){
            x1++;
        }
        if(a1[i][j+1]=='#'){
            x1++;
        }
        if(a1[i+1][j+1]=='#'){
            x1++;
        }
        if(a1[i+1][j]=='#'){
            x1++;
        }
        if(x1==0 || x1==3 || x1==1 || x1==4){
            printf("YES\n");
            return 0;
        }
    }
}

printf("NO");

return 0;
}

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

char s[5][5];
int dnf(int x,int y)
{
    int v=1;
    if(y==3)
        dnf(x+1,0);
    else if(x+1<4&&y+1<4)
    {
        if(s[x][y]==s[x][y+1])
            v++;
        if(s[x][y]==s[x+1][y])
            v++;
        if(s[x][y]==s[x+1][y+1])
            v++;
        if(v>2||v==1)
            return 1;
        else
            dnf(x,y+1);
    }
}
int main()
{
    int i,j;
    for(i=0; i<4; i++)
        scanf("%s",&s[i]);
    if(dnf(0,0)==1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

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

int main()
{
    int i,arr[4][4],j,count,fl=0;
    char str[5];
    i=0;
    while(i<4)
    {
        memset(str,'\0',5);
        //printf("enter the string:");
        gets(str);
        for(j=0;str[j]!='\0';j++)
        {
            if(str[j]=='#')
                arr[i][j]=1;
            else if(str[j]=='.')
                arr[i][j]=0;
        }
        i++;
    }
/*  for(i=0;i<4;i++)
    {
        for(j=0;j<4;j++)
            printf("%d ",arr[i][j]);
        printf("\n");
    }*/
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            count=0;
            if(arr[i][j]==1)
                count++;
            if(arr[i][j+1]==1)
                count++;
            if(arr[i+1][j]==1)
                count++;
            if(arr[i+1][j+1]==1)
                count++;
            if(count==3 || count==4 || count==1 || count==0)
                fl=1;
        }
    }
    if(fl==1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

#include <stdio.h>

int main()
{
	char paper[4][4];
	for (int i = 0; i < 4; ++i)
	{
		for (int j = 0; j < 4; ++j)
		{
			paper[i][j] = getchar();
		}
		getchar();
	}

	char count = 0;
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			if (paper[i][j] == paper[i + 1][j])
			{
				++count;
			}
			if (paper[i][j] == paper[i][j + 1])
			{
				++count;
			}
			if (paper[i][j] == paper[i + 1][j + 1])
			{
				++count;
			}
			if (count != 1)
			{
				puts("YES");
				return 0;
			}
			count = 0;
		}
	}
	puts("NO");

	return 0;
}

#include <stdio.h>
#define mian main
int mian (void) {
    int a[4][4], s, flag = 0;
    char c;
    for (int i = 0; i < 4; ++i)
        for (int j = 0; j < 4; ++j) {
            c = getchar();
            while (c != '#' && c != '.') c = getchar();
            if (c == '#') a[i][j] = 1;
            else a[i][j] = 0;
        }
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j) {
            s = a[i][j] + a[i][j+1] + a[i+1][j] + a[i+1][j+1];
            if (s != 2) {
                printf("YES\n");
                flag = 1;
                return 0;
            }
        }
    printf("NO\n");
    return 0;
}

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

char arr[4][4];

int boardval(char * loc)
{
		if (*loc == '#')
				return 1;
		else return -1;
}

int main(void)
{
		for (int i = 0; i < 4; i++)
				for (int j = 0; j < 4; j++)
						scanf("%c ", &arr[i][j]);

		int sum;
		for (int i = 0; i < 3; i++)
				for (int j = 0; j < 3; j++){
						sum = 0;
						sum += (boardval(&arr[i][j]) + boardval(&arr[i+1][j]) + boardval(&arr[i][j+1]) + boardval(&arr[i+1][j+1]));
						if (abs(sum) >= 2){
								printf("YES\n");
								return 0;
						}
		}

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

#include <stdio.h>
#include <string.h>
char s[100][100];
int main()
{
    int i,j,black=0,white=0,res,p=0,k=0;
    for(i=0;i<4;i++){
        scanf("%s",s[i]);
    }
    int x=0,y=0;
    while(1){
        for(i=x;i<(x+2);i++){
            for(j=y;j<(y+2);j++){
                if(s[i][j]=='#'){
                    black++;
                }
                else white++;
            }
        }
        if(black>=3 || white >=3){
            res=1;
            break;
        }
        else {
            black = 0;
            white =0;
        }
        k++;
        //if(k==2){
          //  k=0;
            y++;
        //}
        if(y==3){
            y=0;
            x=2;
            p++;
        }
        if(p==2){
            res=0;
            break;
        }
    }
    if(res) printf("YES");
    else printf("NO");

    return 0;
}

#include<stdio.h>
int search(int i,int j,char arr[4][4]){
    if((arr[i][j]==arr[i+1][j])){
        if((arr[i][j]==arr[i][j+1])||(arr[i+1][j]==arr[i+1][j+1])){
            return 1;
        }
        else{
            return 0;
        }
    }

    else if((arr[i][j]==arr[i][j+1])){
        if((arr[i][j]==arr[i+1][j])||(arr[i][j+1]==arr[i+1][j+1])){
            return 1;
        }
        else{
            return 0;
        }
    }
    else {
        return 0;
    }
}
int main(){
    char arr[4][4];
    int i,j;
    for(i=0;i<4;i++){
        for(j=0;j<4;j++){
            scanf("%c",&arr[i][j]);
        }
    }
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            if(search(i,j,arr)){
                printf("YES");
                return 0;
            }
        }
    }
    printf("NO");
    return 0;
}

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

int main()
{
     char arr[4][4];
     int flag=0;
     for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            scanf("%c",&arr[i][j]);

        }
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(arr[i][j]==arr[i][j+1]){
                if((arr[i][j]==arr[i+1][j])||(arr[i][j]==arr[i+1][j+1])){
                    flag=1;
                }
            }

        }
    }
    if(flag==1){
        printf("YES");
    }
    else{
        printf("NO");
    }

}

#include <stdio.h>

int main () {

	int lista[4][4];
	int i,j;
	char c;

	fflush(stdin);

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			scanf("%c",&c);
			if(c=='#'){
				lista[i][j]=1;
			}else{
				lista[i][j]=0;
			}
		}
		scanf("%c",&c);
		fflush(stdin);
	}

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			printf("%d",lista[i][j]);
		}
		printf("\n");
	}

	return 0;
}

#include<stdio.h>
#include<stdbool.h>

char tab[5][5];
bool contour(int i,int j);

int main()
{
    int k=0;
    int i,j;

    for(i=0;i<4;i++)scanf("%s",tab[i]);

//main
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if (contour(i,j)){printf("YES \n"); k++; break; }

        }
        if(k!=0)break;
    }
    if(k==0)printf("NO \n");

    return 0;
}

bool contour(int i,int j)
{
    if     ((tab[i][j]==tab[i][j+1])&&(tab[i][j]==tab[i+1][j])){return 1;}
    else if((tab[i][j]==tab[i][j+1])&&(tab[i][j]==tab[i+1][j+1])){return 1;}
    else if((tab[i][j]==tab[i+1][j])&&(tab[i][j]==tab[i+1][j+1])){return 1;}
    else return 0;
}

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

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

int check(int a[6][6]);

int main()
{
    int a[6][6] = {0};
    int i, j, k, t;
    int blank[16] = {0};
    char s[5];
    int m = 0;

    for(i = 1; i < 5; i++) {
        scanf("%s", s);
        for(j = 1; j < 5; j++){
            if(s[j] == '#')
                a[i][j] = 1;
            else
                a[i][j] = 0;
        }
    }
/*
    for(i = 1; i < 5; i++) {
        for(j = 1; j < 5; j++) {
            printf("%d  ", a[i][j]);
        }
        printf("\n");
    }
*/
    m = check(a);
    if(m == 1)
        printf("YES");
    else
        printf("NO");

    return 0;
}

int check(int a[6][6])
{
    int i, j, k, t;
    int result = 0;
    int big = 0;

    for(i = 1; i < 5; i++) {
        for(j = 1; j < 5; j++) {
            if(a[i][j] == 0) {
                if(a[i-1][j-1] || a[i-1][j+1] || a[i+1][j-1] || a[i+1][j+1]) {
                    if(a[i-1][j-1] == 1) { //northwest square
                        if(a[i-1][j] == 1 && a[i][j-1] == 1) {
                            result = 1;
                            return result;
                        }
                        else {
                            result = 0;
                            continue;
                        }
                    }
                    else {
                        if(a[i-1][j+1] == 1) { //northeast square
                            if(a[i-1][j] == 1 && a[i][j+1] == 1) {
                                result = 1;
                                return result;
                            }
                            else {
                                 result = 0;
                                 continue;
                            }
                        }
                        else {
                            if(a[i+1][j-1] == 1) { //southwest square
                                if(a[i][j-1] == 1 && a[i+1][j] == 1) {
                                    result = 1;
                                    return result;
                                }
                                else {
                                    result = 0;
                                    continue;
                                }
                            }
                            else {
                                if(a[i+1][j+1] == 1) { // southeast square
                                    if(a[i][j] == 1 && a[i][j+1] == 1) {
                                        result = 1;
                                        return result;
                                    }
                                    else {
                                        result = 0;
                                        return result;
                                    }
                                }
                            }
                        }

                    }
                }
                else {
                    result = 0;
                    return result;
                }
            }
        }
    }

    return result;
}

#include<stdio.h>
int main()
{
  char a[16],i;
  int c=0;
       for(i=0;i<16;i++)
       {
            scanf("%c",&a[i]);
       }
       for(i=0;i<12;i++)
       {
            if(a[i]==a[i+4]||a[i+1]==a[i+5])
            {
                 c=1;
                 break;
            }

            else
            c=0;
       }
       if(c==1)
       printf("Yes");
       else
       printf("No");
return 0;
}

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

int sumar(int a,int b,int c,int d){

	int k;

	k=a+b+c+d;

	if(k>=3){
		k=0;
	}else{
		k=1;
	}

	return k;
}

int main () {

	int lista[4][4];
	int i,j,k;
	char * p;

	fflush(stdin);

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			lista[i][j]=getchar();
			if(lista[i][j]==46){
				lista[i][j]=0;
			}else{
				lista[i][j]=1;
			}
		}
		getchar();
		fflush(stdin);
	}

	p=(char *)malloc(sizeof(char)*4);
	p="NO";

	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			k=sumar(lista[i][j],lista[i+1][j],lista[i][j+1],lista[i+1][j+1]);
			if(k==0){
				p="YES";
				break;
			}
		}
	}

	puts(p);

	return 0;
}

#include <stdio.h>
#include <stdbool.h>

int main(void) {
    int n = 4;
    int m = 0;
    bool found = false;
    char arr[n][n];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%c", *(arr + i) + j);
        }
        scanf("%c", &m);
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0, k = 0; j < n; j++, k = 0) {
            if (arr[i][j] == '#') {
                k++;
            }
            if (i > 0 && arr[i - 1][j] == '#') {
                k++;
            }
            if (j < (n - 1) && arr[i][j + 1] == '#') {
                k++;
            }
            if (j < (n - 1) && i > 0 && arr[i - 1][j + 1] == '#') {
                k++;
            }

            if (k == 3) {
                found = true;
                goto done;
            }
        }
    }

    done:

    if (found == true) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

#include<stdio.h>
int main()
{
    //freopen("in.txt","r",stdin);
    char p[5][5],c;
    int n,i,j;
    for(i=0;i<4;i++)
       scanf("%s",p[i]);
    for(i=0;i<3;i++)
       for(j=0;j<3;j++)
       {
           n=0;
           c=p[i][j];
           if(c==p[i][j+1])
                n++;
           if(c==p[i+1][j])
                n++;
           if(c==p[i+1][j+1])
                n++;
           if(n>=2)
                goto loop;
       }
    loop:if(n>=2)
             printf("YES\n");
         else
             printf("NO\n");
    return 0;
}

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

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

int main()
{
    char square[4][5];
    int i;
    for(i=0;i<4;i++)
        scanf("%s",square[i]);
    for(i=0;i<4;i++)
    {
        int j;
        for(j=0;j<4;j++)
        {
            if(((square[i][j]==square[i][j+1])&&((square[i][j]==square[i+1][j])||(square[i][j]==square[i+1][j+1])))||((square[i+1][j]==square[i+1][j+1])&&((square[i+1][j]==square[i][j])||(square[i+1][j]==square[i][j+1]))))
            {
                printf("YES\n");
                return 0;
            }
        }
    }
    printf("NO\n");
}

#include<stdio.h>

#define ROW 4
#define COL 4

/*
    .X
    XX
    If any 3 of the 4 squares are the same colour then we can make a square
 */

//Counts
int count (int g[ROW][COL], int r, int c){
    int n=0, i, j;

    for (i=r; i<2; i++)
        for (j=c; j<2; j++)
            if (g[i][j] == 1)
                n++;

    return n;
}

int main (){

    int grid[ROW][COL] = {{0}};
    int i, j, c;
    int sq = 0;

    for (i=0; i<ROW; i++)
        for (j=0; j<COL; j++){
            c = getchar();
            if (c == '#'){
                grid[i][j] = 1;
            } else if (c == '.') {
               grid[i][j] = 0;
            } else {
                //Invalid input
                //Get next char without exiting loop
                j--;
            }
        }

    //Analyse the grid
    for (i=0; i<ROW-1; i++){
        for (j=0; j<COL-1; j++){
            if (count(grid, i, j) != 2)
                sq = 1;
        }
    }

    if (sq == 1)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}

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

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

int sumar(int a,int b,int c,int d){

	a=a+b+c+d;

	if(a>=3){
		a=0;
	}else{
		a=1;
	}

	return a;
}

int main () {

	int lista[4][4];
	int i,j,k;
	char * p;

	p=(char *)malloc(sizeof(char)*4);

	fflush(stdin);

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			lista[i][j]=getchar();
			if(lista[i][j]==46){
				lista[i][j]=0;
			}else{
				lista[i][j]=1;
			}
		}
		getchar();
		fflush(stdin);
	}

	p="NO";

	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			k=sumar(lista[i][j],lista[i+1][j],lista[i][j+1],lista[i+1][j+1]);
			if(k==0){
				p="YES";
				break;
			}
		}
	}

	puts(p);

	return 0;
}

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

#include<stdio.h>

char grid[4][4];

int isBlack(int i,int j)
{
    if(grid[i][j] == '#')
        return 1;
    else
        return 0;
}

int find(int i,int j)
{
    if(isBlack(i,j) && isBlack(i,j+1) && isBlack(i+1,j+1) && !isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && !isBlack(i,j+1) && isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(!isBlack(i,j) && isBlack(i,j+1) && isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    if(isBlack(i,j) && isBlack(i,j+1) && !isBlack(i+1,j+1) && isBlack(i+1,j))
        return 1;
    return 0;
}

int solve()
{
    int i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if(find(i,j)==1)
                return 1;
        }
    }
    return 0;
}

int main()
{
    int i,j;
    char s[5];
    for(i=0;i<4;i++)
    {
        scanf("%s",s);
        for(j=0;j<4;j++)
            grid[i][j] = s[j];
    }

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

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

int check(int a[6][6]);

int main()
{
    int a[6][6] = {0};
    int i, j, k, t;
    char s[5];
    int m;

    for(i = 1; i < 5; i++) {
        scanf("%s", s);
        for(j = 1; j < 5; j++){
            if(s[j] == '#')
                a[i][j] = 1;
            else
                a[i][j] = 0;
        }
    }
/*
    for(i = 1; i < 5; i++) {
        for(j = 1; j < 5; j++) {
            printf("%d  ", a[i][j]);
        }
        printf("\n");
    }
*/
    m = check(a);
    if(m == 1)
        printf("YES");
    else
        printf("NO");

    return 0;
}

int check(int a[6][6])
{
    int i, j, k, t;
    int tmp = 0;

    for(i = 1; i < 4; i++) {
        for(j = 1; j < 4; j++) {
            tmp = a[i][j] + a[i][j+1] + a[i+1][j] + a[i+1][j+1];
            if (tmp == 2)
                return 1;
            else
                continue;
        }
    }

    return 0;
}

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

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

#include <stdio.h>

int main () {

	int lista[4][4];
	int i,j;

	fflush(stdin);

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			lista[i][j]=getchar();
		}
		getchar();
		fflush(stdin);
	}

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			printf("%d",lista[i][j]);
		}
		printf("\n");
	}

	return 0;
}

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

int main()
{
    char square[4][5];
    int i;
    for(i=0;i<4;i++)
        scanf("%s",square[i]);
    for(i=0;i<4;i++)
    {
        int j;
        for(j=0;j<4;j++)
        {
            if((square[i][j]==square[i][j+1])&&((square[i][j]==square[i+1][j])||(square[i][j]==square[i+1][j+1])))
            {
                printf("YES\n");
                return 0;
            }
            if((square[i+1][j]==square[i+1][j+1])&&((square[i+1][j]==square[i][j])||(square[i+1][j]==square[i][j+1])))
            {
                printf("YES\n");
                return 0;
            }
        }
    }
    printf("NO\n");
}