semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n;
	scanf("%d",&n);
	char s[1000][50]={0};
	int i=0,j=0,a[1000]={0},z[1000]={0};
	for(i=0;i<n;i++)
	{
		scanf("%s",s[i]);
		a[i]=strlen(s[i]);
	}
	for(i=0;i<n-1;i++)
	{
		if(z[j]+a[i]<=80&&z[j]+a[i]+1+a[i+1]<=80)
		{
			printf("%s ",s[i]);
			z[j]=z[j]+a[i]+1;
		}
		else if (z[j]+a[i]<=80&&z[j]+a[i]+1+a[i+1]>80)
		{
			printf("%s",s[i]);
			z[j]=z[j]+a[i]+1;
		}
		else if(z[j]+a[i]>80)
		{
			j++;
			printf("\n%s ",s[i]);
			z[j]=z[j]+a[i]+1;
		}
                  	}

	
printf("%s",s[n-1]);
	return 0;
}
int main()
{
	int n, i, len, p = 0;
	cin >> n;
	char str[40];
	for (i = 0; i < n; i++)
	{
		cin >> str;
		len = strlen(str);
		if (p + len < 80)
		{
			if (p != 0)
			{
				cout << " ";
				p++;
			}
			p = p + len;
		}
		else
		{
			p = len;
			cout << endl;
		}
		cout << str;
	}
	return 0;
}
int main()
{
	char words[2000][20],(*p)[20],*s,sumlen=0,len;
	int num;
	cin>>num;
	for(p=words;p-words<num;p++)
	{
		cin>>*p;
	}
	for(p=words;p-words<num;p++)
	{
		for(s=*p;*s!=0;s++);
		len=s-*p;
		if(sumlen+len+1<80)
		{
			if(sumlen==0)
			{
				cout<<endl;
				cout<<*p;
				sumlen+=len;
			}
			else
			{
				cout<<" "<<*p;
				sumlen+=(len+1);
			}
		}
		else
		{
			if(sumlen+len+1==80)
			{
				sumlen=0;
				cout<<" "<<*p;
			}
			else
			{
				sumlen=0;
				p--;
			}
		}
	}
	return 0;
}
main()
{
      int n;
      scanf("%d",&n);
      int i;
      char a[10000][40];
      for (i=0;i<n;i++)
      {
          scanf("%s",a[i]);                   //???? 
      }
      int t,s=0;
      for (i=0;i<n;i++)
      {
         if(i==0)
         {
           t=strlen(a[i]);
           printf("%s",a[i]);                 //????????? ?s????????????? 
           s=s+t;
         }
         else
         {
           t=strlen(a[i]);
           s=s+t+1;
           if(s<=80)
           {
               printf(" %s",a[i]);                //??????????????80?????????? 
           }
           else
           {
               printf("\n");
               printf("%s",a[i]);             //?????80?????????s ?????????????? 
               s=t;                          
           }
         }
      }
      getchar();getchar();getchar();getchar();
}
int main()                            //?????
{
	int n=0;
	int a[81]={0};                    //???????81???
	int *p=&a[0];                     //???????????????
	char s[42];
	cin>>n;
	cin>>s;                           //?????????????
	cout<<s;
	p=p+strlen(s);                    //?????????strlen?s????
	for(int i=0;i<n-1;i++)            
	{
		cin>>s;        
		if(p+strlen(s)<&a[80])         //??????????????????strlen?s????????????????????????????????????strlen(s)+1???
			cout<<" "<<s,p=p+strlen(s)+1;
		else                             //??????????strlen?s?????????????????????????????????&a?0?+strlen?s?
		{
			cout<<endl;
			cout<<s;
			p=&a[0]+strlen(s);		
		}
	}
	return 0;
}
int n,len,tot;
char a[1000][50];
void fill(int p);
int main()
{
	int i,j;
	scanf("%d",&n);
	for (i=0;i<n;i++)
		scanf("%s",&a[i]);
	printf("%s",a[0]);
	tot=strlen(a[0]);
	for (i=1;i<n;i++)
	{
		len=strlen(a[i]);
	    if (tot+len+1<=80)
		{
			printf(" %s",a[i]);
			tot+=len+1;
		}
		else
		{
			printf("\n");
			printf("%s",a[i]);
			tot=len;
		}
	}
}
/*************************
 ***??:??? 1200012776
 ***????:????
 ***??:2012?12?7?
 *************************/
int main()
{
	char ch[2000] = {0}, *p = &ch[0], *q = NULL, *l = NULL, *k;
	int n, flag = 0;
	cin >> n;
	cin.get();
	cin.getline(ch, 2000);
	while (*p != 0)	//??
	{
		flag = 0;
		for (q = p; ;)	//??????????
		{
			for (l = q; *l != ' ' && *l != 0; l++);	//???????
			l--;
			if (l - p < 80)	//???????????80,????
			{
				if (flag == 1)	//?????????,????,?????
				{
					cout << " ";
				}
				for (k = q; k <= l; k++)
				{
					cout << *k;
					flag = 1;
				}
				q = l + 2;	//?q??l+2,???????
			}
			else
			{
					cout << endl;	//??????,??????
					break;
			};
			if (*(l + 1) == 0)
			{
				q = l + 2;
				break;
			}
		}
		p = q;
	}
	return 0;
}
main()
{
    int n,i=0,j=0,k=0;
    int a[100];
    scanf("%d",&n);
    char word[10000];
    do
    {
        scanf("%s",&word[i]);
        i=strlen(word);
        word[i]=' ';
        j=j+1;
        i=i+1;
    }
    while(j<n);
    i=80;
    j=0;
    do
    {
        k=i;
        do
        {
            if(word[k]==' ')
            {
                a[j]=k;
                break;
            }
            k=k-1;
        }
        while(k>i-80);
        i=k+81;
        j=j+1;
    }
    while(word[i]!=0);
    i=0;
    j=0;
    do
    {
        if(i==a[j])
        {
            printf("\n");
            j=j+1;
        }
        else printf("%c",word[i]);
        i=i+1;
    }
    while(word[i+1]!=0);
}
//
//  main.cpp
//  ????
//
//  Created by mac on 12-12-12.
//  Copyright (c) 2012? mac. All rights reserved.
//

int main(){
    int n,num;
    char str[1000][1000];
    cin>>n;
    char (*p)[1000];
    for(int i=0;i<n;i++)
    cin>>str[i];
    cout<<*str;
    num=strlen(*str);
    for(p=str+1;p<n+str;p++){
        num=num+strlen(*p);
        if(num>=80){
            cout<<endl;
            num=strlen(*p);
            cout<<*p;
        }
        else{
            cout<<" "<<*p;
            num=num+1;}
    }
    return 0;
}
int main() {
	char str[1000][45];
	int n, sum = 0;
	cin >> n;
	for ( int i = 1; i <= n; i ++ ) {
		cin >> str[i];
	}
	for ( int i = 1; i <= n; i ++ ) {
		if ( sum == 0 ) {
			cout << str[i];
			sum += strlen( str[i] );
		}
		else if ( sum + strlen( str[i] ) + 1 <= 80 ) {
			cout << " " << str[i];
			sum += strlen( str[i] ) + 1;
		}
		else {
			cout << endl;
			sum = 0;
			i = i - 1;
		}
	}
	return 0;
}
int main()
{
	char str[2000][50];
	int n,i,j,sum=0,geshu,ji=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s",str[i]);
	for(i=0;i<n;i++)
	{
		j=0;
		geshu=0;
		while(str[i][j]!='\0')
		{
			geshu++;
			j++;
		}
		if(ji==0) 
		{
			printf("%s",str[i]);
		    sum=sum+geshu;
		}
		else
		{
			sum=sum+geshu+1;
			if(sum<=80)
				printf(" %s",str[i]);
			else
			{
				printf("\n%s",str[i]);
				sum=geshu;
			}
		}
		ji=1;
	}
	
	return 0;
}
int main()
{
	int t = 0, n, flag[10000] = {0};
	char word[10000][40];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> word[i];
	cout << word[0];
	t = strlen(word[0]);
	for (int i = 1; i < n; i++)
	{
		int l = strlen(word[i]) + 1;
		t = t + l;
		if (t < 81)
			cout << " " << word[i];
		if (t >= 81)
		{
			cout << endl << word[i];
			t = strlen(word[i]);
		}
	}
	return 0;
}
int main(){
	int n;
	cin>>n;
	char l[n][20];
	for(int i=0;i<n;i++)
		cin>>l[i];
	int len=0;
	for(int i=0;i<n;i++){
		if(len+strlen(l[i])>=80){
			cout<<endl;
			cout<<l[i];
			len=strlen(l[i]);
		}
		else if(len==0){
			cout<<l[i];
			len+=strlen(l[i]);
		}
		else {
			cout<<' '<<l[i];
			len+=strlen(l[i])+1;
		}
	}
	return 0;
}
int main(){
	int n,i,j=0,k,t,sum=0;						//??????
	char word[40],str[80];						//??????word???????str?????????
	cin>>n;										//??????
	for(i=1;i<=n;i++){							//????????
		cin>>word;								//????
		sum+=strlen(word);						//???????????
		if((i!=n)&&(sum<=80)){					//??????????????????????80
			for(k=0;k<strlen(word);k++,j++)		
				str[j]=word[k];					//????????????
			str[j]=' ';							//???????
			j++;								//?str????????
			sum++;								//???????
		}
		else if(sum>80){						//????????80
			for(t=0;t<j-1;t++)cout<<str[t];		//????????
			cout<<endl;				
			memset(str,0,sizeof(str));			//?str??
			for(j=0,k=0;k<strlen(word);k++,j++)	//?j??
				str[j]=word[k];					//?????????????
			str[j]=' ';							//???????
			j++;								//?str????????
			sum=strlen(word)+1;					//???????
		}
		else {									//????????????
			for(k=0;k<strlen(word);k++,j++)		
				str[j]=word[k];					//?????
			for(t=0;t<=j-1;t++)cout<<str[t];	//????????
			cout<<endl;
		}
	}
	return 0;
}
int main()
{
	int n;
	int i;
	int l;
	int left = 80;
	char word[10000][42];
	scanf("%d", &n);
	for(i = 0; i<n;i++)
	{
		scanf("%s", word[i]);
	}
	for(i = 0; i<n;i++)
	{
		l = strlen(word[i]);
		if(left == 80)
		{
			printf("%s", word[i]);
			left -= l;
		}
		else if(left >= l+1)
		{
			printf(" %s", word[i]);
			left -= l+1;
		}
		else
		{
			printf("\n%s", word[i]);
			left = 80 - l;
		}
	}
	return 0;
}
int main()
{
	int n, len, i, letter, flag;
	cin >> n;
	char word[1000][41];
	len = 0;
	letter = 0;
	flag = 0;
	for (i = 0; i < n; i++)
	{
		cin >> word[i];
	}
	for (i = 0; i < n; i++)
	{	
		if (flag == 1)
		{
			letter++;
		}
		len = strlen(word[i]);
		letter += len;
		if (letter > 80)
		{
			cout << endl;
			letter = len;
			flag = 0;
		}
		if (flag == 1)
		{
			cout << " " << word[i];
		}
		else
		{
			cout << word[i];
			flag = 1;
		}
	}
	return 0;
}
main(){
	struct word{
		char a[41];
		int l;
	};
	struct word w[10000];
	int n, i, sum;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%s", w[i].a);
		w[i].l=strlen(w[i].a);
	}
	for(i=n; i==n; i++) w[i].l=0;
	sum=0;
	for(i=0; i<n; i++){
		sum+=w[i].l+1;
		if(sum+w[i+1].l<81){
			if(i==n-1) printf("%s", w[i].a);
			else  printf("%s ", w[i].a);
		}
		else{
			if(i==n-1) printf("%s", w[i].a);
			else {
				printf("%s\n", w[i].a);
				sum=0;
			}
		}
	}
}
int main()
{
	int n,sum,len[1000];
	char word[1000][41];
	char *p;               //?????????
	cin>>n;
	sum=0;
	for ( int i=0; i<n;i++ )
	{
		cin>>word[i];
		len[i]=strlen(word[i])+1;
	}
	for ( int i=0; i<n-1;i++ )
	{
		p=word[i];            //????????????
		if ( sum+len[i]<=81)
		{
			if ( sum+len[i]+len[i+1]>81) //????????
			{cout<<word[i];
			sum+=len[i];
			}
			else              //??????
				{
					cout<<word[i]<<' ';
				sum+=len[i];
				}
		}
		else
		{
			cout<<endl;
			cout<<word[i]<<' ';
			sum=len[i];
		}
	}
	cout<<word[n-1]<<endl;
	return 0;
}
//************************************
//??:????
//??:2013.12.20
//************************************
int main()
{
	int n=0,i=0,b[50],l=0,sum=0,j=0,k=0,sum2=0;
	char a[10000];
	cin>>n;
	cin.get();
	gets(a);
	for(i=0;i<strlen(a);i++)
	{
		if(a[i]!=' ')
			l++;
		else
		{
			sum=sum+l;
			if(sum>80)
			{     
				b[j]=sum-l-1;
				j++;
				sum=l+1;  
			}
			else if(sum==80)
			{     b[j]=sum;j++;sum=0;       }
			else 
				   sum=sum+1;
			l=0;
		}
	}
	b[j]=sum+l;
	j=0;
	for(i=0;i<strlen(a);i++)
	{
		cout<<a[i];
		sum2++;
		if(sum2==b[j])
		{
			cout<<endl;
			i++;
			j++;
			sum2=0;
		}
	}
	return 0;
}
void main()
{
	int n, i, t[1000]={0}, k=0;
	char word[1000][40]={""};

	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%s", word[i]);
		t[i] = strlen(word[i]);
	}

	for(i=0; i<n-1; i++)
	{
		k = k+t[i]+1;
		if(k-1<=80 && k+t[i+1]<=80)
			printf("%s ", word[i]);
		else if(k-1<=80)
			printf("%s\n", word[i]);
		else
		{
			k = t[i]+1;
			printf("%s ", word[i]);
		}
	}
	printf("%s", word[n-1]);
}
/*
 * 1.cpp
 *
 *  Created on: 2013-1-13
 *      Author: Administrator
 */
int main()
{
	int n, i, sum = 0;
	char word[1000][50];
	cin >> n;
	for(i = 1; i <= n; i++)
	{
		cin >> word[i];
	}
	for(i = 1; i <= n; i++)
	{
		cout << word[i];
		sum += strlen(word[i]);
		if(i < n && sum + strlen(word[i + 1]) + 1 <= 80)
		{
			cout << " ";
			sum++;
		}
		else
		{
			cout << endl;
			sum = 0;
		}

	}
	return 0;
}
int main()
{
int n,i,sum=0,len=0;
char word[40];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",word);
len=strlen(word);
if(len+sum>80)
{
 printf("\n");
 printf("%s",word);
 sum=len;
}
else 
{ if(sum==0)
 {printf("%s",word);
 sum=sum+len;}
 else
{ sum=sum+len+1;
  if(sum>80)
 {printf("\n");
 printf("%s",word);
 sum=len;}
else
printf(" %s",word);
}}
}
return 0;
}
void main()
{
	int n,i,len[MAX1],line=0;
	char word[MAX1][MAX2];

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",word[i]);
		len[i]=strlen(word[i]);
	}

	for(i=0;i<n;i++){
		printf("%s",word[i]);
		line+=len[i];
		if( line+1+len[i+1]>80 ){
			putchar('\n');
			line=0;
		}
		else if(i<n-1){
			putchar(' ');
			line++;
		}
	}
}
void main()
{
	int n,i,l,s,t;
	char word[40];
	scanf("%d",&n);
	scanf("%s",word);
	printf("%s",word);
	l=strlen(word);
	s=l;
	t=0;
	for(i=1;i<=n-1;i++)
	{
		scanf("%s",word);
		l=strlen(word);
		s+=l;
		t++;
		if(s+t<=80)
			printf(" %s",word);
		else
		{
			printf("\n");
			printf("%s",word);
			s=l;
			t=0;
		}
	}
}
int main()
{
	int n,i,b[1000],m;
	char a[1000][100];
	scanf("%d",&n);
	scanf("%s",a[0]);
	m=strlen(a[0]);
	for(i=1;i<n;i++)
	{
		scanf("%s",a[i]);
		b[i]=strlen(a[i]);
	}	
	printf("%s",a[0]);
	for(i=1;i<n;i++)
	{
		if(m+1+b[i]<=80)
		{
			printf(" %s",a[i]);
			m=m+b[i]+1;
		}
		else
		{
			printf("\n%s",a[i]);
		    m=b[i];
	    }
	}
	return 0;
}
char c[45];
int main()
{  
	int n,cnt=0,s=0;
	cin>>n;
	while(cnt<=n)
	{  
		while(1){
		memset(c,0,sizeof(c));
		cin>>c;//??????
		cnt++;
	  if(cnt==1||cnt==n){if(cnt==1) {cout<<c;s=strlen(c);}
	  							else cout<<' '<<c<<endl;}
	  else {s+=strlen(c)+1;
			if(s>80){cout<<endl<<c;break;}
		else cout<<' '<<c;}
		}
		s=strlen(c);
	}
		
}
/*
 * ????.cpp
 *  Created on: 2012-12-9
 *  Author: ???
 */
int main() {
	int n, m;
	cin >> n;//?????
	char a[50], *p = a;
	for (int i = 0, num = 0; i < n; i++) {//num??????????????
		cin >> a;//????
		m = strlen(a);//???????
		if (num == 0) {//??????????
			for (int j = 0; j < m; j++) {//???
				cout << *(p + j);
			}
			num += m;//num??m
		} else if (num + m + 1 <= 80) {//???????????80
			cout << ' ';//?????????
			for (int j = 0; j < m; j++) {//????????
				cout << *(p + j);
			}
			num += m + 1;//num=num+m+1
		} else {//??????????80
			cout << endl;//?????
			for (int j = 0; j < m; j++) {//???????
				cout << *(p + j);
			}
			num = m;//num??m
		}
	}
	return 0;
}
void main()
{
	char a[500][41];
	int n,i,j,k,r,b[500];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",a[i]);
		b[i]=strlen(a[i]);
	}
	for(i=0,k=b[0]+1;i<n-1;i++)
	{
		k=k+b[i+1];
		printf("%s",a[i]);
		if(k>80)
		{
			printf("\n");
			k=b[i+1]+1;
		}
		else 
		{
			printf(" ");
			k=k+1;
		}
	}
	printf("%s",a[n-1]);
}
int main()
{
    int i;
    int count;
    char *buf;
    char **words;
    int line_word_count = 0;
    scanf("%d", &count);
    words = (char **)malloc(count * sizeof(char *));
    for (i = 0; i < count; i++) {
        buf = (char *)malloc(41 * sizeof(char));
        scanf("%s", buf);
        *(words + i) = buf;
    }
    for (i = 0; i < count; i++) {
        if (i != count - 1 && line_word_count + strlen(*(words +i)) + 1 > 80) {
            printf("\n");
            line_word_count = 0;
        }
        if (line_word_count != 0) {
            line_word_count += 1;
            printf(" ");
        }
        line_word_count += strlen(*(words + i));
        printf("%s", *(words +i));
    }
    return 0;
}
int main()
{  char a[1000][42];
   int sum,i,j,k,n,m;
   cin>>n;
   sum=0;
   for (i=1;i<=n;i++)
        {cin >>a[i]; 
         m=strlen(a[i]);
         if (sum+m+1<=80) 
             if (sum!=0)
                  { cout<<" "<<a[i];
                    sum=sum+m+1; 
                    }
              else { cout<<a[i]; 
                     sum=sum+m; 
                      }        
         else { cout<<endl;
                cout<<a[i];
                sum=0;
                sum=sum+m;         
                   }   
         }
    return 0;   
    
    
    
    
    
    
    }
int main()
{
	char ch[1000][40]={'\0'};
	char *p=NULL;
	int n,i,line=0;
	cin>>n;
	for(i=0;i<n;i++)
	{cin>>*(ch+i);}
	line=strlen(*ch);
	i=0;
	while(i<n)
	{line=strlen(*(ch+i));cout<<*(ch+i);i++;if(i==n) break;line+=strlen(*(ch+i));//???????????????????????
	while(line<80)
	{cout<<' ';cout<<*(ch+i);
	i++;line++;if(i==n) break;
	line+=strlen(*(ch+i));}
	cout<<endl;
	}
	
		return 0;
}
int main()
{
	int n, count = 0, j = 1, l;
	char a[41];
	cin >> n;
	for ( int i=1;i<=n;i++)
	{
		cin>>a;
		l=strlen(a);
		count=count+l;
		if(count<80&&count!=l)
		{
			cout<<" "<<a;
			count++;
		}
		else if(count<80&&count==l)
		{
			cout<<endl<<a;
		}
		
		else
		{
			cout<<endl;
			cout<<a;
			count=l;
		}
	}
	return 0;
}
int main()
{
	int i,n,temp=0;
	scanf("%d",&n);
	char a[10000][41],(*p)[41]=a;
	for(i=0;i<n;i++) scanf("%s",*(p+i));
	for(i=0;i<n;i++)
	{
		if(temp+strlen(*(p+i))<=80)
		{
			if(temp==0)
			{
			printf("%s",*(p+i));
			temp+=strlen(*(p+i))+1;
			}
			else
			{
				printf(" %s",*(p+i));
				temp+=strlen(*(p+i))+1;
			}
		}
		else
		{
			printf("\n");
			temp=0;
			i--;
		}
	}
	return 0;
}
void main()
{
	int n,i,j,k=1,a[1000],s=0;
	char m[1000][40];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s",m[i]);
	for(i=0;i<n;i++)
		a[i]=strlen(m[i]);
	for(i=0;i<n;i++)
	{
		if(i==n-1)
		{
			printf("%s",m[i]);
			break;
		}
		s=s+a[i]+1;
		if(s+a[i+1]<=80)
		{			
			printf("%s ",m[i]);
		
		}
		else
		{
			printf("%s",m[i]);
			printf("\n");
			s=0;
		}
	
	}
}
struct N{
 char w[50];
 int n;
 struct N *next;
};
int main(){
 struct N *p,*q,*head;
 int n,d,i;
 scanf("%d",&n);
 for(i=1;i<=n;i++){                               
	 p=(struct N*)malloc(sizeof(struct N));
	 if(i==1){
	     head=p;
	     q=p;
	 }
	 else{
		 if(i!=n){
		  q->next=p;
		  q=p;
		 }
		 else{
		  q->next=p;
		  p->next=NULL;
		 }
	}}
 p=head;
 for(i=1;i<=n;i++){
  scanf("%s",p->w);
  p->n=(strlen(p->w)+1);
  p=p->next;
 }
 d=-1;
 p=head;
 for(i=1;i<=n;){
	 if(d==(-1))
	 { printf("%s",p->w);
	    i++;
	   d=d+(p->n);
	   p=p->next;}
	 if((d+(p->n))<=80&&d!=(-1)){
	  printf(" %s",p->w);
	  i++;
	  d=d+(p->n);
	  p=p->next;if(p==NULL){break;}
	 }
	 if((d+(p->n))>80){
	  printf("\n");
	  d=-1;
	 }
 }
 return 0;
}
int main()
{
	char str[100000],*p = NULL;
	int n,count = 0;
	cin >> n;
	cin.get();
	cin.getline(str,10000);
	p = str;
    for(p = str; *p != '\0';p++)
	{
		count++;
		if(count == 81)
		{
		   if(*p != ' ')
			{
				while(*p != ' ')
					p--;
			}
            *p = '\n';
			count = 0;
		}
		
	}
	for(p = str; *p != '\0'; p++)
	{
	        cout << *p;
	}
	cout << endl;
		return 0;
}
int main()
{
	char word[40];
	int i,n,len,hang=0,shou=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
			{
			 scanf("%s",word);
			 len=strlen(word);
			 hang+=len;
			 hang+=1;
			 if(hang<=80)
						 { if(shou==1)
						   { printf("%s",word);hang-=1;}
							 else 	{ printf(" %s",word);}
						    shou=0;
						 }
			 else if(hang>80){printf("\n");printf("%s",word); shou=0;hang=len;}
			}

return 0;
}
int getone(char* s)
{
	int count = 0;
	if(!cin.get(*s))
		return -1;
	while(*s != ' ' && *s != 0)
	{
		s++;
		count++;
		if (!cin.get(*s))
		{
			break;
		}
	}
	*s = 0;
	return count;
}



int main()
{
	int n;
	cin >> n;
	cin.get();
	char s[41];
	int c = 0;
	int r = 80;
	for(int i = 0 ; i < n ; i++)
	{
		c = getone(s);
		if (r == 80)
		{
			cout << s;
			r -= c;
		}
		else
		{
			if (r > c)
			{
				cout << ' ' << s ;
				r -= c+1;
			}
			else
			{
				cout << endl << s;
				r = 80 - c;
			}
		}
	}
}
int main()
{
	int n,i;
	int l[1000];
	char s[1000][40]={'\0'};
	scanf("%d\n%s",&n,s[0]);
	l[0]=strlen(s[0]);
	for(i=1;i<n;i++)
	{
		scanf(" %s",s[i]);
		l[i]=strlen(s[i]);
	}
	int a1=0,a2=0;
	for(i=0;i<n-1;i++)
	{
		a1=a1+l[i]+1;
		a2=a1+l[i+1];
		if(a1<=81&&a2<=80)
		{
			printf("%s ",s[i]);
		}
		else if(a1<=81&&a2>80)
		{
			if(i!=n-2)
			    printf("%s",s[i]);
			else
				printf("%s\n",s[i]);
		}
		else 
		{
			printf("\n%s ",s[i]);
			a1=l[i]+1;
		}
	}
	printf("%s",s[n-1]);
	return 0;
}
int main(){
	int g,cco=0;
	cin>>g;
	char b[45];
	cin>>b;
	cout<<b;
	cco=strlen(b);
	for(int i=1;i<g;i++){
		char a[45];
		char *p=a;
		cin>>a;
		cco+=strlen(a);
		if(cco<80){
			cout<<" "<<p;
			cco++;
		}
		else{
			cco=0;
			cout<<endl<<p;
			cco+=strlen(a);
		}
	}
return 0;
}
char a[1000][41];
int n;

void y(int b)
{
	int i;
	int x=0;
	for(i=b;;i++)
	{
		x=x+strlen(a[i]);
		if(x==80)
		{
			cout<<a[i]<<endl;
			if(i==n-1) break;
			y(i+1);
		}
		if(x+1<=80)
		{
			if(x+1+strlen(a[i+1])<=80)
			{
				if(i<n-1)
				{
					x=x+1;
					cout<<a[i]<<" ";
					continue;
				}
				if(i==n-1) 
				{
					cout<<a[i]<<endl;
					exit(1);
				}
			}
			if(x+1+strlen(a[i+1])>80)
			{
				cout<<a[i]<<endl;
				if(i==n-1) break;
				y(i+1);
			}
		}
	}
}

int main()
{
	int p;
	cin>>n;
	for(p=0;p<n;p++)
	{
		cin>>a[p];
	}
	y(0);
	return 0;
}
//***********************************************
//*3ìDò?o&#206;&#196;×&#214;&#197;&#197;°&#230;                               *
//*D&#213;&#195;&#251;?oo&#206;&#212;&#198;&#198;e                                 *
//*&#209;§o&#197;?o1300012888                             *
//*è&#213;&#198;ú?o2013.12.18                             *
//***********************************************

int main()
{
	int n, i, num[1000], *p = num, sum = 0;
	char word[1000][40];
	cin >> n;

	for(i = 0;i <= n - 1;i ++)
	{
		cin >> word[i];
		*(p + i) = strlen(word[i]);
	}

	for(i = 0;i <= n - 1;i ++)
	{
		if(sum == 0)
		{
			sum += *(p + i);
			cout << word[i];
		}
		else
		{
			sum += (*(p + i) + 1);
			if(sum <= 80)
				cout << " " << word[i];
			else
			{
				sum = 0;
				i --;
				cout << endl;
			}
		}
	}
	cout << endl;

	return 0;
}
int main()
{
  int n;
  int i,j;
  int k;
  int end=0;;
  scanf("%d",&n);
  char dz[50];
  for(i=0;i<n;i++)
  {
     for (i = 0; i < n; i++) {   
    scanf("%s", dz);    
    k = strlen(dz);    
  
    if (end + k +1> 80) {
        printf("\n");       
        end = 0;             
    }
    else if (end > 0) {       
        printf(" ");        
        end++;               
    }
    printf("%s", dz);      
    end += k;            
}
  }
return 0;
}
int main()
{
	int n,i,j,len;
	char word[500][81],text[500][81];
	cin>>n;
	for(i=0;i<n;i++)
		cin>>word[i];
	for(i=80;word[n-1][i]==0;i--);
	for(;word[n-1][i]==' ';i--)
		word[n-1][i]=0;

	for(i=0;i<500;i++)
		for(j=0;j<81;j++)
			text[i][j]=0;
	len=0;
	j=0;
	for(i=0;i<n;i++)
	{
		if(strlen(word[i])+len<=80)
		{
			len+=strlen(word[i]);
			strcat(text[j],word[i]);
			if(len<80&&i<n-1)
			{
				text[j][len]=' ';
				len+=1;
			}
		}
		else 
		{
			if(text[j][len-1]==' ')
			text[j][len-1]=0;
			j++;
			len=0;
			i=i-1;
		}
	}

	for(i=0;text[i][0]!=0;i++)
		cout<<text[i]<<endl;
	return 0;
}
int main()
{
    int num;
    char word[1000][50]={' '};
    int length[1000]={0};
    cin >> num;
    int i;
    for (i=0;i<num;i++)
    {
        cin >> word[i];
        length[i] = strlen(word[i]) + 1;
    }
    int sumlength = 0;
    for (i=0;i<num;i++)
    {
        sumlength+=length[i];
        if (sumlength > 81)
        {
            cout << endl;
            cout << word[i] << " ";
            sumlength = length[i];
        }
        else
        {
            if (sumlength == 81)
            {
                cout << word[i];
                cout << endl;
                sumlength = 0;
            }
            else
            {
                cout << word[i];
                if (sumlength+length[i+1]<=81 && i!=num-1)
                {
                     cout << " ";
                }
            }
        }
    }    return 0;
}
int main()
{
	int n,i,j,count=0,count1=0;
	char *p=NULL;
	cin>>n;
	char str[1000][40];
	for(i=0;i<n;i++)cin>>str[i];//?????
	p=&str[0][0];
	for(i=0;i<n;i++){//????
		p=&str[i][0];//???????????????
		for(j=0;j<40;j++){
            if(*p!='\0'){count++;//??????????????
                p++;}
            else break;//??????
		}
		count++;//???????
		if(count-1<=80){if(count1==0){cout<<str[i];count1=1;}//?????? ?????????
		    else cout<<" "<<str[i];
		}
		if(count-1>80){//?????????????
			i--;
			cout<<endl;
			count=0;
			count1=0;
		}
	}
	cout<<endl;
}
int main()
{
    char s[300][20],c;
    int a[300],n,i,x;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
    	scanf("%s",&s[i]);
    	a[i]=1+strlen(s[i]);
    }
    x=0;
    for(i=1;i<n;i++)
    {
    	x=x+a[i];
    	if(x<=81&&x+a[i+1]<=81) printf("%s ",s[i]);
    	if(x<=81&&x+a[i+1]>81) printf("%s",s[i]);
    	if(x>81) {printf("\n");printf("%s ",s[i]);x=a[i];}
    }
    x=x+a[n];
    if(x<=81) printf("%s",s[n]);
    if(x>81) printf("\n%s",s[n]);
    return 0;
}
int main()
{
	int n, l[10000], num = -1, i;
	char str[10000][41];
	cin >> n;
	for ( i = 0; i < n; i ++ )
	{
		cin >> str[i];
		l[i] = strlen ( str[i] );
	}
	for ( int i = 0; i < n; i ++ )
	{
		if ( i == n - 1 )
		{
			cout << str[i];
			break;
		}
		if ( num <= 0 )
			num = l[i];
		num = num + l[i+1];
		if ( num >= 80 )
		{
			num = -1;
			cout << str[i] << endl;
		}
		else
			cout << str[i] << " ";
		num ++;
	}
	return 0;
}