#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
   int compare( const void* a, const void* b)
    {
        long long int int_a = * ( (int*) a );
        long long int int_b = * ( (int*) b );

        if ( int_a == int_b ) return 0;
        else if ( int_a < int_b ) return -1;
        else return 1;
    }
long int fact(int x)
   {
     long int f=1;
     int i;
     for(i=1;i<=x;i++)
       f=f*i;
     return(f);
   }
int main()
{
    char s1[10],s2[10];
    double ans;
    int i,j,sig1=0,sig2=0,un,a[1025];
    scanf("%s",s1);
    getchar();//printf("p");
    gets(s2);

    for(i=0;i<strlen(s1);i++)
    {
        if(s1[i]=='+')
            sig1++;
        else
            sig1--;
    }
    for(i=0;i<strlen(s2);i++)
    {
        if(s2[i]=='+')
            sig2++;
        else if(s2[i]=='-')
            sig2--;
        else if(s2[i]=='?')
            un++;
    }//printf("%d %d %d un  ",sig1,sig2,un);
    if(un==0){if(sig1==sig2) printf("1"); else printf("0");exit(0);}

    int l=1;
    int p = (int)pow(2,(float)un);//printf("%d",p);
    a[0]=sig2+un;
    for(i=1;i<=un;i++)
    {
        int ncr = fact(un)/fact(i);//printf("ncr = %d",ncr);
        for(j=0;j<ncr;j++)
        {
                a[l] =sig2-un+2*i;//printf("al = %d",a[l]);
                l++;
        }
        if(a[l]==sig1)
        {
            ans =(double)((double)ncr/(double)p);
            printf("%f",ans);
            exit(0);
        }
    }
    printf("0");
    return 0;
}
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
   int compare( const void* a, const void* b)
    {
        long long int int_a = * ( (int*) a );
        long long int int_b = * ( (int*) b );

        if ( int_a == int_b ) return 0;
        else if ( int_a < int_b ) return -1;
        else return 1;
    }
long int fact(int x)
   {
     long int f=1;
     int i;
     for(i=1;i<=x;i++)
       f=f*i;
     return(f);
   }
int main()
{
    char s1[10],s2[10];
    double ans;
    int i,j,sig1=0,sig2=0,un,a[1025];
    scanf("%s",s1);
    getchar();//printf("p");
    gets(s2);

    for(i=0;i<strlen(s1);i++)
    {
        if(s1[i]=='+')
            sig1++;
        else
            sig1--;
    }
    for(i=0;i<strlen(s2);i++)
    {
        if(s2[i]=='+')
            sig2++;
        else if(s2[i]=='-')
            sig2--;
        else if(s2[i]=='?')
            un++;
    }//printf("%d %d %d un  ",sig1,sig2,un);
    if(un==0){if(sig1==sig2) printf("1"); else printf("0");exit(0);}

    int l=1;
    int p = (int)pow(2,(float)un);//printf("%d",p);
    a[0]=sig2+un;
    for(i=1;i<=un;i++)
    {
        int ncr = fact(un)/fact(i);//printf("ncr = %d",ncr);
        for(j=0;j<ncr;j++)
        {
                a[l] =sig2-un+2*i;//printf("al = %d",a[l]);
                l++;
        }
        if(a[l]==sig1)
        {
            ans =(double)((double)ncr/(double)p);
            printf("%f",ans);
            exit(0);
        }
    }
    printf("0");
    return 0;
}


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

using namespace std;

int CombinationsRecur(int iN, int iR) {
    if (iR < 0 || iR > iN) {
        return 0;
    }
    if (iR < 1) {
        return 1;
    }
    if (iN == iR) {
        return 1;
    }
    return CombinationsRecur(iN - 1, iR) + CombinationsRecur(iN - 1, iR - 1);
}

int main(){

	char s1[10];
	char s2[10];
	scanf("%s",s1);
	scanf("%s",s2);
	int n=strlen(s1);

    int arr[2];
    arr[0]=arr[1]=0;

    for(int i=0;i<n;i++)
        if(s1[i]=='+') arr[0]++;
        else arr[1]++;

    for(int i=0;i<n;i++)
        if(s2[i]=='+') arr[0]--;
        else if(s2[i]=='-') arr[1]--;

    //printf("%d %d\n",arr[0],arr[1]);

    if((arr[0]<0)||(arr[1]<0)){
        printf("%1.9f",(float)0.0);
        return 0;
    }

    if((arr[0]==0)&&(arr[1]==0)){
        printf("%1.9f",(float)1.0);
        return 0;
    }

    int u=CombinationsRecur(arr[0]+arr[1],arr[0]);
    int v=pow(2,(arr[0]+arr[1]));
    float h=(float)u/(float)v;
    printf("%1.9f",h);

	return 0;
}


#include<stdio.h>
#include<math.h>
int b(int i,int unknown);
int main()
{
    int size=0,f=0,i=0,r,count=0,unknown=0,known=0;
    int y,demosum;
    double c,s;
    char s1[11],s2[11];

    gets(s1);
    gets(s2);

    while(s1[i]!='\0')
    {
        if(s1[i]=='+')
            f++;
        else
            f--;

        size++;
        i++;
    }

    for(i=0;i<size;i++)
    {
        if(s2[i]=='?')
            unknown++;
        else if(s2[i]=='+')
            known++;
        else
            known--;
    }
    y=pow(2,unknown);

    if(unknown!=0)
    {
        for(k=0;k<y;k++)
        {
            r=0;
            demosum=b(k,unknown);
            r=demosum+known;
            if(r==f)
                count++;
        }
        s=y;
        c=count;
        printf("%lf",c/s);

    }
    else
    {
        if(known==f)
            printf("1.000000000000");
        else
            printf("0.000000000000");

    }
    return 0;
}

int b(int i,int unknown)
{
    int sum,z,j;
    char str[unknown];
    sum=0;
    z=0;
    if(i==0)
        return(-unknown);
    while(i!=0)
    {
        if(i%2==0)
        {
            str[z]='0';
            z++;
        }
        else
        {
            str[z]='1';
            z++;
        }
        i=i/2;
    }
    for(j=z;j<unknown;j++)
        str[j]='0';
    for(j=unknown-1;j>=0;j--)
    {
        if(str[j]=='1')
            sum++;
        else
            sum--;
    }
    return (sum);
}


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

int main(void)
{
    int i, n, s, pos_c, pos_s, vel_c, win;
    char states[201], direction[10];

    memset(states, 0, sizeof(states));
    memset(direction, 0, sizeof(direction));

    scanf("%d%d%d%*s%s%s", &n, &pos_s, &pos_c, direction, states);

    if (!strcmp(direction, "head")) vel_c = -1;
    else vel_c = 1;

    s = strlen(states);

    if (pos_s < pos_c) pos_s = 1;
    else pos_s = n;

    win = 0;

    for (i = 0; i < s; i++)
    {
        if (pos_c == pos_s) { win = 1; break; }
        if (pos_c == 1 && vel_c == -1) vel_c = 1;
        if (pos_c == n && vel_c == 1) vel_c = -1;

        if (states[i] == '0')
        {
            pos_c += vel_c;
        }
        else
        {
            pos_c += vel_c;
            if (pos_c > 1) {
                if (vel_c == 1) pos_s = 1;
                else pos_s = n;
            }
            if (pos_c < n) {
                if (vel_c == -1) pos_s = n;
                else pos_s = 1;
            }
        }
    }

    if (win)
        printf("Controller %d\n", i);
    else
        printf("Stowaway\n");

    return 0;
}


#include <stdio.h>

int main (void) {
	int n, st, co, ht, ok, i, tail;
	char s[201];
	scanf ("%d%d%d\n", &n, &st, &co);
	scanf ("to %s", s);
	tail = (s[0]=='t');
	scanf ("%s", s);
	for (ok = i = 0; s[i] != '1' && !ok; i++) {
		if (st < co && st > 1)	/*st esta pro lado do 1 <- -> ou <- <-*/
			st--;
		else if (st > co && st < n)	/*st esta pro lado do n -> -> ou <- ->*/
			st++;
		if (tail) { /* vai pro n */
			if (++co == n)	tail = 0;
		} else { /* vai pro 1 */
			if (--co == 1)	tail = 1;
		}
		if (co == st)	ok = 1;
	}
	if (!ok) { /* s[i] == 1 */
		while (s[i] != '\0' && !ok) {
			if (tail) {
				st = 1;
				if(++co == n)	tail = 0;
			} else {
				st = n;
				if (--co == 1)	tail = 1;
			}
			for (++i; s[i] != '1' && s[i] != '\0' && !ok; i++) {
				if (tail) {
					if(++co == n)	tail = 0;
				} else {
					if (--co == 1)	tail = 1;
				}
				if (co == st)	ok = 1;
			}
		}
	}
	if (!ok)	printf ("Stowaway\n");
	else	printf ("Controller %d\n", i);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int far(int enemy,int dir,int n){
  if(enemy==0) return n-1;
  if(enemy==n-1) return 0;
  if(dir==1) return 0;
  return n-1;
}

int main(){
  int i,j,k,l,m,n,len,turn;
  int now, enemy, dir;
  char in[1000], a[100], b[100];

  while(scanf("%d%d%d",&n,&now,&enemy)==3){
    scanf("%s%s%s",a,b,in);
    if(b[0]=='h') dir=-1; else dir=1;

    now--; enemy--;
    if(enemy+dir < 0 || enemy+dir >= n) dir *= -1;

    if(now < enemy) now = 0;
    else now = n-1;

    for(i=0;;i++) if(in[i]<' ') break; len=i;
    rep(turn,len){
      if(in[turn]=='1') now=-1;
      if(in[turn]=='0' && now==-1) now = far(enemy,dir,n);

      enemy += dir;
      if(enemy+dir < 0 || enemy+dir >= n) dir *= -1;

      if(enemy==now) break;
    }

    if(turn==len)puts("Stowaway"); else printf("Controller %d\n",turn+1);
  }

  return 0;
}


#include <stdio.h>
int main() {
	int n,m,k;
	int i;
	char a[3],b[5];
	char c[201];
	char *p;
	// 1->     -1<-
	int d;
	scanf("%d %d %d", &n, &m, &k);
	scanf("%s %s",a,b);
	scanf("%s", c);

	if(n==2){
		printf("Controller 1\n");
		return 0;
	}

	if(b[0] == 'h')
		d = -1;
	else
		d = 1;

	for(p=c,i=1; *p!='\0'; p++,i++) {
		// move stowaway
		int f = 0
		if(d == 1) {
			if(*p=='1'){
				if(k!=1)
					m = k-1;
				else
					m = k+2;
			} else if(m-k==1 && m!=n){
				m += 1;
			}
			f = 1;
		}else{
			if(*p=='1'){
				if(k!=n)
					m = k+1;
				else
					m = k-2;
			} else if(k-m==1 && m!=1){
				m -= 1;
			}
		}

		// move controller
		k += d;
		if(k == 1)
			d = 1;
		if(k == n)
			d = -1;

		if(k == m && f == 0){
			printf("Controller %d\n",i);
			return 0;
		}
	}

	printf("Stowaway\n");

	return 0;
}


#include<stdio.h>
#define mod 1000000007
int main()
{
    long long n,abc,d,nabc,nd;
    abc=0;  //originally not at a/b/c
    d=1;    //originally at d
    scanf("%I64d",&n);
    while(n--)      //after n steps get completed
    {
        nabc=(abc*2LL + d)%mod;   //to come at a/b/c..we have 3 options
        nd=(abc*3LL4)%mod;         //to come at d..we have 3 options
        abc=nabc;
        d=nd;
    }
    printf("%I64d\n",d);
    return 0;
}


#include <stdio.h>
#include <conio.h>

int main()
{
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int N = 0;
    scanf("%d", &N);
    if(N<2)
        return 0;
    long long currentD=0, oldD=0, currentA=0, oldA=1, modulo=1000000007;
    for(int i=2;i<=N;i++)
    	currentD=(3*oldA)%modulo, currentA=((2*oldA)%modulo+oldD%modulo)%modulo. oldA=currentA, oldD=currentD;
    printf("%ll\n", oldD);
    return 0;
}


#include <stdio.h>
#include <conio.h>

int main()
{
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int N = 0;
    scanf(%d, &N);
    if(N<2)
        return 0;
    int ways[N]={0};
    ways[1]=3;
    for(int i=1;i<N;i++)
        ways[i]=(3*(long long)ways[i-1])%1000000007;
    printf("%d\n",ways[N-1]);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    long long int n,val=1000000007;
    scanf("%lld",&n);
    long long int steps[10000005]={0};
    steps[1]=0;
    for(int i=2;i<=n;i++)
    {
        steps[i]=(pow(3,i-1)%val)-steps[i-1];
    }
    printf("%lld",steps[n]);
    return 0;
}


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

long long int f(int x)
{
    long long int res = 0;
    if(x%2 == 0)
    {
        x /= 2;
        long long int multplier = 1;
        for(int i = 0; i < x; i++)
        {
            res = (res+multplier) % 1000000007;
            multplier = (multplier*9) % 1000000007;
        }
        res = (2*res+1) % 1000000007;
    }
    else
    {
        int _x /= 2;
        long long int mult = 1;
        while(_x-- > 0) mult = (mult*9)%1000000007;
        res = mult - f(x-1);
        while(res < 0) res += 1000000007;
    }
    return res%1000000007;
}

int main()
{
    int n;
    scanf("%d", &n);
    printf("%lld", f(n)%1000000007);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define sort radix_sort(a,n)
int min(int p,int q)
{
    if(p>q) return q;
    else return p;
}
int max(int p,int q)
{
    if(p>q) return p;
    else return q;
}
typedef long long int ll;
  //n=inp();
inline ll inp()
{
    ll n=0,s=1;
    char p=getchar();
    if(p=='-')
    s=-1;
    while((p<'0'||p>'9')&&p!=EOF&&p!='-')
    p=getchar();
    if(p=='-')
    s=-1,p=getchar();
    while(p>='0'&&p<='9')
    {
    n = (n<< 3) + (n<< 1) + (p - '0');
    p=getchar();
    };
    return n*s;
}
void radix_sort(int a[], int n)
{
    int i, x[n+1], m = 0, exp = 1;
    for (i = 1; i <= n; i++)
        if (a[i] > m)
            m = a[i];
    while (m / exp > 0)
    {
        int box[10] = {0,0,0,0,0,0,0,0,0,0};
        for (i = 0; i < n; i++)
            box[a[i] / exp % 10]++;
        for (i = 1; i < 10; i++)
            box[i] += box[i - 1];
        for (i = n-1; i >= 0; i--)
        {
            x[--box[a[i] / exp % 10]] = a[i];
        }
        for (i = 0; i < n; i++)
        {
            a[i] = x[i];
        }
        exp *= 10;
    }
}
  //sort;
int main()
{
    int j,n,i,k,a,b;
    scanf("%d%d%d",&n,&a,&b);
    int arr[a];int all[b];int w[n+1];
    for(i=0;i<=a-1;i++)
        scanf("%d",&arr[i]);
    for(i=0;i<=b-1;i++)
        scanf("%d",&all[i]);
     for(i=0;i<=n;i++)
            w[i]=0;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<a;j++)
        {
            if(i==arr[j] && w[i]==0)
            {   printf("1 ");
                w[i]=1;
            }
        }
            for(k=0;k<b;k++)
            {
                if(i==all[k] && w[i]==0)
                {   printf("2 ");
                    w[i]=1;
                }
            }

    }

    return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int mian()
{
    int i,j,n,a1,b1,a[105],b[105],count=0;
    scanf("%d%d%d",&n,&a1,&b1);
    for(i=0;i<a1;i++)
        scanf("%d",a[i]);
    for(i=0;i<b1;i++)
        scanf("%d",b[i]);
    sort(a,a+a1);
    for(i=1;i<=n;i++)
    {
        if(a[count]==i)
        {
            printf("1");
            count++;
        }
        else
            printf("2");
    }
    return 0;
}


#include<stdio.h>
int main(){
    long long unsigned int x,y,n,a,b;
    scanf("%d",&n);
    scanf("%I64d %I64ud",&x,&y);
    a=(x-1)*(x-1)+(y-1)*(y-1);
    b=(n-x)*(n-x)+(n-x)*(n-x);
    if(a>b){
        printf("Black");
    }
    else{
        printf("White");
    }
}

}


#include<stdio.h>

int main()
{
   long long long int n,x,y;
    int a,b;
    a=((x-1)*(x-1))+((y-1)*(y-1));
    b=((n-x)*(n-x))+((y-n)*(y-n));
    if(a>b)
    {
        printf("black");
    }
    else
    {
        printf("white");
    }
}


#include<stdio.h>
#include<math.h>
 int main()
{
 unsigned double w,b;
 long long int n,x,y,w1,w2,b1,b2;
 scanf("%lld",&n);
 scanf("%lld%lld",&x,&y);
 w1=w2=1;
 b1=b2=n;
 w=sqrt((x-w1)*(x-w1)+(y-w2)*(y-w2));
 b=sqrt((x-b1)*(x-b1)+(y-b2)*(y-b2));
 if(w<=b)
 printf("White");
 else
 printf("Black");
 return 0;
}


#include <stdio.h>

int main(void){
    long long n, x, y, temp1x, temp1y, temp2c, temp2y, max1, max2;
    scanf("%lli %lli %lli", &n ,&x, &y);
    temp1x=x;
    temp1y=y;
    temp2x=n-x;
    temp2y=n-y;
    if(temp1x>temp1y) max1=temp1x;
    else max1=temp1y;
    if(temp2x>temp2y) max2=temp2x;
    else max2=temp2y;
    if(max1>=max2) printf("White");
    else printf("Black");
    return 0;
}


#include <stdio.h>
#include <math.h>
int main()
{
	long long int a,b,n,o;
	scanf("%I64lld",&a);
	scanf("%I64lld %I64lld",&a,&b);
	n=((2*a)-(b+c));
	o=((b+c)-2);
	if(n<o)
	printf("black");
	else
	printf("white");
	return 0;
}


#include<bits/stdc++.h>
int main()
{
    char cur[12],res[12];
    scanf("%s",cur);
    strcpy(res,cur);
    res[0]++;
    int len=strlen(cur);
    for(int i=1;i<len;i++)
        res[i]='0';
    printf("%d",atoi(res)-atoi(cur));
    return 0;
}


#include<stdio.h>
#include<conio.h>

bool luck(long long int y)
{
	int y1,i,j,k=0,n=0;
	y1=y;
	while(y1!=0)
	{
		y1=y1/10;
		n++;
	}
	y1=y;
	for(i=0;i<n;i++)
	{
		j=y1%10;
		y1=y1/10;
		if(j!=0)
		{
			k++;
		}
	}
	if(k==1)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main()
{
	int a=0;
	long long int y;
	scanf("%l64d",&y);
	do
	{
		y++;
		a++;
	}while(!luck(y));
	printf("%d",a);
	return 0;
}


#include<stdio.h>
#include<conio.h>
#include<iostream>
bool luck(long long int y)
{
	int i,j,k=0,n=0;
	int y1=y;
	while(y1!=0)
	{
		y1=y1/10;
		n++;
	}
	y1=y;
	for(i=0;i<n;i++)
	{
		j=y1%10;
		y1=y1/10;
		if(j!=0)
		{
			k++;
		}
	}
	if(k==1)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main()
{
	int a=0;
	long long int y;
	scanf("%l64d",&y);
	do
	{
		y++;
		a++;
	}while(!luck(y));
	printf("%d",a);
	return 0;
}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="test" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/test" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Debug/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-g" />
				</Compiler>
			</Target>
			<Target title="Release">
				<Option output="bin/Release/test" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Release/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-O2" />
				</Compiler>
				<Linker>
					<Add option="-s" />
				</Linker>
			</Target>
		</Build>
		<Compiler>
			<Add option="-Wall" />
		</Compiler>
		<Unit filename="main.c">
			<Option compilerVar="CC" />
		</Unit>
		<Extensions>
			<code_completion />
			<envvars />
			<debugger />
			<lib_finder disable_auto="1" />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


#include <stdio.h>
int main(void){
	int s,v1,v2,t1,t2;
	scanf("%d%d%d%d%d",&s,&v1,&v2,&t1,&t2);
	int p1,p2;
	if
	p1=s*v1-t1;
	p2=s*v2-t2;
	if(p1==p2)
		printf("Friendship");
	if(p1>p2)
		printf("First");
	if(p2>p1)
		printf("Second");
}


nclude <stdio.h>

    struct game{
        int s,v,t;
    };
int main()
{
    struct game player[2];
    scanf("%d %d %d %d %d",&player[0].s,&player[0].v,&player[1].v,&player[0].t,&player[1].t);

        if((player[0].s*player[0].v+2*player[0].t)>(player[0].s*player[1].v+2*player[1].t))
            printf("Second\n");
        else if((player[0].s*player[0].v+2*player[0].t)<(player[0].s*player[1].v+2*player[1].t))
            printf("First\n");
        else printf("Friendship\n");

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define sf scanf
#define pf printf
#define db double
#define end return 0
int func(int,int);
int a[100005];
int main()
{

     char c[1001],ch[1001],i,k=1;
     gets(c);
     ch[0]='/';
     for(i=0;c[i];i++)
     {
          if((ch[k-1]!='/'||ch[k-1]=='/')&& c[i]!='/')
          ch[k++]=c[i];
          else if(ch[k-1]!='/' && c[i]=='/')
          ch[k++]='/';
     }
     if(ch[k-1]=='/';)
     k=k-1;
     ch[k]='\0';
     pf("%s",ch);
end;
}


main() {
char qwer = zxcv = '\r';
while(scanf("%c", &zxcv)) {
if(qwer == '/' && zxcv != '/') {
printf("/", zxcv);
}
printf("%c", zxcv);
qwer = zxcv;
}
}


#include<stdio.h>
long long int n,m,i,j,a,b;
int ab(int a)
{
	if(a<0)
	return -a;
	return a;
}
int max(int a,int b)
{
	if(a<b)
	return b;
	return a;
}
int min(int a,int b)
{
	if(a>b)
	return b;
	return a;
}
int func(int u,int v)
{
		if(i==u&&j==v)
		return 0;
		if(i+a>n&&i-a<=0)
		return -1;
		if(j+b>m&&j-b<=0)
		return -1;
		int x=ab(u-i),y=ab(v-j);
		if(x%a!=0||y%b!=0)
		return -1;
		x=x/a;y=y/b;
		if(x%2!=y%2)
		return -1;
		int t=max(x,y);
		return t;
}
int main()
{
	scanf("%lld%lld%lld%lld%lld%lld",&n,&m,&i,&j,&a,&b);
	int ans=100000000;
	int a=func(1,m);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(n,1);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(1,1);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(n,m);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	if(ans<100000000)
	printf("%d",ans);
	else
	printf("Poor Inna and pony!");
	return 0;
}


#include<stdio.h>

int max(int a,int b)
{
    return a>b?a:b;
}
int min(int a,int b)
{
    return a<b?a:b;
}
int main()
{
    int n,m,i,j,a,b,ans=-1,x,y,an;
    scanf("%d %d %d %d %d %d",&n,&m,&i,&j,&a,&b);
    x=i-1;y=j-1;
    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    x=i-1;y=m-j;
    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    x=n-i;y=j-1;
    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    x=n-i;y=m-j;
    if(x%a==0 && y%b==0 && (x/a-y/b)%2==0)
    {
        an=max(x/a,y/b);
        if(ans==-1) ans=an;
        else ans=min(ans,an);
    }
    if(ans==-1) printf("Poor Inna and pony!");
    else printf("%d",ans);
    return 0;
}


#include <stdio.h>

max (long int *pp,long int *pb){
	long int t;
	if ((*pp)<(*pb)){
		t=*pp;
		*pp=*pb;
		*pb=t;

	}

}
int main (){
	long int n,m,i,j,a,b,p,q;
	scanf("%ld %ld %ld %ld %ld %ld",&n,&m,&i,&j,&a,&b);
	if (((n-i)%a==0) && ( (m-j)%b==0) )
{
	p=(n-i)/a;
	q=(m-j)/b;
	max(&p,&b);

	if ((p-q)%2==0){
		printf("%ld",p);
		exit;
		}
		else {
			printf("Poor Inna and pony!\n");
			exit;
		}
	}
else if (((n-i)%a==0) && ( (j-1)%b==0 ))
{
	p=(n-i)/a;
	q=(j-1)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

else if (((i-1)%a==0) && ( (j-1)%b==0 ))
{
	p=(i-1)/a;
	q=(j-1)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

else if (((i-1)%a==0) && ( (m-j)%b==0 ))
{
	p=(i-1)/a;
	q=(m-j)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

	else
	{
	printf("Poor Inna and pony!\n");

}
return 0;
}


#include<stdio.h>
#define INF 1000000009
int max(int x,int y){
    if(x>y){
        return x;
    }
    return y;
}
int min(int x, int y){
    if(x>y){
        return y;
    }
    return x;
}
int main(){
    int n,m,i,j,a,b,cnt1=INF,cnt2=INF,cnt3=INF,cnt4=INF,ans1=INF,ans2=INF,ans3=INF,ans4=INF,i,j,ret;
    scanf("%d%d%d%d%d%d",&n,&m,&i,&j,&a,&b);
    if((i-1)%a!=0){
        if((n-i)%a!=0){
            if((j-1)%b!=0){
                if((m-j)%b!=0){
                    printf("Poor Inna and pony!\n");
                    return 0;
                }
            }
        }
    }
    if((i-1)%a==0){
        cnt1=(i-1)/a;
    }
    if((n-i)%a==0){
        cnt2=(n-i)/a;
    }
    if((j-1)%b==0){
        cnt3=(j-1)/b;
    }
    if((m-j)%b==0){
        cnt4=(m-j)/b;
    }
    if((cnt1-cnt3)%2==0 && cnt1!=INF && cnt3!=INF){
        ans1=max(cnt1,cnt3);
    }
    if((cnt1-cnt4)%2==0 && cnt1!=INF && cnt4!=INF){
        ans2=max(cnt1,cnt4);
    }
    if((cnt2-cnt3)%2==0 && cnt2!=INF && cnt3!=INF){
        ans3=max(cnt2,cnt3);
    }
    if((cnt2-cnt4)%2==0 && cnt2!=INF && cnt4!=INF){
        ans4=max(cnt2,cnt4);
    }
    if(ans1==INF && ans2==INF && ans3==INF && ans4==INF){
        printf("Poor Inna and pony!\n");
        return 0;
    }
    i=min(ans1,ans2);
    j=min(ans3,ans4);
    ret=min(i,j);
    printf("%d\n",ret);
    return 0;
}


#include <stdio.h>
#include<string.h>
int main()
{
   char t[50],s[50];
   int i,j,temp=0;
   scanf("%s",t);
   int l=strlen(t);
   i=(l+1)/2 -1,j=(l+1)/2;
   if(l==1)
   {
       printf("%s",t);
   }
   while(i>=0&&j<l)
   {
		s[temp++]=t[i--];
		s[temp++]=t[j++];
    }
   if(i>=0)
   {
		while(i>=0)
		s[temp++]=t[i--];
	}
	if(j<l)
	{
		while(j<l)
		s2[temp++]=t[j++];
	}

    printf("%s",s);

    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
         int l,x,y,a,i,j=0;
         char t[100];
         scanf("%s",t);
         char s[100];
         l=strlen(t);
         x=l/2;
         y=x-1;
         a=y+1;
         for(i=0;i<x;i++)
         {

               strcpy(s[j],t[y]);
               j++;
               strcpy(s[j],t[a]);
               a++;
               y--;
               j++;
          }
          for(i=0;i<l;;i++)
          {
               printf{"%c",s[i]):
          }
          return 0;
}


#include<stdio.h>
int main(){
    long int n.s,count=0;
    scanf("%ld %ld",&n,&s);
    if(n>=s)
    count=1;
    else{
        count+=s/n;
        if(s%n!=0)
        count++;
    }
    printf("%ld\n",count);
    return 0;
}


#include<stdio.h>
int main(){
    int n,s;
    int k=0;
    int a=0;
    scanf("%d%d",&n,&s);
    for(i=0;i<=s;i--){
        if(k<s){
            k=k+i;
            a=a+1;
        }
        else{
            printf("%d",a);
        }
    }
return 0;
}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="Coins" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/Coins" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Debug/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-g" />
				</Compiler>
			</Target>
			<Target title="Release">
				<Option output="bin/Release/Coins" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Release/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-O2" />
				</Compiler>
				<Linker>
					<Add option="-s" />
				</Linker>
			</Target>
		</Build>
		<Compiler>
			<Add option="-Wall" />
		</Compiler>
		<Unit filename="main.c">
			<Option compilerVar="CC" />
		</Unit>
		<Extensions>
			<envvars />
			<code_completion />
			<debugger />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


#include<stdio.h>

int main()
{
    long float n, s, a, c;
	long int b ;
	scanf("%lf %lf", &n, &s);
	a=s/n;
	c=a;
	b=a;
	if(c!=b)
	{
		printf("%ld\n", b+1);
	}
	else
	{
		printf("1");
	}
}


#include <stdio.h>

int main()
{
    int a , b ;
    scanf("%d%d",&a.&b);
    printf("%d",b-1/a-1);
}


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

    int n,min,c=0,d=0,l,i=0,sub,count=0;
    scanf("%d",&n);
    char s[200];
    scanf("%s",s);
    l = strlen(s);
    for(i=0;i<l;i++){

        if(s[i]=='X'){
            c++;
        }
        if(s[i]=='x'){
            d++;
        }

    }
    sub = fabs(c - n/2 );
    if(c<(n/2)){
        min = n/2 - c;
        i=0;
        while(i!=n){
                if(s[i]=='x'){
            s[i] = toupper(s[i]);
            count++;
            if(count==min){
                break;
            }
                }
                i++;
        }
    }
    else if(d<(n/2)){
            min = n/2 - d;
      i=0;
      while(i!=n){

            if(s[i]=='X'){
            s[i] = tolower(s[i]);
            count++;
            if(count == min){
                break;
            }
            i++;
        }
    }
    }

    printf("%d\n",sub);
    i = 0;
    while(i!=n){
        printf("%c",s[i]);
        i++;
    }

}


#include <stdio.h>

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

		char arr[n+1];
		arr[n] = '\0';

		int sit = 0, stand = 0;
		for (int i =0; i < n; i++){
				scanf("%c ", &arr[i]);
				if (arr[i] == 'x')
						sit++;
				else
						stand++;
		}

		if (sit == stand)
				printf("0\n");
		else
				printf("1\n");

		int i = 0;
		while (sit > stand && i < n){
				if (arr[i] == 'x'){
						arr[i] = 'X';
						sit--; stand++;
				}
				i++;
		}

		i = 0;
		while (stand > sit && i < n){
				if (arr[i] == 'X'){
						arr[i] = 'x';
						stand--; sit++;
				}
		}

		printf("%s\n", arr);
		return 0;
}


#include <string.h>
#include <stdio.h>
int main()
{ //424A
    int n, i, j;
    char arr[200];
    char c;
    int m = 0;
    int target, remain;
    int current = 0;
    scanf("%d\n", &n);
    target = n / 2;

    for (i = 0; i < n; i++) {
        c = getchar();
        if (c == 'x')
            arr[i] = 0;
        else {
            arr[i] = 1;
            current++;
        }
    }
    remain = target - current;
    m = remain;
    if (remain < 0) remain * = -1;
    if (remain > 0) {
        for (i = 0; i < n && remain > 0; i++) {
            if (arr[i] == 0) {
                arr[i] = 1;
                remain--;
            }
        }
    } else if (remain < 0){
        for (i = 0; i < n && remain < 0; i++) {
            if (arr[i] == 1) {
                arr[i] = 0;
                remain++;
            }
        }
    }

    printf("%d\n", m);
    for (i = 0; i < n; i++) {
        if (arr[i] == 0)
            putchar('x');
        else
            putchar('X');
    }

   return(0);
}


#include<stdio.h>
inat main()
{
    int n,index,standing=0,sitting=0,diff,flag;
    char *array;
    scanf("%d",&n);
    array=(char*)malloc(n*sizeof(char));
    scanf("%s",array);
    for (index=0;index<n;index++)
    {
        if(array[n]=='X')
        standing++;
        else
        sitting++;
    }
    if(stnding>sitting)
    {diff=standing-sitting;
    flag=0;}
    else
    {diff=sitting-standing;
    flag=1;}
    printf("%d\n",diff);
    if(flag=0)
    {
    for (index=0;index<n;index++)
    {
        if(diff!=0)
        {
            if(array[index]=='X')
            {printf("x");
            diff--;
            }
        }
        else
        printf("%c",array[n]);
     }
     }
     else
     {
         for (index=0;index<n;index++)
    {
        if(diff!=0)
        {
            if(array[index]=='x')
            {printf("X");
            diff--;
            }
        }
        else
        printf("%c",array[n]);
     }

     }
     return 0;
}


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


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

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(nullptr), cout.tie(nullptr);

    int n, v;
    cin >> n >> v;
    if (n-1 <= v) {
        cout << n-1 << endl;
        return 0;
    }
    int result = v - 1;
    for(int i = 1; i <= n - v; ++i) {
        result += i;
    }
    cout << result << endl;

    return 0;
}


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

    int sum=0;
    for(int i=2;i<=n-v;i++)
    {
        sum=sum+i;
    }
    int p=v+sum;
    print("%d",p);
}


#include <stdio.h>

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>=b)
    int sum=b;
    else
    sum=a;
    for(int i=2;i<=a-b;i++)
    {
        sum+=i;
    }
    printf("%d",sum);
    return 0;

}


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


#include<stdio.h>
int main()
{
    int n, i, sum=0;
    char a[1000];
    scanf("%d", &n);

    scanf("%s", a);

    for(i=0; i<n; i++)
    {
        if(a[i]=='-')
        {
            if(sum != 0)
                sum--;
        }
        else if(a[i]=='+')
        {
            sum++;
        }
    }
    printf("%d", sum);
}
Chat Conversation End
Type a message...


#include<stdio.h>
#include<stdlib.h>
void main()
{
    char *str;
    int len,i,num;
    num=0;
    scanf("%d",&len);
    str=malloc(sizeof(char)*len);
    scanf("%s",str);
    for(i=0;i<len;i++)
    {
        if(str[i]=='-')
        {
            if(num==0)
                num=0;
            else
                num=num-1;
        }
        else
            num=num+1;
    }
    printf("%d",num);a
}


#include <stdio.h>

int main()
{
    int n;
    scanf("%d\n" , &n);
    char A[n];
    for(int i=0;i<n;i++)
    {
    scanf("%c" , &A[i]);
    }
    int temp=0;
    for(i=0;i<n;i++){
        if(A[i]=='-')
        {temp-=1;
            if(temp == -1)
            { temp=0;}
        }
        if(A[i]=='+'){
        temp++;
            }

    }

    printf("%d" , temp);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	cin>>n;
	char p[n];
	int c=0,i=0;
	cin>>p;
	for(int j=0;j<n;j++)
	{
		if(p[j]=='+')
		c++;
		if(p[j]=='-')
		c--;

		if(c<0)
		{
			i++;
			c=0;
		}
	}

	for(int j=0;j<n;j++)
	{
		if(p[j]=='+')
		i++;
		if(p[j]=='-')
		i--;

	}
	cout<<i<<endl;
}


#include<stdio.h>
int main()
{
	int n;
	scanf("%d\n", &n);
	int a[102];
	a[0] = 0;
	char c;
	int i;
	for (i = 0; i < n; i++)
	{
		scanf("%c", &c);
		if (c == '+')
			a[i + 1] = a[i] + 1;
		else
			a[i + 1] = a[i] - 1;
	}
	int min = 0;
	for (i = 0; i <= n; i++)
		if (min > a[i])
			min = a[i];
	if (0 > a[n] - min)
		printf("0\n");
	else
		printf("%d\n", a[n] - min);
	return 0;


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	long long int l,i,j,k,c=0,d=0,flag=1;
	l=s.length();
	for(i=0;i<l;i++)
	{
		if(s[i]=='0')
		c++;
		else
		break;
	}

	for(i=l-1;i>=0;i--)
	{
		if(s[i]=='0')
		d++;
		else
		break;
	}
	if(c>d)
	flag=0;
	else
	{
		k=d-c;
		for(i=0,j=l-k-1;i<=j;i++,j--)
		{
			if(s[i]!=s[j])
			{
				flag=0;
				break;
			}
		}
	}
	if(flag==1)
	printf("yes\n");
	else
	printf("no\n");

	return 0;
}


#include <stdio.h>
void main()
{
    long a,c,rev=0;
    int d
    scanf("%ld",&a);
    d=a%10;
    while(d==0)
    {
        a/=10;
        d=a%10;
    }
    c=a;
    while(c!=0)
    {
        d=c%10;
        rev=rev*10+d;
    }
    if(rev==a)
    printf("YES");
    else
    printf("NO");
}


#include <stdio.h>
#include <math.h>
int main()
{
	int x, a, reverse = 0, b = 0;
	scanf("%d", &x);
	while (n)
	{
		if (x % 10 == 0)
			x = x / 10;
		else
			break;
	}
	x = b;
	while (x)
	{
		a = x % 10;
		reverse = reverse * 10 + a;
		x = x / 10;
	}
	if (reverse == b)
	{
		printf("YES");
	}
	else
		printf("NO");
	return 0;
}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="Полиморф" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/Полиморф" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Debug/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-g" />
				</Compiler>
			</Target>
			<Target title="Release">
				<Option output="bin/Release/Полиморф" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Release/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-O2" />
				</Compiler>
				<Linker>
					<Add option="-s" />
				</Linker>
			</Target>
		</Build>
		<Compiler>
			<Add option="-Wall" />
			<Add option="-fexceptions" />
		</Compiler>
		<Unit filename="main.cpp" />
		<Extensions>
			<code_completion />
			<envvars />
			<debugger />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char input[1000000];
scanf("%s",&input);
int length=strlen(input),letter=length-1,numofzeroes=0,caseid;

if((length+1)%2==0)
caseid=0;
else
caseid=1;

while(input[letter]=='0'){
letter--;
numofzeroes++;
}

int done=0,front=0,back=letter;
while(done==0){

//printf("%c %c\n",input[front],input[back]);
if(len==1)
done=1;
else if(input[front]!=input[back]){
done=1;
}
else{
if(front==(((length-numofzeroes-caseid)/2)-1)){
done=2;
}
front++;
back--;
}
}

if(done==2)
printf("YES");
else
printf("NO");

}


#include<stdio.h>
long long int max(long long int a,long long int b){
    if(a>b)
      return a;
    else
       return b;
}
int main(){

    long long int n,m;
    scanf("%lld%lld",&n,&m);
    printf("%lld %lld",max(n-2*m,0),max(n-m-1,0);
    return 0;
}


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

int main()
{
	int n,m;//顶点，边
	scanf("%d%d", &n, &m);
	//最少/多几个孤立顶点
	//最少的话尽可能一个边就连两个点
	//最多的话尽可能接近满图
	//解不等式 p(p-1)/2 < m 求maxp
	int maxp = ceil((1 + sqrt(1 + 8 * m)) / 2);// +1;
	if (m == 0)
	{
		maxp = 0;
	}
	printf("%d %d", max(n - 2 * m, 0) , n- maxp);
	return 0;
}


#include<stdio.h>
#include<stdio.h>
int main()
{
	long long n,m,k,a,min,max;
	scanf("%lld %lld",&n,&m);
	for(a=0;a<=m;a++)
	{
		k=a*(a-1);
		if(k>=(2*m))
			break;
	}
	max=n-a;
	min=n-2*m;
	if(min<0)
		min=0;
	printf("%lld %lld\n",min,max);
}
/*
int factorial(int n)
    {
        int ans=n;
        for(int i=n-1;i>0;i++)
        {
            ans*=i;
        }
        return ans;
    }
int main()
    {
        int vertex,edges,min=0,max=0;
        scanf("%d",&vertex);
        scanf("%d",&edges);

        max=(vertex/2-edges)*2;
        min=factorial(vertex)/(factorial(vertex-2)*2)
        if(vertex%2==0)
            {

                printf("%d ",max);
            }
        else
            {
                printf("%d",max+1);
            }

    }
/*


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

int main()
{
    long long temp,m,n,min,max;
    double x;
    while(scanf("%lld %lld",&n,&m)!=EOF)
    {
        if(n==1)
           {
              min=max=1;
              printf("%lld %lld\n",min,max);
              continue;
           }
        if(2*m>n)
              min=0;
        else
              min=n-2*m;
        if(n*(n-1)/2==m)
              max=0;
        else
        {
            x=m;
            x=sqrt(x*2+0.25)+0.5;
            temp=(long long)x;
            temp=temp+1;
            while(temp*(temp-1)/2>=m)
                 temp--;
            temp++;
            max=n-temp;
        }
        printf("%lld %lld\n",min,max);
    }
    return 0;
}


#include<stdio.h>
#define int long long int
int main(){
	int i,n,m,min,max;
	scanf("%lld%lld",&n,&m);
	int l=n-2*m;
	if(l>=0)
		min=l;
	else
		min=0;
	for(i=0;i<n;i++)
		if((i*(i-1))/2 >=m)
			break;
	max=n-i;
	printf("%lld %lld",min,max);
}


#include<stdio.h>
#include<Math.h>
 int main(){
     int t,n;
     scanf("%d",&t);
     while(t>=1){
         scanf("%d",&n);

         } printf("%d\n",int sqrt(n)+int cbrt(n)-int(sqrt( cbrt(n))));
           t--;
     }
 }


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

int main()
{
	int n;
	cin >> n;
	while (cin >> n)
		cout<< (int) sqrt(n) + (int) cbrt(n) - (int) sqrt(cbrt(n)) << endl;
}


#include<stdio.h>
 int main(){
     int t,i;
     scanf("%d",&t);
     while(t>=1){
         int n;
         int count=0;
         scanf("%d",&n);
         for(i=1;i*i<=n;i++){
             if(i*i<=n){
                 count++;
             }if(i*i*i<=n){
                 count++;
             }
         }
    t--; }printf("%d",count);
 }


#include<stdio.h>
#include<Math.h>
 int main(){
     int t,i,count;
     scanf("%d",&t);
     while(t>=1){
         scanf("%d",&n);
         int a=sqrt(n);
         int b=cbrt(n);
         int c=sqrt(b);
        printf("%d\n", a+b-c);
        t--;
         }

     }


#include <stdio.h>
#include <math.h>
void solve() {
    int n;
    scanf("%d",&n);
    printf("%d\n",sqrt(n)+cbrt(n));
}
int main() {
    int t;
    scanf("%d",&t;
    for (int i=0;i<t;i++) {
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;int ar[110];
    int i=0;
    for(i=0;i<109;i++)
        ar[i]=0;
    scanf("%d",&n);
    int ans=0;
    for(i=1;i<=n;i++)
        scanf("%d",&ar[i]);
    for(i=1;i<=n;i++)
    {
        if(ar[i]==1)
            ans++;
        if(ar[i]==0&&ar[i-1]==1&&ar[i+1]==1)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
    }


#include <stdio.h>

enum State
{
    HOME,
    SCHOOL,
    LEAVE
};

int
automation(int n)
{
    int state = HOME;
    int count = 0;
    int pair;
    for (int i = 0; i < n; i++) {
        scanf("%d", &pair);
        switch (state) {
            case HOME:
                if (pair == 1) {
                    state = SCHOOL;
                    count++;
                }
                break;
            case SCHOOL:
                if (pair == 1) {
                    count++;
                }
                else {
                    state = LEAVE;
                }
                break;
            case LEAVE:
                if (pair == 1) {
                    count += 2;
                    state = SCHOOL;
                }
                else {
                    state = HOME;
                }
                break;
        }
    }
    return count;
}

int
main()
{
    int n;
    scanf("%d", &n);
    printf("%d\n", automation(n));
    return 0;
}


#include<cstdio>
int a[150];
int main()
{
	int n,sum,flag,flag1;
	while(~scanf("%d",&n))
	{
		sum=0,flag=1,flag1=1;
		for(int i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
			if(a[i]==1) sum++;
		}
		for(int i=0;i<n;i++)
		{
			if(a[i]==1&&a[i+1]==0&&a[i+2]==1)
			{
				sum++;
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}


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

int max(int a, int b)
{
    return (a>b) ? a : b;
}

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

int main()
{
    int HPY,ATKY,DEFY;
    int HPM,ATKM,DEFM;
    int addDEF = 0;
    int count = 0;
    int mini = 1000001;
    int h,a,d;

    scanf("%d %d %d", &HPY, &ATKY, &DEFY);
    scanf("%d %d %d", &HPM, &ATKM, &DEFM);
    scanf("%d %d %d", &h, &a, &d);

    int i;
    int HPYS = HPY,ATKYS = ATKY,DEFYS = DEFY;
    int HPMS = HPM,ATKMS = ATKM,DEFMS = DEFM;
    /* Increase attaque every time */
    for (i=0;i<100;++i)
    {
        count = a*i;
        if (ATKY+i-DEFM <= 0)
            continue;

        if (ATKY+i > 100)
            break;

        /* Count How much time every one before die */
        int numberH = (int)ceil((double)HPY/(double)max(0,ATKM-DEFY));
        int numberM = (int)ceil((double)HPM/(double)max(0,ATKY+i-DEFM));
        if (numberH > numberM)
            break;
        else if (numberM > 1)
        {
            /* If we increase Defence */
            while (max(0,ATKM-DEFY)*(numberM-1) > HPY)
                ++DEFY;
            count += (DEFY-DEFYS)*d;
            DEFY = DEFYS;
            mini = min(mini, count);
            /* If we increase Health */
            count = a*i;
            HPY += max(0,ATKM-DEFY)*(numberM-1) - HPY;
            count += HPY*h;
            mini = min(mini, count);
        }
        else if (numberM == 1)
        {
            while (max(0,ATKM-DEFY)*numberM > HPY)
                ++DEFY;
            count += (DEFY-DEFYS)*d;
            DEFY = DEFYS;
            mini = min(mini, count);
            /* If we increase Health */
            count = a*i;
            HPY += max(0,ATKM-DEFY)*numberM - HPY;
            count += HPY*h;
            mini = min(mini, count);
        }

        HPY = HPYS,ATKY = ATKYS,DEFY = DEFYS;
        HPM = HPMS,ATKM = ATKMS,DEFM = DEFMS;
    }

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

    return 0;
}


#include <stdio.h>

int max(int a, int b)
{
    return (a>b) ? a : b;
}

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

int main()
{
    int HPY,ATKY,DEFY;
    int HPM,ATKM,DEFM;
    int addDEF = 0;
    int count = 0;
    int mini = 1000001;
    int h,a,d;

    scanf("%d %d %d", &HPY, &ATKY, &DEFY);
    scanf("%d %d %d", &HPM, &ATKM, &DEFM);
    scanf("%d %d %d", &h, &a, &d);

    int i;
    int HPYS = HPY,ATKYS = ATKY,DEFYS = DEFY;
    int HPMS = HPM,ATKMS = ATKM,DEFMS = DEFM;
    /* Increase attaque every time */
    for (i=0;i<100;++i)
    {
        count += a*i;

        while (HPM > 0)
        {
            if (HPY < (ATKM-DEFY))
            {
                while (max(0,ATKM-(DEFY+addDEF)) >= HPY)
                    ++addDEF;

                if ((max(0, ATKM-DEFY)-(HPY)+1)*h < addDEF*d)
                {
                    count += (max(0, ATKM-DEFY)-(HPY)+1)*h;
                    HPY += max(0, ATKM-DEFY)-(HPY)+1;
                    addDEF = 0;
                }
                else
                {
                    count += addDEF*d;
                    DEFY += addDEF;
                    addDEF = 0;
                }
            }

            HPM -= max(0, ATKY+i-DEFM);
            HPY -= max(0, ATKM-DEFY);
        }

        if (HPY > 0)
            mini = min(mini, count);

        HPY = HPYS,ATKY = ATKYS,DEFY = DEFYS;
        HPM = HPMS,ATKM = ATKMS,DEFM = DEFMS;

        count = 0;
    }

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

    return 0;
}


#include <stdio.h>

int lTime(int h, int a, int d) {
    int i=-1;
    if(d>=a) return 999999999;
    while(h>0){
        h=h-(a-d);
        i++;
    }
    return i;
}
int main() {
    int yh,ya,yd;
    int mh,ma,md;
    int h,a,d;
    int lh,la,ld=1000;
    int i,j,k,cost,min=999999999,yaa=0;
    scanf("%d %d %d",&yh,&ya,&yd);
    scanf("%d %d %d",&mh,&ma,&md);
    scanf("%d %d %d",&h,&a,&d);

    for(i=0;i<1000;i++)
        if(lTime(yh+i,ma,yd)>lTime(mh,ya,md))
            break;
    lh=i;
    for(i=0;i<1000;i++)
        if(lTime(yh,ma,yd)>lTime(mh,ya+i,md))
            break;
    la=i;
    for(i=0;i<1000;i++)
        if(lTime(yh,ma,yd+i)>lTime(mh,ya,md))
            break;
    ld=i;

//  lh=(h>10)?10000/h:1000;
//  la=(a>10)?10000/a:1000;
//  ld=(d>10)?10000/d:1000;
    if(ya<=md) yaa=md-ya+1;
//  printf("%d %d %d\n",lh,la,ld);
    for(i=0;i<=lh;i++){
        for(j=yaa;j<=la;j++) {
            for(k=0;k<= ld;k++) {
                if(lTime(yh+i,ma,yd+k)>lTime(mh,ya+j,md)) {
                    cost=i*h+j*a+k*d;
                    if(cost<min) {
                        min=cost;
//                      printf("%d %d %d %d\n",i,j,k,cost);
                    }
                }
            }
        }
    }
    printf("%d\n",min);
    return 0;
}


#include <stdio.h>

int lTime(int h, int a, int d) {
    int i=-1;
    if(d>=a) return 999999999;
    while(h>0){
        h=h-(a-d);
        i++;
    }
    return i;
}
int main() {
    int yh,ya,yd;
    int mh,ma,md;
    int h,a,d;
    int lh,la,ld;
    int i,j,k,cost,min=999999999,yaa=0;
    scanf("%d %d %d",&yh,&ya,&yd);
    scanf("%d %d %d",&mh,&ma,&md);
    scanf("%d %d %d",&h,&a,&d);

    lh=(lh>10)?8000/h:800;
    la=(la>10)?8000/a:800;
    ld=(ld>10)?8000/d:800;
    if(ya<=md) yaa=md-ya+1;
//  printf("%d %d %d\n",lh,la,ld);
    for(i=0;i<lh;i++){
        for(j=yaa;j<la;j++) {
            for(k=0;k<ld;k++) {
                if(lTime(yh+i,ma,yd+k)>lTime(mh,ya+j,md)) {
                    cost=i*h+j*a+k*d;
                    if(cost<min) {
                        min=cost;
//                      printf("%d %d %d %d\n",i,j,k,cost);
                    }
                }
            }
        }
    }
    printf("%d\n",min);
    return 0;
}


#include <stdio.h>

#define Max 200
short Life[Max+1][Max+1][Max+1];

int chkLT(int a,int b,int c) {
    if(a<=Max&&b<=Max&&c<=Max) return Life[a][b][c];
    else if(c>=b) return 99999;
    else return (a-1)/(b-c);
}

int main() {
    int yh,ya,yd;
    int mh,ma,md;
    int h,a,d;
    int i,j,k,cost,min=99999,yaa=0;
    int lh=1000,la=1000,ld=1000;
    scanf("%d %d %d",&yh,&ya,&yd);
    scanf("%d %d %d",&mh,&ma,&md);
    scanf("%d %d %d",&h,&a,&d);

    for(i=1;i<=Max;i++)
        for(j=1;j<=Max;j++)
            for(k=1;k<=Max;k++)
                if(k>=j) Life[i][j][k]=99999;
                else Life[i][j][k]=(i-1)/(j-k);
//printf("%d %d\n",Life[10][5][2],Life[10][6][1]);
    lh=(h>5)?lh/h:1000;
    la=(a>5)?la/a:1000;
    ld=(d>5)?ld/d:1000;

    for(i=0;i<=lh;i++){
        for(j=yaa;j<=la;j++) {
            for(k=0;k<=ld;k++) {
                if(chkLT(yh+i,ma,yd+k)>chkLT(mh,ya+j,md)) {
                    cost=i*h+j*a+k*d;
                    if(cost<min) {
                        min=cost;
//                      printf("%d %d %d %d\n",i,j,k,cost);
                    }
                }
            }
        }
    }
    printf("%d\n",min);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<limits.h>
int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}
long long int min(long long int a,long long int b)
{
    if(a<b)
    return a;
    else
    return b;
}
long long int max(long long int a,long long int b)
{
    if(a>b)
    return a;
    else
    return b;
}
long long int ar[2000005],flag[2000005];
int main()
{
    long long int a,b,val,val1,val2,i,j,ans,mod=1000000007,k;
    scanf("%lld %lld",&a,&b);
    val1=min(a,b);
    val=sqrt(2*(a+b));
    if((val*(val+1))/2>(a+b))
    val--;
    val2=(val*(val+1))/2-max(a,b);
    if(val1>val2)
    {
        val2=val1+val2-(val1=val2);
    }
    //printf("%lld ",val);
    if(val1<0)
    val1=0;
    //printf("%lld %lld ",val,val2);
    //long long int ar[val2+1],flag[val2+1];
    for(i=0;i<=val2;i++)
    ar[i]=0;
    if(val2>min(a,b))
    val2=min(a,b);
    if(val*(val+1)<2*max(a,b))
    i=0;
    else
    i=1;
    for(i=0;i<=val;i++)
    {
        for(k=1;k<=val2;k++)
        flag[k]=0;
        for(j=1;j<=val2;j++)
        {
            if(j-i>0&&ar[j-i]>0&flag[j-i]==0)
            {
                ar[j]=ar[j]+ar[j-i];
                flag[j]=1;
                if(ar[j]>mod)
                ar[j]=ar[j]%mod;
            }
        }
        if(i<=val2)
        ar[i]++;
        if(ar[i]>mod)
        ar[i]=ar[i]%mod;
        //for(k=1;k<=val2;k++)
        //printf("%lld ",ar[k]);
        //printf("\n");
    }
    ans=0;
    for(i=val1;i<=val2;i++)
    {
        ans=ans+ar[i];
        if(ans>mod)
        ans=ans%mod;
    }
    printf("%lld",ans);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<limits.h>
int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}
long long int min(long long int a,long long int b)
{
    if(a<b)
    return a;
    else
    return b;
}
long long int max(long long int a,long long int b)
{
    if(a>b)
    return a;
    else
    return b;
}
long long int ar[2000005],flag[2000005];
int main()
{
    long long int a,b,val,val1,val2,i,j,ans,mod=1000000007,k;
    scanf("%lld %lld",&a,&b);
    val1=min(a,b);
    val=sqrt(2*(a+b));
    val2=(val*(val+1))/2-max(a,b);
    if(val1>val2)
    {
        val2=val1+val2-(val1=val2);
    }
    //printf("%lld %lld ",val,val2);
    //long long int ar[val2+1],flag[val2+1];
    for(i=0;i<=val2;i++)
    ar[i]=0;
    for(i=1;i<=val;i++)
    {
        for(k=1;k<=val2;k++)
        flag[k]=0;
        for(j=1;j<=val2;j++)
        {
            if(j-i>0&&ar[j-i]>0&flag[j-i]==0)
            {
                ar[j]=ar[j]+ar[j-i];
                flag[j]=1;
                if(ar[j]>mod)
                ar[j]=ar[j]%mod;
            }
        }
        if(i<=val2)
        ar[i]++;
        if(ar[i]>mod)
        ar[i]=ar[i]%mod;
        //for(k=1;k<=val2;k++)
        //printf("%lld ",ar[k]);
        //printf("\n");
    }
    ans=0;
    for(i=val1;i<=val2;i++)
    {
        ans=ans+ar[i];
        if(ans>mod)
        ans=ans%mod;
    }
    printf("%lld",ans);
    return 0;
}


#include <stdio.h>

#define MAX 200010
#define MOD 1000000007

using namespace std;

int n, m, h, sum[1010], dp[MAX][2];

void Pregenerate(){
    int i, j, l, res, x = 0;
    for (i = h; i >= 0; i--){
        sum[i] = x;
        x += i;
    }

    for (l = 0; l <= h; l++){
        for (i = n; i >= 0; i--){
            j = sum[l] - i;
            if (i > sum[l]) continue;
            if (j > m) continue;

            if (!l) res = 1;
            else{
                res = 0;
                if ((i + l) <= n) res = res + dp[i + l][(l - 1) & 1];
                if ((j + l) <= m) res = res + dp[i][(l - 1) & 1];
            }

            if (res >= MOD) res -= MOD;
            dp[i][l & 1] = res;
        }
    }
}

int main(){
    int i, j;

    while (scanf("%d %d", &n, &m) != EOF){
        for (h = 0; h <= 1000; h++){
            int x = (h * (h + 1)) >> 1;
            if (x > (n + m)){
                h--;
                break;
            }
        }

        Pregenerate();
        int res = dp[0][h & 1];
        printf("%d\n", res);
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
long long int mmax(long long int a,long long int b){
    if(a>b) return a;
    else return b;
}
long long int fun(long long int i){
    return (i*(i+1))/2;
}
long long int target;
long long int binSearch(long long int i,long long int j){
    long long int mid;
    while (i<j) {
        mid=(i+j)/2;
        if(i==mid) break;
        if(fun(mid)<target)
            i=mid;
        else j=mid;
    }
    return i;
}
long long int dp[200001][1001];
int main(){
    long long int r,g;
    scanf("%lld %lld",&r,&g);
    target=r+g+1;
    long long int h=binSearch(1, target);
    long long int ans=0;
    dp[0][0]=1;
    for (long long int red=0; red<=r; red++) {
        for (long long int height=1; height<=h; height++) {
            if(fun(height)-red<=g){
                dp[red][height]+=dp[red-height][height-1]+dp[red][height-1];
                dp[red][height]%=1000000007;
                if(height==h)
                    ans+=dp[red][height];
                ans%=1000000007;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<limits.h>
int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}
long long int min(long long int a,long long int b)
{
    if(a<b)
    return a;
    else
    return b;
}
long long int max(long long int a,long long int b)
{
    if(a>b)
    return a;
    else
    return b;
}
int main()
{
    long long int a,b,val,val1,val2,i,j,ans,mod=1000000007,k;
    scanf("%lld %lld",&a,&b);
    val1=min(a,b);
    val=sqrt(2*(a+b));
    val2=(val*(val+1))/2-max(a,b);
    if(val1>val2)
    {
        val2=val1+val2-(val1=val2);
    }
    //printf("%lld %lld ",val,val2);
    long long int ar[val2+1],flag[val2+1];
    for(i=0;i<=val2;i++)
    ar[i]=0;
    for(i=1;i<=val;i++)
    {
        for(k=1;k<=val2;k++)
        flag[k]=0;
        for(j=1;j<=val2;j++)
        {
            if(j-i>0&&ar[j-i]>0&flag[j-i]==0)
            {
                ar[j]=ar[j]+ar[j-i];
                flag[j]=1;
                if(ar[j]>mod)
                ar[j]=ar[j]%mod;
            }
        }
        if(i<=val2)
        ar[i]++;
        if(ar[i]>mod)
        ar[i]=ar[i]%mod;
        //for(k=1;k<=val2;k++)
        //printf("%lld ",ar[k]);
        //printf("\n");
    }
    ans=0;
    for(i=val1;i<=val2;i++)
    {
        ans=ans+ar[i];
        if(ans>mod)
        ans=ans%mod;
    }
    printf("%lld",ans);
    return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
    char s[200];
    int k=0,len=0,index=0,i=0,flag=2,count1;count2;
    scanf("%s",s);
    len=strlen(s);
    scanf("%d",&k);
    if((len+k)%2!=0&&len!=0) { index++;}
    while(index<len)
    {
        int mid=index+ (len+k-index)/2;
        for(i=0;mid+i<len;i++)
        {
            if(s[index+i]!=s[mid+i]) break;
        }
        if(mid+i>=len) {flag=0;break;}
        index+=2;
    }
    count1=len+k-index-flag;
    index=0;flag=2,k=0;
    if((len+k)%2!=0&&len!=0) { index++;}
    while(index<len)
    {
        int mid=index+ (len+k-index)/2;
        for(i=0;mid+i<len;i++)
        {
            if(s[index+i]!=s[mid+i]) break;
        }
        if(mid+i>=len) {flag=0;break;}
        index+=2;
    }
    count2=len+k-index-flag;
    if(count1<count2) count1=count2;
    printf("%d",count1);
return 0;
}


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

int tandem(int , int );
char s[401];
int k,count;
int main(void)
{
    int i,j,len,max=0;
    scanf("%s %d",s,&k);
    len=strlen(s);
    for(i=len,j=0;j<k;j++,i++)
        s[i]='?';
    len+=k;
    for(i=0;i<len;i++)
    {
        for(j=i+1;j<len;j++)
        {
            if(tandem(i,j)==1)
            {
                if(max<j-i+1)
                    max=j-i+1;
            }
        }
    }
    printf("%d",max);
    return 0;
}
int tandem(int low,int high)
{
    int cond=1;
    count=0;
    int mid=(high-low+1)/2;
    for(i=0;i<mid;i++)
        if(s[i]!=s[i+mid] && s[i+mid]!='?')
            return 0;
        else
            return 1;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int i,j,k,l,m,temp,res=0,max=0;
    char s[300],in[10];
    scanf("%s",s);
    scanf("%s",in);
    k=atoi(in);
    l=strlen(s);
    if(k>=l)
        printf("%d\n",((k+l)/2));
    else
    {
        for(i=0;i<l-k;i++)
        {
            for(j=(l+k-i)/2;j>=1;j--)
            {
                temp=0;
                for(m=i;m<i+j;m++)
                {
                    if(m+j>=l)
                        break;
                    if(s[i]!=s[m+j])
                    {temp=-1;break;}
                }
                if(temp==0 && j>max)
                    max=j;
            }
        }
        if(max>k)
            printf("%d\n",2*max);
        else
            printf("%d\n",2*k);
    }
    return 0;
}#include <stdio.h>

int main(void) {
	// your code goes here
	return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
    char s[200];
    int k=0,len=0,index=0,i=0,flag=0;
    scanf("%s",s);
    len=strlen(s);
    scanf("%d",&k);
    if((len+k)%2!=0) { index++;}
    while(1)
    {
        int mid=index+ (len+k-index)/2;
        for(i=0;mid+i<len;i++)
        {
            if(s[index+i]!=s[mid+i]) break;
        }
        if(mid+i==len) break;
        index+=2;
    }
    printf("%d",len+k-index);
return 0;
}


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

int ktra(char s[], int start, int end, int u, int n)
{
    int i;
    for (i = start; i < start + u; i++)
    {
        if (s[i] != s[i + u] && i + u <= n - 1)
            break;
    }
    if (i >= start + u)
        return 1;
    else return 0;
}

int kqua(char s[], int k)
{
    int n, u, start, end;
    n = strlen(s);
    u = (n + k) / 2;
    if (n > k)
    {
        for (; u >= k; u--)
        {
            start = 0; end = 2*u - 1;
            while (end <= n + k - 1)
            {
                if (ktra(s, start, end, u, n))
                    break;
                else
                {
                    start++; end++;
                }
            }
            if (end <= n + k - 1)
                return 2 * u;
        }
    }
    else return 2 * u;
}

int main()
{
    char s[100];
    int k;
    scanf("%s", &s);
    scanf("%d", &k);
    printf("%d", kqua(s, k));
    return 0;
}


#include <stdio.h>

int main()
{
    int n,a,b,i;

    scanf("%d %d %d", &n, &a, &b);

    for (i=1; i<=a && i<=b && (a/i + b/i >= n); x++);

    printf("%d", x - 1);

    return 0;

}


#include <stdio.h>

int main()
{
	int n,a,b,x,y,z,i,ans;

	scanf("%d%d%d", &n, &a, &b);
	ans = 0;
	for (i = 1; i< n; i++)
	{
		 x = a / m;
		 y = b / (n - m);
		 z = x < y ? x : y;

		if (ans < z)
			ans = z;
	}
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>

int main()
{
    int n,a,b,i;

    scanf("%d %d %d", &n, &a, &b);

    for (i=1; i<=a && i<=b && (a/i + b/i >= n); i++);

    printf("%d", x - 1);

    return 0;

}


//Date : 27 - 12 - 17

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<inttypes.h>
#include<assert.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(i=0;i<n;i++)
#define rep(i ,a ,b)	for(i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 100005
#define NIL -1
int min(int a,int b){	return (a < b ? a : b)	;}
int max(int a,int b){	return (a > b ? a : b)	;}
/*
int a[MAX] ,p[MAX];
int main(){
	int n ,i ,m = INT_MAX ,r = 0 ,d = INT_MAX;
	s(n);
	For(i ,n){	s(a[i]);	m = min(m ,a[i]);	}
	For(i ,n)	if(a[i] == m)	p[r++] = i;
	rep(i ,1,r - 1)	d = min(d ,p[i] - p[i - 1]);
	printf("%d" ,d);
	return 0;
}*/

void swap(int *a,int *b){
	int t = *a;
	*a = *b;
	*b = t;
}
int main(){
	int n ,a ,b ,i ,x ,y;
	scanf("%d%d%d" ,&n ,&a ,&b);
	if(a > b)	swap(&a ,&b);
	rep(i ,1 ,a){
		x = a / i;
		y = b / i;
		if(x + y < n)	break;
	}
	printf("%d" ,i - 1);
	return 0;
}
/*
int a[3];
int cmp(const void *a,const void *b){
	int *a1 = (int *)a;
	int *b1 = (int *)b;
	if((*a1) > (*b1))	return 1;
	if((*a1) == (*b1))	return 0;
	return -1;
}
int main(){
	scanf("%d%d%d" ,a ,a + 1 ,a + 2);
	qsort(a ,3 ,sizeof(a[0]) ,cmp);
	if(a[0] == 1)	puts("YES");
	else if(a[0] == 2){
		if(a[1] == 2)	puts("YES");
		else puts("NO");
	}else if(a[0] == 3){
		if(a[1] == 3 && a[2] == 3)	puts("YES");
		else puts("NO");
	}else	puts("NO");
	return 0;
}*/
int a[1550]
int main(){
	int n ,i ,j;
	s(n);
	For(i ,n)	s(a[i]);

}


include<stdio.h>
#include<limits.h>
int min(int a,int b)
{
	if(a>b)
	return b;
	else
	return a;
}
int main()
{
	int n;
	scanf("%d",&n);
	int a[n+1];

	int i,x,y;
	x=n;
	for(i=0;i<=n;i++)
	a[i]=INT_MAX;
	a[0]=0;
	int t;
	//int q=11;
	for( i=1;i<=9;i++)
	a[i]=1;
	for(i=10;i<=n;i++)
	{
		x=i;
		while(x/10!=0)
		{
		//	printf("iii");
			y=x%10;
		//	printf("%d\n",y);
			if(y!=0)
			a[i]=min(a[i-y]+1,a[i]);
			x=x/10;
		//	printf("%d\n",x);
		}
		y=x%10;
		if(y!=0)
			a[i]=min(a[i-y]+1,a[i]);

	}
	printf("%d",a[n]);
}


#include<stdio.h>
#include<conio.h>
 int main()
 {
    int n, m, large=0, rem;
  int counter=0;
  scanf("%d", &n);
  for(; n!=0; counter++)
  { large = 0; m = n;
   while(m)
   { rem = m%10;
    if(rem > large) large = rem;
     m = m/10; }
      n = n-large; }
printf("%d\n", counter);
getch();
 return 0;
  }


#include<stdio.h>
#include<conio.h>
 int main()
 {
    int n, m, large=0, rem;
 int counter=0;
  scanf("%d", &n);
  for(; n!=0; counter++)
  { large = 0; m = n;
   while(m)
   { rem = m%10;
    if(rem > large) large = rem;
     m = m/10; }
      n = n-large; }
printf("%d\n", counter);
getch();
 return 0;
  }


#include<stdio.h>
long long int min(long long int a,long long int b)
{
    if(a<b)
        return a;
    else return b;
}
int main()
{
    long long int n,a,b,c;
    scanf("%lld %lld %lld %lld",&n,&a,&b,&c);
    if(n%4==0 )
        printf("0");
    else
    {
    switch(n%4)
    {
        case 3:printf("%d",min(3*c,min(a,b+c));break;
        case 2:printf("%d",min(a+c,min(2*a,b));break;
        case 1:printf("%d",min(a+b,min(3*a,c)));break;

    }
    }
    return 0;

}


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

int main(){
    long long int n, a, b, c;
    scanf("%I64d %I64d %I64d %I64d", &n, &a, &b, &c);
    n %= 4;
    switch(n){
        case 0: printf("0\n"); break;
        case 1: long long int x = a + b;
                if (x > (a + a + a)) x = a + a + a;
                else if (x > c) x = c
                printf("%I64d\n", x); break;
        case 2: long long int x = c + c + a + a + a;
                if (x > (a + a)) x = a + a;
                else if (x > b) x = b;
                printf("%I64d\n", x); break;
        case 3: long long int x = c + b;
                if (x > a) x = a;
                printf("%I64d\n", x); break;
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int n,a,b,c,rem,amt=0;
    scanf("%lld%lld%d%lld",&n,&a,&b,&c);
    rem=n%4;
    if(rem==1)
    {
        amt=(c<3*a)?c:(3*a);
        amt=((a+b)<amt?(a+b):amt);
    }
    else if(rem==2)
    {
        amt = (b<2*a)?b:(2*a);
        amt = ((2*c)<amt)?)2*c):amt;
    }
    else if(rem==3)
    {
        amt=(a<3*c)?a:(3*c);
        amt=amt<(b+c)?amt:(b+c);
    }
    printf("%lld",amt);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,a,b,c;
    int ans;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    switch((n%4))
    {
      case 0 : ans=0;  break;
      case 3 : ans=a < b+c ? a: b+c ;
               ans= ans < 3*c ? ans = 3*c;
      break;
      case 2 : ans= 2*a > b ? b : 2*a ;
               ans = ans < 2*c ? ans : 2*c ;
               break;
      default:  ans= 2*a > b ? b+a : 3*a ;
                ans= ans > c ? c : ans ;
    };
    printf("%d\n",ans);
    return 0;
}


#include<stdio.h>
#define MIN(a,b) (a>b?b:a)
#define Min(a,b,c) MIN(MIN(a,b),c)
main()
{
	long long int x,n,a,b,c;
	scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
	x=n%4;
	switch(x)
	{
		case 1:printf("%lld",min(3*a,c,a+b));
		break;
		case 2:printf("%lld",Min(2*a,b,2*c));
		break;
		case 3:printf("%lld",Min(a,b+c,3*c));
		break;
		default:printf("0");
	}
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long  a;
    scanf("%I64d",&a);
    p=pow(2,a);
    printf("%I64d\n",p);
    return 0;
}


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

int main()
{
    cin>>a;
    print("%d",pow(2,a));
    return 0;
}


#include<stdio.h>
#define M 1000000007
__int64 fastpow(int a,__int64 n){
    __int64 ans;
    if(n==0) return 1;
   if(n==1) return a%M;
   ans=fastpow(a,n/2)%M;
    ans=(ans*ans)%M;
    if(n%2==1)
       ans=((ans%M)*(a%M))%M;
     return ans%M;
}
int main(){
    __int64 ans;
    __int64 n;
    while(scanf("%I64d",&n)!=EOF){
        if(n==0)
         printf("1\n");
         else{
        ans=(fastpow(2,n-1)%M+(2*(fastpow(4,n-1)%M))%M)%M;
        printf("%I64d\n",ans);
         }
        }
  return 0;
}


#include<stdio.h>
#define MAX 1000000007
long long i,n,y=1,temp,temp2,a=0;
long long int pow(long long int a){
	if(!a) return 1;

	temp = pow(a/2);
	temp = (temp*temp) % MAX;
	if(a%2 == 1) temp*=2 % MAX;
	return temp;
}
int main(){
	scanf("%lld",&n);
	n = pow(n);
	printf("%lld",(n*(n+1)/2)%MAX);
	return 0;
}


#include <stdio.h>

const long long mod = 1000000007;

long long
power(long long a, long long b)
{
    if(b == 0){
        return 1;
    }
    if(b % 2 == 0){
        long long l = power(a, b / 2);
        l = (l * l) % mod;
        return l;
    } else {
        long long l = (power(a, b - 1) * a) % mod;
        return l;
    }
}

int
main(void)
{
    long long n;
    if(n == 0){
        printf("1");
        return 0;
    }
    scanf("%I64d", &n);
    long long ans = power(2, n - 1);
    long long ans2 = (ans * 2 + 1) % mod;
    ans = (ans * ans2) % mod;
    printf("%I64d", ans);
    return 0;
}


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

int main(void)
{
    char map[4][4], x, temp[5];
    int c = 0;

    for(int i = 0; i < 4; i++)
    {
        scanf("%s", map[i]);
    }

    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 4; j++)
        {
            if (map[i][j] == '.')
            {
                map[i][j] = 'x';
            }
        }
    }

    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 4; j++)
        {
            temp[j] = map[i][j];
        }
        temp[4] = 0;
        if (strcmp(temp, "xxxx") == 0)
        {
            c++;
        }
    }
    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 4; j++)
        {
            temp[j] = map[j][i];
        }
        temp[4] = 0;
        if (strcmp(temp, "XXXX") == 0)
        {
            c++;
        }
    }

    for(int i = 0; i < 4; i++)
    {
        temp[i] = map[i][i];
    }
    if (strcmp(temp, "XXXX") == 0)
    {
        c++;
    }
    for(int i = 0; i < 4; i++)
    {
        temp[i] = map[i][3 - i];
    }
    if (strcmp(temp, "xxxx") == 0)
    {
        c++;
    }

    if (c == 0)
    {
        puts("NO");
    }
    else
    {
        puts("YES");
    }

    return 0;
}


#include<stdio.h>

int num[4][4] = { 0 };

int ok(int a, int b)
{
	int i, cnt = 0;

	for (i = a - 2; i <= a + 2; i++)
	{
		if (i < 0)
			continue;
		else if (i > 3)
			break;
		else if (num[i][b] == 1)
			cnt++;
		else if (num[i][b] != 1 && cnt > 0 && cnt != 3)
		{
			cnt = 0;
			break;
		}
	}
	if (cnt == 3)
		return 1;
	else
		cnt = 0;

	for (i = b - 2; i <= b + 2; i++)
	{
		if (i < 0)
			continue;
		else if (i > 3)
			break;
		else if (num[a][i] == 1)
			cnt++;
		else if (num[a][i] != 1 && cnt > 0 && cnt != 3)
		{
			cnt = 0;
			break;
		}
	}
	if (cnt == 3)
		return 1;
	else
		cnt = 0;

	for (i = -2; i <= 2; i++)
	{
		if (a + i < 0 || b + i < 0)
			continue;
		else if (a + i > 3 || b + i > 3)
			break;
		else if (num[a + i][b + i] == 1)
			cnt++;
		else if (num[a + i][b + i] != 1 && cnt > 0 && cnt != 3)
		{
			cnt = 0;
			break;
		}
	}
	if (cnt == 3)
		return 1;
	else
		cnt = 0;

	return 0;
}

int dfs(int a, int b)
{
	if (a == 4)
		return 0;
	else if (b == 4)
		return dfs(a + 1, 0);
	else if (num[a][b] == 2 || num[a][b] == 1)
		return dfs(a, b + 1);
	else
	{
		num[a][b] = 1;
		if (ok(a, b))
			return 1;
		num[a][b] = 0;
		return dfs(a, b + 1);
	}
}

int main(void)
{
	int i, j;
	char temp;

	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 4; j++)
		{
			scanf("%c", &temp);
			if (temp == 'x')
				num[i][j] = 1;
			else if (temp == 'o')
				num[i][j] = 2;
		}
		getchar();
	}
	if (dfs(0, 0))
		printf("YES");
	else
		printf("NO");
}


#include "stdio.h"

char a[5][5],temp;
int countX=0, countO=0;

bool check(char temp){
  for (int i=0 ; i<4 ; i++){
    if (a[i][0]==temp && a[i][1]==temp && a[i][2]==temp) return true;
    if (a[i][1]==temp && a[i][2]==temp && a[i][3]==temp) return true;
  }
  for (int i=0 ; i<4 ; i++){
    if (a[0][i]==temp && a[1][i]==temp && a[2][i]==temp) return true;
    if (a[1][i]==temp && a[2][i]==temp && a[3][i]==temp) return true;
  }
  for (int i=2 ; i<4 ; i++){
    for (int j=2 ; j<4 ; j++){
      if (a[i][j]==temp && a[i+1][j-1]==temp && a[i+2][j-2]==temp) return true;
    }
  }
  for (int i=0 ; i<2 ; i++){
    for (int j=0 ; j<2 ; j++){
      if (a[i][j]==temp && a[i+1][j+1]==temp && a[i+2][j+2]==temp) return true;
    }
  }
  return false;
}

int main(int argc, char const *argv[]) {
  for (int i=0 ; i<4 ; i++){
    for (int j=0 ; j<4 ; j++){
      scanf("%c", &a[i][j]);
      if (a[i][j]=='x') countX++;
      if (a[i][j]=='o') countO++;
    }
    scanf("%c", &temp);
  }

  if (countX>countO){
    temp='o';
  }
  else if (countX<countO){
    temp='x';
  }
  else temp='x';
  for (int i=0 ; i<4 ; i++){
    for (int j=0 ; j<4 ; j++){
      if (a[i][j]=='.'){
        a[i][j]=temp;
        if (check(temp)){
          printf("YES");
          return 0;
        }
        a[i][j]='.';
      }
    }
  }
  printf("NO");
  return 0;
}


#include<stdio.h>
int main()
{double a, b, c, d, x, y, a1, a2, p, q;
  scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
x =(a - (a/250)*c);
y =(b - (b/250)*d);
a1 =(3*a)/10;
b2 =(3*b)/10;
p=max(x,a1);
q=max(y,b1);
if(p<q)
   {
     printf("Vasya");
   }
     else if (p>q)
   {
     printf("Misha");
   }
    else if (p==q)
   {
    printf("Tie");

   }
   return 0;
}
   }


#include<stdio.h>
int main()
{int a, b, c, d, x, y, m, n, o, p;
  scanf("%d %d %d %d", &a, &b, &c, &d);
m =(a - (a/250)*c);
n =(b - (b/250)*d);
o =(3*a)/10;
p =(3*b)/10;

   if(m>o)
   {
      x=m;
   }
      else if(m<o)
        {
        x=o;
        }
    if(n>p){
    {
    y=n;
    }
   else if(n<p)
    {
    y=p;
    }
    if (x>y){
        printf("Misha");
    }
    else if(y>x){
        printf("Vasya");
    }
   else if (x==y){
    printf("Tie");
   }

  }


#include<stdio.h>
 main()
{double a, b, c, d, x, y, m, n, o, p;
  scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
m =(a - (a/250)*c);
n =(b - (b/250)*d);
o =(3*a)/10;
p =(3*b)/10;

   if(m>o)
   {
      x=m;
   }
      else if(m<o)
        {
        x=o;
        }
    if(n>p){
    {
    y=n;
    }
   else if(n<p)
    {
    y=p;
    }
    if (x>y){
        printf("Misha");
    }
    else if(y>x){
        printf("Vasya");
    }
   else if (x==y){
    printf("Tie");
   }
   return 0;
  }


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>
int main()
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	int xxx, yy;
	xxx = 75 * a > 250 * a - a*c ? 75 * a : 250 * a - a*c;
	yy = 75 * b> 250 * b - b*d? 75 * b: 250 * b - b*d;
	if (xxx > yy)printf("Misha\n");
	else if (xxx == yy)printf("Tie\n");
	else printf("Vasya\n");
	return 0;
}


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f;
printf("\nEnter points and timings of Misha and Vasya resp.:");
scanf("%d %d %d %d",&a,&b,&c,&d);
e=a-(a/250)*c;
f=b-(b/250)*d;
if(e>f)
{
printf("\nMisha");
}
elseif(e<f)
{
printf("\nVasya");
}
else
{
printf(\nTIE");
}
getch();
}


#include<stdio.h>
int main()
{
	int c,vo,term,v1,a,l,ans=1,sum;
	scanf("%d%d%d%d%d",&c,&vo,&v1,&a,&l);
	sum=vo;
	term=vo+a-l;
	while(sum<c)
	{
		ans++;
		if(term < v1)
		{
			sum=term+sum;
			term=term+a;
		}
		else
			sum=sum+v1-l;
	}
	printf("%d\n",ans);
	return 0;
}


#include<stdio.h>
int main (void){
  int pages,init,max,acc,reread;
  scanf("%d %d %d %d %d",&pages,&init,&max,&acc,&reread)
  int days=0,read=0,speed;
  for(days=1;1==1;days++){
    speed=init+(days-1)*acc;
    if(speed<max){
      read=read+speed;
    }
    else{
      read=read+max;
    }
    if (read>=pages)
      break;
    read=read-reread;
  }
  printf("%d",days);
  return 0;
}


#include<stdio.h>
void main(){
    int c, v0, v1, a, l;
    scanf("%d%d%d%d%d", &c, &v0, &v1, &a, &l);
    int pages = v0;
    int days = 1;
    c = c - pages;
    while (c>0){
        days += 1;
        pages = pages + a;
        if (pages>v1){
            pages = v1;
        }
        c = c + l - (pages);
    }
    printf("%d", days);
}


#include <stdio.h>
#include <stdlib.h>
int abs(int a)
{
    return a < 0 ? -1 : a;
}
int main()
{
    int x1,y1,x2,y2,x,y;
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    int x0 = abs(x1-x2);
    int y0 = abs(y1-y2);
    scanf("%d %d",&x,&y);
    if(x0%x != 0 || y0%y != 0)
        printf("NO\n");
    else
    {
        if((x0/x)%2 == (y0/y)%2)
            printf("YES\n");
        else
            printf("NO\n");
    }

    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    int x1,x2,y1,y2,x,y,a,b;
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    scanf("%d %d",&x,&y);

    a=abs(x2-x1);
    b=abs(y2-y1);

    if(a%x!=0||b%y!=0)
    {
          printf("NO\n");
    }

    else if((a/x)%2==(b/y)%2)
    {
        printf("YES\n");
    }
    else{
        printf("NO\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>
#include <string.h>
#define LONG 10
#define DIG 8
#include "cifrado.h"

int main(){

    /* declaraciones de variables */
    char cifrado[LONG*DIG+1];
    char codigoCifrado[LONG][LONG+1];

     int i,j,k,h=0;

    char cadena[LONG + 1], contrasenia[LONG+1], resultado[LONG+1];

    //lectura de datos
    scanf("%s", &cifrado);
    for(i=0; i<LONG;i++){
        scanf("%s", &codigoCifrado[i]);

    }

        //lee el cifrado de a 10 caracteres
        for(i = 0; i < LONG*DIG; i += LONG)
        {
            //carga los primeros diez digitos en el auxiliar cadena
            for( j = i; j < i + LONG; j++)
            {
                cadena[h] = cifrado[j];
                    h++;
            }
            //incializa la variable h para la siguiente cadena
                h=0;

                cadena[LONG] = '\0';
                //printf("Cad%s\n", cadena);

            //compara cadena con nuestra matriz de cifrados
             for(k = 0; k < LONG; k++)
             {  //printf("Cod%s\n", codigoCifrado[k]);
                if(!strcmp(codigoCifrado[k],cadena)){
                       printf("%d", k);
                        break;
                }

            }
       }
            //K Representa el digito cifrado
            //resultado += contrasenia;

    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
char *extraer(char *string, int pos, int lh) ;
int main()
{
    char *s, digito[10],*puntero;
    gets(s);
    int x;
    for (size_t i = 0; i < sizeof(digito) / sizeof(digito[0]); ++i)
    {
       scanf("%c", &digito[i]);
    }
    for (size_t i = 0; i < 8; ++i)
    {
        puntero = extraer(s,i * 10, 10);
        for (size_t j = 0; j < 10; ++j)
        {
            if (x == digito[j])
            {
                printf("%d",&j);
                break;
            }
        }
    }
    system("pause");
    return 0;
}
char *extraer(char *string, int pos, int lh)
{
   char *puntero;
   int c;

   puntero =(char*) malloc(sizeof (lh+1));

   if (puntero == NULL)
   {
      printf("Memoria no disponible");
      exit(-1);
   }

   for (c = 0 ; c < pos -1 ; c++)
      string++;

   for (c = 0 ; c < lh ; c++)
   {
      *(puntero+c) = *string;
      string++;
   }

   *(puntero+c) = '\0';

   return puntero;
}


package yx_utils;
/*
 * Entero.java
 *
 * ALGORITMOS Y ESTRUCTURAS DE DATOS III
 * Prof. Juan Segovia Silvero
 *
 * Entero es un wrapper sobre "long" que implementa Cmp.
*/

public class Entero implements Cmp
{
   private long n;

   public Entero (int n)
   {
      this.n   = n;
   }

   public int comparar (Cmp c2)
   /*
    * Compara los objetos segun sus valores.
    */
   {
      Entero a2 = (Entero) c2;

      if ( this.n < a2.n )
         return -1;
      if ( this.n > a2.n )
         return 1;

      return 0;
   }

   public String toString()
   {
       return "" + this.n;
   }
}


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

struct Team {
    char name[25];
    int point;
    int score;
    int miss;
}team[4], tmp_team[4];

void swap(int *lhs, int *rhs) {
    int tmp = *lhs;
    *lhs = *rhs;
    *rhs = tmp;
}

void cpy_team() {
    int i;
    for (i = 0; i < 4; ++i) {
        tmp_team[i].point = team[i].point;
        tmp_team[i].score = team[i].score;
        tmp_team[i].miss = team[i].miss;
        strcpy(tmp_team[i].name, team[i].name);
    }
}

char hash_s[4][25];
int hash_idx = 0;
int hash(const char* str) {
    int i;
    for (i = 0; i < hash_idx; ++i) {
        if (!strcmp(str, hash_s[i])) {
            return i;
        }
    }
    strcpy(hash_s[hash_idx++], str);
    return hash_idx - 1;
}

int comp(const void *lhs, const void *rhs) {
    struct Team *sa = (struct Team *)lhs;
    struct Team *sb = (struct Team *)rhs;
    if (sa->point != sb->point) {
        return sa->point < sb->point;
    }
    if (sa->score - sa->miss != sb->score - sb->miss) {
        return sa->score - sa->miss < sb->score - sb->miss;
    }
    if (sa->score != sb->score) {
        return sa->score < sb->score;
    }
    return strcmp(sa->name, sb->name) > 0;
}

int main() {
    //freopen("in.txt", "r", stdin);
    int i, j, ia, ib, na, nb, b_id, opp_id, x, y, min = 10000, cnt[4];
    char sa[25], sb[25];

    memset(cnt, 0, sizeof(cnt));
    for (i = 0; i < 5; ++i) {
        scanf("%s %s %d:%d", sa, sb, &na, &nb);
        ia = hash(sa);
        ib = hash(sb);
        strcpy(team[ia].name, sa);
        strcpy(team[ib].name, sb);
        ++cnt[ia];
        ++cnt[ib];
        /*printf("%d %d %d %d\n", na, nb, ia, ib);*/
        if (nb > na) {
            swap(&na, &nb);
            swap(&ia, &ib);
        }
        /*printf("%d %d\n", na, nb);*/
        if (na > nb) {
            team[ia].point += 3;
        } else if (na == nb) {
            team[ia].point += 1;
            team[ib].point += 1;
        }
        team[ia].score += na;
        team[ia].miss += nb;
        team[ib].score += nb;
        team[ib].miss += na;
    }
    /*for (i = 0; i < 4; ++i) {*/
        /*printf("%d %d %d\n", team[i].point, team[i].score, team[i].miss);*/
    /*}*/
    /*return 0;*/
    for (i = 0; i < 4; ++i) {
        if (!strcmp(team[i].name, "BERLAND")) {
            b_id = i;
        } else if (cnt[i] != 3) {
            opp_id = i;
        }
    }

    cpy_team();
    qsort(tmp_team, 4, sizeof(struct Team), comp);
    /*for (i = 0; i < 4; ++i) {*/
        /*printf("%s\n", tmp_team[i].name);*/
    /*}*/
    /*printf("opp_id = %d, b_id = %d\n", opp_id, b_id);*/
    /*for (i = 0; i < hash_idx; ++i) {*/
        /*printf("%s\n", hash_s[i]);*/
    /*}*/
    for (i = 1; i < 100; ++i) {
        for (j = i - 1; j >= 0; --j) {
            cpy_team();
            tmp_team[b_id].point += 3;
            tmp_team[b_id].score += i;
            tmp_team[opp_id].miss += i;

            tmp_team[b_id].miss += j;
            tmp_team[opp_id].score += j;
            qsort(tmp_team, 4, sizeof(struct Team), comp);
            if (!strcmp(tmp_team[0].name, "BERLAND") || !strcmp(tmp_team[1].name, "BERLAND")) {
                if (i - j < min) {
                    min = i - j;
                    x = i;
                    y = j;
                }
            }
    }
    if (min != 10000) {
        printf("%d:%d\n", x, y);
    } else {
        puts("IMPOSSIBLE");
    }

    return 0;
}


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

struct Team {
    char name[25];
    int point;
    int score;
    int miss;
}team[4], tmp_team[4];

void swap(int *lhs, int *rhs) {
    int tmp = *lhs;
    *lhs = *rhs;
    *rhs = tmp;
}

void cpy_team() {
    int i;
    for (i = 0; i < 4; ++i) {
        tmp_team[i] = team[i];
    }
}

char hash_s[4][25];
int hash_idx = 0;
int hash(const char* str) {
    int i;
    for (i = 0; i < hash_idx; ++i) {
        if (!strcmp(str, hash_s[i])) {
            return i;
        }
    }
    strcpy(hash_s[hash_idx++], str);
    return hash_idx - 1;
}

int comp(const void *lhs, const void *rhs) {
    struct Team *sa = (struct Team *)lhs;
    struct Team *sb = (struct Team *)rhs;
    if (sa->point != sb->point) {
        return sa->point < sb->point;
    }
    if (sa->score - sa->miss != sb->score - sb->miss) {
        return sa->score - sa->miss < sb->score - sb->miss;
    }
    if (sa->score != sb->score) {
        return sa->score < sb->score;
    }
    return strcmp(sa->name, sb->name) > 0;
}

int main() {
    //freopen("in.txt", "r", stdin);
    int i, j, ia, ib, na, nb, b_id, opp_id, cnt[4];
    char sa[25], sb[25];

    memset(cnt, 0, sizeof(cnt));
    for (i = 0; i < 5; ++i) {
        scanf("%s %s %d:%d", sa, sb, &na, &nb);
        ia = hash(sa);
        ib = hash(sb);
        strcpy(team[ia].name, sa);
        strcpy(team[ib].name, sb);
        ++cnt[ia];
        ++cnt[ib];
        /*printf("%d %d %d %d\n", na, nb, ia, ib);*/
        if (nb > na) {
            swap(&na, &nb);
            swap(&ia, &ib);
        }
        /*printf("%d %d\n", na, nb);*/
        if (na > nb) {
            team[ia].point += 3;
        } else if (na == nb) {
            team[ia].point += 1;
            team[ib].point += 1;
        }
        team[ia].score += na;
        team[ia].miss += nb;
        team[ib].score += nb;
        team[ib].miss += na;
    }
    /*for (i = 0; i < 4; ++i) {*/
        /*printf("%d %d %d\n", team[i].point, team[i].score, team[i].miss);*/
    /*}*/
    /*return 0;*/
    for (i = 0; i < 4; ++i) {
        if (!strcmp(team[i].name, "BERLAND")) {
            b_id = i;
        } else if (cnt[i] != 3) {
            opp_id = i;
        }
    }

    cpy_team();
    qsort(tmp_team, 4, sizeof(struct Team), comp);
    /*for (i = 0; i < 4; ++i) {*/
        /*printf("%s\n", tmp_team[i].name);*/
    /*}*/
    /*printf("opp_id = %d, b_id = %d\n", opp_id, b_id);*/
    /*for (i = 0; i < hash_idx; ++i) {*/
        /*printf("%s\n", hash_s[i]);*/
    /*}*/
    for (i = 1; i < 100; ++i) {
        cpy_team();
        tmp_team[b_id].point += 3;
        tmp_team[b_id].score += i;
        tmp_team[opp_id].miss += i;
        /*for (j = 0; j < 4; ++j) {*/
            /*printf("%d %d %d\n", tmp_team[j].point, tmp_team[j].score, tmp_team[j].miss);*/
        /*}*/
        /*putchar('\n');*/
        qsort(tmp_team, 4, sizeof(struct Team), comp);
        if (!strcmp(tmp_team[0].name, "BERLAND") || !strcmp(tmp_team[1].name, "BERLAND")) {
            printf("%d:0\n", i);
            return 0;
        }
    }
    puts("IMPOSSIBLE");

    return 0;
}


/* practice with Dukkha */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char ss[4][32];

int get(char *s) {
	static int n;
	int i;

	for (i = 0; i < n; i++)
		if (strcmp(ss[i], s) == 0)
			return i;
	strcpy(ss[n], s);
	return n++;
}

int g1[4], g0[4], pp[4], dd[4];

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int gi, gj;

	if (pp[i] != pp[j])
		return pp[j] - pp[i];
	gi = g1[i] - g0[i];
	gj = g1[j] - g0[j];
	if (gi != gj)
		return gj - gi;
	if (g1[i] != g1[j])
		return g1[j] - g1[i];
	return strcmp(ss[i], ss[j]);
}

int main() {
	static char s[32], t[32], z[8];
	static int ii[4];
	int h, i, j, x, y, r;

	for (h = 0; h < 5; h++) {
		scanf("%s%s%s", s, t, z);
		i = get(s), j = get(t);
		x = z[0] - '0';
		y = z[2] - '0';
		g1[i] += x, g0[j] += x;
		g0[i] += y, g1[j] += y;
		if (x > y)
			pp[i] += 3;
		else if (x < y)
			pp[j] += 3;
		else {
			pp[i]++;
			pp[j]++;
		}
		dd[i]++;
		dd[j]++;
	}
	for (i = 0; i < 4; i++)
		ii[i] = i;
	i = 0;
	while (strcmp(ss[i], "BERLAND"))
		i++;
	j = 0;
	while (j == i || dd[j] != 2)
		j++;
	for (x = 1, y = 0; x < 30; x++) {
		g1[i] += x, g0[j] += x;
		g0[i] += y, g1[j] += y;
		if (x > y)
			pp[i] += 3;
		else if (x < y)
			pp[j] += 3;
		else {
			pp[i]++;
			pp[j]++;
		}
		qsort(ii, 4, sizeof *ii, compare);
		r = 0;
		while (ii[r] != i)
			r++;
		if (r < 2) {
			printf("%d:0\n", x);
			return 0;
		}
		g1[i] -= x, g0[j] -= x;
		g0[i] -= y, g1[j] -= y;
		if (x > y)
			pp[i] -= 3;
		else if (x < y)
			pp[j] -= 3;
		else {
			pp[i]--;
			pp[j]--;
		}
	}
	printf("IMPOSSIBLE\n");
	return 0;
}


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

struct Team {
    char name[15];
    int point;
    int score;
    int miss;
}team[4], tmp_team[4];

void swap(int *lhs, int *rhs) {
    int tmp = *lhs;
    *lhs = *rhs;
    *rhs = tmp;
}

void cpy_team() {
    int i;
    for (i = 0; i < 4; ++i) {
        tmp_team[i] = team[i];
    }
}

char hash_s[4][25];
int hash_idx = 0;
int hash(const char* str) {
    int i;
    for (i = 0; i < hash_idx; ++i) {
        if (!strcmp(str, hash_s[i])) {
            return i;
        }
    }
    strcpy(hash_s[hash_idx++], str);
    return hash_idx - 1;
}

int comp(const void *lhs, const void *rhs) {
    struct Team *sa = (struct Team *)lhs;
    struct Team *sb = (struct Team *)rhs;
    if (sa->point != sb->point) {
        return sa->point < sb->point;
    }
    if (sa->score - sa->miss != sb->score - sb->miss) {
        return sa->score - sa->miss < sb->score - sb->miss;
    }
    if (sa->score != sb->score) {
        return sa->score < sb->score;
    }
    return strcmp(sa->name, sb->name) > 0;
}

int main() {
    //freopen("in.txt", "r", stdin);
    int i, j, ia, ib, na, nb, b_id, opp_id, cnt[4];
    char sa[25], sb[25];

    memset(cnt, 0, sizeof(cnt));
    for (i = 0; i < 5; ++i) {
        scanf("%s %s %d:%d", sa, sb, &na, &nb);
        ia = hash(sa);
        ib = hash(sb);
        strcpy(team[ia].name, sa);
        strcpy(team[ib].name, sb);
        ++cnt[ia];
        ++cnt[ib];
        /*printf("%d %d %d %d\n", na, nb, ia, ib);*/
        if (nb > na) {
            swap(&na, &nb);
            swap(&ia, &ib);
        }
        /*printf("%d %d\n", na, nb);*/
        if (na > nb) {
            team[ia].point += 3;
        } else if (na == nb) {
            team[ia].point += 1;
            team[ib].point += 1;
        }
        team[ia].score += na;
        team[ia].miss += nb;
        team[ib].score += nb;
        team[ib].miss += na;
    }
    /*for (i = 0; i < 4; ++i) {*/
        /*printf("%d %d %d\n", team[i].point, team[i].score, team[i].miss);*/
    /*}*/
    /*return 0;*/

    cpy_team();
    qsort(tmp_team, 4, sizeof(struct Team), comp);
    /*for (i = 0; i < 4; ++i) {*/
        /*printf("%c\n", tmp_team[i].name);*/
    /*}*/
    for (i = 0; i < 4; ++i) {
        if (!strcmp(tmp_team[i].name, "BERLAND")) {
            b_id = i;
        } else if (cnt[i] != 3) {
            opp_id = i;
        }
    }
    /*printf("opp_id = %d, b_id = %d\n", opp_id, b_id);*/
    /*for (i = 0; i < hash_idx; ++i) {*/
        /*printf("%s\n", hash_s[i]);*/
    /*}*/
    for (i = 1; i < 100; ++i) {
        cpy_team();
        tmp_team[b_id].point += 3;
        tmp_team[b_id].score += i;
        tmp_team[opp_id].miss += i;
        /*for (j = 0; j < 4; ++j) {*/
            /*printf("%d %d %d\n", tmp_team[j].point, tmp_team[j].score, tmp_team[j].miss);*/
        /*}*/
        /*putchar('\n');*/
        qsort(tmp_team, 4, sizeof(struct Team), comp);
        if (!strcmp(tmp_team[0].name, "BERLAND") || !strcmp(tmp_team[1].name, "BERLAND")) {
            printf("%d:0\n", i);
            return 0;
        }
    }
    puts("IMPOSSIBLE");

    return 0;
}


/* practice with Dukkha */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char ss[4][32];

int get(char *s) {
	static int n;
	int i;

	for (i = 0; i < n; i++)
		if (strcmp(ss[i], s) == 0)
			return i;
	strcpy(ss[n], s);
	return n++;
}

int g1[4], g0[4], pp[4], dd[4];

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int gi, gj;

	if (pp[i] != pp[j])
		return pp[j] - pp[i];
	gi = g1[i] - g0[i];
	gj = g1[j] - g0[j];
	if (gi != gj)
		return gj - gi;
	if (g1[i] != g1[j])
		return g1[j] - g1[i];
	return strcmp(ss[i], ss[j]);
}

int main() {
	static char s[32], t[32], z[8];
	static int ii[4];
	int h, i, j, x, y, r;

	for (h = 0; h < 5; h++) {
		scanf("%s%s%s", s, t, z);
		i = get(s), j = get(t);
		x = z[0] - '0';
		y = z[2] - '0';
		g1[i] += x, g0[j] += x;
		g0[i] += y, g1[j] += y;
		if (x > y)
			pp[i] += 3;
		else if (x < y)
			pp[j] += 3;
		else {
			pp[i]++;
			pp[j]++;
		}
		dd[i]++;
		dd[j]++;
	}
	for (i = 0; i < 4; i++)
		ii[i] = i;
	i = 0;
	while (strcmp(ss[i], "BERLAND"))
		i++;
	j = 0;
	while (j == i || dd[j] != 2)
		j++;
	for (x = 0, y = 0; x < 30; x++) {
		g1[i] += x, g0[j] += x;
		g0[i] += y, g1[j] += y;
		if (x > y)
			pp[i] += 3;
		else if (x < y)
			pp[j] += 3;
		else {
			pp[i]++;
			pp[j]++;
		}
		qsort(ii, 4, sizeof *ii, compare);
		r = 0;
		while (ii[r] != i)
			r++;
		if (r < 2) {
			printf("%d:0\n", x);
			return 0;
		}
		g1[i] -= x, g0[j] -= x;
		g0[i] -= y, g1[j] -= y;
		if (x > y)
			pp[i] -= 3;
		else if (x < y)
			pp[j] -= 3;
		else {
			pp[i]--;
			pp[j]--;
		}
	}
	printf("IMPOSSIBLE\n");
	return 0;
}


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

int main()
{
    char str[101];
    scanf("%s", str);

    if(strlen(str) >= 5)
        count++;

    for(i=0; i<strlen(str); i++){
        if(str[i] >= 'A' && str[i] <= 'Z'){
            count++;
            break;
        }
    }

    for(i=0; i<strlen(str); i++){
        if(str[i] >= 'a' && str[i] <= 'z'){
            count++;
            break;
        }
    }

    for(i=0; i<strlen(str); i++){
        if(str[i] >= '1' && str[i] <= '9'){
            count++;
            break;
        }
    }

    if(count == 4)
        printf("Correct");
    else
        printf("Too weak");

    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int Up=0,Low=0,Num=0,i,a=0;
    char str[1000];
    gets(str);
    a=strlen(str);
    for(i=0;i<a;i++){
        if(str[i]>47&&str[i]<58)
            Num++;
        if(str[i]>64&&str[i]<91)
            Up++;
        if(str[i]>96&&str[i]<123)
            Low++;
    }
    if(Num>0 && Up>0 && Low>0 && a>=5)
        printf("Correct\n");
    else
        printf("Too weak\n");a
    return 0;
}


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

typedef struct _P {
    unsigned x;
    unsigned y;
} Point;

int comparePoint(const void *_a, const void *_b) {
    Point *a = (Point*)_a;
    Point *b = (Point*)_b;
    return a->x - b->x ? a->x - b->x : a->y - b->y;
}

bool parallelLine(Point pAA, Point pAB, Point pAC,
        Point pBA, Point pBB, Point pBC) {
    if(pAA.x == pAB.x && pAA.x == pAC.x)
        if(pBA.x == pBB.x && pBA.x == pBC.x)
            if(pAA.y == pBA.y && pAB.y == pBB.y && pAC.y == pBC.y)
                if(pAA.y != pAB.y && pAA.y != pAC.y)
                   return true;
    if(pAA.y == pAB.y && pAA.y == pAC.y)
        if(pBA.y == pBB.y && pBA.y == pBC.y)
            if(pAA.x == pBA.x && pAB.x == pBB.x && pAC.x == pBC.x)
                if(pAA.x != pAB.x && pAA.x != pAC.x)
                     return true;
    return false;
}

const char* answers[2] = {"respectable\n", "ugly\n"};

int main() {
    short i;

    Point ps[8];
    for(i = 0; i < 8; i++)
        scanf("%u%u", &ps[i].x, &ps[i].y);

    qsort(ps, 8u, sizeof(Point), comparePoint);

    if(parallelLine(ps[0], ps[1], ps[2], ps[5], ps[6], ps[7]) &&
            parallelLine(ps[0], ps[3], ps[5], ps[2], ps[4], ps[7]))
        printf(answers[0]);
    else
        printf(answers[1]);
}


#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;

int compare(const void *a,const void *b)
{
    return (*(int *)a-*(int *)b);
}
int main()
{
    int x[8],y[8],i,j;
    for(i=0;i<8;i++)
    {
        scanf("%d %d",&x[i],&y[i]);
    }
    for(i=0;i<8;i++)
    {
        for(j=i+1;j<8;j++)
        {
			if(x[i]==x[j]&&y[i]==y[j])
            {
                printf("ugly");
                return 0;
            }
            else
            {
				continue;
			}
		}
    }
    qsort(x,8,sizeof(int),compare);
    qsort(y,8,sizeof(int),compare);

    if(x[1]==x[0]&&x[2]==x[1]&&x[4]==x[3]&&x[7]==x[6]&&x[5]==x[7]&&x[3]>x[0]&&x[6]>x[3]&&y[3]>y[2]&&y[5]>y[4]&&y[4]==y[3]&&y[0]==y[1]&&y[1]==y[2]&&y[6]==y[7]&&y[5]==y[6]&&y[3]!=y[1])
    {
		printf("respectable\n");
	}
	else
	{
        printf("ugly\n");
	}
	return 0;
}


#include<stdio.h>
#define min(a,b) (a<b?a:b)

int N,val[50005],day=1,mx=1e9+1,id;

int main()
{
	scanf("%d",&N);
	if(N%7==0)
	{
		for(int i=1,u;i<=N;i++)
		{
			scanf("%d",&u);
			if(i%7&&u<mx)mx=u,id=i;
		}
		return printf("%d",id),0;
	}
	for(int i=1,u;i<=N;i++)scanf("%d",val+i),mx=min(mx,val[i]/6);
	for(int i=1;i<=N;i++)val[i]-=mx*6;
	while(1)
	{
		for(int i=1;i<=N;i++,day++)
			if(day==7)day=0;
			else if(!--val[i])return printf("%d",i),0;
	}
}


#include <stdio.h>

int a[50001];
int main(){
	int n, i, j, ind_min=0;
	scanf ("%d", &n);
	for (i=0;i<n;i++) scanf ("%d", &a[i]);

	if (n%7==0){
		for(i=0;i<n;i++){
			if (i%7==0) continue;
			if (a[i]<a[ind_min]) ind_min=i;
		}
	}
	else{
		for (i=0;i<n;i++) a[i]=a[i]%6+6;

		j=1;
		while(1){
			for (i=0;i<n;i++,j++){
				if (j%7==0) continue;
			       	a[i]--;
				if (a[i]==0) goto end;
			}
		}
end:
		ind_min=i;
	}

	printf ("%d\n", ind_min+1);
return 0;}


#include <stdio.h>

int a[50001];
int main(){
	int n, i, j, ind_min=0;
	scanf ("%d", &n);
	for (i=0;i<n;i++) scanf ("%d", &a[i]);

	if (n%7==0){
		for(i=0;i<n;i++){
			if (i%7==6) continue;
			if (a[i]<a[ind_min]) ind_min=i;
		}
	}
	else{
		for(i=0;i<n;i++) {
			if (a[i]<a[ind_min]) ind_min=i;
		}
		for (i=0;i<n;i++) a[i]=a[i]%7+7;
		for (i=0;i<n;i++){
			if (a[i]!=a[ind_min]) a[i]+=1000;
		}

		j=1;
		while(1){
			for (i=0;i<n;i++,j++){
				if (j%7==0) continue;
				a[i]--;
				if (a[i]==0) goto end;
			}
		}
	end:
		ind_min=i;
	}

	printf ("%d\n", ind_min+1);
return 0;}


#include<stdio.h>
#define min(a,b) (a<b?a:b)

int N,val[50005],day=1,mx=1e9+1,id;

int main()
{
	scanf("%d",&N);
	if(N%7==0)
	{
		for(int i=1,u;i<=N;i++)
		{
			scanf("%d",&u);
			if(i%7&&u<mx)u=mx,id=i;
		}
		return printf("%d",id),0;
	}
	for(int i=1,u;i<=N;i++)scanf("%d",val+i),mx=min(mx,val[i]/6);
	for(int i=1;i<=N;i++)val[i]-=mx*6;
	while(1)
	{
		for(int i=1;i<=N;i++,day++)
			if(day==7)day=0;
			else if(!--val[i])return printf("%d",i),0;
	}
}


#include <stdio.h>

int a[50001];
int main(){
	int n, i, j, ind_min=0;
	scanf ("%d", &n);
	for (i=0;i<n;i++) scanf ("%d", &a[i]);

	if (n%7==0){
		for(i=0;i<n;i++){
			if (i%7==6) continue;
			if (a[i]<a[ind_min]) ind_min=i;
		}
	}
	else{
		for (i=0;i<n;i++) a[i]=a[i]%6+6;

		j=1;
		while(1){
			for (i=0;i<n;i++,j++){
				if (j%7==0) continue;
			       	a[i]--;
				if (a[i]==0) goto end;
			}
		}
end:
		ind_min=i;
	}

	printf ("%d\n", ind_min+1);
}


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

    int n,zcount=0,onecount=0,i;
    scanf("%d",&n);
    char str[100];
    scanf("%s",str);
    for(i=0;i<n;i++){
        if(str[i]=='1'&&i<(strlen(str)-1)){onecount++;zcount=0;}
        else if(str[i]=='1'&&i==(strlen(str)-1)){onecount++;printf("%d",onecount);}
        else if(onecount){printf("%d",onecount);onecount=0;}
        if(str[i]=='0')zcount++;
        if(zcount==2){printf("0");zcount=0;}
        if(str(strlen(str)-1)=='0')printf("0");
    }

    return 0;
}


	 int n,i,digit = 0;
	 char s[90];
	   unsigned long num = 0;
	   scanf("%u",&n);
	   scanf("%s",s);
	   i = 0;
	   while(s[i] != '\0'){

	       if(s[i]== '1'){
	           digit++;
	       }else{
	    	   num = (num*10)+digit;
	    	   digit = 0;
	       }
	     i++;
	   }
	   num = (num*10)+digit;

	   printf("%lu",num);


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

char x[89];

int main()
{
    int i,n,c=0;
    scanf("%d %s",&n,x);
    for (i=0; i<=n; i++)
    {
        if (str[i] == '1') c++;
        else
        {
            printf("%d",c);
            c = 0;
        }
    }
    return 0;
}


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

int main()
{
    int strLen;
    scanf("%d",&strLen);
    char str [1000];
    scanf("%s",str);
    //aprintf("%s\n",str);
    int i, cnt=0;
    for (i=0; i<strLen; i++) {
        if (str[i] == '1') {
            cnt++
        } else {
            printf("%d",cnt);
            cnt=0;
        }
    }
    printf("%d",cnt);
    return 0;
}


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

char a[1000000005];

int main()
{
    long long int n, x, k, i, j, r, ans=0;
    scanf("%I64d\n", &n);
    gets(a);
    //puts(a);
    for(i=0; i<n; i++)
    {
        if(a[i]==49){ans++;}
        else{ans*=10;}
        //printf("%I64d\n", ans);
    }
    printf("%I64d", ans);
    return 0;
}


#include<stdio.h>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    char s[110];
    scanf("%s",&s);
    int ans1=0,ans0=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')
        {
            ans0++;
        }
        else
        {
            ans1++;
        }
    }
    if(ans1)
    {
        printf("1");
    }
    for(int i=0;i<ans0;i++)
    {
        printf("0");
    }
    printf("\n");
    return 0;
}


#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
	int t,n,m,i,num,j,sum;
	char a[150];
	memset(a, 0 ,sizeof(a));
	scanf("%d", &t);
	scanf("%s", a);
	int k = strlen(a);
	sum = 0;
	for(i=0; i<k; i++)
	{
		if(a[i] == '0')
		{
			sum ++;
		}
	}
	printf("1");
	for(i=0; i<sum; i++)
	{
		printf("0");
	}
	printf("\n");
	return 0;
}


#include <stdio.h>

main(){
    int i, n, m, hg= 0, sum= 0;
    scanf("%i %i", &n, &m);
    int a[n];
    for(i=0; i<n; ++i){
        scanf("%i", &a[i]);
        if(a[i]>hg) hg = a[i];
        sum += a[i];
    }
    printf("%i %i\n", ((sum+m)%n) ? ((sum+m)/n)+1 : (sum+m)/n, hg+m);


#include<stdio.h>

int main(){
    int benches,initial,late;
    int people[101]={0};

    scanf("%d", &benches);
    scanf("%d", &initial);
    scanf("%d", &late);

    int late_cpy=late;

    int people_cpy[101]={0};

    for(int i=0;i<=benches;++i)
    {
        scanf("%d", &people[i]);
        people_cpy[i]=people[i];
    }

    int max=0;
    for(int i=0;i<=benches;++i)
    {
        if(people[i]>=max){
            max=people[i];
        }
    }
    for(int i=0;i<=benches;++i)
    {
        if(late_cpy<=0){
            break;
        }
        while(benches[i]!=max){
            if(late_cpy<=0){
                break;
            }
            ++benches[i];
            --late_cpy;
        }
    }
    int min=10000;
    for(int i=0;i<=benches;++i)
    {
        if(benches[i]<=min){
            min=benches[i];
        }
    }

    for(int i=0;i<=benches;++i)
    {
        if(benches[i]==max){
            max = benches[i]+late;
            break;
        }
    }
    printf("%d %d", min,max );

}


#include <cstdio>

class CycledDynamicArray {
public:
    CycledDynamicArray(unsigned int initCapacity);
    ~CycledDynamicArray();

    void PushBack(int element);
    void PopBack();
    int Back() const;
    bool IsEmpty() const;

private:
    unsigned int capacity;
    unsigned int siz;
    int start;
    int* data;

    unsigned int CalcModPos(unsigned int pos);
    void Rotate(unsigned int newCapasity);
    void Extend();
    void Shrink();
};
CycledDynamicArray::~CycledDynamicArray(){

}

int main(){
    CycledDynamicArray arr(8);
    arr.PushBack(5);
    return 0;
}