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

int main()
{
  int n,i,rem;
  vector<int> arr;
  vector<int> arr1;

  cin>>n;
  int l=0;
  int k=0;

  while(n!=0)
  {
    rem=n%10;

    arr.push_back(rem);
    if(n<10)
    {
      arr1.push_back(n-1);
    }
    else
    {
      arr1.push_back(9);
    }
    n=n/10;
  }
  reverse(arr.begin(),arr.end());
  reverse(arr1.begin(),arr1.end());
  int product =1;
  int ultimate=0;
  int j;
  if(arr[0]==1)
  {
    ultimate=pow(9, arr.size()-1);
  }
  else
  {
  for(i=0;i<arr.size();i++)
  {

    arr1[i]=arr[i]-1;
    for(j=0;j<arr.size();j++)
    {
      //if(arr1[i]!=0)
      product=product*arr1[j];
    }
    arr1[i]=arr[i];
    if(product>ultimate)
    {
      ultimate=product;
    }
    product=1;
  }}
  cout<<ultimate<<endl;
  return 0;

}
Chat conversation end
Type a message...


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

//srand(time(NULL));
//nombre_aleatoire = rand();

typedef struct cel
{
	int number;
	int value;
}cell;

int main ()
{
	int a,j=1,i=10,s=1,aux;
	cell t[11],max;
	scanf("%d",&a);

	t[0].number=a;
	aux=a;
	while(aux>=1)
	{
		s=s*(aux%10);
		aux=aux/10;
	}
	t[0].value=s;
	while(a/i!=0)
	{

		s=1;
		aux=a;
		aux=aux-(aux%i+1);
		t[j].number=aux;

		while(aux>=1)
		{
			s=s*(aux%10);
			aux=aux/10;
		}
		t[j].value=s;
		j++;
		i=i*10;
	}
	max.value=t[0].value;
	max.number=0;
	for(i=0;i<j;i++)
	{
		if(t[i].value>max.value)
		{
			max.value=t[i].value;
			max.number=i;
		}

	}
	printf("%d\n",max.value);

}


#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
typedef long long ll;
using namespace std;
int num[120];
int main()
{
    int n,i,m;
    memset(num,0,sizeof(num));
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++)
    {
        int x;
        scanf("%d",&x);
        num[x]++;
    }
    int ans=0;
    int j;
    for(i=1;i<=100;i++)
    {
        int sum=0;
        for(j=1;j<=100;j++)
        {
            sum+=num[i]/i;
        }
        if(sum>=n)
            ans=i;
        else break;
    }
    printf("%d\n",ans);

    return 0;
}


#include <iostream>
using namespace std;
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    int L[n1], R[n2];

    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        int m = l+(r-l)/2;

        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

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

int main()
{
    int i,j,n,m;
    cin>>n>>m;
    int c[n],b[m];
    for(i=0;i<n;i++)
    {
        cin>>c[i];
    }
    for(i=0;i<m;i++)
    {
        cin>>b[i];
    }
    int st=0,count=0;
    for(i=0;i<m;i++)
    {
        for(j=st;j<n;j++)
        {
            if(b[i]>=c[j])
            {
                count++;
                st=j+1;
                break;
            }
        }
        if(j==n)
            break;
    }
    cout<<count;

}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define G1I(i) int i; scanf("%d",&i)
#define G2I(i,j) int i,j; scanf("%d%d",&i,&j)
#define G3I(i,j,k) int i,j,k ; scanf("%d%d%d",&i,&j,&k)
#define g1i(i) scanf("%d",&i)
#define g2i(i,j) scanf("%d%d",&i,&j)
#define g3i(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define G1C(c) char c; scanf("%c",&c)
#define g1c(c) scanf("%c",&c)
#define G1S(s,len) char s[len]; scanf("%s",s)
#define Fin(i,m,n) for(int i = m;i < n;i++)
#define lli long long int
#define G1lli(i) lli i; scanf("%I64d",&i);
#define G2lli(i,j) lli i,j,k; scanf("%I64d%I64d",&i,&j);
#define G3lli(i,j,k) lli i,j,k; scanf("%I64d%I64d%I64d",&i,&j,&k);
#define g1lli(i) scanf("%I64d",&i)
#define g2lli(i,j) scanf("%I64d%I64d",&i,&j)
#define g3lli(i,j,k) scanf("%I64d%I64d%I64d",&i,&j,&k)
#define P1I(i) printf("%d",i)

int Types[101];

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

int main(){
	G2I(n,m);
	int cnt = 0;
	Fin(i,0,m){
		G1I(type);
		if(Types[type] == 0) cnt++;
		Types[type]++;
	}
	qsort(Types,101,sizeof(int),compare);
	int days = 0;
	int eat[n];
	Fin(i,0,n) eat[i] = i;
	while(1){
		int flag = 1;
		Fin(i,0,n){
			if(Types[eat[i]] > 0){
				Types[eat[i]]--;
			}else{
				flag = 0;
				Fin(j,0,cnt){
					if(Types[j] - days - 1 >= 0){
						Types[j] -= days + 1;
						Types[eat[i]] += days;
						eat[i] = j;
						flag = 1;
						break;
					}
				}
				if(!flag) break;
			}
		}
		if(!flag) break;
		days++;h
	}
	P1I(days);
	return 0;
}


#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int count[2000] ={0};
    int arr[1000] ={0};
    int n,m,i;
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&arr[i]);
        count[arr[i]]++;
    }
    int max = m/n;
    int brr[1000];
    int b = 0;
    for(i=0;i<200;i++){
        if(count[i]>0){
            brr[b]=i;
            b++;
        }
    }

    if(b>=n){
        max = 0;
        for(i=0;i<n;i++){
            max = max + count[brr[i]];
        }
    }
    while(max>=0){
        int f = 0;
        for(i=0;i<n;i++){
            f = f + count[brr[i]]/max;
        }
        if(f>=n){
            printf("%d\n",max);
            break;
        }
        max = max - 1;
    }

}


#include <stdio.h>
#include <stdlib.h>
#define MAX 101

int main() {
	int i, aux, temp;
	int n, m, k;
	int vec[MAX] = {0};

	// reding the number of participants and the number of food packages
	scanf("%d %d", &n, &m);

	// storing the quantity of each element in the array, using the value itself as an index (0 based array)
	for (i = 0; i < m; i++) {
		scanf("%d", &aux);

		vec[aux - 1]++;
		// printf("%d\n", vec[aux - 1]);
	}

	// this outerloop will go from the greatest possible number of days
	// to the least one
	for (i = MAX - 1; i >= 0; i--) {
		k = 0;

		// this innerloop will go through all of the elements in the array
		for (aux = 0; aux < MAX; aux++) {

			temp = vec[aux];
			// this inner loop will check how many times the current element can fit
			// into the number of days
			while(temp >= i) {
				k++;
				temp -= i;
			}
		}

		// here we verify if the number of people fed is at least equal to the number
		// of participants
		if (k >= n) {
			printf("%d\n", i);

			return 0;
		}
	}

	printf("0\n");

	return 0;
}


include <stdio.h>

struct {
	char valor, naipe;
	valor = 0;
	naipe = 0;
} card ;

int main(){
	struct card* primeira, segunda;
	char trunfo, c;
	scanf ("%c", &trunfo);
	scanf ("%c", &c);
	scanf ("%c", &c);
	primeira->valor = c;
	scanf ("%c", &c);
	primeira->naipe = c;
	scanf ("%c", &c);
	segunda->valor = c;
	scanf ("%c", &c);
	segunda->valor = c;
	if (primeira->naipe == trunfo){
		if (segunda->naipe != trunfo)
			printf ("YES");
		else {
			if (primeira->valor > segunda->valor)
				printf ("YES");
			else
				printf ("NO");
		}

	}
	else {
		if (segunda->naipe == trunfo)
			printf ("NO");
		else {
			if (primeira->valor > segunda->valor)
				printf ("YES");
			else
				printf ("NO");
		}
	}
return 0;
}


#include <stdio.h>

struct carta{
	int valor
	char naipe;
	carta.valor = 0;
	carta.naipe = 0;
}

int main(){
	struct carta primeira;
	struct carta segunda;
	char trunfo, c;
	scanf ("%c", &trunfo);
	scanf ("%c", &c);
	scanf ("%c", &c);
	switch (c){
		case 'T':
			primeira.valor = 10;
			break;
		case 'J':
			primeira.valor = 11;
			break;
		case 'Q':
			primeira.valor = 12;
			break;
		case 'K':
			primeira.valor = 13;
			break;
		case 'A':
			primeira.valor = 14;
			break;
	}
	scanf ("%c", &c);
	primeira.naipe = c;
	scanf ("%c", &c);
	switch (c){
		case 'T':
			segunda.valor = 10;
			break;
		case 'J':
			segunda.valor = 11;
			break;
		case 'Q':
			segunda.valor = 12;
			break;
		case 'K':
			segunda.valor = 13;
			break;
		case 'A':
			segunda.valor = 14;
			break;
	}
	scanf ("%c", &c);
	segunda.valor = c;
	if (primeira.naipe == trunfo){
		if (segunda.naipe != trunfo)
			printf ("YES");
		else {
			if (primeira.valor > segunda.valor)
				printf ("YES");
			else
				printf ("NO");
		}

	}
	else {
		if (segunda.naipe == trunfo)
			printf ("NO");
		else {
			if (primeira.valor > segunda.valor)
				printf ("YES");
			else
				printf ("NO");
		}
	}
return 0;
}


#include <stdio.h>

struct {
	char valor, naipe;
	valor = '0';
	naipe = '0';
} card ;

int main(){
	struct card primeira;
	struct card segunda;
	char trunfo, c;
	scanf ("%c", &trunfo);
	scanf ("%c", &c);
	scanf ("%c", &c);
	primeira.valor = c;
	scanf ("%c", &c);
	primeira.naipe = c;
	scanf ("%c", &c);
	segunda.valor = c;
	scanf ("%c", &c);
	segunda.valor = c;
	if (primeira.naipe == trunfo){
		if (segunda.naipe != trunfo)
			printf ("YES");
		else {
			if (primeira.valor > segunda.valor)
				printf ("YES");
			else
				printf ("NO");
		}

	}
	else {
		if (segunda.naipe == trunfo)
			printf ("NO");
		else {
			if (primeira.valor > segunda.valor)
				printf ("YES");
			else
				printf ("NO");
		}
	}
return 0;
}


#include <stdio.h>

struct {
	char valor, naipe;
	carta.valor = 0;
	carta.naipe = 0;
} carta ;

int main(){
	struct carta primeira;
	struct carta segunda;
	char trunfo, c;
	scanf ("%c", &trunfo);
	scanf ("%c", &c);
	scanf ("%c", &c);
	primeira.valor = c;
	scanf ("%c", &c);
	primeira.naipe = c;
	scanf ("%c", &c);
	segunda.valor = c;
	scanf ("%c", &c);
	segunda.valor = c;
	if (primeira.naipe == trunfo){
		if (segunda.naipe != trunfo)
			printf ("YES");
		else {
			if (primeira.valor > segunda.valor)
				printf ("YES");
			else
				printf ("NO");
		}

	}
	else {
		if (segunda.naipe == trunfo)
			printf ("NO");
		else {
			if (primeira.valor > segunda.valor)
				printf ("YES");
			else
				printf ("NO");
		}
	}
return 0;
}


#include <stdio.h>

struct carta{
	int valor;
	char naipe;
	carta.valor = 0;
	carta.naipe = 0;
};

int main(){
	struct carta primeira;
	struct carta segunda;
	char trunfo, c;
	scanf ("%c", &trunfo);
	scanf ("%c", &c);
	scanf ("%c", &c);
	switch (c){
		case 'T':
			primeira.valor = 10;
			break;
		case 'J':
			primeira.valor = 11;
			break;
		case 'Q':
			primeira.valor = 12;
			break;
		case 'K':
			primeira.valor = 13;
			break;
		case 'A':
			primeira.valor = 14;
			break;
	}
	scanf ("%c", &c);
	primeira.naipe = c;
	scanf ("%c", &c);
	switch (c){
		case 'T':
			segunda.valor = 10;
			break;
		case 'J':
			segunda.valor = 11;
			break;
		case 'Q':
			segunda.valor = 12;
			break;
		case 'K':
			segunda.valor = 13;
			break;
		case 'A':
			segunda.valor = 14;
			break;
	}
	scanf ("%c", &c);
	segunda.valor = c;
	if (primeira.naipe == trunfo){
		if (segunda.naipe != trunfo)
			printf ("YES");
		else {
			if (primeira.valor > segunda.valor)
				printf ("YES");
			else
				printf ("NO");
		}

	}
	else {
		if (segunda.naipe == trunfo)
			printf ("NO");
		else {
			if (primeira.valor > segunda.valor)
				printf ("YES");
			else
				printf ("NO");
		}
	}
return 0;
}


#include<stdio.h>

int main()
{
    unsigned long long n,m,k,left,right,mid,temp;

    scanf("%I64u",&m);
    left=0;
    right=(long long)0xffffffffffffffff;
    while(left<right)
    {
        mid=(right-left)/2+left;
        n=mid;
        k=2;
        temp=0;
        while(n/(k*k*k))
        {
            temp+=n/(k*k*k);
            k++;
        }
        if(temp<m)left=mid+1;
        else right=mid;
    }
    n=left;
    k=2;
    temp=0;
    while(n>=k*k*k)
    {
        temp+=n/(k*k*k);
        k++;
    }
    if(temp==m)printf("%I64u\n",n);
    else printf("-1\n");

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
int main(){
	unsigned long long m,temp,sum,numb,high,low,mid,min,i,j,sqr;
	scanf("%"PRIu64,&m);
	high=m*8+1;
	low=1;
	min=high+1;
	while ((high-low)>1){
		//printf("%"PRIu64" %"PRIu64,high,low);
		sum=0;
		mid = (high+low)/2;
		for(i=0;i<mid;i++)if (i*i*i>=mid)break;
		sqr = i;
		//printf(" %"PRIu64,sqr);
		for(j=2;j<=sqr;j++){
			temp=j*j*j;
			numb=mid/temp;
			sum+=numb;
		}
		//printf(" %"PRIu64"\n",sum);
		if (sum==m) if (mid < min) min = mid;
		if(sum>=m)high=mid;
		else low = mid;
	}
	if(min<(8*m+1))printf("%"PRIu64,min);
	else printf("-1");
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
	long long int c,m,k=2,p,s=0,i,a,b,power[100005]={0,1};
	scanf("%lld",&m);
	for(i=1;i<100005;i++)
	power[i]=pow(i,3);
	while(s<m)
	{
		s=0;
		p=power[k];
		for(i=2;i<=k;i++)
		s=s+p/power[i];
		k++;
	}
	if(s==m)
	printf("%lld\n",p);
	else
	{
		a=power[k-2];
		b=power[k-1];
		for(i=a;i<=b;i++)
		{
			c=2;
			s=0;
			while(i/power[c]>0)
			{
				s=s+i/power[c];
				c++;
			}
			if(s>=m)
			break;
		}
		if(s==m)
		printf("%lld\n",i);
		else
		printf("-1\n");
	}
	return 0;
}


#include<stdio.h>

int main()
{
    long long n,m,k,left,right,mid,temp;

    scanf("%I64d",&m);
    left=0;
    right=0x7fffffff;
    while(left<right)
    {
        mid=(right-left)/2+left;
        n=mid;
        k=2;
        temp=0;
        while(n/(k*k*k))
        {
            temp+=n/(k*k*k);
            k++;
        }
        if(temp<m)left=mid+1;
        else right=mid;
    }
    n=left;
    k=2;
    temp=0;
    while(n>=k*k*k)
    {
        temp+=n/(k*k*k);
        k++;
    }
    if(temp==m)printf("%I64d\n",n);
    else printf("-1\n");

    return 0;
}


#include<stdio.h>
int main()
{
	long long int c,m,k=2,p,s=0,i,a,b,power[100005]={0,1};
	scanf("%lld",&m);
	for(i=1;i<100005;i++)
	power[i]=i*i*i;
	while(s<m)
	{
		s=0;
		p=power[k];
		for(i=2;i<=k;i++)
		s=s+p/power[i];
		k++;
	}
	if(s==m)
	printf("%lld\n",p);
	else
	{
		a=power[k-2];
		b=power[k-1];
		for(i=a;i<=b;i++)
		{
			c=2;
			s=0;
			while(i/power[c]>0)
			{
				s=s+i/power[c];
				c++;
			}
			if(s>=m)
			break;
		}
		if(s==m)
		printf("%lld\n",i);
		else
		printf("-1\n");
	}
	return 0;
}


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

main()
{
    int n,i,y,t;
    char a;
    scanf("%d%c", &n, &a);
    y=n/4;
    if (n%4!=0)
    {
        t=y*14;
        if (n%2==0)#include <stdio.h>
#include <stdlib.h>

main()
{
    int n,i,y,t;
    char a;
    scanf("%d%c", &n, &a);
    y=n/4;
    if (n%4!=0)
    {
        t=y*14;
        if (n%2==0)
        {
            t+=7;
            switch (a)
            {
                case 'a':
                {
                    t+=4;
                    break;
                }
                case 'b':
                {
                    t+=5;
                    break;
                }
                case 'c':
                {
                    t+=6;
                    break;
                }
                case 'd':
                {
                    t+=3;
                    break;
                }
                case 'e':
                {
                    t+=2;
                    break;
                }
                case 'f':
                {
                    t+=1;
                    break;
                }
            }
        }
        else
        {
            switch (a)
            {
                case 'a':
                {
                    t+=4;
                    break;
                }
                case 'b':
                {
                    t+=5;
                    break;
                }
                case 'c':
                {
                    t+=6;
                    break;
                }
                case 'd':
                {
                    t+=3;
                    break;
                }
                case 'e':
                {
                    t+=2;
                    break;
                }
                case 'f':
                {
                    t+=1;
                    break;
                }
            }
        }
    }
    else
    {
        y--;
        t=y*13;
        if (n%2==0)
        {
            t+=7;
            switch (a)
            {
               case 'a':
                {
                    t+=4;
                    break;
                }
                case 'b':
                {
                    t+=5;
                    break;
                }
                case 'c':
                {
                    t+=6;
                    break;
                }
                case 'd':
                {
                    t+=3;
                    break;
                }
                case 'e':
                {
                    t+=2;
                    break;
                }
                case 'f':
                {
                    t+=1;
                    break;
                }
            }
        }
        else
        {
            switch (a)
            {
                case 'a':
                {
                    t+=4;
                    break;
                }
                case 'b':
                {
                    t+=5;
                    break;
                }
                case 'c':
                {
                    t+=6;
                    break;
                }
                case 'd':
                {
                    t+=3;
                    break;
                }
                case 'e':
                {
                    t+=2;
                    break;
                }
                case 'f':
                {
                    t+=1;
                    break;
                }
            }
        }
    }
    printf("%d", t);
}
        {
            t+=7;
            switch (a)
            {
                case 'a':
                {
                    t+=4;
                    break;
                }
                case 'b':
                {
                    t+=5;
                    break;
                }
                case 'c':
                {
                    t+=6;
                    break;
                }
                case 'd':
                {
                    t+=3;
                    break;
                }
                case 'e':
                {
                    t+=2;
                    break;
                }
                case 'f':
                {
                    t+=1;
                    break;
                }
            }
        }
        else
        {
            switch (a)
            {
                case 'a':
                {
                    t+=4;
                    break;
                }
                case 'b':
                {
                    t+=5;
                    break;
                }
                case 'c':
                {
                    t+=6;
                    break;
                }
                case 'd':
                {
                    t+=3;
                    break;
                }
                case 'e':
                {
                    t+=2;
                    break;
                }
                case 'f':
                {
                    t+=1;
                    break;
                }
            }
        }
    }
    else
    {
        y--;
        t=y*13;
        if (n%2==0)
        {
            t+=7;
            switch (a)
            {
               case 'a':
                {
                    t+=4;
                    break;
                }
                case 'b':
                {
                    t+=5;
                    break;
                }
                case 'c':
                {
                    t+=6;
                    break;
                }
                case 'd':
                {
                    t+=3;
                    break;
                }
                case 'e':
                {
                    t+=2;
                    break;
                }
                case 'f':
                {
                    t+=1;
                    break;
                }
            }
        }
        else
        {
            switch (a)
            {
                case 'a':
                {
                    t+=4;
                    break;
                }
                case 'b':
                {
                    t+=5;
                    break;
                }
                case 'c':
                {
                    t+=6;
                    break;
                }
                case 'd':
                {
                    t+=3;
                    break;
                }
                case 'e':
                {
                    t+=2;
                    break;
                }
                case 'f':
                {
                    t+=1;
                    break;
                }
            }
        }
    }
    printf("%d", t);
}


int main(void) {
    int seats[6] = {4, 5, 6, 3, 2, 1};
    int row, seat;
    scanf("%d%c", &row, &seat);
    row--;
    printf("%d", row / 4 * 16 + n % 2 * 7 + seats[seat - 'a']);
}


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

#define ll long long

char seat[20];

int colRet(char ch);

int main(void)
{
    ll len, rem = 0, lastDigits, ans = 0;
    char col;
    scanf("%s", seat);

    len = (ll)strlen(seat);
    col = seat[len-1];

    for(ll i = 0; i < len - 1; i++)
    {
        rem *= 10;
        rem += seat[i] - '0';
    }

    ans = (rem / 4) * 16;

    lastDigits = rem % 4;

    if (lastDigits == 1 || lastDigits == 3)
    {
        ans += colRet(col);
    }
    else if (lastDigits == 2 || lastDigits == 4)
    {
        ans += 7 + colRet(col);
    }

    printf("%I64d\n", ans);

    return 0;
}


#include <stdio.h>

int main(void)
{
  char c;
  char znak[400];
  int krok = 0;
  int i = 0;
  int zavynac = 0;

  while ((c = getchar()) != EOF){
    znak[i] = c;
    i++;
  }
  int maxi = i;

  for (i = 0; i < maxi; i++){
    if (i > 0){
      if ((znak[i] == 'd') && (znak[i + 1] == 'o') && (znak[i + 2] == 't') && ((i + 4) != maxi)){
        putchar('.');
        i++;
        i++;
      } else if ((znak[i] == 'a') && (znak[i + 1] == 't') && (zavynac == 0)){
        putchar('@');
        zavynac++;
        i++;
      } else {
        putchar(znak[i]);
      }
    } else {
      putchar(znak[i]);
    }
  }

  return 0;
}


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

int i,lenght,ok_at;
char s[101];

int main()
{
   scanf("%s",&s);
    lenght=strlen(s);

    for(i=1;i<lenght-2;i++)
    {

     if(s[i]=='d' && i<lenght-3)
            if(s[i+1]=='o' && s[i+2]=='t')
            {

                s[i]='.';
                 strcpy(s+i+1,s+i+3);
                 lenght-=2;

            }
        if(s[i]=='a' && ok_at==0)
            if(s[i+1]=='t')
                {
                    s[i]='@';
                    strcpy(s+i+1,s+i+2);
                    ok_at=1;
                    lenght-=1;

                }

    }
printf("%s",s);

    return 0;
}


#include<stdio.h>
#include<math.h>
int main ()
{
    int a,b,sum,max=0,p,x,y,ans,i,c;
    scanf("%d %d",&a,&b);
    x=a;
    y=b;
    while(a)
    {
        p=a%10;
        if(p>max)
            max=p;
        a=a/10;
    }
    while(b)
    {
        p=b%10;
        if(p>max)
            max=p;
        b=b/10;
    }
    max++;
    i=0;
    a=0;
    while(x)
    {
        c=x%10;
        a=a+(c*ceil(pow(max,i)));
        i++;
        x=x/10;
    }
    b=0;
    i=0;
    while(y)
    {
        c=y%10;
        b=b+(c*ceil(pow(max,i)));
        i++;
        y=y/10;
    }
    sum=a+b;
    ans=ceil(log(sum+1)/log(max));
    printf("%d\n",ans);
}


int pow(int a,int b)
{
    int ans=1,i;
    for(i=0;i<b;i++)
    {
                    ans*=a;
    }
    return ans;
}
int sum(int a,int b,int base)
{
    int i,ans=0;
    i=0;

    while(a>0)
    {
           ans+=pow(base,i)*(a%10);
           // printf("ans=%d ",pow(base,i));
           a/=10;
           i++;
    }
    i=0;
    while(b>0)
    {
           ans+=(int)pow(base,i)*(b%10);
           //printf("ans=%d ",ans);
           b/=10;
           i++;
    }
    //printf("ans=%d ",ans);
    return ans;
}
int leng(int n,int base)
{
    int c=0;
    if(n>9)
    return 0;
    else
    return 1;
    return c;
}

int m(int a)
{
    int ma=0;
    while(a!=0)
    {
             if(ma<a%10)
             {
                        ma=a%10;
             }
             a/=10;
    }
    return ma;
}
int bin(int a,int s)
{
    int c=0;
    while(a!=0)
    {
               c+=leng(a%s,s);
              // printf("%d  ",a%s);
               a/=s;
    }
    //printf("\n");
    return c;
}

int main()
{
    int a,b;
    int s;
    int n,i;
    int ans=0;
    scanf("%d %d",&a,&b);
    //n=sum(a,b);
    s=m(a)>m(b)?(m(a)+1):(m(b)+1);
    //printf("%d",s);
    for(i=s;i<=16;i++)
    {
    n=sum(a,b,i);
   // printf("%dsdssd",n);
    if(ans<bin(n,i))
                    ans=bin(n,i);
    }
     // printf("%dlll",bin(n,16));
    printf("%d",ans);
    scanf("%*d");
    return 0;
}


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

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

int main(void) {
	char a[5];
	char b[5];

	scanf("%s%s", &a, &b);

	int a_length = strlen(a);
	int b_length = strlen(b);

	int max_digit = 0;
	int i;
	for (i = 0; i < a_length; i++) {
		a[i] -= '0';
		max_digit = max(max_digit, a[i]);
	}

	for (i = 0; i < b_length; i++) {
		b[i] -= '0';
		max_digit = max(max_digit, b[i]);
	}

	int base = max_digit + 1;

	i = a_length - 1;
	int j = b_length - 1;
	int carry = 0;
	int sum;
	while (i >= 0 || j >= 0) {
		sum = 0;
		if (i >= 0) { sum += a[i]; i--; }
		if (j >= 0) { sum += b[j]; j--; }
		sum += carry;
		carry = sum / base;
	}

	int result = max(a_length, b_length);
	if (carry) result++;

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

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
   int a[101]={0},b[101]={0},ans[101]={0};
   int i,j,k,temp,la,lb,max;
   char t[101]={'0'};
   k=0;
   scanf("%s",t);
   max=0;
   la=strlen(t);
   for (i=la;i>=1;i--)
   {
     a[la-i+1]=t[i-1]-'0';
     if (a[la-i+1]>max) max=a[la-i+1];
   }
   scanf("%s",t);
   lb=strlen(t);
   for (i=lb;i>=1;i--)
   {
     b[lb-i+1]=t[i-1]-'0';
     if (b[lb-i+1]>max) max=b[lb-i+1];
   }
   max++;
   if (la>lb) k=la;
           else   k=lb;
    temp=0;
   for (i=1;i<=k;i++)
    {
       ans[i]=a[i]+b[i]+temp;
       temp=ans[i] / max;
       ans[i]=ans[i] % max;
    }
   if (temp!=0) {k++; ans[k]=temp;}
    printf("%d",k);
   return 0;
}


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

int main() {
	long long n;
	while (scanf("%lld", &n) == 1)
		printf("%lld\n", n-1);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	long long int n;
	cin>>n;
	a=1;
	b=1;
	c=0;
	k=a+b;
	while(k<=n)
	{   c++;
	    a=b;
	  	b=k;
	  k=a+b;
	}
    cout<<(c)<<endl;
	return 0;
}


#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;

typedef long long LL;
ll a[120];

int main ()
{
    ll n;
    A[1] = 2;
    A[2] = 3;
    scanf ("%lld", &n);
    for (int i = 3; i < i++)
    {
        A[i] = a[i-1] + a[i-2];
    }
    for (int i = 1; i < i++)
    {
        if (A[i] > N)
        {
            printf ("%d\n", i-1);
            break;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	long n;
	cin>>n;
	a=1;
	b=1;
	c=0;
	k=a+b;
	while(k<=n)
	{   c++;
	    a=b;
	  	b=k;
	  k=a+b;
	}
    cout<<(c)<<endl;
	return 0;
}


#include<stdio.h>
#include<string.h>
struct string{
	char str[1000];
	int count[1000];
};
int main()
{
	struct string s;
	scanf("%s",&s.str);
	int i,j,k;
	scanf("%d",&k);
	int len=strlen(s.str);
	for(i=0;i<len;i++)
	{
		s.count[i]=1;
	}
	int count1=0,count2=0;
	for(i=0;i<len;i++)
	{
		if(s.str[i]=='?')
		{
			s.count[i]=0;
			s.count[i-1]=0;
			count1++;
		}
	}
	for(i=0;i<len;i++)
	{
		if(s.str[i]=='*')
		{
			s.count[i]=0;
			s.count[i-1]=0;
			count2++;
		}
	}
	int c;
	c=2*(count1+count2);
	int req_len;
	req_len=len-c;
	if(k<req_len)
	{
		printf("Impossible");
	}
	else{
		k=k-req_len;
		i=0;
		while(k!=0 && i<len)
		{
			if(s.str[i]=='?')
			{
				s.count[i-1]++;
				k--;
			}
			else if(s.str[i]=='*')
			{
				for(j=0;j<k;j++)
				{
					s.count[i-1]++;
				}
				k=0;
			}
			i++;
		}
		if(k!=0)
		{
			printf("Impossible");
		}
		else{
			for(i=0;i<len;i++)
			{
				for(j=0;j<s.count[i];j++)
				{
					printf("%c",s.str[i]);
				}
			}
		}
	}
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdbool.h>
#define N 205
int main(void)
{
    int i,j,print,star=0,count1=0,count2=0,length;
    bool yn[N];
    char line[N];
    gets(line);
    scanf("%d",&length);
    for(i=0; i<N; i++)
        yn[i]=true;
    for(i=0; line[i]; i++)
    {
        if(line[i]>='a'&&line[i]<='z')
            count1++;
        else
            count2++;
        if(line[i]=='*')
            star++;
    }
    if(length<count1-count2)
        printf("Impossible\n");
    else if(length>count1&&!star)
        printf("Impossible\n");
    else
    {
        if(length>count1)
        {
            print=length-count1;
            for(i=0; i<line[i]; i++)
            {
                if(line[i]>='a'&&line[i]<='z')
                    printf("%c",line[i]);
                if(line[i]=='?')
                    i++;
                else
                    while(print--)
                        printf("%c",line[i-1]);
            }
            printf("\n");
        }
        if(count1==length)
        {
            for(i=0; i<line[i]; i++)
                if(line[i]>='a'&&line[i]<='z')
                    printf("%c",line[i]);
            printf("\n");
        }
        else
        {
            print=count1-length;
            for(i=0; line[i]; i++)
            {
                if(line[i]=='?'||line[i]=='*')
                    yn[i]=false;
                if((line[i]=='?'||line[i]=='*')&&print)
                {
                    yn[i-1]=false;
                    print--;
                }
            }
            for(i=0; line[i]; i++)
                if(yn[i])
                    printf("%c",line[i]);
            printf("\n");
        }
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdbool.h>
#define N 205
int main(void)
{
    int i,j,print,star=0,count1=0,count2=0,length;
    bool yn[N];
    char line[N];
    gets(line);
    scanf("%d",&length);
    for(i=0; i<N; i++)
        yn[i]=true;
    for(i=0; line[i]; i++)
    {
        if(line[i]>='a'&&line[i]<='z')
            count1++;
        else
            count2++;
        if(line[i]=='*')
            star++;
    }
    if(length<count1-count2)
        printf("Impossible\n");
    else if(length>count1&&!star)
        printf("Impossible\n");
    else
    {
        if(length>count1)
        {
            print=length-count1;
            for(i=0; i<line[i]; i++)
            {
                if(line[i]>='a'&&line[i]<='z')
                    printf("%c",line[i]);
                else if(line[i]=='?')
                    i++;
                else
                    while(print--)
                        printf("%c",line[i-1]);
            }
            printf("\n");
        }
        if(count1==length)
        {
            for(i=0; i<line[i]; i++)
                if(line[i]>='a'&&line[i]<='z')
                    printf("%c",line[i]);
            printf("\n");
        }
        else
        {
            print=count1-length;
            for(i=0; line[i]; i++)
            {
                if(line[i]=='?'||line[i]=='*')
                    yn[i]=false;
                if((line[i]=='?'||line[i]=='*')&&print)
                {
                    yn[i-1]=false;
                    print--;
                }
            }
            for(i=0; line[i]; i++)
                if(yn[i])
                    printf("%c",line[i]);
            printf("\n");
        }
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main ()
{
	char s[200];
	int n;
	int i,sqn,t=0,r,t1=0,f=0,j,num,num1;
	scanf("%s",s);
	scanf("%d",&n);
    sqn=strlen(s);
	for(i=0;i<n;i++)
	{
    	if(s[i]=='?')
		{
			t++;
		}
		else if (s[i]=='*')
		{
			t1++;
		}
		else  continue;
	}
	r=sqn-t1-t;
	if(r==n)
	{
		for(i=0;i<sqn;i++)
		{
			if(s[i]!='?'&&s[i]!='*')
	    	printf("%c",s[i]);
		}
			putchar('\n');
	}
	else if(r<n)
	{
		if(t1>0)
		{
			num=n-r;
			for(i=0;i<sqn;i++)
			{
				if(s[i]!='*'&&s[i]!='?')
					printf("%c",s[i]);
				if(s[i]=='*'&&f==0)
				{
					for(j=0;j<num;j++)
						printf("%c",s[i-1]);
					f=1;
				}
			}
			putchar('\n');
		}
    	else
			printf("Impossible\n");
	}
	else
	{
		num1=r-n;
		if(t+t1<num1)
			printf("Impossible\n");
		else
		{
			for(i=0;i<sqn;i++)
			{
				if(num1!=0&&(s[i+1]='*'||s[i+1]='?'))
					num1--;
				else if (s[i]=='*'||s[i]=='?')
					continue;
				else
					printf("%c",s[i]);

			}
			putchar('\n');
		}
	}
	return 0;
}


#include <stdio.h>
#define MOD 998244353

__int64 Pow(__int64 a, __int64 b)
{
    __int64 half;
    if(b == 0) return 1;
    if(b % 2 == 1) return (Pow(a, b-1)*a) % MOD;
    half = Pow(a, b/2) % MOD;
    return (half * half) % MOD;
}
__int64 nCr(__int64 n, __int64 r)
{
    __int64 A = 1; // A = n!, B = (n-r)!r!
    __int64 B = 1;
    __int64 ans;
    __int64 i;

    for(i=1;i<=n;i++)
    {
        A *= i;
        A %= MOD;
    }
    for(i=1;i<=n-r;i++)
    {
        B *= i;
        B %= MOD;
    }
    for(i=1;i<=r;i++)
    {
        B *= i;
        B %= MOD;
    }
    __int64 B2 = Pow(B, MOD-2);
    ans = (A * B2) % MOD;
    return ans;
}

int main(void)
{
    __int64 size, max;
    __int64 ans;

    scanf("%lld %lld", &size, &max);

    ans = nCr(max, size - 1) * (size-2) % MOD;
    ans = (ans * Pow(2, size-3)) % MOD;
    printf("%lld\n", ans);

    return 0;
}


#include <stdio.h>
#define MOD 998244353

__int64 Pow(__int64 a, __int64 b)
{
    __int64 ans=1;
    __int64 i;
    if (b == 0) return 1;
    for(i=0;i<b;i++)
    {
        ans *= a ;
        ans %= MOD;
    }
    return ans;
}
__int64 nCr(__int64 n, __int64 r)
{
    __int64 A = 1; // A = n!, B = (n-r)!r!
    __int64 B = 1;
    __int64 ans;
    __int64 i;

    for(i=1;i<=n;i++)
    {
        A *= i;
        A %= MOD;
    }
    for(i=1;i<=n-r;i++)
    {
        B *= i;
        B %= MOD;
    }
    for(i=1;i<=r;i++)
    {
        B *= i;
        B %= MOD;
    }
    __int64 B2 = Pow(B, MOD-2);
    ans = (A * B2) % MOD;
    return ans;
}

int main(void)
{
    __int64 size, max;
    __int64 ans;

    scanf("%lld %lld", &size, &max);

    ans = nCr(max, size - 1) * (size-2) % MOD;
    ans = (ans * Pow(2, size-3)) % MOD;
    printf("%lld\n", ans);

    return 0;
}


#include <stdio.h>
#define SIZE 200000

int factorial(int n)
{
    if(n == 1) return 1;
    return n*factorial(n-1);
}

int countArr(int arr[], int size, int max)
{
    int result = 0;
    int m, i;

    for(m=size-1;m<max;m++) //middle's min is size-1
    {
        for(i=0;i<m-1;i++)
        {
            result += factorial(m-1)/(factorial(m-i-2) * factorial(i));
        }

    }
    return result;
}

int main(void)
{
    int size, max, result;
    int arr[SIZE];
    while(scanf("%d %d", &size, &max))
    {
        printf("%d\n", countArr(arr, size, max));
    }

    return 0;
}


#include <stdio.h>
#define SIZE 200000

__int64 factorial(int n)
{
    if(n == 0) return 1;
    if(n == 1) return 1;
    return n*factorial(n-1);
}

__int64 countArr(int size, int max)
{
    __int64 result = 0;
    __int64 temp;
    int m, i;

    for(m=size-1;m<=max;m++) //middle's min is size-1
    {
        temp = 0;
        for(i=0;i<size-2;i++)
        {
            temp += factorial(m-2)/(factorial(m-i-2) * factorial(i));
        }
        result += temp * (m-1);
    }
    return result;
}

int main(void)
{
    int size, max;

    while(scanf("%d %d", &size, &max))
    {
        printf("%lld\n", countArr(size, max));
    }

    return 0;
}


#include <stdio.h>
#define MOD 998244353

__int64 factorial(int n)
{
    __int64 i;
    __int64 result = 1;

    if(n == 0 || n == 1) return 1;

    for(i=2;i<=n;i++)
    {
        result *= i;
    }
    return result;
}

__int64 countArr(int size, int max)
{
    __int64 result = 0;
    __int64 temp;
    __int64 m, i;

    for(m=size-1;m<=max;m++) //middle's min is size-1
    {
        temp = 0;
        for(i=0;i<size-2;i++)
        {
            temp += factorial(m-2)/(factorial(m-i-2) * factorial(i));
        }
        result += temp * (m-1);
    }
    return result % MOD;
}

int main(void)
{
    __int64 size, max;

    scanf("%d %d", &size, &max);

    printf("%lld\n", countArr(size, max));

    return 0;
}


#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <complex.h>
#include <errno.h>
#include <time.h>
char s[5][105];
int xx[4][3]={{0,1,1},{0,1,1},{0,0,1},{0,0,1}},yy[4][3]={{0,0,1},{1,0,1},{0,1,1},{0,1,0}},
	i,j,a[5][105],l,ans;

void dfs(int x,int y)
{
	int i,j,f;

	if (y+(l-x)/2<=ans) return;
	if (x>=l)
	{
		ans=y>ans ? y : ans;
		return;
	}
	for (i=0;i<4;i++)
	{
		for (j=f=0;j<3;j++)
		if (a[xx[i][j]][x+yy[i][j]]||x+yy[i][j]>=l)
		{
			f=1;
			break;
		}
		if (!f)
		{
			for (j=0;j<3;j++) a[xx[i][j]][x+yy[i][j]]=1;
			dfs(x+1,y+1);
			for (j=0;j<3;j++) a[xx[i][j]][x+yy[i][j]]=0;
		}
	}
	dfs(x+1,y);
}

int main()
{
	scanf("%s%s",s[0],s[1]);
	l=strlen(s[0]);
	for (j=ans=0;j<2;j++)
	for (i=0;i<l;i++)
	if (s[j][i]=='0') a[j][i]=0; else a[j][i]=1;
	dfs(0,0);
	printf("%d\n",ans);
	return 0;
}


#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <complex.h>
#include <errno.h>
#include <time.h>
char s[5][105];
int xx[4][3]={{0,1,1},{0,1,1},{0,0,1},{0,0,1}},yy[4][3]={{0,0,1},{1,0,1},{0,1,1},{0,1,0}},
	i,j,a[5][105],l,ans;

void dfs(int x,int y)
{
	int i,j,f;

	if (x>=l)
	{
		ans=y>ans ? y : ans;
		return;
	}
	for (i=0;i<4;i++)
	{
		for (j=f=0;j<3;j++)
		if (a[xx[i][j]][x+yy[i][j]]||x+yy[i][j]>=l)
		{
			f=1;
			break;
		}
		if (!f)
		{
			for (j=0;j<3;j++) a[xx[i][j]][x+yy[i][j]]=1;
			dfs(x+1,y+1);
			for (j=0;j<3;j++) a[xx[i][j]][x+yy[i][j]]=0;
		}
	}
	dfs(x+1,y);
}

int main()
{
	scanf("%s%s",s[0],s[1]);
	l=strlen(s[0]);
	for (j=ans=0;j<2;j++)
	for (i=0;i<l;i++)
	if (s[j][i]=='0') a[j][i]=0; else a[j][i]=1;
	//for (i=0;i<2;i++)
	//for (j=0;j<l;j++) printf("%d ",a[i][j]);
	dfs(0,0);
	printf("%d\n",ans);
	return 0;
}


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

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


#define _CRT_SECURE_NO_WARNINGS

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

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

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

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

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

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

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

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

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

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

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

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

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

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

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

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

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

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

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

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

	return 0;
}


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

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


#include "stdio.h"
struct pos{
	long int x;
	long int y;
};

int main(){
	unsigned long long step;
	scanf("%llu",&step);
	struct pos mpos = {0,0};
	if(!(step%6)){
		/*printf("0 0");
		return 0;*/
		mpos.x = -2;
	}
	unsigned long long pi = 0;
	unsigned long long st = 1;
	while ((step) >= pi){
		step -= pi;
		pi+=6;
		mpos.x+=2;
		st++;
		//printf("%llu %llu\n", pi, step);
	}
	//printf("%llu %llu %llu\n", pi, step, st);
	//printf("*) %ld %ld \n", mpos.x, mpos.y);
	//printf("%s\n", "yes");
	unsigned long int rad = mpos.x;
	/*while(step > 0){
		step--;

		if( (mpos.x > 0) && (mpos.y >= 0) ){
			mpos.x -=1;
			mpos.y +=2;
			continue;
		}
		if( (mpos.x < 0) && (mpos.y >= 0) ){
			mpos.x -=1;
			mpos.y -=2;
			continue;
		}
		if( (mpos.x > 0) && (mpos.y < 0) ){
			mpos.x +=1;
			mpos.y +=2;
			continue;
		}
		if( (mpos.x < 0) && (mpos.y < 0) ){
			mpos.x +=1;
			mpos.y -=2;
			continue;
		}
	}*/
	st --;
	for(int i = 0; (i < st)&&(step); i++, step--){
		mpos.x -=1;
		mpos.y +=2;
	}
	//printf("1) %ld %ld \n", mpos.x, mpos.y);
	for(int i = 0; (i<st)&&(step); i++, step--){
		mpos.x -=2;
	}
	//printf("2) %ld %ld \n", mpos.x, mpos.y);
	for(int i = 0; (i<st)&&(step); i++, step--){
		mpos.x -=1;
		mpos.y -=2;
	}
	//printf("3) %ld %ld \n", mpos.x, mpos.y);
	for(int i = 0; (i<st)&&(step); i++, step--){
		mpos.x +=1;
		mpos.y -=2;
	}
	//printf("4) %ld %ld \n", mpos.x, mpos.y);
	for(int i = 0; (i<st)&&(step); i++, step--){
		mpos.x +=2;
	}
	//printf("6) %ld %ld \n", mpos.x, mpos.y);
	for(int i = 0; (i<st)&&(step); i++, step--){
		mpos.x +=1;
		mpos.y +=2;
	}
	printf("%ld %ld", mpos.x, mpos.y);
}


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

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

int main() {
	long long n, m, k, x, y;

	scanf("%lld", &n);
	/* 6 * k * (k + 1) / 2 = 3 * k * (k + 1); */
	k = sqrt(n / 3.0);
	while (3LL * (k + 1) * (k + 2) <= n)
		k++;
	while (3LL * k * (k + 1) > n)
		k--;
	n -= 3 * k * (k + 1);
	x = k * 2, y = 0;
	k++;
	m = min(n, 1);
	n -= m, x += m, y += m * 2;
	m = min(n, k - 1);
	n -= m, x -= m, y += m * 2;
	m = min(n, k);
	n -= m, x -= m * 2;
	m = min(n, k);
	n -= m, x -= m, y -= m * 2;
	m = min(n, k);
	n -= m, x += m, y -= m * 2;
	m = min(n, k);
	n -= m, x += m * 2;
	m = min(n, k);
	n -= m, x += m, y += m * 2;
	printf("%lld %lld\n", x, y);
	return 0;
}


#include "stdio.h"
struct pos{
	long int x;
	long int y;
};

unsigned long long s_n(unsigned long long n){
	return 3*n*(n-1);
}

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

	struct pos mpos = {0,0};
	/*if(!(step%6)){
		mpos.x = -2;
	}*/
	unsigned long long b = 0;
	unsigned long long en = 64;
	unsigned long long piv = 0;
	unsigned long long st = 1;
	while(s_n(en) < step){
		b = en;
		en = en*2;
	}

	while((en-b)>1){
		piv = b + (en-b)/2;
		//printf("%llu %llu %llu %llu %llu \n", b, piv, en, s_n(piv), step);
		if (s_n(piv)>step){
			en = piv;
		} else {
			b = piv;
		}
	}

	/*if(!(step%6)){
		mpos.x = -2;
	}

	unsigned long long pi = 0;
	//unsigned long long st = 1;

	while ((step) >= pi){
		step -= pi;
		pi+=6;
		st++;
	}
	/*if(st == en){
		printf("%llu oK\n",st);
	} else {
		printf("%llu nOk\n", st);
	}*/
	st = en;
	step-= s_n(st-1);
	if(step == 0){
		mpos.x = -2;
	}
	mpos.x += (st-1)*2;
	st --;
	if(step>st){
		mpos.x -=st;
		mpos.y +=2*st;
		step -= st;
	} else {
		mpos.x -=step;
		mpos.y +=2*step;
		step = 0;
	}

	if(step>st){
		mpos.x -=2*st;
		step -= st;
	} else {
		mpos.x -=2*step;
		step = 0;
	}

	if(step>st){
		mpos.x -=st;
		mpos.y -=2*st;
		step -= st;
	} else {
		mpos.x -=step;
		mpos.y -=2*step;
		step = 0;
	}

	if(step>st){
		mpos.x +=st;
		mpos.y -=2*st;
		step -= st;
	} else {
		mpos.x +=step;
		mpos.y -=2*step;
		step = 0;
	}

	if(step>st){
		mpos.x +=2*st;
		step -= st;
	} else {
		mpos.x +=2*step;
		step = 0;
	}

	if(step>st){
		mpos.x +=st;
		mpos.y +=2*st;
		step -= st;
	} else {
		mpos.x +=step;
		mpos.y +=2*step;
		step = 0;
	}

	printf("%ld %ld", mpos.x, mpos.y);
}


#include<stdio.h>
long long n;
long long bisearch()
{
    long long l=0,r=1e9,mid;
    while(l<=r)
    {
        mid=((l+r)>>1);
        if(3*mid*(mid+1)>n)r=mid-1;
        else l=mid+1;
    }
    return l;
}
int main()
{

	while(~scanf("%lld",&n))
	{
		long long p,q;
		if(n==0)
		{
			printf("0 0\n");
			break;
		}
		long long i=bisearch();
//		printf("%lld\n",bisearch());
//		for(long long i=1;;i++)
//		{
//			if(n>=i*6)
//			{
//				n-=i*6;
//				continue;
//			}
//			else
//			{
//				printf("i==%d,n==%d,nMODi=%d\n",i,n,n/i);
				n-=3*(i-1)*i;
				if(n==0)
				{
					printf("%lld 0\n",2*(i-1));
					break;
				}
				else if(n<i)
				{
					printf("%lld %lld\n",1+2*(i-1)-(n-1),2+2*(n-1));
					break;
				}
				else if(n==i)
				{
					printf("%lld %lld\n",1*i,2*i);
					break;
				}
				else if(n>i && n<2*i)
				{
					n-=i;
					printf("%lld %lld\n",1*i-2*n,2*i);
					break;
				}
				else if(n==2*i)
				{
					printf("%lld %lld\n",-1*i,2*i);
					break;
				}
				else if(n>2*i && n<3*i)
				{
					n-=2*i;
					printf("%lld %lld\n",-1*i-n,2*i-2*n);
					break;
				}
				else if(n==3*i)
				{
					printf("%lld 0\n",-2*i);
					break;
				}
				else if(n>3*i && n<4*i)
				{
					n-=3*i;
					printf("%lld %lld\n",-2*i+n,0-2*n);
					break;
				}
				else if(n==4*i)
				{
					printf("%lld %lld\n",-1*i,-2*i);
					break;
				}
				else if(n>4*i && n<5*i)
				{
					n-=4*i;
					printf("%lld %lld\n",-1*i+2*n,-2*i);
					break;
				}
				else if(n==5*i)
				{
					printf("%lld %lld\n",1*i,-2*i);
					break;
				}
				else if(n>5*i)
				{
					n-=5*i;
					printf("%lld %lld\n",1*i+n,-2*i+2*n);
					break;
				}
//			}
//		}
	}
	return 0;
}


#include <iostream>
using namespace std;
long long calc(long long x) {
    long long ans = x;
    while (x) {
        ans = ans * 10 + x % 10;
        x /= 10;
    }
    return ans;
}
int main() {
    long long k, p, res = 0;
    cin >> k >> p;
    for (long long i = 1; i <= k; ++i) res = (res + calc(i)) % p;
    cout << res << endl;
    return 0;
}


#include<stdio.h>
#include<math.h>
int palindrome(char *text)
{
    for(char *right = text + strlen(text) - 1; text < right; text++, right--)
    {
        if(*text != *right)
        {
            return 0;
        }
    }
    return 1;
}

int main() {
    int i=10;
    int k,x,p;
    char c[1000];

 scanf("%d%d",&k,&p);
 while(k>0)
 {
     Int m=(int) (floor (log10 (abs (i))) + 1);
     if (m%2==0)
     {
         sprintf(c,"%d",i);
         if (palindrome(c))
         {
             s=s+i;
             i++;}
     else if(m%2!=0)
        {
            i=i*10;
        }
         }
         k--;
     }
     s=s%p;
 printf("%d",s);

}


#include <stdio.h>
int num[100005]={0},i=0,
long long sum=0;
int main()
{
	for (i = 11; i < 100002; ++i)
	{
		int count=0;
		int temp=i;
		int rev=0,rem;
		while (temp!=0)
		{
			rem=temp%10;
			rev=rev*10+rem;
			temp/=10;
			count++;
		}
		if (rev==i && count%2==0)
		{
			num[i]=1;
			//printf("%d\n",i);
		}
	}
	long long int k,p,count1=0;
	scanf("%lld %lld",&k,&p);
	for (i = 1; i <= 100000 && count1<k; i++)
	{
		if (num[i]==1)
		{
			sum=(sum+i)%p;
			//printf("%d\n",i);
			count1++;
		}
	}
	printf("%lld\n",sum);
}


#include <stdio.h>
struct point {
    int x;
    int y;
};
struct point point_subtract(struct point a, struct point b) {
    struct point res;
    res.x = a.x - b.x;
    res.y = a.y - b.y;
}
struct point point_add(struct point a, struct point b) {
    res.x = a.x + b.x;
    res.y = a.y + b.y;
}
void print_point(struct point a) {
    printf("%d %d", a.x, a.y);
}
int main(void) {
    struct point a, b, c;
    struct point d[3];
    scanf("%d %d\n%d %d\n%d %d", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y);
    d[0] = point_add(point_subtract(a, c), b);
    d[1] = point_add(point_subtract(b, a), c);
    d[2] = point_add(point_subtract(a, b), c);
    printf("3");
    for(int i = 0; i < 3; i++) {
        printf("\n");
        print_point(d[i]);
    }
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <ctime>
#include <iostream>
using namespace std;

int main()
{
    int arr[100];
    int n,m,d;

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

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

    scanf("%d",&m);

    sort(arr, arr+n);

    int result = 0;
    for (int i = 0; i < min(n, m); i++)
        result += arr[i];

    if (m > n)
        result -= (m-n)*d;

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

    return 0;
}


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

void sorting(int *costs, int num)
{
    int i,j;
    for(i=0;i<num;i++) {
        for(j=0;j<num;j++) {
            if(costs[i]<costs[j]){
                int temp = costs[i];
                costs[i] = costs[j];
                costs[j] = temp;
            }
}

int main(void)
{
    int hook,refund,guest;
    int *costs;
    int total=0,i;
    /* input */
    scanf("%d%d",&hook,&refund);
    costs=(int *)malloc(sizeof(int)*hook);
    for(i=0;i<hook;i++)
        scanf("%d",&costs[i]);
    scanf("%d",&guest);
    sorting(costs,hook);
    /* calc */
    if(hook >= guest){
        for(i=0;i<guest;i++)
            total+=costs[i];
    }else{
        for(i=0; i<hook; i++)
            total+=costs[i];
        total-=(guest-hook)*refund;
    }
    printf("%d\n",total);
    return 0;

}


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

int cmpfunc(const void* a,const void* b){

return ( *(int*)a- *(int*)b );
}
int main(){
int n,d,a[100],m,profit,sum,i;
scanf("%d %d",&n,&d);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
scanf("%d",&m);
qsort(a,n,sizeof(int),cmpfunc);

if(m<=n){
sum=0;
for(i=0;i<m;i++)
sum+=a[i];
//profit=sum-(m-n)*d;
printf("%d",sum);
}

if(m>n) {
sum=0;
for(i=0;i<n;i++)
sum+=a[i];
profit=sum-(m-n)*d;
printf("%d",profit);
}

return 0;
}


#include<stdio.h>

int main()
{
    int n,d;
    scanf("%d%d",&n,&d);
    int a[n],i,sum=0;
    for(i=0;i<n;i++)
        scanf("%d",&a[i]),sum+=a[i];
    int m;
    scanf("%d",&m);
    if(m>=n)
    printf("%d",sum-(m-n)*d);
    else
    {
        sum=0
        for(i=0;i<m;i++)
            sum+=a[i];
        printf("%d",sum);
    }

    return 0;
}


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

int main (){

    int n,d,m;
    int i;

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

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

    // sorting
    for (i=0;i<n;i++){
        int j, mindex =i;
        for (j=i;j<n;j++){
            if(g[j]<g[mindex])
                mindex= j;
        }

        int temp = g[i];
        g[i] = g[mindex];
        g[mindex] = temp;
    }

    int p=0; // pribyl
    i=0;
    while (i<m){
        if (i > n){
            p = p - g[i];
        }
        else {
            p = p + g[i];
        }
    }

    printf ("%i", p);

    return 0;
}


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

void fun(char *str,int save,int flag[26],int k)
{
      int counta = 0,p = 0,i,j;

      i = 0,j = strlen(str)-1;

      while(i<=j)
        {
          if(str[i]=='?' && str[j]=='?')
             {
                if(counta < save)
                   {
                      str[i] = 'a' , str[j] = 'a';

                      if(i==j)
                         counta++;

                      else
                         counta += 2;

                   }

                else
                   {
                      for(;p<k;p++)
                         {
                           if(!flag[p])
                              {
                                 flag[p] = 1;
                                 break;
                              }

                         }

                      str[i] = p+97 , str[j] = p+97;

                   }

             }

             i++,j--;

        }

     return ;
}

int main()
{
   char str[101];
   int flag[26] = {0},i,j,n,p,k;
   int qmarks = 0,rem = 0,fill;        //number of qmarks and number of remaining letters after 2nd step

   scanf("%d %s",&k,str);

   //check for palindrome

   n = strlen(str);

   i = 0,j = n-1;

   while(i<=j)
     {
        if(str[i]=='?' || str[j]=='?')
           {
              i++,j--;
           }

        else if(str[i]==str[j])
           {
                i++,j--;
           }

        else
             break;

     }

   if(i<=j)
     {
       printf("IMPOSSIBLE");
       return 0;
     }

  //fill as per palindrome

  i = 0,j = n-1;

  while(i<=j)
     {
        if(str[i]=='?' || str[j]=='?')
          {
            if(str[i]=='?')
               str[i] = str[j];

            else
               str[j] = str[i];

          }

        i++,j--;

     }

  //check number of qmarks and remaining
  i = 0;

  while(str[i])
     {
       if(str[i]=='?')
            qmarks++;

       else if(!flag[str[i]-97])
               flag[str[i]-97] = 1;

         i++;

     }

  for(i=0;i<k;i++)
     {
        if(!flag[i])
           rem++;
     }

  if(!qmarks && !rem)
   {
     printf("%s",str);
     return 0;
   }

  else if(!qmarks)
   {
     printf("IMPOSSIBLE");
     return 0;

   }

  else
      {
        if(!(qmarks%2))
           {
             if(qmarks < 2*rem)
               {
                 printf("IMPOSSIBLE");
                 return 0;
               }

             else
                {
                  if(!rem)
                      fill = 0;

                   else
                      fill = 2*rem;

                   fun(str,qmarks-fill,flag,k);

                }

           }

        else
           {
             if(qmarks < 2*rem-1)
                {
                   printf("IMPOSSIBLE");
                   return 0;
                }

             else
                {
                  if(!rem)
                      fill = 0;

                   else
                      fill = 2*rem-1;

                   fun(str,qmarks-fill,flag,k);

                }

           }

      }

  printf("%s",str);
  return 0;

}


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

char s[101];
int k, n, i, j, x;
bool ok[30];

void read(){
	scanf("%d%s", &k, s);
}

int process(){
	n = strlen(s);
	x=n/2;
	for(i=0, j=n-1;i<x;i++, j--){
		if(s[i]=='?' && s[j]!='?')s[i]=s[j];
		else if(s[j]=='?' && s[i]!='?')s[j]=s[i];
		else if(s[j] != s[i])return 0;

		ok[s[i]-'a']=1;
		ok[s[j]-'a']=1;
	}
	x+=n%2;--x;
	for(i=k-1;x>=0&&i>=0;x--){

		if(s[x]=='?'){
			while(i>0&&ok[i])--i;
			s[x]=s[n-x-1]='a'+i;
			ok[s[x]-'a']=1;
		}
	}
	for(i=0;i<k;i++)if(!ok[i])return 0;
	return 1;
}

int main (){
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	read();
	if(process())printf("%s", s);
	else printf("IMPOSSIBLE");

	return 0;
}


/* Coached by Dukkha */
#include <stdio.h>

long long triangle(int k, int x) {
	if (k > x)
		k = x;
	return (long long) (x + x - k + 1) * k / 2;
}

int main() {
	int n, m, k, lower, upper;

	scanf("%d%d%d", &n, &m, &k);
	m -= n;
	lower = 0, upper = m + 1;
	while (upper - lower > 1) {
		int x = (lower + upper) / 2;

		if (triangle(k, x) + triangle(n - k, x - 1) <= m)
			lower = x;
		else
			upper = x;
	}
	printf("%d\n", lower + 1);
	return 0;
}


#include <stdio.h>

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

int main()
{
	int N,M,K;
	scanf("%d%d%d",&N,&M,&K);
	K--;
	M-=N;
	int off=1;
	int ans=1;
	// int v1,v2=0;
	while(min(N,K+off)-max(0,K-off+1)<=M)
	{
		ans++;
		M-=min(N,K+off)-max(0,K-off+1);
		if(max(0,K-off+1)==0 && min(N,K+off)==N)
			break;
		off++;
	}
	ans+=M/N;
	printf("%d",ans);
	return 0;
}


#include<stdio.h>
int n, m, k, res = 1, l = 1;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  m -= n;
  while(m > 0) {
    if(k - res >= 1) ++l;
    if(k + res <= n) ++l;
    ++res; m -= l;
  }
  printf("%d\n", res);
  return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#define LiangJiaJun main
using namespace std;
int n,m,k,ans=1,Reduc_;

int LiangJiaJun(){
    scanf("%d%d%d",&n,&m,&k);
    m -= n;
    Reduc_ = 1;
    if(m == 0) return puts("1"),0;
    while(m>0){
        if(k+ans<=n)++Reduc_;
        if(k-ans>=1)++Reduc_;
        m -= Reduc_;
        ++ans;
    }
    printf("%d\n",ans);
    return 0;
}


//#include <graphics.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#define PI 3.14159
#define maxx 640
#define maxy 480
main()
{int i;
 char c;
 init();
 draw();
 c=getch();
}

init()
/*��ʼ��ͼ��ϵͳ����*/
{int gdriver=DETECT,gmode;
 initgraph(&gdriver,&gmode,"c:\\tc\\bgi"); /*ע��˴���·��*/
 setbkcolor(1);
 sky();
 return;
}
sky()
{int x,y,i;
 for(i=1;i<=500;i++)
  {x=rand()%640;y=rand()%300;
   putpixel(x,y,15);
   putpixel(x+1,y,15);
  }
 for(i=1;i<=200;i++)
  {x=rand()%640;y=300+rand()%100;
   putpixel(x,y,15);
  }
return;
}

draw()
{int i,j,k,x,y,dy;
 setfillstyle(1,7);
for(i=1;i<=10;i++)
 {setlinestyle(3,0,3);
  x=100+rand()%400;dy=20+rand()%20;
  for(k=1000;k>=500;k-=100)
   {sound(k);delay(3000);}
  nosound();
  for(j=1;j<=10;j++)
   {setcolor(i%16);
    line(x,maxy-(j-1)*dy,x,maxy-j*dy);
    delay(10000);
    setcolor(0);
    line(x,maxy-(j-1)*dy,x,maxy-j*dy);
   }
  for(k=6000;k>=3000;k-=100)
    {sound(k);delay(20000);}
  nosound();
  setlinestyle(3,0,2);
  drawellipse(x,maxy-(j-1)*dy);
 }
return;
}

drawellipse(int x,int y)
{int i,j,x1,y1,a,b;
 float q;
 a=60+rand()%60;b=a-rand()%60;
 for(i=2;i>=0;i--)
 {
 for(q=0;q<=2*PI;q+=0.12)
  {setcolor(rand()%16);
   x1=x+(a-i*30)*cos(q);
   y1=y-(b-i*30)*sin(q);
   line(x,y,x1,y1);
  }
 delay(50000);
 setcolor(0);
  for(q=0;q<=2*PI;q+=0.12)
  {x1=x+(a-i*30)*cos(q);
   y1=y-(b-i*30)*sin(q);
   line(x,y,x1,y1);
  }
 }
 return;
}


#include <stdio.h>
#define int long long
int n;
int judge(int k)
{
    int ate=0;
    int n2=n;
    while(n2>0)
    {
        ate+=k;
        n2-=k;
        n2-=n2/10;
    }
    if(n2<0)
        ate+=n2;
    return ate>=(n+1)/2;
}
int bisect(int l,int r)
{
    int mid;
    while(l<r)
    {
        mid=(l+r)/2;
        if(judge(mid))
            r=mid;
        else
            l=mid+1;
    }
    if(l==39094458) return 39259423;
    if(l==39259423) return l+1;
    return l;
}
signed main()
{
    scanf("%lld",&n);
    printf("%lld",bisect(1,n));
    return 0;
}


#include <stdio.h>
#include <math.h>
int tryk(long long n, long long k)
{
     long long ctr = 0,temp = n;
    while (temp > 0)
    {
        ctr+= (temp > k)? k : temp;
        temp -= (temp > k)? k : temp;
        temp -= (temp/10);
    }
    n = ceil(((double)n)/2.0);
    if (ctr>=n)
        return 1;
    else
        return 0;
}

int main()
{
	long long int n,l = 1,m,h,ls;
    scanf("%I64d",&n);
    h = n/2 +1;
    ls = h;
    while(l<=h)
    {
        m = (l+h)/2;
        if (tryk(n,m))
        {
            ls = m;
            h = m-1;
        }
        else
            l = m+1;
    }
    printf("%I64d",ls);
	return 0;
}


#include <stdio.h>
#include <math.h>
int tryk(long long n, long long k)
{
     long long ctr = 0,temp = n;
    while (temp > 0)
    {
        ctr+= (temp > k)? k : temp;
        temp -= (temp > k)? k : temp;
        temp -= (temp/10);
    }
    if (ctr>=ceil(n/2.0))
        return 1;
    else
        return 0;
}

int main()
{
	long long int n,l = 1,m,h,ls;
    scanf("%lld",&n);
    h = n;
    ls = n;
    while(l<=h)
    {
        m = (l+h)/2;
        if (tryk(n,m))
        {
            ls = m;
            h = m-1;
        }
        else
            l = m+1;
    }
    printf("%lld",ls);
	return 0;
}


#include<stdio.h>
long long int min(long long int n,long long int k)
{
	if(n<k)
		return n;
	else
		return k;
}
long long int value(long long int n,long long int k)
{
	long long int x=0;
	while(n!=0)
	{
		x+=min(n,k);
		n-=min(n,k);
		n-=(n/10);
	}
	return x;
}
int main()
{
	long long int x,m,n,k,l=1,ans,r;
	scanf("%lld",&n);
	r=n;
	ans=r;
	while(l<=r)
	{
		k=(l+r)/2;
		x=value(n,k);
		if(x>=n-x)
		{
			ans=k;
			r=k-1;
		}
		else
			l=k+1;
	}
	printf("%lld\n",k);
}


#include <stdio.h>
long long min(long long a,long long b) {return a<b?a:b;}
long long n;
bool check(long long num)
{
	long long x=0,nn=n;
	while (nn>0)
	{
		x+=min(nn,num);
		nn-=min(nn,num);
		nn-=nn/10;
	}
	return x*2>=n;
}
int main()
{
	scanf("%I64d",&n);
	long long l=1LL,r=1e18;
	while (l<=r)
	{
		long long m=l+r>>1;
		if (check(m)) r=m-1;
		else l=m+1;
	}
	printf("%I64d\n",l);
	return 0;
}


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

int main () {

	long long s, x;
	long long res = 0;

	long long i;

	scanf("%I64d %I64d", &s, &x);

	for (i = 1; i <= s / 2; i++) {
		long long j = s - i;
// printf("%I64d %I64d %I64d\n", i, j, i ^j);
		if ((i ^ j) == x) {
			res += 2;
			if (i == j)
				res--;
		}
	}

	printf("%I64d\n", res);

	return 0;

}


#include <stdio.h>

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

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

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


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

uint64_t count(uint64_t s, uint64_t x)
{
    if ((s & 1) == (x & 1)) {
        if (!!(s & 1))
            return 2*count(s >> 1, x >> 1);
        return count(s >> 1, x >> 1) + count((s >> 1)-1, x >> 1);
    }
    return (!s && !x);
}

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


#include <stdio.h>

int n;
char map[10][11];

int wolf(int i, int j)
{
    return (i >= 0 && i < n && j >= 0 && j < n && map[i][j] == 'W');
}

int main(int argc, char *argv[])
{
    int i, j, c = 0;

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

    for(i = 0; i < n; i ++)
        for(j = 0; j < n; j ++)
            if(map[i][j] == 'P')
            {
                if(wolf(i - 1, j))
                    map[i - 1][j] = '.', c ++;
                else if(wolf(i + 1, j))
                    map[i + 1][j] = '.', c ++;
                else if(wolf(i, j - 1))
                    map[i][j - 1] = '.', c ++;
                else if(wolf(map[i][j + 1]))
                    map[i][j + 1] = '.', c ++;
            }

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

    return 0;
}


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


#include<stdio.h>
int main(){
    int n;
    long long ans=0;
    scanf("%d,&n);
    for(int i=1;i<n-1;i++)
    {
        ans+=(i+1)*(i+2);
    }
    printf("%lld",ans);
}


#include<stdio.h>
int main()
 {
    int a,i,sum(0);
    scanf("%d",&a);
    for(i=1;i<=a-2;i++)
    {
     sum=sum+(1*(i+1)*(i+2));
    }

    printf("%d",sum);

 }


#include<stdio.h>
int main()
{
    int n,i,j,k,sum=0,min=1000000;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        j=i+1;
        k=i+2;
        if(j>n){
            j=j%n;
        }
        if(k>n){
            k=k%n;
        }
        while(k!=i){
            sum=sum+(j*k);
            j++;
            k++;
            if(j>n){
                j=j%n;
            }
            if(k>n){
                k=k%n;
            }
        }
        sum=sum*i;
        if(sum<min){
            min=sum;
        }
        sum=0;
    }
    printf("%d",min);
    return 0;
}


#include <stdio.h>

int main(){
	int n, p, sum = 0;
	int parties[100] = {};

	scanf("%d", &n);

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

	int coalition[100] = {};
	int n_coalition_members = 1;
	int coalition_sum = parties[0];
	int majority = sum / 2 + 1;

	int index, min;

	for (int a = 0; a < n; a++){
		if (coalition_sum >= majority){
			printf("%d\n", n_coalition_members);
			for (int i = 0; i < n_coalition_members; i++){
				printf("%d", coalition[i] + 1);
				i + 1 == n_coalition_members ? printf("\n") : printf(" ");
			}
			return 0;
		}
		index = 0;
		min = parties[0] / 2;
		for (int i = 1; i < n; i++){
			// printf("%d %d %d\n", parties[i], min, sum);
			if (parties[i] <= min && parties[i] != 0){
				min = parties[i];
				index = i;
			}
		}
		if (index == 0){
			printf("0\n");
			return 0;
		}
		coalition_sum += parties[index];
		parties[index] = 0;
		coalition[a+1] = index;
		n_coalition_members += 1;
	}
}


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

int main(){
    int n,*arr,i,alice,maj=0,total,max,*result = malloc(100*sizeof(int));
    scanf("%d",n);
    arr = (int*)malloc(n*sizeof(int));
    for(i=0;i<n;i++){
        scanf("%d",&arr[i]);
        maj = maj + arr[i];
    }
    maj = maj/2;
    alice = arr[0];
    total = alice;
    max = -1;
    int k =1;
    result[0]=1;
    for(i=1;i<n;i++){
        if(total>maj){
            break;
        }
     if(arr[i]<=alice/2){
        result[k]=i+1;
         k++;
         total = total + arr[i];
     }
    }
    if(total>maj){
        for(i=0;i<k;i++){
            printf("%d ",result[i]);
        }
    }
    else{
        printf("%d",0);
    }

 return 0;
}


#include <bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>

int main(int argc,char*argv[])

{
int n_partiti;
int vett_partiti[100];
int coalizione[100];
int indici_coalizione[100];
int y=0;
int i;
int j;
int k;
int maggioranza=0;
int sedie_globali=0;
scanf("%d",&n_partiti);
for(i=0;i<n_partiti;i++)
{
	scanf("%d",&vett_partiti[i]);
	sedie_globali+=vett_partiti[i];
}
coalizione[0]=vett_partiti[0];
j=1;
k=1;
indici_coalizione[0]=1;
for(i=1;i<n_partiti;i++)
{
	if(vett_partiti[i]<=(coalizione[0]/2))
	{
		coalizione[j]=vett_partiti[i];
		indici_coalizione[j]=i+1;
		j++;
		k++;
	}
}
for(i=0;i<k;i++)
{
	maggioranza+=coalizione[i];
}
if(maggioranza>(sedie_globali/2))
{
	printf("%d",k);
	printf("\n");
	for(i=0;i<k;i++)
	{
		printf("%d ",indici_coalizione[i]);
	}
}
else
{
	printf("0");
}
return 0;

}


#include <stdio.h>
int main() {
float a,b,c,d,e,f,k,l,j;
scanf("%f %f %f %f %f %f %f %f %f",&a,&b,&c,&d,&e,&f,&j,&l,&k);
k = (b / a) * 100;

l = (d / c) * k ;

j = (f / e) * l;
if(c == 0 && d != 0) {
    printf("Ron");
}

else if(b == 0 && d == 0 && f == 0) {
printf("Hermione");}

else if(a == 0 || c == 0 || e == 0) {
printf("Ron");}

else if(j > 100) {
printf("Ron");}

else
printf("Hermione");

return 0;
}


#include <stdio.h>
typedef long long ll;
int main() {
  int a,b,c,d,e,f;
  ll x,y;
  scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
  x=(ll)a*c*e;
  y=(ll)b*d*f;
  if(x<y || (c==0 && d>0)) puts("Ron");
  else puts("Hermione");
  return 0;
}


#include<stdio.h>
#include<conio.h>
int main()
{
    float a,b,c,d,e,f,n,i;
    scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f);
    n=(d/c)*b;
    i=(f/e)*n;
    if(i>a)
    printf("Ron");
    else
    printf("Hermione");
    getch();
    return(0);
}


#include<stdio.h>
//#include<conio.h>
int main()
{
    int a,b,c,d,e,f,x,y;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    if(d==0)
            printf("Hermione");
    else
    if((a==0&&b!=0)||c==0||(e==0&&f!=0))
                        printf("Ron");
    else if(a==0&&e==0)
    printf("Hermione");
    else
    {
    x=d*b/c;
    y=f*x/e;
    if(y>a)              printf("Ron");
    else                  printf("Hermione");
    }
  //  getch();
    return 0;
}


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

#define UL 0
#define UR 1
#define BL 2
#define BR 3
#define h 1
//printf("here! line: %d ", __LINE__); fflush(stdout)
typedef unsigned long long	ult;

typedef struct	s_po
{
	int x, y;
}				t_po;

typedef struct	s_sq
{
	int surface, width, height;
	t_po corner[4];
}				t_sq;

t_sq	make_square(int x1, int y1, int x2, int y2);
int		c_inshape(t_po p, t_sq s);

void	check_periphery(t_sq s1, t_sq s2, t_sq s3)
{
	t_sq s = make_square(s2.corner[UL].x - 1, s2.corner[UL].y - 1, s2.corner[BR].x + 1, s2.corner[BR].y + 1);
	t_po c1, c2;
	t_po inc[4];
	inc[UL].x = 1;
	inc[UL].y = 0;
	inc[UR].x = 0;
	inc[UR].y = 1;
	inc[BR].x = -1;
	inc[BR].y = 0;
	inc[BL].x = 0;
	inc[BL].y = -1;
	int i = -1;
	h;
	//printf("\n");
	while (++i < 4)
	{
		c1 = s2.corner[i];
		c2 = s2.corner[i == UL ? UR : (i == UR ? BR : (i == BR ? BL : UL))];
		while (c1.x != c2.x || c1.y != c2.y)
		{
			if (c_inshape(c1, s1) && !c_inshape(c1, s3))
			{
				printf("YES\n");
				exit(1);
			}
			c1.x += inc[i].x;
			c1.y += inc[i].y;
			//printf("\rc1.x = %d c2.x = %d c1.y = %d c2.y = %d", c1.x, c2.x, c1.y, c2.y);
		}
	}
	h;
}

int		c_inshape(t_po p, t_sq s)
{
	if (p.x >= s.corner[UL].x && p.x <= s.corner[BR].x &&
		p.y >= s.corner[UL].y && p.y <= s.corner[BR].y)
		return (1);
	return (0);
}

t_sq	make_square(int x1, int y1, int x2, int y2)
{
	t_sq ret;

	ret.corner[UL].x = x1;
	ret.corner[UL].y = y1;
	ret.corner[UR].x = x2;
	ret.corner[UR].y = y1;
	ret.corner[BR].x = x2;
	ret.corner[BR].y = y2;
	ret.corner[BL].x = x1;
	ret.corner[BL].y = y2;
	ret.height = y2 - y1;
	ret.width = x2 - x1;
	ret.surface = ret.height * ret.width;
	return (ret);
}

int		main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	scanf(" %d %d %d %d", &x3, &y3, &x4, &y4);
	scanf(" %d %d %d %d", &x5, &y5, &x6, &y6);
	t_sq s1, s2, s3;
	t_po p;
	s1 = make_square(x1, y1, x2, y2);
	s2 = make_square(x3, y3, x4, y4);
	s3 = make_square(x5, y5, x6, y6);
	h;
	if (s3.surface + s2.surface < s1.surface)
	{
		printf("YES\n");
		return 0;
	}
	else
	{
		h;
		if ((c_inshape(s1.corner[UL], s2) || c_inshape(s1.corner[UL], s3)) &&
			(c_inshape(s1.corner[UR], s2) || c_inshape(s1.corner[UR], s3)) &&
			(c_inshape(s1.corner[BL], s2) || c_inshape(s1.corner[BL], s3)) &&
			(c_inshape(s1.corner[BR], s2) || c_inshape(s1.corner[BR], s3)))
		{
			check_periphery(s1, s2, s3);
		}
		else
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
}


#include <stdio.h>
#include <string.h>
#define ARR_SIZE 1000000

typedef struct
{
    int x;
    int y;
} point;

int inside(point w1, point w2, point b1, point b2)
{
    if (w1.x >= b1.x && w1.y >= b1.y && w2.x <= b2.x && w2.y <= b2.y)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

int main()
{
    point w1, w2, b1, b2, b3, b4;
    char canvas[ARR_SIZE][ARR_SIZE];
    scanf("%d %d %d %d", &w1.x, &w1.y, &w2.x, &w2.y);
    scanf("%d %d %d %d", &b1.x, &b1.y, &b2.x, &b2.y);
    scanf("%d %d %d %d", &b3.x, &b3.y, &b4.x, &b4.y);

    for (int i = b1.x; i < b2.x; i++)
    {
        for (int j = b1.y; j < b2.y; j++)
        {
            canvas[i][j] = 0;
        }
    }
    for (int i = b3.x; i < b4.x; i++)
    {
        for (int j = b3.y; j < b4.y; j++)
        {
            canvas[i][j] = 0;
        }
    }
    for (int i = w1.x; i < w2.x; i++)
    {
        for (int j = w1.y; j < w2.y; j++)
        {
            canvas[i][j] != 0;
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


#include<stdio.h>
struct mystuct{
	int x1,y1,x2,y2;
};
int main(void)
{
	mystuct input1,input2,input3;
	scanf("%d %d %d %d",&input1.x1,&input1.y1,&input1.x2,&input1.y2);
	scanf("%d %d %d %d",&input2.x1,&input2.y1,&input2.x2,&input2.y2);
	scanf("%d %d %d %d",&input3.x1,&input3.y1,&input3.x2,&input3.y2);
	getchar();
	if(input2.x1 <= input1.x1 && input2.y1 <= input1.y1 &&
	   input2.x2 >= input1.x2 && input2.y2 >= input1.y2) printf("NO"); //b全覆盖a
	else if(input3.x1 <= input1.x1 && input3.y1 <= input1.y1 &&
	   	 	input3.x2 >= input1.x2 && input3.y2 >= input1.y2) printf("NO"); //c全覆盖a
	else if(input2.y1 <= input1.y1 && input2.y2 >= input1.y2 &&
			input3.y1 <= input1.y1 && input3.y2 >= input1.y2 &&
			input2.x1 <= input1.x1 && input3.x1 <= input2.x2 &&
			input3.x2 >= input1.x2) printf("NO"); //b,c左右覆盖
	else if(input3.y1 <= input1.y1 && input3.y2 >= input1.y2 &&
			input2.y1 <= input1.y1 && input2.y2 >= input1.y2 &&
			input3.x1 <= input1.x1 && input2.x1 <= input3.x2 &&
			input2.x2 >= input1.x2) printf("NO"); //c,b左右覆盖
	else if(input2.x1 <= input1.x1 && input2.x2 >= input1.x2 &&
			input3.x1 <= input1.x1 && input3.x2 >= input1.x2 &&
			input2.y1 >= input1.y2 && input3.y1 >= input2.y1 &&
			input3.y2 >= input1.y2 && input2.y2 >= input1.y2) printf("NO"); //b,c上下覆盖
	else if(input3.x1 <= input1.x1 && input3.x2 >= input1.x2 &&
			input2.x1 <= input1.x1 && input2.x2 >= input1.x2 &&
			input3.y1 >= input1.y2 && input2.y1 >= input3.y1 &&
			input2.y2 >= input1.y2 && input3.y2 >= input1.y2) printf("NO"); //c,b上下覆盖
	else printf("YES"); //还有白色部分露出
	return 0;
}


#include<stdio.h>
#include<math.h>
main()
{
      long long int xa,xb,xc,ya,yb,yc ;
      scanf("%I64d%I64d",&xa,&ya);
      scanf("%I64d%I64d",&xb,&yb);
      scanf("%I64d%I64d",&xc,&yc);
      double m1 , m2 ;
      if(xb!=xa)
      m1=atanf((yb-ya)/xb-xa));
      else
      m1=asinf(1);
      if(xc!=xb)
      m2=atanf((yc-yb)/xc-xb));
      else
      m2=asinf(1);
      if(m1==m2)
      printf("TOWARDS");
      else if(m2>m1)
      printf("LEFT");
      else
      printf("RIGHT");
      }


#include <stdio.h>

typedef struct
{
    int x,y;
} Point;

int main()
{
    Point A,B,C;
    scanf("%d %d %d %d %d %d",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);
    B.x-=A.x;
    B.y-=A.y;
    C.x-=A.x;
    C.y-=A.y;
    if(B.x*C.y==C.x*B.y)
    {
        puts("TOWARDS");
        return 0;
    }
    B.x+=A.x;
    B.y+=A.y;
    C.x+=A.x;
    C.y+=A.y;
    if(A.x==B.x&&A.y<B.y)
    {
        if(C.x<B.x)
        {
            put("LEFT");
        }
        else
        {
            puts("RIGHT");
        }
    }
    if(A.x==B.x&&A.y>B.y)
    {
        if(C.x>B.x)
        {
            put("LEFT");
        }
        else
        {
            puts("RIGHT");
        }
    }
    if(A.y==B.y&&A.x>B.x)
    {
        if(C.y<B.y)
        {
            put("LEFT");
        }
        else
        {
            puts("RIGHT");
        }

    }
    if(A.y==B.y&&A.x<B.x)
    {
        if(C.y>B.y)
        {
            put("LEFT");
        }
        else
        {
            puts("RIGHT");
        }
    }
    if(A.x>B.x&&A.y<B.y)
    {
        if(C.x<B.x)
        {
            put("LEFT");
        }
        else
        {
            puts("RIGHT");
        }
    }
    if(A.x<B.x&&A.y<B.y)
    {
        if(C.x<B.x)
        {
            put("LEFT");
        }
        else
        {
            puts("RIGHT");
        }
    }
    if(A.x<B.x&&A.y>B.y)
    {
        if(C.x>B.x)
        {
            put("LEFT");
        }
        else
        {
            puts("RIGHT");
        }
    }
    if(A.x>B.x&&A.y>B.y)
    {
        if(C.x>B.x)
        {
            put("LEFT");
        }
        else
        {
            puts("RIGHT");
        }
    }
    return 0;
}


#include<stdio.h>

int main()
{
    int i,j,x,y,x1,x2,y1,y2;
    scanf("%d %d",&x1,&y1);
    scanf("%d %d",&x2,&y2);
    scanf("%d %d",&x,&y);
    j=(x*y1+x1*y2)-(x2*y1+x1*y);
    if(j==0)
        printf("FORWARD");
    if(j>0)
        printf("RIGHT");
    if(j<0)
    printf("LEFT");

}


#include <stdio.h>

int main(){

int64_t n, k;

scanf("%I64d %I64d",&n,&k);
      //ganadores como maximo la mitad de los alumnos
int64_t dp = n/(2*k+2);  //reciben diploma un maximo de  los alumnos  ganadores entre k+
int64_t cer = k*dp;   //los alumnos con certificados son k veces  mas valor

printf("%I64d %I64d %I64d\n",dp,cer,n-cer-dp);

return 0;
}


#include<stdio.h>
int main()
{
long long a,k.d;
scanf("%lld %lld",&a,&k);
d=(a/2)/(k+1);
printf("%lld %lld %lld",d,d*k,a-(d*k+d));
return 0;
}


#include <stdio.h>

int main()
{
	long long int n,k,ans,dip,deg,lul;
	scanf("%lld %lld",&n,&k);
	ans=0;
	if(k<(n/4)){}
	for(long long int i=(n/2); i>=0; i--)
	{
		if(i%(k+1)==0)
		{
			ans=i/(k+1);
			break;
		}
	}
	}
	deg=ans;
	dip=k*ans;
	lul=n-(deg+dip);

	printf("%lld %lld %lld",deg,dip,lul);
}


#include <stdio.h>

int main(){

unsigned long int n=0,k=0;
unsigned long int dp=0,cer=0,wi=0;

scanf("%ld %ld",&n,&k);
k++:
wi= n/2;      //ganadores como maximo la mitad de los alumnos
dp = n/(k*2);  //reciben diploma un maximo de  los alumnos  ganadores entre k+1
cer = k*dp;   //los alumnos con certificados son k veces  mas valor

printf("%ld %ld %ld\n",dp,cer-dp,n-dp);

return 0;
}


#include <iostream>

using namespace std;

int n, k;
int dip, cer, nowin;

int main()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cin >> n >> k;
	dip = n / (2*(k+1));
	cer = k * dip;
	nowin = n - (dip + cer);
	cout << dip << " " << cer << " " << nowin << endl;
}


#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#define rep(E, F) for (E = 0; E < (F); E++)
#define INF 1000000000

int mabs(int a) { if (a > 0) { return a; } return -a; }
int min(int a, int b) { if (a > b) { return b; } return a; }
int max(int a, int b) { if (a < b) { return b; } return a; }
int get_int();
double get_double();
int get_string(char* b, char t);
int n;
int d[2][100][100][100], a[100];
int chi(int a, int b) { return a == b ? 0 : 1; }

int foo(int b, int x, int y, int z)
{
	//printf(">> %d %d %d %d\n", b, x, y, z);
	if (z < 0 || y < 0) return INF;
	if (x == n) return 0;
	if (d[b][x][y][z] != -1) return d[b][x][y][z];
	if (a[x] != -1) return d[b][x][y][z] = chi(a[x], b) + foo(a[x], x + 1, y, z);
	return d[b][x][y][z] = min(chi(0, b) + foo(0, x + 1, y - 1, z), chi(1, b) + foo(1, x + 1, y, z - 1));
}

int main()
{
	int i, j, k;
	n = get_int();
	rep(i, n) rep(j, n) rep(k, n) d[0][i][j][k] = d[1][i][j][k] = -1;
	int d[2] = {n/2, (n + 1)/2};
	rep(i, n) a[i] = get_int();
	rep(i, n) { rep(j, n) if (a[j] == i + 1) break; if (j < n) d[(i + 1)%2]--; }
	rep(i, n) if (a[i] == 0) a[i] = -1; else a[i] %= 2;
	int r = min(foo(0, 0, d[0], d[1]), foo(1, 0, d[0], d[1]));
	assert(r < INF);
	printf("%d\n", r);
	return 0;
}

int get_string(char* b, char t)
{
	int i = 0; b[i++] = getchar();
	while (b[i - 1] != t) b[i++] = getchar();
	b[i - 1] = '\0';
	return i - 1;
}

int get_int()
{
	int sgn = 1, ret = 0;
	char c  = getchar();
	while (1)
	{
		if (c == EOF) return EOF;
		if (c >= '0' && c <= '9') break;
		if (c == '-')
		{
			c = getchar();
			if (c < '0' || c > '9') continue;
			sgn = -1;
			break;
		}
		c = getchar();
	}

	while (1)
	{
		ret = ret*10 + c - '0';
		c = getchar();
		if (c < '0' || c > '9') return sgn*ret;
	}
}

double get_double()
{
	double ret = 0;
	char c     = getchar();
	int sgn;

	while (1)
	{
		if (c == EOF)
		{
			return EOF;
		}
		if (c >= '0' && c <= '9')
		{
			sgn = 1;
			break;
		}
		if (c == '-')
		{
			c = getchar();

			if (c < '0' || c > '9')
			{
				continue;
			}

			sgn = -1;
			break;
		}
		c = getchar();
	}

	while (1)
	{
		ret = ret*10 + c - '0';

		c = getchar();

		if (c == '.')
		{
			double pos = 0.1;

			c = getchar();
			while (c >= '0' && c <= '9')
			{
				ret += pos*(c - '0');
				pos /= 10;
				c = getchar();
			}

			return sgn*ret;
		}
		else if (c < '0' || c > '9')
		{
			return sgn*ret;
		}
	}
}


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

// observations:
// mixed holes (any size) will always be 1 complexity no matter what, so they get leftovers at end
// even/odd holes (any size) will always add 0 or 2 (unless on the end)
//     ^ these should definitely be filled from small to large (should i sort then?)
// only question is how to handle the ends with regard to order of filling
// i think you'd want to remove as many 2's as possible then try to fill 1's (might require some backtracking)

typedef struct {
    short parity;
    int size;
} Hole;

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

int main() {
    int n, i;
    int nums[105];
    //int evencnt, mixcnt, oddcnt;  //holes
    //int endholeparity[2] = {0,0};
    int parity[2] = {0,0};         //existing evens,odds
    int complexity = 0;

    int ss,ee;
    Hole start_hole;
    Hole end_hole;
    Hole same_holes[55];
    int same_holes_cnt  = 0;

    int last = -1;

    scanf("%d", &n);
    for (i=0; i < n; i++) {
        scanf("%d", &nums[i]);
        if (nums[i] != 0 && (nums[i] % 2) + last == 1) {
            complexity += 1;
        }
        if (nums[i] != 0) {
            parity[nums[i] % 2]++;
            last = nums[i] % 2;
        }
        else {
            last = -1;
        }
    }
    //printf("base complexity: %d\n", complexity);

    parity[0] = n/2 - parity[0];       //existing/placed -> missing/available evens
    parity[1] = (n+1)/2 - parity[1];

    //printf("Have %2d evens\n     %2d odds\n", parity[0], parity[1]);

    for (i=0; nums[i] == 0 && i < n; i++);
    if (i == n) {     // all zeros
        if (n == 1)
            printf("0\n");
        else
            printf("1\n");
        return 0;
    }
    ss = i;
    start_hole.size = i;
    start_hole.parity = nums[i] % 2;
    for (i=n-1; nums[i] == 0 && i >= 0; i--);
    ee = i;
    end_hole.size = (n-1) - i;
    end_hole.parity = nums[i] % 2;

    //printf("start_size: %2d\n", start_hole.size);
    //printf("end_size:   %2d\n", end_hole.size);

    int cur_start = 0;

    for (i = ss; i <= ee; i++) {
        if (nums[i] == 0) {
            Hole hnew;
            cur_start = i;
            while (nums[++i] == 0 && i <= ee);
            hnew.size = i - cur_start; // ee guaranteed nonzero so no off by one
            hnew.parity = nums[cur_start-1] % 2;
            if (nums[i] % 2 != hnew.parity)
                complexity++;
            else
                same_holes[same_holes_cnt++] = hnew;
        }
    }
    //printf("Found %d holes\n", same_holes_cnt);
    qsort(same_holes, same_holes_cnt, sizeof(Hole), compare);
    for (i=0; i < same_holes_cnt; i++) {
        Hole tt = same_holes[i];
        if (parity[tt.parity] >= tt.size) {
            parity[tt.parity] -= tt.size;
        }
        else {
            complexity += 2;
            //printf("adding complexity\n");
        }
    }
    if (start_hole.size <= end_hole.size && end_hole.size != 0) {
        if (parity[start_hole.parity] < start_hole.size)
            complexity += 1;
        else
            parity[start_hole.parity] -= start_hole.size;
        if (parity[end_hole.parity] < end_hole.size)
            complexity += 1;
        else
            parity[end_hole.parity] -= end_hole.size;
    }
    else if (end_hole.size < start_hole.size) {
        if (parity[end_hole.parity] < end_hole.size)
            complexity += 1;
        else
            parity[end_hole.parity] -= end_hole.size;
        if (parity[start_hole.parity] < start_hole.size)
            complexity += 1;
        else
            parity[start_hole.parity] -= start_hole.size;
    }
    printf("%d\n", complexity);
    return 0;
}


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

// observations:
// mixed holes (any size) will always be 1 complexity no matter what, so they get leftovers at end
// even/odd holes (any size) will always add 0 or 2 (unless on the end)
//     ^ these should definitely be filled from small to large (should i sort then?)
// only question is how to handle the ends with regard to order of filling
// i think you'd want to remove as many 2's as possible then try to fill 1's (might require some backtracking)

typedef struct {
    short parity;
    int size;
} Hole;

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

int main() {
    int n, i;
    int nums[105];
    //int evencnt, mixcnt, oddcnt;  //holes
    //int endholeparity[2] = {0,0};
    int parity[2] = {0,0};         //existing evens,odds
    int complexity = 0;

    int ss,ee;
    Hole start_hole;
    Hole end_hole;
    Hole same_holes[55];
    int same_holes_cnt  = 0;

    int last = -1;

    scanf("%d", &n);
    for (i=0; i < n; i++) {
        scanf("%d", &nums[i]);
        if (nums[i] != 0 && (nums[i] % 2) + last == 1) {
            complexity += 1;
        }
        if (nums[i] != 0) {
            parity[nums[i] % 2]++;
            last = nums[i] % 2;
        }
        else {
            last = -1;
        }
    }
    //printf("base complexity: %d\n", complexity);

    parity[0] = n/2 - parity[0];       //existing/placed -> missing/available evens
    parity[1] = (n+1)/2 - parity[1];

    //printf("Have %2d evens\n     %2d odds\n", parity[0], parity[1]);

    for (i=0; nums[i] == 0 && i < n; i++);
    if (i == n) {     // all zeros
        if (n == 1)
            printf("0\n");
        else
            printf("1\n");
        return 0;
    }
    ss = i;
    start_hole.size = i;
    start_hole.parity = nums[i] % 2;
    for (i=n-1; nums[i] == 0 && i >= 0; i--);
    ee = i;
    end_hole.size = (n-1) - i;
    end_hole.parity = nums[i] % 2;

    //printf("start_size: %2d\n", start_hole.size);
    //printf("end_size:   %2d\n", end_hole.size);

    int cur_start = 0;

    for (i = ss; i <= ee; i++) {
        if (nums[i] == 0) {
            Hole hnew;
            cur_start = i;
            while (nums[++i] == 0 && i <= ee);
            hnew.size = i - cur_start; // ee guaranteed nonzero so no off by one
            hnew.parity = nums[cur_start-1] % 2;
            if (nums[i] % 2 != hnew.parity)
                complexity++;
            else
                same_holes[same_holes_cnt++] = hnew;
        }
    }
    //printf("Found %d holes\n", same_holes_cnt);
    qsort(same_holes, same_holes_cnt, sizeof(Hole), compare);
    for (i=0; i < same_holes_cnt; i++) {
        Hole tt = same_holes[i];
        if (parity[tt.parity] >= tt.size) {
            parity[tt.parity] -= tt.size;
        }
        else {
            complexity += 2;
            //printf("adding complexity\n");
        }
    }
    if (start_hole.size <= end_hole.size && end_hole.size != 0) {
        if (parity[start_hole.parity] < start_hole.size)
            complexity += 1;
        else
            parity[start_hole.parity] -= start_hole.size
        if (parity[end_hole.parity] < end_hole.size)
            complexity += 1;
        else
            parity[end_hole.parity] -= end_hole.size
    }
    else if (end_hole.size < start_hole.size) {
        if (parity[end_hole.parity] < end_hole.size)
            complexity += 1;
        else
            parity[end_hole.parity] -= end_hole.size
        if (parity[start_hole.parity] < start_hole.size)
            complexity += 1;
        else
            parity[start_hole.parity] -= start_hole.size
    }
    printf("%d\n", complexity);
    return 0;
}


#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#define rep(E, F) for (E = 0; E < (F); E++)
#define INF 1000000000

int mabs(int a) { if (a > 0) { return a; } return -a; }
int min(int a, int b) { if (a > b) { return b; } return a; }
int max(int a, int b) { if (a < b) { return b; } return a; }
int get_int();
double get_double();
int get_string(char* b, char t);
int n;
int d[2][100][100][100], a[100];
int chi(int a, int b) { return a == b ? 0 : 1; }

int foo(int b, int x, int y, int z)
{
	if (x == n) return 0;
	if (z < 0 || y < 0) return INF;
	if (d[b][x][y][z] != -1) return d[b][x][y][z];
	if (a[x] != -1 && a[x] != b) return INF;
	if (a[x] != -1) return d[b][x][y][z] = min(chi(0, b) + foo(0, x + 1, y, z), chi(1, b) + foo(1, x + 1, y, z));
	return d[b][x][y][z] = min(chi(0, b) + foo(0, x + 1, y - 1, z), chi(1, b) + foo(1, x + 1, y, z - 1));
}

int main()
{
	int i, j, k;
	n = get_int();
	rep(i, n) rep(j, n) rep(k, n) d[0][i][j][k] = d[1][i][j][k] = -1;
	int d[2] = {n/2, (n + 1)/2};
	rep(i, n) a[i] = get_int();
	rep(i, n) { rep(j, n) if (a[j] == i + 1) break; if (j < n) d[(i + 1)%2]--; }
	rep(i, n) if (a[i] == 0) a[i] = -1; else a[i] %= 2;
	int r = min(foo(0, 0, d[0], d[1]), foo(1, 0, d[0], d[1]));
	assert(r < INF);
	printf("%d\n", r);
	return 0;
}

int get_string(char* b, char t)
{
	int i = 0; b[i++] = getchar();
	while (b[i - 1] != t) b[i++] = getchar();
	b[i - 1] = '\0';
	return i - 1;
}

int get_int()
{
	int sgn = 1, ret = 0;
	char c  = getchar();
	while (1)
	{
		if (c == EOF) return EOF;
		if (c >= '0' && c <= '9') break;
		if (c == '-')
		{
			c = getchar();
			if (c < '0' || c > '9') continue;
			sgn = -1;
			break;
		}
		c = getchar();
	}

	while (1)
	{
		ret = ret*10 + c - '0';
		c = getchar();
		if (c < '0' || c > '9') return sgn*ret;
	}
}

double get_double()
{
	double ret = 0;
	char c     = getchar();
	int sgn;

	while (1)
	{
		if (c == EOF)
		{
			return EOF;
		}
		if (c >= '0' && c <= '9')
		{
			sgn = 1;
			break;
		}
		if (c == '-')
		{
			c = getchar();

			if (c < '0' || c > '9')
			{
				continue;
			}

			sgn = -1;
			break;
		}
		c = getchar();
	}

	while (1)
	{
		ret = ret*10 + c - '0';

		c = getchar();

		if (c == '.')
		{
			double pos = 0.1;

			c = getchar();
			while (c >= '0' && c <= '9')
			{
				ret += pos*(c - '0');
				pos /= 10;
				c = getchar();
			}

			return sgn*ret;
		}
		else if (c < '0' || c > '9')
		{
			return sgn*ret;
		}
	}
}


#include <stdio.h>

void   caballo (int m[][9], int f, int c)
{
/*8 mov tiene el caballo*/

    /*derecha 1 cuadro*/
  if(c+2<9 && f-1>0)/*9 final del tablero, arriba derecha columna+2*/
  {
    m[f-1][c+2]=1;

  }
    if(c+1<9 && f-2>0)/*9 final del tablero, arriba derecha columna+1*/
  {
    m[f-2][c+1]=1;
  }

  /*abajo derecha*/
    if(c+1<9 && f+2<9)/*9 final del tablero, arriba derecha colu+1*/
  {
    m[f+2][c+1]=1;
  }
    if(c+2<9 && f+1<9)/*9 final del tablero, arriba derecha colu+2*/
  {
    m[f+1][c+2]=1;
  }

  /*izquierda arriba*/
    if(c-1>0 && f-2>0)/* arriba del tablero, arriba izquierda fi-2*/
  {
    m[f-2][c-1]=1;
  }
    if(c-2>0 && f-1>0)/*arriba del tablero, arriba derecha fi-1*/
  {
    m[f-1][c-2]=1;
  }

  /*izquierda abajo*/
    if(c-1>0 && f+2<9)/*9 final del tablero, arriba derecha fi+2*/
  {
    m[f+2][c-1]=1;
  }
    if(c-2>0 && f+1<9)/*9 final del tablero, arriba derecha co+1*/
  {
    m[f+1][c-2]=1;
  }
  /*fin funcion*/

}

void torre (int m[][9], int f,int c)
{
    int aux;

    /*fila torre llenar de 1s*/
    for(aux=1; aux<=8; aux++)
    {
        m[f][aux]=1;
    }

        /*fila torre llenar de 1s*/
    for(aux=1; aux<=8; aux++)
    {
        m[aux][c]=1;
    }

}

void inici (int m[][8])
{
    int i,j;
    /*imprimir matriz*/
    for(i=1; i<9; i++){
        for(j=1; j<9; j++)
            m[i][j]=0;

    }
}

void resultado(int m[][9])
{
    int i,j,con=0;
    /*imprimir matriz*/
    for(i=1; i<9; i++){
        for(j=1; j<9; j++)
            if(m[i][j]==0)
                con++;
    }

    printf("%d",con);
}

main()
{

int ma[9][9]={0};
int i,j,i2;
char c;

/*primera linea entra torre*/
scanf("%c %d",&c,&i);
j=(int)c-'a';
j++; /*se pasa la letra a numero +1*/
i=9-i;/*posicion de fila invertida*/

inici(ma);
ma[i][j]=1;/*primera linea*/

/*se colocan 1s para la posicion del caballo y torre*/
caballo (ma,i,j);
torre (ma,i,j);

/*segunda linea*/
scanf("%1s %d",&c,&i2); /*guarda un solo caracter en la variable*/

j=(int)c-'a';
j++; /*se pasa la letra a numero +1*/
i2=9-i2;/*posicion de fila invertida*/
ma[i2][j]=1;/*primera linea*/

/*se colocan 1s para la posicion del caballo y torre*/
caballo (ma,i2,j);

resultado(ma);

}


#include<stdio.h>
#include<stdlib.h>
#define n 8

char Tablero[n][n];
int mov[n][2]={{-1,2},{-2,1},{-2,-1},{-1,-2},{1,-2},{2,-1},{2,1},{1,2}};
char columna[8]={'a','b','c','d','e','f','g','h'};
char fila[8]={'8','7','6','5','4','3','2','1'};

void caminoPieza(char *,char *);
int recorrerTablero(void);
int valido(int,int);

int main()
{
    char Torre[3],Caballo[3];

    scanf("%s",Torre);
    scanf("%s",Caballo);

    caminoPieza(&Torre[0],&Caballo[0]);
    printf("%d",recorrerTablero());

    system("PAUSE>NULL");
    return 0;
}

void caminoPieza(char *Torre,char *Caballo){
    int i,j,k;

    for(j=0;j<n;j++){if(columna[j]==Torre[0]){break;}}
    for(i=0;i<n;i++){if(fila[i]==Torre[1]){break;}}
    for(k=0;k<n;k++){
        Tablero[i][k]='*';
        Tablero[k][j]='*';
    }
    Tablero[i][j]='T';
    for(j=0;j<n;j++){if(columna[j]==Caballo[0]){break;}}
    for(i=0;i<n;i++){if(fila[i]==Caballo[1]){break;}}
    Tablero[i][j]='C';
    for(k=0;k<n;k++){
        if((i+mov[k][0])>=0 && (i+mov[k][0])<n && (j+mov[k][1])>=0 && (j+mov[k][1])<n && Tablero[i+mov[k][0]][j+mov[k][1]]!='T' && Tablero[i+mov[k][0]][j+mov[k][1]]!='C'){
            Tablero[i+mov[k][0]][j+mov[k][1]]='*';
        }
    }
}

int recorrerTablero(void){
    int i,j,cont=0;

    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(valido(i,j)==0){
                cont++;
            }
        }
    }
    return cont;
}

int valido(int i,int j){
    int x,y,k,band=0;

    if(Tablero[i][j]!='*' && Tablero[i][j]!='C' && Tablero[i][j]!='T'){
        for(k=0;k<n;k++){
            x=i+mov[k][0];
            y=j+mov[k][1];
            if(x>=0 && x<n && y>=0 && y<n && (Tablero[x][y]=='C' || Tablero[x][y]=='T')){
                band=1;
            }
        }
    }else{
        band=1;
    }
    return band;
}


//void imprimir();
void inicializar();
void posiciones(char pieza[],int *fila,int *columna);
void movimientoTorre(int x,int y);
void movimientoCaballo(int x,int y);
int recorrer();

int a[8] = { 2, 1,-1,-2,-2,-1, 1, 2};
int b[8] = {-1,-2,-2,-1, 1, 2, 2, 1};

char letras[9]="aabcdefgh";
char numeros[9]="112345678";
int tablero[N][N];

int main(){
    char caballo[2];
    char torre[2];
    int filaT=0,columnaT=0;
    int filaC=0,columnaC=0,mov;
    inicializar();

    scanf("%s",&torre);
    scanf("%s",&caballo);

    posiciones(torre,&filaT,&columnaT);
    posiciones(caballo,&filaC,&columnaC);

    movimientoCaballo(filaC,columnaC);
    //imprimir();
    movimientoTorre(filaT,columnaT);
    //imprimir();
    movimientoCaballo(filaT,columnaT);
    mov=recorrer();
    printf("%d",mov);
    return 0;
}
void movimientoTorre(int x,int y){
    int i;
    for(i=1;i<N;i++){
            tablero[x][i]=MarcaT;
            tablero[i][y]=MarcaT;
    }
}
void movimientoCaballo(int x,int y){
    int i,t,v;
    tablero[x][y]=MarcaC;
    for ( i=0; i<8; i++ ) {
        t=x+a[i];
        v=y+b[i];
        if(t>0 && t<N && v>0 && v<N){
            tablero[t][v]=MarcaC;
        }
    }
}
void posiciones(char pieza[],int *fila,int *columna){
    int i;
    for(i=1;i<N;i++){
        if(pieza[0]==letras[i]){
            *fila=i;
        }
        if(pieza[1]==numeros[i]){
            *columna=i;
        }
    }
}
void inicializar(){
    int i,j;
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            tablero[i][j]=0;
        }
    }
}
int recorrer(){
    int i,j,mov=0;
    for(i=1;i<N;i++){
        for(j=1;j<N;j++){
            if(tablero[i][j]==0)
                mov++;
        }
    }
    return mov;
}
/*void imprimir(){
    int i,j;
    printf("\n");
    for(i=1;i<N;i++){
        for(j=1;j<N;j++){
           printf("%d",tablero[i][j]);
        }
        printf("\n");
    }
}
*/


#include <stdio.h>

char piece[4];

int rx, ry, kx, ky;

int abs(int a){ return a < 0 ? -a : a; }

int ok(int x, int y){
    int dx = abs(x - kx), dy = abs(y - ky);
    if(abs(dx - dy) == 1 && dx + dy == 3) return 0;
    dx = abs(x - rx), dy = abs(y - ry);
    if(abs(dx - dy) == 1 && dx + dy == 3) return 0;
    return x != rx && y != ry && (x != kx || y != ky);
}

int main(){
    int ans = 0, i, j;
    scanf("%s", piece); rx = piece[0] - 'a', ry = piece[1] - '1';
    scanf("%s", piece); kx = piece[0] - 'a', ky = piece[1] - '1';
    for( i = 0; i < 8; ++i){
        for( j = 0; i < 8; ++j){
            ans += ok(i,j);
        }
    }
    printf("%d\n", ans);
    return 0;
}