#include <stdio.h>

void search_min(int min[], int length, int sum);
void search_max(int max[], int length, int sum);

int main(void)
{
  int length, sum, k, i;
  scanf("%d %d/n", &length, &sum);
  int max[length], min[length];

  if (length* 9 < sum && (length > 1 && sum == 0)) {
    printf("-1 -1");
    return 0;
  }

  search_min(min, length, sum);
  printf(" ");
  search_max(max, length, sum);

  return 0;
}

void search_min(int min[], int length, int sum)
{
  int i, k = length;
  for (i = 0; length > 0; length--) {
    if (length == 1) min[i] = sum;
    if (length == 2) {
      if (sum >= 10) {
        min[i++] = 9, sum -= 9, length--;
        min[i] = sum;
      }
      else {
        min[i++] = sum - 1, sum = 1, length--;
        min[i] = sum;
      }
    }
    if (length > 2) {
      if (sum >= 10) min[i++] = 9, sum -= 9;
      else if (sum > 1) {
        min[i++] = sum - 1, sum = 1, length--;
        min[i] = sum;
      }
      else min[i] = sum;
    }
  }
  for ( ; i >= 0; i--) printf("%d", min[i]);
}

void search_max(int max[], int length, int sum)
{
  int i;
  for (i = 0; length > 0; length--) {
    if (length == 1) max[i] = sum;
    if (length == 2) {
      if (sum >= 10) {
        max[i++] = 9, sum -= 9, length--;
        max[i] = sum;
      }
      else {
        max[i++] = sum, sum = 0, length--;
        max[i] = sum;
      }
    }
    if (length > 2) {
      if (sum >= 10) max[i++] = 9, sum -= 9;
      else if (sum > 0) max[i++] = sum, sum = 0;
      else max[i++] = sum;
    }
  }
  for (i = 0; i <= k - 1; i++) printf("%d", max[i]);
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int so(int n , int s1)
{
	if(s1<=9)
	{
		if(n!=1)
		{
			if(s1-1<0)
			{
				return 0;
			}
			return s1-1;
		}
		else
		{
			if(s1>1)
				return s1;
			else
				return 1;
		}
	}
	else
	{
		return 9;
	}
}
int main()
{
	int m , s , n, s1;
//	FILE *f;
//	f = fopen("1400.inp","rt");
//	fscanf(f,"%d",&m);
//	fscanf(f,"%d",&s);
	scanf("%d",&m);
	scanf("%d",&s);
	int a[m];
	n=m;
	s1=s;
	if(s==0 && m==1)
	{
		printf("%d\t%d",0,0);
	}
	else if (s < 1 || (m*9)< s  )
	{
		printf("%d\t%d",-1,-1);
	}
	else
	{
		for(int i =m-1 ; i>=0; i--)
		{
			a[i]=so(n,s1);
			n -=1;
			s1-=a[i];
		}
		if(a[m-1]==9 || a[m-1]==0)
		{
			if (s<2)
			{
				for(int kk =0 ; kk<m;kk++)
				{
					printf("%d",a[kk]);
				}
				printf("\t");
				for(int kk1= 0; kk1<m;kk1++)
				{
					printf("%d",a[kk1]);
				}

			}
			else
			{
				int ttt=0;
				for(int kk = 0 ; kk<m;kk++)
				{
					printf("%d",a[kk]);
					ttt+=a[kk];
				}
				printf("\t");
				{
					for(int kk1=0;kk1<m;kk1++)
					{
						if(ttt>=9)
						{
							ttt -=9;
							printf("%d",9);
						}
						else if(s>0)
						{
							printf("%d",ttt)
						}
						else
						{
							printf("%d",0);
						}
					}
				}

			}
		}
		else
		{
			int ttt = 0;
			for(int kk =0 ; kk<m;kk++)
			{
				printf("%d",a[kk]);
				ttt += a[kk];
			}
			printf("\t");
			for(int kk1=0;kk1<m;kk1++)
			{
				if(kk1==0)
				{
					printf("%d",ttt);
				}
				else
				{
					printf("%d",0);
				}
			}

		}

	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int so(int n , int s1)
{
	if(s1<=9)
	{
		if(n!=1)
		{
			if(s1-1<0)
			{
				return 0;
			}
			return s1-1;
		}
		else
		{
			if(s1>1)
				return s1;
			else
				return 1;
		}
	}
	else
	{
		return 9;
	}
}
int main()
{
	int m , s , sodu , songuyen , n , s1 ;
	scanf("%d",&m);
	scanf("%d",&s);
	int a[m];
	int b[m];
	n=m;
	s1=s;
	for(int i =m-1 ; i>=0; i--)
	{
		a[i]=so(n,s1);
		b[i]=a[i];
		n -=1;
		s1-=a[i];
	}
	for(int j =0 ; j<m; j++)
	{
		itoa(a[j],t , 10);
		min[j] = t[0];
	}
	for(int j1=0 ; j1<m-1;j1++)
	{
		for(int j2=j1+1 ; j2<m ; j2++)
		{
			if(b[j1]<b[j2])
			{
				int temp;
				temp = b[j1];
				b[j1] = b[j2];
				b[j2] = temp;

			}
		}
	}
	for(int kk =0 ; kk<m;kk++)
	{
		printf("%d\t",a[kk]);
	}
	printf("\n");
	if (s < 1)
	{
		printf("%d\t%d",-1,-1);
	}
	else if (s<2)
	{
		for(int kk =0 ; kk<m;kk++)
		{
			printf("%d",a[kk]);
		}
		printf("\t");
		for(int kk1= 0; kk1<m;kk1++)
		{
			printf("%d",a[kk1]);
		}

	}
	else
	{
		for(int kk = 0 ; kk<m;kk++)
		{
			printf("%d",a[kk]);
		}
		printf("\t");
		for(int kk1= 0; kk1<m;kk1++)
		{
			printf("%d",b[kk1]);
		}
	}

	return 0;
}


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

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int max= 0,clo=m;

	for(int i=0;i<n;i++){
		if(clo>=9){
			max+= 9*pow(10,n-i-1);
      clo-=9;
    }
    else{
      max+= clo*pow(10,n-i-1);
      clo-=clo;
      break;
    }
	}
  if(clo!=0 || m==0){
    printf("-1 -1");
    return 0;
  }
  int min=max,r=0;
  while (min != 0)
  {
    r = r * 10;
    r = r + min%10;
    min = min/10;
  }
  if(r==1){r?=10;}
	printf("%d %d",r,max);
}


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

{
    int i,l1,l2,c=0;
    char s1[120],s2[120];
    scanf("%s",s1);
    scanf("%s",s2);
    l1=strlen(s1);
    l2=strlen(s2);
    if(l1!=l2)
        printf("NO");
        break;
    else {
        for(i=0;i<l1;i++){
            if(s1[i]==s2[l1-(i+1)])
            c++;
            }
        }
    if(c==l1)
        printf("YES");
    else printf("NO");
    return 0;
}


#include <stdio.h>

int main() {
    #include <stdio.h>
#include<string.h>
int main() {
    int i,j,ctr=0,len1,len2;
    char s[1001].t[1001];
    scanf("%s",&s);
    scanf("%s",&t);
    len1=strlen(s);
    len2=strlen(t);
   for(i=len1-1,j=0;i>=0&&j<len2;j++,i--)

    {
        if(s[i]==t[j])
        {
            ctr++;
        }
    }
    if(ctr==len1)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}
    return 0;
}


#include<stdio.h>
#include<string.h>
int main() {
    char s1[100],s2[100];
    scanf("%s",s1);
    scanf("%s",s2);
    int c=0,l1=strlen(s),l2=strlen(t);
    for(i=0,j=12-1;i<l1;i++,j--){
        if(s[i] == t[j]){
            c++;
        }
    }
    if(c==l1){
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    char a[10000],b[10000];
    scanf("%s%s",a,b);
    if(strrev(a)==b)
    printf("YES");
    else
    printf("NO");
    printf(strrev(a))
}


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


#include <stdio.h>
#include <string.h>
int main()
{
	int r,c;
	cin>>r>>c;
	char a[r][c];
	char b[r],d[c],f[c];
	for(int i=0;i<r;i++)
	{
		b[i]=1;
		scanf("%s",f);
		for(int j=0;j<c;j++)
		{
			a[i][j]=f[j];
			d[j]=1;
		}
	}
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			if(a[i][j]=='S')
			{
				 b[i]=0;
			}
		}
	}
	for(int j=0;j<c;j++)
	{
		for(int i=0;i<r;i++)
		{
			if(a[i][j]=='S')
			{
				d[j]=0;
			}
		}
	}
	int cntr=0,cntc=0;
	for(int i=0;i<r;i++)
	{
		if(b[i]==1)
		{
			cntr++;
		}
	}
	for(int i=0;i<c;i++)
	{
		if(d[i]==1)
		{
			cntc++;
		}
	}
	printf("%d",cntr*c+cntc*r-cntr*cntc);
}


#include<stdio.h>
#include<math.h>
#include<string.h>
char s[10][10];
int map[10][10];
int main()
{
    int n,m;
    int flag,count;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
         count=0;
        memset(map,0,sizeof(0));
        for(int i=0;i<n;i++)
        scanf("%s",s[i]);
        for(int j=0;j<n;j++)
        {
            flag=0;
            for(int i=0;i<m;i++)
            {
                if(s[j][i]=='S')
                flag=1;
            }
            if(flag!=1)
            {
                for(int i=0;i<m;i++)
                map[j][i]=1;
                count+=m;
            }
        }
    for(int i=0;i<m;i++)
    {
        flag=0;
        for(int j=0;j<n;j++)
        {
            if(s[j][i]=='S')
            flag=1;
        }
        if(flag!=1)
        {
            for(int j=0;j<n;j++)
            {
                if(map[j][i]==0)
                {
                    count++;
                    map[i][j]=1;
                }
            }
        }

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


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


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

	scanf("%d",&n);
	for(i=n-1;i>0;i--)
	{
		if((n%i)!=0)
		{
			printf("%d",(n-i));
			return 0;
		}
	}
	printf("%d",n);
	return 0;
}


#include <stdio.h>

int main(void) {
	int n;
	scanf("%d",&n);
    n=n-(n-1);
    printf(%d",&n);
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}


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

int main()
{
    char n[100];

    scanf("%s",n);
   if(strlen(n)%2=1)
   {
       printf("1");
   }else{
       printf("2");
   }

    return 0;
}


#include <stdio.h>

int main()
{
    long long n,i;
    scanf("%I64d",&n);
    i=1;
    while(n-i>0)
    {
        n-=i;
        i++;
    }
    printf("%I64d",n)
    return 0;
}


#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <utility>
using namespace std;

#define ll long long int
#define ull unsigned long long int
#define inf (INT_MAX/10)
#define linf (LLONG_MAX/10LL)
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define fl(c,i,n) for(i=c;i<n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define mem(a) memset(a,0,sizeof(a))
#define memn(a) memset(a,-1,sizeof(a))
#define pb push_back
#define pp pop_back()
#define aov(a) a.begin(),a.end()
#define mpr make_pair
#define PI (2.0*acos(0.0)) //#define PI acos(-1.0)
#define xx first
#define yy second
#define mxv(a) *max_element(aov(a))
#define mnv(a) *min_element(aov(a))
#define LB(a,x) (lower_bound(aov(a),x)-a.begin())
#define UB(a,x) (upper_bound(aov(a),x)-a.begin())
#define to_c_string(a) a.c_str()
#define strtoint(c) atoi(&c[0])
#define pii pair< int , int >
#define pll pair< ll , ll >
#define pcs(a) printf("Case %d: ", a)
#define nl puts("")
#define endl '\n'
#define dbg(x) cout<<#x<<" : "<<x<<endl

template <class T> inline T bigmod(T p,T e,T M){ll ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){ll ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
int toLlint(string s){long long int sm;stringstream ss(s);ss>>sm;return sm;}

///int mnth[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};  //Not Leap Year
///int dx[]={1,0,-1,0};int dy[]={0,1,0,-1};//4 direction
///int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
///int kdx[]={2,1,-1,-2,-2,-1,1,2};int kdy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
///int dx[]={-1,+1,0,1,0,-1}; // Hexagonal Direction   **
///int dy[]={-1,+1,1,0,-1,0}; //                       *#*
///                                                     **
const double eps=1e-9;

#define M 1000005
#define MD 1000000007LL
#define MX 100005

int ts,kk=1;

#define intx(i,j,k,l) ((a[i]*b[j]-b[i]*a[j])*(a[k]-a[l])-(a[i]-a[j])*(a[k]*b[l]-b[k]*a[l]))/((a[i]-a[j])*(b[k]-b[l])-(b[i]-b[j])*(a[k]-a[l]))
#define inty(i,j,k,l) ((a[i]*b[j]-b[i]*a[j])*(b[k]-b[l])-(b[i]-b[j])*(a[k]*b[l]-b[k]*a[l]))/((a[i]-a[j])*(b[k]-b[l])-(b[i]-b[j])*(a[k]-a[l]))
#define dst(u,v,x,y) sqrt((x*1.0-u*1.0)*(x*1.0-u*1.0)+(y*1.0-v*1.0)*(y*1.0-v*1.0))
#define area(i,j,k) ((ll)x[i]*y[j]+(ll)x[j]*y[k]+(ll)x[k]*y[i]-(ll)y[i]*x[j]-(ll)y[j]*x[k]-(ll)y[k]*x[i])

ll n,x;

int main()
{
    int t,i,j,k,l;

    cin>>n;

    for(x=1;x<n;x++)
    {
        n-=x;
    }
    cout<<n<<endl;
//    main();

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int i;
    long long n;
    i=1;
    cin>>n;
    while(n-i>0)
    {
        n-=i;
        i++;
    }
    cout<<n;
    return 0;
}


#include<stdio.h>
#define MAX 100000000000
int main(){
	int n;
	int i;
	scanf("%d",&n);
	int g=1;
	int f=0;
	int arr[MAX]={0};
	while(g!=1000){
		for(i=1;i<=g;i++)
		{
			arr[f]=i;
			f++;
		}
		g++;
	}
	printf("%d",arr[n-1]);

}


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

void main (){
    long long n,i=1;
    scanf("%lld",&n);
    while ((i*(i+1))/2 < n){
        i++;

    }
    i--;
    printf ("%lld", n- ((i*(i+1))/2)  )

}


#include <stdio.h>

typedef long long ll;

int main()
{
    ll ax, ay, bx, by, cx, cy;

    scanf("%I64d %I64d %I64d %I64d %I64d %I64d",&ax,&ay,&bx,&by,&cx,&cy);

    if( ay==bx && by==cx && cy==ax) printf("Yes");
    else
        printf("No");

    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define tor 0.00000001

//�������ָ���ģ����Ҫ��ϸ���һ����û��©�����������������Χ(���Ρ������Ρ�ʵ�͡�fabs��abs������)������(int64=at least one int64* others)��û�г������롢�����Χ��û�г���

int main()
{
    long ax,ay,bx,by,cx,cy;
    double k1,k2,dx,dy;//dx,dy:double!!!
    bool vis1,vis2;
    scanf("%ld%ld%ld%ld%ld%ld",&ax,&ay,&bx,&by,&cx,&cy);
    if (ax==cx && ay==cy)
    {
        printf("Yes\n");
        return 0;
    }
    if (ax+cx==bx*2 && ay+cy==by*2)
    {
        printf("No\n");
        return 0;
    }
    vis1=true;
    vis2=true;
    if (cx-ax!=0)
        k1=1.0*(cy-ay)/(cx-ax);
    else
        vis1=false;
    dx=1.0*(ax+cx)/2;
    dy=1.0*(ay+cy)/2;
    if (fabs(bx-dx)>tor)
        k2=1.0*(by-dy)/(bx-dx);
    else
        vis2=false;

    if ((vis1==false && vis2==true && fabs(k2-0)<tor) || (vis1==true && fabs(k1-0)<tor && vis2==false) || (vis1==true && vis2==true && fabs(k1*k2+1)<tor))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}
/*
0 0 1 1 2 2
0 1 1 1000000000 2 1
0 1 1 -1000000000 2 1
0 1 1 5 2 1
2 1 1 5 0 1
2 1 1 -3 0 1

0 0 0 0 0 0

0 0 1 1 0 0
*/


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

int main(void)
{
	long long int ax,ay,bx,by,cx,cy,d1,d2,d3;
	double a,b,c;
	scanf("%I64d %I64d %I64d %I64d %I64d %I64d",&ax,&ay,&bx,&by,&cx,&cy);
	d1=(ax-bx)*(ax-bx)+(ay-by)*(ay-by);
	a=sqrt(d1);
	d2=(cx-bx)*(cx-bx)+(cy-by)*(cy-by);
	b=sqrt(d2);
	d3=(cx-ax)*(cx-ax)+(cy-ay)*(cy-ay);
	c=sqrt(d3);
	if(a==b) {
		if((ax==bx && ax==cx) || (ay==by && ay==cy))
			printf("No");
/*		if(d1+d2==d3)
			printf("Yes");
		else if(a==c)
			printf("Yes");*/
		else
			printf("Yes");
	}
	else
		printf("No");

	return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>0){cout<<"The number is postisve"<<endl;}
    else if(n<0)cout<<"the number is negative";
}


#include<stdio.h>
int main()
{
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    if(z)
    {
        if(x+z==y||x=y+z)
            printf("?");
        else
            if(x>y)
            printf("+");
        else if(x<y)
            printf("-");
        else
            printf("0");
    }
    else
    {
        if(x>y)
            printf("+");
        else if(x<y)
            printf("-");
        else
            printf("0");
    }
}


#include<stdio.h>
int main(){
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    if((x<=z && y<=z) ||(x-y)<=z)){
        printf("?");
    }
    else if(x>y){
        printf("+");
    }
    else if(x<y){
        printf("-");
    }
    else if(x==y){
        printf("0");
    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    int c=x-y;d=abs(c);
    if(d>=z)
    {
        if(c>0)
        printf("+");
        else if(c<0)
        printf("-");
        else
        printf("0");

    }
    else
    printf("?");
    return 0;
}


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

}


    #include <stdio.h>

    int main() {
        int k,n,w,borrow;
        int cost=0,rate;
        scanf("%d%d%d",&k,&n,&w);
        for(i=0;i<w;i++) {
            rate = i * k;
            cost = cost + rate;
        }
        borrow = cost - n;
        if(borrow < 0) {
            borrow = 0;
        } else {
            printf("%d",borrow);
        }
        return 0;
    }


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


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

}


#include <stdio.h>
#include <stdlib.h>
int main()
{
	int i;
	int j;
	int a;
	int b;
	int c;
	int d;
	int e;
	int f;
	int g;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	for (i=1;i<=c;i++)
	{
	  d=i*c
	}
	printf("%d", d);
	return 0;
}


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


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

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

    scanf("%s", s);

    len = strlen(s);

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

    return 0;
}


#include <stdio.h>
int k=0;
int main()
{
    char arr[1000];
    scanf("%s",arr);
    int i,j=0,counter=0;

    for(i=0;arr[i+1]!='\0';i++)
    {
        if(arr[i]!=arr[i+1])
        {

            j=(i+1)-k;

            if(j%2==0)
            {

            counter++;

            }k=i+1;
        }
    }
    printf("%d",counter);
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n=0,cnt=1,no=0;
    char ch,ch1='1';
    while((ch=getchar())!='\n')
    {
        if(ch1!='1')
        {
            if(ch==ch1)
                cnt++;
            else{
                    ch1=ch;
                  if(cnt%2==0 && cnt!=1)
                     no++;
                cnt=1;
                n++;
            }
        }
        else{
            ch1=ch;
            n++;
        }

    }
    if(n%2==0)
        printf("%d\n",no);
}


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

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


#include <stdio.h>
void main{
    int n,t;
    scanf("%d %d",&n,&t);
    char queue[n];
    char temp;
    for(int k=0;k<n-1;k++)
        {
            scanf("%c",&queue[j]);
        }
    for(int i=0;i<t;i++)
    {
        for(int j=0;j<n-1;j++)
        {
            if(queue[j]=='B'&& queue[j+1]=='G')
            {
                temp=queue[j];
                queue[j]=queue[j+1];
                queue[j+1]=temp;
                j++;
            }
        }
    }

}


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

//void swap(int *xp, int *yp)
//{
//    int temp = *xp;
//    *xp = *yp;
//    *yp = temp;
//}
//
//// A function to implement bubble sort
//void bubbleSort(int arr[], int n)
//{
//    int i, j;
//    for (i = 0; i < n-1; i++)
//
//    // Last i elements are already in place
//    for (j = 0; j < n-i-1; j++)
//        if (arr[j] > arr[j+1])
//            swap(&arr[j], &arr[j+1]);
//}

int main(){
	int m,n;
	scanf("%d %d",&m,&n);
	char c[m];
	int a=0;
	bool cek[m];
	for(int i=0;i<m;i++){
		scanf(" %c",&c[i]);
		if(c[i]=='B'){
			cek[i]=false;
			a++;
		}
	}
	char h;
	int b=a;
	for(int i=0;i<n;i++){
		a=0;
		for(int k=0;k<m;k++){
			cek[k]=false;
		}

		for(int j=0;j<m;j++){
			if(c[j]=='B' && c[j+1]=='G' && cek[j]==false){
				h = c[j];
				c[j] = c[j+1];
				c[j+1]=h;
				cek[j+1]=true;

			}
		}
	}

	printf("%s",c);

}


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

//void swap(int *xp, int *yp)
//{
//    int temp = *xp;
//    *xp = *yp;
//    *yp = temp;
//}
//
//// A function to implement bubble sort
//void bubbleSort(int arr[], int n)
//{
//    int i, j;
//    for (i = 0; i < n-1; i++)
//
//    // Last i elements are already in place
//    for (j = 0; j < n-i-1; j++)
//        if (arr[j] > arr[j+1])
//            swap(&arr[j], &arr[j+1]);
//}

int main(){
	int m,n;
	scanf("%d %d",&m,&n);
	char c[m];
	int a=0;
	bool cek[m];
	for(int i=0;i<m;i++){
		scanf(" %c",&c[i]);
		if(c[i]=='B'){
			cek[i]=false;
			a++;
		}
	}
	char h;
	int b=a;
	for(int i=0;i<n;i++){
		a=0;
		for(int k=0;k<m;k++){
			cek[k]=false;
		}

		for(int j=0;j<m-1;j++){
			if(c[j]=='B' && c[j+1]=='G' && cek[j]==false){
				h = c[j];
				c[j] = c[j+1];
				c[j+1]=h;
				cek[j+1]=true;

			}
		}
	}

	printf("%s",c);

}


#include<stdio.h>
int gcd(long long int a,long long int b);
int main()
{
    long long int a,b,x,y,w,h,i=0;
    scanf("%lli%lli%lli%lli",&a,&b,&x,&y);
    w=x/gcd(x,y);
    h=y/gcd(x,y);

    for(i=1;w*i<=a&&h*i<=b;i++);

printf("%lli",i-1);
}
int gcd(long long int a, long long int b)
{
    long long int t;
  if(a>b)
  {
   a=a+b;
   b=a-b;
   a=a-b;
  }
  while(b%a!=0)
  {
     t=a;
     a=b%a;
     b=t;
  }
   return a;
}


#include <stdio.h>
int main(){
	long long a,b,x,y,count=0,m,n,l,k,gcd;
	scanf("%I64d %I64d %I64d %I64d",&a,&b,&x,&y);
	m=x;n=y;
	while(m!=n)
	{
		if(m>n)
		m=m-n;

		if(n>m)
		n=n-m;
	}
	gcd=m;
	y=y/m;
	x=x/m;

	if(a/x>b/y)
	printf("%I64d",b/y);
	else
	printf("%I64d",a/x);

}


#include<stdio.h>
unsigned long long int gcd(unsigned long long int a,unsigned long long int b)
{
	// long long int f=-1;
	if(a==0)
		return b;
	else if(b==0)
		return a;
	else if(a==1 || b==1)
		return 1;
	else if (a>b)
		return gcd(b,a%b);
	else if (a<b)
		return gcd(b%a,a);
	// while(f==-1)
	// {
	// 	if(a==0)
	// 	f= b;
	// else if(b==0)
	// 	f= a;
	// else if(a==1 || b==1)
	// 	f= 1;
	// else if (a>b)
	// 	a=a%b;
	// else if (a<b)
	// 	b=b%a;
	// }
	// return f;
}
int main()
{
	unsigned long long int a,b,x,y;
	// unsigned long long int cnt=0;
	scanf("%llu %llu %llu %llu",&a,&b,&x,&y);
	unsigned long long int g=gcd(x,y);
	x=x/g;
	y=y/g;
	unsigned long long int r1,r2;
	r1=a/x;
	r2=b/y;
	if(x>y)
		printf("%llu\n",r1);
	else
		printf("%llu\n",r2);
	// for(i=1;x*i<=a && y*i<=b;i++)
	// {
	// 	cnt++;
	// }

	// printf("%lld\n",cnt );
	return 0;
}


#include<stdio.h>
unsigned long long int gcd(unsigned long long int a,unsigned long long int b)
{
	// long long int f=-1;
	if(a==0)
		return b;
	else if(b==0)
		return a;
	else if(a==1 || b==1)
		return 1;
	else if (a>b)
		return gcd(b,a%b);
	else if (a<b)
		return gcd(b%a,a);
	// while(f==-1)
	// {
	// 	if(a==0)
	// 	f= b;
	// else if(b==0)
	// 	f= a;
	// else if(a==1 || b==1)
	// 	f= 1;
	// else if (a>b)
	// 	a=a%b;
	// else if (a<b)
	// 	b=b%a;
	// }
	// return f;
}
int main()
{
	unsigned long long int a,b,x,y,i,x1,y1;
	unsigned long long int cnt=0;
	scanf("%llu %llu %llu %llu",&a,&b,&x,&y);
	unsigned long long int g=gcd(x,y);
	x=x/g;
	y=y/g;
	unsigned long long int r1,r2;
	r1=a/x;
	r2=b/y;
	if(x>y)
		printf("%llu\n",r1);
	else
		printf("%llu\n",r2);
	// for(i=1;x*i<=a && y*i<=b;i++)
	// {
	// 	cnt++;
	// }

	// printf("%lld\n",cnt );
}


#include<stdio.h>
long long int gcd(long long int a,long long int b)
{
	// long long int f=-1;
	if(a==0)
		return b;
	else if(b==0)
		return a;
	else if(a==1 || b==1)
		return 1;
	else if (a>b)
		return gcd(b,a%b);
	else if (a<b)
		return gcd(b%a,a);
	// while(f==-1)
	// {
	// 	if(a==0)
	// 	f= b;
	// else if(b==0)
	// 	f= a;
	// else if(a==1 || b==1)
	// 	f= 1;
	// else if (a>b)
	// 	a=a%b;
	// else if (a<b)
	// 	b=b%a;
	// }
	// return f;
}
int main()
{
	long long int a,b,x,y,i,x1,y1;
	long long int cnt=0;
	scanf("%lld %lld %lld %lld",&a,&b,&x,&y);
	long long int g=gcd(x,y);
	x=x/g;
	y=y/g;
	long long int r1,r2;
	r1=a/x;
	r2=b/y;
	if(x>y)
		printf("%d\n",r1);
	else
		printf("%d\n",r2);
	// for(i=1;x*i<=a && y*i<=b;i++)
	// {
	// 	cnt++;
	// }

	// printf("%lld\n",cnt );
}


#include <stdio.h>
#include <math.h>
#include <Windows.h>
int main() {
	long long n,n2;
	long long ans=0;

	scanf_s("%I64d", &n);
	n2 = 9;
	while (n > n2) {
		ans += 9;
		n2 *= 10;
		n2 += 9;
	}
	n2 /= 10;
	n -= n2;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}

	printf("%I64d", ans);
	system("pause");
}


#include <stdio.h>
#include <math.h>
int main() {
	long long n,n2;
	long long ans=0;
	scanf_s("%I64d", &n);

	if (n < 10) {
		printf("%d", n);
		return 0;
	}
	ans += 10 + n % 10;
	n -= 10 + n % 10;

	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	printf("%d", ans);
}


#include<stdio.h>
#include<iostream>

using namespace std;

int main(){
    long long int n,sum=0,x,y;
    scanf("%lld",&n);

    if(n==0)
       cout<<n<<endl;
    else{

    if(n%2==0){
       x=(n/2)-1;
       y=(n/2)+1;
    }
    else{
       x=n/2;
       y=(n/2)+1;
    }
    while(x>0){
       sum+=(x%10);
       x/=10;
    }
    while(y>0){
       sum+=(y%10);
       y/=10;
    }
    printf("%lld\n",sum);
  }
    return 0;
}


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

int main(){

    char ar[105];
    scanf("%s", ar);

    int n = strlen(ar);

    int i , count= 0, count1 = 0;
    if ( ar[0] >= 'A' && ar[0] <= 'Z' ){
        for ( i = 1 ; i < n ; i++){
            if ( ar[i] >= 'A' && ar[i] <= 'Z')
                count1++;
            else
                break;
            }
        }
    if ( count1 == n - 1 ){
        printf( "%s" , ar);
        }

    if( ar[0] >= 'a' && ar[0] <= 'z'){
        for ( i = 1 ; i < n ; i++){
            if ( ar[i] >= 'A' && ar[i] <= 'Z' )
                count++;
            else
                break;
        }
    }
    if ( count == n - 1){
        ar[0] = 'A' + (ar[0] -'a');
        for (i = 1; i < n ; i++ )
            ar[i] = 'a' + ( ar[i] - 'A');
            printf("%s", ar);
            }
    else
        break;

    else
        printf("%s",ar);

    return 0;
    }


#include<stdio.h>
#include <string.h>
int main()
{
    char string[1000];
    int i;
    gets(string);
    strlwr(str);
	if( isupper(string[0]) )
	{
	printf("%c", string[0] );
	}
	else
	{
	printf("%c", string[0]-32 );
	}
	for(i = 1; i < strlen(string); i++ )
	{
		printf("%c",  string[i] );
	}
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(){
    int l,i,c=0;
    char str[i];
    scanf("%s",str);
    l=strlen(str);
    for(i=1;i<l;i++){
        if(isupper(s[i]))
        c++;
    }
    if(c==l-1){
        for(i=0;i<l;i++){
            s[i] = isupper(s[i])?islower(s[i])?toupper(s[i]));
        }
    }
    printf("%s",s);
}
return 0;
}


#include<stduo.h>
int main()
{
    int n,sum=0,r;
    scanf("%d",&n);
    while(n>0)
    {
        r=n%10;
        n=n/10;
        sum=sum+r;
    }
    if(sum%4==0)
    printf("%d",n);
    else
    {
        n++;
    }
    printf("%d",n);
}


#include<stdio.h>

int testingMethod(int interest) {
	int test;

	if (interest < 4)
		test = 4 - interest;
	else if (interest < 8)
		test = 8 - interest;
	else if (interest < 12)
		test = 12 - interest;
	else if (interest < 16)
		test = 16 - interest;
	else if (interest < 20)
		test = 20 - interest;
	else if (interest < 24)
		test = 24 - interest;
	else if (interest < 28)
		test = 28 - interest;
	else if (interest < 32)
		test = 32 - interest;

	return test;
}

int main() {

	char str[5];
	int arr[4];
	gets_s(str);
	int i, j = 0, n;
	int interest = 0, test = 0, carry;

	for (n = 0; str[n]; ++n);
	for (i = n - 1, j = 3; j >= 0 ; --i, --j) {

		if (i < 0)
			arr[j] = 0;
		else
			arr[j] = str[i] - 48;
	}

	for ( ; ; ) {

		for (j = 0; j < 4; ++j) {
			interest += arr[j];
		}

		if (interest % 4 == 0)
			break;

		test = testingMethod(interest);
		if (arr[3] + test < 10) {
			arr[3] += test;
		}
		else {
			arr[3] = 0;
			carry = 1;
			for (i = 2; carry; --i) {
				if ((arr[i] + carry) > 9)
					arr[i] = 0;
				else {
					arr[i] += carry;
					carry = 0;
				}
			}
		}

		interest = 0;
	}
	if (arr[0] > 0)
		++n;

	for(i = 4 - n; n > 0; ++i, --n)
		printf("%d", arr[i]);

	return 0;
}


#include <cstdio>

bool check(int x) {
    int cnt = 0;
    while (x) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt % 4 == 0;
}

int main() {
    int a;
    scanf("%d", &a);
    int ans = a;
    while (!check(ans))
        ans++;
    printf("%d\n", ans);
    return 0;
}


#include <stdio.h>

int main
{
    int i,j,sum,k;
    scanf("%d",&i);
    k=i;
    while(i!=0)
    {
        j=i%10;
        sum=sum+j;
        i=i/10;
    }
    if(sum%4==0)
    printf("%d",k);
    else if(sum%4==1)
    printf("%d",k+3);
    else if(sum%4==2)
    printf("%d",k+2);
    else if(sum%4==3)
    printf("%d",k+1);
    return 0;

}


#include<stdio.h>
int sum(int i);
{
 int k=0;
 while(i>0)
 {
     k=k+i%10;
     i=i/10;
 }
 return k;

}
int main()
{
    int i,j,k;
    scanf("%d",&i);
    while(sum(i)%4!=0)
    {
        i++;
    }
    printf("%d",i);
    return 0;
}


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

// for Fast IO
int readint()
{
    int cc = getchar_unlocked();
    for (;cc < '0' || cc > '9';)
        cc = getchar_unlocked();
    int ret = 0;
    for (;cc >= '0' && cc <= '9';)
    {
        ret = ret * 10 + cc - '0';
        cc = getchar_unlocked();
    }
    return ret;
}
//

int main(void)
{
    int i, j, n, arr[100001], premax, max;

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

    for(i=0; i<n-1; i++)
        for(j=i+1; j<n; j++)
            if(arr[i] > arr[j])
            {
                int temp = arr[j];
                arr[j] = arr[i];
                arr[i] = temp;
            }

    max = arr[n-1];
    for(i=n-2; i>=0; i--)
        if(arr[i] != max)
        {
            premax = arr[i];
            break;
        }

    if(premax*2 <= max)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define mian main
#define inf 1061109567
int min(int a,int b){return a>b?b:a;}
int max(int a,int b){return a<b?b:a;}
void swap(int*a, int*b){*a =*a +*b-(*b =*a);}
int a[100100];
void just(int a[],int left,int right)
{
	if (left>=right)
		return ;
	int l=left,r=right,x=a[(right+left)/2];
	while(l<r)
	{
		while(l<r&&a[l]<x)l++;//
		while(l<r&&a[r]>x)r--;
		if(l<r)
		{
			if(a[l]>a[r])
			{
				int t=a[l];
				a[l]=a[r];
				a[r]=t;
			}
			else l++;
		}

	}
	just(a,left,l-1);
	just(a,l+1,right);
}

int main()
{
	int n;
	scanf("%d",&n);
	int i,j,k;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	just(a,1,n);
	int x,y,z;
	for(i=1;i<n;i++)
	{

		x=a[i];
		y=a[i+1];
		//y=a[i-1];
		if(2*x>y&&x!=y)//x-z
		{
			printf("YES");
			return 0;
		}

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

by IneedAC


#include <stdio.h>
#include <stdlib.h>
int a[100000], n;
int cmp(const void *x, const void *y)
{
	if(*(int*)x < *(int*)y) return -1;
	if(*(int*)x > *(int*)y) return 1;
	return 0;
}
int main()
{
	int flag = 1;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	qsort(a, n, sizeof(int), cmp);
	for(int i = 0; i < n - 1; i++) {
		if(2 * a[i] > a[i + 1]) {
			flag = 0;
			break;
		}
	}
	printf(flag? "NO" : "YES");
	return 0;
}


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

int main(void)
{
    int i, j, n, arr[100001];

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

    for(i=0; i<n-1; i++)
        for(j=i+1; j<n; j++)
            if(arr[i] > arr[j])
            {
                int temp = arr[j];
                arr[j] = arr[i];
                arr[i] = temp;
            }

    if(arr[n-2]*2 <= arr[n-1])
        printf("NO\n");
    else
        printf("YES\n");

    return 0;
}


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

int poww(int m, int n)
{
    int t = 1;
    int i;

    if(n == 0)
        return 1;
    else
        for(i = 1; i <= n; i++)
            t *= m;

    return t;
}

int main()
{
    char hour[6];
    char minu[6];
    int h, m;
    int hmax, mmax;
    int min, max;
    int left;
    int flag;
    int i, j;
    char c;
    int hflag, mflag;

    i = 0;
    while(1) {
        c = getchar();
        if(c != ':') {
            hour[i] = c;
            i++;
        }
        else {
            hour[i] = 0;
            break;
        }
    }

    i = 0;
    while(1) {
        c = getchar();
        if(c != '\n') {
            minu[i] = c;
            i++;
        }
        else {
            minu[i] = 0;
            break;
        }
    }

    h = strlen(hour);
    m = strlen(minu);

    i = 0;
    while(hour[i] == '0') {
        h--;
        i++;
    }
    hflag = i;

    i = 0;
    while(minu[i] == '0') {
        m--;
        i++;
    }
    mflag = i;

    if(m == 1 && h == 1)
        if(hour[hflag] >= '0' && hour[hflag] <= '9' || hour[hflag] <= 'N' && hour[hflag] >= 'A') {
            printf("-1\n");
            return 0;
        }
    if(m == 0 && h == 0) {
        printf("-1\n");
        return 0;
    }

    hmax = 2;
    for(i = hflag; i < hflag + h; i++) {
        if(hour[i] <= '9' && hour[i] >= '0')
            hmax = hmax > (hour[i] - '0' + 1) ? hmax : (hour[i] - '0' + 1);
        else
            hmax = hmax > (hour[i] - 'A' + 11) ? hmax : (hour[i] - 'A' + 11);
    }

    mmax = 2;
    for(i = mflag; i < mflag + m; i++) {
        if(minu[i] <= '9' && minu[i] >= '0')
            mmax = mmax > (minu[i] - '0' + 1) ? mmax : (minu[i] - '0' + 1);
        else
            mmax = mmax > (minu[i] - 'A' + 11) ? mmax : (minu[i] - 'A' + 11);
    }

    hmax = hmax > mmax ? hmax : mmax;
    mmax = hmax;
    min = hmax;

    if(h == 1)
        hmax = -1;
    else {
        flag = 0;
        while( 1 ) {
            left = 23;
            for(i = hflag + h - 1, j = 0; i >= hflag; i--, j++) {
                if(hour[i] <= '9' && hour[i] >= '0')
                    left -= (hour[i] - '0') * poww(hmax, j);
                else
                    left -= (hour[i] - 'A' + 10) * poww(hmax, j);
            }

            if(left >= 0) {
                flag = 1;
                hmax++;
            }
            else if(flag == 0) {
                printf("0\n");
                return 0;
            }
            else {
                hmax--;
                break;
            }
        }
    }

    if(m == 1)
        mmax = -1;
    else {
        flag = 0;
        while( 1 ) {
            left = 59;
            for(i = mflag + m - 1, j = 0; i >= mflag; i--, j++) {
                if(minu[i] <= '9' && minu[i] >= '0')
                    left -= (minu[i] - '0') * poww(mmax, j);
                else
                    left -= (minu[i] - 'A' + 10) * poww(mmax, j);
            }

            if(left >= 0) {
                flag = 1;
                mmax++;
            }
            else if(flag == 0) {
                printf("0\n");
                return 0;
            }
            else {
                mmax--;
                break;
            }
        }
    }

    if(hmax != -1 && mmax != -1)
        max = hmax > mmax ? mmax : hmax;
    else
        max = mmax == -1 ? hmax : mmax;

    for(i = min; i <= max; i++) {
        if(i == max)
            printf("%d\n", i);
        else
            printf("%d ", i);
    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int value(char c){
    if(c>='0' && c<='9') return c-'0';
    else if(c>='A' && c<='Z' ) return c-'A'+10;
    else {
        printf("Error radix\n");
        return -1;
    }
}
int valueR(char* num,int radix){
    int i;
    int rt=0;
    for(i=0;i<strlen(num);i++){
        rt=rt*radix+value(num[i]);
    }
    return rt;
}
int main(){
    char num[20];
    char num1[6];
    char num2[6];

    int max=0;
    int i,j;
    int check,c;

    scanf("%s",num);
    check=0;//count 0
    c=0;
    for(i=0;num[i]!=':';i++){
        if(num[i]!='0') check=1;
        if(check==1){
            num1[c++]=num[i];
            if(value(num[i])>max) max= value(num[i]);
        }
    }
    num1[c]='\0';

    check=0;
    c=0;
    i++;
    for(;num[i]!='\0';i++){
        if(num[i]!='0') check=1;
        if(check==1) {
            num2[c++]=num[i];
            if(value(num[i])>max) max= value(num[i]);
        }
    }
    num2[c]='\0';

    //printf("\n%s:%s %d\n",num1,num2,max);

    //caculate
    if(strlen(num1)==1&&strlen(num2)==1) printf("-1\n");
    else{
        i=max+1;
        check=0;
        while(1){
            //check radix i
            if(valueR(num1,i)<24 && valueR(num2,i)<60){
                printf("%d ",i);
                check=1;
            }else{
                if(check==0) printf("0");
                break;
            }
            i++;
        }
    }
    return 0;
}


#include<math.h>
#include<stdio.h>
#include<string.h>
//#include<iostream>
//using namespace std;
int a[5],b[5];
char t[50];

main()
{
    int i,j,k,n,r,h,m,sizea,sizeb,max=1,flag1=0,flag2=0,p,power;
    scanf("%s",t);
    i=0;
    sizea=0;

    while(t[i]!=':')
    {
        if(t[i]>='0'&&t[i]<='9')
        {
            a[i]=t[i]-'0';
        }
        if(t[i]>='A'&&t[i]<='Z')
        {
            a[i]=t[i]-'A'+10;
        }
        if(a[i]>max)
        max=a[i];

        i++;
        sizea++;
    }
    j=i+1;
    sizeb=0;
    while(t[j]!='\0')
    {
        if(t[j]>='0'&&t[j]<='9')
        {
            b[sizeb]=t[j]-'0';
        }
        if(t[j]>='A'&&t[j]<='Z')
        {
            b[sizeb]=t[j]-'A'+10;
        }
        if(b[sizeb]>max)
        max=b[sizeb];
        //printf("%d\n",b[sizeb]);
        j++;
        sizeb++;

    }
    for(i=0;i<sizea;i++)
    {
        if(i==sizea-1)
        {
            h=a[i];
            flag1=1;
        }
        else if(a[i]==0)
        continue;
        else
        break;
    }
    for(i=0;i<sizeb;i++)
    {
        if(i==sizeb-1)
        {
            m=b[i];
            flag2=1;
        }
        else if(b[i]==0)
        continue;
        else
        break;
    }
    if(flag1==1&&flag2==1&&h<=23&&m<=59)
    {
        printf("-1\n");
        return 0;
    }
    h=0;
    m=0;

   // printf("%d %d\n",sizea,sizeb);
    for(p=max+1;;p++)
    {
        h=0;
        m=0;
        power=1;
        for(i=sizea-1;i>=0;i--)
        {
            h+=a[i]*power;
            power=power*p;
            //printf("%d\n",h);
        }
        power=1;
        for(j=sizeb-1;j>=0;j--)
        {
            m+=b[j]*pow(p,sizeb-j-1);
            power=power*p;

            //printf("%d\n",m);
        }
       // printf("\n%d %d\n",h,m);

        if(h<=23)
        {
            if(m<=59&&h<24)

            printf("%d ",p);

        }

        else
        break;
    }
    if(p==max+1)
    printf("0\n");
    else
    printf("\n");
    return 0;

}


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

int poww(int m, int n)
{
    int t = 1;
    int i;

    if(n == 0)
        return 1;
    else
        for(i = 1; i <= n; i++)
            t *= m;

    return t;
}

int main()
{
    char hour[6];
    char minu[6];
    int h, m;
    int hmax, mmax;
    int min, max;
    int left;
    int flag;
    int i, j;
    char c;
    int hflag, mflag;

    i = 0;
    while(1) {
        c = getchar();
        if(c != ':') {
            hour[i] = c;
            i++;
        }
        else {
            hour[i] = 0;
            break;
        }
    }

    i = 0;
    while(1) {
        c = getchar();
        if(c != '\n') {
            minu[i] = c;
            i++;
        }
        else {
            minu[i] = 0;
            break;
        }
    }

    h = strlen(hour);
    m = strlen(minu);

    i = 0;
    while(hour[i] == '0') {
        h--;
        i++;
    }
    hflag = i;

    i = 0;
    while(minu[i] == '0') {
        m--;
        i++;
    }
    mflag = i;

    if(m == 1 && h == 1)
        if(hour[hflag] >= '0' && hour[hflag] <= '9' || hour[hflag] <= 'N' && hour[hflag] >= 'A') {
            printf("-1\n");
            return 0;
        }
    if(m == 0 && h == 0) {
        printf("-1\n");
        return 0;
    }

    if(h > 0) {
        hmax = 2;
        for(i = hflag; i < hflag + h; i++) {
            if(hour[i] <= '9' && hour[i] >= '0')
                hmax = hmax > (hour[i] - '0' + 1) ? hmax : (hour[i] - '0' + 1);
            else
                hmax = hmax > (hour[i] - 'A' + 11) ? hmax : (hour[i] - 'A' + 11);
        }
    }
    else
        hmax = -1;

    if(m > 0) {
        mmax = 2;
        for(i = mflag; i < mflag + m; i++) {
            if(minu[i] <= '9' && minu[i] >= '0')
                mmax = mmax > (minu[i] - '0' + 1) ? mmax : (minu[i] - '0' + 1);
            else
                mmax = mmax > (minu[i] - 'A' + 11) ? mmax : (minu[i] - 'A' + 11);
        }
    }
    else
        hmax = -1;

    min = hmax > mmax ? hmax : mmax;
    mmax = mmax == -1 ? mmax : min;
    hmax = hmax == -1 ? hmax : hmax;

    if(h == 1)
        hmax = -1;
    else if(hmax != -1) {
        flag = 0;
        while( 1 ) {
            left = 23;
            for(i = hflag + h - 1, j = 0; i >= hflag; i--, j++) {
                if(hour[i] <= '9' && hour[i] >= '0')
                    left -= (hour[i] - '0') * poww(hmax, j);
                else
                    left -= (hour[i] - 'A' + 10) * poww(hmax, j);
            }

            if(left >= 0) {
                flag = 1;
                hmax++;
            }
            else if(flag == 0) {
                printf("0\n");
                return 0;
            }
            else {
                hmax--;
                break;
            }
        }
    }

    if(m == 1)
        mmax = -1;
    else if(mmax != -1) {
        flag = 0;
        while( 1 ) {
            left = 59;
            for(i = mflag + m - 1, j = 0; i >= mflag; i--, j++) {
                if(minu[i] <= '9' && minu[i] >= '0')
                    left -= (minu[i] - '0') * poww(mmax, j);
                else
                    left -= (minu[i] - 'A' + 10) * poww(mmax, j);
            }

            if(left >= 0) {
                flag = 1;
                mmax++;
            }
            else if(flag == 0) {
                printf("0\n");
                return 0;
            }
            else {
                mmax--;
                break;
            }
        }
    }

    if(hmax != -1 && mmax != -1)
        max = hmax > mmax ? mmax : hmax;
    else
        max = mmax == -1 ? hmax : mmax;

    for(i = min; i <= max; i++) {
        if(i == max)
            printf("%d\n", i);
        else
            printf("%d ", i);
    }

    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a,b,sum;
void dfs(int x,int y,int count,int now)
{
	if(x>4||y>2||count>=sum)return ;
	if(x==4&&y==2)
	{
		sum=min(sum,count);
		return ;
	}
	if(now-a>=0)
		dfs(x+1,y,count,now-a);
	else
		dfs(x+1,y,count+1,n-a);
	if(now-b>=0)
		dfs(x,y+1,count,now-b);
	else
		dfs(x,y+1,count+1,n-b);

}
int main()
{
	while(scanf("%d %d %d",&n,&a,&b)==3)
	{
		sum=0x7fff;
		dfs(0,0,1,n);
		printf("%d",sum);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int length,vertical,upper,i;
    scanf("%d%d%d",&length,&vertical,&upper);
    int count=0;
    if (vertical>length/2||upper>length/2){
        if (vertical>length/2){
            if(length-vertical>=upper){
                if(length-vertical>=2*upper)count+=4;
                else if(length-vertical>=upper&&length-vertical<2*upper)count+=4;
            }
            if(length-vertical<upper){
                if(length>=2*upper)count+=5;
                else if(length>=upper&&length<2*upper)count+=6;
            }
            printf("%d\n",count);
            continue;
        }
        if(upper>length/2){
            if(length-upper>=2*vertical)count+=2;
            else if(length-upper<vertical){
                if(length>=4*vertical)count+=3;
                    if(length<4*vertical&&length>=2*vertical)
                        count+=4;
                    if(2*vertical>length)count+=6;
            }
            else if(length-upper>=vertical&&length-upper<2*vertical){
                if(2*vertical<=length)
                    count+=3;
                if(2*vertical>length)
                    count+=4;
            }
            printf("%d\n",count);
            continue;
        }
    }
    else{
        if(length>=(2*vertical+upper)*2){
            printf("1\n");
            continue;
        }
        if(length>=2*vertical+upper){
            printf("2\n");
            continue;
        }
        if(length>=vertical+upper){
            count+=2;
            if(length-vertical-upper<vertical){
                if(length>=2*vertical)count+=1;
                else if(length>=vertical&&length<2*vertical)count+=2;
            }
        }
        printf("%d\n",count);
    }
    return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int n,a,b,sum;
void dfs(int x,int y,int count,int now)
{
	if(x>4||y>2||count>=sum)return ;
	if(x==4&&y==2)
	{
		sum=min(sum,count);
		return ;
	}
	if(now-a>=0)
		dfs(x+1,y,count,now-a);
	else
		dfs(x+1,y,count+1,n-a);
	if(now-b>=0)
		dfs(x,y+1,count,now-b);
	else
		dfs(x,y+1,count+1,n-b);

}
int main()
{
	while(scanf("%d %d %d",&n,&a,&b)==3)
	{
		sum=0x7fff;
		dfs(0,0,1,n);
		printf("%d",sum);
	}
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,b,sum;
void dfs(int x,int y,int count,int now)
{
	if(x>4||y>2||count>=sum)return ;
	if(x==4&&y==2)
	{
		sum=min(sum,count);
		return ;
	}
	if(now-a>=0)
		dfs(x+1,y,count,now-a);
	else
		dfs(x+1,y,count+1,n-a);
	if(now-b>=0)
		dfs(x,y+1,count,now-b);
	else
		dfs(x,y+1,count+1,n-b);

}
int main()
{
	while(scanf("%d %d %d",&n,&a,&b)==3)
	{
		sum=0x7fff;
		dfs(0,0,1,n);
		printf("%d",sum);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int length,vertical,upper,i;
    scanf("%d%d%d",&length,&vertical,&upper);
    int count=0;
    if (vertical>length/2||upper>length/2){
        if (vertical>length/2){
            if(length-vertical>=upper){
                if(length-vertical>=2*upper)count+=4;
                else if(length-vertical>=upper&&length-vertical<2*upper)count+=4;
            }
            if(length-vertical<upper){
                if(length>=2*upper)count+=5;
                else if(length>=upper&&length<2*upper)count+=6;
            }
            printf("%d\n",count);
            continue;
        }
        if(upper>length/2){
            if(length-upper>=2*vertical)count+=2;
            else if(length-upper<vertical){
                if(length>=4*vertical)count+=3;
                    if(length<4*vertical&&length>=2*vertical)
                        count+=4;
                    if(2*vertical>length)count+=6;
            }
            else if(length-upper>=vertical&&length-upper<2*vertical){
                if(2*vertical<=length)
                    count+=3;
                if(2*vertical>length)
                    count+=4;
            }
            printf("%d\n",count);
            continue;
        }
    }
    else{
        if(length>=(2*vertical+upper)*2){
            printf("1\n");
            continue;
        }
        if(length>=2*vertical+upper){
            printf("2\n");
            continue;
        }
        if(length>=vertical+upper){
            count+=2;
            if(length-vertical-upper<vertical){
                if(length>=2*vertical)count+=1;
                else if(length>=vertical&&length<2*vertical)count+=2;
            }
        }
        printf("%d\n",count);
    }
    return 0;
}


#include<stdio.h>
long long int n,c;
void dot(long long int i, int l);
int main (){
   scanf("%I64d",&n);
   dot(2520,1);
   printf("%I64d",c);
void dot(long long int i,int l){
   i*=l;
   if(i<=n){
       c++;
       if(l<=2){
           dot(i,2);
       }
       if(l<=3){
           dot(i,3);
       }
       if(l<=5){
           dot(i,5);
       }
       dot(i,7);
   }
}


#include<stdio.h>
long long int n,c;
void dot(long long int i, int l);
int main (){
   scanf("%I64d",&n);
   do(2520,1);
   printf("%I64d",c);
void dot(long long int i,int l){
   i*=l;
   if(i<=n){
       c++;
       if(l<=2){
           dot(i,2);
       }
       if(l<=3){
           dot(i,3);
       }
       if(l<=5){
           dot(i,5);
       }
       dot(i,7);
   }
}


 #include<stdio.h>
long long int n,c;
void do(long long int i, int l):
int main (){
   scanf("%I64d",&n);
   do(2520,1);
   printf("%I64d",c);
}
void do(long long int i,int l){
   i*=l;
   if(i<=n){
      c++;
      do(i,2);
      do(i,3);
      do(i,5);
      do(i,7);
      if(l!=2){
          do(i,4);
          if(l!=3){
             do(i,6);
             do(i,9);
           }
           if(l!=4){
                do(i,8);
            }
            if(l!=5){
                 do(i,10);
            }
       }
   }
}


#include <stdio.h>
int main ()
{
    long long ("%lli",&n);
    n=n/25200;
    printf("%lli",n);
    return 0 ;
}


#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    __int64 a;
    while(scanf("%I64d",&a)!=EOF)
    {
        printf("%I64d",a/2520);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>

using namespace std;

int cost, coin;

int solve()
{
    int i=1;
    bool flag = true;
    while(flag)
    {
        if (i*cost%10==coin||
            i*cost%10==0) return i;
        i++;
    }
}

int main(void)
{
    cin >> cost >> coin;
    cout << solve() << endl;
    //scanf("%d%d",&cost,&coin);
    //printf("%d\n",solve());
    return 0;
}


#include<stdio.h>
int main()
{
    int k,r,i,t,s;
    scanf("%d",&k);
    scanf("%d",&r);

    for(i=1;i<10;i++){
        t=k*i;
        s=t%10;
        if(s==r ) break;
       else  if(t%2==0 && r%2==0) break;
        else (s!=r ){i=1;break;}
    }
    printf("%d",i);

    return 0;
}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="shovel3" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/shovel3" 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/shovel3" 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)
{
    long n,i,m,r,j;  long sum=0;
    scanf("%ld",&n);
    for (i=2;i<n;i++)
    {
        m=0;j=n;
        while (j)
        {
            r=j%i;
            j=j/i;
            sum+=r;
            }
    }
    printf("%ld/%ld\n",sum,n-2);
}


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


#include <stdio.h>

int cmmdc(int a, int b)
{
    if(a == b) return a;
    else if (a > b) return cmmdc(a - b,b); else  return cmmdv( b - a,a);
}
int n, s, b, z, numitor, numarator, dc;
int main()
{
   scanf("%d", &n);
    numitor = n - 2;
    for(b = 2; b < n; b++)
    {
        z = n;
        while (z > 0){
            s = s + z % b;
            z = z / b;
        }
    }
    numarator = s;
    dc = cmmdc(numarator, numitor);
    printf("%d/%d ", numarator / dc, numitor /dc);
    return 0;
}


#include <stdio.h>
int h(a,b)
{
return b;
h(b,a%b):a;
}
int main()
{
       int a,s=0,i,j,z;
       scanf("%d",&a);
       for(i=2;i<a;i++)
            for(j=a;j;s+=j%i,j/=i);
        j=h(s,a-2);
        printf("%d/%d",s/j,(a-2)/j);
        return 0;
}


#include<stdio.h>
int gcd(int a,int b)
{
 if(b==0)
 return a;
 else
 return gcd(b,a%b);
}
int main()
{
 int i,a,s=0,hcf;
 scanf("%d",&a);
 for(i=2;i<=(a-1);i++)
 {
  t=a;
  while(t!=0)
  {
   s=s+(t%i);
   a=(t/i);
  }
 }
 hcf=gcd(s,a-2);
 printf("%d/%d",(s/hcf),((a-2)/hcf));
 return 0;
}


#include<stdio.h>
using namespace std;
int n,m,s,k;
int main()
{
	scanf("%d%d",&n,&m);
	m=240-m;
	k=5;
	while (m-k>=0) s++,m-=k,k+=5;
	if (s>n) s=n;
	printf("%d",s);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){

	int n,k;
	cin>>n>>k;
	int rTime = 240 -k;
	int i,count=0;
	int a[10];
	for(i=0;i<10;i++)
	{
	a[i]=5*(i+1);

}

	int totalTime = 0;
	i=0;
	while(rTime>=a[i] && count <n)
	{
		rTime-=a[i];
		count++;

		i++;
	}
	cout<<count;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,i;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++){
        k+=5*i;
        if(k>240){
            i--;
            break;}
    }
    printf("%d\n",i);
    return 0;
}


#include <stdio.h>

int main(void)
{
    int n=0, k=0;
    int rest=0;
    int num=0;
    int l=0,h=0,mid=0,time=0;

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

    rest=240-k;
    if(rest <5)
    {
        num=0;
    }
    else
    {
        l=0;
        h=n;
        while( l+1<h)
        {
            mid = (l+h)/2;
            time = 5*(mid)(mid+1)/2;
            if(time >rest)
            {
                h=mid;
            }
            else l=mid;
        }

        time = 5*h(h+1)/2;
        if(time<rest) num=h;
        else num=l;
    }
    printf("%d",num);
    return 0;
}


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

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

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

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

int main () {

  int valor, i, j;

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

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

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

  valor = vai(n,0);

  printf("%d", valor);

  return 0;

}


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

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

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

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

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

int main () {

  int valor, i, j;

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

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

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

  valor = vai(n,0);

  printf("%d", valor);

  return 0;

}


#include <stdio.h>

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

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

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

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

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

}

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

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

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

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

	return total;

}


#include<stdio.h>
#include<math.h>
int main()
{
	int n, a, b, i, x;
	scanf("%d", &n);
	x = sqrt(double(n));
	for(i = 1; i <= x; i++)
	{
		if(n % i == 0)
		{
			a = i;
			b = n / a;
		}
	}
	printf("%d %d\n", a, b);
	return 0;


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

int main(){
	int n, k, a, b;
	scanf("%d", &n);
	k = trunc(sqrt(n));
	for(int i = k; i >= 1; i --)
		if (n % i == 0){
			a = i;
			break;
		}
	printf("%d %d", a, n / a);
	return 0;
}


#include<stdio.h>
int main()
{ lon long i,n,a,b;

scanf("%lld",&n);
for(i=1;i<=n;i++)
{if(n%i==0)

{ a=i;
b=n/i;
if(a<=b && (b-a)<10)
 {printf("%lld%lld\n",a,b);}
}
}
return 0;
}


#include <stdio.h>
#include <string.h>
int main(void){
   char s[50];
   int n,i,a=0,b=0;
   scanf("%s",&s);
   n=strlen(s);
   for(i=0;i<n;i++){
   if(s[i]==4){a++;}
   if(s[i]==7){b++;}
      ;  }
      if(a<b){printf("7");}
      if(b<a){printf("4");}
      if(a==0&&b==0){printf("-1");}else{if(a==b){printf("4");};
      };
      return 0;}


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

main() {
    int i = 0, a = 0, b = 0;
    char s[50]; char ch;

    scanf("%s", s);
    while (s[i] != '\0') {
        if (s[i] == '4') a++;
        if (s[i] == '7') b++;
        i++;
    }

    if (a && a >= b) { printf("%d", 4); return; }
    if (b && a < b) { printf("%d", 7); return; }
    printf("%d", -1);
}


#include<stdio.h>
int main()
{
	int count4=0,count7=0;
	char ch;
	scanf("%c",&ch);
	while (ch!='\n')
	{
		if (ch=='4')
			count4++;
		if (ch=='7')
			count7++;
		scanf("%c",&ch);
	}
	if (count4==0&&count7==0)
		printf("-1\n");
	else
		printf("%c\n"count4>=count7?'4':'7');
	return 0;
}


#include<stdio.h>
int main()
    char s[50]; int i=0,j=0,k=0;
    puts(s);
    while(s[i]!='\0')
    {
        if(s[i]=='4')
            j++;
        else if(s[i]=='7')
                k++;
        i++;
    }
    if(j == 0 && k == 0)
            printf("-1");
    else if(j>=k)
        printf("4");
    else
        printf("7");
    return 0;
}


include<stdio.h>
int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    printf("%s",((n<=m)&&(n<=k))?"Yes":"No");
}


#include<stdio.h>
#define ll long long
main()
{
    ll n,m,k;
    scanf("%lld%lld%lld",&n,&m,&k);
    ll smalle=m>k?k:m;
    if(larger>=n)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }

}


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

int main()
{
    int x,z,y;
    scanf("%d %d %d",&x,&z,&y);
    if (z<x)
    {
      continue;
    }
    if (x>y)
    {
      printf("Yes");
    }
    else{
      printf("No");
    }
    return 0;
}


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


#include<stdio.h>
int main()
{
	int n;
	scanf("%d%d%d",&n,&m,&k);
	if(m>=n && k>=n)
		printf("Yes");
	else
		printf("No");
}


#include<stdio.h>

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

    int arr[n];

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

    int time=0;
    if(n>=1)
        time+=(n-1)*10;

    for(int i=0;i<n;i++)
    {
        time+=arr[i];
    }

    if(d<time)
        printf("%d",-1);
    else
    {
        int jokes_time=(n-1)*10;
        jokes_time+=(d-time);
        printf("%d",jokes_times/5);
    }
    return 0;
}


#include <stdio.h>
int main()

{

	int n, d,a[10005]

	int i,total,left,sum

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

	total = 0;

	for (i = 0; i < n; i++)

	{

		scanf("%d", &a[i]);

		total += a[i];

		total += 10;

	}

	total -= 10;

	if (total>d)

	{

		printf("-1\n");

	}

	else

	{

		left = d - total;

		sum = left / 5;

		sum += 2 * (n - 1);

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

	}

	return 0;

}


#include <stdio.h>
int main(){
    int n, d, x, sum = 0;
 	scanf("%d %d", &n, &d);
    for(i = 0; i < n; i++){
 		scanf("%d", &x);
 		sum += x;
 	}
 	if(sum + (n - 1) * 10 > d){
 		printf("-1\n");
 	}
 	else
 		printf("%d\n", (d - sum)/5);
    return 0;
}


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

int main()
{
    int k,n,d,i,l,sum;
    sum=0;
    scanf("%d %d",&n,&d);
    int ara[10000];
    for(i=0; i<n; i++)
    {
        scanf("%d",&ara[i]);
    }
    for(i=0; i<n; i++)
    {
        sum=sum+ara[i];
    }
    {        if(n%2==0){

    k=sum +((n)*10);}
    else{k=sum+((n-1)*10);}
    }

    }
    if(d<=k)
    {
        printf("-1");
    }
    else if(sum>d){
        printf("-1");
    }
    else
    {
        l=d-sum;
        printf("%d",l/5);

    }
}


#include <stdio.h>
int max(int a,int b){if(a>b) return a;else return b;}
int main(){
    int k;
    scanf("%i",k);
    int mx=0;
    while (k--){
        int a;
        scanf("%i",a);
        mx = max(mx,a);
    }
    if (mx>25)
        mx-=25;
    else
        mx=0;
    printf("%i",mx)
    return 0-0-0;
}


#include <malloc.h>
#include <cstdio>
#include <cstring>
#include <climits>

using namespace std;

int main(){

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

    int max = INT_MIN;
    for(int i=0; i<x ;i++){
        int t;
        scanf("%d",&t);
        if(max>t){
            max = t;
        }
    }

    if(max - x < 0){
       printf("0");
    }
    else{
        printf("%d",max-x);
    }

    return 0;
}


#include <malloc.h>
#include <cstdio>
#include <cstring>
#include <climits>

using namespace std;

int main(){

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

    int max = INT_MIN;
    for(int i=0; i<x ;i++){
        int t;
        scanf("%d",&t);
        if(max<t){
            max = t;
        }
    }

    if((max - 25) < 0){
       printf("0");
    }
    else{
        printf("%d",(max-25));
    }

    return 0;
}


#include<stdio.h>
int main()
{
	int N;
	scanf("%d",&N);
	int A[N]={0},m=0;
	for(int i=0;i<N;i++){
		//cin>>A[i];
		scanf("%d",&A[i]);
		if(A[i]>m)m=A[i];
	}
	if(m-25>0)printf("%d\n",m-25);
	else printf("0\n");
}


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

	return 0;
}


#include<stdio.h>
int main(void)
{
	int n, m, z;

	scanf_s("%d%d%d", &n, &m, &z);

	printf("%d", z / (n*m));

	return 0;
}


#include<stdio.h>
int main()
{
    llong long int a,b,c,l,k;
    while(scanf("%lld %lld %lld",&a,&b,&c)==3)
    {
        l=a*b;
        k=c/l;
        printf("%lld\n",k);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int gcd(int a,int b){return (b>0) ? gcd(b,a%b) : a;}
int main(){
	int n,m,z;
	while(cin >> n >> m >> z){
		int cnt=0;
		int x=n/gcd(m,n)*m;
		for(int i=1;i<=z;i++){
			if(i%x==0)
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int a[3],k,l;
    while(scanf("%d %d %d",&a[0],&a[1],&a[2])==3)
    {
        sort(a,a+3);
        l=a[2]-a[1];
        k=a[2]-a[0];
        printf("%d\n",k+l);
    }
    return 0;
}


#include<stdio.h>
#include<math.h>
int main () {
	printf("m,n,z:");
	int m,n,z,i,t;
	scanf("%d %d %d",&m,&n,&z);
	i=1;
	t=m*i;
	while ((t%n)!=0) {
		i++;
		t=m*i;
	}
	else
		printf("%d",z/t);
}


#include<stdio.h>
#include<stdlib.h>
using namespace std;
main()
{
      int a,b,c,d,e=0,f=0,g,h=0;
      scanf("%d:%d",&a,&b);
      scanf("%d:%d",&c,&d);
      if(b-d>=10)
         e=(b-d);
      else if((b-d)>=0)
         f=(b-d);
      else{
           g=60-abs(b-d);
           if(g>=10)
               e=g;
           else if((b-d)>0)
               f=g;
           h++;
      }
      if((a-c-h)>=10)
         printf("%d:",a-c-h);
      else if((a-c-h)>=0&&(a-c-h)<10)
         printf("0%d:",a-c-h);
      else if((a-c-h)<0)
         printf("%d:",24-abs(a-c-h));
      if(e!=0)
         printf("%d",e);
      else
         printf("0%d",f);
         return 0;
}


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

int no_p(int n,int p)
{
	int i=0;
	while(n%p==0)
	{i++;
		n=n/p;

	}
	return i;
}

int main()
{
	long long int i,j,k,l,n,n5,n2,m,r=1;

	n5=no_p(n,5);

	n2=no_p(n,2);
	printf("%lld %lld\n",n5,n2);
	if (n5<k)
	n5=k-n5;
	else
	n5=0;
	if (n2<k)
	n2=k-n2;
	else
	n2=0;
	for (i=0;i<n2;i++)
	r*=2;
	for(i=0;i<n5;i++)
	r*=5;
	r*=n;
	printf("%lld\n",r);
	return 0;
}


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

/**
 * http://codeforces.com/contest/861/problem/A
 * */
long gcd(long a, long b) {
    long mod = a % b;
    while(mod > 0) {
        a = b;
        b = mod;
        mod = a % b;
    }
    return b;
}

long round(long n, long k) {
    long kk = 1;
    while(k > 0) {
        kk *= 10;
        k--;
    }
    long g = gcd(n, kk);
    return n * kk / g;
}

int main() {
    long n, k;
    scanf("%ld %ld", &n, &k);
//    printf("%ld\n", round(n, k));
    cout << round(n, k);
    return 0;
}


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

long long int power(int osn, int pok);

int main()
{
    long long int n2, n5, n, k, i, j, otv, c2 = 0, c5 = 0, ost, razn5, razn2;
    scanf("%lld%lld", &n, &k);
    n2 = n;
    n5 = n;
    for(i = 0; i < k+1; i++)
    {
        if(n2%2 == 1)break;
        else
        {
            n2 = n2/2;
            c2++;
        }
    }
    for(i = 0; i < k+1; i++)
    {
        if(n5%5 == 0)
        {
            n5 = n5/5;
            c5++;
        }
        else
        {
            break;
        }
    }
    if(k>=c5) razn5 = k - c5;
    else{razn5 = 0;}
    if(k>=c2) razn2 = k - c2;
    else{razn2 = 0;}

    n = n*power(2, razn2)*power(5, razn5);

    printf("%lld", n);
    return 0;
}

int power (int osn, int pok)
{   int temp = osn, temp1;
    int i;
if(pok == 0)return 1;
else{
    if(pok == 1)return osn;
    for (i = 1;i < pok; i++)
    {
        temp1 = temp;
        temp = temp1 * osn;
    }
}
    return temp;
}


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

/**
 * http://codeforces.com/contest/861/problem/A
 * */
long gcd(long a, long b) {
    long mod = a % b;
    while(mod > 0) {
        a = b;
        b = mod;
        mod = a % b;
    }
    return b;
}

long round(long n, long k) {
    long kk = 1;
    while(k > 0) {
        kk *= 10;
        k--;
    }
    long g = gcd(n, kk);
    return n * kk / g;
}

int main() {
    long n, k;
    scanf("%ld %ld", &n, &k);
    cout << round(n, k);
    return 0;
}


#include<stdio.h>
#include<conio.h>
int main()
{
	char a;
	char nam[6000099999000];
	scanf("%c",&a);
	scanf("%s",nam);

	if(a>96){
		printf("%c",a-32);
		printf("%s",nam);
	}
	else{
		printf("%c",a);
		printf("%s",nam);
	}

	return 0;
}


#include<stdio.h>

int main(){
   long long int n;
    scanf("%lld,&n")
    char ch[n];
    scanf("%s",&ch);
    int i=0;
    if(ch[i]>='a' && ch[i]<='z'){
        ch[i]=ch[i]-32;
    }
    printf("%s",ch);
    return 0;
}


#include<stdio.h>
int main()
{
    char str[1000];
    scanf("%s",str[0]);
    if(str[0]>=97 && str[0]<=122)
        str[0]=90-32;
    else
        break;
    printf("%s",str[0]);
}


#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    string s;
    int i;
    getline(cin,s);
    if(s[0]>=97&&s[0]<=122)
    {
        s[0]=s[0]-32;
    }
    cout<<s<<endl;
    return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
    int i,l;
    char s[101];
    scanf("%s",s);
    l=strlen(s);
    for(int i=0;i<l;i++){
        if(s[0]>=97&&s[0]<=122)
        s[0]=s[0]-32;
        printf("%s",str);
    }
return 0;
}


#include<stdio.h>
#include<stdlib.h>
int ndogs;
char colors[100];
char test(char* arr)
{
	int i = 0;
	int j = 0;
	for (i = 0; i <= ndogs; i++)
	{
		for (j = i + 1; j <= ndogs; j++)
		{
			if (arr[i] == arr[j])
			{
				return 1;
			}
		}
	}
	return 0;
}
void main(void)
{
	scanf("%d", &ndogs);
	scanf("%s", colors);
	if (test(colors))
		printf("Yes");
	else printf("No");
	getch();
}


#include<stdio.h>
#include<stdlib.h>
int ndogs;
char colors[100];
char test(char* arr)
{
	int i = 0;
	int j = 0;
	for (i = 0; i <= ndogs; i++)
	{
		for (j = i + 1; j <= ndogs; j++)
		{
			if (arr[i] == arr[j])
			{
				return 1;
			}
		}
	}
	return 0;
}
void main(void)
{
	scanf_s("%d", &ndogs);
	scanf_s("%s", colors, ndogs + 1);
	if (test(colors))
		printf("Yes");
	else printf("No");
	getch();
}


#include <stdio.h>

int main()
{
	char a[2000001];
	int n, i, j, p=0;

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

	for(i=0; i<n; i++)
	{
		for(j=i+1; j<n; j++)
			if(a[i]==a[j])
			{
				p=1;
				break;
			}
		if(p) break;
	}

	if(n==1) p=1;
	if(p==1)
	printf("yes");
	else
	printf("no")
	return 0;
}


char test(char* arr)
{
	for (int i = 0; i <= ndogs; i++)
	{
		for (int j = i + 1; j <= ndogs; j++)
		{
			if (arr[i] == arr[j])
			{
				return 1;
			}
		}
	}
	return 0;
}


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

#define INIT(x) memset(x,0,sizeof(x))
#define eps 1e-8

typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 200005;

inline void read(int &x)
{
    int f=1;x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    x*=f;
}

inline void print(int x)
{
    if(x<0){ putchar('-'); x=-x;}
    if(x>9) print(x/10);
    putchar(x%10+'0');
}

inline void caltime(int tt) {
	tt = clock() - tt;
    cerr << (double)tt/CLOCKS_PER_SEC << " seconds!" << endl;
}

int n;
string s;
int a[100];

int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++) {
		int temp = s[i]-'a';
		a[temp]++;
	}
	int ans = 0;
	for(int i=0;i<26;i++) {
		if(a[i]>=2) {
			ans++;
		}
	}
	if(ans||n==1) {
		cout<<"Yes"<<endl;
	}else {
		cout<<"No"<<endl;
	}
	return 0;
}


#include<stdio.h>
int fact(int x);
int main()
{
	long long n,i;
	while(scanf("%lld",&n)!=EOF)
	{
		int s=0,m,t,j,c,d;
		for(i=1;i<=n;i++)
		{
			c=(n-2*i);
			t=c/3;
			if(c%3==0&&t>=fact(i))
			{
				s++;
			}
		}

			printf("%d\n",s);
	}
}
int fact(int x)
{
	int i,s=0;
	for(i=1;i<x;i++)
	{
		s+=i;
	}
	return s;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
typedef long long ll;
using namespace std;
ll n,ans=0;
int main()
{
	scanf("%I64d",&n);
	ll right=1000000000,left=0,mid;
	while(left<=right)
	{
		mid=(left+right)/2;
		if(2*n-(3*mid-1)*(3*mid+1)<6*mid+4)
			right=mid-1;
		else
		{
			ans=mid;
			left=mid+1;
		}
	}
	printf("%I64d",ans);
}


#include<stdio.h>
 int main()
  {
    long long int t,n,i,count=0,rem;
    scanf("%I64d",&n)
    t=n%3;
    t=3-t;
    for(i=t;3*i*(i+1)/2<=n+i;i+=3)
    {
    count++;
    }
    printf("%I64d\n",count);
    return 0;
  }


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
typedef long long ll;
using namespace std;
ll n,ans=0;
int main()
{
	scanf("%LLd",&n);
	ll right=1000000000,left=0,mid;
	while(left<=right)
	{
		mid=(left+right)/2;
		if(2*n-(3*mid-1)*(3*mid+1)<6*mid+4)
			right=mid-1;
		else
		{
			ans=mid;
			left=mid+1;
		}
	}
	printf("%LLd",ans);
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num=0;
    char s[100];
    gets(s);
    int d=strlen(s);
    for(int i=0;i<d;i++)
    {
        if(s[i]>64||s[i]<91)
        num++;
    }
    if(num>d/2)
    {for(int i=0;i<d;i++)
   {
    if(s[i]>96||s[i]<123)
    s[i]=s[i]-32;
   }}
   else
   {
       if(s[i]>64||s[i]<91)
       s[i]=s[i]+32;
   }
   printf("%s",s);
   return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    char str[100];
    int c=0,c1=0,i;
    scanf("%s",str);
    for(i=0;i<strlen(str);i++)
    {
        if(str[i]>=65&&str[i]<=90)
        c++;
        else
        c1++;
    }
    if(c>c1)
    {
        printf("%s",str.toupper());
    }
    else
    printf("%s",str.tolower());

}


#include<stdio.h>
#include<string.h>
main()
{
    int r,i,up,lw;
	char a[101];
	gets(a);
	r=strlen(a);
	for(i=0;i<r;i++)
	if(a[i]<'a')
       {
  up++;
}else
{
	lw++;
}

	if(up=>lw)
	printf("%s",strupr(a));
	else
	printf("%s",strlwr(a));
}


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

int main()
{
    long long int i,j,l,m,n,a[1000],b[1000],sum=0;
    char a[1000],b[1000];
    scanf("%s",a);
    scanf("%s",b);
    l=strlen(a);
    for(i=0;i<l;i++)
    {
        if(a[i]==b[i])
        printf("0");
        else
        printf("1");
    }
    return 0;
}


#include <stdio.h>

int main() {
	int a, b;
	scanf_s("%d%d", &a, &b);
	if (a == 9 && b == 1) {
		printf("%d %d", a, b * 10);
	}
	else if (a == b) {
		printf("%d %d", a * 10, b * 10 + 1);
	}
	else if (a + 1 == b) {
		printf("%d %d", a, b);
	}
	else printf("%d", -1);
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(abs(a-b)>1)
    printf("-1");
    if(abs(a-b)==0)
    printf("%d12 %d13",a,b);
    if(abs(a-b)==1)
    printf("%d99 %d00",a.);
}


#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==b){
    printf("%d00 %d01\n",a,b);
    }
    else if(a+1=b){
    printf("%d %d\n",a,b);
    }
    else if(a==9&&b==1){
    printf("%d %d0\n",a,b);
    }
    else {
    printf("-1\n");
    }
    return 0;
}


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

main() {

    char s[50];
    gets(s);
    char *numbers;
    strtok_r(s, " ", &numbers);
    int a = atoi(s);
    int b = atoi(numbers);

    if ((b - a) > 1) {
        printf("-1\n");
        exit(0);
    }
    if (a == 9 && b == 1){
        printf("%d %d\n", 99, 100);

        exit(0);
    }
    if (a > b) {
        printf("-1\n");
        exit(0);
    }
    if (a == b){
        printf("%d %d\n", a * 10, b * 10 + 1);
        exit(0);
    }
    if (b > a){
        printf("%d %d\n", (a * 100) + 99, b * 100);
        exit(0);
    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(abs(a-b)>1)
    printf("-1");
    if(abs(a-b)=0)
    printf("%d12 %d13",a,b);
    if(abs(a-b)=1)
    printf("%d99 %d00",a,b);
}


#include <stdio.h>
int main()
{
    int n,s1=0,s2=0
int x,y;
    scanf("%d",&n);

    for(int i = 0; i < n; ++i)
{
        scanf("%d%d",&x,&y);
s1=s1+x;
s2=s2+y;
}
if(s2<s1)
printf("yes");
else printf("no");

    return 0;
}

1


#include<stdio.h>
int main()
{
                 int i,j,n,c;
                 scanf("%d",&n);
                 int a[n],b[n];
                 for(i=0;i<n;i++)
                 {
                     scanf("%d",&a[i]);
                     sum+=a[i];
                 }
                 for(i=0;i<n;i++)
                 {
                     scanf("%d",&b[i]);
                     sum1+=b[i] ;
                 }

               if(sum>=sum1)
               {
                   printf("Yes\n");
               }
               else
               {
                   printf("No\n");
               }
          return 0;
}


#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],b[n],x=0,y=0;
    for(i=0;i<n;i++)
    {scanf("%d",&a[i]);
    x=x+a[i];
    }
     for(i=0;i<n;i++)
   { scanf("%d",&b[i]);
       y=y+b[i];
   }
    if(x>=y)
    printf("Yes");
    else
    printf("No");
    return 0;
}


#include <stdio.h>
int main()
{
  int n,sum1=0,sum2=0,i,j,k;
  scanf("%d",&n);
  int p1[n],p2[n];
  for(i=0;i<n;i++)
      scanf("%d",&p1[i];
  for(j=0;j<n;j++)
      scanf(%d,&p2[j];
  for(k=0;k<n;k++)
    {
        sum1 += p1[k];
        sum2+= p2[k];
    }
    if(sum1>=sum2)  printf("Yes");
        else printf("No");
}


#include<stdio.h>
int main()
{
    int n,i,j;
    scanf("%d",&n);
    int x[n];
    int y[n];

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

}

if(sum==sum1)
printf("Yes");
else
printf("No");
return 0;
}


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

void get (char **number);
void one_digit(char *number);
int two_digit(char *number);
int three_digit(int number);

int main()
{
	// Get input
	char **number = (char **)malloc(sizeof(char *));
	*number = (char *)calloc(101, sizeof(char));
	get(number);
	// Find number of digits
	int length = strlen(*number);
	///////////////////////////////////////////////////////
	int result = 0;

	// For 1 digit
	if (length == 1)
		if (one_digit(*number))
			return 0;

	// For 2 digits
	if (length == 2)
		if (two_digit(*number))
			return 0;

	// For 3 & more digits
	if (length >= 3)
	{
		for (int i = 0; number[0][i] != '\0'; i++)
		{
			for (int j = i + 1; number[0][j] != '\0'; j++)
			{
				for (int z = j + 1; number[0][z] != '\0'; z++)
				{
					char number_3_digits[4] = "";
					strncat(number_3_digits, &number[0][i], 1);
					strncat(number_3_digits, &number[0][j], 1);
					strncat(number_3_digits, &number[0][z], 1);

					int n = atoi(number_3_digits);

					if (three_digit(n))
						return 0;
				}
			}
		}
	}

	printf("NO");
	return 0;
}

int function(int number)
{
	int third = number % 10;
	int second = (number % 100 - third) / 10;
	int first = (number - second - third) / 100;

	if ((third + 2 * second + 4 * first) % 8 == 0)
		return 1;
	return 0;
}

void get(char **number)
{
	scanf("%s", number[0]);
}

void one_digit(char *number)
{
	if (number[0] == '8' || number[0] == '0')
	{
		printf("YES\n");
		printf("%s", number);
		return 1;
	}
	return 0;
}

int two_digit(char *number)
{
	int int_number = atoi(number);
	int second = int_number % 10;
	int first = (int_number - second) / 10;
	if (int_number % 8 == 0)
	{
		printf("YES\n");
		printf("%d", int_number);
		return 1;
	}
	if (second % 8 == 0)
	{
		printf("YES\n");
		printf("%d", second);
		return 1;
	}
	if (first % 8 == 0)
	{
		printf("YES\n");
		printf("%d", first);
		return 1;
	}
	return 0;
}

int three_digit(int number)
{
	if (number % 8 == 0)
	{
		printf("YES\n");
		printf("%d", number);
		return 1;
	}
	else if (function(number))
	{
		printf("YES\n");
		printf("%d", number);
		return 1;
	}
	else
		return 0;
}


#include <stdio.h>

int main() {
	short int arr[100];
	char str[100];
	scanf("%s", str);
	int ch, cnt = 0;
	while ((ch = str[cnt]) != '\0') {
		arr[cnt++] = ch - '0';
		if (arr[cnt-1] == 0 || arr[cnt-1] == 8) {
			printf("YES\n%d", arr[cnt-1]);
			return 0;
		}
	}

	for (int i = cnt-1; i >= 2; i--) {
		if (arr[i] % 2 == 0) {
			for (int j = i-1; j >= 1; j--) {
				if ((arr[j]*10 + arr[i]) % 4 == 0) {
					for (int k = j-1; k >= 0; k--) {
						short int x = arr[k]*100 + arr[j]*10 + arr[i];
						if (x % 8 == 0) {
							printf("YES\n%d", x);
							return 0;
						}
					}
				}
			}
		}
	}

	for (int i = cnt-1; i >= 1; i--) {
		for (int j == i-1; j >= 0; j--) {
			if ((arr[i] + arr[j]*10) % 8 == 0) {
				printf("YES\n%d", arr[i] + arr[j]*10);
				return 0;
			}
		}
	}

	printf("NO");
	return 0;
}


#include "convert.h"
#include <stdio.h>
#include <string.h>
#ifndef H_CONVERT
#define H_CONVERT

#define KIA Str
#define PXFUAODT template
#define JNKEV scanf
#define EIQUTJ Lprime
#define OGF num
#define PBI cur
#define GDSQ puts
#endif

int main()
{
    char KIA[101];
    char PXFUAODT[3];
    int i, j, L;
    JNKEV("%s", KIA);
    L = strlen(KIA);
    for(i = 0; i < 1000; i += 8) {
        memset(PXFUAODT, -1, sizeof(PXFUAODT));
        int EIQUTJ = 0;
        int OGF = i;
        do {
            PXFUAODT[EIQUTJ++] = OGF % 10 + '0';
            OGF /= 10;
        } while(OGF != 0);
        int PBI = L - 1;
        for(j = 0; j < EIQUTJ; ++j) {
            while(PBI >= 0 && KIA[PBI] != PXFUAODT[j]) {
                if(--PBI < 0) {
                    break;
                }
            }
            if(PBI < 0) {
                break;
            }
            --PBI;
        }
        if(j == EIQUTJ) {
            GDSQ("YES");
            printf("%d\n", i);
            return 0;
        }
    }
    GDSQ("NO");
    return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#define pl(n) cout<<n<<endl
#define p(n) cout<<n
#define rep0(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
using namespace std;

typedef long long ll ;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ll> vl;

int main(){
    string str;
    cin>>str;
    int l = str.size();
    if(l<3){
        if(l==1){
            int n = str[0]-'0';
            if(!n%8){
                pl("YES");
                cout<<n<<endl;
                return 0;
            }
            else{
                pl("NO");
                return 0;
            }
        }
        if(l==2){
            int n = (str[0]-'0')*10+str[1]-'0';
            if(n%8==0){
                pl("YES");
                cout<<str<<endl;
                return 0;
            }
            n = str[0]-'0';
            if(n%8==0){
                pl("YES");
                cout<<str[0]<<endl;
                return 0;
            }
            n = str[1]-'0';
            if(n%8==0){
                pl("YES");
                cout<<str[1]<<endl;
                return 0;
            }
        }
    }
    for(int i=l-1;i>2;i--)
    {

        int n = str[i]-'0'+(str[i-1]-'0')*10+(str[i-2]-'0')*100+(str[i-3]-'0')*1000;
        if(n%8==0)
        {
            pl("YES");
            cout<<str<<endl;
            return 0;
        }
        n = (str[i-1]-'0')*1+(str[i-2]-'0')*10+(str[i-3]-'0')*100;
        if(n%8==0){
            pl("YES");
            cout<<str.substr(0,(i-4+1))<<str[i-3]<<str[i-2]<<str[i-1]<<endl;
            return 0;
        }
        n = str[i]-'0'+(str[i-2]-'0')*10+(str[i-3]-'0')*100;
        if(n%8==0){
            pl("YES");
            cout<<str.substr(0,(i-4+1))<<str[i-3]<<str[i-2]<<str[i]<<endl;
            return 0;
        }
        n = str[i]-'0'+(str[i-1]-'0')*10+(str[i-3]-'0')*100;
        if(n%8==0){
            pl("YES");
            cout<<str.substr(0,(i-4+1))<<str[i-3]<<str[i-1]<<str[i]<<endl;
            return 0;
        }
        n = str[i]-'0'+(str[i-1]-'0')*10+(str[i-2]-'0')*100;
        if(n%8==0){
            pl("YES");
            cout<<str.substr(0,(i-4+1))<<str[i-2]<<str[i-1]<<str[i]<<endl;
            return 0;
        }
    }
    pl("NO");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 200111

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

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

ll pot (ll a , ll b){
	ll x = 1LL;
	for (int i = 0; i < b ; i++)
		x = x * a;

	return x;
}

int main (){
	ll n, a;
	scanf ("%lld",&n);
	scanf ("%lld",&a);
	int x = 1;

	for (int i = n; i >= 2; i--){
		ll k = a - pot(2, i - 1);
		ll l = pot(2, i);

		if (k % l == 0){
			x = i;
			break;
		}
	}
	printf("%d\n", x);

	return 0;
}


#include<stdlib.h>
#incude<stdio.h>
int main()
{
    long long n,k,i,t=1;
    scanf("%I64d %I64d",&n,&k);
    for(i=0;i<n-1;i++) t*=2;
    for(i=n-1;i>=0;i--)
    {
        if(k%t!=0)
        {
            t=t/2;
        }
        else break;
    }
    printf("%I64d",i+1);
}


// luogu-judger-enable-o2
#include <cstdio>
int main ()
{
    long long n, t, ans=0;
    scanf("%lld %lld",&n,&t);
    for(int i=1;i<=n;i++)
    	if(t%2==0){
    		t/=2;ans++;
		}
	printf("%lld",ans);
    return 0;
}


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


/* .................... compiled by alankar....................
*/

//......................SHORTCUTS..............................

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

#define pi 3.14159265358979323846  //float type
#define MAX 100000  //for rmq
#define SQRTMAX 317   //for rmq
//#define gc getchar_unlocked

#define FOR(i,a,b) for(i=(a);i<(b);i++)

//only for +ve and single terms
#define s(x) scanf("%d",&x);
#define sl(x) scanf("%llu",&x);
#define p(x) printf("%d\n",x);
#define pl(x) printf("%llu\n",x);
//..........................................................

typedef long long int ll;
const ll MOD=1000000007;

//returns int and +ve numbers

/*inline int inp(){
    int n=0;
    char c;
    c=gc();
    while(c<'0' || c>'9'){
        c=gc();
    }
    while(c>='0' && c<='9'){
        n=(n<<3)+(n<<1)+c-'0';
        c=gc();
    }
    return n;
}
*/
//...................................

//power with mod........long long int
 ll power(ll a,ll b,ll mod){
      if(b==0)
            return 1;
      ll temp=power(a,b/2,mod);
      temp=(temp*temp)%mod;
      if(b&1)
            temp=(temp*a)%mod;
      return temp;
}

 //power without mod........ int
int pwr(int a,int b){
      if(b==0)
            return 1;
      int temp=pwr(a,b/2);
      temp=(temp*temp);
      if(b&1)
            temp=(temp*a);
      return temp;
}
 // .....long long int
ll gcd(ll a,ll b){
      return b==0?a:gcd(b,a%b);
}
 //......long long int
ll lcm(ll a,ll b){
      return (a/gcd(a,b))*b;
}
 //......long long int with mod
ll modularInverse(ll a,ll m){
      return power(a,m-2,m);
}

 //only for int
inline int min(int a,int b) { return a<b? a : b; }
inline int max(int a,int b) { return a>b? a : b; }

//normal compare func on integers //for qsort(name,size,sizeof(type),compare)
int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}
//.......................................................

//segment tree
//not template but how to use ST
//for minimum element
/*
long long s[400000];
long long a[1000000];
int create(long long b,long long e,long long n)
{
    if(b==e)
    {
        s[n]=a[b];
    }
    else
        {
            create(b,(b+e)/2,2*n+1);
            create((b+e)/2+1,e,2*n+2);
            s[n]=s[2*n+1]<s[2*n+2]?s[2*n+1]:s[2*n+2];
        }
    return 0;
}

//for finding minimum element b/w l and r
long long messi(long long b,long long e,long long l,long long r,long long n)
{
    long long i,j;
    if(e<l||b>r)
    {
        return 100000001;
    }
    if(b>=l&&e<=r)
    {
        return s[n];
    }
    i=messi(b,(b+e)/2,l,r,2*n+1);
    j=messi((b+e)/2+1,e,l,r,2*n+2);
    return i<j?i:j;
}
*/
//............................................................................
//range minimam query
//for mim and max number
/*

//preprocess create the min array

long min[SQRTMAX], max[SQRTMAX], b[MAX];
int size, n;

void preProcess(int n){
    int i=0, j=0, k=0;
    long minimum, maximum;

    size = sqrt(n);
    //printf("size = %d\n",size);
    while(j<size){
        minimum = maximum = b[i];
        for(k=0 ; k<size ; k++){
            if(minimum>b[i])
                minimum = b[i];
            if(maximum<b[i])
                maximum = b[i];
            i++;
        }
        min[j] = minimum;
        max[j] = maximum;
        j++;
    }
}

long findMin(int l, int r){
    int j, j2;
    long minimum = b[l];

    j = l/size + 1;
    j2 = r/size - 1;

    //printf("j= %d and j2 = %d\n", j,j2);
    while(l<j*size && l<=r){
        if(minimum > b[l]){
            minimum = b[l];

        }
        //printf("Checked for %d\n", l);
        l++;
    }
    while(j<=j2 && l<=r && j<size){
        if(minimum > min[j])
            minimum = min[j];
        l = (j+1)*size;
        //printf("Checked for %d  <-->  %d\n", j*size, l-1);
        j++;
    }
    while(l<=r){
        if(minimum > b[l]){
            minimum = b[l];
        }
        //printf("Checked for %d\n", l);
        l++;
    }
    return minimum;
}

//finding max value
long findMax(int l, int r){
    int j, j2;
    long maximum = b[l];

    j = l/size + 1;
    j2 = r/size - 1;

    //printf("j= %d and j2 = %d\n", j,j2);
    while(l<j*size && l<=r){
        if(maximum < b[l]){
            maximum = b[l];

        }
        //printf("Checked for %d\n", l);
        l++;
    }
    while(j<=j2 && l<=r && j<size){
        if(maximum < max[j])
            maximum = max[j];
        l = (j+1)*size;
        //printf("Checked for %d  <-->  %d\n", j*size, l-1);
        j++;
    }
    while(l<=r){
        if(maximum < b[l]){
            maximum = b[l];
        }
        //printf("Checked for %d\n", l);
        l++;
    }
    return maximum;
}
*/

//...........................................END OF TEMPLATE.................................................................
int a[101]={0},b[101]={0};

int main()
{ int i,j,k,t,n,d;
a[0]=b[0]=1;
   s(n)
   s(k)
   s(d)
   FOR(i,1,n+1)
   {
       FOR(j,1,k+1)
       {
           if(i-j>=0)
           {
               a[i]=(a[i]+a[i-j])%MOD;
           }
       }
   }
   FOR(i,1,n+1)
   {
       FOR(j,1,d)
       {
           if(i-j>=0)
           {
               b[i]=(b[i]+b[i-j])%MOD;
           }
       }
   }
   p((a[n]-b[n]+MOD)%MOD)

    return 0;
}


#include <stdio.h>

int modMax = 1000000007;
int tsize = 101;
long long int sumWOD[tsize];
long long int sumWD[tsize];

int n, d, k;

void computeSumWOD(int size) {
    sumWOD[0] = 1;
    sumWOD[1] = 1;
    for(int i = 2; i < size; i++) {
        for(int j = 0; j<=k && i-j>0; j++) {
            sumWOD[i] += sumWOD[i-j];
            sumWOD[i] %= modMax;
        }
    }
}

void computerSumWD(int size) {
    for(int i = 1; i < size; i++) {
        if(i >= d)
            sumWD[i] += sumWOD[i-d];
        for(int j = 1; j <=k && i-j>0; j++) {
            if(j == d)
                continue;
            sumWD[i] += sumWD[i-j];
            sumWD[i] %= modMax;
        }
    }
}

int main () {
    //get n, k, d
    int n,k,d;
    scanf("%d%d%d", &n, &k, &d);
    computerSumWOD(n+1);
    computerSumWD(n+1);
    printf("%I64d", sumWD[n]);
    return 0;
}


#include <stdio.h>

const int modMax = 1000000007;
const int size = 101;
long long int sumWOD[size];
long long int sumWD[size];

int n, d, k;

void computeSumWOD(long long int *arr, int size) {
    arr[0] = 1;
    arr[1] = 1;
    for(int i = 2; i < size; i++) {
        for(int j = 0; j<=k && i-j>0; j++) {
            arr[i] += arr[i-j];
            arr[i] %= modMax;
        }
    }
}

void computerSumWD(long long int *arr, int size) {
    for(int i = 1; i < size; i++) {
        if(i >= d)
            arr[i] += sumWOD[i-d];
        for(int j = 1; j <=k && i-j>0; j++) {
            if(j == d)
                continue;
            arr[i] += arr[i-j];
            arr[i] %= modMax;
        }
    }
}

int main () {
    //get n, k, d
    int n,k,d;
    scanf("%d%d%d", &n, &k, &d);
    computerSumWOD(sumWOD, n+1);
    computerSumWD(sumWD, n+1);
    printf("%I64d", sumWD[n]);
    return 0;
}


#include <stdio.h>

const int modMax = 1000000007;
const int size = 101;
long long int sumWOD[size];
long long int sumWD[size];

int n, d, k;

void computeSumWOD(long long int arr, int size) {
    arr[0] = 1;
    arr[1] = 1;
    for(int i = 2; i < size; i++) {
        for(int j = 0; j<=k && i-j>0; j++) {
            arr[i] += arr[i-j];
            arr[i] %= modMax;
        }
    }
}

void computerSumWD(long long int arr, int size) {
    for(int i = 1; i < size; i++) {
        if(i >= d)
            arr[i] += sumWOD[i-d];
        for(int j = 1; j <=k && i-j>0; j++) {
            if(j == d)
                continue;
            arr[i] += arr[i-j];
            arr[i] %= modMax;
        }
    }
}

int main () {
    //get n, k, d
    int n,k,d;
    scanf("%d%d%d", &n, &k, &d);
    computerSumWOD(sumWOD, n+1);
    computerSumWD(sumWD, n+1);
    printf("%I64d", sumWD[n]);
    return 0;
}


#include<stdio.h>
#include<conio.h>
main()
{
int l,r,a,temp,ans;
scanf("%d %d %d",&l,&r,&a);
if(l<r)
{  while(a>0)
  {
      l=l+1;
      a=a-1;
  }
  if(l<=r)
  ans=2*l;
  else
  {temp=l-r;
   if(temp%2==0)
   ans=l+r;
   else
   ans=l+r-1;
  }
}
else
{
  while(a>0)
  {
      r=r+1;
      a=a-1;
  }
   if(l>=r)
  ans=2*r;
  else
  {temp=r-l;
   if(temp%2==0)
   ans=l+r;
   else
   ans=l+r-1;
}
printf("%d",ans);
}


#pragma warning(disable:4996)
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <stdlib.h>
#define N 100
#define EPS 1E-5
//#define min(a,b) (a>b) ? b : a
/*int lol(const void *x1, const void *x2)
{
	return *(int*)x1 - *(int*)x2;
}
int gcd(int a, int b)
{
	int c;
	while (b)
	{
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}*/
int main(void)
{
	int l, r, a;
	int i = 0, max = 0;
	scanf("%i%i%i", &l, &r, &a);
	for (i = 0; i <= a; i++)
		if ((l + i == r - (a - i) && l + i > max) || min(l + i, r - (a - i)) > max)
			max = min(l + i, r - (a - i));
	printf("%i", max * 2);
	return 0;
}


#include <stdio.h>

int main()
{
 int l,r,a;

 scanf("%d%d%d", &l,&r,&a);

 int t = l+r+a;


#include<iostream>
using namespace std;
int getResult(int l,int r,int a){
	int max,min;
	max=l>r?l:r;
	min=l<r?l:r;
	if(max-min==a)
		return max*2;
	if(max-min>a)
		return (min+a)*2;
	if(max-min<a)
		return max*2+(a-max+min)/2*2;
}
int main(){
	int l,r,a;
	cin>>l>>r>>a
	cout<<getResult(l,r,a)<<endl;
	return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
    int n,i,sum=0,flag=0;
    scanf("%d",&n);
    char a[n+1];
    scanf("%s",a);
    for(i=0;i<n;i++)
    {
        if(i<n/2)
        {
            sum = sum + a[i];
            if(a[i]!= 52 && a[i]!=55)
            {
                printf("NO");
                flag++;
                break;
            }
        }
        else
        {
            sum=sum-a[i];
            if(a[i] !=52 && a[i] !=55)
            {
                printf("NO");
                flag++;
                break;
            }
        }
    }
    if(sum==0)
    printf("YES");
    else(sum !=0 && flag==0)
        printf("NO");
    return 0;
}


#include <cstdio>
#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

bool isLuckyTicket(const string& _Src) {
    int m = _Src.size() >> 1;
    string l = _Src.substr(0, m);
    string r = _Src.substr(m, m);
    int numl = 0, numr = 0;
    auto lit = l.begin(), rit = r.begin();
    while (lit != l.end() && rit != r.end()) {
        if (*lit == '4' || *lit == '7')
            numl += int(*lit - '0');
        else return false;
        if (*rit == '4' || *rit == '7')
            numr += int(*rit - '0');
        else return false;
        ++lit, ++rit;
    }
    return (numl == numr);
}

int main() {
    int n;
    string ticket;
    cin >> n >> ticket;
    if (isLuckyTicket(ticket))
        cout << "YES" << endl;
    else cout << "NO" << endl;

	return 0;
}


#include <stdio.h>
int main()
{
	long double a, x, m, m1;
	 int sum = 0, sum1 = 0;
	scanf("%Lf", &x);
	scanf("%Lf", &a);
	m = x / 2;
	for (int i = 0; i < m; i++){
		m1 = a % 10;
		a = a / 10;
		if (m1 == 4 || m1 == 7)sum = sum + m1;
	}
	for (int j = 0; j < m; j++){
		m1 = a % 10;
		a = a / 10;
		if (m1 == 4 || m1 == 7)sum1 = sum1 + m1;
	}

	if (sum == sum1)printf("YES");
	else printf("NO");
	return 0;
}


#include <stdio.h>
main()
{int i,a=0,s=0,t=0,n,c;
scanf("%d",&n);
for(i=1;i<=n;i++)
{ scanf("%d",&c);
   if    (c!=4 && c!=7)
             a++;
 else
       i>n/2?s+=c:t+=c;}
   if(s==t)
printf(a==0?"YES":"NO");
else
puts("NO");
return 0;}


/* 20160803 JJA Codeforces */
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
int main() {
	int n, c;
	int *arrP;
	int *arrT;
	int Limak=0;
	int Radewoosh=0;
	int t;
	scanf("%d %d", &n, &c);
	arrP = (int*)malloc(sizeof(int)*n);
	arrT = (int*)malloc(sizeof(int)*n);
	for (int i = 0; i < n; i++) scanf("%d", &arrP[i]);
	for (int i = 0; i < n; i++) scanf("%d", &arrT[i]);
	t = 0;
	for (int i = 0; i < n; i++) {
		t += arrT[i];
		Limak += max(0,arrP[i] - (t*c));
	}
	t = 0;
	for (int i = n - 1; i >= 0; i--) {
		t += arrT[i];
		Radewoosh += max(0, arrP[i] - (t*c));
	}
	if (Limak > Radewoosh) printf("Limak");
	else if (Limak < Radewoosh) printf("Radewoosh");
	else printf("Tie");
	return 0;
}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="20160329_1" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin\Debug\20160329_1" 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\20160329_1" 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 />
			<debugger />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


#include <stdio.h>

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

int main (void){
	int n, c, t[1010], p[1010], score_l = 0, score_r = 0, i, j, timeR = 0, timeL = 0;

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

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

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

	for(i = 0, j = n-1; i < n; i++, j--){
		//printf("pb : l : %d, r : %d\n", p[i],p[j]);
		//printf("c*p l : %d, c*p r : %d\n",p[i]-(c*t[i]),p[j]-(c*t[j]));
		timeL += t[i];
		timeR += t[j];
		score_l += max(0, p[i]-c*timeL);
		score_r += max(0, p[j]-c*timeR);
	}

	//printf("l  : %d\n r : %d\n", score_l, score_r);
	if(score_l > score_r)
			printf("Limak\n");

	else if(score_l < score_r)
			printf("Radewoosh\n");

	else
			printf("Tie");

	fclose(infp);

return 0;}


#include<stdio.h>
#include<algorithm>

using namespace std;
#define maxD 51

int maxim(int a,int b)
{
    if(a>b) return a;
    return b;
}

int main()
{

    int i,n,c,p[maxD],t[maxD],L,R;
    L=R=0;
    scanf("%d%d",&n,&c);

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

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

    int timp=0;
    for(i=0;i<n;++i)
    {
        timp+=t[i];
        L+=maxim(0,p[i]-c*timp);
    }

    timp=0;
     for(i=n-1;i>=0;--i)
    {
        timp+=t[i];
        R+=maxim(0,p[i]-c*timp);
    }

    if(L>R)
        printf("Limak");
    else if(L==R)
        printf("Tie");
    else
        printf("Radewoosh");
    return 0;
}


#include <string.h>
int main() {
    char kelime[1000]; int i;
    gets(kelime);
    for(i=0;i<strlen(kelime)-2;i++) {
        if(kelime[i]=='W' && kelime[i+1]=='U' && kelime[i+2]=='B') {
            kelime[i]=='\0'; && kelime[i+1]=='\0'; && kelime[i+2]=='\0';
        }
    }
    puts(kelime);
}