#include<stdio.h>
int main()
{
    int n;
    scanf("%d" ,&n);
    if(n%2==0)
        printf("white");
        printf("1 2");
    else
        printf("black");

    return 0;
}


#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	printf(n % 2 == 0 ? "1 2\n" : "black\n");
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int x1,y1,x2,y2,x,y;
    scanf("%d %d %d %d",x1,y1,x2,y2);
    int n,m;
    n=abs(x1-x2);
    m=abs(y1-y2);
    if((n==0&&m%y==0)||(m==0&&n%x==0))
    printf("YES\n");
    else
    printf("NO\n");
    return 0;

}


#include<stdio.h>
int main()
{
    int a,b,c,d,e,f;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    a=abs(a-c);
    b=abs(b-d);
    if(a>b){
    if(a%e==0 && b%f==0 && a%b==0)
    {printf("YES");}
    else {printf("NO");}}
    else {
    if(a%e==0 && b%f==0 && a%b==0)
    {printf("YES");}
    else {printf("NO");}}
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define N 1000

void swap(int *p,int *q)
{
    int temp;
    temp = *p;
    *p = *q;
    *q = temp;
}

int a[N];

int main()
{
    while(1)
    {
        for(int i = 0; i < 3; i ++)
        {
            scanf("%d", &a[i]);
            for(int j = 0; j < i; j ++)
            {
                if(a[i] < a[j]) swap(a + i, a + j);
            }
        }
        printf("%d\n", a[2] - a[0]);
    }
    return 0;
}


#include<stdio.h>
int main()
{
	int a[3],i,j,k,min;
	for (i=0; i<3; i++)
		scanf("%d",&a[i]);
	for (i=0; i<3; i++)
	{
		min=i;
		for (j=i+1; j<3; i++)
		{
			if(a[j]<a[min])
			{
				min=j;
				k=a[j];
				a[j]=a[min];
				a[min]=k;
			}
		}
	}
	int ans;
	ans=-a[0]+a[2];
	printf("%d",ans);
	return 0;
}


#include<stdio.h>

int main()
{
    int n,i,max_zero=0,max_one=0,zero=0,one=0,start,end,start2,end2;
    scanf("%d",&n);
    int a[n+1];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==0)
        {
            zero++;
            if(zero==1)
                start=i;
            if(zero>max_zero)
            {
                max_zero=zero;
                end=i;
            }
        }
        else
            zero=0;
        if(a[i]==1)
        {
            one++;
            if(one==1)
                start2=i;
            if(one>max_one)
            {
                max_one=one;
                end2=i;
            }
        }
        else
            one=0;
    }
    if(a[start-1]==1 && start-1>=0)
        max_zero++;
    if(a[end+1]==1 && end+1<n)
        max_zero++;
    if((a[start2-1]==0 && start2-1>=0) || (a[end2+1]==0 && end2+1<n))
        max_one++;
    else
        max_one=0;
    if(max_zero>max_one)
        printf("%d\n",max_zero);
    else
        printf("%d\n",max_one);
    return 0;
}


#include <stdio.h>

int main()
{
    int n;
    while(scanf("%d", &n))
    {
        if(n % 2 != 0)
            printf("Ehab\n");
        else
            printf("Mahmoud\n");
    }
    return 0;
}


#include<stdio.h>
#include<limits.h>
int cross_main[25500];
int main(){
int time_h;
int time_m;
int a,b,c,d,e,f;
scanf("%d%d",&a,&b);
scanf("%d%d",&c,&d);
getchar();
scanf("%d:%d",&time_h,&time_m);
int i,m; int cnt=0;
for(i=time_h*60+time_m;i<=(time_h*60)+time_m+b;i++){
 cross_main[i]=1;
}
for(i=300;i<=(time_h*60)+time_m+b;i+=c){
int flag=0;
for(m=i+1;m<=i+d;m++){
if(cross_main[m] == 1)
flag=1;
}
if(flag){
    cnt++;
}
}
printf("%d",cnt);
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
	int a, ta, b, tb;
	scanf("%d%d%d%d", &a, &ta, &b, &tb);
	int h, min;
	scanf("%d%*c%d", &h, &min);
	min += h * 60 - 300;

	int bdepart = min - tb > 0 ? min - tb : 0;

	int ar = min + ta > 1140 ? 1140 : min + ta;

	printf("%d\n", (ar - 1) / b - (bdepart) / b + (bdepart == 0));
}


#include<stdio.h>
char s[100];
int main() {
    int k = 0,true=1, n, pos = 1, neg = 0;
    while (true) {
        char c;
        scanf(" %c", &c);
        scanf(" %c", &c);

        if (c == '=') break;
        if (c == '+') pos++;
        if (c == '-') neg++;

        s[k++] = c;
    }

    scanf("%d", &n);

    if (pos - n * neg > n || n * pos - neg < n) {
        printf("Impossible\n");

        return 0;
    }

    printf("Possible\n");

    int S = 0,i=0,x=1;
    for (i = 0; i < k; i++) {
        int sgn = 1;
        if (i > 0 && s[i - 1] == '-') sgn = -1;

        if (sgn == 1) pos--;
        if (sgn == -1) neg--;
        for (x = 1; x <= n; x++)
        {
            if (S + x * sgn + pos - n * neg <= n && S + x * sgn + n * pos - neg >= n) {
                printf("%d %c ", x, s[i]);

                S += x * sgn;

                break;
            }
            }
	}

    printf("%d = %d\n", abs(n), n);

    return 0;
}


#include<stdio.h>
int main()
{
	int a,ta;
	scanf("%d%d",&a,&ta);
	int b,tb;
	scanf("%d%d",&b,&tb);
	int h,m;
	scanf("%d:%d",&h,&m);
	int x,y,w=0,z=300;
	x=60*h+m;
	y=60*h+m+ta;
	jump:
		if(z+tb<x)
		{
			z=z+b;
			goto jump;
		}
		else if(z+tb>x && z<y)
		{
			w+=1;
			z=z+b;
			goto jump;
		}
		else if(z>y)
		{
			goto temp;
		}
		else if(z+tb==x || z==y)
		{
			z=z+b;
			goto jump;
		}
		temp:
		printf("%d\n",w);
	return 0;
}


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

int main() {
	long long i, p, q, d, k;

	scanf("%lld%lld", &p, &d);
	k = 1;
	for (i = 0; ; i = 10 * i + 9) {
		q = p / (i + 1) - 1;
		if (p - (q * k + i) > d) {
			k /= 10;
			i /= 10;
			break;
		}
		k *= 10;
	}
	q = p / (i + 1) - 1;
	printf("%lld\n", q * k + i);
	return 0;
}


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

int main()
{
    const int c =(pow(10,3));
    const int d =(pow(10,9));
    int n;

    do
    {
        scanf("%d",&n);
    }while(!((n>=1) && (n<=c)));

    int i;
    int T[c] ;

    for(i=0;i<n;i++)
    {
        do
        {
           scanf("%d",&T[i]);
           //printf("%d ",T[i]);
        }while(!((T[i]>=1)&& (T[i]<=d)));
    }
    int j;
    int s;
    for (i=0;i<n-1;i++)
    {
        int max=i;

        for (j=i+1;j<n;j++)
        {
            if(T[max]<=T[j])
            {
                max=j;
            }
        }
        if (max==i)
            {
                printf("%d ",0);
            }
             else
             {
                printf("%d ",T[max]-T[i]+1);
             }
    }
    printf("%d",0);

    return 0;
}


//#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int a,b,c,i,j,;
    scanf("%d %d %d",&a,&b,&c);
    printf("%d",(c-1)*(a+b-1)+2*b);
 //   getch();
    return(0);
}


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

void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}

int main(){
	int n,m,r;
	scanf("%d %d %d",&n,&m,&r);
	int s[n];
	int s_min;
	int b_temp = 0;
	int b_max = 0;
	int buy = 0;
	int flag = 0;
	for(int i=0;i<n;i++){
		scanf("%d",&(s[i]));
		if(i == 0){
			s_min = s[i];
		}
		if(s[i]< s_min){
			s_min = s[i];
		}
	}
	for(int i=0;i<m;i++){
		scanf("%d",&b_temp);
		if(b_temp > b_max){
			b_max = b_temp;
		}
	}
	if(s_min >= b_max){
		printf("%d\n",r);
	}
	else{
		buy = r/s_min;
		r = r-b*s_min;
		int count = r + buy*b_max;
		printf("%d\n",count);
	}

}


#include <stdio.h>
int main()
{
     int n,m,r;
     scanf("%d %d %d",&n,&m,&r);
     int s[n],b[m];
     int i,j;
     for(i=0;i<n;i++)
     {
          scanf("%d",&s[i]);
     }
     int min=s[0];
     for(i=0;i<n;i++)
     {
          if(s[i]<min)
          min=s[i];
     }
     for(j=0;j<m;j++)
     {
          scanf("%d",&b[j]);
     }
     int max=b[j];
     for(j=0;j<m;j++)
     {
          if(b[j]>max)
          max=b[j];
     }
     int ans;
     if(max>min)
     {
          ans=*(max-min)*5)+r;
     }
     else
     ans=r;
     printf("%d",ans);
}


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

int main()
{
    int n,m,r,s1[31],s2[31];
    int min_s=1001, max_b=0;
    scanf("%d %d %d",&n,&m,&r);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&s1[i]);
        min_s = min_s > s1[i] ? s1[i] : min_s;
    }
    for(int i=0;i<m;i++)
    {
        scanf("%d",s2[i]);
        max_b = max_b < s2[i] ? s2[i] : max_b;
    }
    if(min_s>=max_b)
        printf("%d",r);
    else
        printf("%d",r+(r/min_s)*(max_b-min_s));
}


#include <stdio.h>
#include <stdlib.h>
int func(const void * a,const void *b)
{
    return ( *(int*)b - *(int*)a );
}
int main()
{
    int i,j,n,m,r,s[1005],b[1005],x=0,t;
    scanf("%d %d %d",&n,&m,&r);
    t=r;
    for (i=0;i<n;i++)
    {
        scanf("%d",&s[i]);
    }
    for (i=0;i<n;i++)
    {
        scanf("%d",&b[i]);
    }
    qsort(s,n,sizeof(s[0]),func);
    qsort(b,m,sizeof(b[0]),func);
    if(s[n-1]<b[0])
    {
        x=r/s[n-1];
        r=r+x*b[0]-x*s[n-1]);
    }
    if(t>r)
        r=t;
    printf("%d\n",r);
    return 0;
}


/*Codeforces Round #200 (Div. 2)    B. Simple Molecules*/
#include <stdio.h>
int Max(int a[],int n);
int main()
{
    int a[4],x,y,z,i,max;
    for (i=1;i<=3;i++)
        scanf ("%d",&a[i]);
    max=Max(a,3);
    i=0;
    for (x=0;x<=max;x++)
    {
        for (y=0;y<=max;y++)
        {
            for (z=0;z<=max;z++)
            {
                if (x+y==a[2]&&y+z==a[3]&&x+z==a[1])
                {
                    printf ("%d %d %d\n",x,y,z);
                    i=1;
                    break;
                }
            }
        }
    }
    if (i==0)
        printf ("Impossible\n");
    return 0;
}
int Max(int a[],int n)
{
    int max=a[1],i;
    for (i=2;i<=n;i++)
    {
        if (max<a[i])
            max=a[i];
    }
    return max;
}


#include <stdio.h>

int main(void) {
    int a[3],i,j,n,f=0,g;
    for(i=0;i<3;i++)
    {
        scanf("%d",&a[i]);
    }
    n=a[0];
    for(i=0;i<=n;i++)
    {
        if((a[1]-i)==(a[2]-n+i))
        {
            if(a[i]-i<0 || a[2]-n+i<0)
            continue;
            f=1;
            break;
        }

    }
    if(f==1)
    printf("%d %d %d",i,a[1]-i,n-i);
    else
    printf("Impossible");

    return 0;
}


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

int main(int argc, char *argv[])
{
    int a, b, c;
    int x, y, z;
    int m1, m2, m3;
    int f;
    while(scanf("%d%d%d",&a, &b, &c) != EOF)
    {
        f = 1;
        m1 = a > b ? a : b;
        m2 = b > c ? b : c;
        m3 = a > c ? a : c;
        for(x = 0; x <= m1; x++)
        {
            for(y = 0; y <= m2; y++)
            {
                for(z = 0; z <= m3; z++)
                {
                    if((x + y == b)&&(x+z == a)&&(y+z == c))
                    {
                        printf("%d %d %d\n", x, y, z);
                        f = 0;
                        break;
                    }
                }
            }
        }
        if(f)
            printf("Impossible\n");
    }
    return 0;
}


#include<stdio.h>
int main()
{
int n,k,i,j,count,ans=0;
scanf("%d %d",&n,&k);
char *ar;
scanf("%s",ar);
for(i=0;i<n;i++)
{
count=0;
for(j=0;j<n;j++)
{
if(ar[i]==ar[j])
count++;
}
if(count>ans)
ans=count;
}
ans>k?printf("NO\n"):printf("YES\n");
return 0;

}


#include<stdio.h>

int main(){
    int w;
    scanf("%d",&w);
    if((!(w%2)) && (w!=0))
        printf("YES\n");
    else
        printf("NO\n");
    return 1;
}


#include <stdio.h>
#define ll long long
ll l,r,x,y,ans,tmp,i;
ll gcd(ll a,ll b){while(b)b^=a^= b^=a%=b;return a;}
int main(){
    scanf("%I64d%I64d%I64d%I64d", &l,&r,&x,&y);
    if(y%x) printf("0\n"); else
    for(i=x ; i*i<=y ; i+=x){
        tmp = x*y/i;
        if(i>=l && tmp<=r && gcd(i,tmp)==x) ans+=2;
    }
    if(x==y && x>=l && x<=r) ans++;
    printf("%I64d\n", ans);
}


#include <stdio.h>

int gcd(int, int);

int main() {
    int i, j, l, r, x, y, count;
    count = 0;
    scanf("%d %d %d %d", &l, &r, &x, &y);
    if (!(y % x))
    {
        for (i = l / x; i <= r / x; i++)
        {
            for (j = l / x; j <= r / x; j++)
            {
                if ((i * j == y / x) && (gcd(i, j) == 1)) count++;
            }
        }
    }
    printf("%d", count);
    return 0;
}

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


#include <stdio.h>
#include <stdlib.h>
#include<limits.h>
long long Veci(long long a,long long b)
{
    if (a>b)
        return a;
    else return b;
}
void swap(long long* a,long long* b)
{
    long long c;
    c=*a;
    *a=*b;
    *b=c;
}
long long Partition(long long *A, long long left, long long right)
{
    long long pivot = A[right], i = left, x;

    for (x = left; x < right; x++){
        if (A[x] <= pivot){
            swap(&A[i], &A[x]);
            i++;
        }
    }

    swap(&A[i], &A[right]);
    return i;
}
void QuickSort(long long Niz[],long long Levo,long long Desno)
{
    if(Levo<Desno)
    {
        long long pos;
        pos=Partition(Niz,Levo,Desno);
        QuickSort(Niz,Levo,pos-1);
        QuickSort(Niz,pos+1,Desno);
    }
}
long long x,y,l,r,i,j,p,A[60],B[60],p1,C[3600],raz=-1,br2=0,i,j,praz=0;
int main()
{
    int br,br1;
    scanf("%lld%lld%lld%lld",&x,&y,&l,&r);
    p=1;
    br=0;
    while (p<r)
    {
        A[br]=p;
        if (LLONG_MAX/p<x)
            p=r;
        else p=p*x;
        br++;
    }
    for(i=0;i<br;i++)
        printf("%lld\n",A[i]);
    br1=0;
    p1=1;
    while (p1<r)
    {
        B[br1]=p1;
        if (LLONG_MAX/p1<y)
            p1=r;
        else p1=p1*y;
        br1++;
    }
    for(i=0;i<br;i++)
        for(j=0;j<br1;j++)
        {
            C[br2]=A[i]+B[j];
            if (C[br2]<=r && C[br2]>=l)
                br2++;
        }
    if (br2==0)
        printf("%lld",r-l+1);
    else if (br2==r-l+1)
        printf("0");
    else {
        QuickSort(C,0,br2-1);
        for(i=1;i<br2;i++)
        {
            praz=C[i]-C[i-1]-1;
            if (praz>raz)
                raz=praz;
        }
        if (l!=C[0])
            raz=Veci(C[0]-l,raz);
        if (r!=C[br2-1])
            raz=Veci(r-C[br2-1],raz);
        printf("%lld",raz);
    }
    long long x;
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long ll;
ll MIN =  1111111111111111111;
ll MAX = -1111111111111111111;
ll max = -1111111111111111111;

void merge(ll arr[], ll l, ll m, ll r)
{
    ll i, j, k;
    ll n1 = m - l + 1;
    ll n2 =  r - m;

    /* create temp arrays */
    ll L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back llo arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(ll arr[], ll l, ll r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        ll m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}

ll power(ll x, ll y)
{
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

int main(ll argc, char const *argv[])
{
    ll T;
 //   scanf("%lld",&T);
    T = 1;
   // printf("%lld %lld %lld",MIN,MAX,max);
    for (ll tqw = 0; tqw < T; tqw++)
    {
        ll x,y,l,r ;
        scanf("%lld %lld %lld %lld",&x,&y,&l,&r);
        ll o = l;
        ll xcountl =  -1;
        while(o)
        {
            xcountl++;
            o = o/x ;
        }

        ll p = r;
        ll xcountr = 0;
        while(p)
        {
            xcountr++;
            p = p/x;
        }
        ll e = r;
        ll ycountr = 0;
        while(e)
        {
            ycountr++;
            e = e/y;
        }
        ll qw = l;
        ll ycountl = -1;
        while(qw)
        {
            ycountl++;
            qw = qw/y;
        }

         // printf("%lld %lld\n",xcountl,xcountr);

        ll totalcount = 0;
        ll A[1000000];
        ll idx = 0;
        for(ll s=xcountl;s<xcountr;s++)
        {
            ll u = 0;
            while(power(y,u)+power(x,s)<l)
            {
                u++;
            }
            while(power(y,u)+power(x,s)<=r)
            {
                A[idx] = power(y,u)+power(x,s) ;
                if(A[idx]>MAX)
                MAX = A[idx] ;
                if(A[idx]<MIN)
                MIN = A[idx] ;
                idx++;
                totalcount++;
                u++;
            }
        }
        for(ll s=ycountl;s<ycountr;s++)
        {
            ll u = 0;
            while(power(x,u)+power(y,s)<l)
            {
                u++;
            }
            while(power(x,u)+power(y,s)<=r&&u<xcountl)
            {
                A[idx] = power(x,u)+power(y,s) ;
                if(A[idx]>MAX)
                MAX = A[idx] ;
                if(A[idx]<MIN)
                MIN = A[idx] ;
                idx++;
                totalcount++;
                u++;
            }
        }
      /*  for(ll g=0;g<idx;g++)
        printf("|%lld|",A[g]);

*/
 //       printf("\n|%lld %lld|",MIN,MAX);
        mergeSort(A,0,idx-1);
        /* for(ll g=0;g<idx;g++)
      printf("|%lld|",A[g]);*/

       // printf("\n|%lld %lld|",MIN,MAX);
        for(ll sd = 1;sd<idx;sd++)
        {
            if(A[sd]-A[sd-1]-1>max&&A[sd]>0&&A[sd-1]>0)
            max = A[sd]-A[sd-1]-1 ;
          //  if(max<0)max=0;
        }
        ll finalanswer = 0;
        ll left = MIN-l;
        if(left<0)left = 0;
        ll right = r-MAX;
        if(right<0)right = 0;
      /*  printf("l %lld r %lld %lld|",left,right,max);*/
        if(left>right)
        {
            if(left>max)
            {
                finalanswer = left;
            }
            else
            {
                finalanswer = max ;
            }
        }
        else
        {
            if(right>max)
            {
                finalanswer = right;
            }
            else
            {
                finalanswer = max ;
            }
        }
        //  printf("<%lld>",totalcount);
        if(totalcount==0)
        {
            finalanswer = r-l+1 ;
        }
        if(l==1)
        {
        if(r-l+1-totalcount==0)
        printf("0\n");
        else
        {printf("%lld\n",finalanswer);}
        }

        else{
        if(r-l+1-totalcount==0)
        printf("0\n");
        else
        { printf("%lld\n",finalanswer);}
        }
    }
    return 0;
}


#include <stdlib.h>
#include <time.h>

int getNumber(){
    int number=0;
    char currentChar=getchar();
    while(currentChar>47&&currentChar<58){
        number*=10;
        number+=currentChar-48;
        currentChar=getchar();
    }
    return number;
}

int main(){
    int a=getNumber();
    int b=getNumber();
    if(a>b){
        printf("%i %i",b,(a-b)>>1);
    }else{
        printf("%i %i",a,(b-a)>>1);
    }
    return 1;
}


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

int main()
{
	int n;
	scanf("%d", &n);

	int arr[n];
	int i,j,k;

	for(i=0;i<n;i++)
	scanf("%d", &arr[i]);

	long long int count=0;
	int right=0;

	while(right!=n-1)
	{
		for(j=0;j<n;j++)
		{
			for(k=0;k<n;k++)
			{
				if(arr[j]==arr[k] && j!=k && arr[j]>0)
				{
					arr[j]-=1;
				}
			}
		}

		right=0;
		for(j=0;j<n-1;j++)
		{
			for(k=i+1;k<n;k++)
			{
				if(arr[j]==arr[k])
				break;
			}
			if(k!=n)
			right++;
		}
	}
	for(i=0;i<n;i++)
	{
		count+=arr[i];
	}

	/*for(i=0;i<n;i++)
	printf("%d ", arr[i]);
	printf("\n");*/

	printf("%lld", count);

	return 0;
}


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

int main()
{
	int n;
	scanf("%d", &n);

	int arr[n];
	int i,j,k;

	for(i=0;i<n;i++)
	scanf("%d", &arr[i]);

	long long int count=0;
	int right=0;

	while(right!=n)
	{
		for(j=0;j<n;j++)
		{
			for(k=0;k<n;k++)
			{
				if(arr[j]==arr[k] && j!=k && arr[j]>0)
				{
					arr[j]-=1;
				}
			}
		}

		right=0;
		for(j=0;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(arr[j]==arr[k])
				break;
			}
			if(k==n)
			right++;
		}
	}
	for(i=0;i<n;i++)
	{
		count+=arr[i];
	}

	/*for(i=0;i<n;i++)
	printf("%d ", arr[i]);
	printf("\n");*/

	printf("%lld", count);

	return 0;
}


#include <stdio.h>
#include <stdbool.h>
int main() {
    static int count[27];
    static bool check[27];
    int i,j,s=0,n,max = 0,value;
    count[0] = check[0] = 0;
    scanf("%d",&n);
    for(i=1; i<=n; i++) {
        scanf("%d",&value);
        count[value]++;
        check[value] = 1;
        if(value>max)
            max = value;
    }
    i = max;
    while(i) {
        if(count[i]) {
            s += i;
            count[i]--;
            while(count[i]) {
                j = i - 1;
                while(check[j])
                    j--;
                if(j) {
                    s += j;
                    check[j] = 1;
                }
                count[i]--;
            }
        }
        i--;
    }
    printf("%d",s);
    return 0;
}


#include<stdio.h>
int main()
{
    int m;
    scanf("%d",m);
    if(m%2)
    printf("ehab\n");
    printf("mahmuod\n");
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    int n,m,a,b;
    int i,j;
    scanf("%d",&n);
    scanf("%d",&m);
    scanf("%d",&a);
    scanf("%d",&b);
    int mincost[n];
    int cost=0;
    int z=0;
    if(a<b)
    {
        for(i=0;i<=1000;i++)
        {
            for(j=0;j<=1000;j=j+m)
            {
                if(i+j==n)
                {
                    cost=((a*i)+(b*(j/m)));
                    mincost[z]=cost;
                    z++;
                }
            }
        }
    }
    else if(b<a)
    {
        for(j=0;j<=1000;j=j+m)
        {
            if(j>=n)
            {
                cost=(b*(j/m));
                mincost[z]=cost;
                z++;
            }
        }
    }
    int min=mincost[0];
    for(i=0;i<z;i++)
    {
        if(min>mincost[i])
        {
            min=mincost[i];
        }
    }
    printf("%d",min);
}


#include <stdio.h>

int min(int a, int b) {
  return a <= b ? a : b;
}

int
main() {
  int a, ta, b, tb;
  int time_h, time_m;
  scanf("%d %d", &a, &ta);
  scanf("%d %d", &b, &tb);
  scanf("%d:%d", &time_h, &time_m);
  int m = (time_h - 5) * 60 + time_m;
  int bus_b = 0;
  for(int i = 0; i < (24 - 5) * 60; ++i) {
    if (i >= tb && i % b == 0) {
      --bus_b;
    }
    if (i == m) {
      for(int j = i; j < min((24 - 5) * 60, m + ta); ++j) {
        if (j % b == 0) {
          ++bus_b;
        }
      }
      break;
    }
    if (i % b == 0) {
      ++bus_b;
    }
  }
  printf("%d\n", bus_b);
  return 0;
}


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

void main() {
	char *s = (char*)malloc(sizeof(char)*101);
	scanf("%[^\n]",s);
	int result = 0;
	int i=0,j=0;
	while(s[i]!='\0') {
		j=i+1;
		int count = 1;
		while(s[j]!='\0' && s[i]==s[j]) {
			count++;
			j++;
		}
		if(count%2==0) {
			result++;
		}
		if(j=='\0') {
			break;
		}
		i=j;
	}
	printf("%d",result);
}


#include <iostream>
#include "string.h"
#include "stdio.h"
using namespace std;

int main(){
    char s[101];
    int i, j, len, numA=0, toAdd=0;

    scanf("%s", s);

    len = strlen(s);

    for(i = 0; i < len; i++){
        numA = 0;
        for(j = i; s[i] == s[j]; j++){
            numA++;
        }
        i = j - 1;
        if(!(numA % 2)){
            toAdd++;
        }
    }
    printf("%d\n", toAdd);

    return 0;
}


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

#define MAX(a, b) (a>b?a:b)
#define MIN(a, b) (a<b?a:b)
#define MOD 1000000007

int compare(const void* a, const void* b) {
    return *(int*)a-*(int*)b;
}

void testCase() {
    long long int n, i;
    scanf("%lld", &n);
    char s[101];
    scanf("%s", s);
    int res=0;
    for(i=0;s[i]!='\0';i++) {
        char x = s[i];
        int count = 0;
        while(i < n) {
            i++;
            if(s[i] == x) {
                count++;
            }
            else
                break;
        }
        i--;
        if(count%2)
            res++;
    }
    printf("%d\n", res);
}

int main() {
    int t=1;
    // scanf("%d", &t);
    while(t--) {
        testCase();
    }
    return 0;
}


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

int main()
{
    char str[102];
    while ((scanf("%s", str)))
    {
        int length = strlen(str);
        int count = 0;
        int i = 0;
        while (i < length)
        {
            int j = i + 1;
            while (j < length && str[j] == str[j - 1])
                j++;

            int diff = j - i;
            if (diff && diff % 2 == 0)
                count++;

            i = j;
        }
        print("%d\n", count);
    }

    return 0;
}


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

int main()
{
    char str[102];
    while ((scanf("%s", str)))
    {
        int length = strlen(str);
        int count = 0;
        int i = 0;
        while (i < length)
        {
            int j = i + 1;
            while (j < length && str[j] == str[j - 1])
                j++;

            int diff = j - i;
            if (diff && diff % 2 == 0)
                count++;

            i = j;
        }
        printf("%d\n", count);
    }

    return 0;
}


#include<stdio.h>
char str[101];
int main()
{
   scanf("%s", str);
   int len = 1, index = 0, result = 0;
   while(str[index++]) {
        if (str[index] == str[index - 1]) {
            len++;
        } else {
            if (len % 2 == 0)
                result++;
            len = 1;
        }
   }
   printf("%d\n",result);
}
~


#include <stdio.h>

#define N 100

int main(void)
{
    size_t n;
    size_t ret;
    size_t p1 = 0;
    size_t p2 = 0;
    static char seq[N + 1];

    for (n = 0; n < N; ++n) {
        char byte;

        scanf("%c", &byte);
        if ((byte != 'A')
        &&  (byte != 'T')
        &&  (byte != 'G')
        &&  (byte != 'C'))
            break;

        seq[n] = byte;
    }

    ret = 0;
    while ((p1 < n) && (p2 < n)) {
        if (seq[p1] == seq[p2]) {
            ++p1;
        } else {
            if (((p1 - p2) % 2) == 0) {
                ++ret;
            }
            p2 = p1;
        }
    }

    printf("%zu\n", ret);

    return 0;
}


#include <stdio.h>

int main(void){
int k;
scanf("%d", k);
int cnt[10];
for (int i=0; i<10; i++)
cnt[i] = 2 * k;
char c;
while ((c = getchar()) != EOF)
if (c >= '0' && (c -= '0') <= 9)
if (!(cnt[c]--)){
printf("NO\n");
return 0;
}
printf("YES\n");
}


#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    if(n%2==0)
    {
        printf("Mahmud\n");
    }
    else if(n%2!=0)
    {
        printf("Ehab\n");
    }

    return 1;
}


#include<stdio.h>
main()
{
int n;
scanf("%d",n);
if(n%2==0)
printf("Ehab");
else
printf("Mahmoud");
return 0;
}


#include<stdio.h>

int main()
{

    int n,a,f=0;
    scanf("%d",&n);
    a=1;
    while(a>0)
    {
        if(a%2!=0)
        {
            f=0;
            a=n-a;
        }
        else
        {
            f=1;
            a=n-a;
        }
    }
    if(f==0)
        printf("Ehab");
    else
        printf("Mahmoud");
    return 0;
}


#include<stdio.h>

int main()

{
    long long n,i,count=0,count1=0;

    scanf("%lld",&n);
long long  a[n];
    for(i=0; i<n; i++)

    {
        a[i]=i+1;

    }

    for(i=0; i<n; i++)
       {
         if(a[i]%2==0)
            count++;
       }

 for(i=0; i<n; i++)
       {
         if(a[i]%2!=0)
            count1++;
       }

if(count>count1 || count==count1)
     printf("Mahmoud");

else
   printf("Ehab");

}


#include<stdio.h>
void main()
{
int a=9;

if(a%2==0)
{
printf("YES");
}
else
{
printf("NO");
}
}


#define _CRT_SECURE_NO_WARNINGS

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

typedef uint64_t uint64; typedef uint32_t uint32;
typedef int64_t int64; typedef int32_t int32;

#define finc(i,a,b) for(int32 i=(a);i<=(b);i++)
#define fdec(i,a,b) for(int32 i=(b)+1;i-->(a);)
#define in(i,bits) scanf("%"PRId##bits"",&i)
#define uin(i,bits) scanf("%"PRIu##bits"",&i)
#define out(i,bits,c) printf("%"PRId##bits"%c",i,c)
#define uout(i,bits,c) printf("%"PRIu##bits"%c",i,c)
#define end '\n'

#define mod (int64)(1e9+7)
int64 C[1001][1001], A[1001];
int main(void)
{
	C[0][0] = 1;
	finc(i, 1, 1000)
	{
		C[i][0] = 1;
		C[i][1] = i;
	}
	finc(i, 2, 1000)
	{
		finc(j, 2, i)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
	}
	A[0] = 1, A[1] = 1;
	finc(i, 2, 1000)
		A[i] = (A[i - 1] * i) % mod;

	int32 n, x, index;
	in(n, 32); in(x, 32); in(index, 32);

	int32 totalup = n - x, totaldown = x - 1;
	int32 cup = 0, cdown = 0;
	int32 left = 0, right = n - 1;
	while (left != right)
	{
		int32 mid = (left + right) / 2;
		if (mid < index)
		{
			left = mid + 1;
			cdown++;
			continue;
		}
		if (mid > index)
		{
			right = mid;
			cup++;
			continue;
		}
		break;
	}
	int64 a = (C[totaldown][cdown] * A[cdown]) % mod;
	int64 b = (C[totalup][cup] * A[cup]) % mod;
	int64 ans = (((a * b) % mod) * A[n - 1 - cup - cdown]) % mod;
	out(ans, 64, end);

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

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

typedef uint64_t uint64; typedef uint32_t uint32;
typedef int64_t int64; typedef int32_t int32;

#define finc(i,a,b) for(int32 i=(a);i<=(b);i++)
#define fdec(i,a,b) for(int32 i=(b)+1;i-->(a);)
#define in(i,bits) scanf("%"PRId##bits"",&i)
#define uin(i,bits) scanf("%"PRIu##bits"",&i)
#define out(i,bits,c) printf("%"PRId##bits"%c",i,c)
#define uout(i,bits,c) printf("%"PRIu##bits"%c",i,c)
#define end '\n'

#define mod (int64)(1e9+7)
int64 C[1001][1001], A[1001];
int main(void)
{
	C[0][0] = 1;
	finc(i, 1, 1000)
	{
		C[i][0] = 1;
		C[i][1] = i;
	}
	finc(i, 2, 1000)
	{
		finc(j, 2, i)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
	}
	A[0] = 1, A[1] = 1;
	finc(i, 2, 1000)
		A[i] = (A[i - 1] * i) % mod;

	int32 n, x, index;
	in(n, 32); in(x, 32); in(index, 32);

	int32 totalup = n - x, totaldown = x - 1;
	int32 cup = 0, cdown = 0;
	int32 l = 0, r = n;
	while (l<r)
	{
		int32 mid = (l + r) / 2;
		if (mid <= index)
		{
			cup++;
			l = mid + 1;
			continue;
		}
		if (mid > index)
		{
			cdown++;
			r = mid;
		}
	}
	int64 a = (C[totaldown][cdown] * A[cdown]) % mod;
	int64 b = (C[totalup][cup] * A[cup]) % mod;
	int64 ans = (((a * b) % mod) * A[n - 1 - cup - cdown]) % mod;
	out(ans, 64, end);

	return 0;
}


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

int main ()
{
	long long n,x,pos;
	const long long mod=1e9+7;
	scanf("%d %d %d",&n,&x,&pos);
    long long  l=0,r=n;
    long long min=x-1,max=n-x;
    long long mid;
    long long num=1;
    while (l<r)
    {
        mid=(l+r)/2;
        if(mid<pos)
        {
            l=mid+1;
            num=num*min%mod;
            min--;
        }
        else if(mid==pos)
			l=mid+1;
        else
        {
            r=mid;
            num=num*max%mod;
            max--;
        }
    }
    for(long long i=1;i<=max+min;i++)
    {
        num=num*i%mod;
    }
    printf("%d",num);
}


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

int main ()
{
	int n,x,pos;
	const int mod=1e9+7;
	scanf("%d %d %d",&n,&x,&pos);
    int  l=0,r=n;
    int min=x-1,max=n-x;
    int mid;
    int num=1;
    while (l<r)
    {
        mid=(l+r)/2;
        if(mid<pos)
        {
            l=mid+1;
            num=num*min%mod;
            min--;
        }
        else if(mid==pos)
			l=mid+1;
        else
        {
            r=mid;
            num=num*max%mod;
            max--;
        }
    }
    for(int i=1;i<=max+min;i++)
    {
        num=1ll*num*i%mod;
    }
    printf("%d",num);
}


#include <stdio.h>

#define N	100

struct ball {
	int c, cnt;
} bb[N];

int count(struct ball *bb, int n, int i) {
	int l, r, k;

	k = bb[i].cnt;
	for (l = i - 1, r = i + 1; l >= 0 && r < n && bb[l].cnt + bb[r].cnt >= 3; l--, r++)
		k += bb[l].cnt + bb[r].cnt;
	return k;
}

int main() {
	int n, k, x, c_, l, i, max, cnt;

	scanf("%d%d%d", &n, &k, &x);
	c_ = -1;
	l = -1;
	for (i = 0; i <= n; i++) {
		int c;

		if (i < n)
			scanf("%d", &c);
		if (i == n || c_ != c) {
			l++;
			if (i < n) {
				bb[l].cnt = 1;
				bb[l].c = (c_ = c);
			}
			c_ = c;
		} else
			bb[l].cnt++;
	}
	max = 0;
	for (i = 0; i < l; i++)
		if (bb[i].c == x && bb[i].cnt == 2) {
			cnt = count(bb, l, i);
			if (max < cnt)
				max = cnt;
		}
	printf("%d\n", max);
	return 0;
}


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

int Destroy(int *Data, int Len)
{
    int i, j;
    int Pre = Data[0];
    int Con = 1;
    for(i=1; i<Len; ++i)
    {
        if(Data[i] == Pre)
        {
            ++Con;
        }
        else
        {
            if(Con > 2)
            {
                for(j=i-Con; j<i-Con+Len-Con; ++j)
                {
                    Data[j] = Data[j+Con];
                }
                return Len + Destroy(Data, Len-Con);
            }
            else
            {
                Pre = Data[i];
                Con = 1;
            }
        }
    }
    return 0;
}

int Fun(int *Data, int Len, int idx)
{
    int Array[101];
    memcpy(Array, Data, idx*sizeof(int));
    Array[idx] = Data[idx - 1];
    memcpy(Array+idx+1, Data+idx, (Len-idx)*sizeof(int));
    return Destroy(Array, Len+1);
}

int main()
{
    int N, K, X, i, Max, Sum;
    int Data[101];
    scanf("%d %d %d", &N, &K, &X);
    for(i=0; i<N; ++i)
    {
        scanf("%d", &Data[i]);
    }
    Max = 0;
    for(i=0; i<N; ++i)
    {
        if(Data[i]==X && i>0 && Data[i-1]!=X)
        {
            Sum = Fun(Data, N, i+1)-1;
            if(Sum > Max)
            {
                Max = Sum;
            }
        }
    }
    printf("%d\n", Max);
    return 0;
}


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

int Destroy(int *Data, int Len)
{
    int i, j;
    int Pre = Data[0];
    int Con = 1;
    for(i=1; i<Len; ++i)
    {
        if(Data[i] == Pre)
        {
            ++Con;
        }
        else
        {
            if(Con > 2)
            {
                for(j=i-Con; j<i-Con+Len-Con; ++j)
                {
                    Data[j] = Data[j+Con];
                }
                return Con + Destroy(Data, Len-Con);
            }
            else
            {
                Pre = Data[i];
                Con = 1;
            }
        }
    }
    if(Con > 2)
    {
        return Con + Destroy(Data, Len-Con);
    }
    return 0;
}

int Fun(int *Data, int Len, int idx)
{
    int Array[101];
    memcpy(Array, Data, idx*sizeof(int));
    Array[idx] = Data[idx - 1];
    memcpy(Array+idx+1, Data+idx, (Len-idx)*sizeof(int));
    return Destroy(Array, Len+1);
}

int main()
{
    int N, K, X, i, Max, Sum;
    int Data[101];
    scanf("%d %d %d", &N, &K, &X);
    for(i=0; i<N; ++i)
    {
        scanf("%d", &Data[i]);
    }
    Max = 0;
    for(i=0; i<N; ++i)
    {
        if(Data[i]==X && i>0 && Data[i-1]==X)
        {
            Sum = Fun(Data, N, i+1)-1;
            if(Sum > Max)
            {
                Max = Sum;
            }
        }
    }
    printf("%d\n", Max);
    return 0;
}


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

int a[105],b[105];

int n,k,x,ans=0;

int Ins(int pos)
{
    int l,r,num,flag,now;
    num=0;
    l=pos;r=pos+1;
    if (a[l]==x&&a[r]==x) { num+=2;l=pos-1;r=pos+2;} else return 0;
    do
    {
        flag=0;
        if (a[l]!=a[r]) break; else now=2;
        while (l>1&&a[l-1]==a[l]) { l--;now++; }
        while (r<n&&a[r]==a[r+1]) { r++;now++; }
        if (now>=3) { num+=now;flag=1; }
        if (flag==0) break;
    }while(1);
    if (num>ans) ans=num;
    return 0;
}

int main()
{
    int i,j;
    scanf("%d %d %d",&n,&k,&x);
    memset(a,0,sizeof(a));
    for (i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    if (n==1) ans=0;
    else
    {
        for (i=1;i<n;i++)
        {
            Ins(i);
            for (j=1;j<=n;j++)
              a[i]=b[i];
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

int ball[128], tmp[128], pre[128], next[128], n, ans;
void merge(int k, int c)
{
	int cnt=-1, i, pa, pb;

	for (i=k; i!=-1 && tmp[i]==c; i=pre[i]) {
		cnt++;
		pa = i;
	}
	for (i=k; i!=n && tmp[i]==c; i=next[i]) {
		cnt++;
		pb = i;
	}
	if (cnt >= 3) {
		ans += cnt;
		if (pre[pa]!=-1 && next[pb]!=n) {
			next[pre[pa]] = next[pb];
			pre[next[pb]] = pre[pa];
		}
		else if (pre[pa] != -1) {
			next[pre[pa]] = n;
		}
		else if (next[pb] != n) {
			pre[next[pb]] = -1;
		}
		else {
			return;
		}
	}
	if (pre[pa] != -1)
		merge(pre[pa], tmp[pre[pa]]);
	else if (next[pa] != n)
		merge(next[pa], tmp[next[pa]]);

	return;
}

int main(void)
{
	int k, i, j, max, t;

	scanf("%d%*d%d", &n, &k);
	for (i=0; i<n; i++)
		scanf("%d", &ball[i]);
	max = 0;
	for (i=0; i<n; i++)
		if (ball[i]==k && ball[i+1]==k) {
			memcpy(tmp, ball, 128*4);
			for (j=0; j<n; j++) {
				pre[j] = j-1;
				next[j] = j+1;
			}
			ans = 0;
			t = n+1;
			tmp[t] = k;
			pre[t] = i-1;
			next[t] = i;
			next[i-1] = pre[i] = t;
			merge(t, tmp[i]);
			if (ans > max)
				max = ans;
		}
	if (!max)
		max = 1;
	printf("%d\n", max-1);

	return 0;
}


#include<stdio.h>
int main()
{
	int n,k,x,i,max=0,start,end;
	scanf("%d%d%d",&n,&k,&x);
	int A[n],consecutive[n-1],count=0,count2=0,temp,temp2,tempcount;
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
	for(i=0;i<n-1;i++)
	{
		if(A[i]==A[i+1] && A[i]== x)
			consecutive[count++]=i;
	}
	//printf("%d\n",count );
	for(i=0;i<count;i++)
	{
		start=consecutive[i];
		end=consecutive[i]+1;
		start--;
		end++;
		tempcount=2;
		while(start!=-1 && end != n)
		{
			count2=0;
			if(A[start]==A[end] && (start && A[start-1]==A[end]) && (end!=n-1 && A[start]==A[end+1]))
				count2=4,start-=2,end+=2;
			else if((A[start]== A[end])&&(start && A[start-1]==A[end]))
				count2=3,start-=2,end+=1;
			else if((A[start]==A[end])&&(end!=n-1 && A[start]==A[end+1]))
				count2=3,start-=1,end+=2;
			else
				;
			if(count2>=3)
				tempcount=tempcount+count2;

		}

		if(tempcount>max)
			max=tempcount;
	}
	printf("%d\n",max );
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    scanf("%d",&n);
    char s[50];
    scanf("%s",s);
    int count=0,c=0;
    for(int i=0;i<n;i++)
    {

        if(s[0]=='S'&& s[n-1]=='F')
        {

            count++;
        }
        else if(s[0]=='F'&& s[n-1]=='S')
        {
            c++;
        }
    }
    if(count>c)
    {
        printf("YES");
    }
    else
    {
      printf("NO");
    }

    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j=0,k=0;
    scanf("%d",&n);
    char a[n];
    scanf("%s",a);
    for(i=0;i<n;i++){
        if(0==strcmp(a[i],"S") && 0==strcmp(a[i+1],"F")){
            j++;
        }
        else if(0==strcmp(a[i],"F") && 0==strcmp(a[i+1],"S")){
            k++;
        }
    }
    if(j>k){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}


#include <stdio.h>

int main()
{
    freopen ("input.txt","r",stdin);
    freopen ("output.txt","w",stdout);
     int a=0,b=0,c=0;
     scanf ("%d %d %d",&a,&b,&c);
     printf ("%d",a*b*c-(a-1)*(b-1)*(c-1));

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",(b+1)*(c+1)-a*(a-1));
    return 0;
}


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


#include<stdio.h>
man()
{
    int n,k,l,c,d,z,p,y,nl,x,np;
    scanf("%d %d %d %d %d %d %d %d",&n,&k,&l,&c,&d,&p,&nl,&np);
    x=k*l/nl;
    y=c*d;
    z=p/np;
      if(x<y&&x<z)
    printf("%d",x/n);
      if(x>y&&y<z)
    printf("%d",y/n);
      if(x>z&&y>z)
    printf("%d",z/n);
}


#include<stdio.h>
int main()
{
     int n,k,l,c,d,p,nl,np;
     scanf("%d %d %d %d %d %d %d %d",&n,&k,&l,&c,&d,&p,&nl,&np);
     ///printf("n=%d\nk=%d\nl=%d\nc=%d\nd=%d\np=%d\nnl=%d\nnp=%d\n",n,k,l,c,d,p,nl,np);
     int cdt=c*d;
     int drinkt=k*l;
     int s,q,i;
     s=drinkt/nl;
     q=p/np;
     int a[]={cdt,s,q};
     int min=a[0];
     for(i=0;i<3;i++)
     {
          if(a[i]<min)
          {
               min=a[i];
          }
     }
     printf("%d\n"min);
}


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

int main() {
        int n;
        scanf("%d", &n);
        char s[n];
        scanf("%s", s);
        char alphabet[26] = "abcdefghijklmnopqrstuvwxyz";
        int cur = 25;
        int deleted = 0;
        while(cur != 0 && (n - deleted) != 1) {
                int found = 0;
                // printf("Cur: %i Str: %s Del: %i\n", cur, s, deleted);
                for (int i = 0; i < (n - deleted); i++) {
                        if (alphabet[cur] == s[i]) {
                                if (i != (n - deleted) - 1) {
                                        if (alphabet[cur-1] == s[i+1]) {
                                                for (int j = i; j < n-1; j++) {
                                                        s[j] = s[j+1];
                                                }
                                                s[n - deleted - 1] = '\0';
                                                found = 1;
                                                deleted += 1;
                                                i--;
                                        }
                                }
                                if (i != 0) {
                                        if (alphabet[cur-1] == s[i-1]) {
                                                for (int j = i; j < n-1; j++) {
                                                        s[j] = s[j+1];
                                                }
                                                s[n - deleted - 1] = '\0';
                                                found = 1;
                                                deleted += 1;
                                                i--;
                                        }
                                }
                        }
                }

                if (found == 0) {
                        cur -= 1;
                }
        }
        printf("%d", deleted);
}
// strcpy(&str[idx_to_delete], &str[idx_to_delete + 1]);
// RemoveAdjacent.c


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

#define in32(x) scanf("%d", &x)
#define out32(x) printf("%d\n", (x))
#define in64(x) scanf("%lld", &x)
#define out64(x) printf("%lld\n", (x))
#define inStr(x) scanf("%s", x)
#define outStr(x) printf("%s\n", (x))
#define fo(a,b,c) for(a=b;a<=c;a++)
#define of(a,b,c) for(a=b;a>=c;a--)

void sort(int * a, int size) {
   if (size <= 10) {

   }
}

int main() {
   char w[101], c;

   int ans=0,n,i,j;
   in32(n);
   inStr(w);
   of(c,'z','b') {
      fo(i,0,n) {
         if (w[i]==c &&
            ((i && w[i-1]==c-1) ||
            (i<n-1 && w[i+1]==c-1))) {
            fo(j,i,n-1){
               w[j]=w[j+1];
            }
            i--;
            n--;
            ans++;
         }
      }
   }
   out32(ans);
   return 0;
}


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

char maxChar (char *str)
{
    char c = str[0];

    for ( int i = 1; str[i] != '\0'; i++)
    {
        if (c < str[i])
        {
            c = str[i];
        }
    }
    return c;
}
int testRoutine (char *str)
{
    for (int i = 0; str[i] != '\0'; i++)
    {
        if (str[i] == (str[i+1] - 1) || str[i] == (str[i-1] - 1))
        {
            return 1;
        }
    }
    return 0;
}

void search (char *str, char max, int pos)
{
    if (max == 'a')
        return;
    else if (str[pos] == '\0')
    {
        return search(str,max-1,0);
    }
    else if (str[pos] != max)
    {
        return search(str, max, pos + 1);
    }
    else if (str[pos] == max)
    {
        while (str[pos] == (str[pos+1] + 1) || str[pos] == (str[pos-1] + 1))
        {
            for ( int i = pos; str[i] != '\0'; i++)
                str[i] = str[i+1];
        }
        return search(str,max,pos+1);
    }
    else
    {
        return search(str,max,pos+1);
    }
}

int main ()
{
    int size;
    scanf("%d", &size);
    char str[size];
    scanf("%s", str);
    char lel;

    while (testRoutine(str))
    {
        lel = maxChar(str);
        search(str,lel,0);

    }

    printf("%d\n", (size - strlen(str)));

    return 0;
}


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

char maxChar (char *str)
{
    char c = str[0];

    for ( int i = 1; str[i] != '\0'; i++)
    {
        if (c < str[i])
        {
            c = str[i];
        }
    }
    return c;
}
int testRoutine (char *str)
{
    for (int i = 0; str[i] != '\0'; i++)
    {
        if (str[i] == (str[i+1] - 1) || str[i] == (str[i-1] - 1))
        {
            return 1;
        }
    }
    return 0;
}

void search (char *str, char max, int pos)
{
    if (max == 'a' || str[pos] == '\0')
        return;
    else if (str[pos] != max)
    {
        return search(str, max, pos + 1);
    }
    else if (str[pos] == max)
    {
        while (str[pos] == (str[pos+1] + 1) || str[pos] == (str[pos-1] + 1))
        {
            for ( int i = pos; str[i] != '\0'; i++)
                str[i] = str[i+1];
        }
        return search(str,max,pos+1);
    }
    else
    {
        return search(str,max,pos+1);
    }
}

int main ()
{
    int size;
    printf("enter size and string\n");
    scanf("%d", &size);
    char str[size];
    scanf("%s", str);
    char lel;

    while (testRoutine(str))
    {
        lel = maxChar(str);
        search(str,lel,0);

    }
    printf("%s\n%d\n", str, strlen(str));
    printf("%d\n", (size - strlen(str)));

    return 0;
}


#include <stdio.h>
#include <string.h>
void gogo(char a[], int j, int s, int r)
{
    for (int k = 0; k < r; k++)
        for (int i = j; i < s; i++)
        {
            a[i] = a[i + 1];
        }
}
int main(void)
{
    int s, counts = 0;
    char a[105] = {0};
    scanf("%d", &s);
    for (int i = 0; i < s; i++)
    {
        scanf(" %c", &a[i]);
    }
    for (int i = 'z'; i >= 'a'; i--)
    {
        for (int j = 0; j < strlen(a); j++)
        {
            int num = 0;
            if (a[j] == i)
            {
                if (a[j - 1] == i + 1)
                {
                    for (int k = j - 1; k >= 0; k--)
                    {
                        if (a[k] == a[j - 1])
                        {
                            num++;
                        }
                        else
                            break;
                    }
                    gogo(a, j - num, strlen(a), num);
                    counts += num;
                    if (num != 0)
                    {
                        j = 0;
                        num = 0;
                    }
                }
                if (a[j + 1] == i + 1)
                {
                    for (int k = j + 1; k < strlen(a); k++)
                    {
                        if (a[k] == a[j + 1])
                        {
                            num++;
                        }
                        else
                            break;
                    }
                    gogo(a, j + 1, strlen(a), num);
                    counts += num;
                    if (num != 0)
                    {
                        j = 0;
                        num = 0;
                    }
                }
            }
        }
    }
    puts(a);
    printf("%d\n", counts);
}


#include<stdio.h>
void main()
{
    int i,a,b,x,y,count=0;
    scanf("%d%d%d%d",&x,&y,&a,&b);
    for(i=a; i<=b; i++)
    {
        if(i%x==0)
        {
            if(i%y==0)
            {
                count++;
            }
        }
    }
    printf("%d",count);
}


#include<stdio.h>
int main()
{
    int x,y,a,b,max,lcm,i,ans,d;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    max=y;
    if(x>=y)
    max=x;
    lcm=x*y;
    for(i=max;i<=x*y;i++)
    {
        if(i%x==0&&i%y==0)
        {
        lcm=i;
        break;
        }
    }
    int count=0;
    for(i=a;i<=b;i++)
    {
        if(i%lcm==0)
        count++;
    }
    printf("%d",count);
    return 0;
}


#include <stdio.h>
#include <inttypes.h>
int main()
{
	int64_t x,y,a,b,i,count=0;
	scanf("%"PRId64" %"PRId64" %"PRId64" %"PRId64" ",&x,&y,&a,&b);
	for(i=a;i<=b;i++)
	{
		if(i%x==0 && i%y==0)
			count++;
	}
	printf("%"PRId64"",count);
	return 0;
}


#include <stdio.h>
int main()
{
    int a,b,x,y,sum,i,j;
    while(scanf("%d%d%d%d",&a,&b,&x,&y)!=EOF)
    {
        sum=0;
        for(i=x;i<=y;i++)
        {
            if(i%a==0)
            break;
        }
        for(j=i/a;j*a<=y;j++)
        {
            if((a*j)%b==0)
            sum++;
        }
        printf("%d\n",sum);
    }
    return 0;
}


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

long long int gcd(long long int a, long long int b) {
	while (b != 0) {
		long long int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

int main(void) {
	int l, r, x, y;
	scanf("%d%d%d%d", &l, &r, &x, &y);

	long long int mul = (long long int) x * y;
	int cnt = 0;
	for (long long int i = l; i <= r; i++) {
		long long int div = mul/i;
		if (mul % i != 0 || gcd(i, div) != 1) {
			continue;
		}
		cnt += div >= l && div <= r;
	}

	printf("%d\n", cnt);
}


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

long long int gcd(long long int a, long long int b) {
	while (b != 0) {
		long long int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

int main(void) {
	int l, r, x, y;
	scanf("%d%d%d%d", &l, &r, &x, &y);

	if (y % x != 0) {
		printf("0\n");
		return 0;
	}
	y /= x;
	l /= x;
	r /= x;

	int cnt = 0;
	for (long long int a = 1; a*a <= y; a++) {
		if (y % a != 0) {
			continue;
		}
		long long int b = y/a;
		if (gcd(a, b) == 1
			&& a >= l && a <= r
			&& b >= l && b <= r) {
			cnt += 1 + (a != b);
		}
	}
	printf("%d\n", cnt);
}


//489nastyastudiesinformatics
#include<stdio.h>
typedef long long ll;
void swap(ll *a,ll *b)
{
  *a^=*b;
  *b^=*a;
  *a^=*b;
}
ll gcd(ll a, ll b)
{
  while(b)
  {
    a %= b;
    swap(&a,&b);
  }
  return a;
}
int main()
{
  ll l,r,x,y;
  scanf("%lld %lld %lld %lld",&l,&r,&x,&y);
  if(y%x)
  {
    printf("0\n");
    return 0;
  }
  y=y/x;
  ll i,c;
  for( i=1,c=0 ;i*i<=y;i++)
    if(y%i==0 && x*i>=l && (x*y)/i<=r && gcd(i,y/i)==1)
    //or gcd(x*i,x*(y/i))==x,then lcm will also be y(a*b=x*y)
      c += 1 + (i!=1);
  printf("%lld\n",c);
  return 0;
}


#include <stdio.h>
int gc,lm;
int check(int a, int b)  // checking gcd lcm
{
  int r,min,max;
  if (a>=b) {max=a; min=b;}
  else {max=b; min=a;}
  while (1)
  {
    r=max%min;
    if (r==0) break;
    max=min;
    min=r;
  }
  r=(a/min)*b;
  if (gc==min && lm==r) return 1;
  else return 0;
}
int main()
{
   int h,l,i,j,k=0,r,count=0;
   int ar[40000];
   scanf("%d %d %d %d",&l,&h,&gc,&lm);
   for (i=l; i*i<=lm; i++)
   {
     if (i>h) break;
     if (lm%i==0)
     {
      r=lm/i;
      if (r==i) ar[++k]=r;
      else
      {
        if (r<=h) ar[++k]=r;
        if (i<=h) ar[++k]=i;
      }
     }
   }
   for (i=1; i<=k; i++)
   {
     for (j=i; j<=k; j++)
     {
       r=check(ar[i],ar[j]);
       if (r)
       {
         if (ar[i]==ar[j]) count++;
         else count+=2;
       }
     }
   }
   printf("%d\n",count);

}


#include<stdio.h>

main()
{
    int w,p,i;

    printf("Give weight");

    scanf("%d",&w==EOF);

    while((w%2==0)&&(1<=w || w<=100))
    {
        p=w/2;

        if(p%2!=0)
        {

            printf("No");

            break;
        }

        else
        {

            printf("yes");

            break;
        }

    }

    }


#include <stdio.h>
void main()
{
	int a = 0;
    scanf("%d", a);
    if (a%2 == 0)  printf("YES\n");
    else printf("NO\n");
    return 0;
}


#include<stdio.h>
int main()
{
          int w;
          printf("Enter the weight of the watermelon ");
          scanf("%d",w);
          if(w<0 && w>100)
          printf("NO");
          else if (w%2==0)
          printf("YES");
          else
          printf("NO");
          return 0;
}


#include <stdio.h>

long long int P(int b, int exp)
{
    long long int r = 1, i;

    for(i=1;i<=exp;i++)
        r *= b;

    return b;
}

int main()
{
    scanf("%d", &n);

    printf("%lld", P(2, n + 1) - 2);

    return 0;
}


#include<stdio.h>
#include<malloc.h>

int main()
{
 int n,m,a,b,ans=0;
 scanf("%d %d %d %d",&n,&m,&a,&b);
ch:
 if(m>=n && b<=n*a) ans+=b;
 else if(m>=n && b>n*a) ans+=n*a;
 else if(b < m*a)
	{
	  ans+=b*(n/m);
			n-=(n/m)*m;
		}
		if(n > 0) goto ch;
	printf("%d",ans);
		return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,a,b,c=0,k=0;
    char day[50];
    scanf("%d",&n);
    scanf("%s",day);
    for(i=0; i<n; i++)
    {
        a=day[i];
        b=day[i+1];
        if(a=='S'&&b=='F')
            c++;
        if(a=='F'&&b=='S')
            k++;
    }
    if(c-k>0)
        printf("YES");
    else
        printf("NO");

    return 0;
}


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

typedef int64_t i64;
typedef int32_t i32;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

const i32 mod = 1000000007;

#define ADD(x, a) do{(x) += (a); if ((x) >= mod) (x) -= mod;} while (0)
#define SUB(x, a) do{(x) += mod - (a); if ((x) >= mod) (x) -= mod;} while (0)

i32 inv (i32 a) {
  i32 t = 1;
  while (a > 1) {
    t = (i64) t * (mod - mod / a) % mod;
    a = mod % a;
  }
  return t;
}

i32 calc (const i64 p, const i32 c, const i32 k) {
  i32 *dp = (i32 *) calloc (c + 1, sizeof (i32));
  dp[c] = 1;
  i32 *prob = (i32 *) calloc (c + 1, sizeof (i32));
  for (i32 i = 0; i <= c; ++i) {
    prob[i] = inv (i + 1);
  }
  for (i32 i = 0; i < k; ++i) {
    i32 sum = 0;
    for (i32 j = 0; j <= c; ++j) {
      i32 v = (i64) prob[j] * dp[j] % mod;
      ADD(sum, v);
    }
    for (i32 j = 0; j <= c; ++j) {
      i32 assign = sum;
      i32 v = (i64) prob[j] * dp[j] % mod;
      SUB(sum, v);
      dp[j] = assign;
    }
  }
  i32 ans = 0;
  for (i32 i = c; i >= 0; --i) {
    ans = ((i64) p * ans + dp[i]) % mod;
  }
  free (dp);
  free (prob);
  return ans;
}

void run (void) {
  i64 n = read_int();
  i32 k = read_int();
  i64 ans = 1;
  for (i64 p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    i32 c = 0;
    while (n % p == 0) {
      n /= p;
      ++c;
    }
    ans = ans * calc (p, c, k) % mod;
  }
  if (n > 1) ans = ans * calc (n, 1, k) % mod;
  print_int (ans);
  puts ("");
}

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


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

typedef int64_t i64;
typedef int32_t i32;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

const i32 mod = 1000000007;

#define ADD(x, a) do{(x) += (a); if ((x) >= mod) (x) -= mod;} while (0)
#define SUB(x, a) do{(x) += mod - (a); if ((x) >= mod) (x) -= mod;} while (0)

i32 inv (i32 a) {
  i32 t = 1;
  while (a > 1) {
    t = (i64) t * (mod - mod / a) % mod;
    a = mod % a;
  }
  return t;
}

i32 calc (const i64 p, const i32 c, const i32 k) {
  i32 *dp = (i32 *) calloc (c + 1, sizeof (i32));
  dp[c] = 1;
  i32 *prob = (i32 *) calloc (c + 1, sizeof (i32));
  for (i32 i = 0; i <= c; ++i) {
    prob[i] = inv (i + 1);
  }
  for (i32 i = 0; i < k; ++i) {
    i32 sum = 0;
    for (i32 j = 0; j <= c; ++j) {
      i32 v = (i64) prob[j] * dp[j] % mod;
      ADD(sum, v);
    }
    for (i32 j = 0; j <= c; ++j) {
      i32 assign = sum;
      i32 v = (i64) prob[j] * dp[j] % mod;
      SUB(sum, v);
      dp[j] = assign;
    }
  }
  i32 ans = 0;
  for (i32 i = c; i >= 0; --i) {
    ans = ((i64) p * ans + dp[i]) % mod;
  }
  free (dp);
  free (prob);
  return ans;
}

void run (void) {
  i64 n = read_int();
  i32 k = read_int();
  i64 ans = 1;
  for (i64 p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    i32 c = 0;
    while (n % p == 0) {
      n /= p;
      ++c;
    }
    ans = ans * calc (p, c, k) % mod;
  }
  if (n > 1) ans = ans * calc (n, 1, k) % mod;
  print_int (ans);
  puts ("");
}

int main (void) {
  run ();
  return 0;
}
220x218x26x45:gori ymkw$ emacs 1.c
220x218x26x45:gori ymkw$ gg 1.c
220x218x26x45:gori ymkw$ cat 1.c
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int64_t i64;
typedef int32_t i32;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

const i32 mod = 1000000007;

#define ADD(x, a) do{(x) += (a); if ((x) >= mod) (x) -= mod;} while (0)
#define SUB(x, a) do{(x) += mod - (a); if ((x) >= mod) (x) -= mod;} while (0)

i32 inv (i32 a) {
  i32 t = 1;
  while (a > 1) {
    t = (i64) t * (mod - mod / a) % mod;
    a = mod % a;
  }
  return t;
}

i32 calc (i64 p, const i32 c, const i32 k) {
  i32 *dp = (i32 *) calloc (c + 1, sizeof (i32));
  dp[c] = 1;
  i32 *prob = (i32 *) calloc (c + 1, sizeof (i32));
  for (i32 i = 0; i <= c; ++i) {
    prob[i] = inv (i + 1);
  }
  for (i32 i = 0; i < k; ++i) {
    i32 sum = 0;
    for (i32 j = 0; j <= c; ++j) {
      i32 v = (i64) prob[j] * dp[j] % mod;
      ADD(sum, v);
    }
    for (i32 j = 0; j <= c; ++j) {
      i32 assign = sum;
      i32 v = (i64) prob[j] * dp[j] % mod;
      SUB(sum, v);
      dp[j] = assign;
    }
  }
  p %= mod;
  i32 ans = 0;
  for (i32 i = c; i >= 0; --i) {
    ans = ((i64) p * ans + dp[i]) % mod;
  }
  free (dp);
  free (prob);
  return ans;
}

void run (void) {
  i64 n = read_int();
  i32 k = read_int();
  i64 ans = 1;
  for (i64 p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    i32 c = 0;
    while (n % p == 0) {
      n /= p;
      ++c;
    }
    ans = ans * calc (p, c, k) % mod;
  }
  if (n > 1) ans = ans * calc (n, 1, k) % mod;
  print_int (ans);
  puts ("");
}

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


#include<stdio.h>
struct list {
int x;
struct list*next;
}
int main()
{
    char str[20];
    int i;j;
    scanf("%s",str);
    int x=strlen(str);
    for(i=0;i<x;i++)
      str[i]=str[i]-'0';
    char c=str;
    scanf("%d",&k);
    while(k!=0)
    {
        max=str[i];
        for(j=i+1;j<=i+k;j++)
          {
              if(j==x)
                break;
              if(max<str[j]){max=str[j];ctr=j;}

          }

    }
}


#include<stdio.h>
#include<string.h>
int main()
{
    int m,k,count,l,i,j,temp;
    char ar[45],ch,temp1,max;
scanf("%s%c%d",&ar,&ch,&m);
l=strlen(ar);

k=m;
for(i=0;i<l-1;i++)
{
    if(m>0)
    {
    j=i+1;
    temp=i;
    k=m;
    max=ar[i];
while(k>0 &&j<l-1)
{
    if(max<ar[j])
    {
        temp=j;
        max=ar[j];
    }
    k--;
    j++;
}
    if(temp!=i)
    {
        temp1=ar[temp];
        for(j=temp;j>i;j--)
        ar[j]=ar[j-1];
        ar[i]=temp1;
    }
    m=m-(temp-i);
    }
    else
    break;
}
printf("%s\n",ar);
return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	int i,j,c,k,n,m,temp,z,pos,diff,max;
	unsigned long long num,x;
	long long int a[20];
	scanf("%lld%d",&num,&k);
	c=0;
	x=num;
	while(num>0)
	{
			num=num/10;
			c++;
	}
	for(i=c-1;i>=0;i--)
	{
			a[i]=x%10;
			x=x/10;

	}
	for(i=0;i<c;i++)
	{
		max=a[i];
		diff=0;
		for(j=i+1;j<c;j++)
		{
			if(j>i+k)
			{
				break;
			}
			if(a[i]<a[j])
			{
				max=a[k];
				pos=j;
				diff=pos-i;
			}
		}
		for(j=pos;j>i;j--)
		{
			temp=a[j];
			a[j]=a[j-1];
			a[j-1]=temp;
		}
		k=k-diff;
		if(k==0)
		{
			break;
		}
	}
	for(i=0;i<=c-1;i++)
	{
		printf("%d",a[i]);
	}
	return 0;
}


#include<stdio.h>
long long int fib[55];
void fibo(int n)
{
	if(n==53)
		return;
	fib[n]=fib[n-1]+fib[n-2];
	fibo(n+1);
}
void func(int k,int r,int n)
{
	if(n==0)
		return;
	if(k<=fib[n])
	{
		printf("%d ",1+r);
		func(k,r+1,n-1);
	}
	else
	{
		printf("%d %d ",2+r,1+r);
		func(k-fib[n],r+2,n-2);
	}
}
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	fib[1]=1;
	fib[2]=1;
	fibo(3);
	func(k,0,n);
	printf("\n");
	return 0;
}


#include <stdio.h>

int main(void) {
	int n;

	scanf("%d", &n);

	if (n <= 1) return 1;

	int i; int result = 1;
	for (i = 2; i <= n; i++)
		result = (result * 3) % 1000003;

	printf("%d\n", result);

	return 0;
}


#include<stdio.h>
int main()
{
    char array[10000];
    scanf("%s",&array);
    int i=0,j=0,count=0,n=0;
    int length=0;
    length=strlen(array);
    for(i=length-1; i>=0; i--)
    {
        if(array[i]!='0')
        {
            break;
        }
        if(array[i]=='0')
        {
            array[i]='\0';
            count++;
        }
    }
    length-=count;
    for(j=0,i=length-1; j<=length/2; j++,i--)
    {
        if(array[i]!=array[j])
        {
            f=n;
            break;
        }
    }
    if(!n)
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }
    return 0;
}


#include<Stdio.h>
int main()
{
	int a, b, c;
	b = 0;
	scanf_s("%d", &c);
	a = c;
	for (;;)
	{
		if (a % 10 != 0)
			break;
		a = 1.0* a / 10;
	}
	for (; ;)
	{
		b =b*10+ a % 10;
		a = 1.0* a / 10;
		if (a == 0)
			break;
	}
	if (b == c)
		printf("YES");
	else printf("NO");
	return 0;
}


#include<stdio.h>
long long int fact(int x){
    if(x>=1){
        return x*fact(x-1);
    }
    else{
        return 1;
    }
}
int main(){
    long long int x,y,ans;
    scanf("%lld%lld",&x,&y);
    if(x>y){
     ans =fact(y);
    }
    else{
        ans=fact(x);
    }
printf("%lld",ans)l

    return 0;
}


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

unsigned long long int Fact(unsigned long long int a)
{
    unsigned long long int fact = a,k = 1;
    if(a % 2 == 0)
    {
        for(int i = 2;i<=a/2;i++)
        {
            fact = fact * i * (a - k);
            k++;
        }
        return fact;
    }

    for(int i = 2;i<=a/2;i++)
    {
        fact = fact * i * (a-k);
        k++;
    }
    fact *= a/2 + 1;
    return fact;
}

unsigned long long int GCD(unsigned long long int a, unsigned long long int b)
{
    unsigned long long int temp,rem;
    if(a<b)
    {
        temp = a;
        a = b;
        b = temp;
    }
    rem = a%b;
    while(rem > 0)
    {
        a = b;
        b = rem;
        rem = a%b;
    }
    return b;
}

int main()
{
    unsigned long long int a,b;
    scanf("%llu %llu",&a,&b);

    unsigned long long int facta = Fact(a);
    unsigned long long int factb = Fact(b);

    unsigned long long int gcd = GCD(facta,factb);
    printf("%llu\n",gcd);
    return 0;
}


#include <stdio.h>
#include <math.h>
int main()
{	long long int i,a,b,x,f1=1,f2=1,gcd;
	scanf("%lld %lld",&a,&b);
	for(i=a,i=b;i>=1;i--)
	{
		f1=f1*i;
		f2=f2*i;
		}
		for(i=1;i<=f1 && i<=f2;++i)
		{
			if(f1%i==0 && f2%i==0)
			gcd=i;
			}
		printf("%lld\n",gcd);
	return 0;
 }


#include<stdio.h>
int fact(int f){
    int a=1,i;
    for(i=f;i>=1;i--)
        a=a*i;
    return a;
}
int main()
{
    int l,n,r=0,d,e,i,j;
    scanf("%d%d",&l,&n);
    d=fact(l);
    e=fact(n);
    while(d%e!=0){
        r=d%e;
        d=e;
        e=r;
    }
    printf("%d",e);
    return 0;
}


#include <stdio.h>
int main() {
    int arr[10001]={0};
    long int a = 0, n,m, temp1;
    scanf("%ld", &n);
    scanf("%ld",&m);
    arr[10000] = 1;
    if(n>m)
    n=m;
    for (long int i = 2; i <= n; i++) {
      a = 0;
      for (long int j = 10000; j >= 0; j--) {
        a = a + arr[j] * i;
        arr[j] = a % 10;
        a = a / 10;
      }
    }
    for (long int k = 0; k <= 10000; k++) {
      if (arr[k] != 0) {
        temp = k;
        break;
      }
    }
    for (long int k1 = temp; k1 <= 10000; k1++)
      printf("%d", arr[k1]);
    printf("\n");
    return 0;
  }


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

int main()
{ int a;
    scanf("%d",a);
    if (a%2==0)
    {
        printf("YES");

    }
    else {
        printf("NO");
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int m,n,a,b;
    int f,sum=0,i;

    scanf("%d%d%d%d",&n,&m,&a,&b);
    double x=b,y=m,z=a;
    if(x/y<=z)
    {
        f=m;
        while(m<=n);
        {
            sum+=b;
            m+=f;
        }
        if(m!=n&&f<n)
        {
            m-=f;
            n=n-m;
            {
                if(b>=a)
                {
                    for(i=0;i<n;i++)
                    {
                        sum+=a;
                    }
                }
                else if(n!=0)
                {
                    sum+=b;
                }
            }
        }
    }
    else
    {
        for(i=0;i<n;i++)
        {
            sum+=a;
        }
    }
    printf("%d",sum);
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char str[10000];

int main(){
int n,i,j,k,l,d,u,r,m,x=0,y=0,L;
l=0;d=0;r=0;u=0;
scanf("%d%s",&n,str);
L = strlen(str);
int count = 0;
int max = -1;

for(i=0;i<L;i++){
if(str[i]=='U'){
y++;u++;}
else if(str[i]=='D'){
y--;d++;}
else if(str[i]=='L'){
x--;l++;}
else if(str[i]=='R'){
x++;r++;}
}
max = n-x-y;
printf("%d\n",max);
retur


#include<stdio.h>
int main()
{
    int arr[3],i,j,temp;
    for(i=0; i<3; i++)
    {
        scanf("%d",&arr[i]);
    }
    for(i=3; i>0; i--)
    {
        for(j=0; j<i; j++)
        {
            if(arr[j]<arr[j+1])
            {
                temp=arr[j];
                arr[j]=arr[j+1];
                arr[j+1]=temp;
            }
        }
    }
    if(arr[0]<arr[1]+arr[2])
    {
        printf("%d",0);
    }
    else
    {
        printf("%d",arr[0]-arr[1]-arr[2]+1);
    }
    return 0;
}


#include<stdio.h>
int main(void)
{
	int arr[3], ans=0, sum=0;
	for(int i=0; i<3; i++)
	{
		scanf("%d", arr[i]);
	}
	int max=0;
	for(int i=0; i<3; i++)
	{
		if(arr[i]>max)
			max=i;
	}
	for(int i=0; i<3; i++)
	{
		if(i!=max)
			sum+=arr[i];

	}
	ans=arr[max]-sum;
	if(ans>0)
		printf("%d", ans+1);
	else
		printf("0");
	return 0;

}


#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d,&a,&b,&c");
    if(a>=b+c)
    printf("%d%d%d",a-b-c-1);
    else  if(b>=a+c)
    printf("%d%d%d",b-a-c-1);
    else if(c>=b+c)
    printf("%d%d%d",c-b-a-1);
    else
    printf("0");
    }


#include <bits/stdc++.h>
using namespace std;

  int main() {
  char num[100];
  long long int limit, p = 0, q = 1, ans;
  int i, len, j, r;
  scanf("%s", num);
  scanf("%lld", &limit);
  len = strlen(num);
  for(i = len-1 ; i >= 0; i--, q *= 10) {
      if(num[i] == '9')
          continue;
          p = q*(num[i] - 47);
          if(p > limit)
             break;
          limit -= p;
          j = i;
          num[i] = '9';
          while(j-- >= 0) {
             if(num[j] != '0') {
                num[j]--;
                break;
             }
                num[j] = '9';

          }
  }
  sscanf(num, "%lld", &ans);
  printf("%lld\n", ans);
  return 0;
  }


#include<stdio.h>
typedef long long ll;
ll s[20],c[20];
int main()
{
    ll n,m,l;
    scanf("%lld%lld",&n,&m);
    if(!m)
    {
        printf("%lld",n);
        return 0;
    }
    l=n;
    int count=0,i=0,max=0,j,flag=1;
    m=n-m;
    while(n)
    {
        s[count++]=n%10;
        if(n%10!=9)
            flag=0;
        n/=10;
    }
    if(flag)
    {
        printf("%lld",l);
        return 0;
    }
    int count2=0;
    while(m)
    {
        c[count2++]=m%10;
        m/=10;
    }
    if(count==count2)
    {
        for(i=count-1;i>0;--i)
        {
            if(s[i]!=c[i])
            {
                int flag=0;
                for(j=0;j<i;++j)
                {
                    if(s[j]!=9)
                    {
                        flag=1;
                        break;
                    }
                }
                if(flag){
                --s[i];
                for(j=0;j<i;++j)
                    s[j]=9;
                }
                break;
            }
        }
        for(i=count-1;i>=0;--i)
            printf("%lld",s[i]);
    }
    else
    {
        if(s[count-1]==1)
        {
            if(count==1)
                printf("1");
            else
            {
                                int flag=0;
                for(j=0;j<i;++j)
                {
                    if(s[j]!=9)
                    {
                        flag=1;
                        break;
                    }
                }
                if(!flag)
                    printf("1");
                for(i=0;i<count-1;++i)
                    printf("9");
            }
            return 0;
        }
        printf("%lld",s[count-1]-1);
        for(i=count-2;i>=0;--i)
            printf("9",s[i]);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
  int main() {
  char num[100];
  long long int limit, p = 0, q = 1;
  int i, len, j, r;
  scanf("%s", num);
  scanf("%lld", &limit);
  len = strlen(num);
  for(i = len-1 ; i >= 0; i--, q *= 10) {
      if(num[i] == '9')
          continue;
          p = q*(num[i] - 47);
          if(p > limit)
             break;
          limit -= p;
          j = i;
          num[i] = '9';
          while(j-- >= 0) {
             if(num[j] != '0') {
                num[j]--;
                break;
             }
                num[j] = '9';

          }
  }
  puts(num);
  return 0;
  }


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

    long a,b,c=1,d=1,i,small,large,gcd=0;
    scanf("%d %d",&a,&b);

    for(i=1; i<=a; i++)
    {
        c=c*i;
    }
    for(i=1; i<=b; i++)
    {
        d=d*i;
    }

    if(c<d)
    {
        small=c;
        large=d;
    }
    else
    {
        small=d;
        large=c;
    }

    //printf("%d %d\n",c,d);

    if(c==0 || d==0)
    {
        printf("%d",large);
    }
    else if(c==d)
    {
        printf("%d",c);
    }

    else if(c==1 || d==1)
    {
        printf("%d",1);
    }

    else if(c!=0 && d!=0)
    {
        for(i=small; i>=2; i--)
        {
            if((c%small)==0 && (d%small)==0)
            {
                gcd=i;
                break;
            }
        }
        printf("%d",gcd);
    }

    return 0;

}


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

    long a,b,c=1,d=1,i,small,large,gcd;
    scanf("%d %d",&a,&b);

    for(i=1; i<=a; i++)
    {
        c=c*i;
    }
    for(i=1; i<=b; i++)
    {
        d=d*i;
    }

    if(c<d)
    {
        small=c;
        large=d;
    }
    else
    {
        small=d;
        large=c;
    }

    if(a>10 || b>10)
    {
        if(a>b)
        {
            printf("%d",d);
            exit(1);
        }
        else
        {
            printf("%d",c);
            exit(1);
        }

    }

   // printf("%d %d\n",c,d);

    if(c==0 || d==0)
    {
        printf("%d",large);
    }
    else if(c==d)
    {
        printf("%d",c);
    }

    else if(c==1 || d==1)
    {
        printf("%d",1);
    }

    else if(c!=0 && d!=0)
    {
        for(i=small; i>=2; i--)
        {
            if((c%small)==0 && (d%small)==0)
            {
                gcd=i;
                break;
            }
        }
        printf("%d",gcd);
    }

    return 0;

}


#include<stdio.h>
long int multiplyNumbers(int n);
int hcf(int n1, int n2);
int main(){
    int p,q,s,t;
    scanf("%d%d",&p,q);
    t=multiplyNumbers(p);
    s=multiplyNumbers(q);
     printf(hcf(n1, n2));
    return 0;
}

long int multiplyNumbers(int n) {
    if (n>=1)
        return n*multiplyNumbers(n-1);
    else
        return 1;
}

int hcf(int n1, int n2) {
    if (n2 != 0)
        return hcf(n2, n1 % n2);
    else
        return n1;
}


#include<stdio.h>
long int multiplyNumbers(int n);
int hcf(int n1, int n2);
int main(){
    int p,q,s,t;
    scanf("%d%d",&p,q);
    t=multiplyNumbers(p);
    s=multiplyNumbers(q);
     printf(hcf(s,t));
    return 0;
}

long int multiplyNumbers(int n) {
    if (n>=1)
        return n*multiplyNumbers(n-1);
    else
        return 1;
}

int hcf(int n1, int n2) {
    if (n2 != 0)
        return hcf(n2, n1 % n2);
    else
        return n1;
}


#include<stdio.h>
int main()
{
 long long  int i,a,r,b,s1=1,s2=1;
scanf("%lld %lld",&a, &b);

for(i=a;i>0;i--){
    s1=s1*i;
}
for(i=b;i>0;i--){
s2=s2*i;
}
while(s2!=0){
    r=s1%s2;
    s1=s2;
    s2=r;
}
printf("%lld",s1);

 return 0;

}


#include<stdio.h>
double fact(int a)
{
    double sum=0;
    sum=a;
    a=a-1;
    while(a!=0)
    {

        sum=sum*a;
        a--;

    }
    return sum;
}
int main()
{
    int a,b,GCD;
    scanf("%d %d",&a,&b);
    double f,s;
    f=fact(a);
    s=fact(b);

        for(int i = 1; i <= f && i <= s; i++)
        {
            if(f%i == 0 && s % i == 0)
                GCD = i;
        }

    printf("%d",GCD);
}


#include<stdio.h>
double fact(int a)
{
    double sum=0;
    sum=a;
    a=a-1;
    while(a!=0)
    {

        sum=sum*a;
        a--;

    }
    return sum;
}
int main()
{
    int a,b,GCD;
    scanf("%d %d",&a,&b);
    int f,s;
    f=fact(a);
    s=fact(b);

        for(int i = 1; i <= f && i <= s; i++)
        {
            if(f%i == 0 && s % i == 0)
                GCD = i;
        }

    printf("%d",GCD);
}


#include<stdio.h>
int main()
{
    int a,b,p=1,q=1,r=1;
    scanf("%d %d",&a,&b);
    for(int i=1;i<=a;i++)
    {
       p=p*i;
    }
    for(int i=1;i<=b;i++)
    {
        q=q*i;
    }
    for(int i=1;i<=p||i<=q;i++)
    {
        int t=p%i;
        int s=q%i;
        if(t==0&&s==0)
        r=i;
    }
    printf("%d",r);
    return 0;
}


#include <stdio.h>
#include <math.h>
 long int multiplyNumbers(long int n)
{
    if (n >= 1)
        return n*multiplyNumbers(n-1);
    else
        return 1;
}

int main()

{

    long long int num1, num2, gcd, lcm, remainder, numerator, denominator;

   // printf("Enter two numbers\n");

    scanf("%lld %lld", &num1, &num2);

    num1=multiplyNumbers(num1);
    num2=multiplyNumbers(num2);

    if (num1 > num2)

    {

        numerator = num1;

        denominator = num2;

    }

    else

    {

        numerator = num2;

        denominator = num1;

    }

    remainder = numerator % denominator;

    while (remainder != 0)

    {

        numerator   = denominator;

        denominator = remainder;

        remainder   = numerator % denominator;

    }

    gcd = denominator;

  // printf("GCD of %d and %d = %d\n", num1, num2, gcd);
printf("%lld",gcd);
return 0;
    //printf("LCM of %d and %d = %d\n", num1, num2, lcm);

}


#include<stdio.h>
int main(){
       int a,b; long long c=1;
       scanf("%d %d",&a,&b);
       b=a<b?a:b;
       while(b--)    C*=b;
       printf("%I64d",c);
}


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

long long int fact(long long int x)
{
	int p=1;
	for(int i=1;i<=x;i++)
     p=p*i;
 return p;
}
int min(long long int q,long long int w)
{
	if(q>w)
		return w;
else
	return q;
}
int main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
 	#endif
	long long int a,b,a1,b1,m;
	scanf("%lld %lld",&a,&b);
     a1=fact(a);
     b1=fact(b);
      m=min(a1,b1);
      for(long long int i=m;i>0;i--)
      {
      	if(a1%i==0 && b1%i==0)

{      		printf("%lld",i);
      	break;
      }
      }
}


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

long long int fact(long long int x)
{
	long long int p=1;
	for(int i=1;i<=x;i++)
     p=p*i;
 return p;
}
int main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
 	#endif
	long long int b,b1, a1,a;int m;
	scanf("%lld %lld",&a,&b);
     a1=fact(a);
     b1=fact(b);
      m=min(a1,b1);
           printf("%d",m);

}


#include<stdio.h>
int main()
{
	int n,k,l,c,d,p,nl,np,a,b,v;
	scanf("%d %d %d %d %d %d %d %d",&n, &k, &l, &c, &p, &nl, &np);
    a=(n*nl)/(k*l);
    b=(n)/d;
    v=(n*np)/p;

    if(a<=b && a<=v)
	{
     printf("%d",a);
    }
    else if (b<=a && b<=v)
    {
    	printf("%d",b);
	}
	else
	{
	printf("%d",v);
    }

}


#include <stdio.h>

unsigned  long count(unsigned long s, unsigned long x)
{
    if (!s && !x)
        return 1;
    if ((s & 1)) {
        if (!(x & 1)) return 0;
        return count(s >> 1, x >> 1) + count(s >> 1, x >> 1);
    }

    if ((x & 1)) return 0;
    return count(s >> 1, x >> 1) + count((s >> 1)-1, x >> 1);
}

int main(int argc, char *argv[])
{
    unsigned long s, x;
    scanf("%lu %lu", &s, &x);
    printf("%lu\n", count(s, x) - 2*(s == x));
    return 0;
}


#include <stdio.h>
#include <stdint.h>

unsigned long long count(unsigned long long s, unsigned long long x)
{
    if ((!s && !x))
        return 1;
    if ((s & 1)) {
        if (!(x & 1)) return 0;
        return 2*count(s >> 1, x >> 1);
    }

    if ((x & 1)) return 0;
    return count(s >> 1, x >> 1) + count((s >> 1)-1, x >> 1);
}

int main(int argc, char *argv[])
{
    unsigned long long s, x;
    scanf("%l64u %l64u", &s, &x);
    printf("%l64u\n", count(s, x) - 2*(s == x));
    return 0;
}


#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int count=0;
	while(n>1)
	{
		count =count+1;
		if(n%2!=0)
		{
			count++;
			n=n-1;
		}
		n=n/2;
	}
	printf("%d\n",count);
}


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

#define for(n) for(int k=0;k<n;k++)
#define gi(n) scanf(" %lld", &n);
#define gil(s,n) scanf(" %s%n",s,&n);
#define go(n) printf("%lld",n);
#define gol(s) printf("%s",s);
#define line printf("\n");

int min(int a, int b){ return a<b?a:b; }
int max(int a, int b){ return a>b?a:b; }
int abs(int a){ return max(a,-a); }

int main(){
	long long n;
	gi(n);
	if (180%(360/(n+1))){ go(n+1); }
	else{ go(180/(360/(n+1))); }
	line
	return 0;
}


#include <stdio.h>

int main() {
	int n, d;
	long long sum;

	scanf("%d", &n);
	sum = 0;
	for (d = 1; d <= n; d++)
		sum += (1 << d);
	printf("%lld\n", sum);
	return 0;
}


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

int main(){

    long long  n = 0;
    long long total = 2;

    scanf("%d",&n);

    if (n == 1)
        printf("2\n");
    else {
        for (int i = 1; i <= n;i++)
            total *= 2;
        printf("%d\n",total-2);
    }

    return 0;
}


#include<stdio.h>
#include<string.h>
main()
{
  int i=0,count=0;
  char a[10];
  scanf("%s",a);
  int b=strlen(a);

  while(i<b)
  {
    if(a[i]=='h'&& count==0)
    count=count+1;
    if(a[i]=='e'&& count == 1)
    count=count+1;
    if(a[i]=='l'&& count==2)
    {count=count+1;i++;continue;}
    if(a[i]=='l'&& count==3)
    count=count+1;
    if(a[i]=='o' && count == 4)
    count=count+1;
    if(count == 5)
    break;

   i++;
  }
  if (count==5)
  printf("YES\n");
  else
  printf("NO\n");
  return(0);
}


// Bear and the three balls
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>

	// solución por fuerza bruta: comparar cada bola con otras dos, si antres de terminar el ciclo hay dos que difieren en menos de 2 en valor absoluto, se puede
	// Si se acaba el ciclo sin encontrar nada, se imprime NO

	int particion (int a[],int ini, int fin);
	void quicksort (int a[],int ini, int fin);
	void swap (int a[],int x,int y);

int main(void){
	int n;
	int *vec;
	int i, cont = 0;

	scanf ( "%d", &n );

	vec = (int*)malloc(n*sizeof(int));

	for ( i = 0; i < n; i++){
			scanf ( "%d", &vec[i] );
	}

	quicksort( vec, 0, n - 1 );

	/*for ( i = 0; i < n; i++ ){
		printf ( "%d - ", vec[i] );
	}*/

	for ( i = 1; i < n; i++ ){
		if ( vec[i - 1] == (vec[i] - 1) )
			cont++;
		else if ( vec[i - 1] != vec[i] )
			cont = 0;
		if ( cont == 2 ){
			printf ( "YES" );
			exit(1);
		}
	}
	printf ( "NO" );

	return 0;
}

void quicksort (int a[],int ini, int fin)		//cada vez que se llama a quicksort un nuevo pivot va colocandose en su posicion
{
	int piv;
	if (ini<fin)
	{	//cont++;
		piv=particion(a,ini,fin);
		quicksort(a,ini,piv-1);				//como el pivot ya esta en su ubicacion se divide en dos y se vuelve a llamar
		quicksort(a,piv+1,fin);				//a quicksort pero sin tocar el pivot
	}
}

int particion (int a[],int ini, int fin)		//particion ubica al pivot en su posicion y devulve esa posicion
{
	int pivot,i,j;
	pivot=a[fin];
	i=ini;
	for (j=ini;j<fin;j++)
	{
		if (a[j]<pivot)
		{
			swap(a,j,i);
			i++;
		}
	}
	swap(a,i,fin);
	return i;
}

void swap (int a[],int x,int y)
{
	int aux;
	aux=a[x];
	a[x]=a[y];
	a[y]=aux;
}


#include<stdio.h>
int max=0;
int n;
char command[101];
void maxcom(int x,int y,int i,int no,int com){

	if(x==0&&y==0){
		if(no>max)
			max=no;
	}

	if(i>=n)
		return;

	if(command[i]=='U'){

		if(com==0){

			maxcom(x,y,i+1,no,0);
			maxcom(x,y,i+1,no,1);

		}

		if(com==1){

			maxcom(x,y+1,i+1,no+1,0);

			maxcom(x,y+1,i+1,no+1,1);

		}

	}

	        if(command[i]=='D'){

                if(com==0){

                        maxcom(x,y,i+1,no,0);
                        maxcom(x,y,i+1,no,1);

                }

                if(com==1){

                        maxcom(x,y-1,i+1,no+1,0);

                        maxcom(x,y-1,i+1,no+1,1);

                }

        }

	        if(command[i]=='L'){

                if(com==0){

                        maxcom(x,y,i+1,no,0);
                        maxcom(x,y,i+1,no,1);

                }

                if(com==1){

                        maxcom(x-1,y,i+1,no+1,0);

                        maxcom(x-1,y,i+1,no+1,1);

                }

        }

	        if(command[i]=='R'){

                if(com==0){

                        maxcom(x,y,i+1,no,0);
                        maxcom(x,y,i+1,no,1);

                }

                if(com==1){

                        maxcom(x+1,y,i+1,no+1,0);

                        maxcom(x+1,y,i+1,no+1,1);

                }

        }

}

int main(){

scanf("%d",&n);

scanf("%s",command);

maxcom(0,0,0,1,0);
maxcom(0,0,0,1,1);

printf("%d\n",max-1);

return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    char s[105];
    int i,n,x,xx,y,yy,cx,cy,total;
    while(~scanf("%d",&n))
    {
        getchar();
        scanf("%s",s);
        x=0;
        y=0;
        for(i=0;i<n;i++)
        {
            if(s[i]=='R' || s[i]=='L')
            {
                x++;
            }
            else if(s[i]=='U' || s[i]=='D')
            {
                y++;
            }
        }
        cx=0;
        cy=0;
        for(i=0;i<n;i++)
        {
            if(s[i]=='R')
            {
                cx=cx+1;
            }
            else if(s[i]=='L')
            {
                cx=cx-1;
            }
            else if(s[i]=='U')
            {
                cy=cy+1;
            }
            else if(s[i]=='D')
            {
                cy=cy-1;
            }
        }
        xx=x-cx;
        yy=y-cy;
        if(xx>n)
        {
            xx=xx%n;
        }
        if(yy>n)
        {
            yy=yy%n;
        }
        total=xx+yy;
        printf("%d\n",total);
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
int a[101],i,j,n,max=0;
char s[101];
int turn[4][2]={{0,1},{0,-1},{-1,0},{1,0}};
void dfs(int nowpos,int nowx,int nowy,int tot)
{
	if (tot>max&&nowx==0&&nowy==0)
		max=tot;
	if (nowpos==n+1) return;
	if (tot+n-nowpos+1<=max) return;
	dfs(nowpos+1,nowx,nowy,tot);
	dfs(nowpos+1,nowx+turn[a[nowpos]][0],nowy+turn[a[nowpos]][1],tot+1);
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	for (i=0;s[i];i++)
		switch (s[i]){
			case 'U':a[i+1]=0; break;
			case 'D':a[i+1]=1; break;
			case 'L':a[i+1]=2; break;
			case 'R':a[i+1]=3; break;
		}
	dfs(1,0,0,0);
	printf("%d\n",max);
	return 0;
}


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

        int n,m,a,b;
        scanf("%d %d %d %d\n",&n,&m,&a,&b);
        int r=0;
        if(b<a*m){
            while(n>0){
                if(n>=m){
                n=n-m;
                r=r+b;
                }

                else{
                    if(a*n>b){
                        r=r+b;
                    }
                    else{
                        r=r+a*n;
                    }
                }
            }

        }
        else{
            r=n*a;
        }
        printf("%d\n",r);

    return 0;
}


#include<stdio.h>
int main()
{
 int n,m,a,b,sum=0;
 scanf("%d%d%d%d",&n,&m,&a,&b);
 while(n!=0){
    if(n>=m){
        n=n-m;
        sum+=b;
    }
    else if(n<m && a<b){
        n=n-1;
        sum+=a;
    }
    else if(n<m && b<a){
        sum+=b;
        n--;
    }
 }
printf("%d",sum);

return 0;
}


void main(){
    int a ;
    scanf('%d',a);
    if ((a % 2)==0){
        printf("YES");
    }
    else
    printf("NO");
    return 0;
}


#include<stdio.h>
#include<string.h>
int main ()
{
   char str[100],str1[100];
   char str2[]="hello";
   int i = 0,j=0;
   gets(str);
   while(str[i]!='\0')
   {
       if(str[i]==str[i+1])
       {
           str1[j]=str[i];
           i++;
        }
        else{
            str1[j]=str[i];
            j++;
            i++;
        }
   }
   if(strcmp(str2,strstr(str1,str2)))
   printf("YES");
   else
   printf("NO");
   return 0 ;
}


#include<stdio.h>
#include<string.h>
char s[101];
int main()
{
    char t[]="hello";
    int i=0,c=0;
    int j,l=0;
    scanf("%s",s);
    while((s[i]!='\0')&&(t[l]!='\0'))
    {

       j=strcmp(s[i],t[l]) ;
       i++;
       if(j==0)
       {
           c++;
           l++;

       }
       else
       {

       }
    }

    if(c==5)
    {
        printf("YES");

    }
    else
    {
        printf("NO");
}
return 0;
}


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

int main(void) {
    int n,k,l,c,d,p,nl,np;
    scanf("%d %d %d %d %d %d %d %d",&n,&k,&l,&c,&d,&p,&nl,&np);
    l*=k;
    d*=c;
    l/=nl;
    p/=np;
    int toast = min(l,min(p,d));
    toast/=n;
    printf("%d",toast);
    return 0;
}


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

#define MAX(A, B) (A > B ? A : B);

int main(){

    int n;
    scanf("%d", &n);

    int *arr= malloc(sizeof(int)*n);
    int *check = calloc(n, sizeof(int));
    int ones = 0;
    int max = -1;

    int j = 0;
    for(int i=0; i<n; i++){
        scanf("%d", &arr+i);
        if(arr[i]){
            if(check[j] < 1)
                check[j]--;
            else {
                j++;
                check[j]++;
            }
        } else {
            if(check[j] > -1)
                check[j]++;
            else {
                j++;
                check[j]++;
            }

        }

    }

    int curr = 0;
    for(int i=0; i<=j; i++){
        if(check[j] > 0)
            max = MAX(max, curr+check[j]);

        if(curr + check[j] <= 0)
            curr = 0;
        else
            curr += check[j];
    }

    printf("%d", max + ones);
    return 0;
}


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

int main()
{
    int a['z']={0},n,k;
    scanf("%d %d",&n,&k);
    char s[1000];
    scanf("%s",&s);
    int i;
    for(i=0;s[i]!='\0';i++)
    {
        char z=s[i];
        a[z]++;
    }
    char d;
    for(d='a';d<='z';d++)
    {
        if(y[d]<y)
         {
             printf("NO\n");
             return 0;
         }
    }
    printf("YES\n");
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define ll long long int

int main()
{
    int n,k,a[26],i,max=0;
    scanf("%d %d",&n,&k);
    for(i=0;i<26;i++)
        a[i]=0;
    for(i=0;i<n;i++)
    {
        char c;
        scanf("%1c",&c);
        a[c-'a']++;
    }
    for(i=0;i<26;i++)
    {
        if(a[i]>max)
            max=a[i];
    }
    if(max>k)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}
→Judgement Proto


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

int main()  {

  int stack[3]={0}, move, endpos, temp;
  scanf("%d%d", &move, &endpos);
  stack[endpos]=1;

  while( move>0 ) {

    if(move%2!=0)  {
      temp = stack[0];
      stack[0]= stack[1];
      stack[1]=temp;
    }

    else if(move%2==0) {

      temp = stack[1];
      stack[1]= stack[2];
      stack[2]=temp;
    }
    move--;
  }
  for(temp=0; temp<3; temp++)
    if( stack[temp] )
      break;
  printf("%d\n", temp );
  return 0;
}


#include<stdio.h>
int main()
{
    int n;
    int position;
    scanf("%d",&n);
    scanf("%d",&position);
    while(n>0)
    {
        if(n%2 == 0)
        {
            if(position == 2)
            {
                position = 1;
            }
            else if(position == 1)
            {
                position = 2;
            }
        }
        else
        {
            if(position == 0)
            {
                position = 1;
            }
            else if(position == 1)
            {
                position = 0;
            }
        }
        n--;
    }
    printf("%d",position);
}


#include <stdio.h>
int main()
{
    long long int n;
    int p;
    scanf("%l64d", &n);
    scanf("%d", &p);
    int s[]={0,0,0};
    s[p]=1;
    for(int i=n;i>0;i--)
    {
        if(i%2==0)
        {
            int temp=0;
            temp=s[1];
            s[1]=s[2];
            s[2]=temp;
        }
        else
        {
            int temp=0;
            temp=s[0];
            s[0]=s[1];
            s[1]=temp;
        }
    }
    for(int i=0; i<3;i++)
    {
        if(s[i]==1)
        {
            printf("%d",i);
            return 0;
        }
    }

    return 0;
}


#include<stdio.h>
int main()
{
	long long n,x,i,l=0,m=0,r=0,temp;
	scanf("%lld%lld",&n,&x);
	if(x==0)
		l=1;
	else if(x==1)
		m=1;
	else if(x==2)
		r=1;
	if(n%2!=0)
	{
			for(i=1;i<=n;i++)
		{
			if(i%2==0)
			{
				temp=r;
				r=m;
				m=temp;
			}
			else if(i%2!=0)
			{
				temp=l;
				l=m;
				m=temp;
			}
		}
	}
	if(n%2==0)
	{
			for(i=1;i<=n;i++)
		{
			if(i%2!=0)
			{
				temp=r;
				r=m;
				m=temp;
			}
			else if(i%2==0)
			{
				temp=l;
				l=m;
				m=temp;
			}
		}
	}

	if(l==1)
		printf("0\n");
	else if(m==1)
		printf("1\n");
	else if(r==1)
		printf("2\n");
}


#include<stdio.h>
int swap(int* a,int* b)
{
	int c;
	c = *a;
	*a = *b;
	*b = c;
}
int main()
{
	int count;
	int store;
	int arr[3];

	scanf("%d%d",&count,&store);

	int c = store;
	for(int i=0;i<3;i++)
	{
		arr[i] == i;
	}

	int j,k;
	j = c;
	while(count > 0)
	{
		if(count % 2 == 0)
		{
			swap(&arr[1],&arr[2]);
			if(j == 2)
			{
				j = 1;
			}

			else if(j == 1)
			{
				j = 2;
			}
			count = count - 1;
			/*k = j - 1;
			swap(&arr[j],&arr[k]);
			count = count - 1;
			j = k;*/
		}

		else
		{
			swap(&arr[0],&arr[1]);
			if(j == 1)
			{
				j = 0;
			}

			else if(j == 0)
			{
				j = 1;
			}
			count = count - 1;

			/*k = j + 1;
			swap(&arr[j],&arr[k]);
			count = count - 1;
			j = k;*/
		}

	}

	printf("%d\n",j);

	return 0;
}


#include<stdio.h>
int main()
{   long long n;
    int pos,arr[3]={0,1,2},temp,i;
    scanf("%lld %d",&n,&pos);
    for(i=1;i<=n;i++) {
    if(i%2==0) {
    temp=arr[1];
    arr[1]=arr[2];
    arr[2]=temp;
    }
    else{
    temp=arr[0];
    arr[0]=arr[1];
    arr[1]=temp;
    }
    }
    printf("%d",arr[pos]);
    return 0;
}


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

int n, m, a[11], b[11], c[11], d[11], A[1001][11];

int vai (int massa, int posi) {
  int pode = 80000;
  int i, valor;
  if (posi >= 10) {
    if (posi != 0)
      pode =  a[posi] / b[posi];
    if (n / c[posi] < pode)
      pode = n / c[posi];

    valor = 0;
    for (i = 0; i < pode; i++){
      if (A[massa - i * c[posi]][ posi +1] == -1) {
         valor = max (valor, vai (massa - i * c[posi], posi +1) + d[posi] * i);
         A[massa - i * c[posi]][ posi +1] = valor;
         }
      else
          return A[massa - i * c[posi]][ posi +1];
    }
    return valor;
  }
  else
    return 0;
}

int main () {

  int valor, i, j;

  for(i = 0; i < 1001; i++)
        for(j = 0; j < 11; j++)
              A[i][j] = -1;

  scanf("%d%d%d%d", &n, &m, &c[0], &d[0]);
  a[0] = 1;
  b[0] = 0;

  for(i = 1; i <= m; i++) {
    scanf("%d", &a[i]);
    scanf("%d", &b[i]);
    scanf("%d", &c[i]);
    scanf("%d", &d[i]);
  }

  valor = vai(n,0);

  printf("%d", valor);

  return 0;

}


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

int n, m, a[11], b[11], c[11], d[11], A[1001][11];

int max (int i, int j) {
    if (i > j)
       return i;
    return j;
}

int vai (int massa, int posi) {
  int pode = 80000;
  int i, valor;

  if (posi <= m) {
    if (posi != 0)
      pode =  a[posi] / b[posi];
    if (massa / c[posi] < pode)
      pode = massa / c[posi];

    valor = 0;
    for (i = 0; i <= pode; i++){
      if (A[massa - i * c[posi]][ posi +1] == -1) {
         valor = max (valor, vai (massa - i * c[posi], posi +1) + d[posi] * i);
         A[massa - i * c[posi]][ posi +1] = valor;
         }
      else
          valor = A[massa - i * c[posi]][ posi +1];
    }
    return valor;
  }
  else
    return 0;
}

int main () {

  int valor, i, j;

  for(i = 0; i < 1001; i++)
        for(j = 0; j < 11; j++)
              A[i][j] = -1;

  scanf("%d%d%d%d", &n, &m, &c[0], &d[0]);
  a[0] = 0;
  b[0] = 0;

  for(i = 1; i <= m; i++) {
    scanf("%d", &a[i]);
    scanf("%d", &b[i]);
    scanf("%d", &c[i]);
    scanf("%d", &d[i]);
  }

  valor = vai(n,0);

  printf("%d", valor);

  return 0;

}


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

int n, m, a[11], b[11], c[11], d[11], A[1001][11];

int max (int i, int j) {
    if (i > j)
       return i;
    return j;
}

int vai (int massa, int posi) {
  int pode = 80000;
  int i, valor;
  if (posi <= 10) {
    if (posi != 0)
      pode =  a[posi] / b[posi];
    if (n / c[posi] < pode)
      pode = n / c[posi];

    valor = 0;
    for (i = 0; i < pode; i++){
      if (A[massa - i * c[posi]][ posi +1] == -1) {
         valor = max (valor, vai (massa - i * c[posi], posi +1) + d[posi] * i);
         A[massa - i * c[posi]][ posi +1] = valor;
         }
      else
          valor = A[massa - i * c[posi]][ posi +1];
    }
    return valor;
  }
  else
    return 0;
}

int main () {

  int valor, i, j;

  for(i = 0; i < 1001; i++)
        for(j = 0; j < 11; j++)
              A[i][j] = -1;

  scanf("%d%d%d%d", &n, &m, &c[0], &d[0]);
  a[0] = 1;
  b[0] = 0;

  for(i = 1; i <= m; i++) {
    scanf("%d", &a[i]);
    scanf("%d", &b[i]);
    scanf("%d", &c[i]);
    scanf("%d", &d[i]);
  }

  valor = vai(n,0);

  printf("%d", valor);

  return 0;

}


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

int n, m, a[11], b[11], c[11], d[11]/*, A[1001][11]*/;

int max (int i, int j) {
    if (i > j)
       return i;
    return j;
}

int vai (int massa, int posi) {
  int pode = 80000;
  int i, valor;

  if (posi <= m) {
    if (posi != 0)
      pode =  a[posi] / b[posi];
    if (massa / c[posi] < pode)
      pode = massa / c[posi];

    valor = 0;
    for (i = 0; i <= pode; i++){
    /*  if (A[massa - i * c[posi]][ posi +1] == -1) { */
         valor = max (valor, vai (massa - i * c[posi], posi +1) + d[posi] * i);
     /*    A[massa - i * c[posi]][ posi +1] = valor;
         }
      else
          valor = A[massa - i * c[posi]][ posi +1]; */
    }
    return valor;
  }
  else
    return 0;
}

int main () {

  int valor, i, j;

 /* for(i = 0; i < 1001; i++)
        for(j = 0; j < 11; j++)
              A[i][j] = -1; */

  scanf("%d%d%d%d", &n, &m, &c[0], &d[0]);
  a[0] = 0;
  b[0] = 0;

  for(i = 1; i <= m; i++) {
    scanf("%d", &a[i]);
    scanf("%d", &b[i]);
    scanf("%d", &c[i]);
    scanf("%d", &d[i]);
  }

  valor = vai(n,0);

  printf("%d", valor);

  return 0;

}


#include <stdio.h>

int CalculaMax (int tipo, int tot[][4], int massa);

int main (){
	int tot[11][4], i, max;

	scanf ("%d %d %d %d", &tot[0][0], &tot[0][1], &tot[0][2], &tot[0][3]);
	for (i = 1; i <= tot[0][1]; i++)
		scanf ("%d %d %d %d", &tot[i][0], &tot[i][1], &tot[i][2], &tot[i][3]);

	max = CalculaMax (0, tot, tot[0][0]);

	printf ("%d\n", max);
	return 0;

}

int CalculaMax (int tipo, int tot[][4], int massa){
	int maxpaes, i, totalparcial, total = 0;

	if (tipo > tot[0][1])
		return 0;

	maxpaes = massa/tot[tipo][2];
	if (tipo != 0)
		if (tot[tipo][0]/tot[tipo][1] < maxpaes)
			maxpaes = tot[tipo][0]/tot[tipo][1];

	for (i = maxpaes; i >= 0; i--){
		totalparcial = i*tot[tipo][3] + CalculaMax (tipo+1, tot, massa-(i*tot[tipo][2]));
		if (totalparcial > total)
			total = totalparcial;
	}

	return total;

}