semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main(){
	int n;
	cin>>n;

	int a[6], b[6], i;

	b[0]= n;

	for(i= 0; i< 6; i++){
		if(i== 0){
			b[i+ 1]= b[i]% 100;
			a[i]= (b[i]- b[i+ 1])/ 100;
		}
		if(i== 1){
			b[i+ 1]= b[i]% 50;
			a[i]= (b[i]- b[i+ 1])/ 50;
		}
		if(i== 2){
			b[i+ 1]= b[i]% 20;
			a[i]= (b[i]- b[i+1])/ 20;
		}
		if(i== 3){
			b[i+ 1]= b[i]% 10;
			a[i]= (b[i]- b[i+1])/ 10;
		}
		if(i== 4){
			b[i+ 1]= b[i]% 5;
			a[i]= (b[i]- b[i+1])/ 5;
		}

	}

	for(i= 0; i<=4; i++){
		cout<<a[i]<<endl;
	}

	cout<<b[5]<<endl;

	return 0;

}
int main(){
	int n=0,a[7]={0};
	scanf("%d\n",&n);
	a[1]=n/100;
	a[2]=(n%100)/50;
	a[3]=(n%50)/20;
	a[4]=((n%50)%20)/10;
	a[5]=(n%10)/5;
	a[6]=(n%5)/1;
	for(int i=1;i<=6;i++)
		printf("%d\n",a[i]);
	return 0;
}
int main(int argc, char* argv[])
{   int n;
    
	int a=0;
	int b=0;
	int c=0;
	int d=0;
	int e=0;
	int f=0;
	scanf("%d",&n);
    a=(n-n%100)/100;
	b=(n%100-(n%100)%50)/50;
	c=((n%100)%50-((n%100)%50)%20)/20;
	d=(((n%100)%50)%20-(((n%100)%50)%20)%10)/10;
	e=((((n%100)%50)%20)%10-((((n%100)%50)%20)%10)%5)/5;
	f=((((n%100)%50)%20)%10)%5;
	printf("%d\n%d\n%d\n%d\n%d\n%d\n",a,b,c,d,e,f);
   
	return 0;
}
int main()
{
	int n100=0,n50=0,n20=0,n10=0,n5=0,n1=0,m=0;
	scanf("%d",&m);

	if (m>=100)
	{
		n100=m/100;
		m=m%(n100*100);
	}
	if (m>=50)
	{
		n50=m/50;
		m=m%(n50*50);
	}
	if (m>=20)
	{
		n20=m/20;
		m=m%(n20*20);
	}
	if (m>=10)
	{
		n10=m/10;
		m=m%(n10*10);
	}
	if (m>=5)
	{
		n5=m/5;
		m=m%(n5*5);
	}
	n1=m;
	printf("%d\n%d\n%d\n%d\n%d\n%d\n",n100,n50,n20,n10,n5,n1);
	return 0;
}
//???? 
//???




int main()
{
    int n,len;
    char str[1000][1000];
    cin>>n;
    int i;
    for(i=0;i<n;i++)
    cin>>str[i];//??
    cout<<*str;
    char (*p)[1000];  //??????

    len=strlen(*str);
    for(p=str+1;p<n+str;p++)
    {
        len+=strlen(*p);
        if(len>=80)//??
        {
            cout<<endl;//??
            cout<<*p;//??
            len=strlen(*p); //?????
        }
        else{//????
            cout<<" "<<*p;
            len++;
        }
    }
    return 0;
    
}//??
//********************************
//*???2.???? **
//*?????? 1300017623 **
//*???2013.12.11  **
//********************************
int main()
{
	char a[1000][43];
	char (*p)[43] = a;
	int n, l, i;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> *(p + i);
	do
	{
		cout << *p;
		l = strlen(*p);
		p++;
		while((l += strlen(*p) + 1) <= 80)
		{
			cout << " " << *p;
			p++;
			if (p > &a[n-1])
				break;
		}
		cout << endl;
	}while(p <= &a[n-1]);

	return 0;
}
int main(int argc, char* argv[])
{
	char word[41],words[41];
	int n,s=0,l,i,x=90;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{	
		scanf("%s",word);
		l=strlen(word);		
		if (i==1) {s=l;printf("%s",word);continue;}
		s=s+l+1;
		if (s<=80) printf(" %s",word);
		else {printf("\n%s",word);s=l;}
		
	}
	return 0;
}
//********************************
//*???2.cpp   **
//*?????? 1200012768 **
//*???2013.1.3  **
//*???????  **
//********************************
int main()
{
	int n, i, j, count = 0, len1, len2;
	cin >> n;
	char w1[41], w2[41], w3[41];
	cin >> w1;
	len1 = strlen(w1);
	if (n == 1)
		cout << w1;
	else if (n == 2)
	{
		cin >> w2;
		cout << w1 << " " << w2; 
	}
else
{
	for (i = 2;i < n; i++)
	{
		cin >> w2;
		len2 = strlen(w2);
		count += len1 + 1 + len2;
		if (count <= 80)
		{
			cout << w1 << " ";
			count -= len2;
		}
		else
		{
			cout << w1 << endl;
			count = 0;
		}
		strcpy(w1, w2);
		len1 = strlen(w1);
	}
	cin >> w2;
	len2 = strlen(w2);
	count += len1 + 1 + len2;
	if (count <= 80)
		cout << w1 << " " << w2;
	else
		cout << w1 << endl << w2;
}
	return 0;
}
void compose_word(char word[1000][25], int number)
{
	int count = 0, len = 0, first = 0, i = 0;//count????????????????len?????????,first?????????
	len = strlen(word[0]);
	for (i = 0; i < number;)
	{
		while (len + count < 80)
		{
			if (first)
			{
				cout << ' ';
				count ++;
			}
			else
				first = 1;
			cout << word[i];
			count += len;
			i ++;
			if (i >= number)
				break;
			len = strlen(word[i]);
		}
		cout << endl;
		count = 0;
		first = 0;
		if (i >= number)
			break;
	}
}
int main()
{
	int number = 0, i;//number????????
	cin >> number;
	getchar();
	char word[1000][25] = {'\0'};
	for (i = 0; i < number; i ++)
		scanf("%s",word[i]);
	compose_word(word,number);//????
	return 0;
}
/*
 * word.cpp
 *
 *  Created on: 2011-12-11
 *      Author: wangshiheng
 */

int main()
{
	char words[41];
	int s=-1,l,n,i;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>words;
		l=strlen(words);
			if (s==-1){s=l+s+1;cout<<words;}
			else if (s+l+1<=80){s=l+s+1;cout<<' '<<words;}
			else {s=l;cout<<endl;cout<<words;}
	}

	return 0;
}
int main()
{
      int n,i,s=0;
	  struct z
	  {
		  char a[40];
		  int l;
	  }z[1000];
	  scanf("%d",&n);
	  for(i=0;i<n;i++)
	  {
		  scanf("%s",z[i].a);
		  z[i].l=strlen(z[i].a);
	  }
	  for(i=0;i<n-1;i++)
	  {
			  
			  
				  s=s+z[i].l;
				  printf("%s",z[i].a);
				  
			  
			  if(s+z[i+1].l>=80)
			  {
				  printf("\n");
				  s=0;
			  }
			  else {
				  printf(" ");
			  s++;
			  }
			  
			  
	  }
	  printf("%s",z[n-1].a);





	return 0;
}
int main(int argc, char* argv[])
{
    int n,i,m,count=0,k=0;
	char c[40];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",c);
        m=strlen(c);
		
		count=count+m+1;
		if(count-1>80)
		{
			printf("\n%s",c);
			count=m+1;
			
		}
		else
		{
			if(k==0)
			{
              printf("%s",c);
			  k=1;
			}
			else
			printf(" %s",c);
		}
	}
	return 0;
}
int main(){
	int n,i,num,t;  //????
	cin>>n;
	char word[1000][40];
	for(i=0;i<n;i++)
	    scanf("%s",word[i]);  //????????
	i=0;
	for(t=0;i<n-1;t++){  //???
		cout<<word[i];  //??????
		for(num=1+strlen(word[i]);i<n-1;){
		    num=num+strlen(word[i+1])+1;
		    if(num<=81){  //??????
		    	cout<<" "<<word[i+1];
		    	i++;}
		    else{
		    	cout<<endl;  //??
		    	i++;
		    	break;}
		}
	}
	return 0;  //????
}
void main()
{
 char word[50];
 int a=0,b=0,c,d,i,n,j,k;
 scanf("%d",&n);
 scanf("%s",word);
  a=strlen(word)+1;
  b=b+a;
  printf("%s",word);
 for(i=1;i<n;i++)
 {
  scanf("%s",word);
  a=strlen(word)+1;
  b=b+a;
  if(b<=81) printf(" %s",word);
   if(b>81) 
  {
   printf("\n%s",word);
   b=a;
  }
 }
}
int main()
{
	char verb[42], m;
	int num, size, sum = 0;
	cin >> num;
	while (1)
	{
		cin >> verb;
		m = cin.get();
		size = strlen(verb);
		if (sum == 0)
		{
			cout << verb;
			sum += size;
		}
		else
		{
			sum += (size + 1);
			if (sum <= 80)
			{
				cout << " " << verb;
			}
			else 
			{
				cout << endl;
				cout << verb;
				sum = size;
			}
		}
		if (m == '\n')
			break;
	}
	return 0;
}
int main()
{
	int n;                          //n????
	char ch[1000][41];
	int len[1000];

	cin >> n;
	for ( int i = 0; i < n; i++ )   //??
	{
		cin >> ch[i];
		len[i] = strlen(ch[i]);
	}
	char *p;                         //????

	int num = 0, cnt = 0;           //???????cnt??????num
	while(1)
	{
		if ( cnt >= n )             //???????????
			break;
    	while( num + len[cnt] <= 80 )  //???????????????80????
		{
			p = ch[cnt];            //?????ch[cnt]???????????
			if ( cnt >= n )
		    	break;
	    	cout << p;             //??????
			num += len[cnt];          //????
			cnt++;
			if ( num + len[cnt] < 80 && cnt < n)  //???????????????1
			{
				num++;
				cout << " ";
			}
			else
			{
				cout << endl;
				num = 0;                      //????????
			}
		}
	}
	return 0;
}
int main()
{
	int n;
	cin>>n;
	char p[1][20];
	cin>>(*p);
	int len=strlen(*p);
	cout<<(*p);
	for(int i=1;i<n;i++)
	{
		cin>>(*p);
		if(len+strlen(*p)+1>80)
		{
			cout<<endl<<(*p);
			len=strlen(*p);
		}
		else
		{
			cout<<' '<<(*p);
			len+=strlen(*p)+1;
		}
	}
	return 0;
}
/*
 * assignment.cpp
 *
 *  Created on: 2010-11-23
 *      Author: ??
 *      ????
 */
//???
int main() {
	int n;
	cin >> n;
	char word[100];
	unsigned int len = 0;
	for (int i = 0; i < n; i++) {
		cin >> word;
		len = len + strlen(word)+1 ;
		if (len == strlen(word) + 1){
			cout << word;
			len--;
		}
		else if (len <= 80)
			cout << " " << word;
		else {
			cout << endl << word;
			len = strlen(word) ;
		}
	}
	return 0;
}
const int maxlen=80;

char st[50];

int n, len, newline, nowlen;

int main(){

	//freopen("a.in", "r", stdin);
	scanf("%d", &n);
	newline = 1;
	for (int i=0; i<n; i++){
		scanf("%s", st);
		nowlen = strlen(st);
		if ((i?1:0)+nowlen+len > maxlen){
			printf("\n%s", st);
			len = nowlen;
		}
		else {
			if (i) putchar(' ');
			printf("%s", st);
			len += (i?1:0) + nowlen;
		}
	}

	return 0;
}
main()

{     int n,i,s=0,flg=0;
      char p[1000][50],l[1000];
      scanf("%d",&n);
      for(i=0;i<n;i++)
         {scanf("%s",p[i]);
         l[i]=strlen(p[i]);}
      for (i=0;i<n;i++)
          {if (flg)                    //shouwei 0  
              if ((s+l[i]+1)<=80)
                 {printf(" %s",p[i]);
                 s=s+l[i]+1;}
              else 
               {
               printf("\n");
               printf("%s",p[i]);
               s=l[i];}
          else
                 {printf("%s",p[i]);
                 flg=1;
                 s=s+l[i];}
              
                       
                       }
      
     
}
struct word
{
	char str[50];
	int a;
	struct word *next;
}w[10000];
int main()
{
	struct word *head,*p1,*p2,*p;
	int n,i=0,t=0;
	scanf("%d", &n);
	p1=p2=(struct word *)malloc(len);
	 scanf("%s",p1->str);
	p1->a=strlen(p1->str);
	head=NULL;
	while(i<n-1)
	{
		i++;
		if(i==1)
		  head=p1; 
		p1=(struct word *)malloc(len);
	    scanf("%s",&p1->str);
     	p1->a=strlen(p1->str);
	    p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	p=head;
	i=0;
	while(i<n)
	{ 
	  printf("%s",p->str);
	  i++;
	  t=t+p->a;
	  p=p->next;
	 if(p!=NULL)
	 {
	   while(t+1+p->a<=80)
	   {
		 printf(" ");
	     printf("%s",p->str);
		 i++;
		 t=t+1+p->a;
		 p=p->next;
		 if(p==NULL)
			 break;
	   }
	 }
	   printf("\n");
	   t=0;
	}
	return 0;
}
int main()
{
	char a[50];
	int n,b[1000];
	cin>>n;
	int i,j,k,m,q=0,s=0,para=0,word=0;
	char *p=a;
	cin>>a;cout<<a;//?????
	para=para+strlen(a);
	for(i=1;i<n;i++)
	{
		cin>>a;
		word=strlen(a);
		para=para+strlen(a)+1;
		if(para==strlen(a)+1)
		{
			cout<<a;
			para=para-1;//???????
		}
		else
		{
		if(para<80&&para!=strlen(a)+1)
		{
			cout<<" ";
			for(p=a;p<a+strlen(a);p++)
				cout<<*p;//??????
		}
		if(para==80)
		{
			cout<<" ";
			for(p=a;p<a+strlen(a);p++)
				cout<<*p;
			cout<<endl;//??80???
			para=0;
		}
		if(para>80)
		{
			para=strlen(a);
			cout<<endl;
			for(p=a;p<a+strlen(a);p++)
			cout<<*p;//??????
		}
		}

	}
	return 0;
}
int main()
{
	char a[100000];
	int n,i,j,count=0;
	cin>>n;
	cin.get();
	cin.getline(a,100000);
	for(i=0;a[i]!='\0';i++)
	{
		if(a[i]!=' ')
		{
			cout<<a[i];count++;
		}
		if(a[i]==' ')
		{
			for(j=i+1;a[j]!='\0';j++)
			{
				if(a[j]==' ')
					break;
			}
			if((count-1)/80==(count+j-i-1)/80)
			{
				cout<<a[i];count++;
			}
			else
			{
				cout<<endl;count=0;
			}
		}
	}
	return 0;
}
int main()
{
	int n,i,j,len[250];
	char word[250][40];
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
	    scanf("%s",word[i]);
		len[i]=strlen(word[i]);
	}
	for(j=0,i=0;i<n;i++)
	{
		j+=len[i]+1;
		if(i!=n-1)
		{
		if(j-1>80)
		{
			printf("\n");
			i--;
			j=0;
		}else{
			if(j==80&&j-1==80)
			{
				printf("%s",word[i]);
				printf("\n");
			}else{
				if(j+len[i+1]>80)
				{
				printf("%s",word[i]);
				}else{
				printf("%s",word[i]);
				printf(" ");
				}
			}
		}
		}else{
			printf("%s",word[n-1]);
		}
	}
	return 0;
}
int main()
{
	char word[1000][40]={'\0'};
	int wordlen[1000]={0},i,n,sum=0;	//sum??????????
	cin>>n;
	cin.get();
	for (i=0;i<n;i++)
		cin>>word[i];						//???cin??????
	for (i=0;i<n;i++)
		wordlen[i]=strlen(word[i]);			//?????????
	cout<<word[0];
	sum=wordlen[0];
	for (i=1;i<n;i++)
	{
		if ((wordlen[i]+1+sum)<=80)
		{
			cout<<" "<<word[i];
			sum=sum+wordlen[i]+1;
		}
		else
		{
			cout<<endl;
			sum=wordlen[i];
			cout<<word[i];
		}
	}
	return 0;
}
int main()
{
	int i, j, n, k = 0, sum = 0, len = 0;
	int flag[100];
	char word[1000][41];
	cin >> n;
	for(i = 0; i < n; i ++)
		cin >> word[i];
	flag[0] = 0;
	for(i = 0; i < n; i ++)
	{
		len = strlen(*(word + i));
		sum += len;
		if(sum + i - flag[k] > 80)
		{
			flag[++ k] = i;
			i --;
			sum = 0;
		}
	}
	flag[k + 1] = n;
	for(i = 0; i <= k; i ++)
	{
		for(j = flag[i]; j < flag[i + 1] - 1; j ++)
		{
			cout << *(word + j) << " ";
		}
		cout << *(word + flag[i + 1] - 1) << endl;
	}
	return 0;
}
//********************
//**???????	**
//**?????		**
//**???2013.12.14**
//**????2.cpp	**
//********************
int main()
{
	char word[1000][40], (*p)[40] = word;
	int n, i, g, temp = 1, cnt[1000] = {0};
	cin >> n; // ??????
	for (i = 1; i <= n; i++)
		cin >> word[i]; // ?????????
	for (i = 1; i <= n; i++)
	{
		cnt[i] = cnt[i - 1] + strlen(word[i]); // ??????????

		// ???????80???????????????????????????????????????????????
		if ((cnt[i - 1] <= 81 && cnt[i] >= 81) || i == n)
		{
			for (g = temp; g < i- 1; g++) // ??????????
				cout << word[g] << ' ';
			cout << word[i - 1];
			if (i < n)
				cout << endl;
			else
			{
				cout << ' '  << word[i] << endl;
				break;
			}
			temp = i;
			cnt[i - 1] = 0; // ????????????0
			i--; // i?1????????
		}
		else
			cnt[i]++; // ????????
	}
	return 0;
}
int main()
{
	int i,n;
	int count=0,flag=0;
	char word[40];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",word);
		if(count+strlen(word)+1<=80)
		{
			if(flag==0)
			{
				printf("%s",word);
				flag=1;
				count+=strlen(word);
			}
			else
			{
				printf(" ");
				printf("%s",word);
				count+=strlen(word)+1;
			}
			
		}
		else
		{
			printf("\n");
			printf("%s",word);
			count=strlen(word);
		}
	}
	return 0;
}
int main()
{
	int n;
	cin >> n;
	char word[600][40];
	char (*p)[40] = word;
	for (int i = 0; i < n ;i++)
		cin >> word[i];
	int sum = 0;
	int flag = 1;
	for (int i = 0; i < n ; i++,p++)
	{
		if (flag)
		{
			sum += strlen(word[i]);
		}
		else
		{
			sum += strlen(word[i]) + 1;
		}
		if (sum <= 80)
		{
			if (flag)
			{
				cout << *p;
				flag = 0;
			}
			else
				cout << " " << *p;
		}
		else
		{
			cout << endl;
			flag = 1;
			sum = 0;
			i--;
			p--;
		}
	}
	return 0;
}
int main()
{
	int n;
	cin>>n;
		char str[1000][40];
	int i;
	for(i=0;i<n;i++)
	{
		cin>>*(str+i);
	}
	int len;
	
	for(i=0;i<n;i++)
	{
		len=0;
		while(true)
		{
			len+=strlen(*(str+i));
			if(len+strlen(*(str+i+1))+1>80||i>=n)
			{
				cout<<*(str+i)<<endl;
				break;
			}
			else
			{
				cout<<*(str+i);
				if(len+1+strlen(*(str+i+1))<=80&&i<n-1)
				{cout<<" ";len++;}
			}i++;
		}
		//cout<<endl;
	}
	return 0;
}
int main(){
	int n;
	scanf("%d",&n);
	char zfc[1000][42];
	int i;
	for(i=0;i<n;i++){
		scanf("%s",zfc[i]);
	}
	int len=0,k;
	for(i=0;i<n;i++){    
        len=len+strlen(zfc[i])+1;
	  if(i<n-1){
		if(len<=80){
            k=len+strlen(zfc[i+1])+1;
			if(k>81){
				 printf("%s",zfc[i]);
			}
			if(k<=81){
				 printf("%s ",zfc[i]);
			}
		}
		if(len==81){
			printf("%s\n",zfc[i]);
			len=0;
		}
		if(len>81){
			printf("\n%s ",zfc[i]);
			len=strlen(zfc[i])+1;
		}
	  }
	  if(i==n-1){
		  printf("%s",zfc[n-1]);
	  }

	}
	return 0;
}
int main()
{
    int n;
    scanf("%d",&n);
    char word[2000][1000];
    for(int i=0;i<n;i++)
    {
        scanf("%s",word[i]);    
    }
    int start=0;
    int count=0;
    for(int i=0;i<n;i++)
    {
        count=count+strlen(word[i]);
        if(count+i-start>80)
        {
            for(int j=start;j<=i-2;j++)
            printf("%s ",word[j]);
            printf("%s\n",word[i-1]);
            start=i;  
            i=i-1;
            count=0;       
        }
        if(i==n-1&&count+i-start<80)
        {
            for(int j=start;j<=i-1;j++)
            printf("%s ",word[j]);
            printf("%s",word[i]);                       
        }    
    }
    return 0;
}
int main()
{
    int n,i,j,d=0,t=0;
    char s[40],s0[40],s1[10000]={'\0'};
    scanf("%d ",&n);
    scanf("%s ",s);
    d=strlen(s);
    strcat(s1,s);
    for(i=0;i<n-1;i++)
    {
      scanf("%s ",s);
      for(j=0;s[j]!='\0';j++){
       s0[t]=s[j];
       t++;
      }
      d=d+strlen(s)+1;
      if(d<=80)
      {
          s0[t]='\0';
          strcat(s1," ");
          strcat(s1,s0);
      }
      if(d>80)
       {
           s0[t]='\0';
           strcat(s1,"\n");
           strcat(s1,s0);
           d=strlen(s0);
        }
       t=0;
       
    }
    puts(s1);
    return 0;
}
/*
 * 1.cpp
 *
 *  Created on: 2012-12-10
 *      Author: ???
 *      Function:????
 */

int main() {
	int space;
	cin >> space;
	char str[10000], empty[10];
	int l[1000] = { 0 };
	cin.getline(empty, 10);
	cin.getline(str, 10000);
	int k = strlen(str);

	char *p = str;
	*(p + k) = ' ';
	int *len = l;
	int sum = 0, num = 0;//?????????
	while (sum < space) {

		while (*p != ' ') {
			if (!sum)
				cout << *p;
			p++;
			(*len)++;
		}

		//cout<<*len;
		if (sum) {
			for (char *x = p - *len - 1; x < p; x++) {
				if (num - 1 <= 80 && num + *len > 80) {
					*(p - *len - 1) = '\n';
					num = 0;
				} else if (num + *len <= 80)
					*(p - *len - 1) = ' ';

				cout << *x;
			}
		}
		num += *len + 1;
		//cout << " ";
		p++;
		sum++;
		len++;
		//cout << sum << " " << num;
	}

	return 0;
}
int main()
{
	int n,i;
	int count=0;
	char word[40];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",word);
		if (count==0)
			printf("%s",word);
		int j=0;
		while (word[j]!='\0')
		{
			j++;
		}
		count=count+j;
		if(count>j)
		{
		if(count<79)
		{
			count++;
			printf(" %s",word);
		}
		else if(count==79)
		{
			printf(" %s\n",word);
			count=0;
		}
		if(count>79)
		{
			printf("\n%s",word);
			count=j;
		}
		}
	}
	return 0;
}
int main()
{
    int max = 80;
    int i, n, len;
    int end = 0;   /* ????????????? */
    char word[80];

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s", word);
        len = strlen(word);
        /* ?????????????????????
           ???80????????? */
        if (end + len + 1 > 80) {
            printf("\n");
            end = 0;
        }
        else {
            /* ?????????????????? */
            if (i > 0) {
                printf(" ");
                end++;
            }
        }
        printf("%s", word);
        end += len;
    }
    return 0;
}
int main()
{
    int n,i;
    cin>>n;
    char word[n][81],c;
    for(i=0;i<n;i++)
    {
        cin>>word[i];
    }
    int sum=strlen(word[0]);
    cout<<word[0];
    for(i=1;i<n;i++)
    {
        if(sum+strlen(word[i])+1<=80)
        {
            if(sum!=-1) cout<<' ';
            cout<<word[i];
            sum=sum+strlen(word[i])+1;
        }
        else
        {
            cout<<endl;
            sum=-1;
            i--;
        }
    }
    return 0;
}
int main()
{
	int n, i, sum = 0, len;
	char c[10000][41];
	char (*p)[41];
	p = c;
	cin >> n;
	for(i = 0;i < n;i++)
		cin >> *(p+i);
	 for(i = 0;i < n;i++)
	 {
		 len = strlen(*(p+i));
		 if(sum + len > 80)
		 {
			 sum = 0;
			 cout << *(p+i) <<' ';
		 }
		 else if(sum + len < 80)
		 {
			 sum = sum + len + 1;
			 len = strlen(*(p+i+1));
			 if(sum + len > 80)
			 {
				 sum = 0;
				 cout << *(p+i);
				 cout << endl;
			 }
			 else if(sum + len < 80) 
			 {
				 if(i == n-1)  cout << *(p+i);
				 else cout <<*(p+i) <<' ';
			 }
		 }
		 else if(sum + len == 80)
		 {
			 sum = 0;
			 cout << *(p+i-1) <<' '<< *(p+i) <<endl;
		 }
	 }
	 return 0;
}
int main()
{int n;
cin>>n;
int t=0;
char a[80];
int i,j;
cin>>a;
t=strlen(a)+1;
cout<<a;
for(i=1;i<n;i++)
{cin>>a;
if(t+strlen(a)<=80)
{cout<<' '<<a;
t=t+strlen(a)+1;
}
else
{cout<<endl<<a;
t=strlen(a)+1; 
}
}


return 0;

}
int len(char word[81])
{
	char *p;
	p=word;
	int i=0,count=0;
	for(i=0;i<81;i++)
	{
		if(*(p+i)==0)
			break;
		else
			count++;
	}
		return count;
}
int main()
{
	char word[81];
	memset(word,0,sizeof(word));
	int n=0,num=0;
	cin>>n;
	int i=0;
	scanf("%s", word);
	cout<<word;
	num=len(word)+1;
	for(i=2;i<=n;i++)
	{
		scanf("%s", word);
		if(len(word)+num>80)
		{
			cout<<endl;
			cout<<word;
			num=len(word)+1;
		}
		else
		{
			cout<<" "<<word;
			num=num+len(word)+1;
		}
	}
	return 0;
}
//********************************
//*???*????*
//*?????? 1300012811 **
//*???2013.12.13 **
//********************************
int main ()
{
	int n ;
	char str[10001][40];
	cin >> n ;cin.get();
	for ( int i = 1 ; i <= n ; i++ )
	{
		cin.getline(str[i],40,' ');
	} 
	int sum = 0 ;
	for ( int i = 1 ;i <= n ; i ++ )
	{
		sum += strlen(str[i]);
		if ( sum <= 80 )
		{
			if ( sum != strlen(str[i]) )
			{				
				cout << " " ;
			}
			for ( int j = 0 ; j < strlen(str[i]); j ++ )
			{
				cout << *(str[i]+j);
			}
			sum ++ ;			
		}
		else
		{
			cout << endl ;
			sum = 0 ;
			i -- ;
		}
	}
	return 0 ;
}
int word_len(char *p)  //????????
{
	int n=0;
	for (;*p!=0&&*p!=' ';p++)
		n++;
	return n;
}
int main ()
{
	char str[10001]={0};
	char *p=str;
	int n;
	cin>>n;
	getchar();
	cin.getline(p,10000,'\n');
	int row=0;
	for (int i=0;i<n;i++)
	{
		if (row+word_len(p)<=79)
		{
			if (row!=0)
			{
				cout<<" ";
				row++;  //???????
			}
			row+=word_len(p);
			for (;*p!=' '&&*p!=0;p++)
				cout<<*p;  //??????
		}
		else //??80???
		{
			cout<<endl;
			row=word_len(p);
			for (;*p!=' '&&*p!=0;p++)
				cout<<*p;  
		}
		p++;
	}
	
	return 0;
}
//??????????????????????....???strlen???????????????...???????????= =
int main()
{
	char a[45];
	int m;
	int count=0;
	cin>>m;
	for(int i=1;i<=m;i++)
	{
	cin>>a;
		if(count==0)	//?????????????
			{cout<<a;	//????
			count=strlen(a);//???????????
			}
		else if(count+strlen(a)+1<80)	//??????????????80??????
		{
		cout<<" "<<a;	//?????? ???????
		count=count+strlen(a)+1;	//??????????????
		}
		else if(count+strlen(a)+1==80)		//????????????80
		{
		cout<<" "<<a<<endl;	//????????????????
		count=0;	//????????0
		}
		else		//????????????????80
			{
			 cout<<endl;	//???
			 cout<<a;		//???????????
			 count=strlen(a);
			}
	}
	return 0;
}
char word[200][41];
void pb(char* a,int p,int t)
{
    t += strlen(a);
    if(t > 80)
    {
      printf("\n");
      t=0;
      t += strlen(a);
    }
    else if(t - strlen(a))
     printf(" "); 
    printf("%s",a);
    t++;
    if(p) 
    pb(word[p-1],p-1,t);
}
int main()
{   
  int n,i;
  char m;
  scanf("%d",&n);
  for(i = n-1;i >= 0; i--)
  {
   scanf("%s",word[i]);
   getchar(); 
  }
  pb(word[n-1],n-1,0);
 return 0;    
}
int main()
{
	int i=0,j,begin,end;
	char a[10000],b[10];
	gets(b);
	gets(a);
	while(a[i]){
		begin=i;
		for(j=0;j<80&&a[i];j++)
			i++;
		if(a[i]==0){
			end=i-1;
			i--;
		}
		else{
			while(a[i]!=' ')
					i--;
			end=i-1;
		}
		while(begin<=end){
			printf("%c",a[begin]);
			begin++;
		}
		printf("\n");
		i++;
	}
	return 0;
}
/*
 * WenziPaiban.cpp
 *
 *  Created on: 2012-12-18
 *      Author: ThinkPad
 */
int main()
{
    int n,i,count=0;
    cin>>n;
    char a[n][40];
    for(i=0;i<n;i++)
    	cin>>*(a+i);
    for(i=0;i<n;i++)
    {
    	count=count+strlen(*(a+i))+1;

    	if(count<=80&&count+strlen(*(a+i+1))<=80&&i<n-1)cout<<a[i]<<" ";
    	if(count==81||count+strlen(*(a+i+1))>80||i==n-1)
    	{
    		cout<<*(a+i);
    		count=0;
    		cout<<endl;
    	}
    }

	return 0;

}
//********************************
//*???????   **
//*?????? 1300012713 **
//*???2013.12.11  **
//********************************
int main()
{
	int n, m = 0, b[300] = {0};
	char a[300][40];
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> *(a+i);
		*(b+i) = strlen(*(a+i));
	}
	for(int j = 1; j <= n; j++)
	{
		m = m + *(b+j) + 1;
		if(m <= 81)
		{
			cout << *(a+j);
			if(j < n && m + *(b+j+1) < 81) cout << " ";
		}
		else 
		{
			m = 0;
			cout << "\n";
			j--;
		}
	}
	return 0;
}
int main()
{
	char word[500][40];
	int n,i,l[500],length=80;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>word[i];
		l[i]=strlen(word[i]);
	}
	cout<<word[0];
	length=length-l[0];
	for(i=1;i<n;i++)
	{
		if(l[i]<length)
		{
			cout<<" "<<word[i];
			length=length-l[i]-1;
		}
		else
		{
			cout<<endl;
			length=80;
			cout<<word[i];
			length=length-l[i];
		}
	}
	return 0;
}