Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet.

The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes).

Output the decoded ternary number. It can have leading zeroes.

#include <stdio.h>

int main() {
  char input[200 + 1], output[200 + 1] = "";
  char *in = input, *out = output;
  enum states {
    st_start,
    st_0,
    st_12,
    st_1,
    st_2
  };
  enum states state = st_start;
  struct branch {
    enum states new_state;
    int is_final;
  };
  struct branch table[5][2] = {
    // st_start
    { {st_0, 1}, {st_12, 0} },
    // st_0
    { {st_0, 1}, {st_12, 0} },
    // st_12
    { {st_1, 1}, {st_2, 1} },
    // st_1
    { {st_0, 1}, {st_12, 0} },
    // st_2
    { {st_0, 1}, {st_12, 0} }
  };
  struct branch *pb;

  scanf("%s", input);

  for (; *in != '\0'; ++in) {
    if (*in == '.') {
      pb = &table[state][0];
    } else {
      pb = &table[state][1];
    }
    state = pb->new_state;
    if (pb->is_final) {
      if (state == st_0) {
	*out = '0';
      } else if (state == st_1) {
	*out = '1';
      } else {
	*out = '2';
      }
      ++out;
    }
  }

  printf("%s", output);

  return 0;
}

#include<stdio.h>
int main()
{
    int flag=0;
    char temp;
    for(;scanf("%c",&temp) && temp!='\n';)
    {
        if(temp=='.')printf("0");
        else
        {
            scanf("%c",&temp);
            if(temp=='.')printf("1");
            else printf("2");
        }
    }
    printf("\n");
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int  take_input(char x[])
{
   int i=1;
   x[0]='0';
   while(x[i-1]!='\n')       //x[0]=0 && x[i-1]=\n;
    {
      scanf("%c",&x[i]);
      i++;
    }
  return i-1;
}
int main()
{

	char a[201];
	int l=take_input(a);
	//printf("%s\n",a);

	for (int i = 1; i < l ; i++)
	{
		if (a[i]=='.')
		{
			printf("0");
		}
		else if (a[i]=='-')
		{
			if (a[i+1]=='.')
			{
				printf("1");
				i++;
			}
			else if(a[i+1]=='-')
			{
				printf("2");
				i++;
			}
		}
	}

	return 0;
}

#include <stdio.h>
#include <string.h>
int main ()
{
    char str[210];
    gets(str);
    int i, l=strlen(str);
    for(i=0; i<l; i++)
    {
        if(str[i]=='.')
        {
            printf("0");
        }
        else if(str[i]=='-' && str[i+1]=='.')
        {
            printf("1");
            i++;
        }
        else if(str[i]=='-' && str[i+1]=='-')
        {
            printf("2");
            i++;
        }
    }
    printf("\n");
    return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    int i,l;
    char a[1000];
    scanf("%s",a);
    l=strlen(a);
    for(i=0; i<l; i=i+2)
    {
        if(a[i]=='-'&& a[i+1]=='-')
            printf("2");
        else if(a[i]=='-'&& a[i+1]=='.')
            printf("1");
            else if(a[i]=='.'){
            printf("0");
            i=i-1;
            }

    }
    return 0;
}

#include<stdio.h>
int main()
{
    int i=0;
    char arr[201];

    scanf("%s",arr);
    //printf("%s\n",arr );

    while(arr[i]!='\0'){
        if(arr[i]=='.'){
            printf("0");
        }
        else if(arr[i]=='-'){
            if(arr[i+1]=='.'){
                printf("1");
            }
            else{
                printf("2");
            }
           i++;
        }
        i++;
    }
    return 0;
}

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

int main()
{
    int i = 0;

    char str[202];

    scanf("%s", str);

    int ln = strlen(str);

     while( i < ln ){
         if(str[i] == '.') printf("0");
         else if(str[i] == '-' && str[i+1] == '.') {
                printf("1");
                i++;
                }
         else if(str[i] == '-' && str[i+1] == '-'){
            printf("2");
        i++;
         }
        i++;

    }
    printf("\n");

    return 0;

}

#include <stdio.h>

int main(void)
{
    char str[200];

    scanf("%[^\n]%*c", str);

    int size = sizeof(str) / sizeof(str[0]);

    for(int i = 0; i < size; i++)
    {
        if(str[i] == '.')
        {
            printf("0");
        }
        else if(str[i] == '-' && str[i+1] == '.')
        {
            printf("1");
            i++;
        }
        else if(str[i] == '-' && str[i+1] == '-')
        {
            printf("2");
            i++;
        }
    }

    return 0;
}

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

void call();

int main()
{
    call();
    return 0;
}

void call()
{
    int i;
    char borze[201];

    scanf("%[^\n]",borze);

    for(i=0; i<strlen(borze); i++)
    {

        if(borze[i]=='.')
            printf("0");
        else if(borze[i]=='-' && borze[i+1]=='.')
        {
            printf("1");
            i++;
        }

        else if(borze[i]=='-' && borze[i+1]=='-')
        {
            printf("2");
            i++;
        }

    }
}

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

		int i;
		char str[200];
		gets(str);
		for(i=0; i<strlen(str); i++)
			{
				if(str[i]=='.')
					printf("0");

				if(str[i]=='-'&&str[i+1]=='.')
				{
					printf("1");
					i++;
				}
				if(str[i]=='-'&&str[i+1]=='-')
				{

					printf("2");
					i++;
				}
			}

}

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

int main()
{
    char s[200];
    scanf("%s",s);
    int i;
    int len=strlen(s);
    for(i=0;i<len;i++)
    {
        if(s[i]=='.')
        {
            printf("0");
        }
        else if(s[i]=='-')
        {
            i++;
            if(s[i]=='.')
                printf("1");
            else if(s[i]=='-')
            {
                printf("2");
            }

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

#include <stdio.h>

int main()
{
	char string_in[250]={0},string_out[250]={0};
	int i = 0,g = 0;
	scanf("%s",string_in);
	do{
		if (string_in[i] == '.')
		{
			string_out[g] = '0';
			i++;g++;
		}
		else if (string_in[i] == '-')
		{
			if (string_in[i+1] == '.')    /*   '-.'  >>>>>1*/
			{
				string_out[g] = '1';
				g++;i+=2;
			}
			else if (string_in[i+1] == '-')
			{
				string_out[g] = '2';
				g++;i+=2;
			}

		}

	}while (string_in[i] !=0);

	string_out[g] = 0;

	printf("%s",string_out);

	return 0;
}

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

int main()
{
    char borze[201], dec[201];
    int n, i, j;
    scanf("%s", borze);
    n = strlen(borze);
    i = 0; j = 0;
    while(borze[i] != '\0')
    {
        if (borze[i] == '.') {j++; dec[j] = '0'; i++;}
        else
            if (borze[i + 1] == '.') {j++; dec[j] = '1'; i = i + 2;}
            else {j++; dec[j] = '2'; i = i + 2;}
    }
    for (i = 1; i <= j; i++)
    printf("%c", dec[i]);
    return 0;
}

#include<stdio.h>
#include<string.h>
int main(){
	char test[1000],hasil[1000];

	scanf("%s",test);

	int len = strlen(test);
	int i,j=0;

	for(i=0;i<len;i++){
		if(test[i]=='.'){
			hasil[j] = '0';
		}
		else if(test[i]=='-'&&test[i+1]=='.'){
			hasil[j] ='1';
			i+= 1;
		}
		else if(test[i]=='-' && test[i+1]=='-'){
			hasil[j] ='2';
			i+= 1;
		}
		j+=1;
	}
	int len1 = strlen(hasil);
	for(i=0;i<len1;i++){
	    if(hasil[i]=='1'||hasil[i]=='2'||hasil[i]=='0'){
	         printf("%c",hasil[i]);
	    }
	}
	return 0;

}

// no array used. single character has been consumed
#include <stdio.h>

int main(){
	char c;
	c=getchar();
	while(c=='.' || c=='-'){
		if(c=='.')
			putchar('0');
		else{
			if(getchar()=='-')
				putchar('2');
			else
				putchar('1');
		}
		c=getchar();
	}
	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
	char a[201];
	int i;
	scanf("%s",a);
	for(i=0;i<strlen(a);i++)
	{
	    if(a[i]=='.')
	    printf("0");
	    if(a[i]=='-')
	    {
	        if(a[i+1]=='.')
	        printf("1");
	        else
	        printf("2");
	        i++;
	    }
	}
	return 0;
}

// no array. single character has been consumed
#include <stdio.h>

int main(){
	char c;
	c=getchar();
	while(c=='.' || c=='-'){
		if(c=='.')
			putchar('0');
		else{
			//c=getchar();
			c=getchar();
			if(c=='-')
				putchar('2');
			else
				putchar('1');
		}
		c=getchar();
	}
	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,l,j=0;
    char ch[200];
    scanf("%s",ch);
    l=strlen(ch);
    for(i=0;i<l;i++){
        if(ch[i]=='.')
            printf("0");
        else if(ch[i]=='-'&&ch[i+1]=='.'){
            printf("1");
            i++;
        }
        else if(ch[i]=='-'&&ch[i+1]=='-'){
            printf("2");
            i++;
        }
    }
    return 0;
}

#include <stdio.h>

#include<string.h>
int main()
{
 int i,len;
 char a[200];

 scanf("%s",a);

 len=strlen(a);
 for(i=0;i<len;i++)
 {
     if(a[i]=='-' && a[i+1]=='.')
     {
         printf("1");
         i++;
     }
 else  if(a[i]=='-' && a[i+1]=='-')
     {
         printf("2");
         i++;
     }
 else if(a[i]=='.') printf("0");
 }
 printf("\n");
 return 0;
}

#include<stdio.h>
#include<string.h>
int main (){int i,l;char ternary[210];gets(ternary);l=strlen(ternary);for(i=0;i<l;i++){if(ternary[i]=='.')printf("0");else{if(ternary[i+1]=='.')printf("1");else printf("2");i++;}}printf("\n");return 0;}

#include<stdio.h>
int main(){
    char c[200];
    int i=0;
    scanf("%s",c);
    while(c[i]!='\0'){
        if(c[i]=='.') {printf("0");i++;continue;}
        else if(c[i]=='-'&&c[i+1]=='.'){printf("1");i+=2;continue;}
        else {printf("2");i+=2;continue;}
    }
}

#include<stdio.h>

int main()
{
    char s;

    while(scanf("%c", &s)!=EOF) {
       if(s=='.') {
          printf("0");
       }
       else if(s=='-') {
         s=getchar();
         if(s=='.') {
            printf("1");
         }
         else if(s=='-') {
            printf("2");
         }
        }
    }

    return 0;
}

#include <stdio.h>
#include <string.h>
// #define inout
int main()
{
// #ifdef inout
// 	freopen("input.txt", "r++", stdin);
// 	freopen("output.out", "w++", stdout);
// #endif
	int i, n, j;
	char num[200];
	scanf("%s", num);
	n = strlen(num);
	for (i = 0; i < n; i++)
	{
		if (num[i] == '.')
		{
			printf("%d", 0 );

		}
		else if (num[i] == '-' && num[i + 1] == '.')
		{
			printf("%d", 1 );
			i++;
		}
		else if (num[i] == '-' && num[i + 1] == '-')
		{
			printf("%d", 2 );
			i++;
		}
	}
	puts("");

	return 0;
}

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

int main()
{
    int i, len, j;
    char string[200];
    gets(string);
    len = strlen(string);

    int arra[len];

    for(i = 0, j = 0; i < len; i++, j++){
        if(string[i] == '-' && string[i + 1] == '-'){
            arra[j] = 2;
            i++;
        }
        else if(string[i] == '-' && string[i + 1] == '.'){

            arra[j] = 1;
            i++;
        }
        else arra[j] = 0;
    }

    for(i = 0; i < j; i++){
        printf("%d", arra[i]);
    }

    return 0;
}

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

int main()
{
    int i,l;
    char ara[9910];
    scanf("%s",&ara);

    l=strlen(ara);

    for(i=0;i<l;){
        if(ara[i]=='.'){
            printf("0");
            i=i+1;
        }
        else if(ara[i]=='-'){
            if(ara[i+1]=='.'){
                printf("1");
            }
            else{
                printf("2");
            }
            i=i+2;
        }

    }
    return 0;
}

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

int main()
{
    char a[201];
    scanf ("%s",a);
    int i = 0;
    while (i < strlen(a)) {
        if (a[i] == '-' && a[i + 1] == '.') {
            printf ("1");
            i++;
        }
        else if (a[i] == '-' && a[i + 1] == '-') {
             printf ("2");
             i++;
        }
        else {
            printf ("0");
        }
        i++;
    }
    printf ("\n");
    return 0;
}

#include <stdio.h>
#include <string.h>
int main(){
char arr[201];
int b;
scanf("%s",&arr);
b=strlen(arr);
for (int i=0;i<b;i++){
	if (arr[i]=='.'){
		printf("0");
	}
	else if(arr[i]=='-'&&arr[i+1]=='.'){
		printf("1");
		i++;
	}
	else if(arr[i]=='-'&&arr[i+1]=='-'){
		printf("2");
		i++;
	}
}
puts("");
return 0;
}

#include<stdio.h>
#include<string.h>
int main ()
{
    int l,i;
    char a[1000];
    scanf("%s",a);
    l=strlen(a);
    for(i=0; i<l; i++)
    {

        if(a[i]=='.')
        {
          printf("0");
        }

        else if(a[i]=='-' && a[i+1]=='.')
        {
             printf("1");
            i++;
        }

        else
            {

            printf("2");
            i++;
        }

    }
    printf("\n");

    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,n;
    char s[1000];
    scanf("%s",s);
    n=strlen(s);
    for(i=0;i<n;i++)
    {
        if (s[i]=='.')
        {
            printf("0");

        }
        else if(s[i]=='-' && s[i+1]=='.')
        {
            printf("1");
            i++;
        }
        else
        {
            printf("2");
            i++;

        }

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

#include <stdio.h>

int main()
{
    char str[201];
    scanf("%s", str);
    for(int i = 0; str[i]; ++i) {
        if(str[i] == '.') {
            putchar('0');
        } else {
            putchar(str[i + 1] == '.' ? '1' : '2');
            ++i;
        }
    }
    putchar('\n');
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char str[200];
    int i;
    //printf("Please enter the string\n");
    gets(str);
    for(i=0;str[i]!='\0';i++)
    {
        if(str[i]=='.')
        {
            printf("0");
        }
        if(str[i]=='-'&&str[i+1]=='.')
        {
            printf("1");
            i++;
        }
        if(str[i]=='-'&&str[i]=='-')
        {
            printf("2");
            i++;
        }
    }
}

#include<stdio.h>
int main()
{
    int i,j,flag=0;
    char temp;
    for(i=0;scanf("%c",&temp) && temp!='\n';i++)
    {
        if(temp=='.')
        {
            if(flag==0)printf("0");
            else
            {
                printf("1");
                flag=0;
            }
        }
        else
        {
            if(flag==1)
            {
                printf("2");
                flag=0;
            }
            else flag=1;
        }
    }
    return 0;
}

#include <stdio.h>
#define LEN 501
int main()
{
    char string[LEN];
    //scanf("%s", &string);
    gets(string);
    int i;
    for (i = 0; string[i] != '\0';i++)
    {
        if (string[i] == '-' && string[i + 1] == '-')
        {
            printf("2");
            i+=1;
        }
        else if (string[i] == '-' && string[i + 1] == '.')
        {
            printf("1");
            i+=1;
        }
        else if (string[i] == '.' && string[i - 1] == '-' || string[i - 1] != '-')
        {
            printf("0");
            //i-=1;
        }
    }
    return 0;
}

// no array. single character has been consumed
#include <stdio.h>

int main(){
	char c;
	c=getchar();
	while(c=='.' || c=='-'){
		if(c=='.')
			putchar('0');
		else{
			//c=getchar();
			c=getchar();
			if(c=='-')
				putchar('2');
			else
				putchar('1');
		}
		c=getchar();
	}
	return 0;
}

#include<stdio.h>
#include<string.h>
int main(){
    char str[200],s[200];
    scanf("%s",str);
    int l=strlen(str),flag=0,j=0;
    for(int i=0;i<l;i++){
        if(flag==1){
            if(str[i]=='.'){
                s[j]='1';
                j++;
            }
            else{
                s[j]='2';
                j++;
            }
            flag=0;
        }
        else{
            if(str[i]=='.'){
                s[j]='0';
                j++;
            }
            else{
                flag=1;
            }
        }
    }
    printf("%s",s);
    return 0;
}

#include<stdio.h>
int main()
{
    int i=0,newarr[200],x=0;
    char arr[201];

    scanf("%s",arr);

    while(arr[i]=='\0'){
        if(arr[i]=='.'){
            newarr[x]=0;
            x++;
            i++;
        }
        else{
            if(arr[i+1]=='.'){
                newarr[x]=1;
                x++;
                i=i+2;
            }
            else{
                newarr[x]=2;
                x++;
                i=i+2;
            }
        }
    for(i=0;i<x;i++){
        printf("%d",newarr[x]);
    }
	return 0;
}}

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

int main(void)
{
    char str[201];
    fflush(stdin);
    scanf("%s", &str);

    int size = sizeof(str) / sizeof(str[0]);

    for(int i = 0; i <= size; i++)
    {
        if(str[i] == '.')
        {
            printf("0");
        }
        else if(str[i] == '-' && str[i+1] == '.')
        {
            printf("1");
            i++;
        }
        else if(str[i] == '-' && str[i+1] == '-')
        {
            printf("2");
            i++;
        }
    }

    return 0;
}

#include <stdio.h>
#include <string.h>
int main()
{
	int count=0,n,i;
	char arr[100];
	fgets(arr,100,stdin);
	puts(arr);
	for(i=0;i<strlen(arr);i++)
	{
		if(arr[i]=='.')
		printf("0");
		if(arr[i]=='-')
		{
			if(arr[i+1]=='-')
			printf("2");
			else if(arr[i+1]=='.')
			printf("1");
			else
			continue;
			i++;
		}
	}

	return 0;
}

#include <stdio.h>

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

	char S[256];
	scanf("%s",S);

	for(int i = 0; S[i] != '\0'; i++){
		if(S[i] == '.'){
			printf("0");
		}
		else{
			if(S[i+1] == '.'){
				printf("1");
				i++;
			}
			else{
				printf("2");
				i++;
				i++;
			}
		}
	}

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

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

int main(){
  char a[201],i;
  i=0;
  scanf("%s",a);
  while(a[i]){
    if(a[i]=='.') { printf("0"); i++; }
    else {
      if(a[i+1]=='.') printf("1");
      else printf("2");
      i+=2;
}
  }
  printf("\n");
  return 0;
}

#include <stdio.h>

int main(void)
{
    char str[200];

    scanf("%s", &str);

    int size = sizeof(str) / sizeof(str[0]);

    for(int i = 0; i < size; i++)
    {
        if(str[i] == '.')
        {
            printf("0");
        }
        else if(str[i] == '-' && str[i+1] == '.')
        {
            printf("1");
            i++;
        }
        else if(str[i] == '-' && str[i+1] == '-')
        {
            printf("2");
            i++;
        }
    }

    return 0;
}

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

    int a,i,k=0,d;
    int ara[150];
    char s[150];
    scanf("%d",&a);
    scanf("%s",&s);
    for(i=0;i<a;i++)
    {

        if(s[i]=='1'){
            ara[k]=i;
            k++;
        }
    }
    for(i=0;i<k-1;i++){
        if(i==0){
            d=ara[i+1]-ara[i];
        }
        else if(d!=ara[i+1]-ara[i]){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
}

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

int main()
{
	char bor[201],c=0;
	int code[201];
	scanf("%s",bor);
	int i=1;
	while(i<strlen(bor)){
		if(bor[i]=='-' && bor[i-1]=='-'){
			code[c]=2;
			i=i+2;
		}
		else if(bor[i]=='.' && bor[i-1]=='-'){
			code[c]=1;
			i=i+2;
		}
		else{
			code[c]=0;
			i++;
		}
		c++;
	}

	for(int j=0;j<=c;j++){
		printf("%d",code[j]);
	}

}

#include<stdio.h>
#include<string.h>
int main()
{
	char input[205];
	scanf("%s",input);
	int len = strlen(input);
	int count = 0;
	for(int i = 0;i<len;i++)
	{
		if(input[i] == '-' && input[i+1] == '-')
		{
			printf("2");
		}
		else if(input[i] == '.' & count<1)
		{
			printf("0");
			count++;
		}
		else if(input[i] == '-' && input[i+1] == '.')
		{
			printf("1");
		}

	}

}

#include <stdio.h>
#include <string.h>
int main()
{
    int i=0,n,m=0;
    char name[3];
    scanf("%s",name);

    char new[6];
    n=strlen(name);
    while(i<=n-1)
    {
        if(name[i]=='.')
        {
            new[m]='0';
            i++;
            m++;
        }
        else if(name[i]='-')
            {
                if(name[i+1]='.')
                {
                    new[m]='1';
                    m++;
                    i=i+2;
                }
                else if(name[i+1]='-')
                {
                    new[m]='2';
                    m++;
                    i=i+2;
                }

            }
    }
    new[m+1]='\0';
    printf("%s",new);

}

/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>
#include<string.h>
int main()
{  char str[201];
   int arr[strlen(str)],index=0;
  scanf("%s",str);

  for(int i=0;i<strlen(str);i++){
      if(str[i]=='.'){
          arr[index]=0;
          index++;
          continue;
      }
           if(str[i]=='-'){
               if(str[i+1]=='-'){arr[index]=2;
                   index++;
                   i++;
                   continue;
               }
               if(str[i+1]=='.'){arr[index]=1;
                   index++;
                   i++;
                   continue;
               }
           }
  }

 for(int i=0;i<index;i++){
      printf("%d",arr[i]);}

    return 0;
}

#include <stdio.h>

int main(void)
{
    char str[200];

    scanf("%s", &str);

    int size = sizeof(str) / sizeof(str[0]);

    for(int i = 0; i < size; i++)
    {
        if(str[i] == '.')
        {
            printf("0");
        }
        else if(str[i] == '-' && str[i+1] == '.')
        {
            printf("1");
            i+=2;
            continue;
        }
        else if(str[i] == '-' && str[i+1] == '-')
        {
            printf("2");
            i+=2;
            continue;
        }
    }

    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char ch[210];
    gets(ch);
    int l=strlen(ch),i;
    for(i=0;i<=201;i++)
    {
        if(ch[i]=='.') printf("0");
        else if(ch[i]=='-' && ch[i+1]=='-') {printf("1"); i++;}
        else if(ch[i]=='-' && ch[i+1]=='-') {printf("2"); i++;}
        else break;
    }
}

#include<stdio.h>
#include<string.h>
int main()
{
      int i,l;
      char s[1000];
      scanf("%s",s);
      l=strlen(s);
      for(i=0;i<l;i++)
      {
            if(s[i]=='.')
            printf("0");
            else
            {
                  if(s[i+1]=='.')
                  printf("1");
                  else
                  printf("2");
            }
      }
      printf("\n");
}

#include <stdio.h>

int main(void)
{
    char str[200];

    scanf("%s", &str);

    int size = sizeof(str) / sizeof(str[0]);

    for(int i = 0; i < size; i++)
    {
        if(str[i] == '.')
        {
            printf("0");
        }
        else if(str[i] == '-' && str[i+1] == '.')
        {
            printf("1");
            i++;
            continue;
        }
        else if(str[i] == '-' && str[i+1] == '-')
        {
            printf("2");
            i++;
            continue;
        }
    }

    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{int n,i,a=0,b=1,c=2;
char arr[200];
scanf("%s",arr);
for (i=0;i<n;++i)
    {if (arr[i]=='.')
        {printf("%d",a);}
    else if (arr[i]=='-' && arr[i+1]=='.' )
        {printf("%d",b); i++;}
   else if (arr[i]=='-' && arr[i+1]=='-')
        {printf("%d",c); i++;}
    }
    return 0;
}

#include <stdio.h>
#include <string.h>
int main ()
{
    char str[100];
    gets(str);
    int i, l=strlen(str);
    for(i=0; i<l; i++)
    {
        if(str[i]=='.')
        {
            printf("0");
        }
        else if(str[i]=='-' && str[i]=='.')
        {
            printf("1");
            i++;
        }
        else if(str[i]=='-' && str[i]=='-')
        {
            printf("2");
            i++;
        }
    }
    printf("\n");
    return 0;
}

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

int main(){
    char x[200];
    scanf("%s",x);
    //printf("%s",x);
    int len=strlen(x);
    int y[len];
    //printf("%d %d",'-','.');
    for(int i=0;i<len;i++){
        y[i]=x[i]-'-';
        printf("%d ",y[i]);
    }
    for(int i=0;i<len;i++){
        if(y[i]==1){
            printf("0");
        }else if(y[i]==0&&y[i+1]==0){
            printf("2");
            i++;
        }else if(y[i]==0&&y[i+1]==1){
            printf("1");
            i++;
        }
    }
    return 0;
}

#include<stdio.h>
#include<string.h>
int main(){
	char test[1000],hasil[1000];

	gets(test);

	int len = strlen(test);
	int i,j=0;

	for(i=0;i<len;i++){
		if(test[i]=='.'){
			hasil[j] = '0';
		}
		else if(test[i]=='-'&&test[i+1]=='.'){
			hasil[j] ='1';
			i+= 1;
		}
		else if(test[i]=='-' && test[i+1]=='-'){
			hasil[j] ='2';
			i+= 1;
		}
		j++;
	}
	printf("%s",hasil);

	return 0;

}

#include<stdio.h>
#include<string.h>
int main()
{
    int n,j;
    char crypt[n] ;
    gets(crypt);
    n=strlen(crypt);
    for(j = 0 ; j<n ; j++)
    {
      if (crypt[j]== '.')
        { printf("0"); }
      else if ( crypt[j]== '-' && crypt[j+1]== '.' &&j!=n-1)
        { printf("1");j++ ;}
      else if ( crypt[j]== '-' && crypt[j+1]== '-'&&j!=n-1 )
        { printf("2"); j++;}

    }
    return 0;
}

#include <stdio.h>
int main() {
    int count=0;
    signed char ch;
    ch=getchar();
    while (ch!=EOF) {
        if (ch=='.') {
            printf("%d",count);
            count=0;
        } else if (ch=='-') {
            count++;
        }
        ch=getchar();
    }
    printf("%d",count);
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,n,a;
    char s[100];
    scanf("%s",s);
    n=strlen(s);
    for(i=0;i<n;i++)
    {
        if(s[i]=='.')
        {
            printf("0");

        }
        else if(s[i]=='-' && s[i+1]=='.')
        {
            printf("1");
        }
        else
        {
            printf("2");

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

#include<stdio.h>
#include<string.h>
int main()
{
	char input[205];
	scanf("%s",input);
	int len = strlen(input);
	int count = 0;
	int flag = 0;
	for(int i = 0;i<len;i++)
	{
		if(input[i] == '-' && input[i+1] == '-')
		{
			flag = 1;
			printf("2");
		}
		else if(flag == 1 && input[i] == '-')
		{
			continue;
		}
		else if(input[i] == '-')
		{
			printf("1");
			flag = 0;
		}
		else if(input[i] == '.' & count<1)
		{
			printf("0");
			count++;
			flag = 0;
		}

	}

}

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

main()
{
    char c[210];
    int i,len=0;
    gets(c);
    for(i=0;c[i]!='\0';++i) {
        if(c[i]=='.') {
            printf("%d",len);
            len=0;
        }
        else len++;
    }
    printf("%d\n",len);
    return 0;
}

#include <stdio.h>
#include <string.h>
#define inout
int cnt;
int main()
{
// #ifdef inout
// 	freopen("input.txt", "r++", stdin);
// 	freopen("output.out", "w++", stdout);
// #endif
	int i, n;
	char num[200];
	scanf("%s", num);
	n = strlen(num);
	char num2[n + 1];
	for (i = 0; i < n; i++)
	{
		if (num[i] == '.')
		{
			num2[cnt++] = '0';

		}
		else if (num[i] == '-' && num[i + 1] == '.')
		{
			num2[cnt++] = '1';
			i++;
		}
		else if (num[i] == '-' && num[i + 1] == '-')
		{
			num2[cnt++] = '2';
			i++;
		}
	}
	printf("%s\n", num2);

	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
	int i,n;
	char str[200];
	scanf("%s",&str);
    n=strlen(str);
    for(i=0;i<n;i++)
    {
    	if(str[i]=='.')
    	{
    		printf("0");
    		continue;
		}
		else if(str[i]=='-' && str[i+1]=='.')
		{
			printf("1");
			continue;
		}
		else if(str[i]=='-' && str[i+1]=='-')
		{
			printf("2");
			continue;
		}
	}
	return 0;

}

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

int main()
{
	char a[201];
	int i;
	fgets(a,200,stdin);
	for(i = 0; i < strlen(a);i++)
	{
		if(a[i] == '.' /*&& a[i-1] != '-'*/)
		{
		printf("0");
		continue;
		}
		if(a[i] == '-' && a[i+1] == '-')
		{
		printf("2");
		i++;
		continue;

	}
	if(a[i] == '-' && a[i+1] == '.')
		{
		printf("1");
		i++;
		continue;
	}

		}
	return 0;
	}

#include<stdio.h>
#include<string.h>
int main()
{
    char a[201];
	scanf("%s",&a);

	int i,l;
	l=strlen(a);
	for(i=0;i<l;i++){

        if(a[i]=='.')
        printf("%d",0);
        else{
        	if(a[i+1]=='.'){
        		printf("%d",1);
        		i=i+2;
			}
			else{
				printf("%d",2);
				i=i+2;
			}
		}
	}

return 0;
}

#include <stdio.h>
#include <string.h>
int main(){
char arr[201];
int b;
scanf("%s",&arr);
b=strlen(arr);
for (int i=0;i<b;i++){
	if (arr[i]=='.'){
		printf("0");
		continue;
	}
	else if(arr[i]=='-'&&arr[i+1]=='.'){
		printf("1");
		continue;
	}
	else if(arr[i]=='-'&&arr[i+1]=='-'){
		printf("2");
		continue;
	}
}
puts("");
return 0;
}

#include <stdio.h>

int main()
{
	char string_in[201]={0},string_out[201]={0};
	char i = 0,g = 0;
	scanf("%s",string_in);
	do{
		if (string_in[i] == '.')
		{
			string_out[g] = '0';
			i++;g++;
		}
		else if (string_in[i] == '-')
		{
			if (string_in[i+1] == '.')    /*   '-.'  >>>>>1*/
			{
				string_out[g] = '1';
				g++;i+=2;
			}
			else if (string_in[i+1] == '-')
			{
				string_out[g] = '2';
				g++;i+=2;
			}

		}

	}while (string_in[i] !=0);

	string_out[g] = 0;

	printf("%s",string_out);

	return 0;
}

#include <stdio.h>

int main(void)
{
    char str[201];
    fflush(stdin);
    scanf("%s", &str);

    int size = sizeof(str) / sizeof(str[0]);

    for(int i = 0; i <= size; i++)
    {
        if(str[i] == '.')
        {
            printf("0");
        }
        else if(str[i] == '-' && str[i+1] == '.')
        {
            printf("1");
            i++;
        }
        else if(str[i] == '-' && str[i+1] == '-')
        {
            printf("2");
            i++;
        }
    }

    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i;
    char A[200];

    for(i=0;i<200;i++)
    {
        scanf("%c ",&A[i]);
    }
    for(i=0;i<200;i++)
    {
        if(A[i]=='.')
        {
            printf("0");
            break;
        }
        else if(A[i]=='-')
                {
                    if(A[i+1]=='.')
                    {
                        printf("1");
                        break;
                    }
                    else
                    {
                        printf("2");
                        break;
                    }
                }
    }
return 0;

}

#include <stdio.h>

int main(void)
{
    char str[200];

    scanf("%s", &str);

    int size = sizeof(str) / sizeof(str[0]);

    for(int i = 0; i <= size; i++)
    {
        if(str[i] == '.')
        {
            printf("0");
        }
        else if(str[i] == '-' && str[i+1] == '.')
        {
            printf("1");
            i++;
        }
        else if(str[i] == '-' && str[i+1] == '-')
        {
            printf("2");
            i++;
        }
    }

    return 0;
}

#include <stdio.h>

int main()
{
	char string_in[200]={0},string_out[200]={0};
	char i = 0,g = 0;
	scanf("%s",string_in);
	do{
		if (string_in[i] == '.')
		{
			string_out[g] = '0';
			i++;g++;
		}
		else
		{
			if (string_in[i+1] == '.')    /*   '-.'  >>>>>1*/
			{
				string_out[g] = '1';
				g++;i+=2;
			}
			else
			{
				string_out[g] = '2';
				g++;i+=2;
			}

		}

	}while (string_in[i] !=0);

	string_out[g] = 0;

	printf("%s",string_out);

	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char s[201];
    int count=0, i ,p ;
    gets(s);
    for(i=0 ; i<strlen(s) ; i++)
    {
      if(s[i]=='-')
            count++;
      if(s[i]=='.' )
          {
              if(count>2)
              {
                  count=count-2;
                    p=2;
               printf("%d",p);
               printf("%d",count);
               count=0;

              }
              else{
               printf("%d",count);
               count=0;
               }

          }

    }
printf("%d",count);

    return 0;
}

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

int main()
{
    int i,l;
    char ara[9910];
    scanf("%s",&ara);

    l=strlen(ara);
    printf("%d",l);

    for(i=0;i<l;){
        if(ara[i]=='.'){
            printf("0");
            i=i+1;
        }
        else if(ara[i]=='-'){
            if(ara[i+1]=='.'){
                printf("1");
            }
            else{
                printf("2");
            }
            i=i+2;
        }

    }
    return 0;
}

#include <stdio.h>
#include <string.h>
int main(){
char arr[201];
int b;
scanf("%s",&arr);
b=strlen(arr);
for (int i=0;i<b;i++){
	if (arr[i]=='.'){
		printf("0");
	}
	else if(arr[i]=='-'&&arr[i+1]=='.'){
		printf("1");
		continue;
	}
	else if(arr[i]=='-'&&arr[i+1]=='-'){
		printf("2");
		continue;
	}
}
puts("");
return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char the[200];
    char thi[200];
    int i =0;
    int f = -1;
    scanf("%s",the);
    while (i< (strlen(the))){
        if (the[i]=='-' && the[i+1]=='.'){
            f+=1;
            thi[f]='1';
            i+=2;
        }
        else if (the[i]=='-' && the[i+1]=='-'){
            f+=1;
            thi[f]='2';
            i+=2;

        }
        else if (the[i]=='.'){
            f+=1;
            thi[f]='0';
            i+=1;
        }

    }
    printf("%s",thi);
    return 0;
}

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

int main()
{
	char bor[201],c=0;
	int code[201];
	scanf("%s",bor);
	int i=0;
	while(i<strlen(bor)){
		if(bor[i]=='-' && bor[i+1]=='-'){
			code[c]=2;
			i=i+2;
		}
		else if(bor[i]=='.' && bor[i+1]=='-'){
			code[c]=1;
			i=i+2;
		}
		else{
			code[c]=0;
			i++;
		}
		c++;
	}

	for(int j=0;j<c;j++){
		printf("%d",code[j]);
	}

}

#include<stdio.h>
#include<string.h>
int main()
{
    int i;
    char str[205];
    scanf("%s", str);
    int l = strlen(str);

    for(i=0; i<l; i++)
    {
        if(str[i] == '-')
        {
            if(str[i+1] == '-')
            {
                printf("2");
            }
            else if(str[i+1] == '.')
            {
                printf("1");
            }
        }

        else if (str[i] == '.')
        {
            printf("0");
        }

    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char the[100];
    char thi[100];
    int i =0;
    int f = -1;
    scanf("%s",the);
    while (i< (strlen(the))){
        if (the[i]=='-' && the[i+1]=='.'){
            f+=1;
            thi[f]='1';
            i+=2;
        }
        else if (the[i]=='-' && the[i+1]=='-'){
            f+=1;
            thi[f]='2';
            i+=2;

        }
        else if (the[i]=='.'){
            f+=1;
            thi[f]='0';
            i+=1;
        }

    }
    printf("%s",thi);
    return 0;
}

#include <stdio.h>

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

	char S[256];
	scanf("%s",S);

	for(int i = 0; S[i] != '\0'; i++){
		if(S[i] == '.'){
			printf("0");
		}
		else{
			if(S[i+1] == '.'){
				printf("1");
				i++;
			}
			else{
				printf("2");
				i++;
				i++;
			}
		}
	}

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

#include <stdio.h>
#include <string.h>
int main()
{
    int i=0,n,m=0;
    char name[3];
    scanf("%s",name);

    char new[6];
    n=strlen(name);
    while(i<=n-1)
    {
        if(name[i]=='.')
        {
            new[m]='0';
            i++;
            m++;
        }
        else if(name[i]='-')
            {
                if(name[i+1]='.')
                {
                    new[m]='1';
                    m++;
                    i=i+2;
                }
                else if(name[i+1]='-')
                {
                    new[m]='2';
                    m++;
                    i=i+2;
                }

            }
    }
    new[m]='\0';
    printf("%s",new);

}


There is a binary string $$$t$$$ of length $$$10^{100}$$$, and initally all of its bits are $$$\texttt{0}$$$. You are given a binary string $$$s$$$, and perform the following operation some times:   Select some substring of $$$t$$$, and replace it with its XOR with $$$s$$$.$$$^\dagger$$$  After several operations, the string $$$t$$$ has exactly two bits $$$\texttt{1}$$$; that is, there are exactly two distinct indices $$$p$$$ and $$$q$$$ such that the $$$p$$$-th and $$$q$$$-th bits of $$$t$$$ are $$$\texttt{1}$$$, and the rest of the bits are $$$\texttt{0}$$$. Find the lexicographically largest$$$^\ddagger$$$ string $$$t$$$ satisfying these constraints, or report that no such string exists.$$$^\dagger$$$ Formally, choose an index $$$i$$$ such that $$$0 \leq i \leq 10^{100}-|s|$$$. For all $$$1 \leq j \leq |s|$$$, if $$$s_j = \texttt{1}$$$, then toggle $$$t_{i+j}$$$. That is, if $$$t_{i+j}=\texttt{0}$$$, set $$$t_{i+j}=\texttt{1}$$$. Otherwise if $$$t_{i+j}=\texttt{1}$$$, set $$$t_{i+j}=\texttt{0}$$$.$$$^\ddagger$$$ A binary string $$$a$$$ is lexicographically larger than a binary string $$$b$$$ of the same length if in the first position where $$$a$$$ and $$$b$$$ differ, the string $$$a$$$ has a bit $$$\texttt{1}$$$ and the corresponding bit in $$$b$$$ is $$$\texttt{0}$$$.

The only line of each test contains a single binary string $$$s$$$ ($$$1 \leq |s| \leq 35$$$).

If no string $$$t$$$ exists as described in the statement, output -1. Otherwise, output the integers $$$p$$$ and $$$q$$$ ($$$1 \leq p < q \leq 10^{100}$$$) such that the $$$p$$$-th and $$$q$$$-th bits of the lexicographically maximal $$$t$$$ are $$$\texttt{1}$$$.

NoteIn the first test, you can perform the following operations. $$$$$$\texttt{00000}\ldots \to \color{red}{\texttt{1}}\texttt{0000}\ldots \to \texttt{1}\color{red}{\texttt{1}}\texttt{000}\ldots$$$$$$In the second test, you can perform the following operations. $$$$$$\texttt{00000}\ldots \to \color{red}{\texttt{001}}\texttt{00}\ldots \to \texttt{0}\color{red}{\texttt{011}}\texttt{0}\ldots$$$$$$In the third test, you can perform the following operations. $$$$$$\texttt{00000}\ldots \to \color{red}{\texttt{1111}}\texttt{0}\ldots \to \texttt{1}\color{red}{\texttt{0001}}\ldots$$$$$$It can be proven that these strings $$$t$$$ are the lexicographically largest ones.In the fourth test, you can't make a single bit $$$\texttt{1}$$$, so it is impossible.

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

#define N	35
#define N_	((N + 1) / 2)

unsigned int X;

void srand_() {
	struct timeval tv;

	gettimeofday(&tv, NULL);
	X = tv.tv_sec ^ tv.tv_usec | 1;
}

int rand_() {
	return (X *= 3) >> 1;
}

void multiply(char *aa, char *bb, char *md, int n) {
	static char cc[N * 2];
	int i, j;

	memset(cc, 0, n * 2 * sizeof *cc);
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			if (aa[i] && bb[j])
				cc[i + j] ^= 1;
	for (i = n * 2 - 1; i >= n - 1; i--)
		if (cc[i])
			for (j = 0; j < n; j++)
				if (md[j])
					cc[i - (n - 1 - j)] ^= 1;
	memcpy(aa, cc, n * sizeof *cc);
}

char ppp[1 << N_][N]; int n;

int compare(int i, int j) {
	int c = memcmp(ppp[i], ppp[j], n * sizeof *ppp[j]);

	return c ? c : i - j;
}

void sort(int *ii, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;

		while (j < k) {
			int c = compare(ii[j], i_);

			if (c == 0)
				j++;
			else if (c < 0) {
				tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
			}
		}
		sort(ii, l, i);
		l = k;
	}
}

int search(int *ii, int m, char *pp) {
	int lower = -1, upper = m;

	while (upper - lower > 1) {
		int i = (lower + upper) / 2;

		if (memcmp(ppp[ii[i]], pp, n * sizeof *ppp[ii[i]]) >= 0)
			upper = i;
		else
			lower = i;
	}
	return upper < m && memcmp(pp, ppp[ii[upper]], n * sizeof *ppp[ii[upper]]) == 0 ? ii[upper] : -1;
}

int main() {
	static char cc_[N + 1], *cc, md[N], xx[N], vv[N], pp[N], pp_[N];
	static int rr[1 << N_];
	int n_, p, q, r, i, j, one;
	char tmp;

	srand_();
	scanf("%s", cc_), n = strlen(cc_);
	p = 0;
	while (p < n && cc_[p] == '0')
		p++;
	if (p == n) {
		printf("-1\n");
		return 0;
	}
	cc = cc_ + p, n -= p;
	while (cc[n - 1] == '0')
		n--;
	if (n == 1) {
		printf("%d %d\n", p + 1, p + 2);
		return 0;
	}
	n_ = (n + 1) / 2;
	cc[n] = 0;
	for (i = 0, j = n - 1; i < j; i++, j--)
		tmp = cc[i], cc[i] = cc[j], cc[j] = tmp;
	for (i = 0; i < n; i++)
		md[i] = cc[i] - '0';
	for (j = 0; j < n - 1; j++)
		vv[j] = md[j + 1];
	memset(pp, 0, n * sizeof *pp), pp[0] = 1;
	for (r = 0; r < 1 << n_; r++) {
		memcpy(ppp[r], pp, n * sizeof *pp);
		one = 1;
		for (i = 0; i < n; i++)
			if ((pp[i] == 1) != (i == 0)) {
				one = 0;
				break;
			}
		if (one && r != 0) {
			printf("%d %d\n", p + 1, p + 1 + r);
			return 0;
		}
		multiply(pp, vv, md, n);
	}
	for (r = 0; r < 1 << n_; r++)
		rr[r] = r;
	sort(rr, 0, 1 << n_);
	memset(pp_, 0, n * sizeof *pp_), pp_[0] = 1;
	xx[1] = 1, multiply(xx, pp_, md, n);
	for (r = 0; r < 1 << n_; r++)
		multiply(pp_, xx, md, n);
	memset(pp, 0, n * sizeof *pp), pp[0] = 1;
	for (q = 1; q <= 1 << n_; q++) {
		multiply(pp, pp_, md, n);
		if ((r = search(rr, 1 << n_, pp)) != -1) {
			printf("%d %lld\n", p + 1, p + 1 + ((long long) q << n_) + r);
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}


When Valera was playing football on a stadium, it suddenly began to rain. Valera hid in the corridor under the grandstand not to get wet. However, the desire to play was so great that he decided to train his hitting the ball right in this corridor. Valera went back far enough, put the ball and hit it. The ball bounced off the walls, the ceiling and the floor corridor and finally hit the exit door. As the ball was wet, it left a spot on the door. Now Valera wants to know the coordinates for this spot.Let's describe the event more formally. The ball will be considered a point in space. The door of the corridor will be considered a rectangle located on plane xOz, such that the lower left corner of the door is located at point (0, 0, 0), and the upper right corner is located at point (a, 0, b) . The corridor will be considered as a rectangular parallelepiped, infinite in the direction of increasing coordinates of y. In this corridor the floor will be considered as plane xOy, and the ceiling as plane, parallel to xOy and passing through point (a, 0, b). We will also assume that one of the walls is plane yOz, and the other wall is plane, parallel to yOz and passing through point (a, 0, b).We'll say that the ball hit the door when its coordinate y was equal to 0. Thus the coordinates of the spot are point (x0, 0, z0), where 0 ≤ x0 ≤ a, 0 ≤ z0 ≤ b. To hit the ball, Valera steps away from the door at distance m and puts the ball in the center of the corridor at point . After the hit the ball flies at speed (vx, vy, vz). This means that if the ball has coordinates (x, y, z), then after one second it will have coordinates (x + vx, y + vy, z + vz).See image in notes for clarification.When the ball collides with the ceiling, the floor or a wall of the corridor, it bounces off in accordance with the laws of reflection (the angle of incidence equals the angle of reflection). In the problem we consider the ideal physical model, so we can assume that there is no air resistance, friction force, or any loss of energy.

The first line contains three space-separated integers a, b, m (1 ≤ a, b, m ≤ 100). The first two integers specify point (a, 0, b), through which the ceiling and one of the corridor walls pass. The third integer is the distance at which Valera went away from the door. The second line has three space-separated integers vx, vy, vz (|vx|, |vy|, |vz| ≤ 100, vy < 0, vz ≥ 0) — the speed of the ball after the hit. It is guaranteed that the ball hits the door.

Print two real numbers x0, z0 — the x and z coordinates of point (x0, 0, z0), at which the ball hits the exit door. The answer will be considered correct, if its absolute or relative error does not exceed 10  - 6.

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

#define MAX
#define MODBY 1000000007
#define NIL (1e-8)

typedef long long int lld;
typedef float Lf;

int i,j,n;
Lf x,y,z;
int vix,viy,viz;
int a,b;
Lf vx,vy,vz;
Lf tmin,t1;
int cmp(Lf f,Lf s)
{ return ((fabs(f-s)<NIL));}
int main()
{
   s(a);s(b);sf(y);
   s(vix);s(viy);s(viz);
   vx=vix;vy=viy;vz=viz;
   z=0;x=a/2.0;

   //printf("ball is at %Lf,%Lf,%Lf\n",x,y,z);
   //   while(!cmp(y,0)){
   int cnt=18;
   while(y>0){
      tmin=INT_MAX;
      if(vix){
         t1=-x/vx;//x=0 plane

         if((t1>0)&&(t1<tmin)){
            tmin=t1;
         }
         t1=-(x-a)/vx;
         if((t1>0)&&(t1<tmin)){
            tmin=t1;
         }
      }
      if(viz){
         t1=-z/vz;//z=0 plane
         if((t1>0)&&(t1<tmin)){
            tmin=t1;
         }
         t1=-(z-b)/vz;
         if((t1>0)&&(t1<tmin)){
            tmin=t1;
         }
      }
      if(viy){
         t1=-y/vy;//y=0 plane
         if((t1>0)&&(t1<tmin)){
            tmin=t1;
         }
      }
      x=x+vx*tmin;
      y=y+vy*tmin;
      z=z+vz*tmin;
   //   printf("ball is at %Lf,%Lf,%Lf\n",x,y,z);
      if(vix!=0)
         if((x==0)||(x==a)) vx*=-1;
      if(viz!=0){
         if((z==0)||(z==b)) vz*=-1;
      }
      //else break;
   }
   printf("%f %f\n",x,z);
   return 0;
}

#include <stdio.h>
double a,b,m;
int vx,vy,vz;
int main()
{
    double t,d;
    scanf("%lf%lf%lf%d%d%d",&a,&b,&m,&vx,&vy,&vz);
    t = m/-vy;

    d = (vx>0?vx:-vx)*t;
    if(d<a/2) printf("%.9f ",vx>0?a/2+d:a/2-d);
    else
    {
        for(d-=a/2,vx=-vx;d>a;d-=a,vx=-vx);
        printf("%.9f ",vx>0?d:a-d);
    }

    d = (vz>0?vz:-vz)*t;
    for(;d>b;d-=b,vz=-vz);
    printf("%.9f",vz>=0?d:b-d);

    return 0;
}

#include <stdio.h>

int main() {
    int a, b, m, vx, vy, vz;
    double x0, z0, time;

    scanf("%d %d %d", &a, &b, &m);
    scanf("%d %d %d", &vx, &vy, &vz);

    time = - (double) m / vy;
    x0 = (double) a / 2 + vx * time;
    x0 = x0 > 0 ? x0 : -x0;
    z0 = vz * time;
    while (x0 >= 2 * a)
        x0 -= 2 * a;
    while (z0 >= 2 * b)
        z0 -= 2 * b;
    x0 = x0 > a ? 2 * a - x0 : x0;
    z0 = z0 > b ? 2 * b - z0 : z0;

    printf("%.10f %.10f\n", x0, z0);

    return 0;
}

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

int main(){
	//freopen("in.txt", "r", stdin);
	int a, b, m, speedx, speedy, speedz;
	scanf("%d%d%d%d%d%d", &a, &b, &m, &speedx, &speedy, &speedz);
	double posx, posy=m, posz;
	double costtime = -posy / speedy;
	double xpass = fabs(speedx * costtime), zpass = fabs(speedz * costtime);
	if(speedz == 0)
		posz = 0;
	else{
		int round = zpass/b;
		posz = zpass - round*b;
		if(round%2==1)
			posz = b - posz;
	}
	if(speedx == 0)
		posx = 0.5 * a;
	else{
		xpass += 0.5 * a;
		if(speedx < 0)
			xpass += a;
		int round = xpass/a;
		posx = xpass - round*a;
		if(round%2==1)
			posx = a - posx;
	}
	printf("%.8lf %.8lf\n", posx, posz);
	return 0;
}

/*
ID: Sfiction
OJ: CF128 Div2
PROB: D
*/
#include <stdio.h>
int main()
{
    double a,b,m,vx,vy,vz;
    double x,z,t;
    scanf("%lf%lf%lf",&a,&b,&m);
    scanf("%lf%lf%lf",&vx,&vy,&vz);
    t=-m/vy;
    x=a/2+t*vx;
    z=t*vz;
    while (x<0||x>a)
        if (x>a) x=2*a-x;
        else x=-x;
    while (z<0||z>b)
        if (z>b) z=2*b-z;
        else z=-z;
    printf("%.10lf %.10lf",x,z);
    return 0;
}

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

int main(){
    double a, b, m, vx, vy, vz, x, z, t;
    scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &m, &vx, &vy, &vz);
    t = m / -vy;
    x = a / 2 + vx * t;
    z = vz * t;
    if (x < 0)x = -x;
    if ((int)(x / a) % 2)
       x = a - (x - (int)(x / a) * a);
    else x -= (int)(x / a) * a;
    if ((int)(z / b) % 2)
       z = b - (z - (int)(z / b) * b);
    else z -= (int)(z / b) * b;
    printf("%.7lf %.7lf\n", x, z);
    scanf(" ");
    return 0;
}

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

#define MAX
#define MODBY 1000000007
#define NIL (1e-8)

typedef long long int lld;
typedef long double Lf;

int i,j,n;
Lf x,y,z;
int vix,viy,viz;
int a,b;
Lf vx,vy,vz;
Lf tmin,t1;
int cmp(Lf f,Lf s)
{ return ((fabs(f-s)<NIL));}
int main()
{
   s(a);s(b);sf(y);
   s(vix);s(viy);s(viz);
   vx=vix;vy=viy;vz=viz;
   z=0;x=a/2.0;

   //printf("ball is at %Lf,%Lf,%Lf\n",x,y,z);
   //   while(!cmp(y,0)){
   int cnt=18;
   while(y>0){
      tmin=INT_MAX;
      if(vix){
         t1=-x/vx;//x=0 plane

         if((t1>0)&&(t1<tmin)){
            tmin=t1;
         }
         t1=-(x-a)/vx;
         if((t1>0)&&(t1<tmin)){
            tmin=t1;
         }
      }
      if(viz){
         t1=-z/vz;//z=0 plane
         if((t1>0)&&(t1<tmin)){
            tmin=t1;
         }
         t1=-(z-b)/vz;
         if((t1>0)&&(t1<tmin)){
            tmin=t1;
         }
      }
      if(viy){
         t1=-y/vy;//y=0 plane
         if((t1>0)&&(t1<tmin)){
            tmin=t1;
         }
      }
      x=x+vx*tmin;
      y=y+vy*tmin;
      z=z+vz*tmin;
   //   printf("ball is at %Lf,%Lf,%Lf\n",x,y,z);
      if(vix!=0)
         if((x==0)||(x==a)) vx*=-1;
      if(viz!=0){
         if((z==0)||(z==b)) vz*=-1;
      }
      //else break;
   }
   printf("%Lf %Lf\n",x,z);
   return 0;
}

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

#define MAX
#define MODBY 1000000007
#define NIL (1e-8)

typedef long long int lld;
typedef long double Lf;

int i,j,n;
Lf x,y,z;
int vix,viy,viz;
int a,b;
Lf vx,vy,vz;
Lf tmin,t1;
int cmp(Lf f,Lf s)
{ return ((fabs(f-s)<NIL));}
int main()
{
   s(a);s(b);sf(y);
   s(vix);s(viy);s(viz);
   vx=vix;vy=viy;vz=viz;
   z=0;x=a/2.0;

   //printf("ball is at %Lf,%Lf,%Lf\n",x,y,z);
   //   while(!cmp(y,0)){
   int cnt=18;
   while(y>0){
      tmin=INT_MAX;
      if(vix){
         t1=-x/vx;//x=0 plane
         if((t1>NIL)&&(t1<tmin)){
            tmin=t1;
         }
         t1=-(x-a)/vx;
         if((t1>NIL)&&(t1<tmin)){
            tmin=t1;
         }
      }
      if(viz){
         t1=-z/vz;//z=0 plane
         if((t1>NIL)&&(t1<tmin)){
            tmin=t1;
         }
         t1=-(z-b)/vz;
         if((t1>NIL)&&(t1<tmin)){
            tmin=t1;
         }
      }
      if(viy){
         t1=-y/vy;//y=0 plane
         if((t1>NIL)&&(t1<tmin)){
            tmin=t1;
         }
      }
      x=x+vx*tmin;
      y=y+vy*tmin;
      z=z+vz*tmin;
   //   printf("ball is at %Lf,%Lf,%Lf\n",x,y,z);
      if(vix!=0)
         if((x==0)||(x==a)) vx*=-1;
      if(viz!=0){
         if((z==0)||(z==b)) vz*=-1;
      }
      //else break;
   }
   printf("%Lf %Lf\n",x,z);
   return 0;
}

#include <stdio.h>
double a,b,m;
int vx,vy,vz;
int main()
{
    double t,d;
    scanf("%lf%lf%lf%d%d%d",&a,&b,&m,&vx,&vy,&vz);
    t = m/-vy;

    d = (vx>0?vx:-vx)*t;
    if(d<a/2) printf("%.9f ",vx>0?a/2+d:a/2-d);
    else
    {
        for(d-=a/2,vx=-vx;d>a;d-=a,vx=-vx);
        printf("%.9f ",vx>0?d:a-d);
    }

    d = (vz>0?vz:-vz)*t;
    for(;d>b;d-=b,vz=-vz);
    printf("%.9f",vz>0?d:b-d);

    return 0;
}


Santa Claus has n candies, he dreams to give them as gifts to children.What is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.

The only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.

Print to the first line integer number k — maximal number of kids which can get candies. Print to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n. If there are many solutions, print any of them.

#include <stdio.h>
#include <math.h>
int main(void) {
	// your code goes here
	int n,i,k,j,a;
	scanf("%d",&n);
	a=1+(8*n);
	a=sqrt(a);
	a=a-1;
	a=a/2; //number of elements
	k=a;
	printf("%d\n",k);
	if(k==1)
	{
		printf("%d",n);return 0;
	}
	int sum=0;
	for(i=1;i<=k;i++)
	{
		if(sum+i>n)
		break;
		sum=sum+i;
	}
	if(sum==n)
	{
		for(j=1;j<i;j++)
		printf("%d ",j);
		return 0;
	}
	for(j=1;j<i-1;j++)
		printf("%d ",j);
		sum=sum-i+1;
	printf("%d",n-sum);
	return 0;
}

#include<stdio.h>
int main()
{
    long long int n,sum=0,i,sum1=0,j;
    scanf("%lld",&n);
    if(n==1){
        printf("1\n 1\n");
    }
    else {
    for(i=0;i<n;i++){
        sum=sum+i;
        if(sum>n)
            break;
    }
    printf("%lld\n",i-1);
    for(j=1;j<i-1;j++){
        printf("%lld ",j);
    }
    for(j=1;j<i-1;j++){
        sum1=sum1+j;
    }
    printf("%lld\n",n-sum1);
    }
    return 0;
}

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

#include<stdio.h>
#include<math.h>
int main()
{
  int i,n,alpha,last;
  scanf("%d",&n);
  alpha = (-1 + (sqrt(1 + (8*n))))/2;
  last=n-((alpha*(alpha+1))/2) + alpha;
  printf("%d\n",alpha);
  for(i=1;i<alpha;i++)
    printf("%d ",i);
  printf("%d\n",last);
  return 0;
}

#include<stdio.h>
#include<stdlib.h>
typedef unsigned u;
u A[1111],Ai;
int main()
{
	u n,i=1;
	for(scanf("%u",&n);n>(i<<1);)
	{
		n-=A[Ai++]=i++;
	}
	A[Ai++]=n;
	for(printf("%u\n",Ai);Ai--;)printf("%u%c",A[Ai],"\n "[Ai>0]);
	return 0;
}

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

int main()
{
    int i,j,k,x;
    int a,b,c,d;
    scanf("%d",&x);
    int ara[x];
    for(i=1,j=0;i<=x;i++){
        a=x;
        x=x-i;

        if(x>i){
            ara[i-1]=i;
            j++;
        }
        else if(x==i){
            ara[i-1]=a;
            j++;
            break;
        }

        else if(x<i){
                ara[i-1]=x+i;
                j++;
        }

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

    return 0;
}

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

}
void Q_santa(int n)
{
	double temp = floor((-1+sqrt(8*n+1))*0.5);
	printf("%d\n", (int)temp);
	int i;
	int sum = 0;
	for (i = 1; i <= temp; i++)
	{
		if (i != temp)
		{
			sum += i;
			printf("%d ", i);
			fflush(stdout);
		}
		else
			printf("%d", n - sum);

	}
}

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

int main()
{
	int n,k,i,ans;
	scanf("%d",&n);
	ans = (int)((-1+sqrt(1+8*n))/2);
	printf("%d\n",ans);
	for(i=1;i<ans;i++)
		printf("%d ",i);
	ans = n - ((ans-1)*ans)/2;
	printf("%d\n",ans);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j=0,x,sum=0,a[100]={0},count=0;
scanf("%d",&x);
for(i=1;i<100;i++)
{
    if(sum<x)
    {   count++;
        a[i]=i;
        sum+=i;
    }

    if(sum==x)
    {
 //       printf("yeeeees\n");
        break;
    }

    if(sum>x)
    {
        while(sum>x)
        {
            sum=sum - 1; j++;
        }

        a[j]=0;
        count--;
    }

}
printf("\n%d\n",count);
for(i=0;i<=count+1;i++)
    if(a[i]!=0)
    printf("%d ",a[i]);

}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
main()
{
    int n;
    int a[10000],i,j,sum=0,p=0;
    scanf("%d",&n);
    if(n==1)
    {
        printf("1\n");
        printf("1\n");
        return 0;

    }

    for(i=0;i<n;i++)
    {
           a[i]=i+1;
        sum=sum+a[i];

        if(sum>n)
        {
            p=abs(n-(sum-a[i]));
            a[i-1]=a[i-1]+p;
            break;
        }
    }
         printf("%d\n",i);
         for(j=0;j<i;j++)
         {
             printf("%d\t",a[j]);
         }

}

#include <stdio.h>

int main(){
  int n, ready = 0, count = 0, i = 1;
  scanf("%d", &n);
  int kids[50];
  while (!ready){
    if(i < n - i){
      kids[count] = i;
      count++;
      n = n - i;
      i++;
    }
    else{
      kids[count] = n;
      ready = 1;
    }
  }
  printf("%d\n", count + 1);
  for(int i = 0; i <= count; i++){
    printf("%d ", kids[i]);
  }
  printf("\n");
  return 0;
}

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

}

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

int main()
{
   int n;
   int i;
   int s = 1;
   scanf("%d", &n);
   i = 1;

   while (s + i + 1 <= n){
i++;
    s += i;

   }

   printf("%d\n", i);
   printf("%d ", n-s+i);
   i--;
   for (; i>0; i--){
    printf("%d ", i);
   }

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
void fun(int );
void fun(int n)
{
    int i,tmp=0,j,sum=0;
    if(n==1)
    {
        printf("1\n1\n");
        return;
    }
    if(n==2)
    {
        printf("1\n2\n");
        return;
    }
    for(i=1;;i++)
    {
        tmp=tmp+i;
        if(tmp>n)
        {
            break;
        }
    }
    i--;
    printf("%d\n",i);
    for(j=1;j<=i-1;j++)
    {
        printf("%d ",j);
        sum=sum+j;
    }
    printf("%d\n",n-sum);
}
int main()
{
    int n;
    scanf("%d",&n);
    fun(n);
    return 0;
}

#include<stdio.h>

int main(void)
{
	int n, n2, k = 1, rez = 0;
	scanf("%d", &n);
	n2 = n;
	while (n2 - k >= 0){
		rez++;
		n2 -= k;
		k++;
	}
	printf("%d\n", rez);
	k = 1;
	while (rez){
		if (rez != 1 || !n2){
			printf("%d ", k);
		} else {
			printf("%d ", n2 + k);
		}
		k++;
		rez--;
	}
}

#include<stdio.h>
#include<math.h>
int main()
{
	int n,num,temp;
	scanf("%d",&n);
	temp=1+8*n;
	temp=sqrt(temp);
	num=(-1+temp)/2;
	int i,rem,flag=0;
	rem=n-(num*(num+1))/2;
	printf("%d\n",num);
	for(i=1;i<num;i++)
	{
		printf("%d ",i);
	}
	printf("%d",(rem+i));
	return 0;
}

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int num;
    scanf("%d", &num);
    int i;
    for(i = 1; ; ++i){
        if(i * (i + 1) / 2 > num)
            break;
    }
    i--;
    printf("%d\n", i);
    for(int m = 1; m < i; ++m){
        printf("%d ", m);
    }
    printf("%d\n",num - (i * (i - 1) / 2));
}

#include <stdio.h>

int main()
{
   int n;
   int i;
   int s = 1;
   scanf("%d", &n);
   i = 1;

   while (s + i + 1 <= n){
i++;
    s += i;

   }

   printf("%d\n", i);
   printf("%d ", n-s+i);
   i--;
   for (; i>0; i--){
    printf("%d ", i);
   }

    return 0;
}

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

	int i = 1;
	for (; m >= 0; m -= i, ++i);
	i -= 2;
	printf("%d\n", i);

	int sum = 0;
	for (m = 1; m < i; ++m)
	{
		printf("%d ", m);
		sum += m;
	}
	printf("%d\n", n - sum);

	return 0;
}

#include <stdio.h>

int main(void)
{
    int n, k, i, j;

    j=0;

    scanf("%d", &n);

    for(i=1; i<46; i++)
    {
        j+=i;

        if(j>n)
        {
            j-=2*i-1;
            k=i-1;
            break;
        }
    }

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

    for(i=1; i<k; i++)
    {
        printf("%d ", i);
    }

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

    return 0;
}

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

#include<stdio.h> //http://codeforces.com/problemset/problem/753/A
int main()
{
	int i,n; scanf("%d",&n);

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

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

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int n,k,magic,sum=0;
int main(){
    scanf("%d",&n);

    for(int i=1;i<46;i++){
        if((i+1)*i/2 > n){
            k=i-1;
            magic=k*(k+1)/2;
            printf("%d\n",k);

            for(int i=1;i<k;i++)
            {
                printf("%d ",i);
                sum+=i;
            }
            printf("%d",k+n-magic);
            sum+=k+n-magic;
            return 0;
        }
       }

}

#include <stdio.h>

int main () {
    int candies;
    int i = 1;
    int j;
    int soma = 0;
    scanf("%d", &candies);
    while (soma < candies) {
        soma += i;
        i++;
    }
    if (soma == candies) {
        printf ("%d\n", i - 1);
        for (j = 1; j <= i - 1; j++) {
            if (j == i) {
                printf ("%d\n", j);
            }
            else {
                printf ("%d ", j);
            }
        }
    }
    else {
        printf("%d\n", i - 2);
        for (j = 1; j <= i - 1; j++) {
            if (j == i - 1) {
                printf ("%d\n", j);
            }
            else if (j == soma - candies) {
            }
            else {
                printf ("%d ", j);
            }
        }
    }
    return 0;
}

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

}

#include <stdio.h>

int main()
{
    int n;
    int ans[1000];
    int size = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        if(n >= i) {
            ans[size++] = i;
            n -= i;
        }
    }
    ans[size - 1] += n;
    printf("%d\n", size);
    for(int i = 0; i < size; ++i) {
        printf("%d ", ans[i]);
    }
    return 0;
}

#include<stdio.h>
int main()
{int n,i,m,j;char c=' ';
scanf("%d",&n);
for(i=1;1;i++)

    if(i*(i+1)/2>n)break;

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

    for(j=1;j<=i-2;j++)
    printf("%d%c",j,c);
    int sum=(i-2)*(i-1)/2;
    printf("%d",n-sum);

return 0;}

#include <stdio.h>
int count[1111];
int main()
{
	int n, i = 1, sum = 1, cnt = 1;
	scanf("%d", &n);
	if (n == 1) {printf("1\n1"); return 0;}
	if (n == 2) {printf("1\n2"); return 0;}
	count[1]++;
	while (i < n)
	{
		i++;
		sum += i;
		if ((n-sum)>i || sum==n)
		{
			count[i]++;
			cnt++;
			sum += i;
		}
		sum -= i;
	}
	printf("%d\n", cnt);
	for (i = 0; i < 1111; i++) if (count[i]) printf("%d ", i);
	return 0;
}

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

int main(){
    int n;
    scanf("%d",&n);
    bool *p = (bool*)calloc(n,1);
    int i=0;
    int k=0;
    int t=0;
    int count=0;

    while(n){
        if(p[0]==0){p[0]=1;n--;i=0;count++;continue;}
        for(i=0;i<=k;i++){
           t=i+1;
            if(p[t]==0&&p[i]==1){//printf("df\n");
                p[t]=1;
                p[i]=0;
                if(t>k)k=t;
                break;
            }
        }
        n--;
    }
    printf("%d\n",count);
    for(i=0;i<=k;i++){
        if(p[i]==1)printf("%d ",i+1);

    }
    printf("\n");
}

#include <stdio.h>

void allot (int use[1001], int* sum, int i, int* num) {
  if (use[i]) return;
  if (*sum-i > i) {
    use[*sum] = 0;
    use[*sum-i] = 1;
    use[i] = 1;
    (*num)++;
    (*sum)-=i;
    allot(use, sum, i+1, num);
  }
  return;
}

int main(void) {
  int n;
  scanf("%d", &n);
  int use[1001] = {0};
  use[n] = 1;
  int sum[0], num[0];
  *sum = n;
  *num = 1;
  allot(use, sum, 1, num);
  printf("%d\n", *num);
  int i, j;
  for(i=0; i<=1000; i++) {
    if (use[i]) { printf("%d", i); break;}
  }
  for(j=i+1; j<=1000; j++) {
    if (use[j]) printf(" %d", j);
  }
  puts("");
  return 0;
}

#include<stdio.h>

int a[46],arr[46];

int binarySearch(int left,int right,int key)
{
    int middle=(left+right)/2;

    if(right-left==1)
    {
        if(arr[right]>key)
        return left;

        else
        return right;
    }

    else if(arr[middle]<key)
    return binarySearch(middle,right,key);

    else if(arr[middle]>=key)
    return binarySearch(left,middle,key);
}

int main()
{
    int i,n,index;
    arr[0]=0;
    arr[1]=1;

    for(i=0;i<46;i++)
    a[i]=i;

    for(i=2;i<46;i++)
    arr[i]=i+arr[i-1];

    scanf("%d",&n);

    index=binarySearch(1,45,n);

    a[index]=a[index]+n-arr[index];

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

    for(i=1;i<=index;i++)
    printf("%d ",a[i]);
    printf("\n");

return 0;
}

#include<stdio.h>
int main()
{
    int n,i,s,j,p;
    scanf("%d",&n);
    s=0;
    for(i=1;i<=55;i++) {
        s=s+i;
        if(s==n) {
        printf("%d\n",i);
    for(j=1;j<=i;j++) {
        printf("%d ",j);
                 }
                 break;
        }

        else if(s>n) {

             printf("%d\n",i-1);
             p=s-n;
            for(j=1;j<=i;j++) {
              if(j!=p) {printf("%d ",j); }
                }
             break;
        }

    }
}

#include<stdio.h>
int main()
{
	int n,s,i,cnt = 0;
	scanf("%d",&n);
	int B[n];
	for(i=1;i<=n;i++)
	B[i] = 0;
	s = 0;
	for(i=1;i<=n;i++)
	{
		if(B[i] == 0 &&	i<= n-s)
		{
			B[i] = i;
			s = s+ B[i];
			cnt++;
		}
		else
		{
			B[i-1] = B[i-1] + n-s;
			break;
		}
	}
	printf("%d\n",cnt);
   for(i=1;i<=cnt;i++)
   printf("%d\t",B[i]);
   return 0;
}

#include<stdio.h>

int ans[100];

int main()
{
	int num, i, n;

	scanf("%d", &n);

	for(i = 1, num = 0; i <= n; i ++)
	{
		if(i <= n)
			ans[num ++] = i;
		n -= i;
	}

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

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

	return 0;
}

#include<stdio.h>
int main()
{
    int n,i,j,b=0,sum=0,ara[10000],c=0;
    scanf("%d",&n);
    int a = n;
    for(i=1,j=0;i<=n;i++,j++){
        a = a-i;
        if(i<a){ara[j]=i;
        b ++;
        sum += i;}
        else{
            int h = n - sum;
            ara[j]=h;
            c=1;
        }
    }
    printf("%d\n",b+c);
    for(i=0;i<(b+c);i++)printf("%d ",ara[i]);

    return 0;

}

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

int main()
{
   int n;
   int i;
   int s = 1;
   scanf("%d", &n);
   i = 1;

   while (s + i + 1 <= n){
i++;
    s += i;

   }

   printf("%d\n", i);
   printf("%d ", n-s+i);
   i--;
   for (; i>0; i--){
    printf("%d ", i);
   }

    return 0;
}

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

#include<stdio.h>
#include<math.h>
int main()
{
    int N;
    scanf("%d",&N);
    float x=sqrt(1+8*N);

    x=(-1+x)/2.0;
    int y=x;
    int z=(y*(y+1))/2;
    int remaining=N-z;
    printf("%d\n",y);
    for(z=y;z>0;z--){
        if(remaining>0){
            printf("%d ",z+1);
            remaining-=1;
        }
        else{
            printf("%d ",z);
        }
    }
    return 0;
}

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

#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int sum =0,i=0,ans[100];
	int ele=1,count=0;
	while(n-sum>2*ele)
	{
		ans[count]=ele;
		sum+=ele;
		ele++;
		count++;
	}
	ans[count++]=n-sum;
	printf("%d\n",count);
	for(i=0;i<count-1;i++)printf("%d ",ans[i]);

	printf("%d\n",ans[i]);
	return 0;
}

#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int i,k=0,count=0,sum=0;
i=1;
int n1=n;
int a[n];
while(n>k)
{
if(n>k)
{
n=n-i;
sum+=i;
a[count]=i;
count++;
k=i;

}
i++;
}
sum-=a[count-1];
printf("%d\n",count);
if(count!=1)
{a[count-1]=n1-sum;
for(i=0;i<count;i++)
{
printf("%d ",a[i]);
}
}
else
printf("%d\n",n1);

return 0;
}

#include <stdio.h>
int queue[1000];
int n, sum, top;
int main(void) {
   scanf("%d", &n);
   for(int i = 1; sum < n; i++) {
       queue[top++] = i;
       sum += i;
   }
   if(sum != n) {
        sum -= queue[top - 1];
        top--;
        queue[top - 1] += n - sum;
   }
   printf("%d\n%d", top, queue[0]);
   for(int i = 1; i < top; i++) {
       printf(" %d", queue[i]);
    }
    return 0;
}

#include<stdio.h>
#define maxn 1000
int a[maxn];
void init();
int main()
{
    init();
    int n,i;
    while(~scanf("%d",&n))
    {
        if(n==1||n==2)
        {
            printf("%d\n",1);
            printf("%d\n",n);
            continue;
        }
        printf("%d\n",a[n]);
        int sum=0;
        for(i=1;i<a[n];i++)
        {
            sum+=i;
            printf("%d ",i);

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

    }
    return 0;
}

void init()
{
    int s=1;
    int i,j;
    for(i=1;i<=1000;i+=s)
    {
        for(j=i;j<i+s+1;j++)
            a[j]=s;
        s++;
    }

}

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

/*
int binary(int x, int a[], int size)
{
    int first=1, last=size;
    while(first<=last)
    {
	int mid=(first+last)/2;
	if(a[mid]==x)
	    return mid;
	if(a[mid]>x)
	    last=mid-1;
	else
	    first=mid+1;
    }

    return 0;
}//end of binary search function
*/

int main()
{
    int n;
    scanf("%d", &n);
    int m;
    printf("%d\n", m=(int)(sqrt(8*n+1)-1)/2);
    int s=0;
    for(int i=1;i<m;++i) {
	s+=i;
	printf("%d ", i);
    }
    if(n=n-s)
	printf("%d", n);
}//end of main

#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n], j=0, i=-1,x;
while(n>j)
{
n-=++j;
if(n>=0)
{
i++;
arr[i]=j;
}
}
arr[i]+=n;
printf("%d\n",i+1);
for(x=0;x<=i;x++)
{
printf("%d ",arr[x]);
}
return 0;

}

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

int main(void) {
    int total;
    scanf("%d", &total);
    if (total < 0 || total > 1000)
        return 0;
    int i;
    int *result = calloc(45,sizeof(int));
    int *selection = calloc(45,sizeof(int));
    selection[0] = total;
    for (i=1;i<46;i++) {
        result[i] = i;
        selection[i] = selection[i-1] - i;
        if (selection[i] <= i) {
            result[0] = i;
            result[i] = selection[i-1];
            break;
        }
    }
    printf("%d\n", result[0]);
    for (i = 1; i<result[0]; i++) {
        printf("%d ", result[i]);
    }
    printf("%d\n",result[result[0]]);
    free(result);
    free(selection);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n;
    scanf("%d",&n);
    int *a=(int *)malloc(n*sizeof(int));
    int i,s=0,q=0;
    for(i=1;s<=n;i++)
    {
        s+=i;
        q++;
    }
    printf("%d\n",q-1);
    s=0;
    int r=q-1,w=0;
    for(i=1;;i++)
    {
        if(i<r)
        {
            s+=i;
            printf("%d ",i);
        }
        else
        {
            w=s+i;
            if(n-w!=0)
            {
                continue ;
            }
            else if(n-w==0)
            {
                printf("%d",i);
                return 0;
            }
        }
    }
    return 0;
}

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

    int no_of_people = 1;
    while(no_of_people*(no_of_people + 1) <= 2*no_of_gifts)
        no_of_people++;

    no_of_people--;

    printf("%d\n", no_of_people);
    for(int i = 1; i < no_of_people; i++)
    {
        printf("%d ", i);
        no_of_gifts -= i;
    }

    printf("%d\n", no_of_gifts); //Last person gets all remaining gifts
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int n,num,temp;
	scanf("%d",&n);
	temp=1+8*n;
	temp=sqrt(temp);
	num=(-1+temp)/2;
	int i,rem,flag=0;
	rem=n-(num*(num+1))/2;
	printf("%d\n",num);
	for(i=1;i<num;i++)
	{
		printf("%d ",i);
	}
	printf("%d",(rem+i));
	return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int rs[1000];
    int k = 0;

    int i = 1;
    while (n > 0)
    {

        if (n - 2*i - 1 < 0)
            i += n - i;
        rs[k] = i;
        k++;
        n -= i++;
    }

    printf("%d\n", k);
    for (int j = 0; j < k-1; j++)
        printf("%d ", rs[j]);
    printf("%d\n", rs[k-1]);

    return 0;
}

#include<stdio.h>
int main()
{
	int n,i,j,p;
	long long int count=0;
	scanf("%d",&n);
	int a[1001];
	i=0;
	p=n;
	if(n==1 || n==2)
	{
		printf("1\n");
		printf("%d\n",n);
	}
	else
	{
		a[0]=1;
		p=p-a[0];
		count++;
		while(p!=0)
		{
			if(p<=a[i])
			{
				p=p+a[i];
				a[i]=a[i]+1;
				p=p-a[i];
			}
			else
			{
				i++;
				a[i]=a[i-1]+1;
				count++;
				p=p-a[i];
			}
		}
		printf("%lld\n",count);
		for(j=0;j<=i;j++)
		{
			printf("%d ",a[j]);
		}
		printf("\n");
	}
	return 0;
}

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

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

int main() {
	int CandyNum;
	int i = 1;
	int sum = 0;

	scanf("%d", &CandyNum);
	while ((i * (i + 1) / 2) <= CandyNum) {
		i++;
	}
	i--;

	int KidNum = i;

	printf("%d\n", KidNum);
	for (i = 0; i < KidNum - 1; i++) { // leave last Kid
		printf("%d ", i + 1);
		sum += i + 1;
	}
	printf("%d ", CandyNum - sum);

	return 0;
}

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

int main()
{
	int n,k,i;
	scanf("%d",&n);
	k=round(sqrt(2*n));
	n-=(k*(k-1))/2;
	printf("%d\n",k-1);
	for(i=1;i<k-n;i++) printf("%d ",i);
	for(;i<k;i++) printf("%d ",i+1);
	printf("\n");
	return 0;
}

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

int main()
{
    int i,j,k,x;
    int a,b,c,d;
    scanf("%d",&x);
    int ara[x];
    for(i=1,j=0;i<=x;i++){
        a=x;
        x=x-i;
        if(x!=i){
            ara[i-1]=i;
            j++;
        }
        else if(x==i){
            ara[i-1]=a;
            j++;
            break;
        }

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

    return 0;
}

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

int main()
{
    int i,j,k,x;
    int a,b,c,d;
    scanf("%d",&x);
    int ara[x];
    for(i=1,j=0;i<x;i++){
        a=x;
        x=x-i;
        if(x!=i){
            ara[i-1]=i;
            j++;
        }
        else if(x==i){
            ara[i-1]=a;
            j++;
            break;
        }

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

    return 0;
}

#include<stdio.h>
int main()
{int n,i,m,j;char c=' ';
scanf("%d",&n);
for(i=1;1;i++)

    if(i*(i+1)/2>n)break;

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

    for(j=1;j<=i-2;j++)
    printf("%d%c",j,c);
    printf("%d",n-i+2);

return 0;}

#include <stdio.h>

int main()
{
    int n;
    int ans[1000];
    int size = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        if(n >= i) {
            ans[size++] = i;
            n -= i;
        }
    }
    ans[size - 1] += n;
    printf("%d\n", n);
    for(int i = 0; i < size; ++i) {
        printf("%d ", ans[i]);
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main(){
    int n;
    scanf("%d",&n);
    int *elements=calloc(n,sizeof(int));
    int count=0,rem=n,term;
    while(rem){
        term=(rem/2)+1;
        elements[count++]=term;
        rem=rem-term;
    }
    printf("%d\n",count);
    for(int i=0;i<count;i++){
        printf("%d ",elements[i]);
    }
    printf("\n");
}

#include <stdio.h>
int digsum(long long n){
    long long sum=0;
    while(n){
        sum+=n%10;
        n/=10;
    }
    return sum;
}
int main(){
    long long perfectnos[10000];
    long long temp;
    perfectnos[0]=19;
    int k;
    scanf("%d",&k);
    for(int i=0;i<k-1;i++){
        temp=perfectnos[i]+9;
        while(digsum(temp)!=10){
            temp+=9;
        }
        perfectnos[i+1]=temp;
    }
    printf("%lld\n",perfectnos[k-1]);
}

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

int main()
{
	int cand, child, y, sum, defr, i;
	scanf("%d", &cand);
	y=sqrt(cand);	//floor value
	sum=(y*(y+1))/2;
	defr=0;
	if(sum!=cand)	{
		defr=cand-sum;
	}
	printf("%d\n", y);
	for(i=1; i<y; i++)	{
		printf("%d ", i);
	}
	printf("%d\n", y+defr);
	return 0;
}

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

    y=x-n;
    if(y>0){
        printf("%d\n",i-1);
    }
    else{
        printf("%d\n",i);
    }
    for(j=1;j<=i;j++){
        if(j==y){
            continue;
        }
        printf("%d ",j);
    }
    return 0;
}

#include <stdio.h>
int main()
{
    int n,m=0,k,l,f,a[1000],s,g;
    scanf("%d", &n);
    g = n;
    for(k=1;k<g;k++)
    {
        n = n - k;
        if(n < 0)
        {
            m++;
            l = -n;
            a[k-1] = k;
            break;
        }
        else {
            m++;
        if(n == 0) {
             a[k-1] = k;
            break;
        }

        a[k-1] = k;
        }
    }
    printf("%d\n",m-1);
    for(s=0;s<m;s++)
    {
        if(a[s] == l)
            continue;
        else
            printf("%d ",a[s]);
    }
    return 0;
}

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

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int arr[n+1],i,j,ans=0,tot=0;
    for(i=1;i<=n;i++)
        arr[i]=i;
    for(i=1;i<n;i++)
    {
        tot++;
        ans+=arr[i];
        if(ans>n)
        {
            int temp=ans-n;
            arr[temp]=0;
            arr[i+1]=-1;
            tot--;
            break;
        }
    }
    printf("%d\n",tot);
    for(i=1;i<n;i++)
    {
        if(arr[i]==-1)
        break;
        else if(arr[i]!=0)
            printf("%d ",arr[i]);
    }
}

#include <stdio.h>
#include <stdlib.h>
#define nax 1000
int main(){
	int k;
	int size = 0;
	int dp[nax];
	scanf("%i",&k);
	for(int i=0;i<k;i++){
		dp[i]=i;
		size++;
		k-=i;
	}
	dp[size-1]+=k;

	printf("%i\n",size-1);
	for (int i=1;i<size;i++){
		printf("%i ",dp[i]);

	}

}

#include<stdio.h>
int main()
{
    int n,i,s,j,p;
    scanf("%d",&n);
    s=0;
    for(i=1;i<=14;i++) {
        s=s+i;
        if(s==n) {
        printf("%d\n",i);
    for(j=1;j<=i;j++) {
        printf("%d ",j);
                 }
                 break;
        }

        else if(s>n) {

             printf("%d\n",i-1);
             p=s-n;
            for(j=1;j<=i;j++) {
              if(j!=p) {printf("%d ",j); }
                }
             break;
        }

    }
}

#include <stdio.h>
int main(void) {
    int n, i;
    int sum = 0;
    scanf("%d", &n);
    for(i = 1; sum <= n; i++) {
        sum += i;
    }
    sum -= i;
    i--;
    printf("%d\n", i);
    for(int j = 1; j < i; j++) {
        printf("%d ", j);
    }
    printf("%d", n - sum);
    return 0;
}

#include <stdio.h>
int main(void) {
    int n, i;
    int sum = 0;
    scanf("%d", &n);
    for(i = 1; sum <= n; i++) {
        sum += i;
    }
    sum -= i;
    printf("%d\n", i);
    for(int j = 1; j < i; j++) {
        printf("%d ", j);
    }
    printf("%d", n - sum);
    return 0;
}

#include <stdio.h>
int count[1111];
int main()
{
	int n, i = 1, sum = 1, cnt = 1;
	scanf("%d", &n);
	if (n == 1) {printf("1\n1"); return 0;}
	if (n == 2) {printf("1\n2"); return 0;}
	count[1]++;
	while (i < n)
	{
		i++;
		if ((i+sum) <= n)
		{
			count[i]++;
			cnt++;
			sum += i;
		}
	}
	printf("%d\n", cnt);
	for (i = 0; i < 1111; i++) if (count[i]) printf("%d ", i);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d", &n);
int arr[n], j=0, i=-1,x;
while(n>j)
{
n-=++j;
if(n>=0)
{
i++;
arr[i]=j;
}
}
arr[i]+=n;
printf("\n%d",i+1);
for(x=0;x<=i;x++)
{
printf("%d ",arr[x]);
}
return 0;

}

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

int main()
{
int x;
printf("enter the number of sweets: ");
scanf("%d", &x);
int a[x], j=0, i, m=0;
while(x!=0)
{
for(i=0; i<x; i++)
{
x = (x-(++j));
a[i] = j;
}
a[i-1]+=x;
x=0;
}
printf("%d\n", i);
for(m=0; m<i; m++)
printf("%d ", a[m]);
return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
printf(" Enter the number of candies: ");
scanf("%d", &n);
int arr[n], j=0, i=-1,x;
while(n>j)
{
n-=++j;
if(n>=0)
{
i++;
arr[i]=j;
}
}
arr[i]+=n;
printf("\n Number of children %d",i+1);
for(x=0;x<=i;x++)
{
printf("\n children number %d will take %d",x+1,arr[x]);
}
return 0;

}

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

# include <stdio.h>
# include <math.h>
int main(void)
{
    int count = 0;
    int sum = 0;
    int lastbutone = 0;
    int input;

    scanf("%i",&input);

    for(int i = 1; i < input; i++)
    {
      sum = sum + i;
       if(sum < input || sum == input)
       {
        count = count + 1;
       }

    }

    printf("%i \n", count);

    for (int i = 1; i < count ; i++)
    {
	printf("%i ", i);
	lastbutone = lastbutone + i;

    }

    int remainder;
    remainder = input - lastbutone ;

    printf("%i", remainder);

    return 0;
}

#include <stdio.h>
int main(void) {
    int n, i, j;
    scanf("%d", &n);
    i = 1;
    while(i * (i + 1) / 2 <= n)
        i++;
    printf("%d\n", --i);
    for(j = 1;j < i;j++)
        printf("%d ", 1);
    printf("%d\n", n - j + 1);
    return 0;
}

#include <stdio.h>
int main(void) {
    int n, i, j;
    scanf("%d", &n);
    i = 1;
    while(i * (i + 1) / 2 <= n)
        i++;
    printf("%d\n", --i);
    for(j = 1;j <= i;j++)
        printf("%d ", 1);
    return 0;
}

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

    if(n==1){
        printf("1 1");return 0;
    }
    if(n==2){
        printf("1 2");return 0;
    }
    if(n==3){
        printf("2 1 2");return 0;
    }
    if(n==4){
        printf("2 1 3");return 0;
    }
    if(n==5){
        printf("2 1 4");return 0;
    }

    for(int i=1;i<46;i++){
        if((i+1)*i/2 > n){
            k=i-1;
            break;
        }
        if((i+1)*i/2 == n){
            k=i;
            break;
        }
    }
    printf("%d\n",k);
    for(int i=1;i<k;i++)
    {
        printf("%d ",i);
    }
    printf("%d",n-k);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int n,k,dif;
int main(){
    scanf("%d",&n);
    for(int i=1;i<46;i++){
        if((i+1)*i/2 > n){
            k=i-1;
            break;
        }
        if((i+1)*i/2 == n){
            k=i;
            break;
        }
    }
    printf("%d\n",k);
    for(int i=1;i<k;i++)
    {
        printf("%d ",i);
    }
    printf("%d",n-k);
    return 0;
}

#include<stdio.h>

int main()
{
    int n ;
    scanf("%d",&n);
    int i;
    int k=0;
    int t[n];
    int m=n;
    for (i=1;(i<m)&&(n>0);i++)
    {
        if (n-i<=i)
        {

            t[k]=n;
            n=0 ;
            k++;
        }
        else
            {
                n=n-i;
                t[k]=i;
                k++;
            }
        }

    printf("%d\n",k);
    for(i=0;i<k;i++)
        printf("%d ",t[i]);
    return 0 ;
}

#include<stdio.h> //http://codeforces.com/problemset/problem/753/A
int main()
{
	int i,n; scanf("%d",&n);

	for(i=0;i*(i+1)/2<n;i++)
	{}
	i--;
	printf("%d\n",i);
	for(int k=1;k<i;k++)
	{printf("%d ",k);n=n-k;}

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

#include <stdio.h>
int main()
{
    int n,k,j,i,p,s;
    int arr[100];
    printf("enter the number of toffiess \n");
    scanf("%d",&n);
    k=0;
    j=0;
    for(i=1;i+j<=n;i++)
    {
        k++;
        j=j+i;
    }
    printf("%d \n",k);
    p=0;
    for(i=0;i<=k-2;i++)
        arr[i]=i+1;
    for(i=0;i<=k-2;i++)
        p=p+i+1;
        s=n-p;
        for(i=0;i<=k-2;i++)
            printf("%d ",arr[i]);

            printf("%d ",s);

}

#include <stdio.h>

int main () {
    int candies;
    int i = 1;
    int j;
    int soma = 0;
    scanf("%d", &candies);
    while (soma < candies) {
        soma += i;
        i++;
    }
    if (soma == candies) {
        printf ("%d\n", i - 1);
        for (j = 1; j <= i; j++) {
            if (j == i) {
                printf ("%d\n", j);
            }
            else {
                printf ("%d ", j);
            }
        }
    }
    else {
        printf("%d\n", i - 2);
        for (j = 1; j <= i - 1; j++) {
            if (j == i - 1) {
                printf ("%d\n", j);
            }
            else if (j == soma - candies) {
            }
            else {
                printf ("%d ", j);
            }
        }
    }
    return 0;
}

#include <stdio.h>
int main()
{
    int a;
	scanf("%d",&a);
	int num=0;
	int x[1000];
	int sum=a;
	for(int n=1;;n++){
		sum=sum-n;
		if(sum>0){
			x[num]=n;
			num++;
		}
		else{
			break;
		}
	}
	if(sum==0){
		printf("%d\n",num);
		for(int n=0;n<num;n++){
			if(n!=0)printf(" ");
			printf("%d",x[n]);
		}
	}
	else{
		printf("%d\n",num);
		sum=-sum;
		x[sum-1]=num+1;
		for(int n=0;n<num;n++){
			if(n!=0)printf(" ");
			printf("%d",x[n]);
		}
	}

	return 0;
}

#include <stdio.h>
int main()
{
    int a;
	scanf("%d",&a);
	int num=0;
	int x[1000];
	int sum=a;
	for(int n=1;;n++){
		sum=sum-n;
		if(sum>0){
			x[num]=n;
			num++;
		}
		else{
			break;
		}
	}
	if(sum==0){
		for(int n=0;n<num;n++){
			if(n!=0)printf(" ");
			printf("%d",x[n]);
		}
	}
	else{
		sum=-sum;
		x[sum-1]=num+1;
		for(int n=0;n<num;n++){
			if(n!=0)printf(" ");
			printf("%d",x[n]);
		}
	}

	return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
int judge(char s[])
{
    if(strcmp(s,"monday")==0)
       return 1;
    if(strcmp(s,"tuesday")==0)
       return 2;
    if(strcmp(s,"wednesday")==0)
       return 3;
    if(strcmp(s,"thursday")==0)
       return 4;
    if(strcmp(s,"friday")==0)
       return 5;
    if(strcmp(s,"saturday")==0)
       return 6;
    if(strcmp(s,"sunday")==0)
       return 7;
}///��Ӣ��ת��Ϊ����
int main()
{
    char s1[20],s2[20],n,m;
    int i;
    while(~scanf("%s%s",s1,s2))
    {
        n=judge(s1);
        m=judge(s2);
        int a=(m-n+7)%7;///������ֵǮ��һ����
        if(a==3||a==2||a==0)
            printf("YES\n");
        else
            printf("NO\n");

    }
    return 0;

}

#include<stdio.h>

int main()
{
    int n;

    scanf("%d",&n);

    int can[n+1];
    int i,ck = 0;

    for(i = n; ; ){
        if(i == 2 || i == 1){
            can[ck] = i;
            ck++;
            break;
        }
        else{
            int d;
            d = (int)(i/2) + 1;
            i -= d;
            can[ck] = d;
            ck++;
        }
    }
    printf("%d\n",ck);

    for(i = 0; i < ck; i++){
        if(i == ck-1){
            printf("%d\n",can[i]);
        }
        else{
            printf("%d ",can[i]);
        }
    }
    return 0;
}

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

int main()
{
	int n,p=0,count=0,i;

	scanf("%d",&n);

	for(i=1;i<=n;i++)
	{
		p=p+i;

		if(p>n)
		break;

		count++;
	}

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

	for(i=1;i<count;i++)
	{
		printf("%d ",i);
	}

	printf("%d",n-p+2*count+1);
	}

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

int main()
{
	int n,p=0,count=0,i;

	scanf("%d",&n);

	for(i=1;i<=n;i++)
	{
		p=p+i;

		if(p>n)
		break;

		count++;
	}

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

	for(i=1;i<count;i++)
	{
		printf("%d ",i);
	}

	if(n=1)
	{
		printf("1");
	}

	else
	printf("%d",n-p+2*count+1);
	}

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

int main()
{
    int x;
    printf("enter the number of sweets: ");
    scanf("%d", &x);
    int a[x], j=0, i, m=0;
    while(x!=0)
    {
        for(i=0; i<x; i++)
        {
            x = (x-(++j));
            a[i] = j;
        }
        a[i-1]+=x;
        x=0;
    }
    printf("%d\n", i);
    for(m=0; m<i; m++)
        printf("%d\t", a[m]);
    return 0;
}

#include<stdio.h>

int ans[100];

int main()
{
	int num, i, n;

	scanf("%d", &n);

	for(i = 1, num = 0; i <= n; i ++)
	{
		if(i <= n)
			ans[num ++] = i;
		n -= i;
	}

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

	return 0;
}

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

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

#include<stdio.h>
int main()
{
    int n,i,j,k,sum=0,p;
    scanf("%d",&n);
    k=0;
    p=n;
    while(n-k-1>0)
    {
        n=n-k-1;
        k++;
    }
    printf("%d\n",k);
    j=1;
    for(i=1;i<k;i++)
    {
        printf("%d ",j);
        sum=sum+j;
        j++;
    }
    printf("%d\n",(p-sum));
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void Q_santa(int n);
int main()
{
	Q_santa(9);

}
void Q_santa(int n)
{
	double temp = floor((-1+sqrt(8*n+1))*0.5);
	printf("%d\n", (int)temp);
	int i;
	int sum = 0;
	for (i = 1; i <= temp; i++)
	{
		if (i != temp)
		{
			sum += i;
			printf("%d ", i);
			fflush(stdout);
		}
		else
			printf("%d", n - sum);

	}
}


The only difference between easy and hard versions is constraints.Polycarp loves to listen to music, so he never leaves the player, even on the way home from the university. Polycarp overcomes the distance from the university to the house in exactly $$$T$$$ minutes.In the player, Polycarp stores $$$n$$$ songs, each of which is characterized by two parameters: $$$t_i$$$ and $$$g_i$$$, where $$$t_i$$$ is the length of the song in minutes ($$$1 \le t_i \le 15$$$), $$$g_i$$$ is its genre ($$$1 \le g_i \le 3$$$).Polycarp wants to create such a playlist so that he can listen to music all the time on the way from the university to his home, and at the time of his arrival home, the playlist is over. Polycarp never interrupts songs and always listens to them from beginning to end. Thus, if he started listening to the $$$i$$$-th song, he would spend exactly $$$t_i$$$ minutes on its listening. Polycarp also does not like when two songs of the same genre play in a row (i.e. successively/adjacently) or when the songs in his playlist are repeated.Help Polycarpus count the number of different sequences of songs (their order matters), the total duration is exactly $$$T$$$, such that there are no two consecutive songs of the same genre in them and all the songs in the playlist are different.

The first line of the input contains two integers $$$n$$$ and $$$T$$$ ($$$1 \le n \le 15, 1 \le T \le 225$$$) — the number of songs in the player and the required total duration, respectively. Next, the $$$n$$$ lines contain descriptions of songs: the $$$i$$$-th line contains two integers $$$t_i$$$ and $$$g_i$$$ ($$$1 \le t_i \le 15, 1 \le g_i \le 3$$$) — the duration of the $$$i$$$-th song and its genre, respectively.

Output one integer — the number of different sequences of songs, the total length of exactly $$$T$$$, such that there are no two consecutive songs of the same genre in them and all the songs in the playlist are different. Since the answer may be huge, output it modulo $$$10^9 + 7$$$ (that is, the remainder when dividing the quantity by $$$10^9 + 7$$$).

NoteIn the first example, Polycarp can make any of the $$$6$$$ possible playlist by rearranging the available songs: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]$$$, $$$[3, 1, 2]$$$ and $$$[3, 2, 1]$$$ (indices of the songs are given).In the second example, the first and second songs cannot go in succession (since they have the same genre). Thus, Polycarp can create a playlist in one of $$$2$$$ possible ways: $$$[1, 3, 2]$$$ and $$$[2, 3, 1]$$$ (indices of the songs are given).In the third example, Polycarp can make the following playlists: $$$[1, 2, 3]$$$, $$$[1, 3, 2]$$$, $$$[2, 1, 3]$$$, $$$[2, 3, 1]$$$, $$$[3, 1, 2]$$$, $$$[3, 2, 1]$$$, $$$[1, 4]$$$, $$$[4, 1]$$$, $$$[2, 3, 4]$$$ and $$$[4, 3, 2]$$$ (indices of the songs are given).

/* https://codeforces.com/contest/1185/submission/55797221 (Dukkha) */
#include <stdio.h>

#define N	50
#define T	2500
#define MD	1000000007

int dp[N + 1][N + 1][N + 1], dq[N + 1][N + 1][N + 1][3];

void init(int na, int nb, int nc) {
	int ma, mb, mc, x0, x1, x2;

	for (ma = 0; ma <= na; ma++)
		for (mb = 0; mb <= nb; mb++)
			for (mc = 0; mc <= nc; mc++) {
				x0 = ma > 0 ? (long long) dq[ma - 1][mb][mc][0] * ma % MD : 0;
				x1 = mb > 0 ? (long long) dq[ma][mb - 1][mc][1] * mb % MD : 0;
				x2 = mc > 0 ? (long long) dq[ma][mb][mc - 1][2] * mc % MD : 0;
				if (ma == 0 && mb == 0 && mc == 0) {
					dp[ma][mb][mc] = 1;
					dq[ma][mb][mc][0] = dq[ma][mb][mc][1] = dq[ma][mb][mc][2] = 1;
				} else {
					dp[ma][mb][mc] = ((long long) x0 + x1 + x2) % MD;
					dq[ma][mb][mc][0] = (x1 + x2) % MD;
					dq[ma][mb][mc][1] = (x0 + x2) % MD;
					dq[ma][mb][mc][2] = (x0 + x1) % MD;
				}
			}
}

void solve1(int *aa, int t, int n, int da[][N + 1]) {
	int i, s, m, a;

	for (s = 0; s <= t; s++)
		for (m = 0; m <= n; m++)
			da[0][0] = 0;
	da[0][0] = 1;
	for (i = 0; i < n; i++) {
		a = aa[i];
		for (s = t; s >= a; s--)
			for (m = 1; m <= n; m++)
				da[s][m] = (da[s][m] + da[s - a][m - 1]) % MD;
	}
}

void solve2(int *aa, int *bb, int t, int na, int nb, int dab[][N + 1][N + 1]) {
	static int da[T + 1][N + 1];
	int i, b, s, ma, mb;

	solve1(aa, t, na, da);
	for (s = 0; s <= t; s++)
		for (ma = 0; ma <= na; ma++) {
			dab[s][ma][0] = da[s][ma];
			for (mb = 1; mb <= nb; mb++)
				dab[s][ma][mb] = 0;
		}
	for (i = 0; i < nb; i++) {
		b = bb[i];
		for (s = t; s >= b; s--)
			for (ma = 0; ma <= na; ma++)
				for (mb = 1; mb <= nb; mb++)
					dab[s][ma][mb] = (dab[s][ma][mb] + dab[s - b][ma][mb - 1]) % MD;
	}
}

int main() {
	static int aa[N], bb[N], cc[N], dab[T + 1][N + 1][N + 1], dc[T + 1][N + 1];
	int n, na, nb, nc, t, tab, tc, ma, mb, mc, xab, xc, ans;

	scanf("%d%d", &n, &t);
	na = nb = nc = 0;
	while (n--) {
		int a, g;

		scanf("%d%d", &a, &g);
		if (g == 1)
			aa[na++] = a;
		else if (g == 2)
			bb[nb++] = a;
		else
			cc[nc++] = a;
	}
	init(na, nb, nc);
	solve1(cc, t, nc, dc);
	solve2(aa, bb, t, na, nb, dab);
	ans = 0;
	for (tab = 0; tab <= t; tab++) {
		tc = t - tab;
		for (ma = 0; ma <= na; ma++)
			for (mb = 0; mb <= nb; mb++)
				if ((xab = dab[tab][ma][mb]))
					for (mc = 0; mc <= nc; mc++)
						if ((xc = dc[tc][mc]))
							ans = (ans + (long long) xab * xc % MD * dp[ma][mb][mc]) % MD;
	}
	printf("%d\n", ans);
	return 0;
}