semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
/**
?????80??????????????????????????????????????????? 
 
???? 
????????n?????????????????????n+1??????n??????????????????????????????????????40?????
 
???? 
??????????????????80???????????????????????????? 

*/

int main()
{
	char essay[10000];
	char *space, *begin, *p, *q;
	int n;
	cin >> n;
	cin.get();
	cin.getline(essay, 10000);
	begin = essay;
	p = essay;
	for ( p = essay; *p != '\0'; p ++ )
	{
		if ( *p ==' ' )
		{
			if ( p - begin > 80 )
			{
				for ( q = begin; q < space; q ++ )
					cout << *q;
				cout << endl;
				p = p + 1;
				begin = space + 1;
			}
			space = p;
		}
	}
	for ( q = begin; *q != '\0'; q ++ )
		cout << *q;
	cout << endl;

	return 0;
}
int main()
{
	char str[2000][41];
	int n;
	cin >> n;
	int i;
	int length[2000];
	int *p = length;
	for(i = 1; i <= n; i++)
	{
		cin >> str[i];
        *(p + i) = strlen(str[i]);
	}
	*(p + i) = 1000;
	int total = 80;
	for(i = 1; i <= n; i++)
	{
		if(*(p + i) <= total)
		{
			cout << str[i];
			total -= *(p + i);
			total--;
			if(*(p + i + 1) <= total)
				cout << " ";
		}
		else
		{
			cout << endl;
			total = 80;
			i--;
		}
	}
	return 0;
}
int main()
{
	char x[1000][41];
	int a,b,i;
	scanf("%d",&a);
	for(i=0;i<a;i++)
	{
		scanf("%s",x[i]);
	}
	x[a][0]='\0';
	b=strlen(x[0]);
	for(i=0;i<a;i++)
	{
		b+=strlen(x[i+1]);
		if(b>=80)
		{
			printf("%s\n",x[i]);
			b=strlen(x[i+1]);
		}
		else if(i==a-1)
		{
			printf("%s",x[i]);
		}
		else 
		{printf("%s ",x[i]);
		b++;}

	}


	return 0;
}
int main()
{
	char word[9999][50];
	int i , j , n , len , cnt = 0;
	cin >> n;
	for(i = 0 ; i < n ; i++)
		cin >> word[i];
	for(i = 0 ; i < n - 1 ; i++)
	{
		if(cnt + strlen(word[i])   <= 80 && cnt + strlen(word[i]) + 1 + strlen(word[i + 1])  > 80 )
		{
			cout << word[i] << endl;
			cnt = 0;
		}
		else//(cnt + strlen(word[i]) + 1 <= 80 && cnt + strlen(word[i]) + 1 + strlen(word[i + 1]) + 1 <= 80)
		{
			cout << word[i] << " " ;
			cnt = cnt + strlen(word[i]) + 1;
		}
		
	}
	cout << word[n - 1];
	return 0;
}
int main()
{
	int n, i, num=0, l, j;
	char a[40], *p;
	cin >> n;
	while(n>0)
	{
		memset(a, 40, '\0');
		cin >> a;
		l=strlen(a);
		a[l]='\t';
		p=a;
		if(num+l <= 80)
		{
			if(num>0)
			{
				cout << " ";
			}
			for(i=0; a[i] != '\t'; i++)
			{
				cout << *(p+i);
			}
			num += l+1;
		}
		else
		{
			num=0;
			cout << endl;
			for(i=0; i<l; i++)
			{
				cout << *(p+i);
			}
			num += l+1;
		}
		n--;
	}
	return 0;
}
//????
int main()
{
	int n, num = 0;
	char word[41];
	cin >> n;
	for(int k = 0; k < n; k++)
	{
		cin >> word;
		if(num == 0)
		{
			cout << word;
			num += strlen(word);
			continue;
		}
		num += strlen(word) + 1;
		if(num <= 80)
		{
			cout << ' ' << word;
		}
		else
		{
			cout << endl << word;
			num = strlen(word);
		}
	}
	return 0;
}
int main(){
	int n,i,charnum=0;
	cin>>n;
	char a[n][100];
	for(i=0;i<n;i++)
	cin>>*(a+i);
    for(i=0;i<n;i++){
       charnum+=strlen(*(a+i))+1;
       if(charnum+strlen(*(a+i+1))>80 && charnum<=81)
    	   cout<<*(a+i);
       if(charnum+strlen(*(a+i+1))<=80&&i!=n-1)
           cout<<*(a+i)<<" ";
       if(charnum+strlen(*(a+i+1))<=80&&i==n-1)
                  cout<<*(a+i);
       if(charnum>81){
    	       cout<<endl;
    	       cout<<*(a+i)<<" ";
    	       charnum=strlen(*(a+i))+1;
       }
    }
	return 0;
}
//**************************************
//*???????                     
//*????? 1100012780     	        
//*???2011.12.30                     
//**************************************
int main()
{
	int n;
	cin>>n;
	cin.get();
	int i;
	char words[1000][40];
	for (i = 0;i < n;i++)//????????
	{
		cin>>words[i];
	}
	int len[1000];
	for (i = 0;i < n;i++)//????????
		len[i] = strlen(words[i]);
	int line[100] = {0};//???????????
	int j = 0;
	cout<<words[0];
	line[0] = len[0];
	for (i = 1;i < n;i++)
	{
		if (line[j] + len[i] + 1 <= 80)//???????
		{
			cout << " " << words[i];
			line[j] += len[i] + 1;//???????
		}
		else//?????
		{
			cout << endl << words[i];
			j++;
			line[j] += len[i];
		}
	}
	return 0;
}
int main()
{
	int n,i,lw,len=0;
	char p[100],w[100];
	scanf("%d",&n);
	strcpy(p,"");
    for(i=0;i<n;i++)
	{
		printf("%s",p);
		scanf("%s",w);
		lw=strlen(w);
		if(len+lw>80)
		{
			printf("\n");
			len=0;
		}else if(i!=0)printf(" ");
		len+=lw+1;
		strcpy(p,w);
	}
	printf("%s\n",p);
	
	return 0;
}
main()
{
	int n, l=0, L=0;
	int i, t;
	char w[200][41], c[100]={'\0'};

	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%s", w[i]);
	}
	for(i=0; i<n; i++)
	{
		l=strlen(w[i])+1;//???????????
		L=L+l;
		if(L<=81)
		{
			strcat(c, w[i]);
			strcat(c, " ");
			if(L==81)
			{
				c[80]='\0';
				puts(c);
				for(t=0; c[t]!='\0'; t++)
				{
					c[t]='\0';
				}
				l=L=0;
			}
			if(i==n-1)
			{
				c[L-1]='\0';
				puts(c);
				printf("\n");
			}
		}
		if(L>81)
		{
			c[L-1-l]='\0';
			puts(c);
			printf("\n");
			for(t=0; c[t]!='\0'; t++)
				{
					c[t]='\0';
				}
			strcat(c, w[i]);
			strcat(c, " ");
			L=0;
			l=strlen(w[i])+1;
			L=L+l;
		}
	}
	

	return 0;
}
int main()
{
	int n,i,m=0;
	char word[41];
	scanf("%d",&n);
	scanf("%s",word);
	for(i=0;i<n;i++)
	{
		if(m==0)
		{
			printf("%s",word);
			m=m+strlen(word);
			scanf("%s",word);
		}
		else
		{
			if(m+strlen(word)+1>80)
			{
				printf("\n");
				m=0;
				i--;
			}
			else
			{
				printf(" %s",word);
				m=m+strlen(word)+1;
				scanf("%s",word);
			}
		}
	}
	return 0;
}
int main()
{
    int n,i=0,t=0;
    char c[4000]={'\0'};
    cin>>n;
    getchar();          //??
    while (i<=n)
    {
        c[t]=getchar();
        if(c[t]==' ')
            i++;
        if(c[t]=='\n')
        {
            break;
            c[t]='\0';
        }
        t++;
    }
    char *p=&c[0]+80;       //??80???????
    int m=0;
    while(1)
    {
        while (*p!=' ')
        {
            p--;
        }                      //??????
        for(i=m;&c[i]!=p;i++)
        {
            cout<<c[i];
        }
        cout<<endl;
        if(c[i+81]!='\0')
        {
            p=&c[i+1]+80;
            m=i+1;
        }
        else
        {
            i++;
            for(;c[i]!='\0';i++)
            {
                cout<<c[i];
            }
            break;
        }
    }
    return 0;
}
int main()
{
	char a[1000][100]={'\0'};
	int n,i1;
	cin>>n;
	for (i1=0;i1<n;i1++)
		cin>>*(a+i1);
	int num=0;
	for (int i2=0;i2<=i1-1;i2++)
	{
		if (num+strlen(*(a+i2))<=80&&num+strlen(*(a+i2))+1+strlen(*(a+i2+1))<=80&&i2!=i1-1)
		{
			cout<<*(a+i2)<<" ";
			num=num+strlen(*(a+i2))+1;
		}
		else if (num+strlen(*(a+i2))<=80&&num+strlen(*(a+i2))+1+strlen(*(a+i2+1))>80)
		{
			cout<<*(a+i2)<<endl;
			num=0;
		}
		else if(num+strlen(*(a+i2))<=80&&num+strlen(*(a+i2))+1+strlen(*(a+i2+1))<=80&&i2==i1-1)
			cout<<*(a+i2);
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	char s1[41];
	char s2[41];
	char *now;
	char *next;
	char *mid;
	int i,j;
	int nowlen;
	int thislen;
	scanf("%s",s1);
//			printf("%s\n",s1);
	now = s1;
	next = s2;
	nowlen = strlen(s1);
	for(i = 0;i < n - 1;i++)
	{
		for(j = 0;j < 41;j++)
			next[j] = '\0';
		scanf("%s",next);
//					printf("%s\n",next);
		thislen = strlen(next);
//							printf("%d %d\n",nowlen,thislen);
		if(nowlen + thislen + 1 <= 80) 
		{
			printf("%s ",now);
			nowlen = nowlen + thislen + 1;
		}
		else
		{
			printf("%s\n",now);
			nowlen = thislen;
		}
		mid = now;
		now = next;
		next = mid;
	}
	printf("%s",now);
	return 0;
}
main()
{
	char a[1000][40];
	int i,n,m;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s",a[i]);
	m=strlen(a[0]);
	printf("%s",a[0]);
	for(i=1;i<n;i++)
	{	
		m=m+strlen(a[i])+1;
		if(m<=80)
			printf(" %s",a[i]);
		else
		{
			m=strlen(a[i]);
            printf("\n%s",a[i]);
		}
	}
}
int main ()
{
	int n, i, cnt[1000],sum;
	char w [1000][50];
	char *p = * w;
	cin >> n;
	for (i = 0; i < n;i ++)
	{
		cin >> *(w + i);
	}

	for (i = 0; i < n; i++)
	{
		cnt[i] = strlen(*(w + i));
	}
	sum = 0;
	for (i = 0; i < n;i ++)
	{
		sum = sum + cnt [i];
		if (sum > 80)
		{
			cout << endl;
			cout << w [i] << " ";
			sum = cnt [i] + 1;
		}
		else
		{
			cout << w[i];
			if (sum + cnt [i + 1] + 1<= 80 && i != n -1)
				cout << " ";
			sum = sum + 1;
		}
	}
	return 0;
}
int main()
{
	int numofwords=0,numofchar=0;// num of char is used to count the num in the line
	int lenofwords[1000]={0};
	int i=0,flag=0;
	char words[1000][40];
	cin>>numofwords;
	cin.get();
	while(numofwords>0)
	{
		scanf("%s",words[i]);//cin the words
		cin.get();
		lenofwords[i]=strlen(words[i]);
		numofwords--;
		if((numofchar+lenofwords[i]+1<=80)&&(flag==1))
        {
			cout<<" ";
			printf("%s",words[i]);
         numofchar=numofchar+lenofwords[i]+1;
        }
         else if ((numofchar+lenofwords[i]<=80)&&(flag==0))
         {
              printf("%s",words[i]);
              flag=1;
              numofchar=numofchar+lenofwords[i];
         }
         else
         {
             printf("\n");
             cout<<endl<<words[i];
             flag=1;
             numofchar=lenofwords[i];
         }
		i++;
	}
    return 0;
}
int main()
{
	int n,i,l[1000],t=0;
	char word[1000][41];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",&word[i]);
		l[i]=(int)strlen(word[i]);
	}
	for(i=0;i<n-1;i++)
	{
		t+=l[i];
		if(t<80) 
		{
			printf("%s",word[i]);
			t+=1;
		}
		else if(t==80) 
		{
			printf("%s\n",word[i]);
			t=0;
		}
		else
		{
			printf("\n");
			t=0;
			i-=1;
		}
		if(t+l[i+1]<=80 && t!=0) printf(" ");
	}
	printf("%s",word[i]);
	return 0;
}
int main(){
	int n,i=0,len,L=0;
	char ori[300][42];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",ori[i]);
	}
	printf("%s",ori[0]);
	L+=strlen(ori[0]);
	for(i=1;i<n;i++){
		L+=strlen(ori[i])+1;
		if(L>80){
			L=0;
			printf("\n%s",ori[i]);
			L+=strlen(ori[i]);
		}else{
			printf(" %s",ori[i]);
		}
	}


	return 0;
}
int main()
{
	int i, n, j=0, l = 0, m=0,t=0, k;
	char str[10000];
	cin >> n;
	cin.get();
	cin.getline(str,10000);
	k = strlen(str);
	for ( i = 0 ; i < k ; i++ )
	{
		t++;
		if ( str[i] != ' ')
			m++;
		else
		{
			if ( t > 81)
			{
				if ( l != 0)
				{
					for ( j = l ; j < i - m - 1 ; j++ )
						cout << str[j];
					l = l + t - m - 1;
					i = i - m - 1;
					cout << endl;
					t=0;
				}
				else
				{
					for ( j = l; j < i - m - 1 ; j++ )
						cout << str[j];
					l = l + t - m - 1;
					i = i - m - 1;
					cout << endl;
					t=0;
				}
			}
			if ( t == 81 )
			{
				if ( l != 0 )
				{
					for ( j = l ; j < i ; j++ )
						cout << str[j];
					l = l + t;
					cout << endl;
					t=0;
				}
				else
				{
					for ( j = l ; j < i ; j++ )
						cout << str[j];
					l = l + t ;
					cout << endl;
					t=0;
				}
			}
			m=0;
		}
	}
	for ( j = l  ; j < k ; j++ )
		cout << str[j];
	return 0;
}
int main ( )
{
	int n, i, j, k, m;
	char word[1000][41] = {'\0'}, newword[1000][81] = {'\0'};
	cin >> n;
	for(i = 0;i < n;i++)
	{
		cin >> word[i];
	}
	j = 0;
	k = 0;
	for(i = 0;i < n;i++)
	{
		m = strlen(word[i]);
		if(j+m > 80)//?????????????????>80
		{
			newword[k][j-1] = '\0';
			newword[k][j] = '\0';//??????
			k++;
			strcpy(newword[k], word[i]);//???????
			j = m;
			newword[k][j] = ' ';//???????
			j++;
		}
		else if(j+m==80)
		{
			strcat(newword[k], word[i]);//????
			k++;
			j = 0;
		}
		else
		{
			if(j==0)
			{
				strcpy(newword[k], word[i]);
				j += m;
				newword[k][j] = ' ';
				j++;
			}
			else
			{
				strcat(newword[k], word[i]);
				j += m;
				newword[k][j] = ' ';
				j++;
			}
		}
	}
	newword[k][j-1] = '\0';
	newword[k][j] = '\0';
	for(i = 0;i <= k;i++)
	{
		m = strlen(newword[i]);
		for(j = 0;j < m;j++)
		{
			if(j == m-1)
				cout << newword[i][j] <<endl;
			else cout << newword[i][j];
		}
	}
	return 0;
}
int main(int argc, char *argv[])
{
  char word[40];
  int n,m,i,j,k,p,q,sum=0,flag=0;
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
  {
       scanf("%s",word);
       if(sum==0)
       {
         printf("%s",word);
                
       }
      
       if(sum!=0&&sum<=80&&(sum+strlen(word))<=80)
       {
         printf(" %s",word);
                                            
       }
       
       if(sum!=0&&sum<=81&&(sum+strlen(word))>80)
       {
         printf("\n%s",word);sum=0;
                                           
       }
        sum+=strlen(word)+1;                         
  }
  	
  return 0;
}
int main()
{
    int n,i,num,len;;
    char w[50];
    scanf("%d",&n);
    num=0;
    scanf("%s",w);
    len=strlen(w);
    for(i=0;i<n;i++)
    {
        if(num+len<=80)
        {
            if(i!=n-1)
            {
                printf("%s",w);
                num=num+len+1;
            }
            else
            printf("%s",w);
        }
        else
        {
            printf("\n");
            num=len+1;
            printf("%s",w);
        }
        scanf("%s",w);
        len=strlen(w);
        if((num+len<=80)&&(i!=n-1))
        printf(" ");
    }
}
int main(void){
	int n, i;
	char word[41];
	scanf("%d", &n);
	int curLen;
	curLen = 0;
	int afterLen;
	int wordLen;
	for (i=0; i<n; i++){
		scanf("%s", word);
		wordLen = strlen(word);
		if (curLen == 0){
			afterLen = curLen+wordLen;
			if (afterLen<=80){
				printf("%s", word);
				curLen = afterLen;
			}
			else{
				printf("\n%s", word);
				curLen = wordLen;
			}
		}
		else {
			afterLen = 1+curLen+wordLen;
			if (afterLen<=80){
				printf(" %s", word);
				curLen = afterLen;
			}
			else{
				printf("\n%s", word);
				curLen = wordLen;
			}
		}
	}
	printf("\n");
	return 0;
}
/*
 * wordedit.cpp
 *
 *  Created on: 2013-12-7
 *      Author: sony
 */

int main(){
	char word[503][40];
	int sum = 0,n;
	cin>>n;
	for(int i = 0;i < n;i++){
            cin>>word[i];
            }
	cout<<word[0];
	sum = strlen(word[0]) + 1;
    for(int i = 1;i < n;i++){
    	sum = sum +strlen(word[i]);
    if(sum  <= 80){
    	   cout<<' ';
           sum ++;
           }
    else {
         cout<<endl;
         sum = strlen(word[i]) + 1;
         }
    cout<<word[i];
    }
    return 0;
}
int main()
{
    int i,n,num=0,len;
    char s[100];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s",s);
        len=strlen(s);
        if(num==0)
        {
            printf("%s",s);
            num=len;
            continue;
        }
       if(num+len<80)
       {
           printf(" %s",s);
           num=num+len+1;
           continue;
       }
       if(num+len>=80)
       {
           printf("\n%s",s);
           num=len;
           continue;
       }
    }
    return 0;
}
int main()
{
	char A[2013][100];
	int N;
	scanf("%d\n",&N);
	for (int I = 1; I <= N; I ++) cin >> A[I];
	int S = 0;
	for (int I = 1; I <= N; I ++)
	{
		if (S == 0)
		{
			cout << A[I];
			S = strlen(A[I]);
		}
		else if (S + strlen(A[I]) + 1 <= 80)
			{
				cout << " " << A[I];
				S = S + strlen(A[I]) + 1;
			}
			else
			{
				S = 0;
				printf("\n");
				I --;
			}
	}
}
int main( )
{
	char a[250][45]={'\0'},c;
	int n,i,h,l,countnum;
	cin>>n;
	h=0;
	for(i=0;i<n;i++)
	{
		cin>>*(a+i);
               

		
	}
	countnum=0;
	i=0;
	while(i<n)
	{
		if((countnum+strlen(*(a+i)))<80)
		{
			if(countnum==0)
			{cout<<*(a+i);
			countnum=countnum+strlen(*(a+i));
			i++;}
			else 
			{
				cout<<" "<<*(a+i);
				countnum+=strlen(*(a+i))+1;
				i++;
			}
		}
		else 
		{
			cout<<endl;
			countnum=0;
		}
	}
	
	return 0;
}
int main()
{
	int n,i;
	scanf("%d",&n);
	char s[500][41];
	for(i=0;i<n;i++)
	{
		scanf("%s",s[i]);
	}
	int count=-1;
	for(i=0;i<n;i++)
	{
		count+=strlen(s[i])+1;
		if((count-strlen(s[i])-1)==-1)
                {
                        printf("%s",s[i]);
                        continue;
                }
		else if(count>0&&count<=80)printf(" %s",s[i]);
		else if(count>80)
		{
			count=-1;
			i--;
			printf("\n");
		}
		

	}
    
	return 0;
}
int main(int argc, char* argv[])
{
	int n,line,l1,l2,i,j,b;
	char s1[40],s2[40];
	scanf("%d",&n);
	line=80;
	scanf("%s",s1);
	l1=strlen(s1);
	for (i=1;i<=n;i++)
	{
		if (i!=n)
		{
			scanf("%s",s2);
		    l2=strlen(s2);
		}
		else l2=0;
		if (line-l1+b>0) 
		{
			line=line-l1;
			printf("%s",s1);
		}
		else
		{
			printf("\n%s",s1);
			line=80-l1;
		}
		b=0;
		if ((line-1-l2>=0)&&(i!=n))
		{
			printf(" ");
			line--;
			b=1;
		}
		for (j=0;j<l2;j++)
			s1[j]=s2[j];
		s1[l2]='\0';
		l1=l2;
//	    printf("*%d*",line);
	}
 	return 0;
}
int main()
{  int n,i,j,k,t;
   char word[40];

   scanf("%d",&n);

   for(i=0,t=81;i<n;i++)
   {scanf("%s",word);
     k=strlen(word);
	 if(t-k-1>=0) 
	  { if(t==81) printf("%s",word);
		 else printf(" %s",word);
       t=t-k-1;
	  }
	 else  {printf("\n");
	        t=81-k-1;
		    printf("%s",word);}   
   }
     printf("\n");
    return 0;
}
int main()
{
	char a[300][40];
	int i=0,n,words=0;
	cin>>n;
	do
	{
		cin>>a[i];
		i++;
	}
	while(i<n);
	for(i=0;i<n;i++)
	{
		words=words+strlen(a[i])+1;
		if(i!=n-1)
		{
			if(words+strlen(a[i+1])<=80)
			{
				cout<<a[i]<<" ";
			}
		    else
			{
				cout<<a[i]<<endl;
			    words=0;
			}
		}
		if(i==n-1)
		{
			cout<<a[i];
		}
	}
	return 0;
}
int main()
{
	int n;
	cin >> n;
	cin.get();
	char a[10000];
	memset(a,'\0',10000);
	gets(a);
	int q = strlen(a);
	for (int i = 0; i <= q; )
	{
		if (a[i + 80] == '\0')
		{
			puts(a+i);
			break;
		}
		else if(a[i + 79] == ' ')
		{
			a[i + 79] = '\n';
			for (int j = i; j <= i + 79; j++)
				putchar(a[j]);
			i += 80;
		}
		else if(a[i + 80] == ' ')
		{
			a[i + 80] = '\n';
			for (int j = i; j <= i + 80; j++)
				putchar(a[j]);
			i += 81;
		}
		else
		{
			int j = i + 79;
			for(;a[j] != ' ';j--);
			a[j] = '\n';
			for (int l = i; l <= j; l++)
				putchar(a[l]);
			i = j + 1;
		}
	}
}
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);
          //  cout << a;
            sum = l;
        }
       else
       if ( sum + l + 1 <= 80) 
       {
            cout << ' ' << a;
            sum = sum + l +1;
       }
       else 
       {
           sum = l;
           cout << endl<< a;
       }
    }
    return 0;
}
void main()
{
	int n,i;
	char a[300][40];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
	}
	int sum=0;
	for(i=0;i<n-1;i++){
		if((80-sum)>=(strlen(a[i]))&&(80-sum)<(strlen(a[i])+strlen(a[i+1])+1)){
			printf("%s\n",a[i]);
			sum=0;
		}
		else if((80-sum)>=(strlen(a[i])+strlen(a[i+1])+1)){
			printf("%s ",a[i]);
			sum=sum+strlen(a[i])+1;
		}
	}
	printf("%s\n",a[n-1]);
}
int main(){
	char word[42];
	int chars_left,word_length,i,j,word_num;

	scanf("%d",&word_num);
//???word????
	scanf("%s",&word);
	printf("%s",word);
	word_num--;
	word_length=strlen(word);
	chars_left=80-word_length;

//????word??
	while(word_num--){
		scanf("%s",&word);
		word_length=strlen(word);
		if(chars_left<word_length+1){
			printf("\n%s",word);
			chars_left=80-word_length;
		}
		/*else if(chars_left==word_length+1){
			printf(" %s\n",word);
			chars_left=80;
		}*/
		else{
			printf(" %s",word);
			chars_left-=word_length+1;
		}
	}
	return 1;
}
int main ()
{
	int n;
	char str[10000];
	char *b, *c;
	int flag = 0;
	c = str;
	b = str;
	
	cin >> n;
	cin.get();
	cin.getline(str, 10000);
	int len = strlen(str);
	if (len == 80) cout << str;
	else
	{
	for (; b - str < len + 1; b++)
    {
		if ((b - c + 1) % 80 == 0)
		{
			if(*b == ' ' )
			{	
				for (b = c; b < c + 79; b++)
				{cout << *b;}
			    cout << endl;
				b++;
				c = b;
			}
			else
			{
				if(*(b + 1) == ' ')
			    {
		    		for (b = c; b < c + 80; b++)
		    		{cout << *b;}
					cout << endl;
		    		b++;
		    		c = b;
	    		}
				else
				{
					int num = 0;
				    if (*(b + 1) != ' ')
					{
						while (*b != ' ')
						{
							b--; 
							num++;// ???????????????????
						}
					    for (b = c; b < c + 79 - num; b++)
		    		     {cout << *b;}
					     cout << endl;
		    		     b++;
		    		     c = b;
					}
				}
		    }
		   
    	} 
		if (*b == '\0')
		{
		    b = c;
			while (*b != '\0')
			{
				cout << *b;
				b++;
			}
			cout << endl;
		}
	}
	}
    return 0;       
}
int main()
{
    char a[40], *p;
    int n, s = 0, len = -1, flag = 0;
    p = a;
    cin >> n;
    while (s < n)
    {
          s++;
          cin >> a;
          len = len + 1 + strlen(a);
          if (len <= 80)
          {
               if (flag == 0)
               {
                    cout << a;
                    flag = 1;
               }
               else
               {
                   cout << ' ' << a;
               }
          }
          if (len > 80)
          {
               cout << endl;
			   cout << a;
               len = strlen(a);
          }
    }      
	return 0;
}
int main()
{
	int n;
	cin>>n;
	char a[1000][40]={'\0'};
	char *p=*a;
	int num[1000]={0};
	int *q=num;
	int i;
	for(i=0;i<n;i++)
		{
			cin>>*(a+i);
			*(q+i)=strlen(*(a+i));
	    }
	int count=*q;
	cout<<*a;
	for(i=1;i<n-1;i++)
	{
		if(count+*(q+i)+1<=80)
			{
				cout<<" "<<*(a+i);
				count+=*(q+i)+1;
				continue;
		    }
		if(count+*(q+i)+1>80)
		{
			cout<<endl;
			cout<<*(a+i);
			count=*(q+i);
			continue;
		}
	}
	if(count+*(q+n-1)+1<=80)
		cout<<" "<<*(a+n-1);
	else 
	{
		cout<<endl;
		cout<<*(a+n-1);
	}
	return 0;
}
int main()
{
	char a[41];
	int num,count=0,sum=0;
	cin>>num;
	while(count<num)
	{
		count++;
		cin>>a;
		int l=strlen(a);
		if(sum==0)
		{	
			cout<<a;
			sum+=l;
		}
		else if(sum+l+1>80)
		{
			cout<<endl;
			cout<<a;
			sum=l;
		}
		else if(sum>0&&sum+l<80)
		{
			cout<<" "<<a;
			sum+=(l+1);
		}
	}
	return 0;
}
int main()
{
	int n;
	scanf("%d\n",&n);
	char art[8000];
	gets(art);
	int len;
	len=strlen(art);
	int i,j=0,k=0;
	char wor[200][40];
	for(i=0;i<len;i++){
		if(art[i]!=' '){
			wor[j][k]=art[i];
			k++;
		}else{
			wor[j][k]='\0';
			k=0;
			j++;
		}
	}
	wor[j][k]='\0';
	int sum=0;
	int a;
	int be=0,ed;
	for(i=0;i<n;i++){
		a=strlen(wor[i]);
		sum+=a+1;
		if(sum<=81){
			ed=i;
		}else{
			for(j=be;j<ed;j++){
				printf("%s ",wor[j]);
			}
			printf("%s\n",wor[ed]);
			be=i;
			sum=a+1;
		}
	}
	for(i=be;i<n-1;i++){
		printf("%s ",wor[i]);
	}
	printf("%s",wor[n-1]);
	return 0;
}
/*
 *
 * ??????
 * ???2011-01-09
 * ?????? 1000012774
 * ???
 */

int main()
{
	int n,i,j,sum;
	int len[1000];
	char a[1000][40],b[1000][40];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
        len[i]=strlen(a[i])+1;
	}
	i=0;
	while(i<n){
		sum=0;
		while((sum+len[i])<=81){
			sum=sum+len[i];
			if((((sum+len[i+1])<=81)+(i<n-1)==2))
			cout<<a[i]<<" ";
			else
				cout<<a[i];
			i++;
		}
		cout<<endl;

	}
	cout<<endl;
	return 0;
}
int main(){
	char S1[41],S2[41];
	char *s1=NULL,*s2=NULL;
	int N,sum=0;
	cin>>N;
	cin>>S1;s1=S1;
	N=N-1;
	while(N>0){
		cin>>S2;
		s2=S2;
		int l1=strlen(S1),l2=strlen(S2);
		sum=sum+l1+1+l2;
		if(sum<=80){
			for(int i=0;i<l1;i++)
				cout<<*(s1+i);
			cout<<' ';
			sum=sum-l2;
			l1=l2;
			strcpy(S1,S2);
		}
		else {
			for(int i=0;i<l1;i++)
				cout<<*(s1+i);
			cout<<endl;
			sum=0;
			l1=l2;
			strcpy(S1,S2);
		}
		if(N==1)
			for(int i=0;i<l2;i++)
				cout<<*(s2+i);
		N--;
	}
	return 0;
}
//********************************
//*?????? 1300012733 **
//*???2013?12?14?
//********************************
int main()
{
	int n;
	char a[999999];
	cin >> n;
	cin.get();
	cin.getline( a , sizeof(a) );
	int l = strlen( a );
	char *p = a;
	while( p+80 <= a+l-1 )
	{
		p = p + 80;
		if( *p == ' ' )
			*p = '\n';
		else
		{
			while( *p != ' ' )
				p--;
			*p = '\n';
		}
		p++;
	}
	cout << a;
	return 0 ;
}
int main()
{
	int i=0,j=0,len,k,m,l,n,f;
	char a[100],b[100][100];
	cin>>n;
	for(f=0;f<n;f++)
	{	cin>>a;
		len=strlen(a);
		for(k=0;k<len;k++)
		{
			b[i][j++]=a[k];}
		if(j==79||j==80){b[i][j]='\0';i++;j=0;}
		else if(j>80){
			for(l=j-1;;l--)
			{
                if(b[i][l]!=' ')
				b[i][l]='\0';
				if(b[i][l]==' ')break;
			}b[i][l]='\0';j=0;i++;
			for(k=0;k<len;k++)
			{
				b[i][j++]=a[k];
			}
			b[i][j++]=' ';
		}
		else if(j<79)b[i][j++]=' ';
	}
	b[i][j-1]='\0';
	for(m=0;m<=i;m++){
			cout<<b[m]<<endl;
	}

	return 0;
}
int main()
{
	char a[50];
	int jishu,n,len=0,k=0;
	
	cin>>n;
	
	while(n>0)
	{
		if(k>0)
		{
			jishu=k+1;
		}
		else
		{
			jishu=0;
		}
		k=0;
		cin>>a;
		
		n--;
		len=strlen(a);
		jishu=jishu+len;
		cout<<a;
		
		while(jishu<=80)
		{

		   cin>>a;
		   n--;
		   
		   len=strlen(a);
			jishu=jishu+len;
			
			 if(jishu+1<=80)
			  {
				   cout<<" "<<a;
				   jishu++;
				   if(n==0)
				   {
					   break;
				   }
				   
			  }
			   else
			   {   k=len;
				   cout<<endl<<a;
				   cout<<" ";
				   break;
			   }
		   }
	}
	
		
		



	
	return 0;
}