semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
struct words
{
     int len;
     char word[20];
};
int main()
{
   int n,i,size,count=0;;
   struct words *a;
   scanf("%d",&n);
   a=(struct words *)malloc(sizeof(struct words)*n);
   for (i=0;i<n;i++)
   {
       size=0;
       scanf("%s",&(a+i)->word);
       for (size=0;(a+i)->word[size]!='\0';size++);
       (a+i)->len=size;
    }
    count=0;
    for (i=0;i<n;i++)
     {
         if (count+(a+i)->len+1>80)
         {
             printf("\n");
             count=0;
             i--;
         }
         else
         {
            if (count==0)
            {
                printf("%s",(a+i)->word);
                count=count+(a+i)->len;
            }
            else
            {
                printf(" %s",(a+i)->word);
                count=count+(a+i)->len+1;
            }
         }
    }
}
int main()
{
	int a ;
	int newline=1;
	int sum = 0;
	char word[80]={0};
	cin >> a;
	memset(word,0,sizeof(word));
	scanf("%s",word);
	cout << word;	
	sum = strlen(word);
	while ( a > 1 )
	{
		memset(word,0,sizeof(word));
		scanf("%s",word);
		sum+=strlen(word)+1;
		if(sum <= 80)
		{
			cout <<' '<< word;//<<"sum="<<sum<<endl;

		}
		else
		{
			cout << endl << word;
			sum = strlen(word);
		}
		a--;
	}
		return 0;
}
int main()
{
	int n,i,j=1;
	char w[500][100];
	int l[500],s[100];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%s",w[i]);
		l[i]=strlen(w[i]);
	}
	//for(i=1;i<=n;i++)
	//{
	//	printf("%s ",w[i]);
	//	printf("%d ",l[i]);
	//}
	for(i=0;;i++)
	{
		printf("%s",w[j]);
		s[i]=l[j];
		j++;
		if(j==n+1)
			break;
		while(s[i]+l[j]+1<=80)
		{
			printf(" %s",w[j]);
			s[i]=s[i]+1+l[j];
			j++;
			if(j==n+1)
				break;
		}
		printf("\n");
		if(j==n+1)
			break;
	}
	return 0;
}
int main(int argc, char* argv[])
{int n;
scanf("%d",&n);
int i;
int k=0,m=0;
char s[45];
int len;
for(i=0;i<n;i++)
{
	scanf("%s",s);
	len=strlen(s);
	k=k+len;
	m++;
	if(m==1)
	{printf("%s",s);}
	else
	{
	if((k+m-1)<=80)
	{ printf(" ");
	printf("%s",s);
	}
	else
	{printf("\n");
	printf("%s",s);
	k=len;
	m=1;}
	}
}
return 0;
}
int main(){
  int i,n,t;
  char a[1000][40];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",a[i]);
  }
  t=0;
  for(i=0;i<n-1;i++){
    if(strlen(a[i])+t>80){
      printf("\n%s",a[i]);
      t=strlen(a[i])+1;
    }
    else if(strlen(a[i])+t<=80){
      if(t+strlen(a[i])+1+strlen(a[i+1])<=80){
        printf("%s ",a[i]);
        t=t+strlen(a[i])+1;
      }else{
        printf("%s\n",a[i]);
        t=0;
      }
    }
  }
  printf("%s",a[n-1]);
  return 0;
}
int main()
{
	int n, i;
	cin >> n;
	char word[1000][41];
	int temp = 0;
	for(i = 0; i < n; i++)
	{
		cin >> word[i];
	}
	for(i = 0; i < n - 1; i++)
	{
		if(temp + strlen(word[i]) + strlen(word[i + 1]) + 1 <= 80)
		{
			cout << word[i] << ' ';
			temp = temp + strlen(word[i]) + 1;
		}
		else
		{
			cout << word[i] << endl;
			temp = 0;
		}
	}
	cout << word[n - 1]; 
	return 0;
}
/*
 *  Name:homework.cpp
 *  Created on: 2012-12-10
 *  Author: Meng Li
 *  Function:????
 */


int main(){                            //???
	int n, i;
	cin >> n;
	char *start;
	char *temp;
	temp=start;
	for (i=0;i<n;i++){
		char word[40];
		cin >> word;
		int length=strlen(word);
		if (temp-start+length<80){
			if (temp-start!=0){
				cout << ' ';
				temp++;
			}
			cout << word;
			temp=temp+length;
		}
		else{
			start=temp;
			cout << endl;
			cout << word;
			temp=temp+length;
		}
	}
	return 0;
}
/*
 * qimo_2.cpp
 * Name:????
 *  Created on: 2011-1-9
 *      Author: Wang Ju
 */

int main() {
	int l = 0, n;
	char *p=NULL;
	char s[2000], a[10];
	cin >> n;
	cin.getline(a, 10);
	l = 0;
	cin >> s;
	p = s;
	cout << p;
	l = strlen(s);
	while (n > 1) {
		cin >> s;
		l = l + strlen(s);
		p = s;
		if (l == 80) {
			cout << "\n" << p;
			l = strlen(s);
		} else {
			if (l < 80) {
				cout << " " << p;
				l++;
			} else if (l > 80) {
				cout << "\n" << p;
				l = strlen(s);
			}
		}
		n--;
	}
	return 0;
}
void main()
{
	char s[1000][40];
	int n,len=0,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s",s[i]);
	len=strlen(s[0]);
	for(i=0;i<n-1;i++)
	{
		len=len+strlen(s[i+1])+1;
		if(len>80)
		{
			len=strlen(s[i+1]);
			printf("%s",s[i]);
			printf("\n");
		}
		else
			printf("%s ",s[i]);
	}
	printf("%s",s[n-1]);
}
struct word
{
	char vol[40];
	int len;
	struct word * next;
};
struct word * create(int n)
{
	struct word *p1,*p2,*head;
	int i;
	for(i=0;i<n;i++)
	{
		p1=(struct word *)malloc(sizeof(struct word));
		scanf("%s",&p1->vol);
		p1->len=strlen(p1->vol)+1;
		if(i==0)
		{
			head=p1;
			p2=p1;
		}
		else
		{
			p2->next=p1;
			p2=p1;
		}
	}
	p1->next=NULL;
	return head;
}
void print(struct word * head,int n)
{
	struct word * pa;
	int count=0;
	pa=head;
	while(n)
	{
		if(count==0)
		{
			printf("%s",pa->vol);
			count+=pa->len;
			pa=pa->next;
			if(pa)
			count+=pa->len;
		}
		else if(count<=81&&count!=0)
		{
			printf(" %s",pa->vol);
			pa=pa->next;
			if(pa)
			count+=pa->len;
		}
		else if(count>81)
		{
			printf("\n%s",pa->vol);
			count=pa->len;
			pa=pa->next;
			if(pa)
			count+=pa->len;
		}
		n--;
	}
}
int main()
{
	int n;
	struct word * head;
	scanf("%d",&n);
	head=create(n);
	print(head,n);
	return 0;
}
int main()
{
	char a[1000][42];
	int n,len[1000],sum=0;
	cin>>n;
	int i;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		len[i]=strlen(a[i]);
	}
	for(i=0;i<n;i++)
	{
		if(sum+len[i]<=80)
		{
			cout<<a[i];
			sum+=len[i];
			if(sum+1+len[i+1]<=80)
			{
				if(i!=n-1)
				{
				cout<<' ';
				sum++;
				}
			}
			else
			{
				cout<<endl;
				sum=0;
			}
		}
	}
	cout<<endl;
		return 0;
}
int main(){
	int N,number=0;
	cin>>N;
	const int n=N;
	char a[n][50];
	for(int i=0;i<=n-1;++i)
		cin>>*(a+i);
	for(int i=0;i<=n-1;++i){
		if(number+strlen(*(a+i))<=80){
			if(i==0) cout<<*(a+i);
			if(i!=0) cout<<' '<<*(a+i);
			number+=1+strlen(*(a+i));
		}
		else {
			number=0;
			cout<<endl;
			cout<<*(a+i);
			number+=1+strlen(*(a+i));
		}
	}
	return 0;
}
int main ()
{
	char a[1000][41] = {'\0'};                       //???????
	int i = 0, j = 0, n = 0;
	cin >> n;
	for(i = 0; i < n; i ++)
		cin >> *(a+i);                               //????
	int sum = 0;
	for(i = 0; i < n; i ++)
	{
		if(sum == 0)                                 //?????????
		{
			cout << *(a + i);
			sum = sum + strlen(*(a + i));
		}
		else if (sum == 80)                          //??????80???
		{
			cout << endl;
			sum = 0;
			i --;
		}
		else if (sum + strlen(*(a + i))  >= 80)      //?????????????80
		{
			cout << endl ;
			sum = 0;
			i --;
		}
		else                                         //?????
		{
			cout << ' ' << *(a + i);
			sum = sum + strlen(*(a + i)) + 1;
		}
	}

	return 0;
}
int main()
{
	int n,i,len[9999],j,total=0,k=0;
	char x[9999][43];
	char (*p)[43]=x;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",p+i);
		len[i]=strlen(x[i]);
	}
	for(i=0;i<n;i++)
	{
		total=total+len[i];
		if(total+i-k>80)
		{
			for(j=k;j<i-1;j++)
				printf("%s ",p+j);
			printf("%s\n",p+i-1);
			k=i;
			i=i-1;
			total=0;
		}
	}
	if(k<n)
	{
		for(i=k;i<n-1;i++)
			printf("%s ",p+i);
		printf("%s",p+n-1);
	}
		return 0;
}
int main()
{
	int n ;
	cin >> n ;
	char paper[500][50] ;
	for ( int i = 0 ; i < n ; i++ )
		cin >> * ( paper + i ) ;
	int l = 81 ;
	for ( int i = 0 ; i < n ; i++ )
	{
		if ( l + strlen( * ( paper + i ) ) + 1 <= 80 )//???????
		{
			cout << ' ' << * ( paper + i ) ;
			l = l + strlen( * ( paper + i ) ) + 1 ;
		}
		else//???????
		{
			cout << endl ;
			cout << * ( paper + i ) ;
			l = strlen( * ( paper + i ) ) ;
		}
	}

	return 0 ;
}
// ( > w < ) finished~
char word[1000][41];
int n;


int main()
{
	cin >>n;
	for(int i = 0;i < n; i ++)
		cin >> word[i];
	int count = 0;
	int p = 0;

	while(p < n)
	{
		int len = strlen(word[p]);
		if(count == 0)
		{
			printf("%s", word[p]);
			p ++;
			count += len;
		}
		else if(len + 1 + count <= 80)
		{
			printf(" %s", word[p]);
			p ++;
			count += len + 1;
		}
		else if(len + 1 + count > 80)
		{
			printf("\n");
			count = 0;
		}
		else
			printf("ERROR!-----------------------------------");
	}
	return 0;
}
int main()
{
	int n;
	struct W{
		char word[100];
		int len;
	}w[520];
	int i,m,j;
	scanf("%d",&n);
	m=0;
	for (i=0;i<n;i++)
	{
		
		scanf("%s",w[i].word);
		w[i].len=0;
		for (j=0;w[i].word[j]!='\0';j++)
		{
			w[i].len++;
		}
	
	}
	for (i=0;i<n;i++)
	{
		m=m+w[i].len+1;
		if (i==n-1){
			if (m<=81)
				printf("%s",w[i].word);
			else {
				printf("\n");
				printf("%s",w[i].word);
			}
			}
	else if (m<80 && m+w[i+1].len<81)
		printf("%s ",w[i].word);
	else if (m>81)
		{
			printf("\n");
			printf("%s ",w[i].word);
			m=w[i].len+1;
		}
	else
	{
		printf("%s\n",w[i].word);
		m=0;
	}
	}
	return 0;
}
int main(){
	char str[1000][100]={0};
	int n,num[1000]={0},sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
	cin>>*(str+i);
	for(int j=0;*(*(str+i)+j)!=0;j++)(*(num+i))++;
	}
	cout<<*str;sum=*(num);
	for(int i=1;i<n;i++){
		sum+=*(num+i)+1;
		if(sum>80){cout<<endl<<*(str+i);sum=*(num+i);}
		else if(sum==80){cout<<' '<<*(str+i)<<endl<<*(str+i+1);sum=*(num+i+1);i++;}
		else{cout<<' '<<*(str+i);}
	}
	return 0;
}
int main()
{
	char s[1000][45];
	int n,i,j,k;
	int sum;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",s[i]);
	}
	sum=0;
	for(i=0;i<n-1;i++)
	{
		k=sum+strlen(s[i]);
		if(k<80)
		{
			if((k+1+strlen(s[1+i]))>80)
			{
				printf("%s\n",s[i]);
                sum=0;
			}else
			{
				printf("%s ",s[i]);
				sum+=strlen(s[i])+1;
			}
		}else
		{
			if(k==80)
			{
				printf("%s\n",s[i]);
				sum=0;
			}
		}
	}
	printf("%s",s[n-1]);
	return 0;
}
int main()
{
    int l=0,i,n;
    char word[1500][50];
    cin>>n;
    for(i=0;i<n;i++)
    	cin>>word[i];
    for(i=0;i<n-1;i++)
    {
    	if(l+strlen(word[i])==80)
    	{
    		l=0;
    		cout<<word[i]<<endl;
    	}
    	else if(l+strlen(word[i])<80)
    	{
    		if(l+strlen(word[i])+1+strlen(word[i+1])<=80)
    		{
    			cout<<word[i]<<' ';
    			l=l+strlen(word[i])+1;
    		}
    		else
    		{
    			cout<<word[i]<<endl;
    			l=0;
    		}
    	}
    }
    cout<<word[i];
	return 0;
}
int main(){
	int n,i,len=0;
	scanf("%d",&n);
	char word[1000][40];
	for(i=0;i<n;i++){
		scanf("%s",word[i]);
	}
	for(i=0;i<n;i++){
		len+=strlen(word[i]);
		if(len<=80){
			printf("%s",word[i]);
			len++;
			if(i!=n-1&&len+strlen(word[i+1])<=80){
				printf(" ");
			}
		}else{
			printf("\n%s ",word[i]);
			len=strlen(word[i])+1;
		}
	}
	return 0;
}
char a[10000],tmp[40],cn;
int n,i,j,l=0,tmpl=0;

int main(int argc, char* argv[])
{
	
	gets(&cn);
	n=atoi (&cn);
	gets(a);
    for (i=0;i<n;i++)
	{
		for (j=0;j<40;j++)
		{
			if (a[j+l]!=' ')
			{
				tmp[j]=a[j+l];
			}
			else 
			{
				tmp[j]='\0';
				j=40;	
			}
		}
		l+=strlen(tmp)+1;
        l:if (tmpl==0)
		{
			printf ("%s",tmp);
			tmpl+=strlen(tmp)+1;
		}
        else if ((strlen(tmp)+tmpl)<=80)
		{
			printf (" %s",tmp);
  		    tmpl+=strlen(tmp)+1;
		}
		else if ((strlen(tmp)+tmpl)>80)
		{
			printf ("\n");
			tmpl=0;
			goto l;
		}
        //printf ("%d",tmpl);
	}
	return 0;
}
int main()
{
	int n,i,m=0,j=0;
	int a[10000];
	char word[10000][40];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s",word[i]);
	for(i=0;i<n;i++)
		a[i]=strlen(word[i]);
	for(i=0,m=a[0]+1;i<n;)
	{m=m+a[i+1]+1;
    if(m>81)
	{printf("%s\n",word[i]);
	m=a[i+1]+1;i++;continue;}
	else if(m==81)
	{printf("%s%c",word[i],(i<n-1)?' ': '\n');
	printf("%s\n",word[i+1]);
	m=a[i+2]+1;
	i=i+2;
	continue;}
	else if(m==80)
	{printf("%s%c",word[i],(i<n-1)?' ':'\n');
	printf("%s\n",word[i+1]);
    m=a[i+2]+1;
	i=i+2;continue;
	}
	else
	{printf("%s%c",word[i],(i<n-1)?' ': '\n');
	i++;
	}
	}
return 0;
}
int main()
{
	int i,n,count = 0;
	char word[1000][40];
	cin >> n;
	for(i = 0 ; i < n ; i++)
	{
		cin >> word[i];
	}
	cout << word[0];
	count = count + strlen(word[0]) + 1;
	for(i = 1 ; i < n; i++)
	{
		if(count + strlen(word[i]) > 80)
		{
			cout << endl;
			count = strlen(word[i]) + 1;
			cout << word[i];
		}
		else
		{
			cout << " " << word[i];
			count = count + strlen(word[i]) + 1;
		}
	}
	return 0;
}
int main()
{
	int n, counter = 0,len;
	char a[300][50];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n ; i++)
	{
		if (counter == 0)
		{
			cout << *(a + i);
			counter += strlen(*(a + i));
		}
		else if (counter + strlen (*(a + i)) + 1 < 80)
		{
			cout << " " << *(a + i);
			counter += strlen(*(a + i)) + 1;
		}
		else if (counter + strlen (*(a + i)) + 1== 80)
		{
			cout << " " << *(a + i) << endl;
			counter =0;
		}
		else
		{
			cout << endl << *(a + i);
			counter = strlen (*(a + i));
		}
	}

	
	return 0;
}
int main(int argc,char*argv[])
{
	int n,i,m=0,t=0;
	char word[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",word);
		t+=strlen(word);
		m++;
		if(m==1){
			printf("%s",word);
		}else{
			if((t+m-1)<=80){
				printf(" ");
				printf("%s",word);
			}else{
				printf("\n");
				printf("%s",word);
				m=1;
				t=strlen(word);
			}
		}
	}
	return 0;
}
int main()
{
	char s[100];
	int n;
	cin>>n;
	int t=0;
	for (int i=0;i<n;i++)
	{
		cin>>s;
		if (t==0)
		{
			printf("%s",s);
			t+=strlen(s);
		}
		else
		{
			t+=strlen(s)+1;
			if (t<=80)
			{
				printf(" %s",s);
			}
			else
			{
				printf("\n%s",s);
				t=strlen(s);
			}
		}
	}
	
	return 0;
}
int main()
{
	int n,i,j,k,l[1000],sum;
	char a[1000][50];
	cin>>n;
	cin.get();
	for(i=1;i<=n;i++)
	{
		cin>>*(a+i);
	}
	for(i=1;i<=n;i++)
	{
		l[i]=strlen(*(a+i));
	}
	for(i=1;i<=n;i++)
	{
		sum=0;
		for(j=i;j<=n;j++)
		{
			if(sum+l[j]>80)
			{
				break;
			}
			else
			{
			  sum+=l[j]+1;
			}
		}
		if(i==n)
		{
			cout<<*(a+n)<<endl;
		}
		else
		{
          for(k=i;k<j-1;k++)
		 {
			cout<<*(a+k)<<' ';
		  }
		  cout<<*(a+j-1)<<endl;
		}
		i=j-1;
	}
	return 0;
}
int main()
{
	int n,i,l,L=-1,k=0,j;
	char before[40];//????before???????
	char word[40];//????word???????
	cin>>n;//????
	scanf("%s",word);//????
	l=strlen(word);//???????
	for(i=0;i<l;i++)
		before[i]=word[i];
	before[l]='\0';//???????????????before?
	L=l;//L?????????l
	for(i=1;i<n;i++)
	{
		scanf("%s", word);//???????????
        l=strlen(word);//???
        k=L+l+1;//?????????k
		if(k>80&&L<=80)//?k>80??L<=80??????????????
		{
			cout<<before;//??????????
		    cout<<endl;//??
			L=l;//????????l
			for(j=0;j<l;j++)
				before[j]=word[j];
			before[l]='\0';//?????????before?
		}
		else
		{
			cout<<before<<" ";//???????????
		
			for(j=0;j<l;j++)
				before[j]=word[j];
			before[l]='\0';//?????????before?
			L=k;//???????k
		}
	}
	cout<<word;//??????????
	return 0;
}
int main()
{
	int i , n , j , sum = 0 , len , sum1 ;
	char before[500][40] , c , *p ;
	cin >> n ; 
	for ( i = 0 ; i < n ; i++ )
	{
		j = 0 ;
		p = *( before + i ) ;
		while ( 1 )
		{
			c = cin.get() ;
			if ( c == ' ' || c == '\n' )
				continue ;
			else
				break ;
		}
		*p = c ;
		while ( 1 ) 
		{
			c = cin.get() ;
			if ( c == ' ' || c == '\n' )
				break ;
			else
				*++p = c ;
		}
		*++p = '\0' ;
	}
	/*	for ( i = 0 ; i < n ; i++ )
	{
		cout << before[i] << " " ;
	}*/
	for ( i = 0 ; i < n ; i++ )
	{
		len = strlen( before[i] ) ;
		sum = sum + len ;
		sum1 = sum + 1 + strlen( before[i+1] ) ;
		if ( sum > 80 )
		{
			sum = len ;
			sum1 = sum + 1 + strlen( before[i+1] ) ;
			cout << endl ;
		}
		cout << before[i] ;
		if ( i < n - 1 &&  sum1 <= 80 )
		{	
			cout << " " ;
			sum++ ;
		}
		else
			sum++ ;
	}
	return 0 ;
}
int main()
{
	char word[50];
	int count=0;
	int n;
	cin>>n;
	scanf("%s", word);
	count = strlen(word);
	cout<<word;
	for(int i=1;i<n;i++)
	{
		scanf("%s", word);
		if(count+strlen(word)+1<=80)
		{
			count=count+strlen(word)+1;
			cout<<" "<<word;
		}
		else
		{
			cout<<endl;
			cout<<word;
			count = strlen(word);
		}
	}
	return 0;

}
int main()
{
	int n;
	cin>>n;
	char ch[300][50];
	int lengthch[300];
	for (int i=0;i<n;i++)
	{
		cin>>ch[i];
	    lengthch[i]=strlen(ch[i]);
	}
	int num=80;
	for (int i=0;i<n;i++)
	{
		if (i==n-1) cout<<ch[i];
		else {
		if (num-lengthch[i]-lengthch[i+1]>0)
		{cout<<ch[i]<<' ';num=num-lengthch[i]-1;}
		else
		{cout<<ch[i]<<endl;num=80;}}
	}
	return 0;
}
int main(){
	int n,i,j,sum;
	char word[40];
	scanf("%d\n",&n);
	scanf("%s",word);
	printf("%s",word);
	sum=strlen(word);
	for(i=1;i<n;i++){
		for(j=0;j<40;j++){
			word[j]='\0';
		}
        scanf("%s",word);
		if(sum+strlen(word)+1<=80){
			printf(" %s",word);
			sum=sum+strlen(word)+1;
		}else{
			printf("\n%s",word);
			sum=strlen(word);
		}
	}
	return 0;
}
int main()
{
	char words[10000][41];
	char *p;
	int i,n,l=0;
	int len[10000];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>words[i];
	}
    
	for(i=0;i<n;i++)
	{
		len[i]=strlen(words[i]);
	}
	

	for(i=0;i<n;i++)
	{
		p=words[i];
		if(l+len[i]+1<=80)
		{
			if(i!=0)
			{
				cout<<" "<<p;
			l+=len[i]+1;
			}
			else {
				cout<<p;
				
			l+=len[i];
			}
			
			continue;
		}
		
		else {

			cout<<endl;
			cout<<p;
			l=0;
			l+=len[i];
			continue;
		}	
	}


	return 0;
}
int main()
{
	int n,i,l,L=0;
	char word[25];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",word);
		l=strlen(word);
		L+=(l+1);
		if(i==0)
			printf("%s",word);
		else
		{
			if(L>81)
				L=l+1;
			if(L!=(l+1))
				printf(" %s",word);
			else
				printf("\n%s",word);
		}
	}
	return 0;
}
int find(char *s);
char s[1000];
int main()
{
	int i,j,n,d=0;
	char c;
	scanf("%d%c",&n,&c);
	gets(s);
	for(i=0;*(s+i)!='\0';i++)
	{
		d+=1;
		if(*(s+i)==' '&&d<=81&&d+find(s+i)>81)
		{
			printf("\n");
			d=0;
		}
		else
			printf("%c",*(s+i));
	}
	gets(s);
	gets(s);
	return 0;
}
int find(char *s)
{
	int i,j,k;
	for(i=1;i<=40;i++)
	{
		if(*(s+i)==' ')
			return i;
	}
}
int main()
{
	int n;
	cin>>n;
	char a[1000][40]={'\0'};
	char b[40];
	char *p=*a;
	char *q=&b[0];
	int i,j;
	int N;
	int num[1000]={0};
	int *x=num;
	int count=0;
	for(i=0;i<n;i++)
	{
		p=*(a+i);
		cin>>b;
		N=strlen(b);
		*(x+i)=N;
		for(j=0;j<N;j++)
		{
			*(p+j)=*(q+j);
		}
	}
	p=*a;
	for(i=0;i<n;i++)
	{
		p=*(a+i);
		if(count+*(x+i)<=80&&i!=n-1&&count+*(x+i)+*(x+i+1)+1<=80)
		{
			for(j=0;j<*(x+i);j++)
			{
				cout<<*(p+j);
			}	
			count=count+*(x+i)+1;
			cout<<" ";
			continue;
		}
		if(count+*(x+i)<=80&&i!=n-1&&count+*(x+i)+*(x+i+1)+1>80)
		{
			for(j=0;j<*(x+i);j++)
			{
				cout<<*(p+j);
			}	
			count=count+*(x+i)+1;
                           continue;
		}
		if(count+*(x+i)<=80&&i==n-1)
		{
			for(j=0;j<*(x+i);j++)
			{
				cout<<*(p+j);
			}	
			count=count+*(x+i)+1;
                           continue;
		}
		if(count+*(x+i)>80&&i!=n-1)
		{
			cout<<endl;
			for(j=0;j<*(x+i);j++)
			{
				cout<<*(p+j);
			}			
			count=*(x+i)+1;
			cout<<" ";
                           continue;
		}
		if(count+*(x+i)>80&&i==n-1)
		{
			cout<<endl;
			for(j=0;j<*(x+i);j++)
			{
				cout<<*(p+j);
			}			
			count=*(x+i)+1;
                           continue;
		}
	}
	return 0;
}
int main()
{
	char word[1000][80];                
	int i,n;
	int l1,l2,aa=0;                        
	cin>>n;                             
	for (i=0;i<=n-1;i++)                
	{
		cin>>word[i];                   
	}
	i=0;
	while (i!=n-1)
	{
		l1=strlen(word[i]);             
		l2=strlen(word[i+1]);
		if ((aa+l1+l2+1>80)&&(aa+l1<=80))                    
		{
			cout<<word[i]<<endl;
			aa=0;
			i++;
		}
		else
		{
			cout<<word[i]<<" ";
			aa=aa+l1+1;
			i++;
		}
	}
	if (aa+l2<=80)
		cout<<word[n-1];
	else
	{
		cout<<endl;
		cout<<word[n-1];
	}
	return 0;
}
// ????.cpp : Defines the entry point for the console application.
// ????:????
int main()
{
	int n;                                                        //????n???????
	char words[1000][42];                                         //?????????words?????
	char (*p)[42];                                                //???????p???????????
	int sum=0,len1=0,len2=0;                                      //????sum????????????len1?len2????????????
	cin>>n;                                                       //???????
	for(int i=0;i<n;i++)                                          //????????
	{
		scanf("%s",words[i]);
	}
	p=words;                     //?p??????
	int i=0;                     //??????i??????
	while(sum<=80&&i<n)               //????????????80???????????
	{
		len1=strlen(words[i]);      //???i??????
		len2=strlen(words[i+1]);           //???i+1??????
		if((sum+len1)<=80&&(sum+len1+1+len2)>80)           //?????i?????????i+1???
		{
			cout<<*p<<endl;                     //??i????????
			p++;                                //?????????
			i++;                                //i????
			sum=0;                                    //sum???0
		}
		else if((sum+len1)<80&&(sum+len1+1+len2)<=80)     //?????i?????????????
		{
			if(i!=n-1)                  //??????????
			{
				cout<<*p<<" ";            //??????????
			    p++;                       //p???????
			    sum=sum+len1+1;             //?????sum+1
			    i++;                       //i??
			}
			else                      //?????????????????
			{
				cout<<*p;
				break;
			}
		}
	}
	return 0;
}
int main()
{
    int n, i, j, sum, l;
    char a[41];
    char *p = a;
    cin >> n;
    sum = 0;
    for (i = 1; i <= n; i++)
    {
       cin >> a;
       l = strlen(a);
       if (sum == 0) 
       {
            for (j = 0; j <l; j++) cout << *(p+j);
            sum = l;
        }
       else
       if ( sum + l + 1 <= 80) 
       {
            cout << ' ' ;
            for (j = 0; j <l; j++) cout << *(p+j);
            sum = sum + l +1;
       }
       else 
       {
           sum = l;
           cout << endl;
           for (j = 0; j <l; j++) cout << *(p+j);
       }
    }
    return 0;
}
int main(int argc, char *argv[])
{
    int n,i,sum1=0,len1,len2,count=0;
    char a[500][40];
    scanf("%d",&n);
    for(i=0;i<n;i++){   //?? 
                     scanf("%s",a[i]);
                     }
    int sum2=strlen(a[0]);
    
    for(i=0;i<n-1;i++){
                     len1=strlen(a[i]);
                     len2=strlen(a[i+1]);
                     sum1+=len1;
                     sum2+=len2;
                     
                     if(sum2+count+1<=80) {printf("%s ",a[i]);count++;}
                     else if(sum2+count+1>80 && sum1+count<=80)  {
                          printf("%s\n",a[i]);
                          count=sum1=0;
                          sum2=strlen(a[i+1]);
                          }
                     else {
                          printf("\n");
                          count=sum1=0;i--; 
                          sum2=strlen(a[i]);
                          
                          }
                          }
                          
                          
    printf("%s\n",a[n-1]);
    
    

  return 0;
}
int main(){
	char a[300][40];
	int b[300],c=0;
	int n;
	scanf("%d",&n);
	int i,j,r,k;
	int p=0;
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
		b[i]=strlen(a[i]);
	}
	for(i=0;i<n;i++){
		c=c+b[i]+1;
		if(c==81){
			for(j=p;j<i;j++){
				printf("%s ",a[j]);
			}
			printf("%s\n",a[i]);
			c=0;
			p=i+1;
		}
		else if(c>=82){
			for(j=p;j<i-1;j++){
				printf("%s ",a[j]);
			}
			printf("%s\n",a[i-1]);
			c=b[i]+1;
			p=i;
		}
		else if(c<81){
			int d=0;
			for(k=p;k<n;k++){
				d=d+b[k]+1;
			}
			if(d<=80){
			for(r=p;r<n-1;r++){
				printf("%s ",a[r]);
			}
			printf("%s",a[n-1]);
break;
			}
		}
	}
}
int check(char *p)
{
	int i=0;
	int temp;
	for(i=0;i<81;i++)
	{
		if(*(p+i)=='\0')//?????????
		{
			temp=0;
			break;
		}
		else
			temp=1;
	}
	return temp;
}
void out(char *p)
{
	int i,j;
	if(check (p)==1)
	{
		if(*(p+80)==' ')//???????
		{
			for(i=0;i<80;i++)
				cout<<*(p+i);
			cout<<endl;
			out(p+81);
		}
		else
		{
			for(i=0;i<80;i++)//????????????????
			{
				if(*(p+80-i)==' ')
					break;
			}
			for(j=0;j<80-i;j++)//??????
				cout<<*(p+j);
			cout<<endl;
			out(p+81-i);
		}
	}
	else if(check(p)==0)
		cout<<p;
}
int main()
{
	int n;
	cin>>n;
	cin.get();
	int i=0,j=0,k=0;
	char words[30000]={0};
	cin.get(words,30000,'\n');
	//cout<<words;
	char *p=&words[0];
    out(p);
	
}
int change1(int n)
{
	return n%10;
}
int change2(int n)
{
	return n%100/10;
}
int change3(int n)
{
	return n /100;
}








int main ()
{
	
    int n;
	cin>>n;
	char a[20];
	int len,relen=0;
	cin>>a;
	relen+=strlen(a);
	cout<<a;
	for (int i=0;i<n-1;i++)
	{
		cin>>a;
		len=strlen(a);
		if(relen+1+len<=80)
		{
			relen+=1+len;
			cout<<' '<<a;
		}
		else
		{
			cout<<endl;
			relen=strlen(a);
			cout<<a;
		}
	}
		
















	return 0;
}