semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n,i,len=0;						//??????????????
	char (*p)[40]=NULL;					//??
	char word[2000][40];				//????
	cin>>n;
	for(i=0;i<n;i++)
		scanf("%s",word[i]);
	p=&word[0];							//?????????
	for(i=0;i<n-1;i++)
	{
		len+=strlen(*p);
		if(len+1+strlen(*(p+1))>80)		//??????80
		{
			cout<<*p<<endl;				//??
			len=0;
			p+=1;
		}
		else
		{
			len+=1;
			cout<<*p<<" ";
			p+=1;
		}
	}
	cout<<*p;
	return 0;
}
int main()
{
	int n;
	cin >> n;
	cin.get();
	char a[90000];
	cin.getline(a, 90000);
	int la = strlen(a);
	int i, j = 80;
	while(j < la)
	{
		for(i = j; i > j - 30; i--)
		{
			if(a[i] == ' ')
			{ a[i] = '~'; break; }
		}
		j = i + 81;
	}
	for(i = 0; i < la; i++)
	{
		if(a[i] != '~')
			cout << a[i];
		else 
			cout << endl;
	}
	return 0;
}
int main( )
{
	int n,i;
	cin>>n;
	char str[3000][45];
	for(i=0;i<n;i++)
		cin>>str[i];
	i=0;
	while(i<n)
	{
		int len=strlen(str[i]);
		cout<<str[i];
		i++;
		while(i<n)
		{
			len=len+strlen(str[i])+1;
			if(len<=80)
				cout<<' '<<str[i];
			else
			{
				cout<<endl;
				break;
			}
			i++;
		}
	}
	return 0;
}
int main( )
{
	char s[250][50]={0};
	int n,i,c;
	cin>>n;
	cin.get();
	for(i=0;i<n;i++)
	{
		cin>>*(s+i);
	}
	c=0;
	i=0;
	while(i<n)
	{
		if(c+strlen(*(s+i))+1>80)
		{
			cout<<endl;
			c=0;
		}
		else if(c+strlen(*(s+i))+1<=80&&c==0)
		{
			cout<<*(s+i);
			c+=strlen(*(s+i));
			i++;
		}
		else if(c+strlen(*(s+i))+1<=80)
		{
			cout<<" "<<*(s+i);
			c+=strlen(*(s+i))+1;
			i++;
		}

	}
		return 0;
}
int	main()
{
	int	n;
	int	count;
	cin >> n;
	for( int i = 1 ; i <= n ; i ++ )
	{
		char	s[41];
		cin >> s;
		if( i == 1 )
		{
			cout << s;
			count = strlen( s );
		}
		else
		{
			if( count + strlen( s ) + 1 <= 80 )
			{
				cout << ' ' << s;
				count += strlen( s ) + 1;
			}
			else
			{
				cout << endl << s;
				count = strlen( s );
			}
		}
	}

	return 0;
}
int main()
{
    char word[1000][40];
    int number,count=0,i;
    scanf("%d",&number);
    for(i=0;i<number;i++)scanf("%s",word[i]);
    for(i=0;i<number;i++)
    {
        if(count+strlen(word[i])+1<=80)
        {
            if(i==0)
            {
                printf("%s",word[i]);
                count+=strlen(word[i]);
            }
            else
            {
                printf(" %s",word[i]);
                count+=strlen(word[i])+1;
            }
        }
        else
        {
            printf("\n%s",word[i]);
            count=strlen(word[i]);
        }
    }
    return 0;
}
int main(void)
{
	int cnt;
	char data[1000][90];
	scanf("%d",&cnt);
	int i;
	for(i=0;i<cnt;i++)
		scanf("%s",data[i]);
	int c=0;
	i=0;
	while(i<cnt){
		while(c<80){
			if(c+strlen(data[i]) >= 80)
				break;
			if(c != 0)
			{
				printf(" ");
				c++;
			}
			printf("%s",data[i]);
			c = c+strlen(data[i]);
			i++;
			if(i>=cnt)
				break;
		}
		printf("\n");
		c=0;
	}
	
	return 0;
}
int main()
{
	char c,str[1000][40]={0};
	int i,j,n,num[1000],sum=0;
	cin>>n;
	for(i=0;i<n;)
	{
		j=0;
		c=cin.get();
		if(c==' '||c=='\n')
			continue;
		else
		{
			str[i][j]=c;
			j++;
		}
		for(;;j++)
		{
			c=cin.get();
			if(c!=' '&&c!='\n')
				str[i][j]=c;
			else
				break;
		}
		num[i]=j;
		i++;//input
	}
	while(c!='\n')
		c=cin.get();
	cout<<str[0];
         sum=num[0];
	for(i=1;i<n;i++)
	{
		if(sum+num[i]+1<=80)
		{
			sum=sum+num[i]+1;
			cout<<' '<<str[i];
		}
		else
		{
			sum=num[i];
			cout<<'\n'<<str[i];
		}
	}
	return 0;
}
// lp.cpp : Defines the entry point for the console application.
//
// ??????.cpp : Defines the entry point for the console application.
//

int main()
{
	int n,i,j,len=0;
	char s[1000][100];
	char *p;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>s[i];
	cout<<s[0];
	len=strlen(s[0]);
    for(i=1;i<n;i++)
	{
		if(len+strlen(s[i])+1<=80)
		{
			p=s[i];
			cout<<' '<<p;
			len+=strlen(s[i])+1;
		}
		else
		{
			p=s[i];
			cout<<endl;
			cout<<p;
			len=strlen(s[i]);
		}
	}
	return 0;
}
int main(){
	char word[1010][30];
	int i, n, len = 0;

	cin >> n;
	for (i = 0; i < n; i++)
		cin >> word[i];
	cout << word[0];
	len = strlen(word[0]) + 1;
	for (i = 1; i < n - 1; i++)
	{
		if (len + strlen(word[i]) < 81)
		{
			if (len == 0)
			{
				cout << word[i];
			}
			else
				cout << " " << word[i];
				len = len + strlen(word[i]) + 1;
		}
		else if (len + strlen(word[i]) > 80)
		{
			cout << endl;
			len = 0;
			i = i - 1;
		}
	}
	cout << " " << word[n - 1];
	return 0;
}
int main()
{
	char letter[40];
	int n, i, blank = 0, num = 0;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		memset(letter, '0', sizeof(letter));
		cin >> letter;
		if (strlen(letter) + blank + num > 80)
		{
			blank = 0;
			num = 0;
			cout << endl;
		}
		if (blank)
			cout << ' ';
		cout << letter;
		num += strlen(letter) + blank;
		blank = 1;
	}
	return 0;
}
int main()
{ 
	int n,length=0,l;
	cin>>n;
	char a[1000][40];
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for (int i=0;i<n;i++)
	{
		l=strlen(a[i]);
		if (i==n-1)
		{	cout<<a[i]<<endl;
		break;}
		if (length+l+1+strlen(a[i+1])<=80)
		{
			cout<<a[i];
			cout<<' ';
			length+=l+1;
		}
		else 
		{
			cout<<a[i];
			cout<<endl;
			length=0;
		}
		
	}








	return 0;
}
int main()
{
	int i, n;//???
	cin>>n;
	char a[50];//??
	int sum=0;//?????
	int num=0;//????
	char *p=NULL;
	cin>>a;
	cout<<a;
	num=strlen(a);
	sum=num;
	for(i=0;i<n-1;i++)
	{
		cin>>a;//??????????????
		num=strlen(a);
		sum=num+sum+1;
		if(sum==num+1)
		{
			for(p=a;p<num+a;p++)//??????
			{
			 cout<<*p;
			}
			sum--;
		}
		else
		{
			if(sum<80&&sum!=num+1)
		{
			cout<<' ';
			for(p=a;p<num+a;p++)//??????
			{
			 cout<<*p;
			}
			
		}
		
		if(sum==80)
		{
			cout<<' ';
			for(p=a;p<num+a;p++)//??????
			{
			 cout<<*p;
			}
			cout<<endl;
			sum=0;
		}
		if(sum>80)//??
		{
			sum=num;
			
			cout<<endl;
			for(p=a;p<num+a;p++)
			{
			 cout<<*p;
			}
		}
		}
	}

	
	return 0;
}
int main()
{
	int i,n;
	char str[500][41]={'\0'};
	int a[500]={0};
	cin>>n;
	for(i=0;i<n;i++)
	{
		int j;
		cin>>*(str+i);
		for(j=0;*(*(str+i)+j)!='\0';j++);
		*(a+i)=j;
	}
	char c[20][82]={'\0'};
	int s=0,t,s1,j;
	for(i=0;i<20;i++)
	{
		t=0;
		s1=s;
		for(j=s1;j<n;j++)
		{
			for(int m=0;m<a[j];m++)
			{c[i][t]=str[j][m];t++;}
			s++;
			if(t+a[j+1]>=80) break;
			if(s>=n) break;
			c[i][t]=' ';
			t++;
		}
		if(s>=n) break;
	}
	for(int k=0;k<=i;k++)
		cout<<c[k]<<endl;
	return 0;
}
int main()
{
    int n,i,l,sum;
    char s[220];

    scanf("%d",&n);
    sum=0;
    for (i=0;i<n;i++)
    {
        scanf("%s",s);
        l=strlen(s);
        if (sum==0) {printf("%s",s);sum=l;}
        else if (sum+1+l>80) {printf("\n%s",s);sum=l;}
        else {printf(" %s",s);sum=sum+1+l;}
    }
    return 0;
}
/*
 * ????.cpp
 *
 * ??: 2012-12-15
 *  ??:?????
 */
int main()
{
	int n,count=0;//?????????????
	for(cin>>n;n>0;n--){//??n???
		char s[41];
	    cin>>s;//????
	    char *p=s;//??????????
	    int lp=0;//?????
	    for(;*p!='\0';p++)//???????
	    	lp++;
	    p=s;//????????
	    if(count==0) {count=lp;cout<<p;}//???????????????????????
	    else if(count+lp+1<=80){//???????????????????????80
	    	count+=1+lp;cout<<" "<<p;//??????????????????1????????
	    }
	    else {
	    	cout<<endl<<p;//??????
	    	count=lp;//?????????????
	    }
	}
	return 0;
}
int main()
{
	char word[1000][83];
	int n,i,counter=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>word[i];
	//cout<<word[28]<<endl;
	for(i=0;i<n;i++)
	{
		if(counter==0)
		{
			cout<<word[i];
			counter=counter+strlen(word[i]);
		}
		else
		{
			if(counter+strlen(word[i])+1<=80)
			{
				cout<<" "<<word[i];
				counter=counter+strlen(word[i])+1;
			}
			else
			{
				cout<<endl;
				counter=0;
				i--;
			}
		}
	}
	return 0;
}
int main()
{
	int n;
	char c[41];
	int s=0;
	cin>>n;
	int y=0;
	for(int i=0;i<n;i++)
	{
		
		int f=0;
		cin>>c;
		s+=strlen(c)+1;
		if(s>81)
		{
			cout<<endl;
			s=0;
			s+=strlen(c)+1;
			f=1;
		}
		else
			if(y!=0)
			cout<<" ";
		y=1;
		cout<<c;
	}
	return 0;
}
int main()
{
	char w[315][45];
	int i,j,k,n,g,m=0,len[315];
	cin>>n;
	for (i=0;i<=n-1;i++)
	{
		cin>>w[i];
		len[i]=strlen(w[i]);
	}
	

	for (j=0;j<=n-1;)
	{
        
		if (m==0)
		{
			m=m+len[j];
			cout<<w[j];
			j=j+1;
		}
		else
		{

		if (m+len[j]+1<=80)
		{
			m=m+len[j]+1;
			
				cout<<" "<<w[j];
				j=j+1;

			
		}
		else
		{
			cout<<endl;
			m=0;
			
		}
		}
	}
		return 0;
	}
//************************************************************************
//*???2.cpp                                                         
//*???????                                                       
//*??????                                                          
//*???2013?12?12?                                                   
//************************************************************************
int main()
{
	int n, i, num = 0;		//num???????????
	char str[1000][40];	    //???????????????????????
	cin >> n;
	for(i = 0; i < n; i++)
		cin >> str[i];
	for(i = 0; i < n - 1; i++)  //?????????n-1???????????????????????????????
	{
		num += strlen(*(str + i));  //????????????????????????????????????
		if( num + 1 + strlen(*(str + i + 1)) <= 80)	
		{
			cout << *(str + i) << " ";
			num++;						//???????????num?????????????????????
		}
		else if((num <= 80) && (num + 1 + strlen(*(str + i + 1)) > 80))  //???????????????????????????
		{
			cout << *(str + i);	
			num++;
		}
		else
		{
			cout << endl;				//????????
			i--;                        //????????i?1?????????????????????i??1????????????????
			num = 0;					//???????num?0????
		}		
	}
	cout << *(str + n - 1) << endl;     //????????????
	return 0;
}
int main()
{
	int n;
	char s[1000][50];
	int len[1000]={0};
	int sum=0;
//	int breakpoint[1000];
	int i;
	cin>>n;
	cin.get();
	for(i=0;i<n;i++)
	{
		cin>>s[i];
		len[i]=strlen(s[i]);
	}
    for(i=0;i<n;i++)
	{
		if(i==n-1)
		{	
			cout<<s[i]<<endl;
			break;
		}
		cout<<s[i]<<" ";
		sum=sum+len[i]+1;
		if((sum+len[i+1]<=80)&&(sum+len[i+1]+1+len[i+2]>80))
		{
			i=i+1;
			cout<<s[i]<<endl;
			sum=0;
		}
	}
	return 0;
}
int main ()
{
	int n,i,sum=0,k=1;
	cin>>n;
	char a[1000][40];
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
	{
		if(k==1)
			sum=sum+strlen(a[i]);
		else 
			sum=sum+strlen(a[i])+1;
		if(sum<=80 && k!=1)
			cout<<" "<<a[i];
		else if(sum<=80 && k==1)
		{
			k=0;
			cout<<a[i];
		}
		if(sum>80)
		{
			cout<<endl;
			cout<<a[i];
			sum=strlen(a[i]);
		}
		else if(sum==80)
		{	
			cout<<endl;
			sum=0;
			k=1;
		}
	}
	return 0;
}
int main()
{
    int n,i,j,l,k;
    char s[100];
    scanf("%d",&n);
    k=0;
    for(i=1;i<=n;i++)
    {
        scanf("%s",s);
        l=strlen(s);
        if (k==0)
        {
            printf("%s",s);
            k=l;
            continue;
        }
        if (k+l<80)
        {
            printf(" %s",s);
            k=k+l+1;
            continue;
        }
        if (k+l>=80)
        {
            printf("\n%s",s);
            k=l;
            continue;
        }
    }    
    return 0;
}
int main()
{
	int i,k,flag=0;
	char word[1000][40]={'\0'};
	int lenth[1000]={0};
	cin>>k;
	cin.get();
	for(i=0;i<k;i++)
	{
		cin.getline(word[i],40,' ');
		lenth[i]=strlen(word[i]);
	}
	cout<<*word;
	flag=*lenth;
	for(i=1;i<k;i++)
	{
		flag=flag+1+*(lenth+i);
		if(flag>80)
		{
			cout<<endl;
			cout<<*(word+i);
			flag=*(lenth+i);
		}
		else
			cout<<" "<<*(word+i);
	}
	return 0;
}
int main()
{
	int n;
	scanf("%d",&n);
	char **p=(char **)malloc((n+5)*sizeof(char *));
	for(int i=0;i<n;i++)
	    {
		p[i]=(char *)malloc(sizeof(char)*41);
		scanf("%s",p[i]);	
		}
	int count=0;
	for(int i=0;i<n;i++)
	    {
		if(count==0)
			{
			printf("%s",p[i]);
			count+=strlen(p[i]);	
			}	
		else
			{
			if(count+strlen(p[i])+1<=80)
				{
				printf(" %s",p[i]);
				count+=(strlen(p[i])+1);	
				}	
			else
				{
				printf("\n");
				printf("%s",p[i]);
				count=strlen(p[i]);
				}	
			}
		}
}
int main()
{
	int i=0,n,flag=0,sum=0;
	char sen[59];
	cin>>n;
	cin.get();
	while(cin>>sen)
	{
		if(flag==0&&sum<80)
		{
			cout<<sen;
			sum=sum+strlen(sen);
			//cout<<sum<<endl;
			flag=1;
		}
		else if(flag==1)
		{
			sum=sum+strlen(sen)+1;
			if(sum<=80)
			cout<<" "<<sen;
			else
			{
				cout<<endl<<sen;
				sum=strlen(sen);
			}
		}
	}


	return 0;
}
int main(){
	int n;
	scanf("%d",&n);
	char a[1000][40];
	int i;
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
	}
	int b[1000];
	for(i=0;i<n;i++){
		b[i]=strlen(a[i]);
	}
	printf("%s",a[0]);
	int count=strlen(a[0]);
	for(i=1;i<n;i++){
		if(count+1+strlen(a[i])<=80){
			printf(" %s",a[i]);
			count=count+1+strlen(a[i]);
		}else{
			printf("\n%s",a[i]);
			count=strlen(a[i]);
		}
	}
	return 0;
}
int main()
{
    char a[100],*p;
    int n;
    cin>>n;
    int num;
    cin>>a;
    int len=strlen(a);
    p=a;
    cout<<endl;
    num=len;
    cout<<p;
    for (int i=1;i<n;i++)
    {  
                   cin>>a;
                   int len=strlen(a);
                   p=a;
                   if (num+len+1>80) {cout<<endl;num=len;cout<<p;}
                   else {num+=len+1;cout<<' ';cout<<p;}
    }
    
    return 0;
}
int main()
{
	int n,l[500],*p,num=0,i;
	char a[500][41];
	cin>>n;
	cin.get();
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		l[i]=strlen(a[i]);
	}
	p=&l[1];
	for(i=1;i<=n;i++)
	{
		if(num==0)
		{
			cout<<a[i];
			num=(*p)+num+1;
			p++;
			continue;
		}
		num=num+(*p)+1;
		if(num<=81)
		{
			cout<<" "<<a[i];
			p++;
			continue;
		}
		if(num>81)
		{
			num=0;
			i--;
			cout<<endl;
			continue;
		}
	}
	return 0;
}
int main()
{
	int n,i;
	cin>>n;
	char a[1000][50];
	for (i=1;i<=n;i++)
		cin>>a[i];
	int count=0;
	for (i=1;i<=n;i++)
	{
		count=count+strlen(a[i]);
		if (count<=80)
		{
			if (i<n)
			{
			cout<<a[i];
			if (count+1+strlen(a[i+1])<=80)
			{
				cout<<" ";
			}
			count++;
			}
			else if (i==n)
				cout<<a[n];
		}
		else if (count>80)
		{
			if (i<n)
			{
			count=strlen(a[i]);
			cout<<endl;
			cout<<a[i]<<" ";
			count++;
			}
			else if (i==n)
				cout<<a[n];
		}
	}
}
int main()
{
	int n,l=0,i,a[1000];
	char s[1000][100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s",s[i]);
	for(i=0;i<n;i++)
		a[i]=strlen(s[i]);
	for(i=0;i<n;i++)
	{
		printf("%s",s[i]);
	   	l+=a[i]+1;
		if(i!=n-1 && l+a[i+1]<=80)printf(" ");
		else{
			l=0;
			printf("\n");
		}
	}
     return 0;
}
main()
{	char words[500][40];
	int n,i,j,numwords[500]={0},num=0;
    scanf("%d",&n);
	for(i=0;i<n;i++)
  	{scanf("%s",words[i]);}
	
	for(i=0;i<n;i++)
	{	for(j=0;words[i][j]!='\0';j++)
 		{	numwords[i]++;
		 							  }
	 						
					 }
					 
	for(i=0;i<n-1;i++)
	{	if((numwords[i]+num)>80)
		{	printf("\n");
			printf("%s ",words[i]);
			num=numwords[i]+1;
		 						}					 
	 	else if((numwords[i+1]+num+numwords[i]+1)>80)
	 	{	printf("%s",words[i]);
	 		num=num+numwords[i]+1;
		 						}			
		else
		{	printf("%s ",words[i]);
	 		num=num+numwords[i]+1;
		 						}						 
					 }
  	  printf("%s",words[n-1]); 
		 
			 }
int main ()
{
	int n, i=0, temp1, temp2;
	scanf("%d", &n);
	char s[10000];
	gets(s);
	gets(s);
	char * ps=s, * ps1;
	temp1=(int)s;
	for ( ; *ps; ps++) {
		i++;
		if (*ps==' ') {
			if (i>LINELENTH+1) {
				for(ps1=(char *)temp1; ps1<(char *)temp2; ps1++)
					printf("%c", *ps1);
				i=((int)ps-temp2)/sizeof(char);
				temp1=temp2+sizeof(char);
				printf("\n");
			}
			else temp2=(int)ps;
		}
	}
	for (ps1=(char *)temp1; *ps1; ps1++)
		printf("%c", *ps1);
	return 0;
}
int main()
{
	int n, i, cnt;
	char a[999][41];
	cin >> n;
	for(i = 1; i <= n; i++)
	{cin >> a[i];}
	i = 1;
	cnt = 0;
	do
	{
		cnt += strlen(*(a + i));
		if(cnt <= 80)
		{
			cout << *(a + i); 
			if(cnt + strlen(*(a + i + 1)) + 1 <= 80 && i != n)
			{
				cout << " ";	
			}
                        cnt++;		
			i++;
		}
		else
		{
			cout << endl;
			cnt = 0;
		}
	}while(i <= n); 
	return 0;
}
int main()
{
	int n, wl=0,/*wordlength*/ ll=0,/*linelength*/ i;
	char c[50]={'\0'}, ch;
	char *p=c;
	cin>>n; cin.get();
        do
	{
                cin.get(ch);
		if (ch!=' ')  { cout<<ch; ll++; }
	}
        while (ch!=' ');
	for (i=1; i<=n; i++)
	{
		wl=0; p=c;
		cin.get(ch);
		while (ch!=' ' &&  ch!='\n')
		{
			wl++;  *p=ch; p++;
			cin.get(ch);
		}
		if (ll+wl<80 && i<n)
		{
			cout<<' '; ll=ll+wl+1;
		}else
		{
			cout<<endl; ll=wl;
		}
		for (p=c; p<(c+wl); p++) cout<<*p;
	}
	return 0;
}
/*
 * paiban.cpp
 *?????
 *  Created on: 2012-12-14
 *      Author: ??
 */


int main() {
	char *p;//??????
	p = (char*)malloc(100*4);
	int chang = 0, n, len;//????????n,????
	cin >> n;//??n
	cin >> p;
	cout << p;//??????????
	chang = strlen(p);//???????????
	n--;//????
	while (n > 0) {
		cin >> p;
		len = strlen(p);//???????
		chang += len + 1;//???????
		if (chang > 80) {
			cout << '\n' << p;
			chang = len;//??????????????????
		} else
			cout << ' ' << p;//????????????
		n--;//?????
	}
	return 0;
}
/*
 * ????.cpp
 *
 *  Created on: 2011-12-7
 *      author: ???
 */

int main(){
	char a[40];
	int counter=0,n;                   //counter???????????
	cin>>n;
	while(cin>>a&&n>0){                //?????????????????????????80?????????????????
		if(counter==0){                //??????????
			counter=counter+strlen(a);
			cout<<a;
		}
		else{
			if(counter+strlen(a)+1<=80){//?????????????????80??????????
				counter+=strlen(a)+1;
				cout<<" "<<a;
			}
			else{                       //???????
				counter=strlen(a);
				cout<<endl<<a;
			}
		}
		n--;
	}
	return 0;
}
int main()
{
	int n,i,letters=0,space=0;
	char (*word)[41];
	scanf("%d",&n);
	word=(char *)malloc((n+1)*41*sizeof(char));
	for(i=0;i<n;i++)
	{
		scanf("%s",word+i);
	}
	for(i=0;i<n;i++)
	{
		letters+=(strlen(word+i));
		if(letters>80)
		{
			letters=strlen(word+i);
			printf("\n%s",word+i);
		}else if(letters==80){
			letters=0;
			printf(" %s\n",word+i);
			space=0;
			letters--;
		}else if(space==0){
			printf("%s",word+i);
			space++;
		}else{
			printf(" %s",word+i);
		}
		letters++;
	}
	return 0;
}
void main()
{
	int n;
	char a[1000][41];
	int b[1000];
	int i,s=0;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",a[i]);
		b[i]=strlen(a[i]);
	}

	for(i=0;i<n;i++)
	{
//		int u=0;
		if(s==0)
		{
			printf("%s",a[i]);
//			u=0;
			s=b[i];
			i++;
		}
		s=s+b[i]+1;
		if(s>80)
		{
			printf("\n");
			s=0;
			i--;
//			u=1;
			continue;
		}
		else
		{
			printf(" %s",a[i]);
		}
	}
}
int main()
{
	int num;
	char word[50];
	cin>>num;
	int count = 0;
	while(num--){
		scanf("%s",word);
		if(count ==0){
			cout<<word;
			count = strlen(word);
		}
		else{
			count += (strlen(word)+1);
			if(count > 80)
			{
				cout<<endl<<word;
				count = strlen(word);
			}
			else if(count==80){
				cout<<' '<<word<<endl;
				count = 0;
			}
			else
				cout<<' '<<word;
		}
	}
	return 0;
}
int main()
{ int n;
   scanf("%d",&n);
  int i=0,num=0;
  char s[100];
  while(i<n)
  {scanf("%s",&s);
   num+=strlen(s);
   if(num==strlen(s))
   {printf("%s",s);
   num++;}
   else if(num<80)
   {printf(" %s",s);
    num++;}
    else if(num==80)
    {printf(" %s\n",s);
     num=0;}
   else if(num>80)
   {printf("\n%s",s);
     num=strlen(s);
     num++;}
      i++;
  }
     return 0;
}
/*
 * wenzipaiban.cpp
 *????
 *  Created on: 2011-12-9
 *      Author: q
 */
int main()
{
	char ch[1000][40]={0};
	char (*p)[40];//?????????
	int n,i,counter=0;//counter???????????
	p=ch;//?????
	cin>>n;
	for(i=0;i<n;i++)cin>>*p++;//??
	p=ch;//???????
	while(p<(ch+n))
	{
		if(counter==0)//?????????
		{
			counter+=strlen(*p);
			cout<<*p;
			p++;
		}
		else {
			counter+=strlen(*p)+1;//1?????
			if(counter<=80){//???80
				cout<<' '<<*p;
				p++;
			}
			else 
			{//??80??????
				counter=0;
				cout<<endl;
			}
		}
	}

	return 0;
}
int main(){
	char word[41];
	int n, cnt, len;

	scanf("%d", &n);
	cnt = 0;
	while (n--){
		scanf("%s", word);
		len = strlen(word);
		if (cnt == 0){
			printf("%s", word);
			cnt = len;
		}else if (cnt + len < 80){
			printf(" %s", word);
			cnt += len + 1;
		}else{
			printf("\n%s", word);
			cnt = len;
		}
	}

	return 0;
}
int main()
{
	int i,n,j,k,l,a[1000];
	char c[1000][40];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",c[i]);
		a[i]=strlen(c[i]);
	}
	for(i=0,k=-1,l=0;i<n;i++)
	{
		k=k+a[i]+1;
		if(k>80)
		{
			printf("%s",c[l]);
			for(j=l+1;j<i;j++)
				printf(" %s",c[j]);
			printf("\n");
			l=i;
			k=-1;
			i=i-1;
		}
		if(i==n-1)
		{
			printf("%s",c[l]);
			for(j=l+1;j<n;j++)
				printf(" %s",c[j]);
		}
	}
	return 0;
}
int main()
{
	char a[1000][50] ; 
    int m , i, b[1000],sum ;
	cin >> m ;
	for (i = 1 ; i <= m ; i ++ )
	{
			cin >> a[i] ;
			b[i] = strlen(a[i]) ;
	}
	sum = 0 ;
	for (i = 1 ; i <= m -1 ; i ++ )
	{
        sum = sum + b[i] + 1 ;
		if(sum < 80 && sum + b[i + 1] > 80 )
		{
			cout << a[i] <<endl;
			sum = 0 ;
		}
		else if(sum == 80)
		{
			cout << a[i] << endl ;
			sum = 0 ;
		}
		else if (sum == 81)
        {
			sum = 0 ;
			cout << a[i] << endl ;
		}
		else
		cout << a[i] << " ";/*if(sum == 79)
		{
			cout << a[i] << endl ;
			sum = 0 ;
		}
		else if(sum == 80)
		{
			cout << a[i] << endl ;
			sum = 0 ;
		}
		else
		{
			cout << endl << a[i] ;
			sum = b[i] ;
		}*/
	}
	cout << a[m] ;
	return 0 ;
}
void main(){
	char *f(char *p);
	char b[3],c[10000],*p,*q;
	int i;
	gets(b);
	gets(c);
	p=c;
	while((p+79)<c+strlen(c))
	{
		for(q=p;q<f(p);q++)
		{
			printf("%c",*q);
		}
		printf("\n");
		p=f(p)+1;
	}
	for(q=p;q<c+strlen(c);q++)
	{
		printf("%c",*q);
	}
	scanf("%d",&i);
}

char *f(char *p)
{
	char *s;
	for(s=p+80;s>p;s--)
	{
		if(*s==32) break;
	}
	return s;
}
int main()
{
	char ch[500][50];
	int i,j,n,m,l[500]={0};
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>ch[i];
		l[i]=strlen(ch[i]);
	}
	m=0;
	for(i=1;i<=n;i++)
	{
		if(m>0)
		{
			if(m+1+l[i]<=80)
			{
				cout<<' '<<ch[i];
				m+=l[i]+1;
			}
			else
			{
				m=0;
				cout<<endl;
			}
		}
		if(m==0)
		{
			cout<<ch[i];
			m+=l[i];
		}
	}
	return 0;
}
int main()
{
	char s[300][300];
	int n,i,l,x=0,j;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s",s[i]);
	}
	for (i=0;i<n;i++)
	{
		l=strlen(s[i]);
		x+=l;
		if (x==80)
		{
			printf("%s\n",s[i]);
			x=0;
		}
		else if(x>80)
		{
			if (i==n-1)
			{
				printf("\n%s\n",s[i]);
			}
			else
			{
			printf("\n%s ",s[i]);
			}	
			x=l+1;
		}
		else 
		{
			j=strlen(s[i+1]);
			if (i==n-1)
			{
				printf("%s\n",s[i]);
			}
			else
			{
				if (x+j+1>80)
				{
					printf("%s",s[i]);
				}
				else 
				{
					printf("%s ",s[i]);
				}
			}	
			x+=1;
		}
	}
	return 0;
}
int main()
{
	int n , len = 0 , l = 0;
	int i , j;
	char a[ 1000 ][ 50 ];
	cin >> n;
	for ( i = 0 ; i <= n - 1 ; i++ )
		cin >> a[ i ];
    l = strlen( a[0] );
	cout << a[ 0 ];
	for ( i = 1 ; i <= n - 1 ; i++ )
	{
		len = strlen( a[ i ] );
		if ( l + len + 1 <= 80 )
		{
			l = l + len + 1;
			cout << ' ' << a[ i ];
		}
		else if( l + len + 1 > 80 )
		{
			cout << endl;
			cout << a[ i ];
			l = len;
		}
	}
	return 0;
}
int main()
{
	int n, i, j, number;
	char input[500][40] = {0};
	int lenth[500] = {0}, lenth0 = 0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> input[i];
		lenth[i] = strlen(input[i]);
	}
	i = 0, number = 0;
	while (1)
	{
		lenth0 += lenth[number] + 1;
		if (lenth0 <= 81)
		{
			number++;
		}
		if (lenth0 > 81 || number == n)
		{
			for (j = i; j < number - 1; j++)
			{
				cout << input[j] << " ";
			}
			cout << input[number - 1] << endl;
			i = number;
			lenth0 = 0;
		}
		if (i == n)
			break;
	}
	return 0;
}
int main()
{
	int n,a[1000],s=0;
	cin>>n;
	char word[40],*q;
	cin>>word;
    q=word;
	while(*q!='\0')q++;
	a[1]=q-word;
	s=s+a[1]+1;
	cout<<word;
	for(int i=2;i<=n;i++)
	{
        char words[40],*p;
		cin>>words;
		p=words;
		while(*p!='\0')p++;
		a[i]=p-words;
		s=s+a[i]+1;
		if(s<=80)
		cout<<" "<<words;
		else
			{if(s==81)cout<<" "<<words;
			else
		{cout<<endl;
		cout<<words;
		s=a[i]+1;}}

	}
	return 0;
}
int main()
{
    int n,f=0,f1=0;
    char w[41];
    cin>>n;
    cin.get();
    while(cin>>w)
    {
        if ((f+1+strlen(w))<=80)
        {
            if(f1!=0)
            {
                f++;
                cout<<" ";
            }
            cout<<w;
            f1++;
            f+=strlen(w);
        }
        else
        {
            cout<<endl;
            f1=0;
            cout<<w<<" ";
            f=strlen(w)+1;
        }   
        memset(w,0,sizeof(w));
    }
    return 0;
}