semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n,i,p,q;
	char word[500][40],str[80]={"\0"};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",word[i]);
	}
	for(i=0;i<n;i++)
	{
		strcat(str,word[i]);
		p=strlen(str);q=p+strlen(word[i+1])+1;
		if(p<=80&&q>80)
		{
			printf("%s\n",str);strcpy(str,"\0");
		}
		else 
			if(i==n-1){printf("%s",str);}
			else strcat(str," ");
	}
}
int main(int argc, char* argv[])
{
	struct word{
		int num;
		char words[46];
	}word[1000];
	int n;
	scanf("%d",&n);
	int i,j,m;
	for(i=0;i<n;i++)
	{
		scanf("%s",&word[i].words);
		for(j=0;word[i].words[j]!='\0';j++){}
		word[i].num=j;
	}
	j=0;
	m=0;

	int max=80;
	int length=word[0].num+1;
         printf("%s",word[0].words);
	for(i=1;i<n;i++)
	{
                  
		if(word[i].num<=max-length)
		{
			printf(" %s",word[i].words);
			length=length+word[i].num+1;
		}
		else if(word[i].num>max-length)
		{
			printf("\n%s",word[i].words);
			length=word[i].num+1;
		}
	}
	return 0;
}
int main()
{
	int n,s;
	cin>>n;
	char a[n][20],*p=a[0];
	for(int i=0;i<n;i++)
		cin>>a[i];
	s=strlen(a[0]);
	cout<<a[0];
	for(int i=1;i<n;i++)
		{
		s+=strlen(a[i])+1;
		if(s<=80)
			cout<<" "<<(p+i*20);
		else
		{
			cout<<endl<<(p+i*20);
			s=strlen(a[i]);
		}
		}
}
//bug????????
int main()
{
	int i,j;
	int n;
	int l;
	int num;
	char a[50];   //????
	char s[160];   //??
	scanf("%d",&n);   //?????
	for(i=0;i<=n;i++)
	{
		//printf("%d ",i);  //debug
		scanf("%s",a);    //????????
		l=strlen(a);
		if((num+l>=80)||(n==i))   //????????
		{
			printf("%s\n",s);   //?????
			num=0;        //???????
		}
		else
			if(num>0)     //???????
			{
				*(s+num)=' ';
				num++;     //????
			}
		for(j=0;j<l;j++)
		{
			*(s+num+j)=*(a+j);
		}
		*(s+num+l)='\0';
		num+=l;    //???
		//printf("%d %s\n",i,s);  //debug
	}
	return 0;
}
int main()
{
	int n,s=0;
	char word[500][50];
	int l[500];
	char *q;
	int i,j;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>word[i];
	}
	for(i=0;i<n;i++)
	{
		l[i]=0;
		q=word[i];
		while(*q!='\0')
		{
			l[i]++;
			q++;
		}
	}
	for(i=0;i<n;i++)
	{
		if(s>0&&s+l[i]<=80)
			cout<<" "<<word[i];
		if(s+l[i]>80)
		{
			s=0;
			cout<<'\n';
		}
		if(s==0)
			cout<<word[i];
		s=s+l[i]+1;
	}
	return 0;
}
int main()
{
	char a[1000][50];//???????????????????
	int n,i;
	cin >> n;
	for(i=0;i<n;i++)
		cin >> *(a+i);
	long sum=0;//sum?????????
	for(i=0;i<n;i++)
	{
		if(sum+strlen(*(a+i))+1>80)//??????????
		{
			cout << endl << *(a+i);
			sum=strlen(*(a+i));
			continue;
		}
		sum+=strlen(*(a+i))+1;
		if(i==0)//????????????
		{
			cout << *(a+i);
			sum--;
			continue;
		}
		cout << ' '<< *(a+i);//????????
	}
	return 0;
}
int main ()
{
	int n,s;
	cin>>n;
	char a[9999][41];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	s=0;
	cout<<a[0];
	for(int i=0;a[0][i]!='\0';i++)  s++;  
	for(int i=1;i<n;i++)
	{
		for(int j=0;a[i][j]!='\0';j++)  s++;
		s++;
		if(s<=80)   cout<<" "<<a[i];
		else 
		{
			cout<<endl;
			s=0;
			cout<<a[i];
			for(int j=0;a[i][j]!='\0';j++) s++;
		}
	}
	cout<<endl;
	return 0;
}
int main()
{
	char word[300][40];
	int n, i, a[300] = {0}, flag = 0;

	cin >> n;

	for (i = 0; i < n; i++)
	{
		scanf("%s", word[i]);
	}
	
	int begin = 0, j = 0;
	int s = strlen(word[0]);
	
	for (i = 1; i < n; i++)
	{
		s += strlen(word[i]) + 1;
		if (s > 80)
		{
			for (j = begin; j < i; j++)
			{
				if (flag == 0)
				{
					cout << word[j];
					a[j] = 1;
					flag = 1;
				}
				else
				{
					cout << " " << word[j];
					a[j] = 1;
				}
			}
			cout << endl;
			flag = 0;
			begin = i;
			s = strlen(word[i]);
		}			
	}

	flag = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] == 0)
		{
			for (j = i; j < n; j++)
			{
				if (flag == 0)
				{
					cout << word[j];
					flag = 1;
				}
				else
				{
					cout << " " << word[j];
				}
			}
			break;
		}
	}

	return 0;
}
/*
 * qm2.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main(){
	int n;
	cin>>n;
	char word[n][100];
	int i;
	for(i=0;i<n;i++){
		cin>>*(word+i);
	}
	int k,l=0;
	k=0;
	for(i=0;i<n;i++){
		k+=strlen(*(word+i))+1;
		if(k+strlen(*(word+i+1))>80){
			l++;
			cout<<*(word+i)<<endl;
			k=0;
		}
		else if(l==n-1)  cout<<*(word+i);
		else{
		cout<<*(word+i)<<" ";l++;}
	}
	return 0;
}
//***************************
//*±à&Otilde;&szlig;&pound;&ordm;&sup1;ù&frac12;&iexcl;&Ocirc;&ordf; 1300012809 **
//*&Ecirc;±&frac14;&auml;&pound;&ordm;2013-12-13        **
//*&Igrave;&acirc;&Auml;&iquest;&pound;&ordm;&Icirc;&Auml;×&Ouml;&Aring;&Aring;°&aelig;          **
//***************************
int main()
{
	int a, n, i = 0, j = 0, k, jishu = 0, cd = 0;
	char w[2000][50] = {'\0'};
	cin >> n;
	cin.get();
	do
	{
		a = cin.get();
		if (a != ' ' && a != '\n')
		{
			w[i][j] = a;
			j++;
		}
		else
		{
			i++;
			j = 0;
			jishu++;
		}
	}while (jishu < n); 
    
	for (i = 0; i < n; i++)
	{
		if (cd + strlen(w[i]) <= 80)
		{
			if (cd == 0)
			{
				cout << w[i];
				cd = cd + 1 + strlen(w[i]);
			}
			else
			{
				cout << " " << w[i];
				cd = cd + 1 + strlen(w[i]);
			}
		}
		else
		{
			cout << endl;
			cout << w[i];
			cd = strlen(w[i]) + 1;
		}
	}
	return 0;
}
/*????
 *  Created on: 2012-12-10
 *      Author: ??
 */
int main() {
	int n, sum = 0;//?????????
	cin >> n;//??
	char a[40], *p = a;//??
	cin >> p;//???
	sum = strlen(p);
	cout << p;
	for (int i = 1; i < n; i++) {//?????
		cin >> p;//??
		sum += strlen(p);//??
		if (sum > 79) {//??
			cout << endl << p;
			sum = strlen(p);
		} else {//???
			cout << ' ' << p;
			sum++;
		}
	}
	return 0;
}
int main()
{
	int n;
	cin>>n;
	char word[200];
	cin.get();
	int sum;
	cin.getline(word,200,' ');
	cout<<word;
	sum=strlen(word)+1;
	for(int i=1;i<n;i++)
	{
		cin.getline(word,200,' ');
		if(sum+strlen(word)>80)
		{
			cout<<endl<<word;
			sum=0;
		}
		else
		{
			cout<<' '<<word;
		}
		sum+=strlen(word)+1;
	}
	return 0;
}
int main()
{
	int n,sum=0;
	char word[41]={0};
	char*p=word;            //???????word
	cin>>n;
	         //???????
	cin>>p;                //???p????,??
	sum+=strlen(p);        //sum????????
	cout<<p;  
	         //?????n-1???
	for(int i=1;i<n;i++)
	{
		cin>>p;
		sum+=strlen(p)+1;    //???,?????1
		if(sum>80)           //??80???
		{
			cout<<endl<<p;   //??
			sum=strlen(p);   //?????????
		}
		else cout<<' '<<p;
	}
	return 0;
}
int main ()
{int n,i,j,l=0;
char a[40];
scanf ("%d",&n);
for (i=0;i<n;i++)
{scanf("%s",a);
j=strlen (a);
if(l==0)  {a[j]='\0';printf("%s",a);l=l+j+1;}
else
if (l+j<=80) {a[j]='\0';printf(" %s",a);l=l+j+1;}
else {printf("\n%s",a);l=j+1;}
}
return 0;
}
int WordLen(char *a)
{
    int i;
    for (i=0;a[i];i++);
    return i;
}
main()
{
    int i,num,space=80;
    char word[41];
    cin>>num;
    for (i=0;i<num;i++)
    {
        cin>>word;
        if (space==80)
        {
            cout<<word;
            space-=WordLen(word);
        }
        else if (space>=WordLen(word)+1)
        {
            cout<<' '<<word;
            space-=WordLen(word)+1;
        }
        else 
        {
            cout<<endl<<word;
            space=80-WordLen(word);
        }
    }
    
}
//********************************
//*????????  **
//*????? 1300012845 **
//*???2013.12.11  **
//********************************
char str[1000][50] = {0};


int main ()
{
	int label[1000] = {0};
	int i, j, n;
	int l= -1;
	int k = 0;
	char str[1000][50] = {0};
	char (*p)[50] = str;//p???????
	cin >> n;
	for ( i = 1; i <= n; i++)
		cin >> str[i];
	p++;
	while ( k <= n )//??????????
	{
		while ( l <= 80 )//?????80???????
		{
			k++;
		    l+=1+strlen(str[k]);//????
		}
	k = k - 1, l = -1;//k?????
	label[k] = 1;//???????????
	}
	for ( i = 1; i <= n - 1; i++ )//??
	{
		if ( label[i] != 1)
			cout << *(p++) <<" ";
		else
			cout << *(p++) << endl;
	}
	cout << str[i] << endl;
	return 0;
}
//struct
main()
{
    int n;
    scanf("%d",&n);
    char a[400][40];
    for(int i=0;i<n;i++)
    {
        scanf("%s", a[i]);
    }
    int l=80,o,s,d;
    for(int i=0;i<n-1;i++)
    {
        s=strlen(a[i]);
        d=strlen(a[i+1]);
        o=l-s-d-1;
        if(o<0)
        {
            if((l-s)>=0)
            printf("%s\n",a[i]);
            l=80;
        }
        else
        {
            printf("%s ",a[i]);
            l=l-1-s;
        }
    }
        s=strlen(a[n-1]);
        l=l-s;
        if(l<0)
        {
            printf("\n");
            printf("%s",a[n-1]);
        }
        else
        printf("%s",a[n-1]);
}
/*
 * 111202_03_makeup.cpp
 *
 *  Created on: 2011-12-2
 *      Author: Alfalfa
 */
int main(){
	int n1,max=0,i;
	cin>>n1;
	const int n=n1;
	char word[n+1][41];
	int len[n+1];
	for(i=1;i<=n;i++)
		{
		scanf("%s", word[i]);
		len[i+1]=0;
		len[i]=strlen(word[i]); //??len????????
		}
	for(i=1;i<=n;i++){
		max=max+len[i];
		if(max<=80&&max+len[i+1]+1<=80&&i!=n) { cout<<word[i]<<" "; max++;} //??????????????????????80
		else if(max<=80&&max+len[i+1]+1>80&&i!=n) {
			cout<<word[i]<<endl; max=0;
		} //?????????
		else cout<<word[i]; //???????
	}

}
int main()
{
	char a[1000][40];
	int i, n, len[1000], max;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		len[i] = strlen(a[i]);
	}
	max = 81;
	for (i = 0; i < n; i++)
	{
		max += len[i] + 1;
		if (max > 80)
		{
			cout << endl;
			max = len[i];
			cout << a[i];
		}
		else
			cout << " " << a[i];
	}
	cout << endl;
	return 0;
}
int main()
{
	char a[1000][41];
	int b[1000],num=0;
	char *(p);
	int n,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=strlen(a[i]);
	}
	p=&a[0][0];
	for(i=0;i<n;i++)
	{
		num=num+b[i];
		if(num==b[i])
			cout<<a[i];
		if(num<=80&&num!=b[i])
			cout<<" "<<a[i];
		if(num>80)
		{
			cout<<endl;cout<<a[i];
			num=b[i];
		}
		num=num+1;
	}
	return 0;
}
int main(){
	int i,j,k,n,m,sum=0;
	char a[1000][40]={0},*p;
	scanf("%d",&n);
	for(i=0;i<=n;i++){
		scanf("%s",a[i]);
	}
         sum+=strlen(a[0]);
         printf("%s",a[0]);
	for(p=&a[1][0];p<&a[0][0]+n*40;p+=40){
		if(strlen(p)+sum+1>80){
		   printf("\n%s",p);
                     sum =strlen(p);
                     continue;
		}
		printf(" %s",p);
                  sum+=strlen(p);
                  sum++;
	}
         printf("%s",p+40);
}
//*********************************
// ???2.cpp
// ??????? 
// ?????? 1300012894
// ???2013.12.11
//*********************************
int main()
{
	int n; // ???????????? 
	cin >> n; // ??????????????? 
	char a[10000]; // ???? 
	cin.getline(a, 10000); // ??????????? 
	cin.getline(a, 10000); // ??????? 
	char *p = NULL, *q = NULL; // ?????? 
	p = a; // ????? 
	q = p + 80;
	while (*q != 0)
	{
		while (*q != ' ') // ??????????????? 
		{
			q--;
		}
		*q = 0; // ????? 
		cout << p << endl; // ?? 
		p =  q + 1; // ??????? 
		q = p + 80;
	} 
	cout << p << endl; // ????????? 
	return 0;
}
int main()
{
	int n,i,len=0,m;
	char w[41];
	scanf("%d",&n);
	scanf("%s",w);
	m=strlen(w);
	len=m;
         printf("%s",w);
	for(i=1;i<n;i++){
		scanf("%s",w);
		m=strlen(w);
		len+=m+1;
		if(len>80){
			printf("\n%s",w);
			len=m;
		}
		else{
			printf(" %s",w);
		}
		}
	return 0;
}
int main()
{
    int number;
    cin >> number;
    char article[40]; 
    int i = 0,k = 0;
    cin >> article;
    i = strlen(article);
    cout << article;
    while(k < number-1)
    {
         cin >> article;
         char *p = article;
         i = i + strlen(article) + 1; 
         if(i <= 80)
         {
              //cout << " " << article;
              cout << " ";
              for(;*p != '\0'; p++) cout << *p;
         }
         else
         {
              cout << endl << article;
              i = strlen(article);
         }
         ++k;
    }
    return 0;
}
int main()
{
	char word[1000][20];
	int n,i,j,sum=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>word[i];
	char(*p)[20]=word;
	for(i=0;i<n;i++)
	{
		sum=sum+strlen(*(p+i));
		if(sum<=80)
		{
			cout<<*(p+i);
			if((sum+strlen(*(p+i+1))+1)<=80 && i!=n-1)
			{	
				sum++;
				cout<<' ';
			}
			else
			{
				cout<<endl;
				sum=0;
			}

		}
		else
		{
			cout<<endl;
			cout<<*(p+i);
			sum=strlen(*(p+i));
		}
	
	}
	return 0;
}
char in[1000][50]={0};
char out[1000][4000]={0};

int main ()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;i++)
		cin>>*(in+i);
	int row = 0;
	for (int i=1;i<n;i++){
		if (strlen(*(out+row))+strlen(*(in+i)) <= 80){
			strcat(*(out+row),*(in+i));
			if (strlen(*(out+row))+strlen(*(in+i+1))+1 <= 80)
				strcat(*(out+row)," ");
			else row += 1;
		}
	}
	strcat(*(out+row),*(in+n));

	for (int i=0;i<=row;i++)
		cout<<*(out+i)<<endl;

	return 0;
}
int main()
{
	int n,i,count,j;
	char word[50];
	cin>>n;
	count=0;
	for(i=0;i<n;i++)
	{
		cin>>word;
		for(j=0;word[j];j++);
		if(count+j<=80)
		{
			if(i==0)
				cout<<word;
			else
				cout<<" "<<word;
			count+=j+1;
		}
		else
		{
			cout<<endl;
			cout<<word;
			count=j+1;
		}
	}
	
	return 0;
}
int main()
{
	char a[500][41];
	int n, i, len, b[500];
	int *q = b;
	char (*p)[41] = a;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> *(p + i);
		*(q + i) = strlen(*(p + i));
	}
	cout << *p;
	len = *q + 1;
	for(i = 1; i < n; i++)
	{
		if(len + *(q + i) <= 80)
		{
			cout << ' ' << *(p + i);
			len += 1 + *(q + i);
		}
		else
		{
			cout << endl << *(p + i);
			len = *(q + i) + 1;
		}
	}
	return 0;
}
int main ()
{
	int n;
	scanf("%d",&n);
	int i;
	struct point
	{
		char a[40];
	}words[1000];
	for(i=0;i<n;i++)
	{   
		scanf("%s",words[i].a);
		int b;
		b=strlen(words[i].a);
		if(i<n-1)
		{
			words[i].a[b]=' ';
		    words[i].a[b+1]='\0';
		}	
	}
	int num=0;
	for(i=0;i<n;i++)
	{
		num+=strlen(words[i].a);
        if(num+strlen(words[i+1].a)>81)
		{
				int k;
				k=strlen(words[i].a);
				words[i].a[k-1]='\n';
				words[i].a[k]='\0';
				num=0;
		}
	}
	for(i=0;i<n;i++)
	{
		printf("%s",words[i].a);
	}
	return 0;
}
int main()
{
	int n, i;
	char word[41], *p = NULL;
	int count = 0, flag_first_word = 1;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> word;
		p = word;
		if (flag_first_word == 1)
		{
			cout << p;
			count = strlen(p);
			flag_first_word = 0;
		}
		else
		{
			if (count + strlen(p) + 1 <= 80)
			{
			
				cout << " " << p;
				count += strlen(p) + 1;
			}
			else
			{
				cout << endl << p;
				count = strlen(p);
			}
		}
	}
	return 0;
}
int main()
{
	int n,i,k,x=0,flag=0,count=0;
	int a[500]={0};
	char word[500][50];
	cin >> n;
	for (i=0;i<n;i++)
	{
		cin >> word[i];
		a[i]=strlen(word[i])+1;
	}
	i=0;
	while (1)
	{
		while (count<=81)
		{
			count+=a[i];
			i++;
			if (i==n)
			{
				flag=1;
				break;
			}
		}		
		if (flag==1)
		{
			cout << word[x];
			for (k=x+1;k<n;k++)
			{
				cout << " " << word[k];
			}
			break;
		}
		i--;
		count=0;
		cout << word[x];
		for (k=x+1;k<i;k++)
		{
			cout << " " << word[k];
		}
		cout << endl;
		x=i;
	}
	return 0;
}
int main()
{
	int n,i;
	cin>>n;
	char a[1000][40];
	int b[1000];
	int sum[1000];
	for ( i = 0 ; i < n ; i ++ )
	{
		cin>>a[i];
		b[i] = strlen(a[i]);
		sum[i]=0;
	
	}
	for ( i = 1 ; i < n ; i ++ )
	{
		sum[i] = sum[i-1] + b[i-1] + 1 ;
		sum[i+1] = sum[i] + b[i] + 1;
		if ( sum[i] < 81 && sum[i+1] <= 81 )
			cout<<a[i-1]<<" ";
		else if ( sum[i] <= 81 && sum[i+1] > 81 )
		{	
			cout<<a[i-1]<<endl;
			sum[i] = 0 ;
		}
		
	}
	cout<<a[n-1]<<endl;
}
int main()
{
	int n, i, k, l[1000], len = 0;
	char word[1000][45];
	char *p[1000];
	cin >> n;
	for(i = 1; i <= n; i++)
	{
		cin >>word[i];
		l[i] = strlen(word[i]);
		p[i] = word[i];
	}
	cout << word[1];
	len += l[1] + 1;
	for(i = 2; i <= n; i++)
	{
		len += l[i];
		if(len <= 80)
		{
			cout <<' ';
			for(k = 0; k < l[i]; k++)
				cout << *(p[i]+k);
			len++;
		}
		else
		{
			cout <<endl;
			for(k = 0; k < l[i]; k++)
				cout << *(p[i]+k);
			len = l[i] + 1;
		}
		
	}


	return 0;
}
int main()
{   int n;
    cin>>n;
    char a[1000][50]={0};
    int i;
    int j;
    char b;
    cin.get(b);
    int num[1000]={0};
    for(i=1;i<n;i++)
       {     j=1;
             while(1)
           { 
             cin.get(b);
             if(b==' ')   
                {    *(num+i)=j-1;
                    break;
                }
             else
               {   *(*(a+i)+j)=b;
                   j=j+1;
               }
           }
       }
    j=1;
     while(1)
           { 
             cin.get(b);
             if(b=='\n')   
                {    *(num+i)=j-1;
                    break;
                }
             else
               {   *(*(a+i)+j)=b;
                   j=j+1;
               }
           }
    int sum=0;
    
    for(i=1;i<=n;i++)
      {    if(sum==0)
             {for(j=1;j<=*(num+i);j++)
                {  cout<<*(*(a+i)+j);
                   
                }
              sum=sum+*(num+i);
             }
           else if(sum+*(num+i)+1<=80)
             { cout<<' ';
               for(j=1;j<=*(num+i);j++)
                {  cout<<*(*(a+i)+j);
                    
                }
                sum=sum+*(num+i)+1;
             } 
           else if(sum+*(num+i)+1>80)
              {  cout<<endl;
                 i=i-1;
                 sum=0;
              }
      }
    return 0;
}
int main()
{
	int n;
	cin>>n;
	int i,j,b[10000];
	char word[80];
	int rank=0,temp;
	while(n--)
	{
		if (rank==0)
		{
			scanf("%s", word);
			rank=strlen(word);
			cout<<word;
			continue;
		}
		scanf("%s", word);
		temp=strlen(word);
		if (rank+temp+1<=80)
		{
			cout<<' '<<word;
			rank+=temp+1;
		}
		else
		{
			cout<<endl;
			cout<<word;
			rank=temp;
		}
	}

		
	return 0;
}
int main()
{
	int n,i,m,j,length,sum=0;
	cin>>n;
	char str[41];
	cin.get();
	cin.getline(str,41,' ');
	sum=strlen(str)+1;
	cout<<str;
	for(i=1;i<n;i++)
	{
		cin.getline(str,41,' ');
		length=strlen(str);
		sum=sum+length+1;
		if(sum<=81)
		{cout<<' '<<str;
		continue;}
		else 
		{
			cout<<endl;
			cout<<str;
			sum=strlen(str)+1;
		}
	}
	return 0;
}
char dat[1000][41];
int main()
{
    int l1,cou;
    int n;

    scanf("%d",&n);
    for (l1=1;l1<=n;l1++)
        scanf("%s",dat[l1]);

    printf("%s",dat[1]);
    cou=strlen(dat[1]);
    for (l1=2;l1<=n;l1++)
        if (cou+strlen(dat[l1])+1>80)
            {
                printf("\n%s",dat[l1]);
                cou=strlen(dat[l1]);
            }
        else
            {
                printf(" %s",dat[l1]);
                cou+=strlen(dat[l1])+1;
            }

    return 0;
}
void main()
{
	int i,n,mun;  //mun?????????
	int b[500]; //b??????????
	char word[500][50];
	char *pi;
	pi=word[0];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",word[i]);
		b[i]=strlen(word[i]);
	}
	printf("%s",pi);
	mun=b[0];
	for(i=1;i<n;i++)
	{
		pi=word[i];
		mun=mun+b[i]+1;
		if(mun<=80)
		{
			printf(" %s",pi);
		}
		else
		{
			printf("\n%s",pi);
			mun=b[i];
		}
	}
}
main()
{
      int n,c=0,f=1;
      scanf("%d",&n);
      char  p[1000][41];  
      for(int i=0;i<n;i++)
      { 
              scanf("%s",p[i]); 
      }
      for(int j=0;j<n;j++)
      { 
                   c=c+strlen(p[j]);
                   if(c<=80)
                   {
                            if(f==1)
                            {
                              printf("%s",p[j]); 
                              f=0;
                              } 
                              else
                              printf(" %s",p[j]);
                          c++; 
                   }
                   else
                   {
                       printf("\n");
                       f=1;
                       c=0;
                       j--;
                   } 
      }
      getchar();
      getchar();
}
int main(){
	int n,i,j,len[10000],tempzifushu=0,dancishu=-1;
	cin>>n;
	char a[1000][1000];
	for(i=0;i<=n-1;i++)
	{
		len[i]=0;
		cin>>a[i];
	}
	len[0]=strlen(a[0])+1;
    for(i=0;i<=n-2;i++)
    	len[i+1]=strlen(a[i+1])+1+len[i];
    for(i=0;i<=n-2;i++)
    {
    	if((len[i]<=81+tempzifushu)&&(len[i+1]>=82+tempzifushu))
    	{
    		tempzifushu=len[i];
    		for(j=dancishu+1;j<=i-1;j++)
    			cout<<a[j]<<" ";
    		cout<<a[i];
    		cout<<endl;
    		dancishu=i;
    	}
    }
    for(i=dancishu+1;i<=n-2;i++)
    	cout<<a[i]<<" ";
    cout<<a[n-1];
    return 0;
}
int main()
{
	int n;
	cin>>n;
	int length = 0;
	for(int i =0;i<n;i++)
	{
		char str[40];
		cin>>str;
		if(length == 0)
		{
			cout << str;
		length +=strlen(str);
		}
		else
		{
			length +=strlen(str);
			length++;
		if(length <= 80)
		cout<<' '<<str;
		else
		{
			cout <<endl;
			cout <<str;
			length = strlen(str);
		}
		}
	}
	return 0;
}
int main(){
int n,i,len,end=0;
char c[max+1];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",c);
len=strlen(c);
if(i==0){
printf("%s",c);
end+=len;
}
else{
	if(len+end+1>line){
printf("\n");
printf("%s",c);
end=len;
	}
else{
	printf(" ");
printf("%s",c); 
end+=len+1;
}
}
}
return 0;
}
int main()
{
	int n,total=0;
	int i=0,m=0;
	int len;
	char word[40];
	cin>>n;
	scanf("%s", word);
	len=strlen(word);
	cout<<word;
	i+=len;
	total+=1;
	while(1)
	{
		scanf("%s", word);
		len=strlen(word);
		if(total==n-1)
		{
			cout<<" "<<word;
			break;
		}
		else if(total<n-1)
		{
			if(i+len+1<=80)
			{
				cout<<" "<<word;
				i+=len+1;
				total+=1;
			}
			else
			{
				cout<<endl;
				cout<<word;
				i=len;
				total+=1;
			}
		}
	}
	return 0;
}
/*
 * paiban.cpp
 *?????
 *  Created on: 2012-12-14
 *      Author: ??
 */


int main() {
	char word[100],*p=word;//??????
	int chang = 0, n, len;//????????n,????
	cin >> n;//??n
	cin >> p;
	cout << p;//??????????
	chang = strlen(p);//???????????
	n--;//????
	while (n > 0) {
		cin >> p;
		len = strlen(p);//???????
		chang += len + 1;//???????
		if (chang > 80) {
			cout << '\n' << p;
			chang = len;//??????????????????
		} else
			cout << ' ' << p;//????????????
		n--;//?????
	}
	return 0;
}
int main()
{
	int n, i, t = 0, s1 = 0, d, s2 = 0, d2 = 80;
	char a[500][41], (*p)[41];
	cin >> n;
	for(i = 0; i <= n - 1; i ++)
		cin >> a[i];
	while(t < n)
	{
		d = strlen(a[t]);
		t ++;
		if(d > d2)
		{
			s2 = t - 2;
			cout << a[s1];
			for(p = a + s1 + 1; p <= a + s2; p ++)
				cout << " " << *p;
			cout << endl;
			s1 = t - 1;
			d2 = 79 - d;
		}
		else
		{
			d2 = d2 - d - 1;
		}
	}
	if(t - s1 >= 1)
	{
		cout << a[s1];
		for(p = a + s1 + 1; p <= a + n - 1; p ++)
			cout << " " << *p;
		cout << endl;
	}
	return 0;
}
int main()
{
	char a[10000];
	int len;
	char *p;
	int i, n,j;
	int lenq=0, lenh=0;
	cin>>n;
	cin.get();
	cin.getline(a,10000);
	p=a;
	i=0;
	while(*(p+i)!=' ')
	{

		i++;
	}
	lenq=i;
	len=lenq;
	while(n--)
	{
		i=0;
		p+=lenq;
		p++;
		while(*(p+i)!=' '&&*(p+i)!='\0')
		{
			i++;
		}
		lenh=i;
		len+=lenh;
		len++;
		p-=lenq;
		p--;
		if(len<=80)
			{
				for(j=0;j<=lenq-1;j++)
					cout<<*(p+j);
				if(n)
					cout<<" ";
			}
		else
			{
				for(j=0;j<=lenq-1;j++)
					cout<<*(p+j);
				cout<<endl;
				len=lenh;
			}
		p+=lenq;
		p++;
		lenq=lenh;
					
	}



	return 0;
}
// ????
//????wayne
//?????12.30

 
char a[41];

int main()
{
	int cnt=0,n,i,length;
	cin>>n;
	cin>>a;
	cout<<a;
	cnt=strlen(a);
	for(i=1;i<n;i++)
	{
		cin>>a;
		length=strlen(a);
		cnt++;
		cnt+=length;
		if((cnt)<=80)
			cout<<" "<<a;
		else
		{
			cout<<endl;
			cout<<a;
			cnt=strlen(a);
		}
	}
	return 0;
}
int main() {
	int n;
	cin >> n;
	int s = 0;
	char p[1000][100] = { 0 };
	for (int i = 0; i < n; i++) {
		int j = 0;
		cin >> *(p + i);
		while (*(*(p + i) + j) != 0) {//?????????
			s++;
			j++;
		}
		s++;
		if (i < n - 1 && i != 0) {//??
			if (s <82)
				cout << *(p + i - 1) << ' ';
			else {

				cout << *(p + i - 1) << endl;
				s = j+1;
			}
		} else if (i == n - 1) {
			if (s < 82)
				cout << *(p + i - 1) << ' ' << *(p + i);
			else
				cout << *(p + i - 1) << endl << *(p + i);
		}

	}
	return 0;
}
int main()
{
 char **words;
 int n, i, j;
 scanf("%d",&n);
 words=(char **)malloc(sizeof(char*)*n);
 for (i=0;i<n;i++)
 {
  words[i]=(char *)malloc(sizeof(char)*40);
  scanf("%s",words[i]);
 }
 printf("%s",words[0]);
 j=strlen(words[0]);
 for (i=1;i<n;i++)
 {
  j++;
  j+=strlen(words[i]);
  if (j<=80)
   printf(" %s",words[i]);
  else
  {
   printf("\n%s",words[i]);
   j=strlen(words[i]);
  }
 }
 for (i=0;i<n;i++)
  free(words[i]);
 free(words);
 return 0;
}
int main(){
	int WN,i;
	cin>>WN;
	int len[WN];
	char wo[WN][40];
	for(i=0;i<WN;i++){
		cin>>wo[i];
		len[i]=strlen(wo[i]);
	}
	int sum=len[0]+len[1];
	cout<<wo[0];
	for(i=1;i<WN;i++){
		if(sum<80){
			cout<<" "<<wo[i];
			sum=sum+len[i+1]+1;
		}
		else{
			cout<<'\n'<<wo[i];
			sum=len[i]+len[i+1];
		}
	}
	return 0;
}