semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void main()
{
	char a[500][41];
	int n,i,k,b[500];
	int *p1;
	char (*p2)[41];
	scanf("%d",&n);
	for(i=0,p2=a,p1=b;i<n;i++,p1++,p2++)
	{
		scanf("%s",*p2);
		b[i]=strlen(*p2);
	}
	p2=a;p1=b;
	for(i=0,k=*p1+1;i<n-1;i++,p2++,p1++)
	{
		k=k+*(p1+1);
		printf("%s",*p2);
		if(k>80)
		{
			printf("\n");
			k=*(p1+1)+1;
		}
		else 
		{
			printf(" ");
			k=k+1;
		}
	}
	p2=a;
	printf("%s",*(p2+n-1));
}
//*******************************
//*???????              **
//*?????? 1300012965     **
//*???20131211              **
//*******************************
int main()
{
	char a[999][41];
	memset(a,0,sizeof(a));
	int n, i, j, count = 0, nlen;
	char *p, *q;
	cin >> n;
	for(i = 1; i <= n; i++)
		cin >> a[i];
	p = *a;
	cout << *(a+1);
	nlen = strlen(a[1]);
	count = nlen;
	for(j = 2; j <= n; j++)
	{
		nlen = strlen(a[j]);
		if(count+nlen+1 <= 80)
		{
			cout << " " << *(a+j);
			count = count+nlen+1;
		}
		else
		{
			count = nlen;
			cout << endl;
			cout << *(a+j);
		}
	}
	return 0;
}
/* Note:Your choice is C IDE */
int main()
{
    int i,n,a[1000],x=0;
    char s[1000][40];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
    	scanf("%s",&s[i]);
    	a[i]=1+strlen(s[i]);
    }
    for(i=1;i<n;i++)
    {
    	x=x+a[i];
    	if(x<=81)
    	{
    		if((x+a[i+1])<=81) printf("%s ",s[i]);
    		else printf("%s",s[i]);
    	}
    	else
    	{
    		printf("\n");
    		x=a[i];
    		printf("%s ",s[i]);
    	}
    }
    if((x+a[n])<=81) printf("%s",s[n]);
    else printf("\n%s",s[n]);
    return 0;
}
int main()
{
	struct
	{
		char word[41];
		int lw;
	}a[10000];
	int lpr=0;
	
	int n,m,i,j,k=0;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s",a[i].word);
		a[i].lw=strlen(a[i].word);
	}
	printf("%s",a[0].word);
	lpr=a[0].lw;
	for (i=1;i<n;i++)
	{
			lpr+=a[i].lw;
			if (lpr<80)
			{
				printf(" %s",a[i].word);
				lpr++;
			}
			else
			{
				printf("\n");
				printf("%s",a[i].word);
				lpr=a[i].lw;
			}
	}
	printf("\n");
	return 0;
}
int main(int argc, char* argv[])
{
	int n,p=0,m=0;
	int i;
	char word[60],s[60];
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s",word);
    	m=strlen(word);
		if (p+m>80)
		{
			printf("\n");
			p=0;
		}
		else if(i>0)
		{
			printf(" ");
		}
		p=p+m+1;
		strcpy(s,word);
		printf(s);
	}
	printf("\0");
	return 0;
}
int main()
{
	int num,i,len;
	char word[1000][50];
	scanf("%d",&num);
	for(i=0;i<num;i++)
	{
		scanf("%s",word[i]);
	}
	len=0;
	i=0;
	while(i<num)
	{
		while(len+strlen(word[i])<=80)
		{
			len=len+strlen(word[i]);
			cout<<word[i];
			if(i+1>=num)
			{
				i++;
				break;
			}
			if(len+strlen(word[i+1])<80)
			{
				cout<<" ";
			}
			len=len+1;
			i++;
		}
		cout<<endl;
		len=0;
	}
}
int main(){
 char s[1000][40];
 int n,i;
 scanf("%d",&n);getchar();
 for(i=0;i<n;i++){
     scanf("%s",s[i]);getchar();
     }
  int h=strlen(s[0]);
  printf("%s",s[0]);
  for(i=1;i<n;i++){
     h+=strlen(s[i])+1;
     if(h<=80){
           printf(" %s",s[i]);getchar();
     }else{
           h=strlen(s[i]);
           printf("\n");getchar();
           printf("%s",s[i]);
           }
  }
    return 0;
}
int main()
{
    int n,i,wl,len=0;
    char w[64],p[64]="";
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
         printf(p);
         scanf("%s",w);
         wl=strlen(w);
         if(len+wl>80)
         {
             printf("\n");
             len=0;
         }
         else if(i>0)
         {
              printf(" ");
         }
         len+=wl+1;
         strcpy(p,w);
    } 
         printf(p);
         getchar();
         getchar();
         getchar();
         return 0;
}
int main(){
	int i , n , j , l , c = 0;
	char word[100000][20];
	scanf( "%d" , &n );
	for(i = 0 ; i <= n - 1 ; i++){
		scanf("%s" , word[i]);
	}
	for(i = 0 ; i <= n - 1; i++){
		printf("%s" , word[i]);
		l = strlen(word[i]);
		j = strlen(word[i+1]);
		c = c + l + 1;
		//	printf("\n%d %d %d" , l , j , c);
		if( c + j > 80) {
			printf("\n");
			c = 0 ;
		}
		else if( i == n - 1 ) printf("\n");
		else printf(" ");
	}

	return(0);
}
int main (){
	int n,t=0;
		cin>>n;
		char word[n][41];
		char *p[n];//????????,?????
		for(int i=0;i<n;i++){
			cin>>word[i];
			p[i]=word[i];
		}
		for(int i=0;i<n;i++){
			t+=strlen(word[i])+1;
		    if(t+strlen(word[i+1])<=80){
		    	if(i==n-1){
		    		cout<<p[i];
		    	    break;
		    	}
		    	cout<<p[i]<<" ";
		    }
		    if(t+strlen(word[i+1])>80){
		    	cout<<p[i]<<endl;
		    	t=0;
		    }
		}

	return 0;
}
/*
 * p.cpp
 *
 *  Created on: 2011-12-2
 *      Author: Administrator
 */
int main()
{
	int max,n,t,i;
	char word[50];
	cin>>n;
	cin>>word;                       //?????word???
	cout<<word;
	max=strlen(word);                //max?????????
	for(i=2;i<=n;i++){
		scanf("%s", word);
		t=strlen(word);
		max+=t+1;
		if(max>80){                  //?????
			max=t;
			cout<<endl<<word;        //????????
			continue;
		}
		cout<<' '<<word;
	}
	return 0;
}
int main(){
	char words[50];
	int n,sum=0,temp=0,lens;
	cin>>n;
	while(n>0){
		cin>>words;
		lens=strlen(words);
		if(lens+sum<80){
			if(temp==0){
				cout<<words;
				sum=sum+lens;
				temp++;
			}
			else{
				cout<<" "<<words;
				sum=sum+lens+1;
				temp++;}
		}
		else {
			cout<<endl<<words<<" ";
			sum=lens+1;
			temp=0;
		}
		n--;
		memset(words,0,sizeof(words));
	}
	return 0;
}
int main()
{
	int n=0;
	scanf("%d",&n);
	int i=0;
	char s[40];
	int length=0;
	int len=0;
	for(i=0;i<n;i++)
	{
		scanf("%s",s);
		len=strlen(s);
		length+=len;
		if(length<MAX)
		{
			if(length!=len)
			{
				printf(" ");
				length++;
			}
			printf(s);
		}
		else
		{
			printf("\n");
			length=len;
			printf(s);
		}
	}
	return 0;
}
int main()
{
	char word[40];
	int n,sum=0;
	int i;
	int first=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		scanf("%s",word);
		sum=sum+(strlen(word))+1;//?????????????????
		if(sum<=81)//????????80?(????????)?????
		{
			if(first==0)
			{
				cout<<word;
			first=1;
			}
			else
			{
				cout<<" "<<word;
			}
		}
		else
		{
			first=0;
			cout<<endl<<word<<" ";//??????80???
			sum=strlen(word)+1;//????????????
		}
	}
	
	return 0;
}
int main()
{
	int n,k,i,temp=0;//????
	char b[1000][50];//??????????
    char *p[1000];//??????
	cin>>n;cin.get();
	k=1;
	while(k<=n)
	{
		cin>>b[k];
		p[k]=b[k];//??????????
		k++;
	}
	for(i=1;i<=n;i++)
	{
		cout<<p[i];//??????????
		temp++;
		temp+=strlen(b[i]);
			if(temp+strlen(b[i+1])>80) {cout<<endl;temp=0;}//???80????????
			else if(i!=n) cout<<" ";//??,?????????,?????
	}
	return 0;
}
int main()
{
	int n=0,count=0;
	cin>>n;cin.get();
	for(int i=0;i<n;i++)
	{
		char letter[50];
		cin>>letter;
		if(count+strlen(letter)+1>80)
		{
				count=0;
				cout<<endl;
		}
		if(count==0)
		{
			cout<<letter;
			count=strlen(letter);
		}
		else
		{
			cout<<' '<<letter;
			count+=1+strlen(letter);
		}
	}
	return 0;
}
int main()
{
    int n;
	scanf("%d",&n);
	char word[1000][41];
	int len[1000];
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%s",word[i]);
		len[i]=strlen(word[i]);

	}
	int m=0;
	int flag=0;
	for(i=0;i<n;i++)
	{
		if(m==0)
		      {m+=(len[i]);flag=1;}
		else m+=(len[i]+1);
		if(m<=80)
		{
			if(flag==1)
			{printf("%s",word[i]);flag=0;}
			else printf(" %s",word[i]);

		}
		else
		{
			m=0;
			printf("\n");
			i--;
		}
	}

	

    return 0;

}
int main()
{
	char A[250][250];
	int n,i,a,s,b;
	scanf("%d",&n);
	for (i=0;i<n;i++)
		scanf("%s",A[i]);
	for (i=0;i<n;i++)
	{
		a=strlen(A[i]);
		s=a+s;
		if (s==80)
		{
			printf("%s\n",A[i]);
			s=0;
		}
		else if (s>80)
		{
			if (i!=n-1)
			printf("\n%s ",A[i]);
			else 
				printf("\n%s\n",A[i]);
			s=a+1;
		}
		else 
		{
			b=strlen(A[i+1]);
			if (i!=n-1)
			{
				if (s+b+1>80)
			printf("%s",A[i]);
				else printf("%s ",A[i]);
			}
			else 
				printf("%s\n",A[i]);
			s=s+1;
		}
	}
	return 0;
}
int main()
{
	int n;
	scanf("%d",&n);
	char str[800][80];
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%s",str[i]);
	}
	int a=0;
	int k=0;
	int j;
	for(i=0;i<n-1;i++)
	{
		a=a+strlen(str[i])+1;

		if(a<80&&((a+strlen(str[i+1])+1)==80||(a+strlen(str[i+1]))==80)) //jia shang zui hou yi ge ci zheng hao 80(wu kong ge)//
		{
			for(j=k;j<=i;j++)
			{
				printf("%s ",str[j]);
			}
			printf("%s",str[j]);
			printf("\n");
			a=0;
			k=i+2;
			i=i+1;
		}

		if(a<80&&(a+strlen(str[i+1])+1)>80)
		{
			for(j=k;j<i;j++)
			{
				printf("%s ",str[j]);
			}
			printf("%s",str[j]);
			printf("\n");
			a=0;
			k=i+1;
		}
		
	}
	for(j=k;j<n-1;j++)
	{
		printf("%s ",str[j]);
	}
	printf("%s",str[j]);
	return 0;
}
int main()
{
	int n;
	int len;
	cin >> n;
	cin.get();
	char str[42];
	cin >> str;
	cout << str;
	int num=strlen(str);
	n=n-1;
	while(n--)
	{
		cin>> str;
		len=strlen(str);
		num=num+len+1;
		if(num<=80)
			cout<<' '<<str;
		else
		{
			cout<<endl;
			cout<<str;
			num=len;
		}
	}
	return 0;
}
int main()
{
 int n;
 cin>>n;
 int len,len2;
 //char word[50];
 char ans[32768];
 memset(ans,0,sizeof(ans));
 cin>>ans;
 len=strlen(ans);
 len2=strlen(ans);
 //cout<<ans<<endl;
 //cout<<len;
 for(int i=1;i<n;i++)
 {
	 char word[50];
  cin>>word;
  if(len+1+strlen(word)>80)
  {  /* cout<<len<<endl;
      cout<<len2<<endl;*/
	  ans[len2]='\n';
	  strcat(ans,word);
	  len=strlen(word);
	  len2=len2+strlen(word)+1;
  }
  else
  {
   ans[len2]=' ';
   strcat(ans,word);
    len=len+1+strlen(word);
	len2=len2+1+strlen(word);
  }
 /* len=len+1+strlen(word);*/
 }
 //cout<<len<<endl;
 cout<<ans<<endl;
 return 0;
}
int main()
{
    int n;
    cin>>n;
    int i,j,k;
    char s[10000][40];                     //???????????
    int sum=0;                             //??????????????????0
    for(i=0; i<n; i++)
    {
        cin>>*(s+i);                       //??n?????????
    }
    for(i=0; i<n; i++)
    {
        if(sum==0)                         //???????0????
        {
            cout<<*(s+i);
            sum=strlen(*(s+i));            //??????????????
        }
        else if(sum+strlen(*(s+i))+1<=80)  //????????????????
        {
            cout<<" "<<*(s+i);             //????????????????
            sum=sum+strlen(*(s+i))+1;      //sum????
        }
        else
        {
            cout<<endl;    //????????????80????????????
            cout<<*(s+i);
            sum=strlen(*(s+i));             //?????????
        }
    }
    return 0;
}
void main()
{
	int n,i,t=0;
	char a[1000][50];
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
		scanf("%s",a[i]);
	}
	for(i=0;i<=n-2;i++)
	{
		t=t+strlen(a[i])+1;
		if(t<81&&(t+strlen(a[i+1])+1)<=81)
		{
			printf("%s ",a[i]);
		}
		else if(t<81&&(t+strlen(a[i+1])+1)>81)
		{
			printf("%s",a[i]);
		}
		else if(t==81)
		{
			printf("%s\n",a[i]);
			t=0;
		}
		else if(t>81)
		{
			printf("\n");
			t=0;
			i=i-1;
		}
	}
	printf("%s\n",a[n-1]);
}
// ????????????.cpp : ??????????????
//



int main()
{
	int x,n,i = 0,j = 0,k = 0,word = 0;
	char a[10000];
	cin >> n;
	cin.get();
	cin.getline(a,10000);
	char *p = a;
	for (;;)
	{
		if (word == n)
		{
			break;
		}
		while (*(p + i) != ' ' && *(p + i) != '\0')
		{
			k++;
			i++;
		}
		if (i <= 80 && i != k)
		{
			cout << ' ';	
		}
		if (i <= 80)
		{
			for (j = i - k;j <= i - 1;j++)
			{
				cout << *(p + j);
			}
			i++;
			k = 0;
			word++;
		}
		if (i > 80)
		{
			cout << endl;
			for (x = 1;x <= i - k;x++)
			{
				*p++;
			}
			i = 0;
			k = 0;
		}
	}
	return 0;
}
int judge(char *p1,char *p2,int l)
{
	char *x1,*t1,*t2;
    int y=1;
	t1=p1;
	x1=t1+l-1;
	t2=p2;
	while ((t1<=x1) && y)
	{
		if (*t1!=*t2) y=0;
		t1++;
		t2++;
	}
	return y;
}

void main()
{
	char c[3243];
		int i,j,k,n,l,len;
	//freopen("tt.in","r",stdin);
	//freopen("tt.out","w",stdout);
    scanf("%d",&n);
	//for(i=0;i<=l-1;i++) if (c[i]==' ') k++;

	
	len=0; 
	for (i=1;i<=n;i++) 
	{

    scanf("%s",c);
	l=strlen(c);
	if (len==0) {printf("%s",c); len+=l;}
	else
	   if (len+l+1<=80)
	   {
		printf(" %s",c);len+=l+1;
	   }
	   else 
	   {printf("\n%s",c); len=l;}

	}
	

	
}
int main()
{
    int n;char a[1000][50];//????
    int i,b[1000],sum=0,p=0;
    cin>>n;//????
    for(i=0;i<n;i++) {scanf("%s",a[i]);b[i]=strlen(a[i]);}//???????????????
   for(i=0;i<n;i++)
   {

       if(p) cout<<" ";
       cout<<a[i];
       p=1;
       sum=sum+b[i]+1;
       if(sum+b[i+1]>80) {cout<<endl;sum=0;p=0;}//?????80????
   }
    return 0;
}
main()
{
   char c[1000][40],w[40];
   int n,i,j,k,a[1000];
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {  
      scanf("%s",w);
      for(j=0;w[j]!='\0';j++)
      {
         c[i][j]=w[j];
         c[i][j+1]='\0';
         a[i]++;
      }
   }
   k=0;
   for(i=0;i<n;i++)
   {
      k+=a[i]+1;   
      if((k+a[i+1])>80)
      {
        k=0;
        for(j=0;j<a[i];j++)
         printf("%c",c[i][j]);
        printf("\n");
        continue;        
      }   
      for(j=0;j<a[i];j++) 
       printf("%c",c[i][j]); 
      if(i!=(n-1))
        printf(" ");       
   }    
  getchar();getchar();getchar();getchar();getchar();        
}
/*??????
 *?????zhizhen1.cpp
 *Created on: 2012-12-19
 *???????
 */
int main() {
	int n;
	cin >> n;                                       //??????
	char p[5000];
	cin.getline(p, 5000);                           //?????
	cin.getline(p, 5000);                           //??????
	char m[500][45];
	char (*h)[45];
	h = m;
	int i, j, k;
	for (i = 0, j = 0, k = 0; i < strlen(p); i++) {
		if (*(p + i) != ' ') {
			*(*(h + j) + k) = *(p + i);
			k++;
		}                                           //???????????
		else if (i != strlen(p) - 1) {
			j++;
			k = 0;
		}
	}

	int sum, i1;
	for (sum = 0, i1 = 0; i1 < n; i1++) {
		sum = sum + strlen(m[i1]);

		if ((sum + strlen(m[i1 + 1]) + 1 <= 80) && (i1 != n - 1)) {
			cout << *(h + i1) << " ";
			sum++;
		}                                           //???? ???
		else {
			cout << *(h + i1) << endl;
			sum = 0;
		}                                           //?????
	}

	return 0;                                       //????
}
void main()
{
	int n,i,m=0;
	struct word
	{
		char word[40];
		int len;
	} words[500];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",words[i].word);
		words[i].len=strlen(words[i].word);
	}
	printf("%s",words[0].word);
	m=words[0].len;
	for(i=1;i<n;i++)
	{
		m+=(words[i].len+1);
		if(m<=80) printf(" %s",words[i].word);
		else 
		{
			printf("\n");
			printf("%s",words[i].word);
			m=words[i].len;
		}
	}
	printf("\n");
}
int main()
{
	char a[100],v;int number=0,c,m=1,an_number=0;
	cin>>c;
	const int max=80;
	while(m)
	{
		while(number<=max)
		{
			cin>>a;
			an_number+=1;
			if(number==0)
			{
				cout<<a;
				number=number+strlen(a);
			}
			else if(number+strlen(a)+1<=max)
			{	
				cout<<' '<<a;
				number=number+strlen(a)+1;
			}
			else break;
			if(an_number==c)
			{
				m=0;
				break;
			}
		}
		if(an_number!=c)
		{
			cout<<endl;
			cout<<a;
			number=strlen(a);
		}
	}
	return 0;
}
int main()
{
	char word[300][40];
	int i,n,sum;
	cin>>n;
	for(i=0;i<n-1;i++)
	{
		scanf("%s",word[i]);
	}
	scanf("%s",word[n-1]);
	sum=0;
	i=0;
	do
	{
		cout<<word[i];
		sum+=strlen(word[i]);
		i++;
		while(sum+strlen(word[i])+1<=80)
		{
			cout<<' '<<word[i];
			sum+=strlen(word[i])+1;
			i++;
			if(i==n)
			{
				break;
			}
		}
		cout<<endl;
		sum=0;
	}while(i<n);
	return 0;
}
/*
 * zhizhen3.cpp
 *??????
 *  Created on: 2011-12-5
 *      Author: APPLE
 */
int main()                                                    //?????
{
     int n,csum=0,j=0,i=0;
     cin>>n;
     char words[1000][20];                                         //????????????
     for(i=0;i<n;i++)
     scanf("%s",words[i]);
     for(i=0;i<n;i++)
       {
    	 csum=csum+strlen(words[i])+1;                   //?csum??????????+1???????
        if(csum==81)                                  //?????80?????  ??????????
       {
          cout<<words[j];
           for(j=j+1;j<=i;j++)
        	cout<<' '<<words[j];
          	  csum=0;                                 //?csum????
          	   cout<<endl;
            continue;
               }

    	 if(csum>81)                              //????80????? ??????????
       {
    	 cout<<words[j];
    	for(j=j+1;j<i;j++)
    	  cout<<' '<<words[j];
    	csum=strlen(words[i])+1;                                 //?csum????
    	cout<<endl;
    	continue;
       }
       }
     cout<<words[j];
                   for(j=j+1;j<n;j++)
                	   cout<<' '<<words[j];                  //???????
        return 0;                                            //?????

}
int main()
{
	char str[1000][40];
	int n,i,j,a[1000]={0},line=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",str[i]);
		for(j=0;str[i][j]!='\0';j++)
		{
			a[i]=a[i]+1;
		}
	}
	for(i=0;i<n;i++)
	{
		line=line+a[i];
		if(line>80)
		{
			printf("\n");
			if(i==n-1)
				printf("%s",str[i]);
			else
				printf("%s ",str[i]);
			line=a[i]+1;
		}
		else
		{
			if(i==n-1)
				printf("%s",str[i]);
			else
			{
				if(line+a[i+1]+1>80)
					printf("%s",str[i]);
				else
					printf("%s ",str[i]);
			}
			line=line+1;
		}
	}
	return 0;
}
int main()
{
	char a[300][41],*p=NULL;
	int n=0;
	cin >>n;
	for(int i=0;i<n;i++)
		cin >>a[i];
	p=a[0];
	int sum=0;
	for(int i=0;i<n;i++)
	{
		p=a[i];
		if(sum+strlen(a[i])>79)
		{
			i=i-1;
			sum=0;
			cout <<endl;
		}
		else if(sum+strlen(a[i])==79)
		{
			if(sum!=0)
				cout <<" ";
			do{
				cout <<*p;
				p=p+1;
			}while(*p!='\0');
			cout <<endl;
			sum=0;
		}
		else{
			if(sum!=0)
			{
				cout <<" ";
				sum=sum+1;
			}
			do{
				cout <<*p;
				p=p+1;
			}while(*p!='\0');
			sum=sum+strlen(a[i]);
		}
	}
	cout <<endl;
	return 0;
}
int main()
{
	int n;
	int sum = 0;
	char a[50];
	cin>>n;
	for(int i = 0;i<n;i++)
	{
		cin>>a;
		int s = strlen(a);
		sum += s+1;
		if(sum == s+1)
		{
			cout<<a;
			sum--;
		}
		else if(sum>80)
		{
			cout<<endl;
			cout<<a;
			sum = s;
		}
		else if(sum<80)
		{
			cout<<' '<<a;
		}
		else if(sum == 80)
		{
			cout<<' '<<a;
			cout<<endl;
			sum = 0;
		}
	}

	return 0;
}
/*?????????????
 *??????
 *???2011-4-10
 */
int main()
{
	char word[41];
	int counter, num, len;
	cin >> num;
	counter = 0;
	for (int i = 0; i < num; i++){
		cin >> word;
		len = strlen(word);
		counter += len;
		if (counter + 1 > 80){
			cout << endl;
			counter = len;
		}
		else if (counter != len){
			cout << ' ';
			counter++;
		}
		cout << word;
	}
	return 0;
}
int main()
{
	int words=0,count=0;
	char str1[100],str2[100];
	int length1=0,length2=0,length3=0;
	cin>>words;
	gets(str1); 
	cin>>str1;
	count=1;
	cout<<str1;
	length1=strlen(str1);
	while (count<words)
	{
		cin>>str2;
		length2=strlen(str2);
		length1=length1+length2+1;
		if (length1<=80)
			cout<<" "<<str2;
		else
		{
			cout<<endl;
			cout<<str2;
			strcpy(str1,str2);
			length1=strlen(str1);
		}
		count++;
	}
	return 0;
}
int main()
{
 int n,i,len=0;           //len????????????
 cin>>n;
 char word[1000][41];
 for(i=0;i<n;i++)
  cin>>*(word+i);         //????
 i=0;
 while(i<n)
 {
  if(len==0)
  {
   cout<<*(word+i);
   len+=strlen(*(word+i++)); //?len?0??????????????????
  }
  else
   if(len+1+strlen(*(word+i))<=80)
   {
    cout<<' '<<*(word+i);
    len+=(strlen(*(word+i++))+1);  //?????????????????????????80???????????
   }
   else
   {
    cout<<endl;
    len=0;                       //?????????80?????len???0
   }
 }
 return 0;
}
int main()
{
    int n,i,c,j;
	char a[300][100];
	int l[300];
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s",a[i]);
        l[i]=strlen(a[i]);
	}
	c=l[0];j=0;
//	for (i=0;i<n;i++)
//		printf("%d ",l[i]);
    while (j<n)
	{
 	    while ((c<=80)&&(j<n))
		{
 // 		 if (c+l[j]<=80) printf("%s ",a[j]);
			if (c==l[j]) printf("%s",a[j]); else printf(" %s",a[j]);
  		    c++;j++;
  		    c=c+l[j];
		}
  		 printf("\n");
 		c=l[j];
	}
	return 0;
}
/*
 * ???1.cpp
 * Created on: 2012-12-11
 * Author: ???
 * ??: ????????????
 */
int main(){
	int a=0;           //??????
	int n,i,*sum=&a,len1,len2;      //????
	cin>>n; //??n
	char str[n][50];   //????
	for(i=0;i<n;i++)   //??????
	{
       cin>>str[i];
	}
	i=0;
	while(i<n-1)        //??????
	{
		len1=strlen(str[i]);        //??????
		len2=strlen(str[i+1]);      //???????
	    if(*sum+len1<=80 && *sum+len1+len2+1<=80) //??????????
	     {
	      cout<<str[i]<<" ";      //???????
		  *sum=*sum+len1+1;       //????
	     }
	    else if(*sum+len1<=80 && *sum+len1+len2+1>80)  //??????
	    {
	    	cout<<str[i]<<endl;     //???????
	    	*sum=0;      //???0
	    }
	    i++; //?i?1
	}
	len1=strlen(str[n-1]); //?????????
	if(*sum+len1>80)      //
	{
		cout<<endl;
		cout<<str[n-1];
	}
	if(*sum+len1<=80)
	{
		cout<<str[n-1];
	}
return 0;           //????
}
/*
 * hehe.cpp
 *
 *  Created on: 2012-12-04
 *      Author:??
 *   ???????????????????????????????????????????????????
 *?????80???????????????????????????????????????????
 *????????????
 *
 */
int main(){
	char a[8000],blank[100];
	char *ap,*end;
	int n;
	cin>>n;
	cin.getline(blank,1);
	ap=a;
	cin.getline(a,8000);
	int lena=strlen(a),i,c;

	for(;lena>=80;){
    for(i=0;i<=80;i++)
    {	if(*(ap+i)==' ')
    		{end=ap+i;         //??????
    		c=i;
    		}
    }
    lena=lena-c-1;
    for(;ap<end;ap++)
    	cout<<*ap;            //?????
        cout<<endl;
        ap++;                 //??????
	}
	for(int j=0;j<lena;j++)
		cout<<*(ap+j);
	return 0;
}
void main()
{
	int n,i,j,k=0;
	char a[1000][40]={'0'};
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s",a[i]);


   for(i=0;a[0][i]!='\0';i++)
	   
		   {
		   printf("%c",a[0][i]);
		   k++;
	
		   }

	for(j=1;j<n;j++)
	   
	{
		if((signed)strlen(a[j])<=80-k-1)
		
	   {
		   printf(" ");
		   k++;
		   for(i=0;a[j][i]!='\0';i++)
	   
		   {
		   printf("%c",a[j][i]);
		   k++;
	
		   }
	   }

	   
		  

		else 
		   {
			   printf("\n");
			   k=0;
			   for(i=0;a[j][i]!='\0';i++)
			   {
				   printf("%c",a[j][i]);
					   k++;
			   }
			 
		   }
	}

}
int main()
{
	int n,i=0,k=0,p=0,l;
	cin>> n;
	char x[500][40]={0};  //??????????????
	for(i=0;i<n;i++)
	{
		cin>> *(x+i);//??????    ???cin????scanf???cin.getline???????????1
    }
	for(i=0;i<n;i++)
	{
		l=strlen(*(x+i));
		k=k+l;//k??????????
		if(i==0) {cout<< *(x);continue;}//???????
		if(k!=l&&k+p+1<=80) {cout<<" "<< *(x+i);p++;continue;}//???????80???????p????????
		if(k+p+1>80) {cout<< endl;cout<< *(x+i);k=strlen(*(x+i));p=0;continue;}//????80????????????k?p??
	}
	return 0;
}
int main(){
	int n,i,m=0,j;
	struct W{
		int l;
		char s[42];
	}w[520];
	scanf("%d",&n);
	for (i=0;i<=n-1;i++){
		scanf("%s",w[i].s);
		w[i].l=0;
		for (j=0;w[i].s[j]!='\0';j++){
			w[i].l++;
		}
	}
	for (i=0;i<=n-1;i++){
		m=m+w[i].l+1;
		if (i==n-1){
			if (m<=81)
				printf("%s",w[i].s);
			else {
				printf("\n");
				printf("%s",w[i].s);
			}
		}
		else if ((m<80)&&(m+w[i+1].l<=80)){
			printf("%s ",w[i].s);
		}
		else if (m>81){
			printf("\n");
			printf("%s ",w[i].s);
			m=w[i].l+1;
		}
		else{ 
			printf("%s",w[i].s);
			printf("\n");
			m=0;
		}
	}
	return 0;
}
int main()
{
	char word[50], *p = NULL;
	int n, k = 0, sum = 0, len, f = 1;
	cin >> n;
	while(k < n)
	{
		cin >> word;
		p = word;
		len = strlen(p);
		if(f == 1)
		{
			cout << word;
			sum = len;
			k++;
			f = 0;
			continue;
		}
		if(sum + 1 + len > 80)
		{
			cout << endl << word;
			sum = len;
			k++;
			continue;
		}
		if(sum + 1 + len <= 80)
		{
			cout << " " << word;
			sum = sum + 1 + len;
			k++;
			continue;
		}
	}
	return 0;
}
int main()
{
	int n,sum=0;
	char word[41]={0};
	cin>>n;
	cin>>word;
	sum+=strlen(word);
	cout<<word;
	memset(word,0,sizeof(word));
	for(int i=1;i<n;i++)
	{
		cin>>word;
		sum+=strlen(word)+1;
		if(sum>80)
		{
			cout<<endl<<word;
			sum=strlen(word);
		}
		else cout<<' '<<word;
	}
	return 0;
}
int main()
{
	char a[40];
	int n, sum = 0, i = 0;
	cin >> n;
	while (cin >> a && n > 0)
	{
		i ++;
		int len = strlen(a);
		if (i == 1)
		{
			sum = sum + len;
		}
		else
		{
			sum = sum + len + 1;
		}
		if (sum <= 80)
		{
			if (i == 1)
			{
				cout << a;
			}
			else
			{
				cout << " " << a;
			}
		}
		if (sum == 80)
		{
			cout << endl;
			sum = 0;
			i = 0;
		}
		if (sum > 80)
		{
			cout << endl;
			cout << a;
			sum = len;
			i = 1;
		}
		n --;
	}
	return 0;
}
int main()
{
	char a[400][50] = {0};
	int i, b[400];
	int n;
	cin >> n;
	for (i = 1; i <= n; i++)
	{	
		cin >> a[i];
		b[i] = strlen(a[i]);
	}
	int num;
	int length = b[1];
	i = 1;
	cout << a[1];
	while(1)
	{
		if (i > 1)
		length = length + 1 + b[i];
			if (length + 1 + b[i + 1] <= 80)
			{
				cout << " " << a[i + 1];
			}
			else 
			{
				cout << endl << a[i + 1];
				length = -1;
			}
		i++;
		if (i == n)
			break;
	}
	return 0;
}