semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
char a[10010];
int l, n, i, j;

void biubiu(int ks, int ll)
{
    int k;
    if(ll - ks < 80)
    {
        for(i = ks; i < ll; i++)
            cout << a[i];
        cout << endl;
    }
    else
    {
        if(a[ks + 79] == ' ')
        {
            for(i = ks; i < ks + 79; i++)
            cout << a[i];
            cout << endl;
            biubiu(ks + 80, ll);
        }
        else
        {
            if(a[ks + 80] == ' ')
            {
                for(i = ks; i <= ks + 79; i++)
                cout << a[i];
                cout << endl;
                biubiu(ks + 81, ll);
            }

            else
            {
                for(k = ks + 78; k > ks; k--)
                if(a[k] == ' ')
                    break;
                for(i = ks; i < k; i++)
                cout << a[i];
                cout << endl;
                biubiu(k + 1, ll);
            }

        }
    }

}

int main()
{
    scanf("%d\n", &n);
    gets(a);
    l = strlen(a);
    int ll = l;
    i = l;
    while(a[i] == ' ')
    {
        i --;
        ll --;
    }
    for(i = 0; i < l; i++)
    {
        if(i == 0 && a[i] == ' ')
        {
            for(j = 0; j < l - 1; j++)
                a[j] = a[j + 1];
            i--;
            ll--;
        }
    }
    biubiu(0, ll);
    return 0;
}
/*
84
One sweltering day, I was scooping ice cream into cones and told my four children they could "buy" a cone from me for a hug. Almost immediately, the kids lined up to make their purchases. The three youngest each gave me a quick hug, grabbed their cones and raced back outside. But when my teenage son at the end of the line finally got his turn to "buy" his ice cream, he gave me two hugs. "Keep the changes," he said with a smile.
*/
/*
 * ???:passage.cpp
 * ??:??1200012840
 * ????:2012-12-14
 * ??:?????????????????????????????????????
 *      ??????????????
 *      ?????80???????????????
 *      ????????????????????????????
 *      ????????????
 */



int main()
{
	int n,i,line=0,m;//????
	char a[45],*p;//???????
	cin>>n;//??
	for(i=1;i<=n;i++)
	{
		cin>>a;//???????
		p=a;//?????????
		if(line==0)//??????????
			m=0;
		else
			m=1;
		while(*p!='\0')//???????
		{
			p++;
			m++;
		}
		if(line+m<=80)//????????
		{
			if(line!=0)//???????????
				cout<<' ';
			line=line+m;
			cout<<a;//????
		}
		else//???????
		{
			line=m-1;
			cout<<'\n'<<a;
		}
	}
	return 0;
}
//***********************************
//** ???Dec 11, 2013 - ???? **
//** ?????? 1300012719       **
//** ???2013.12.13              **
//***********************************
int main()
{
	char str[2000][40];                            //str??????(???????????????),letnum??????????
	int i, n, letnum = 0;
	cin >> n;
	cin.get();
	for (i = 0; i < n; i++)                        //????????????,???????????
		cin >> *(str + i);
	cout << *str;                                  //?????????,?????????
	letnum += strlen(*str);
	for (i = 1; i < n; i++)
	{
		if (strlen(*(str + i)) + 1 + letnum <= 80)
		{
			cout << " " << *(str + i);             //????????????????????,?????????
			letnum += strlen(*(str + i)) + 1;
		}
		else                                       //??????,???????????
		{
			cout << endl << *(str + i);
			letnum = strlen (*(str + i));
		}
	}
	cout << endl;                                  //???????????
	return 0;
}
int main ()
{
	int n ;
	char str[10001][40];
	cin >> n ;cin.get();
	for ( int i = 1 ; i <= n ; i++ )
	{
		cin.getline(str[i],40,' ');
	} 
	int sum = 0 ;
	for ( int i = 1 ;i <= n ; i ++ )
	{
		sum += strlen(str[i]);
		if ( sum <= 80 )
		{
			if ( sum != strlen(str[i]) )
			{				
				cout << " " ;
			}
			else
			{
				sum = sum ;
			}
			for ( int j = 0 ; j < strlen(str[i]); j ++ )
			{
				cout << *(str[i]+j);
			}
			sum ++ ;			
		}
		else
		{
			cout << endl ;
			sum = 0 ;
			i -- ;
		}
	}
	return 0 ;
}
//??????????????????????....???strlen???????????????...???????????= =
int main()
{
	char a[45];
	int m,n;	//m?????n????
	int count=0;
	cin>>m;
	n=m+1;		//??n???
	for(int i=1;i<=m;i++)
	{
	cin>>a;
		if(count==0)
			{cout<<a;
			count=strlen(a);
			}
		else if(count+strlen(a)+1<80)
		{
		cout<<" "<<a;
		count=count+strlen(a)+1;
		}
		else if(count+strlen(a)+1==80)
		{
		cout<<" "<<a<<endl;
		count=0;
		}
		else
			{
			 cout<<endl;
			 cout<<a;
			 count=strlen(a);
			}
	}
	return 0;
}
int main()
{
  int n,i,m=0;
  char word[1000][20];
  scanf("%d",&n);
  for(i=0;i<=n-1;i++)
  {
	  scanf("%s",word[i]);
  }
  for(i=0;i<=n-1;i++)
  {
	  if(m<=80-strlen(word[i]))
	  {
		  printf("%s",word[i]);
		  if(m<=79-strlen(word[i])-strlen(word[i+1])&&i<n-1)
		  printf(" ");
          m+=strlen(word[i])+1;
	  }
      else
	  {
		  i=i-1;
		  printf("\n");
		  m=0;
	  }
	  
  }
  return 0;
}
int main()
{
    int i,n,sum=0,length[1000];
    char word[1000][50];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                    scanf("%s",word[i]);
                    length[i]=strlen(word[i]);
    }
    for(i=0;i<n-1;i++)
    {
                    if(sum+length[i]<=80)
                    {
                                         if(sum+length[i]+length[i+1]+1<=80)
                                         {
                                                                            printf("%s ",word[i]);
                                                                            sum+=length[i]+1;
                                         }
                                         else
                                         {
                                             printf("%s\n", word[i]);
                                             sum=0;
                                         }
                                         
                    }                                         
                    
    }
    printf("%s", word[n-1]);
    return 0;
}
void main()
{
	int i,n,sum=0,m;
	char word[40];
	scanf("%d",&n);
	printf("\n");
	for(i=1;i<=n;i++)
	{
		scanf("%s",word);
		m=strlen(word)+1;
		sum=sum+m;
		if((sum>81)||(i==1))
		{
			printf("\n");
			sum=m;
			printf("%s",word);
		}
		else
		    printf(" %s",word);
	}
	printf("\n");
}
/*
 * Typesetting.cpp
 *
 *  Created on: 2013-12-5
 *      Author: KEVIN
 */


int main()
{
	int n;
	cin>>n;
	char line[81];
	char* p=line;
	memset(line,'\0',81);
	while(n--)
	{
		char word[41];
		cin>>word;
		int len=strlen(word);
		if(strlen(line)+len>80)
		{
			*(p-1)='\0';//?line???????'\0'
			cout<<line<<endl;
			memset(line,'\0',81);
			p=line;
		}
		memcpy(p,word,len);
		p+=len;
		*p++=' ';
	}
	if(strlen(line)>0)
	{
		*(p-1)='\0';
		cout<<line;
	}
	return 0;
}
int main()
{
	int n,i,len[1000];
	char word[1000][41];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>word[i];
		len[i]=strlen(word[i]);
	}
	int m=0,j=0;
	while(m<=80&&j<n)
	{
		if((m+len[j]<=80)&&(j<n-1))
		{
			m=m+len[j]+1;
			cout<<word[j];
			if(m+len[j+1]<=80)
				cout<<" ";
			j++;
		}
		if((m+len[j]<=80)&&j==n-1)
		{
			cout<<word[j]<<endl;
			break;
		}
		if(m+len[j]>80)
		{
			cout<<endl;
		    j=j;
			m=0;
		}
	}
	return 0;
	;
}
int n;//?????
char words[1000][100];//?????????
int wordlen[1000],longsum=0;//?????????
void out(int location)
{
	int i,j;
	for(i=location;i<n;i++)
	{
		longsum=longsum+wordlen[i]+1;
		if(longsum-1>80)
		{
			for(j=location;j<=i-2;j++)
				cout<<words[j]<<' ';
			cout<<words[i-1]<<endl;
			break;
		}
		if(longsum-1==80)
		{
			for(j=location;j<=i-1;j++)
				cout<<words[j]<<' ';
			cout<<words[i]<<endl;
			i++;
			break;
		}
		if(i==n-1)
		{
			for(j=location;j<n-1;j++)
				cout<<words[j]<<' ';
			cout<<words[n-1]<<endl;
			return;
		}
	}
	longsum=0;
	location=i;
	out(location);
}
int main()
{	
	int i,j;//????
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>words[i];
		wordlen[i]=strlen(words[i]);
	}
	out(0);
	return 0;
}
int main()
{
	char words[400][50];
	int n;
	cin >> n;
	int i;
	int counter = 0;
	for( i = 0 ; i <= n - 1 ; i ++ )
		cin >> words[i];
	char (*p)[50];
	for( p = words ; p <= words + n - 2 ; p ++ )
	{
		counter = counter + strlen( * p );
		if( counter < 80 )
		{
			if( counter + 1 + strlen( * ( p + 1 ) ) <= 80 )
			{
				cout << *p << " ";
				counter ++;
			}
			else
			{
				cout << *p << endl;
				counter = 0;
			}
		}
		else if( counter == 80 )
		{
			cout << *p << endl;
			counter = 0;
		}
		else
		{
			cout << endl << *p ;
			counter = strlen( *p );

		}
	}
	counter = counter + strlen( * p );
	if( counter <= 80)
		cout << *p;
	else
		cout << endl << *p;



	return 0;
}
main()
{
    int n;
    scanf("%d",&n);
    char word[n][41];
    for(int i=0;i<n;i++)
    {
        scanf("%s",word[i]);
    }
    int l=0;
    for(int i=0;i<n;i++)
    {
        if(l==0)
        {
            printf("%s",word[i]);
            l+=strlen(word[i]);
        }
        else
        {
            l+=strlen(word[i])+1;
            if(l<81)
                printf(" %s",word[i]);
            else
            {
                printf("\n");
                l=0;
                i--;
            }
        }
    }
}
/*
 * homework.cpp
 *
 *  Created on: 2011-12-5
 *      Author: luo
 */
int main()
{
	int n,i,j,totallenth=0,record=0;     //totallenth??????????record??????????
	int *p;
	cin>>n;
	p=&n;
	int lenth[*p];    //?????????
	char str[*p][41];    //??????
	for(i=0;i<n;i++)   //?????????
	{
		cin>>str[i];
		lenth[i]=strlen(str[i]);
	}
	for(i=0;i<n;i++)       
	{
		totallenth+=lenth[i]+1;       //?????????????????????????????????
		if(totallenth>81)         //????????????81?????????????????
		{
			for(j=record;j<=i-1;j++)    
				{
				cout<<str[j];
				if(j!=i-1)
					cout<<' ';
				else {cout<<endl;
				}
				}
			totallenth=lenth[i]+1;    //?totallenth???????????
			record=i;        //?????????????
		}
		if(i==n-1&&record!=i)    //???????????????????????
		{
			for(j=record;j<=i;j++)
				{
				cout<<str[j];
				if(j!=i)
					cout<<' ';
				else cout<<endl;
				}
		}
	}
	return 0;
}
int main()
{
	int n; cin >> n;
	int t = 2;
	char initial[40];
	cin >> initial;
	cout << initial;
	int count = strlen(initial);
	int mark = 1;
	while (t <= n)
	{
		char word[41];
		cin >> word;
		int lenth = strlen(word);
		count+= lenth;
		if (count + t - mark> 80)
		{
			/*for (int i = 0; i < lenth; i++)
			{
				temp[i] = word[i];
			}
			temp[lenth] = '\0';*/
			cout << endl;
			cout << word;
			count = lenth;
			mark = t;
		}
		else
			cout << " " << word;
		t++;
	}
	cout << endl;
	return 0;
}
/*
 * wenzi.cpp
 *
 *  Created on: 2012-12-7
 *      Author: ada
 */
int main()
{
	int n ;
	cin>>n;
	char a[1000][41];
	for(int i = 0 ; i <= n ; i++)
	{
		cin>>a[i];
	}
	int len = (int)strlen(a[0]) ;

	cout<<a[0];
	 for(int i  = 1 ; i < n ; i++)
	 {
		 len = len + (int)strlen(a[i])+1;
		 if(len<=80)
		 {

			 cout<<" "<<a[i];
		 }
		 else
		 {
			 cout<<endl<<endl<<a[i];
			 len = (int)strlen(a[i]);

		 }
	 }
	 return 0 ;
}
int main(){
	int i,n,len;
	int sum=0;
	char dw[1000][41];
	scanf("%d",&n);
    for(i=0;i<n;i++){
		scanf("%s",dw[i]);
		len=strlen(dw[i]);
	
		if(sum+len+1>80){
			printf("\n");
			sum=0;
		}else{
			if(i>0){
			   printf(" ");
			   sum++;
			}
		}
		printf("%s",dw[i]);	
		sum+=len;
	}
	return 0;
}
/*??????????????????????????????????????????????????????
 * ?????80???????????????????????????????????????????
 *????: 2012-12-10
 *??: ??
 */
int main() {
	char word[300][41];
	int i, n, len;
	cin >> n >> *(word + 0);
	cout << *(word + 0);
	len = strlen(*(word + 0));
	for (i = 1; i < n; i++) {
		cin >> *(word + i);
		if (len + strlen(*(word + i)) < 80) {  //??????????
			cout << ' ' << *(word + i);
			len += strlen(*(word + i)) + 1;
		} else {  //??
			cout << endl << *(word + i);
			len = strlen(*(word + i));
		}
	}
	return 0;
}
//********************************
//*???????   **
//*?????? 1300012713 **
//*???2013.12.11  **
//********************************
int main()
{
	int n, m = 0, b[300] = {0};
	char a[300][40];
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		b[i] = strlen(a[i]);
	}
	for(int j = 1; j <= n; j++)
	{
		m = m + b[j] + 1;
		if(m <= 81)
		{
			cout << a[j];
			if(j < n && m + b[j+1] < 81) cout << " ";
		}
		else 
		{
			m = 0;
			cout << "\n";
			j--;
		}
	}
	return 0;
}
int main(){
    int n,i,x,linelen=0;
    char words[40];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
            scanf("%s",words);
            if (linelen==0)
            x=strlen(words);
            else
            x=strlen(words)+1;
            if(linelen==0)
            {
                printf("%s",words);
                linelen+=x;
            }
            else if((linelen+x)<80)
            {
                printf(" %s",words);
                linelen+=x;
            }
            else if((linelen+x)==80)
            {
                printf(" %s\n",words);
                linelen=0;
            } 
            else if((linelen+x)>80)
            {
                 printf("\n%s",words);
                 linelen=x;
                 linelen--;
            }
    }

    return 0;    
}
main()
{
    char word[41];
    int sum=0,n,t;
    scanf("%d",&n);
    t=n;
    while(n>0)
    {
        scanf("%s",word);
        if((sum+strlen(word)+1<=80)&&n!=t)
        {
            printf(" ");
            sum++;
        }
        else
        {
            printf("\n");sum=0;
        }
        sum=sum+strlen(word);
        printf("%s",word);
        memset(word,0,sizeof(word));
        n--;
    }
}
void main()
{
	char a[1000][100];
	int n,i,j=0,k=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{	scanf("%s",a[i]);
		if(strlen(a[i])+1>80-j) {  printf("\n");j=0;k++;  }
		if(j){printf(" ");j++;}
		printf("%s",a[i]);j+=strlen(a[i]);
	}	
}
int main(int argc, char* argv[])
{
	char a[1000][41];
	int p=0,i=0,n;
	/*gets(a[0]);
	printf("%d",strlen(a[0]));*/
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s",a[i]);
	for(i=0;i<n;i++)
	{
		if(p==0)
		{
			printf("%s",a[i]);
			p=p+strlen(a[i]);
		}
		else if(p+1+strlen(a[i])<=80)
		{	
			printf(" %s",a[i]);
			p=p+strlen(a[i])+1;
		}
		else
		{
		/*	printf("(%i)",p);*/
			p=0;
			i--;
			printf("\n");
		}
	}
}
int main()
{
	char a[1000][40];
	int n,m,i,b[1000];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=strlen(a[i])+1;
	}
	m=b[0];
	for(i=0;i<n;i++)
	{
		m+=b[i+1];
		if(m<=81&&i!=n-1)
			cout<<a[i]<<" ";
		else
		{
			cout<<a[i]<<endl;
			m=b[i+1];
		}
	}
	return 0;
}
int main()
{
	int n;
	char word[40]={0};
	cin>>n;cin.get();
	int end=0;
	for(int i=1;i<=n;i++)
	{
	    scanf("%s",word);
	    int l=strlen(word);
		if(end+l+1>80)
		{
			cout<<endl;
			cout<<word;
			end=l;
		}
		else 
		{
			if(i>1)
			{
			    cout<<' ';
			    end++;
			}
			cout<<word;
			end=end+l;
		}
	}
	return 0;
}
int main()                                   //?????
{
	int n,i,j=0;
	char word[40];
	char first[40];
	int sum[1000]={0};
	cin>>n;                             //??????
	for(i=1;i<=n;)
	{
		scanf("%s",first);        //???????
		i++;                        //??????
		sum[j]=sum[j]+strlen(first)+1;  //??????
		cout<<first;                   //???????
		for(;sum[j]<=81;)           //????
		{	scanf("%s",word);    //????
		    i++;                     //??????
		    sum[j]=sum[j]+strlen(word)+1;
		    if(sum[j]<=81)
		    cout<<" "<<word;           //?????????
		    else
		    {j++;                       //????
			cout<<endl;             //??
			cout<<word;             //????
			sum[j]=sum[j]+strlen(word)+1;
		    }
            if(i-1==n)
            	break;                      //????
		 }
		if(i-1==n)     
			break;                 //????

	}
	return 0;                     //????
}
int main()
{
	char a[50];
	char *p = NULL;
	int i,len = 0,l,n,num = 0;
	p = a;
	cin >> n;
	while(cin >> a)
	{
		
		l = strlen(a);
		num ++;
		len += l;
		if ( len > 80 )  
		{
			cout << endl; 
			len = l;
			num = 1;
		}
		else if( num != 1 ) cout <<' ';
		for ( i = 0; i < l; i ++ )
		{
			cout<<*(p + i);
		}
		len ++;
	}
	return 0;
}
int main()
{
	int n, i, sum = 0, len;
	char c[10000][41];
	cin >> n;
	for(i = 0;i < n;i++)
		cin >> c[i];
	 for(i = 0;i < n;i++)
	 {
		 len = strlen(c[i]);
		 if(sum + len > 80)
		 {
			 sum = 0;
			// cout << endl;
			 cout << c[i] <<' ';
		 }
		 else if(sum + len < 80)
		 {
			 sum = sum + len + 1;
			 len = strlen(c[i+1]);
			 if(sum + len > 80)
			 {
				 sum = 0;
				 cout << c[i];
				 cout << endl;
			 }
			 else if(sum + len < 80) 
			 {
				 if(i == n-1)  cout << c[i];
				 else cout <<c[i] <<' ';
			 }
		 }
		 else if(sum + len == 80)
		 {
			 sum = 0;
			 cout << c[i-1] <<' '<< c[i] << endl;
		 }
	 }
	 return 0;
}
int main()
{
	int n,i,len[1000];
	char word[1000][41],(*p)[41]=word;
	
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>*(p+i);
		len[i]=strlen(*(p+i));
	}
	int m=0,j=0;
	while(m<=80&&j<n)
	{
		if((m+len[j]<=80)&&(j<n-1))
		{
			m=m+len[j]+1;
			cout<<*(p+j);
			if(m+len[j+1]<=80)
				cout<<" ";
			j++;
		}
		if((m+len[j]<=80)&&j==n-1)
		{
			cout<<*(p+j)<<endl;
			break;
		}
		if(m+len[j]>80)
		{
			cout<<endl;
		    j=j;
			m=0;
		}
	}
	return 0;
}
int main()
{
	int n=0,line=80;
	cin>>n;
	getchar();
	while(n>0)
	{
		int changdu=1;
		char a[50]={'\0'};
		char *p=NULL;
		p=a;
		char d='\n';
		while(d=='\n')d=getchar();		
		*p=d;
		while(true)
		{
			d=getchar();
			if(d==' '||d=='\n')break;
			changdu++;
			p++;
			*p=d;			
		}
		p=a;
		int i;
		//for(i=1;i<=changdu;i++){cout<<*p;p++;}
		//cout<<endl<<changdu<<endl;

		if(changdu<line)
		{
			if(line!=80){cout<<" ";line--;}
			for(i=1;i<=changdu;i++){cout<<*p;p++;}
			line=line-changdu;
			if(line==0)
			{
				cout<<endl;
				line=80;
			}			
			
		}
		else
		{
			cout<<endl;
			for(i=1;i<=changdu;i++){cout<<*p;p++;}
			line=80-changdu;

		}
		

	n--;	
	}
	
	
	return 0;
}
int main()
{
    char str[400][45];
    int len[400];
    int *p;
    int k=0,sum=0;
    p=len;
    int n,i,j;
    cin>>n;
    for(i=0;i<=n-1;i++)
      cin>>str[i];
      
    for(i=0;i<=n-1;i++)  
    {
      len[i]=strlen(str[i]);                       
    }
    i=0;sum=0;k=0;
    
    while(i<=n-1)
    {
       if(k==0)
      {
       cout<<str[i];
       k++;
       sum=len[i]+sum;
       i++;
       } 
      else
      {
        if(sum+1+len[i]<=80)
        {
        cout<<" "<<str[i]; 
        k++;
        sum+=(1+len[i]);
        i++;          
        }  
        else
        {
         cout<<endl;
         k=0;sum=0;    
        }  
      }                  
                                     
    }
    
    
    
return 0;    
}
int main(){
	int n,i,len;
	char a[1000][41];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
	}
	len=strlen(a[0]);
	printf("%s",a[0]);
	for(i=1;i<n;i++){
		len+=1+strlen(a[i]);
		if(len<=80){
			printf(" %s",a[i]);
		}
		if(len>80){
			printf("\n%s",a[i]);
			len=strlen(a[i]);
		}
	}
	return 0;
}
int main()
{
	int n=0;
	cin>>n;
	char b[2];
	cin.getline(b,2);
	char a[5000];
	cin.getline(a,5000);
	char *p=NULL,*q=NULL;
	int sum=0,single=0;//????????????
	for(p=a;*p!=' ';p++)
		cout<<*p;
	sum=p-a;
	for(int i=1;i<n;i++){
		single=0;
		q=p+1;
		for(p++;*p!=' '&&*p!='\0';p++)
			single++;
		sum+=single+1;
		if(sum<=80)cout<<' ';
		else {
			cout<<endl;
			sum=single;
		}
		if(i<n-1){
			for(;*q!=' ';q++)
				cout<<*q;
		}
		else {
			for(;*q!='\0';q++)
				cout<<*q;
		}
	}
	return 0;
}
int main(int argc, char *argv[])
{
  char a[50];
  int n,i,j,line,l;
  scanf("%d",&n);
  scanf("%s",a);
  printf("%s",a);
  line=strlen(a);
  for(i=2;i<=n;i++)
  {
      scanf("%s",a);
      line+=strlen(a)+1;
      if(line<=80)
      {
          printf(" %s",a);
      }
      else
      {
          printf("\n%s",a);
          line=strlen(a);
      }
  }

  return 0;
}
int main()
{
	char a[500][45];
	int n,m=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>*(a+i);
	for(int i=0;i<n-1;i++)
	{
		cout<<*(a+i);
		m+=strlen(*(a+i));
		if(m+1+strlen(*(a+i+1))<=80)
		{
			cout<<" ";
			m++;
		}
		else    
		{
			cout<<endl;
			m=0;
		}
	}
	cout<<*(a+n-1);
	return 0;
}
//********************
//**???????	**
//**?????		**
//**???2013.12.14**
//**????2.cpp	**
//********************
int main()
{
	char word[1000][40];
	int n, i, g, temp = 1, cnt[1000] = {0};
	cin >> n; // ??????
	for (i = 1; i <= n; i++)
		cin >> word[i]; // ?????????
	for (i = 1; i <= n; i++)
	{
		*(cnt +  i) = *(cnt + i - 1) + strlen(word[i]); // ??????????

		// ???????80???????????????????????????????????????????????
		if ((*(cnt + i - 1) <= 81 && *(cnt + i) >= 81) || i == n)
		{
			for (g = temp; g < i- 1; g++) // ??????????
				cout << word[g] << ' ';
			cout << word[i - 1];
			if (i < n)
				cout << endl;
			else
			{
				cout << ' '  << word[i] << endl;
				break;
			}
			temp = i;
			*(cnt +  i - 1) = 0; // ????????????0
			i--; // i?1????????
		}
		else
			(*(cnt + i))++; // ????????
	}
	return 0;
}
int main()
{
	char a[100000];
	int n=0,j=0,i=0,sum=0,j1=0,j2=0;
	cin>>n;
	//cout<<n;
	cin.get();
	cin.getline(a,100000);
	//cout<<'f';
	while(a[i]!='\0')
	{i++;
		sum++;}
	while(sum-j>80)
	{j1=j;
	j=j+80;
	j2=j;
	
	
		while(a[j]!=' ')
			j--;
		if(j==j2)
			for(i=j1;i<j;i++)
				if(i==j-1)
					cout<<a[i]<<endl;
				else
				cout<<a[i];
		else
		for(i=j1;i<j;i++)
			if(i==j-1)
				cout<<a[i]<<endl<<endl;
			else
				cout<<a[i];
		j=j+1;
	}
	for(i=j;i<sum;i++)
		if(i==sum-1)
			cout<<a[i];
		else
		cout<<a[i];
	return 0;
}
char a[100000][50];
int main()
{int n=0;
cin>>n;
for (int i=1;i<=n;i++)scanf("%s", a[i]);
int s=0;

for (int i=1;i<=n;i++)
 {
      
      if (s+strlen(a[i])<=80)
       {
        if (s+strlen(a[i])+strlen(a[i+1])+1<=80){cout<<a[i];if (i!=n)cout<<' ';s+=strlen(a[i]);s++;}
        else if (s+strlen(a[i])+strlen(a[i+1])+1>80){cout<<a[i]<<endl;s=0;}
       }
      else if (s+strlen(a[i])>80)
      {cout<<endl<<a[i]<<' ';s=strlen(a[i]);s++;}
    
   
 }
return 0;
}
main()
{
      int i,j,count[20000]={0},s=0,n,m=0;
      char a[20000][50]={'\0'};
      scanf("%d\n",&n);
      for(i=0;i<n-1;i++)
      {
                       for(j=0;j<50;j++)
                       {
                                        scanf("%c",&a[i][j]);
                                        if(a[i][j]==' ')break;
                                        count[i]++;
                       }                
      }
      scanf("%s",a[n-1]);
      for(i=0;i<50;i++)
      {
                       if(a[n-1][i]!='\0')count[n-1]++;
                       else break;
      }
      for(i=0;i<n-1;i++)
      {
                      if(m+count[i]<80 && m+count[i]+1+count[i+1]<=80)
                      {
                                       for(j=0;j<count[i];j++)
                                       {
                                                              printf("%c",a[i][j]);
                                       }
                                       printf(" ");
                                       m=m+count[i]+1;
                      }
                      else if(m+count[i]<80 && m+count[i]+1+count[i+1]>80)
                      {
                           for(j=0;j<count[i];j++)printf("%c",a[i][j]);
                           m=m+count[i]+1;
                      }
                      else if(m+count[i]==80)
                      {
                           for(j=0;j<count[i];j++)printf("%c",a[i][j]);
                           printf("\n");
                           m=0;
                      }
                      else if(m+count[i]>80)
                      {
                           printf("\n");
                           for(j=0;j<count[i];j++)printf("%c",a[i][j]);
printf(" ");
                           m=count[i]+1;
                      }
      }
for(i=0;i<count[n-1];i++)printf("%c",a[n-1][i]);
}
int main ( )
{
	int n ;                     //??????	
	cin >> n ;
	char a[10000][41] ;         //????????????????? 
	int t[10000] ;              //???????????
	char (*p)[41] ;             //???????? 
	int i ;                     //??????
	p = a ;
	for( i = 0 ; i <= n - 1 ; i++ )
	{
		cin >> *(p+i) ;
		t[i] = strlen(*(p+i)) ;
	}
	p = a ;
	int s = 0 ;                 //?????????? 
	int flag1 = 0 ;             //??????????
	int flag2 = 0 ;             //????????80?????
	for( i = 0 ; i <= n-1 ; i++ )
	{
		s += t[i] ;
		if( s > 80 )
		{
			flag2 = i ;          //????80????????
			for( i = flag1 ; i <= flag2 - 2 ; i++ )
			{
				cout << *(p+i) << " " ;
			}                 
			cout << *(p-1+flag2) << endl ;
			                     //?????????????????????  
			flag1 = i + 1 ;      //?????????????????????
			s = 0 ;              //???????s?? 
		}
		else
			s += 1 ;             //???80??????????
	}
	for( i = flag1 ; i <= n-2 ; i++ )
	{
		cout << *(p+i) << " " ;
	}                
	cout << *(p+n-1) << endl ;   //????????
	return 0 ;
}