semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
//*******************************
//*????                    **
//*????? 1300012848       **
//*???2013.12.11            **
//*******************************
int mystrlen(char *p)
{
	int i = 0;
	while(*(p+i) != 0)
	{
		i++;
	}
	return i;
}
int main()
{
	char a[999][41];
	memset(a,0,sizeof(a));
	int n, i, j, cnt = 0, nlen;
	char *p, *q;
	cin >> n;
	for(i = 1; i <= n; i++)
		cin >> a[i];
	p = *a;//??a[0]
	cout << *(a+1);//?????
	nlen = mystrlen(*(a+1));
	cnt = nlen;
	for(j = 2; j <= n; j++)
	{
		nlen = mystrlen(*(a+j));
		if(cnt + nlen + 1 <= 80)//????????
		{
			cout << " " << *(a+j);
			cnt += nlen + 1;
		}
		else//????????
		{
			cnt = nlen;
			cout << endl;
			cout << *(a+j);
		}
	}
	return 0;
}
//??????????????????????
int main()
{
	int number=0;
	char string1[50],string2[50];
	int length1=0,length2=0,length3=0;
	int k=0,m=0,n=0;
	cin>>number;
	gets( string1 );                                                  //????????????

	cin>>string1;                                                     //string1?????
	k=1;                                                              //k?????????
	cout<<string1;
	length1=strlen(string1);
	while ( k<number )
	{
		cin>>string2;
		length2=strlen(string2);
		length1=length1+length2+1;

		if ( length1<=80 )                                            //??????????<=80?????????????
			cout<<" "<<string2;
		else if ( length1>80 )                                        //??????????????80???????????
		{
			cout<<endl;                                               //???
			cout<<string2;
			strcpy(string1,string2);                                  //???????????
			length1=strlen(string1);
		}
		k++;
	}
	return 0;
}
//*****************************
//*???2011?1?9?         *
//*??????               *
//*?????4                *   
//*****************************
int main()//???
{//?????
	int n=0;
	char a[10000];
	cin>>n;
	cin.get();
	cin.get(a,10000,'\n');
	char *p=a;
	int lenth[100]={0};
	int m=0;
	int flag=0;
	while(*p!='\0'&&flag==0)
	{
		int i=0;
		for(i=0;i<80;i++)
		{
			p++;
			if(*p=='\0')
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
		{
			if(*p!=' ')
				for(;*p!=' ';p--);
			*p='\0';
		}
		p=a;
		for(int j=0;j<m;j++)
			for(i=0;i<lenth[j]+1;i++)
				p++;
		for(;*p!='\0';p++)
		{
			cout<<*p;
			lenth[m]++;
		}
			cout<<endl;
		m++;
		p++;
	}
	return 0;
}//?????
int main ()
{
	int n,i,line = 0,count = 0;
	char ch[45], *p;
	cin >> n;
	for (i = 1; i<= n;i++)
	{
		cin >> ch;
		p = ch;
		while (*p !='\0' )
		{
			p++;
			count++;
		}
		if (line +  count <= 80 && line == 0)
		{
			line = count;
			cout << ch;
			count = 0;
			continue;
		}
		if(line + count  + 1<= 80)
			{
				cout << ' ' << ch;
				line = count +1  + line;
				count = 0;
				continue;
			}
		if (line + count + 1> 80)
		{
			cout << endl;
			cout << ch;
			line =  count;
			count = 0;
		}
		
	}
	return 0;
}
int main()
{
	int n,i,j,k,len[8000],sum=0,a;
	char str[8000][40];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",&str[i]);
		len[i]=strlen(str[i]);
	}
	for(j=0;j<(n-1);j++)
	{
		sum=sum+len[j];
		if(sum<=80)
			printf("%s",str[j]);
	

		a=sum+len[j+1];
		if(a<80)
		{
			printf(" ");
			sum++;
		}
		if(a>=80)
		{
			printf("\n");
			sum=0;
		}
	}
    if(a<=80)
		{
			printf("%s",str[n-1]);
		}
		if(a>80)
		{
			printf("\n");
			printf("%s",str[n-1]);
		}


	return 0;
}
int main()
{
    int n;
    char c[450][50];
    int sum[450]={0},b[450];
 
    
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        b[i]=strlen(c[i]);
    }
    sum[0]=b[0]+1;
    sum[1]=sum[0]+b[1]+1;
    cout<<c[0]<<" ";
    for(int i=1;i<n;i++)
    {
        sum[i]=sum[i-1]+b[i]+1;
        sum[i+1]=sum[i]+b[i+1]+1;
       
        if(sum[i]> 81 &&sum[i-1]<=81)
        {
            cout<<endl;
            cout<<c[i]<<" ";
            sum[i]=b[i]+1;
        }
        else if(sum[i]<=81&&sum[i+1]>81) cout<<c[i];
        else if(i==n-1) cout<<c[i]<<endl;  
        else
        {
            cout<<c[i]<<" ";
        }  
    }

     return 0;       
                    

}
void main ()
{
	char word[10000][40];
	int i,n,q=0;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s",word[i]);
	}
	for (i=0;i<n;i++)
	{
		if (q!=0)
		{
			q=q+1+strlen(word[i]);
		}
		if (q==0)
		{
			q=q+strlen(word[i]);
		}
		
		if (q-strlen(word[i])==0)
			printf("%s",word[i]);
	    if (q-strlen(word[i])!=0&&q<=80)
			printf(" %s",word[i]);
		if (q>80)
		{
			printf("\n");
			printf("%s",word[i]);
			q=strlen(word[i]);
		}
	}
}
int main()
{
	char t[85],in[45];
	char *p = t, *q = in;
	int n;
	cin>>n;
	int i,sum = 0,len,j,k = 0;

	for(i = 0; i < n; i ++)
	{
		cin>>in;

		q = in;
		k = 0;

		len = strlen(in);

		while(*q != '\0')
		{
			*p++ = *q++;
			k++;
			sum ++;

			if(sum > 80)
			{
				p = p - k;
				sum -= k;

				if(*(p-1) == ' ')
				{
					p --;
					sum --;
				}

				q = in;
				k = 0;

				*p = '\0';
				cout<<t<<endl;

				p = t;
				sum = 0;

				while(*q != 0)
				{
					*p++ = *q++;
					k++;
					sum ++;
				}
			}
		}
		if(sum < 80)
		{
			*p = ' ';
			p++;
			sum ++;
		}
	}
	p--;
		*p = '\0';
		cout<<t;
	return 0;
}
int main()
{ char *string,a[100]={'\0'};
  int n=0,i=0,sum=0,t=1; 
  scanf("%d",&n);
  string=a;
  scanf("%s",string);
  sum=sum+strlen(string);
  for(i=1;i<=n;i++)
  {  printf("%s",string);
	 if(i<n) 
	 {scanf("%s",string);}
	 sum=sum+strlen(string)+1;
	 
	  if(sum>80) 
	  {sum=strlen(string);printf("\n");t=0;}
      if(i<n&&t!=0)
	  { printf(" ");
	  	  }
	 t=1;
  
  }

 return(0);
}
int main()
{
	int n=0,i=0,len=0,count=0;
	char word[1000][41];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>word[i];
	}
	for(;count<n;)
	{
		len+=strlen(word[count]);
		cout<<word[count++];
		while(len+strlen(word[count])+1<=80)
		{
			if(count>=n)
				break;
			else
			{
				len+=strlen(word[count])+1;
				cout<<" "<<word[count++];
			}
		}
		len=0;
		cout<<endl;
	}
	cout<<endl;
	return 0;
}
// ????.cpp : Defines the entry point for the console application.
//




int main()
{
	int n, lenth = 0, i, j, flag = 0;
	char a[40], *p = a;
	cin >> n;
	for(i = 0; i < n; i++)
	{
			cin >> a;
			lenth += strlen(a) + 1;
			if((lenth - 1) <= 80)
			{
				if(flag == 1)
					cout << ' ';
				cout << a;
				flag = 1;
			}
			if(lenth - 1 > 80)
			{
				cout << endl;
				lenth = strlen(a) + 1;
				cout << a;
			}
			for(j = 0; j < 40; j++)
				*(p + j) = NULL;          //???????
	}
	return 0;
}
int main()
{
	int n,i,len1=0,len2;		//len1?????????????len2????????????
	char words[1000][41];		//????
	char (*p)[41]=NULL;			//?????????
	p=words;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>*(p+i);
	len2=strlen(*p)+1;
	for(i=0;i<n;i++)
	{
		len1+=strlen(*(p+i));	//?????????
		len2+=strlen(*(p+i+1));	//???????????
		if(len2<=80 && i!=n-1)	//????????80?????
		{
			cout<<*(p+i)<<" ";	//???????
			len1++;
			len2++;				//??????
		}
		else 
		{
			if(len1<=80 )		//????????80
			{
				cout<<*(p+i)<<endl;	//???????
				len1=0;
				len2=strlen(*(p+i+1))+1;
			}
			else				//?????????80
			{
				cout<<endl;		//??
				len1=0;
				len2=strlen(*(p+i))+1;
			}
		}
	}
	return 0;
}
int main(){
	char c[41];
	char *p=c;
	int n;
	cin>>n;
	int i;
	int j;//????
	int num=0;//?????
	for(i=1;i<=n;i++)
	{
		cin>>c;
		//for(;*p!=0;p++);j=p-c;
		for(j=0;*p!=0;p++,j++);
		if(num==0)//?????????
		{
			cout<<c;
			num=j;
		}
		else{//????????????????????
		if((num+j+1)>80)//+1??????????
		{
			cout<<endl<<c;
			num=j;
		}
		/*
		else if((num+j+1)==80)
		{
			cout<<' '<<c<<endl;
			num=0;
		}*/
		else
		{
			cout<<' '<<c;
			num+=(j+1);
		}
		}
		p=c;
	}
}
int main()
{
 int n,i,l[1000],count=0;
 char s[1000][40];
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
   scanf("%s",s[i]);
   l[i]=strlen(s[i]);
 }
 for(i=-1;i<n;i)
 {
   i++;
   printf("%s",s[i]);
   count=l[i]+l[i+1]+1;
   while(count<=80&&i<n-1)
   {
     i++;
     printf(" ");
     printf("%s",s[i]);
     count+=1+l[i+1];
   }
   printf("\n");
}

  return 0;
}
void main(){
  int i, j, n, b, num=0;
  char string[10000][40];
  char c;
  scanf("%d", &n);
  for(i=0;i<n;i++)
	  scanf("%s",string[i]);
  
  for(i=0;i<n;i++){
	  for(j=0,b=0;(c=string[i][j])!='\0';j++)
		  b++;
	  num=num+b+1;
	 
      if(num<81||num==81){
		  if(i==0)printf("%s", string[0]);
			  else 
	    printf(" %s", string[i]);
	  }
	  else if(num>81){
		printf("\n%s", string[i]);
		num=b+1;
	  }
  }
}
int main(){
	char word[42];
	int chars_left,word_length,word_num;

	scanf("%d",&word_num);
	scanf("%s",&word);
	printf("%s",word);
	word_num--;
	word_length=strlen(word);
	chars_left=80-word_length;
	while(word_num!=0){
		scanf("%s",&word);
		word_length=strlen(word);
		if(chars_left<word_length+1){
			printf("\n%s",word);
			chars_left=80-word_length;
		}
		else{
			printf(" %s",word);
			chars_left=chars_left-word_length-1;
		}
        word_num--;
	}
	return 0;
}
/*
  Name: ????????????
  Copyright: 
  Author: 
  Date: 07/12/12 12:44
  Description:??????????????????????????????????????????????????? 
?????80??????????????????????????????????????????? 
????????????  
*/
//?????? 
int main()
{
	char a[1000][45],*p=NULL; 
	int n,i,count=0;
	cin>>n;
	for(i=0;i<n;i++) 
	{
        //??
		cin>>a[i];
		//cout<<*p<<endl; 
	} 
	//for(i=0;i<n;i++)
     //  cout<<a[i]<<endl; 
    count=strlen(a[0]);
	   cout<<a[0];
	for(i=1;i<n;i++)
	{
		count=count+strlen(a[i])+1;
		if(count<=80)
		{
			cout<<" "<<a[i];
		}
		else
		{
			count=strlen(a[i]);
			cout<<endl;
			cout<<a[i];
		}
	}



	return 0;
}
main()
{
 int i,n,sum=0;
 char letter[1000][41]={""};
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  scanf("%s",(letter+i));
 }
 for(i=0;i<n;i++)
 {
  if(i!=n-1)
  {if(sum==79||((sum+strlen(letter[i]))>80))
  {printf("\n");sum=0;i--;}
  else
  {
   if((sum+strlen(letter[i])+1+strlen(letter[i+1]))>80)
   {sum+=strlen(letter[i]);
   printf("%s",letter[i]);sum++;}
   else{
       sum+=strlen(letter[i]);
   printf("%s ",letter[i]);sum++;
       }
  }}
  else
  printf("%s",letter[i]);
 }
}
int main()
{
char x[500][50]={0};
    int i,j,m,k,total,temp,y[500];
    scanf("%d",&k);
    temp=k;
    for(i=0;i<=k-1;i++)
    scanf("%s",x[i]);
    for(i=0;i<=k-1;i++)
    y[i]=strlen(x[i]);
    for(i=0;;)
    {
                 printf("%s",x[i]);
                 total=y[i];
                 temp--;
                 for(j=i+1;;j++)
                 {
                                total=total+y[j]+1;
                                if(total>80) break;
                                temp--;
                                if(temp==0) break;
                 }
                 if(temp!=0)
                 {
                 for(m=i+1;m<=j-1;m++)
                 printf(" %s",x[m]);
                 printf("\n");
                 i=j;
                 }
                 else 
                 {
                      for(m=i+1;m<=k-1;m++)
                      printf(" %s",x[m]);
                      printf("\n");
                      break;
                 }
    }
return 0;
}
int main ()
{
	int n,i,k=0,sum[2000]={0};
	char word[2000][45];
	cin>>n;
	for(i=0;i<n;i++)
		cin>>word[i];
	for(i=0;i<n-1;i++)
	{ 
		sum[k]=sum[k]+strlen(word[i])+1;  //????????
		if(sum[k]-1<=80 && sum[k]+strlen(word[i+1])<=80)   //???????????????
		{
			if(i!=n-2)
				cout<<word[i]<<' ';
			else
				cout<<word[i]<<' '<<word[i+1];
		}		
		else if(sum[k]-1<=80 && sum[k]+strlen(word[i+1])>80)
		{
			cout<<word[i]<<endl;
			k++;
		}
	}
	return 0;
}
int main(int argc, char* argv[])

{
	int n,i,len=0;
	char word[20];
    scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	   scanf("%s", word);
	   len=len+1+strlen(word);
	   if(i==0)
	   {
		   printf("%s",word);
	   
	   }
	   else 
	   {
		   if(len<=81)
		   printf(" %s",word);
	        else
			{
		   printf("\n");
		   printf("%s",word);
		   len=strlen(word)+1;
			}
	  }
	}
	return 0;
}
int main()
{
	char word[1000][83];
	int n,i,counter=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>word[i];
        char *p,*temp;
	for(i=0;i<n;i++)
	{
                temp=word[i];
		if(counter==0)
		{
                        for(p=temp;p<temp+strlen(word[i]);p++)
                             cout<<*p;
			counter=counter+strlen(word[i]);
		}
		else
		{
			if(counter+strlen(word[i])+1<=80)
			{
				cout<<" ";
                                for(p=temp;p<temp+strlen(word[i]);p++)
                                      cout<<*p;
				counter=counter+strlen(word[i])+1;
			}
			else
			{
				cout<<endl;
				counter=0;
				i--;
			}
		}
	}
	return 0;
}
int main(){
	char word[41];
	int sum=0,n,t;
	cin>>n;
	t=n;
	n--;
	scanf("%s",word);
	cout <<word;
	sum=sum+strlen(word);
	while(n--)
	{
		scanf("%s",word);
		if((sum+strlen(word)+1 <= 80)&&(n!=t)){
			cout<<' ';
			sum++;
		}
		else {
			cout<<'\n';
			sum=0;
		}
		sum=sum+strlen(word);
		cout<<word;
		memset(word,0,sizeof(word));
	}
	
    return 0;
}
void read_words(char words[][WSIZE], int n)
{
  int i;
  for (i = 0; i < n; i++) {
    scanf("%s", words[i]);
  }
}

int split_lines(char words[][WSIZE], int lines[], int n)
{
  int i = 0;
  int j = 0;
  lines[j] = 0;
  while (i < n) {
    int len = strlen(words[i]);
    while (len <= MAX_LINE) {
      i++;
      if (i < n) {
        len += 1 + strlen(words[i]);
      }
      else break;
    }
    j++;
    lines[j] = i;
  }
  return j;
}

void print_words(char words[][WSIZE], int lines[], int line_num)
{
  int i, e, k;
  for (k = 0; k < line_num; k++) {
    e = lines[k + 1] - 1;
    for (i = lines[k]; i < e; i++) {
      printf("%s ", words[i]);
    }
    printf("%s\n", words[e]);
  }
}

int main()
{
  int n;
  scanf("%d", &n);
  char words[n][WSIZE];
  read_words(words, n);
  int lines[n];
  int line_num = split_lines(words, lines, n);
  print_words(words, lines, line_num);
  return 0;
}
/*
 * wordedit.cpp
 *
 *  Created on: 2013-12-7
 *      Author: tangqinyi
 */

int main(){
	char word[503][40];
	int sum = 0,n;
	cin>>n;
	for(int i = 0;i < n;i++){
            cin>>*(word+i);//??????
            }
	cout<<*(word);//??????
	sum = strlen(*word) + 1;//??????????? 
    for(int i = 1;i < n;i++){
    	sum = sum +strlen(*(word+i));
    if(sum  <= 80){//?????????80
    	   cout<<' ';
           sum ++;
           }
    else {
         cout<<endl;//??80??
         sum = strlen(*(word+i)) + 1;//???????
         }
    cout<<*(word+i);//?????
    }
    return 0;
}
void main()
{
	int i,n,sum=0;
	char *p;//???????????
	scanf("%d",&n);//??????
    p=(char *)malloc(40);
	scanf("%s",p);
	sum+=strlen(p);
	printf("%s",p);//????????????????
	for(i=1;i<n;i++)
	{
		p=(char *)malloc(40);
		scanf("%s",p);
		sum+=strlen(p)+1;//????????
		if(sum<80)
			printf(" %s",p);
		else
			if(sum==80)
			{
				printf(" %s\n",p);//?????
				free(p);p=(char *)malloc(40);//??p?????????????????
				scanf("%s",p);
				printf("%s",p);
				sum=strlen(p);//????????????????
				i++;//??????????
			}
			else
			{
				printf("\n%s",p);//?????????????
				sum=strlen(p);//??
			}
	}
	printf("\n");
}
int main()
{
	char word[41];//??????
	int sum=0,n,t;
	cin>>n;//?????
	t=n;
	while(n>0)//?????????
	{
		scanf("%s",word);//????
		if(n!=t)
		{
		if((sum+strlen(word))<=80){cout<<" ";}//?????80???????
		if((sum+strlen(word))>80) {cout<<endl,sum=0;}//??80???????
		}
		sum=sum+strlen(word);//?????
		cout<<word;//????
		memset(word,0,sizeof(word));//????
		n--;//?????
		sum++;//????1
	}
	
	return 0;//??
 }
/*
 * m.cpp
 *
 *  Created on: 2013-12-7
 *      Author: de
 */

char *p=NULL;

int t=0,len=0;
void paiban(char *q,int i){
	if(q[i]==' '){q[i]='\n';
      t+=80;
      if(len-t<=80) {
    	  cout<<p;return;}
      else paiban(q+i+1,79);
	}
	else{
		if(q[i+1]==' '){q[i+1]='\n';
		t+=81;
		if(len-t<=80) {
		    	  cout<<p;return;}
		      else paiban(q+i+2,79);
		}
		else{
		i--;
		while(q[i]!=' '){
			i--;
		}
		q[i]='\n';
		i++;
		t+=i;
		if(len-t<=80){cout<<p;
		return;
		}
		else paiban(q+i,79);
		}
	}
}
int main(){
	int n;
   cin>>n;
  char text[42*n];
  p=text;
   char c[1];
   cin.getline(c,1);
   cin.getline(text,42*n); //cout<<"*********************"<<strlen(text);
   len=strlen(text);
   if(len>80){

   paiban(text,79);
   }
   else
   cout<<text<<endl;

	return 0;
}
int main()
{
	char a[1000][40];
	int n,i,j;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<n;)
	{
		cout << a[i];
		int la=strlen(a[i]);
		int lc=la;
		for(j=1;j+i<n;j++)
		{
			int lb=strlen(a[i+j]);
			lc+=lb;
			if(lc<80)
			{
				cout <<" "<<a[i+j];
				lc++;
			}
			else
			{
				cout <<endl;
				break;
			}
		}
		i+=j;
	}
	return 0;
}
int main()
{
	char a[1000][45];//??????
	int sum=0,n,i;//sum??????????
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];//????
	for(i=1;i<=n;i++)
	{
		if(sum==0)
		{
			sum=strlen(a[i]);
		}
		else if(strlen(a[i])+1+sum<=80) 
		{
			cout<<" ";
			sum=sum+1+strlen(a[i]);
		}
		else if(strlen(a[i])+1+sum>80)
		{
			cout<<endl;
			sum=strlen(a[i]);
		}
		cout<<a[i];
	}
	return 0;
}
int main()
{
	int n,i,k=0,ll=0;
	char word[300][41];
	char **p;
	int len[300];
	int *l;
	l=len;
	p=word;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",word[i]);
		*(l+i)=strlen(word[i]);
	}
	for(i=0;i<n;i++){
		if(k==0){
			printf("%s",word[i]);
			k++;
			ll+=*(l+i);
		}
		else{
			if(ll+*(l+i)+1<=80){
				printf(" %s",word[i]);
				ll+=*(l+i)+1;
			}
			else{
				printf("\n%s",word[i]);
				ll=*(l+i);
			}
		}
	}
	return 0;
}
int main()
{
	int n, count = 0, j = 1, l;
	char a[41];
	char *p = a;
	cin >> n;
	for ( int i = 1; i <= n; i++ )
	{
		cin >> p;
		l = 0;
		for ( *p; *p != '\0'; *p++ )
		{
			l++;
		}
		count = count + l;
		p=a;
		if ( count < 80 && count != l )
		{
			cout << " " << p;
			count++;
		}
		else if ( count < 80 && count == l )
		{
			cout << p;
		}
		else
		{
			cout << endl;
			cout << p;
			count = l;
		}
	}
	return 0;
}
int main ()
{
	int a[1000],i,n,sum=0;
	char word[1000][40]={""};
	scanf("%d",&n);
	for (i=0;i<n;i++)
		scanf("%s",word[i]),
		a[i]=strlen(word[i]);
	for(i=0;i<n-1;i++)
	{	sum=sum+a[i]+1;
	
	if(sum+a[i+1]<81)
		printf("%s ",word[i]);
	else
		printf("%s\n",word[i]),
		sum=0;
	}
	printf("%s",word[n-1]);
	return 0;
}
int main()
{
	char str[1000][50]={0};
	int i,j,n,k;
	int sum=0,m=0;
	char useless;
	scanf("%d",&n);
	scanf("%c",&useless);

	//??
	for(i=0;i<n-1;i++)
	{
		for(j=0;;j++)
		{
		  scanf("%c",&str[i][j]);
		  if(str[i][j]==' ')
		  {
			str[i][j]='\0';
            break;
		  }
		}	
	}
	gets(str[n-1]);

//	for(i=0;i<n;i++)
//		puts(str[i]);


	for(i=0;;i++)
	{
		m=strlen(str[i]);
		sum=sum+m;

		if(sum<=80)
		{
			if(sum<80)
			{
				printf("%s",str[i]);
				if((sum+1+strlen(str[i+1])<=80)&&i<n-1) printf(" ");
				sum=sum+1;
			}

			else
				printf("%s",str[i]);
		}

		else
		{
			if(sum+1>80) printf("\n");
			else
			{
		//	for(j=sum+1;j<=80;j++) printf(" ");
			printf("\n");
			}
			sum=0;
			i=i-1;
		}
		if(i==n-1) break;
	}


	return 0;
}
int main()
{
    char word[1000][50];
    int sum=0,n,i;
    cin>>n;
    cin.get();
    for(i=0;i<n;i++)
    cin.getline(word[i],50,' ');

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

    return 0;
}
void main()
{
	int n;
	int i,j;
	char a[500][40];
	int b[500],m;

	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%s",a[i]);
		b[i]=strlen(a[i]);
	}
	a[i][0]='\0';
	b[i]=0;
    m=b[0];
	for(j=0;j<n-1;j++)
	{
		m=m+1+b[j+1];
		if(m<=80)
			printf("%s ",a[j]);
		else
		{
			printf("%s\n",a[j]);
			m=b[j+1];
		}
	}
	printf("%s\n",a[j]);
}
int main()
{
	int n, i, count = 0, len,j, flag = 0;
	char word[2000][2000];
	char *p = NULL;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> word[i];
		len = strlen(word[i]);
		word[i][len] = 0;
	}
	i = 0;
	while(i < n)
	{
		p = word[i];
		j = 0; 
		{
			len = 0;
		//	while (*(p+len) != 0) len++;
		len = strlen(word[i]);
		//	cout << count << endl;
		//	cout << len << endl;
			if (len > (80 - count))
			{
				cout << endl;
				while (*p != 0)
				{
					cout << *p;
					p++;
				}
				
				i++;
				count = len + 1;
			}
			else
			{
				if (! count == 0) 	cout << " ";
				while (*p != 0)
				{
					cout << *p;
					p++;
				}
				count += len;
				count++;
				i++;
			}
		}
	}

	return 0;
}
int main()
{
	char c[500][100];
	int d[500];
	int i=0;
	int a,sum,num,w;
	scanf("%d",&a);
	do
	{
		scanf("%s",c[i]);
		i++;
	}while(i<a);
	i=0;
	do
	{
		d[i]=strlen(c[i]);
		i++;}
	while(i<a);
	i=0;
	printf("%s",c[0]);
	do
	{   
		sum=0;
		num=0;
		if(w==1)
		{printf("%s",c[i]);
		sum+=d[i];i++;num++;}
		w=0;
		do
		{
		if(i==0)
		{sum+=d[i];i++;num++;}
		sum+=d[i];
		printf(" %s",c[i]);
		i++;
		if(i==a)
		{break;}
		num++;
		}while(sum+d[i]+num<=80);
		printf("\n");w++;
	}while(i<a);
	return 0;
}
int main() {
	int i, k, n, sum = 0;
	cin >> n;
	getchar();//?????????
	char text[1000][45];
	for (i = 0; i < n - 1; i++)
		for (k = 0; k < 40; k++) {
			*(*(text+i)+k) = getchar();
			if (*(*(text+i)+k) == ' ') {
				*(*(text+i)+k+1) = '\0';
				break;//???n-1???
			}
		}
	cin.getline(*(text+n-1),200);//????????????????
	for (i = 0; i < n; i++) {
		sum = sum + strlen(*(text+i));//?????????80
		if (sum - 1 > 80) {
			cout << endl;
			sum = strlen(*(text+i));
		}
		k = 0;
		while (true) {
			if(i != n - 1)
			if (*(*(text+i)+k) != ' ') {
				cout << *(*(text+i)+k);
				k = k + 1;//?????
			} else {
				if (sum + strlen(*(text+i + 1)) - 1 <= 80)
					cout << " ";
				break;//???????????????
			}
			if (i == (n - 1))
				if (*(*(text+i)+k)!='\0') {
					cout << *(*(text+i)+k);
					k = k + 1;
				} else
					break;//??????????????????
		}
	}
	return 0;
}
/*??
 ???????????????????????????????????????????????????
 ?????80???????????????????????????????????????????
 ????
 ????????n?????????????. ???n??????????????????????????????????????40?????
 ????
 ??????????????????80????????????????????????????*/
int main()
{
    int n=0,sum=0,length=0;
    char *p=NULL;
    char istring[30];
    cin>>n;
    p=istring;memset(istring,'\0',sizeof(istring));
    cin>>istring;
    cout<<istring;
    sum=strlen(istring);
    for(int i=0;i<n-1;i++)
    {
        
        memset(istring,'\0',sizeof(istring));
        cin>>istring;
        length=strlen(istring);
        if(sum+length+1>80)
        {
            cout<<endl;
            sum=length;
            cout<<istring;
        }
        else
        {
            sum=sum+length+1;
            cout<<" "<<istring;
            
        }
    }
    return 0;
}
int main()
{
	char danci[300][40];
	int n,i=0,j=0,k=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>danci[i];
	for(i=j;i<n;i++)
	{
		int a=0;
		for(j=i;j<n;j++)
		{
			a=a+strlen(danci[j])+1;
			if(a>81)
				break;
		}
		if(a<=81)
			for(int h=i;h<n;h++)
			{
				if(h==i)
					cout<<danci[h];
				else
					cout<<" "<<danci[h];
			}
		else
		{
			for(int h=i;h<j;h++)
			{
				if(h==i)
					cout<<danci[h];
				else
					cout<<" "<<danci[h];
			}
			cout<<endl;
		}
		i=j-1;

	}
	return 0;



}