semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	char str[1000];
	char a[50];
	char b[50];
	cin.getline(str,1000);
	cin.getline(a, 50);
	cin.getline(b,50);
	int i, j;
	for (i = 0; str[i] != '\0'; i ++)
	{
		int  len = 0, k;
		for (j = 0; a[j] != '\0'; j ++)
	       if(str[i + j] == a[j]  && (str[i - 1]==' '&& i!=0)||i == 0)
			   len ++;
		if (len == strlen(a) && (str[i + j] == ' '|| str[i + j] == '\0'))
		{
			if (strlen(a) >= strlen(b))
			{
				for (k = 0; k < strlen(b); k ++)
					str[i + k] = b[k];
				for (k = i + strlen(b); str[k]!='\0'; k ++)
					str[k] = str[k + strlen(a) - strlen(b)];
			}
			else
			{
				for (k = strlen(str)+ strlen(b) - strlen(a);k >= i + strlen(a);  k --)
					str[k] = str[k + strlen(a) - strlen(b)];
				for (k = 0; k < strlen(b); k ++)
					str[i + k] = b[k];
				i += strlen(b);
			}
            
				
		}
	}
	cout << str << endl;
	return 0;
}
int main()
{
 char wordbuff[50][20], ch, target[20], replace[20];
 int i, j;
 for (i=0;i<50;i++)
  for (j=0;j<20;j++)
   wordbuff[i][j]='\0';

 i=0;j=0;
 while (1)
 {
  ch=getchar();
  if (ch!='\n' && ch!=' ')
  {
   wordbuff[i][j]=ch;
   j++;
  }
  else
  {
   i++;
   j=0;
  }
  if (ch=='\n') break;
 }
 scanf("%s\n%s",target,replace);
 int n;
 for (n=0; n<i;n++)
 {
  if (!strcmp(wordbuff[n],target))
   strcpy(wordbuff[n],replace);
 }
 for (n=0;n<i;n++)
  if (!n) printf("%s",wordbuff[n]);
  else printf(" %s",wordbuff[n]);
 return 0;
}
/*
 * ???: 1000010191_30_3.cpp
 * ??: ???
 * ????: 2010-11-5
 * ??: ????
 */


int main()
{
	char s[101],a[101],b[101],r[101]=""; //?????,r???
	cin.getline(s,101);
	cin.getline(a,101);
	cin.getline(b,101);
	char temp[101];
	int templen=0;
	for (int i=0;s[i];i++)
	{
		if (s[i]!=' ')
		{
			temp[templen]=s[i];
			templen++;
		}
		else
		{
			temp[templen]='\0';
			if (!strcmp(temp,a))
				strcat(r,b); //?????????
			else
				strcat(r,temp); //????????
			strcat(r," "); //????
			templen=0;
		}
	}
	temp[templen]='\0';
	if (!strcmp(temp,a))
		strcat(r,b); //?????????
	else
		strcat(r,temp); //????????
	cout<<r<<endl;
	return 0;
}
/*
 * ????1000012737_31(5).cpp
 * ??????
 * ????: 2010-11-11
 * ?????????3???1???????????? s??2??????
 * ?? a (??<=100???3??a??????? b (??<=100)??s???
 * ??a???b?????????s???a???????s?????
 */

int main (){
	char s[201],a[101],b[101];//?????
	int S,A;//??S,A????s?a???
	int i,j,m=0;//??????
	cin.getline(s,201);S=strlen(s);//??s???s?????S
	cin.getline(a,101);A=strlen(a);//??a???a?????A
	cin.getline(b,101);//??b
	for(i=0;i<S;i++){//?s??????????????a
		if(s[i]==a[0]){
			for(j=i;j<A+i;j++){
					if(s[j]==a[j-i])
						m++;//??????a??????????????A????????????m??
			}
			if((i==0)&&(m==A)){
				cout<<b;//????????????s[i]??????,?????b
				i=i+A-1;//i??a????????
			}
			else if((m==A)&&(i!=0)&&(s[i-1]==32)){
				cout<<b;//???????????????s[i]????????????????????????b
				i=i+A-1;//i??a????????
			}
			else cout<<s[i];//?????????????????s[i]
			m=0;//?m????0
		}
		else cout<<s[i];//?????a???????????????
	}
	return 0;//????
}
void main()
{
	char s[101],s1[101],s2[101],s4[101];
	gets(s);
	gets(s1);
	gets(s2);
	char s3[100][101];
	char *p;
	char (*p3)[101];
	int n,i;
	n=strlen(s);
	p=s;
	p3=s3;
	i=0;
	for(p=s;p<=(s+n);p++)
	{
		if((*p==' ')||(*p=='\0'))
		{
			*((*p3)+i)='\0';
			p3++;
			i=0;
		}
		else
		{
			*((*p3)+i)=*p;
			i++;
		}
	}
	*((*p3))='\0';
	for(p3=s3;*((*p3))!='\0';p3++)
	{
		if(strcmp(*p3,s1)==0)
		{
			strcpy(*p3,s2);
		}
	}
	p3=s3;
	strcpy(s4,*p3);
	for(p3=s3+1;*((*p3))!='\0';p3++)
	{
		strcat(s4," ");
		strcat(s4,*p3);
	}
	puts(s4);
}
int main()
{
	char words[110],zfcsz[110][110];
	char a[110],b[110];
	int i,n,k,j;
	gets(words);
	scanf("%s",a);
	scanf("%s",b);
	n=strlen(words);
	k=0;
	j=0;
	for(i=0;i<n;i++)
	{
		if(words[i]!=' ')
		{
			zfcsz[k][j]=words[i];
			j++;
			if(i==n-1)
			{
				k++;
				zfcsz[k][j]='\0';
			}
		}
		else
		{
			zfcsz[k][j]='\0';
			k++;
			j=0;
		}
	}
	for(i=0;i<k-1;i++)
	{
		if(strcmp(zfcsz[i],a)==0)
		{
			printf("%s ",b);
		}
		else
		{
			printf("%s ",zfcsz[i]);
		}
	}
	if(strcmp(zfcsz[k-1],a)==0)
	{
		printf("%s",b);
	}
	else
	{
		printf("%s",zfcsz[i]);
	}
	return 0;
}
int main()
{
	char s[100],a[100],b[100];
	gets(s);
	gets(a);
	gets(b);
	int i,j=0,k=0;
	char c[100][100]={'\0'};
	for(i=0;s[i]!='\0';i++)
	{
		if(s[i]!=' ')
		{
			c[j][k]=s[i];
			k++;
		}
		else
		{
			j++;
			k=0;
		}
	}
	for(i=0;i<=j;i++){
		if(strcmp(c[i],a)==0)
		{
			strcpy(c[i],b);
		}
	}
	for(i=0;i<=j;i++)
	{
		if(i==0)
		printf("%s",c[i]);
        else
        printf(" %s",c[i]);
	}
	return 0;
}
void main()
{
	char *str[1024];
	int n=0,i;
	str[0]=(char*)calloc(101,sizeof(char));
	while(scanf("%s",str[n])!=EOF)
	{
		n=n+1;
		str[n]=(char*)calloc(101,sizeof(char));
	}
	for(i=0;i<n-3;i++)
	{
		if(strcmp(str[i],str[n-2])==0)
			printf("%s ",str[n-1]);
		else
			printf("%s ",str[i]);
	}
	if(strcmp(str[i],str[n-2])==0)
		printf("%s",str[n-1]);
	else
		printf("%s",str[i]);
}
void main()
{
char c=' ';
char *str1,*str2;
str1 = (char *)malloc(100*sizeof(char));
str2 = (char *)malloc(100*sizeof(char));

char str[100][100];
int i,n=0;
for(i=0;i<100;i++)
{
	strcpy(str[i],"\0");
    scanf("%s",str[i]);
    if(c=getchar()!=' ')break;
    n++;
}
strcpy(str1,"\0");
strcpy(str2,"\0");
scanf("%s",str1);
scanf("%s",str2);

for(i=0;i<=n;i++)
{
	if(strcmp(str1,str[i])==0)
		strcpy(str[i],str2);
}
for(i=0;i<=n-1;i++)
printf("%s ",str[i]);
printf("%s",str[n]);

}
int main ()
{
	char s[100],a[100],b[100],x[100];
	int len,n=0,at=1,i,j,t=0,m=0;
	gets(s),gets(a),gets(b);
	strcat(s," ");
	len=strlen(s);
	for(i=0;i<len+1;i++){
		if(s[i]==' '){
			at=0;
		}
		if(at==0){
			at=1;
			n++;
		}
	}
	for(i=0;i<n;i++){
		for(j=t;;j++){
			if(s[j]!=' '){
				x[j-t]=s[j];
			}
			else{
				x[j-t]='\0';
				t=j+1;
				m++;
				break;
			}
		}
		if(strcmp(x,a)==0){
			strcpy(x,b);
		}
		printf("%s",x);
		if(m!=n){
			printf(" ");
		}
	}
	return 0;
}
int main()
{
	char s[210]={0},a[100],b[100];int ls,la,i,j,k,g=0,lb;
        gets(s);cin>>a>>b;
        la=strlen(a);ls=strlen(s);lb=strlen(b);
     if(la<=ls)
            {
                        for(j=0;j<=ls-la;j++){   
                            if((j==0)||(s[j-1]<65))
{for(k=0;k<la;k++){if(a[k]==s[j+k])g++;}
                            if(g==la){if(lb>=la){for(i=ls+lb-la-1;i>=j+lb;i--)s[i]=s[i-lb+la];}
						        	  else {for(i=j+lb;i<ls+lb-la;i++)s[i]=s[i-lb+la];for(i=ls+lb-la;i<ls;i++)s[i]=0;}
									  for(i=0;i<lb;i++)s[i+j]=b[i];j=j+lb-1;}}
							g=0;ls=strlen(s);}}
                     ls=strlen(s);for(i=0;i<ls;i++) cout<<s[i];
         return 0;}
int main()
{
	char sen[100],word[50][20]={0},pre[20],post[20];
	int i,l,f[50]={0},g[50]={0};
	int word_num=0,char_num=0;
	gets(sen);
	gets(pre);
	gets(post);
	l=strlen(sen);
	for(i=0;i<l;i++){
		if(sen[i]!=' '){
			word[word_num][char_num]=sen[i];
			char_num++;
		}
		else if(sen[i]==' '){
			word_num++;
			char_num=0;
		}
	}
	for(i=0;i<=word_num;i++){
		f[i]=strlen(word[i]);
	}
	for(i=0;i<=word_num;i++){
		if(strcmp(word[i],pre)==0)
			strcpy(word[i],post);
	}
	for(i=0;i<word_num;i++){
		printf("%s",word[i]);
		printf(" ");
	}
	printf("%s",word[word_num]);
	return 0;
}
void main()
{
	char a[100]={0},b[100]={0};char temp[100][100]={{0}};
	int i,j,k,s1,a1,b1;
	for(i=0;i<100;i++)
	{
		scanf("%s",temp[i]);
		if(getchar()=='\n')
		{
			break;
		}
	}
	gets(a);gets(b);
	a1=strlen(a);b1=strlen(b);
	for(j=0;j<i;j++)
	{
		if(strcmp(temp[j],a)==0)
		{
			for(k=0;k<b1;k++)
			{
				temp[j][k]=b[k];
			
			}
				temp[j][b1]='\0';
		}
		printf("%s ",temp[j]);
	}
		if(strcmp(temp[i],a)==0)
		{
			for(k=0;k<b1;k++)
			{
				temp[i][k]=b[k];
			
			}
				temp[i][b1]='\0';
		}
		printf("%s",temp[i]);

}
/*
 * p7.cpp
 *
 *  Created on: 2010-11-5
 *      Author: ???
 *      ????
 */
int main()
{
	int i,j,k,a,l,sum=0;  //????????
	char s[101];
	char s1[101];
	char s2[101];
	char s0[101];
	cin.getline(s,101);   //?????
	cin>>s1;
	cin>>s2;
	int k1=strlen(s);
	for(i=0;i<strlen(s);i++)   //???????
	{	if((s[i]==s1[0]&&s[strlen(s1)+i]==' '&&s[i-1]==' ')||(i==0&&s[i]==s1[0]&&s[strlen(s1)+i]==' ')||(s[i]==s1[0]&&s[i-1]==' '&&i+strlen(s1)==strlen(s)))    //
		{
		for(a=0;a<strlen(s)-i-strlen(s1);a++)  //????????????
			s0[a]=s[i+strlen(s1)+a];
	for(j=0;j<strlen(s2);j++)   //???????
		s[i+j]=s2[j];
	for(l=0;l<strlen(s0);l++)   //????????
		s[i+j+l]=s0[l];
     sum++; i=i+strlen(s2)-strlen(s1);
		}
	}
	for(k=0;k<k1+sum*strlen(s2)-sum*strlen(s1);k++)
	cout<<s[k];   //??
	return 0;
}
int main()
{
	char s[10000] , a[100] , b[100] ;
	gets(s);
	gets(a);
	gets(b);
	int n = strlen(s)-strlen(a) , m = strlen(a) , l = strlen(s) , k[10] , d = 0;
	for(int i = 0;i<=n;i++)
	{
		int c = 0;
		for(int j = 0;j<m;j++)
		{
			if(a[j] != s[j+i])
				c ++;
		}
		if(c == 0 && (int)s[i-1]==32)
		{
			k[d+1] = i;
			d++;
		}
		else if(c ==0 && (int)s[i]>=65 && (int)s[i]<=90)
		{
			k[d+1] = i;
			d++;
		}
	}
	k[0] = 0;
	k[d+1] = l;
	for(int q = k[0];q<k[1];q++)
		    printf("%c",s[q]);
	for(int r = 1;r<=d;r++)
	{
		printf("%s",b);
	    for(int g = k[r]+m;g<k[r+1];g++)
		    printf("%c",s[g]);
	}
	return 0;
}
int main()
{
	char ch[11000],target[1000],replace[1000];
	cin.getline(ch,10000);
	cin.getline(target,110);
	cin.getline(replace,110);
	int c=strlen(ch);
	int t=strlen(target);
	ch[c]=' ';
	for(int i=0;i<c;i++)
	{
		if(ch[i]!=target[0])//??????????
			cout<<ch[i];
		else if(i==0&&ch[i]==target[0]&&ch[t]!=' ')//????????????????????????
			cout<<ch[i];
		else if (i>0&&(ch[i-1]!=' '||ch[i+t]!=' '))//???????????????
			cout<<ch[i];
		else//?????????????????
			{
				int count=0;
				for(int j=0;j<t;j++)
				{
					if(ch[i+j]==target[j])
						count++;
					else
						break;
				}
				if(count==t)
				{
					cout<<replace;
					i=i+t-1;
				}
				else
				{
					cout<<ch[i];
				}
			}
	}
	return 0;
 }
int main()
{
	int i,a=0,b=0;
	char zfc[101],y[101],x[101],word[101][101];
	gets(zfc);
	gets(y);
	gets(x);
	for(i=0;zfc[i]!='\0';i++){
		if(zfc[i]!=' '){
			word[a][b]=zfc[i];
			b++;
		}else{
			word[a][b]='\0';
			b=0;
			a++;
		}
	}
	word[a][b]='\0';
	for(i=0;i<=a;i++){
		if(strcmp(word[i],y)==0){
			strcpy(word[i],x);
		}
	}
	for(i=0;i<a;i++){
		printf("%s ",word[i]);
	}
	printf("%s\n",word[a]);
	return 0;
}
void Input (char *a, char *b, char *c){
gets(a);
gets(b);
gets(c);
}
void Swap (char *str, char *FindWord, char *SwapWord){
 int j,s,k,i=0,SwapWordLength,strLength,FindWordLength,n; 
 char *p1,*p2;
 p1=str; 
 p2=FindWord; 
 strLength=strlen(str);
 FindWordLength=strlen(FindWord);  
 SwapWordLength=strlen(SwapWord); 
 n=SwapWordLength-FindWordLength; 
 while(*p1!='\0'){
   if(*p1==*p2)
   while((*p1==*p2)&&(*p2!='\0')) 
   { p1++; p2++; i++; }   
  else { p1++; i++; } 
  if(*p2=='\0'&&(*(p1-FindWordLength-1)==' '||i-FindWordLength-2<0)){ 
   if(n<0){
    j=i-FindWordLength;
    for(k=0; k<SwapWordLength; k++) 
     str[j++]=SwapWord[k];
    for(s=i; s<strLength; s++) 
     str[j++]=str[s]; 
    while(j<strLength) 
     str[j++]='\0'; 
    strLength=strlen(str); 
    i+=n; 
    p1+=n; 
   } 
   else 
   { 
    for(s=strLength+n; s>i; s--) 
     str[s]=str[strLength--];
    j=i-FindWordLength; 
    for(k=0; k<SwapWordLength; k++) 
     str[j++]=SwapWord[k]; 
    strLength=strlen(str); 
    i+=n; 
    p1+=n; 
   } 
  } 
  p2=FindWord; 
 } 
} 
void main(){
 char sen[MAX],old[LEN],new[LEN];
 Input(sen,old,new);
 Swap(sen,old,new);
 puts(sen);
}
void main()
{
	char c[101],a[101],b[101],s[10001];
	int n[101],i;
	for(i=0;i<=100;i++)
	{
		c[i]='\0';
		s[i]='\0';
		a[i]='\0';
	}
	gets(c);
	gets(a);
	gets(b);
	int lc;
	lc=strlen(c);
	n[0]=-1;
	int j=1;
	for(i=0;i<=(lc-1);i++)
	{
		if(c[i]==' ')
		{
			n[j]=i;
			j++;
		}
	}
	n[j]=lc;
	char x[2];
	x[0]=' ';
	x[1]='\0';
	for(i=1;i<=j;i++)
	{
		int l,m;
		char ch[101];
		for(m=0;m<=100;m++)
		{
			ch[m]='\0';
		}
		l=n[i]-n[i-1]-1;
		for(m=0;m<=(l-1);m++)
		{
			ch[m]=c[n[i-1]+m+1];
		}
		if(strcmp(a,ch)==0)
		{
			strcat(s,b);
		}
		else strcat(s,ch);
		if(i<j) strcat(s,x);
	}
	puts(s);
}
int main()
{
    char a[100][100] , b[100] ,c[100] ;
    int i = 0 ;
    int len = 0 ;
    for( i = 0 ; i <= 99 ; i ++ )
    {
    cin >> a[i] ;
    len ++ ;
    if( cin.get() == '\n' )
    break ;
    }
    cin >> b >> c ;
    for( i = 0 ; i <= len - 1 ; i ++ )
    {
         if( strcmp( a[i] , b ) == 0 )
             strcpy( a[i] , c );
         if( i >= 1 )
             cout << " " ;
         cout << a[i] ;
    } 
return 0;
}
int main()
{
    int i,temp = 0,j = 0 , len,a[1000] ,temp2;
    char str[1000],str1[101],str2[101],name[1000][101];
    gets(str);
    gets(str1);
    gets(str2);
    len = strlen(str);
    for( i =0;i<=len;i++ )
    { 
       if( str[i]!=' ')
       {
         name[temp][j]= str[i];
         j++; 
       }
       
       if( str[i] == ' ' )
       {
          a[temp] = j;
          temp ++;          
          j = 0;
       }
    }
    for( j = 0 ;j< temp ;j++ )
    {if( strcmp( str1,name[j] )==0 )
    {cout <<str2<<" ";}
     else
     cout<<name[j]<<" ";
    }
     if(  strcmp( str1,name[temp] )==0 )
     cout <<str2;
     if(  strcmp( str1,name[temp] )!=0 )
     cout<<name[temp];
}
int main()
{
	int i,j,l=0,k=0,m[100],str1,str2,str3;
	char a[1000],b[100],c[1000],d[1000];
	cin.getline(a,1000);
	cin.getline(b,100);
	cin.getline(c,1000);
	str1=strlen(a);
	str2=strlen(b);
	str3=strlen(c);
	for(i=0;i<str1;i++)
	{
		for(j=0;j<str2;j++)
		{
			if(a[i+j]!=b[j])
			{
				break;
			}
			if(j==str2-1&&(a[i-1]==' '||i==0))
			{
				m[k]=i;k++;
			}
		}
	}
	k=0;
	for(i=0;i<str1;i++)
	{
		if(m[k]==i)
		{
			l++;k++;i+=str2-1;
			for(j=0;j<str3;j++)
			{
				cout<<c[j];
			}
		}
		else
		{
		    cout<<a[i];
		}
	}
	return 0;
}
int main()
{
	char s[100][100]={0};//????
	char a[100]={0},b[100]={0},n=0;//????????????????   n???????????
	int i=0,k=0,kongzhi=0,x=0;//????
	for(i=0;;i++)//????
	{
		for(k=0;;k++)
		{
			s[i][k]=getchar();
			if(s[i][k]==' '||s[i][k]=='\n')
				break;
		}
		n++;//?????
		if(s[i][k]=='\n')
			break;
	}
	for(i=0;;i++)//??
	{
		a[i]=getchar();
		if(a[i]=='\n')
			break;

	}
	for(i=0;;i++)//??
	{
		b[i]=getchar();
		if(b[i]=='\n')
		{
			x=i;
			b[i]=' ';
			break;
		}

	}
	for(i=0;i<n;i++)//??
	{
		for(k=0;k<100;k++)
		{
			if(s[i][k]!=a[k]&&s[i][k]!=' '&&s[i][k]!='\n')
				kongzhi=1;
		} 
		if(kongzhi==0)
		{
			if(i==n-1)
				b[x]=0;
			for(k=0;k<100;k++)
				s[i][k]=b[k];
		}
		kongzhi=0;
	}
	for(i=0;s[i][k]!=0;i++)//??
	{
		for(k=0;s[i][k]!=0;k++)
			cout<<s[i][k];
		k=0;//?K?????????????????
	}
	return 0;
}
int main ()
{
    int lena,posi,i,j;
    char a[101][100],b[101],c[101],index=0,e[200];
    gets(e);
i=0;
for(j=0;j<strlen(e);j++)
{
if(e[j]==' ')
{
index++;
i=0;
}
else
a[index][i++]=e[j];

}
index++;
//printf("%d!\n",index);
    scanf("%s",b);
    scanf("%s",c);
    for(i=0;i<index;i++)
{
       if(strcmp(a[i],b)==0) printf("%s",c);
       else printf("%s",a[i]);
if(i!=index-1)printf(" ");
}
    return 0;
}
/* begin 11:40 */
int main()
{
	char s[100][101],a[101],b[101];
	int i=0,j=0,k=0;
	for (i=0;;)
	{
		for (j=0;;j++)
		{
			scanf("%c",&s[i][j]);
			if (s[i][j]==' ') 
			{
				s[i][j]='\0';
				i++;
				break;
			}
			if (s[i][j]=='\n')
			{
				break;
			}
		}
		if (s[i][j]=='\n')
		{
			break;
		}
	}
	s[i][j]='\0';
	gets(a);
	gets(b);
	for (k=0;k<=i;k++)
	{
		if (strcmp(s[k],a)==0)
		{
			strcpy(s[k],b);
		}
	}
	for (k=0;k<=i;k++)
	{
		if (k==0) printf("%s",s[k]);
		else printf(" %s",s[k]);
	}
	return 0;
}
void main()
{
   char a[100][100],b[25],c[25],d;
   int m,n,p[25],q,i,j;
   
   i=0;
   do
   {
	   scanf("%s",&a[i]);
       i++;    
   }while(getchar()!='\n');
   scanf("%s",&b);
   scanf("%s",&c);
   for (j=0;j<i;j++)
   {
	   p[j]=1;   
	   if (strcmp(a[j],b)==0)
	   {
		   p[j]=0;
	   }
   }
   for (j=0;j<i;j++)
   {
	   if (j!=0)
	   {
		   printf(" ");
	   }
	   if (p[j]!=0)
	   {
		   printf("%s",a[j]);
	   }
	   else printf("%s",c);
   }
}
char str1[150],str2[50],str3[50];
char *p1=str1,*p2=str2,*p3=str3;

int compare(char *local,int len)
{
	p2=str2;
	char* p;
	int flag=1;
	for(p=local;*p2!='\0'&&flag==1&&p<local+len;p2++,p++)
		if(*p!=*p2) flag=0;
	if(*p2=='\0'&&p==local+len) return 1;
	else return 0;
}

int main()
{
	char newline[150];
	char *news=newline,*local,*p;
	int flag=1,len=0;
	gets(p1);gets(p2);gets(p3);
	for(p1=str1;p1<=str1+strlen(str1);p1++)
	{
		if(isalpha(*p1))
			if(flag==1) flag=0,len=1,local=p1;
		    else len++;
		else
			if(flag==0) 
			{
				flag=1;
				if(compare(local,len)) for(p3=str3;*p3!='\0';p3++,news++) *news=*p3;
				else for(p=local;p<local+len;p++,news++) *news=*p;
				*news++=*p1;
			}
	}
	*news='\0';
	for(news=newline;*news!='\0';news++)
		printf("%c",*news);
	
	return 0;

}
void huan(int start,char W[100],char B[100],int Len1,int Len2,int Len3,int t)
{
	int i,k;
	char WW[100];
	for(i=0;i<start;i++)
		WW[i]=W[i];
	for(i=start,k=0;i<start+Len3;i++,k++)
		WW[i]=B[k];
	for(i=start+Len3;i<=Len1-Len2*t+Len3*t-1;i++)
		WW[i]=W[i+Len2-Len3];
	for(i=0;i<=Len1-Len2*t+Len3*t-1;i++)
		W[i]=WW[i];
}


int main()
{
	char whole[100];
	char a[100];
	char b[100];
	char gai[100];
	gets(whole);
	gets(a);
	gets(b);
	int i,j,k,t;
	int len1;
	int len2;
	int len3;
	len1=strlen(whole);
	len2=strlen(a);
	len3=strlen(b);
    int judge;
	int begin[100];
	t=0;
	if(whole[0]!=a[0])
	{
	for(i=0;i<len1-len2+1;i++)
	{
		for(j=i, k=0;j<len2+i;j++,k++)
		{
			if(whole[j]!=a[k])
			{
				judge=0;
				break;
			}
			else
				judge=1;
		}
		if(whole[i-1]==' ' && judge==1)
		{
		    begin[t]=i;
			t++;
		}
	}
	}
	else
	{
		t=1;
		begin[0]=0;
for(i=0;i<len1-len2+1;i++)
	{
		for(j=i, k=0;j<len2+i;j++,k++)
		{
			if(whole[j]!=a[k])
			{
				judge=0;
				break;
			}
			else
				judge=1;
		}
		if(whole[i-1]==' ' && judge==1)
		{
		    begin[t]=i;
			t++;
		}
	}
	}

	if(len1>=len2)
	{
    int u;
	for(i=t-1,u=1;i>=0;i--,u++)
	{
		huan(begin[i],whole,b,len1,len2,len3,u);
	}
	for(i=0;i<=len1-1-len2*(u-1)+len3*(u-1);i++)
	{
		printf("%c",whole[i]);
	}
	}
	else
	{int v;
	for(i=0,v=1;i<=t-1;i++,v++)
	{
		huan(begin[i],whole,b,len1,len2,len3,v);
	}
	for(i=0;i<=len1-1-len2*(v-1)+len3*(v-1);i++)
	{
		printf("%c",whole[i]);
	}
	}


	return 0;
}
int main()
{
	char s[103],a[103],b[103],t[103][103];
	int i,len,start=0,end=1,cur=0,k=0,w,e;
	
	int result;
	char *p=NULL;
	gets(s);
	gets(a);
	gets(b);
	len=strlen(s);
	w=strlen(a);
	e=strlen(b);
	
	
	while(end<len)
	{
		if(s[end]==' '||s[end]==0)
		{
			for(i=start,k=0;i<end;i++,k++)
				t[cur][k]=s[i];
				t[cur][k+1]='\0';
				cur++;
				start=end+1;
				end=start+1;
		}
		else end++;
	}
	
	
				for(i=start,k=0;i<end;i++,k++)
				t[cur][k]=s[i];
				t[cur][k+1]='\0';
				cur++;
	
	for(i=0;i<cur;i++)
{
	if(i==cur-1)
	{
		if(strcmp(t[i],a)==0)
			printf("%s",b);
		else printf("%s",t[i]);
	}
	else
	{
		if(strcmp(t[i],a)==0)
			printf("%s ",b);
		else printf("%s ",t[i]);
	}
	

}

}
int main()
{
    char s[100],a[100],b[100],c[100];
    int len1=0,len2=0,len3=0,i,j,n=-1,k,flag;  //flag????s????a?1???
    cin.getline(s,101,'\n');                  //??
    cin.getline(a,101,'\n');
    cin.getline(b,101,'\n');
    
    for(len1=0;s[len1]!='\0';len1++);          //?len1,len2,len3??s,a,b???
    for(len2=0;a[len2]!='\0';len2++);
    for(len3=0;b[len3]!='\0';len3++);
	
     
    for (i=0;i<len1;i++)
    {   
        flag=0;            //??0                  
        if (((i!=0)&&(s[i]==a[0])&&(s[i-1]==' '))||((i==0)&&(s[i]==a[0])))   //??s???????a??,????????????????????(?????),?????
		{ flag=1;          //flag??1
          for (j=1;j<len2;j++)
          if (s[i+j]!=a[j]) flag=0;//??????a??,flag?0
		  if (((i+j)!=len1)&&(s[i+j]!=' ')) flag=0; //???????????????????,?????,??flag=0;
        }
        
         if (flag)             //??s??a,?b????????c
         {
			 k=n+1;             
             while(n<k+len3-1)
			 {n++;c[n]=b[n-k];}
			 i=i+len2-1;         //i??s???a???
		 }
         else
         {n++;c[n]=s[i];}        //??????a,???s????c
    }
    for (i=0;i<=n;i++) cout<<c[i];  //??c
    
    return 0;
 }
void main()
{int i,j,n;
 char x[100][100];
 for (i=0;i<100;i++)
 {scanf("%s",x[i]);
  if (strlen(x[i])==0)
	  break;
 }
 n=i;
 for (i=0;i<n;i++)
 {if (strcmp(x[i],x[n-2])==0)
     strcpy(x[i],x[n-1]);
 }
 printf("%s",x[0]);
 for (i=1;i<n-2;i++)
	 printf(" %s",x[i]);
}
int main()
{
	int i,j,k,w,nw=0,ns,na,nb,rem[102],flag,FLAG=0;
	char s[102],a[102],b[102];
	int vest[102];
	gets(s);
	gets(a);
	gets(b);
	ns=strlen(s);
	na=strlen(a);
	nb=strlen(b);
	for (i=0;i<ns;i++)
	{

	if (s[i]!=' ' && FLAG==0)
	{
		FLAG=1;
		flag=0;
		for (k=i,j=0;j<na;j++,k++)
		{
			if (s[k]!=a[j])
			{
				flag=1;
				break;
			}
		}
		if (flag==0 && (s[k]==' ' || s[k]=='\0'))
		{
			rem[nw]=i;
			nw++;
		}
	}
	else
	{
		FLAG=0;
	}

	}
	for (w=0;w<nw;w++)	
	{
			if (nb==na)
			{
				for (k=0;k<na;k++)
				{
					s[k+rem[w]]=b[k];
				}
			}
			else if (nb>na)
			{
				ns=ns+nb-na;
				s[ns]='\0';
				for (k=ns-1;k>rem[w];k--)
				{
					s[k]=s[k-nb+na];
				}
				for (k=0;k<nb;k++)
				{
					s[k+rem[w]]=b[k];
				}				
				for (j=0;j<nw;j++)
				{
					rem[j]=rem[j]+nb-na;
				}
			}
			else
			{
				ns=ns+nb-na;
				for (k=rem[w]+1;k<ns;k++)
				{
					s[k]=s[k-nb+na];
				}
				for (k=0;k<nb;k++)
				{
					s[k+rem[w]]=b[k];
				}				
				for (j=0;j<nw;j++)
				{
					rem[j]=rem[j]+nb-na;
				}
			}
	}
	for (i=0;i<ns;i++)
	{
		printf("%c",s[i]);
	}
	printf("\n");
	return 0;
}
int main()
{
	int j=0,i,l,ls;
	char s[105],str[105],a[105],x[105],s1[105]={' ','\0'},s2[2]={' ','\0'};
	gets(s);
	gets(str);
	gets(a);
	strcat(s,s2);
	strcat(s1,s);
	strcpy(s,s1);
	l=strlen(str);
	ls=strlen(a);
	strcpy(x,s);
	for(i=0;s[i]!='\0';i++){
		if(s[i]==str[j]){
			j++;
		}else{
			j=0;
		}
		if(l==j&&s[i-j]==' '&&s[i+1]==' '){
			if(i-j!=-1){
			    x[i-j+1]='\0';
		    	strcat(x,a);
			}else{
				strcpy(x,a);
			}
			strcat(x,s+i+1);
			i=i+ls-l;
			j=0;
			strcpy(s,x);
		}
	}
	for(i=0;x[i+2]!='\0';i++){
        x[i]=x[i+1];
	}
	x[i]='\0';
	printf("%s",x);
	return 0;
}
int main()
{
    char s[101];//????????
    char a[101];
    char b[101];
    char d[101][101];//
    int l;//???s?
    int i,j,k;  //????
    while(gets(s)){//?????s
        int t=0;
		scanf("%s",a);//?????a
        scanf("%s",b);//?????b
		getchar();//
		l=strlen(s);//?????s???
		i=0;//???????
		j=0;
		k=0;
		for(i=0;i<=l;i++){//??
			if(s[i]==' '){//????????????
				d[j][k]='\0';
				k=0;
				++j;//?????1
			}
			else if(s[i]=='\0'){//???????
				d[j][k]='\0';
				++j;//?????1
			}
			else{
				d[j][k] = s[i];++k;//??????????????
			}
		}
		for(i=0;i<j;i++){//??
			if(strcmp(a,d[i])==0)//?????????
				strcpy(d[i],b);
		}
		for(i=0;i<j-1;i++)//??
			printf("%s ",d[i]);
		printf("%s\n",d[i]);}//????
	return 0;
}
void main()
{
	char str[100],str2[100],original[100],word[100],replace[100];
	int len ;
	gets(str);
	len = strlen(str);
	str[len]=' ';
	str[len+1]='\0';
	gets(original);
	gets(replace);
	int i = 0 ,p = 0 ,wordlen = 0 ,j = 0,temp=0 , k ,n=0;
	int t = 0;
	while(i<strlen(str))
	{

		if(str[i]!=' ')
		{
			word[j]=str[i];
			j++;
			i++;
			temp=1;
		}else if(temp==1)
		{
			word[j]='\0';
	/*	printf("??word:");
			while(t<strlen(word))
			{
				printf("%c",word[t]);
				t++;
			}
			printf("\n");*/
			t=0;
			if(strcmp(word,original)==0)
			{
				for(k=0;k<(i-j);k++)//???????????str2
				{
					str2[k] = str[k];
				}
				n = 0 ;
				while(n<strlen(replace))//????????
				{
					str2[k]=replace[n];
					n++;
					k++;
				}
				n = i ;
				while(n<strlen(str))//???????????
				{
					str2[k]=str[n];
					n++;
					k++;
				}
				n=0;
				while(n<k)//????str
				{
					str[n]=str2[n];
					n++;
				}
				str[n]='\0';
				i = 0;//??????
			}else
			{
				i++;//?????????
			}
			j=0;
			temp=0;
		}else if(temp==0)//??????
		{
			i++;
		}
	}
	i = 0 ;
	while(i<strlen(str)-1)
	{
		printf("%c",str[i]);
		i++;
	}

}
char w[100];
char m[200][200];           
char a[200],b[200];
int main()
{
	gets(w);
	scanf("%s",a);
	scanf("%s",b);
	int p=0,q=0,r;
	for(r=0;w[r]!='\0';r++)
	{
		if(w[r]==' ') 
		{
			p++;
			q=0;
		}
		else
		{
			m[p][q]=w[r];
			q++;       
		}
	}
	int i,x;
	for(i=0;i<p+1;i++)
	{
		if(strcmp(m[i],a)==0)
		{
			for(x=0;x<(strlen(b)+1);x++)
			{
				m[i][x]=b[x];
			}
		}
	}
	printf("%s",m[0]);
	for(i=1;i<p+1;i++)
	{
		printf(" %s",m[i]);
	}

	return 0;
}
void main()
{
	char s[30][20]={0};
	char a[101]={0}, b[101]={0};
	char ch, (*p)[20];
	int i=0;
	ch=0;
	while (ch!='\n')
	{
		scanf("%s",s[i++]);
	ch=getchar();
	}

	gets(a);
	gets(b);

	p=&s[0];
	while(strcmp(*p,"")!=0)
	{
		if (strcmp(*p,a)==0) printf("%s",b);
		else printf("%s", *p);
		p++;
		if (strcmp(*p,"")!=0) printf(" ");
	}

}