semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{	int i,j;
	char d,a[100][100]={0},b[100]={0},c[100]={0};
	j=0;for(i=0;;){d=getchar();if(d=='\n')break;else if((d>64&&d<91)||(d>96&&d<123)){*(a[j]+i)=d;i++;}else {i=0;j++;}}
	for(i=0;;){d=getchar();if(d=='\n')break;if((d>64&&d<91)||(d>96&&d<123)){*(b+i)=d;i++;}}
	for(i=0;;){d=getchar();if(d=='\n')break;if((d>64&&d<91)||(d>96&&d<123)){*(c+i)=d;i++;}}
	if(strcmp(a[0],b)==0)printf("%s",c);else printf("%s",a[0]);
	for(j=1;;j++){if(*a[j]==0){printf("\n");break;}else {printf(" ");if(strcmp(a[j],b)==0)printf("%s",c);else printf("%s",a[j]);}}
    return 0;}
int main()
{
	char s[1000],a[1000],b[1000],c[1000];
	int ls,la,lb,i,j,pointer=0,t,m=0,n=0;
	cin.get(s,1000);
	cin>>a;
	cin>>b;
	ls=strlen(s);
	la=strlen(a);
	lb=strlen(b);
	for(i=0;i<ls;i++)
	{
		int counter=0;
		
			for(j=0;j<la;j++)
			{
				if(s[i+j]==a[j])
				{counter++;continue;}
				else
					break;
			}
			if(counter==la&&(s[i]==a[0] &&  (i==0|| s[i-1]==' ')))
			{
				
				for(t=0;t<lb;t++)
				{
					c[pointer]=b[t];
					pointer++;
					
				}
				
		
				i=i+la-1;
            }
			else
			{
				c[pointer]=s[i];
				pointer++;
			}
		
	}
	c[pointer]='\0';
	for(j=0;j<pointer;j++)
		cout<<c[j];
	return 0;
}
int main()
{
    char *x=(char *)malloc(sizeof(char)*100);
    char *y=(char *)malloc(sizeof(char)*100);
    char *a=(char *)malloc(sizeof(char)*100);
    char *b=(char *)malloc(sizeof(char)*100);
    gets(x);
    scanf("%s",a);
    scanf("%s",b);
    int length=strlen(x);
    int l1=strlen(a);
    int l2=strlen(b);

    int yc=0;
    int i;
    for(i=0;i<length;i++)
    {
        if(x[i]==a[0]&&(i==0||x[i-1]==' '))
        {
            int j;
            int test=0;
            for(j=1;j<l1;j++)
            {
                if(x[i+j]!=a[j])
                {
                    test=1;
                    break;
                }
            }
            if(test!=0)
            {
                //printf("error is :%c\n",x[i]);
                y[yc]=x[i];
                yc++;
                //printf("this y is:%s\n",y);
            }
            else
            {
                if((i+j==length||x[i+j]==' ')&&(i==0||x[i-1]==' '))
                {
                    int k;
                    for(k=0;k<l2;k++)
                    {
                        y[yc]=b[k];
                        yc++;
                    }
                    i=i+j-1;
                }
            }
        }
        else
        {
            y[yc]=x[i];
            yc++;
        }
    }
    printf("%s\n",y);

    return 0;
}
void main()
{
	int i,j,p=0,k;
	char *s,*ch,*a,*b;
	s=(char *)malloc(10000*sizeof(char));
	ch=(char *)malloc(100*sizeof(char));
	a=(char *)malloc(100*sizeof(char));
	b=(char *)malloc(100*sizeof(char));

	gets(s);
	gets(a);
	gets(b);
	for(i=0;*(s+i)!='\0';i++)
	{
	for(j=0;(*(s+i)!=' '&&*(s+i)!='\0');i++,j++)
			*(ch+j)=*(s+i);
	*(ch+j)='\0';
	if (strcmp(ch,a)==0) strcpy(ch,b);
	if (p>0) printf(" ");
	printf("%s",ch);
	for(k=0;k<=j;k++) *(ch+k)='\0';
	p++;
	}
}
int main(){
	char s[110],a[110],b[110];
	gets(s);
	scanf("%s%s",a,b);
	int n=strlen(s);
	int na=strlen(a);
	int i,j,ans[30],c=0;
	for(i=0;i<n;i++){
		if(s[i]==' '||i==0){
			int count=0,q;
			if(i==0)
				q=0;
			else
				q=i+1;
			for(j=q;j<=q+na-1;j++){
				if(s[j]!=a[j-q])
					break;
				count++;
			}
			if(count==na){
				ans[c]=q;
				c++;
			}
		}
	}

	if(c==0)
		printf("%s",s);
	else{
		int p=0;
		for(i=0;i<=c-1;i++){
			for(j=p;j<ans[i];j++){
				printf("%c",s[j]);
			}
			printf("%s",b);
			p=ans[i]+na;
		}
		for(j=p;j<n;j++){
			printf("%c",s[j]);
		}
	}
}
int main()
{
char a[101][101]={0},b[101],c[101];
int i,j;
for(j=0;;j++)
{
scanf("%s",a[j]);

if(getchar()=='\n') break;
}
gets(b);
gets(c);
for(i=0;i<101;i++)
{
if(strcmp(a[i],b)==0) strcpy(a[i],c);
}
printf("%s",a[0]);
for(i=1;i<=j;i++)
{
printf(" %s",a[i]);
}
return 0;
}
void main()
{
	char *s,*a,*b,*p,*w[100];
	int i,j,k;
	s=(char *)malloc(100*sizeof(char));
	a=(char *)malloc(100*sizeof(char));
	b=(char *)malloc(100*sizeof(char));
	for(i=0;i<100;i++)
	{
		*s='\0';
		*a='\0';
		*b='\0';
	}
	gets(s);
	scanf("%s",a);
	scanf("%s",b);
	w[0]=(char *)malloc(100*sizeof(char));
	for(j=0;j<100;j++)
		*(w[0]+j)='\0';
	i=0;j=0;
	for(p=s;*p!='\0';p++)
	{
		if(*p!=' ')
		{
		    *(w[i]+j)=*p;
			j++;
		}
		else
		{
			i++;
			w[i]=(char *)malloc(100*sizeof(char));
			for(j=0;j<100;j++)
		        *(w[i]+j)='\0';
			j=0;
		}
	}
	k=i;
	for(i=0;i<k;i++)
	{
		if(strcmp(w[i],a)==0)
			strcpy(w[i],b);
		for(j=0;*(w[i]+j)!='\0';j++)
	        printf("%c",*(w[i]+j));
		printf(" ");
	}
	if(strcmp(w[k],a)==0)
		strcpy(w[k],b);
	for(j=0;*(w[k]+j)!='\0';j++)
	    printf("%c",*(w[k]+j));
	printf("\n");
}
int main()
{
    char a[1000],b[100],c[100],t[100];
    int lenb,lena,len;
    int i=0,j,k,flag;
    gets(c);
    scanf("%s",a);
    scanf("%s",b);
    len=strlen(c);
    lena=strlen(a);
    lenb=strlen(b);
    while(i<len)
    {
        j=0;
        while(isgraph(c[i]))
            t[j++]=c[i++];
        t[j]='\0';
        if(strcmp(t,a))
            printf("%s",t);
        else
            printf("%s",b);
        if(c[i])
            printf("%c",c[i++]);
    }
    return 0;
}
void main()
{
	char str1[100][100]={{0,0}},str2[100],str3[100],str4[100];
	int n,i=0,j=0,k[100]={0},m=0;
	gets(str2);
	scanf("\n");
	gets(str3);
	scanf("\n");
	gets(str4);
	n=strlen(str2);
	m=strlen(str4);
	for(i=0;i<n;i++)
	{
		if(str2[i]==' ')
		{
			j=j+1;
			k[j]=0;
		}
		else
		{
			str1[j][k[j]]=str2[i];
			k[j]=k[j]+1;
		}
	}
	for(i=0;i<=j;i++)
	{
		if(strcmp(str1[i],str3)==0)
		{
			if(k[i]<m)
			{memset(str1[i],0,m);
			strcpy(str1[i],str4);
			}
			else
			{
				memset(str1[i],0,k[i]);
				strcpy(str1[i],str4);
			}
		}
	}
	
		printf("%s",str1[0]);
		for(i=1;i<=j;i++)
			printf(" %s",str1[i]);
}
// Program Test.cpp : ??????????????
//

struct Vocabulary
{
	char character[Vocabularysize];
	struct Vocabulary *next;
};
int n=0;
char str[Sentencelength];
struct Vocabulary* create()
{
	int i;
	struct Vocabulary*head;
	struct Vocabulary *p1,*p2;
	n=0;
	int k=0,l=0;
	p1=p2=(struct Vocabulary*)malloc(sizeof(struct Vocabulary));//?????????
	for(l=k;str[l]!=' ';l++);
	for(i=k;i<l;i++)p1->character[i]=str[i];
	p1->character[i]='\0';
	k=l+1;
	i=0;
	head=NULL;
	
	while(str[i]!='\0')
	{
		n=n+1;//?????????????????????
		if(n==1)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct Vocabulary *)malloc(sizeof(struct Vocabulary));
	
		if(str[l]!='\0')
		{	for(l=k;str[l]!=' '&&l<=strlen(str)-1;l++);
			int m;
			for(i=k,m=0;i<l;i++,m++)p1->character[m]=str[i];
			p1->character[m]='\0';//copy the character
			k=l+1;
		}
		else i=l;
	}

	p2->next=p1;
	p2=p1;
	p2->next=NULL;

return (head);
}

void print(struct Vocabulary *head)
{
	struct Vocabulary*p;
	p=head;
	for(p=head;p->next!=NULL;p=p->next)
		printf("%s ",p->character);
	printf("%s\n",p->character);
	

}
int main()
{
	struct Vocabulary *head;
	gets(str);
//
	char stra[Sentencelength],strb[Sentencelength];
	gets(stra);
	gets(strb);
//
	head=create();
	struct Vocabulary *p=head;

	for(p=head;p!=NULL;p=p->next)
	{
//
		if(strcmp(p->character,stra)==0)
			strcpy(p->character,strb);
	
	
	}
	print(head);
	return 0;
}
int main ()  
{  
    int i,j,index,len,len2;  
    char str[101],word[101],newword[101],temp[101];  
    while(gets(str)){  
        index = 0;  
        len = strlen(str);  
        cin>>word;  
        cin>>newword;  
        for(i=0;i<=len;i++){  
            if(str[i] == ' ' || i == len){  
                temp[index] = '\0';  
                if(strcmp(temp,word) == 0){  
                    cout<<newword;  
                }  
                else{  
                    cout<<temp;  
                }  
                if(str[i] == ' '){  
                    printf(" ");  
                }  
                else{  
                    printf("\n");  
                }  
                index = 0;  
                memset(temp,0,sizeof(temp));  
            }  
            else{  
                temp[index++] = str[i];  
            }  
        }  
        getchar();  
    }  
    return 0;  
}
void main()
{
char stc[201],wrd1[101],wrd2[101],wrdd[100][101];
int i,j=0,k=0,l=0;
gets(stc);
gets(wrd1);
gets(wrd2);

for(i=0;stc[i]!='\0';i++)
{if(stc[i]!=' ')wrdd[j][k]=stc[i],k++;
else wrdd[j][k]='\0',j++,k=0;}

for(i=0;i<=j;i++)
 if(strcmp(wrd1,wrdd[i])==0)strcpy(wrdd[i],wrd2);

for(i=0,k=0;l<=j;i++)
{if(wrdd[l][k]!='\0') stc[i]=wrdd[l][k],k++;
else stc[i]=' ',l++,k=0;}
stc[i-1]='\0';
puts(stc);
}
void main()
{
	int i,j=0,k=0,len;
	char  s[100]={'\0'},a[100]={'\0'},b[100]={'\0'},temp[100][100]={'\0'};
	gets(s);
	gets(a);
	gets(b);
//	printf("%s\n",s);
//	printf("%s\n",a);
	len=strlen(s);
	for(i=0;i<len;i++)
	{
		if(s[i]!=' ')
		{
			temp[j][k]=s[i];
			k++;
		}
		else
		{
			k=0;
			j++;
		}
	}
	for(i=0;i<=j;i++)
	{
	//	printf("%s\n",temp[i]);
		if(strcmp(a,temp[i])==0)
		{
			if(i==0)
				printf("%s",b);
			else
				printf(" %s",b);
		}
		else if(i==0)
			printf("%s",temp[i]);
		else
			printf(" %s",temp[i]);
	}
}
int main()
{
	char s[999];
	char a[100];
	char b[100];
	int i=0,j=0,k;
	int add;
	char word[200][100]={'\0'};
	gets(s);
	gets(a);
	gets(b);
	for(k=0;s[k]!='\0';k++)
	{
		if(s[k]==' ')
		{
			i++;
		    j=0;
	    }
		else
		{			
			word[i][j]=s[k];
		    j++;
		}

	}
	add=i;
	for(i=0;i<add+1;i++)
	{
		if(strcmp(word[i],a)==0)
			strcpy(word[i],b);
	}
	for(i=0;i<add;i++)
		printf("%s ",word[i]);
	puts(word[i]);
	return 0;
}
int main()
{
    char sen[1000],a[1000],b[1000],end[2000]; //???????????????????
	int i,j,lensen,lena,lenb;                 //????????????????????????
    sen[0]=' ';                               //????????????
	a[0]=' ';                                 //???????????????????
	b[0]=' ';                                 //????????????????????????
    gets(&sen[1]);                            //????????????  
    cin>>&a[1]>>&b[1];                        //???????????????????
	                                          //????????????????????????
    lensen=strlen(sen)+1;                     //????????????
    lena=strlen(a)+1;                         //??????????????????
    lenb=strlen(b)+1;                         //????????????????????????
	                                          //????????????
    sen[lensen-1]=' ';
	a[lena-1]=' ';
	b[lenb-1]=' ';
    
	sen[lensen]='\0';
    a[lena]='\0';
    b[lenb]='\0';

    
    for(i=0,j=0;i<lensen;++i,++j)
    {
        if (strncmp(sen+i,a,lena) == 0)
        {
            strcpy(end+j,b);
            i = i+lena-1;
            j = j+lenb-1;
        }
        else
      {
            end[j] =sen[i];
        }                                          //??????????????????? 
    }                                            //????????????????????????
	                                            //????????????
    end[j-1] = 0;                                //???????????????????
    cout<<&end[1]<<endl;                        //????????????????????????
    return 0;                                   //????????????
}
int main()
{
	char s[10000];
	char tmp[105],a[105],b[105];
	int i,j;
	gets(s);
	scanf("%s",a);
	scanf("%s",b);
	for(i=0,j=0;s[i]!='\0';i++)
	{
		if(s[i]==' ')
		{
			tmp[j]='\0';
			j=0;
			if(strcmp(a,tmp)==0)
			{
				printf("%s ",b);
			}
			else 
			{
				printf("%s ",tmp);
			}
		}
		else
		{
			tmp[j]=s[i];
			j++;
			
		}
	}
	tmp[j]='\0';
	if(strcmp(a,tmp)==0)
			{
				printf("%s\n",b);
			}
			else 
			{
				printf("%s\n",tmp);
			}
	return 0;
}
void main()
{
	char c[101],a[101],b[101],s[10001];
	int n[101],i;
	for(i=0;i<=100;i++) c[i]=s[i]=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 m;
		char ch[101];
		for(m=0;m<=100;m++) ch[m]='\0';
		for(m=0;m<=(n[i]-n[i-1]-2);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);
}
/*
 * 1000012746_30_3.cpp
 *
 *  Created on: 2010-11-6
 *      Author: dyj
 *      Description:???????????????????<=100??
 *                  ???????????????????????????????????
 *                  ????????????????????????????????
 *
 */

int main(){
	char a[101],b[101],c[101],d[10001];
	cin.getline(a,101);
	cin>>b;
	cin>>c;
	int la=strlen(a);
	int lb=strlen(b);
	int lc=strlen(c);
	int i,j=0,k,num;
	for(i=0;i<la;i++){//???????????????lb???????
		for(k=0,num=0;k<lb;k++){
			if(a[i]==b[k])
				num++;
			i++;
		}//?num?????????
	   if(((num==lb)&&(a[i-k-1]==' '))||((num==lb)&&(i==k))){//??????????????
		   i=i-1;
		   for(k=0;k<lc;k++){
			   d[j]=c[k];
			   j++;
		   }//????c??
	   }
	   else {
		   i=i-k;
		   d[j]=a[i];
		   j++;
	   }//??????a
	   d[j]='\0';
	}
	cout<<d<<endl;//???????d
	return 0;//????
}
void Swap (char *str, char *FindWord, char *SwapWord){

 int j,s,k,i=0,SwapWordLength,yc,FindWordLength,n; 

 char *p1,*p2;

 p1=str; 

 p2=FindWord; 

 yc=strlen(str);   

 FindWordLength=strlen(FindWord); 

 SwapWordLength=strlen(SwapWord);  

 n=SwapWordLength-FindWordLength; 

 while(*p1!='\0'){

   if((*p1==*p2)&&(!isalpha(*(p1-1)))) 

   while((*p1==*p2)&&(*p2!='\0')) 

   { p1++; p2++; i++; }   

  else { p1++; i++; } 

  if((*p2=='\0')&&(isalpha(*p1)==0)){ 

 

   if(n<0){ 

    j=i-FindWordLength;  

    for(k=0; k<SwapWordLength; k++) 

     str[j++]=SwapWord[k]; 

    for(s=i; s<yc; s++) 

     str[j++]=str[s]; 

    while(j<yc) 

     str[j++]='\0'; 

     yc=strlen(str); 

    i+=n; 

    p1+=n; 

   } 

   else 

   { 

    for(s=yc+n; s>i; s--) 

     str[s]=str[yc--]; 

    j=i-FindWordLength; 

    for(k=0; k<SwapWordLength; k++) 

     str[j++]=SwapWord[k]; 

    yc=strlen(str); 

    i+=n; 

    p1+=n; 

   } 

  } 

  p2=FindWord; 

 } 

} 

int main(){

 char sen[MAX],old[LEN],a[LEN];

 gets(sen);

 gets(old);

 gets(a);

 Swap(sen,old,a);

 puts(sen);
 return 0;

}
int main()
{
  char s[20][100]={0},a[100]={0},b[100]={0},c;
  int i=0,j=0,n1=0,n2=0,m=0;
  for(i=0;i<20;i++)//?? 
  {
        cin>>s[i];
            c=getchar();
            if(c=='\n')
            {
                m=i;
            break;
            }
  }
cin>>a;
cin>>b;
    n1=strlen(a);
    for(i=0;i<=m;i++)//?????? 
    {
        n2=0;
        for(j=0;j<n1;j++)
        {
            if(s[i][j]==a[j]) n2=n2+1;
            else n2=n2;
        }
        if(n1!=n2) continue;
        for(j=0;j<100;j++)
        {
            s[i][j]=b[j];
        }
    }
    cout<<s[0];
    for(i=1;i<=m;i++)//?? 
    {
        cout<<" "<<s[i];
    }
    return 0;
}
int main()
{
	char string[100],str1[100],str2[100],str3[200];
	int n1,n2,i=0,s,j,a=0,b;
	gets(string);gets(str1);gets(str2);
	n1=strlen(str1);
	n2=strlen(str2);
	while(i<100)
	{b=0;
		for(j=0;j<n1;j++)
		{
			if((string[i+j]==str1[j]))
				b+=1;
			else b=0;}
		
		
		
		
		
		
		
		if(i==0){if(b==n1&&string[i+n1]==' ')
			{
				for(s=0;s<n2;s++)
				{str3[a]=str2[s];a++;}
		i+=n1;}
		else
		 {str3[a]=string[i];a+=1;i+=1;}}
		
		
		
		
		
		
		
		else
		{if(b==n1&&string[i+n1]==' '&&string[i-1]==' ')
			{
				for(s=0;s<n2;s++)
				{str3[a]=str2[s];a++;}
		i+=n1;}
		else
		 {str3[a]=string[i];a+=1;i+=1;}}
		
		
		
		
	}
	printf("%s",str3);
	return 0;
}
int main()
{
	char s[100],a[100],b[100];
	int x,y,z,i,j,k;
	gets(s);gets(a);gets(b);
	x=strlen(s);y=strlen(a);z=strlen(b);
	for(i=0;i<x;i++)
	{
		k=1;
		if(i!=0)
		{
			if(s[i]==' ')
			{
				k=0;
			    for(j=0;j<y;j++)
				{
					if(s[i+j+1]!=a[j]) k=1;
				}
			}
			if(k==0) 
			{
				printf(" ");
				for(j=0;j<z;j++) printf("%c",b[j]);
			    i=i+y;
			}
			if(k==1) printf("%c",s[i]);
		}
		else if(i==0)
		{
			k=0;
			for(j=0;j<y;j++)
			{
				if(s[j]!=a[j]) k=1;
			}
			if(k==0) 
			{
				for(j=0;j<z;j++) printf("%c",b[j]);
			    i=y-1;
			}
			if(k==1) printf("%c",s[0]);
		}
	}
	return 0;
}
char temp[1000];
char test[1000][1000];
char s[1000];
char d[1000];
char now[1000];
int main()
{
	//freopen("D:\\1.txt","r",stdin);
	cin.getline(temp,1000);
	cin>>s;
	cin>>d;
	memset(test,0,sizeof(test));
	int length=strlen(temp);
	int i;
	int j=0;
	int k=0;
	for(i=0;i<length;i++)
	{
		if(temp[i]!=' ')
			now[j++]=temp[i];
		else
		{
			strcpy(test[k],now);
			memset(now,0,sizeof(now));
			j=0;
			k++;
		}
	}
   strcpy(test[k],now);
	for(i=0;i<=k;i++)
	{
		if(strcmp(test[i],s)==0)
			strcpy(test[i],d);
	}
	for(i=0;i<=k;i++)
	{
		if(i!=k)
		cout<<test[i]<<" ";
		else
			cout<<test[i]<<endl;
	}
	return 0;
}
int main ( )
{
	char sen[1000]="\0";char word_1[101]="\0";char word_2[101]="\0";char word_1_1[101]="\0";
	int number[101]={0};
	int i,j,k;int sum;int num=0;int m=0;
	gets(sen);gets(word_1);gets(word_2);
	for(i=0;i<=strlen(sen)-strlen(word_1);i++)
	{
		sum=0;
		for(j=0;j<=strlen(word_1)-1;j++)
			word_1_1[j]=sen[j+i];
		for(j=0;j<=strlen(word_1)-1;j++)
		{
			if(word_1_1[j]!=word_1[j])
				sum=sum+1;
		}
		if((sum==0)&&(i!=0)&&(sen[i-1]!=' '))
			sum=sum+1;
		if(sum==0)
		{
			number[m]=i;m=m+1;num=num+1;
		}
	}
	for(k=1;k<=num;k++)
	{
		
		if(k==1)
			for(j=0;j<number[k-1];j++)
				printf("%c",sen[j]);
		if(k!=1)
			for(j=number[k-2]+strlen(word_1);j<number[k-1];j++)
				printf("%c",sen[j]);
		for(j=0;j<strlen(word_2);j++)
			printf("%c",word_2[j]);
		if(k==num)
		{
			if(number[k-1]+strlen(word_1)==strlen(sen))
				printf("\n");
			else
			{
				for(j=number[k-1]+strlen(word_1);j<strlen(sen);j++)
				{
					
					if(j==strlen(sen)-1)
						printf("%c\n",sen[j]);
					else
						printf("%c",sen[j]);
				}
			}
		}
	}
		
	if(num==0)
		printf("%s\n",sen);
	return 0;
}
int main(){
	char s[200],a[100],b[100],s_[200][200],s__[200];
	int i,n=0,m,j=0,p=0;
	gets(s);
	for(i=0;s[i]!='\0';i++){
		s__[i]=s[i];
	}
	s__[i]=' ';
	s__[i+1]='\0';
	scanf("%s%s",a,b);
	for(i=0;s__[i]!='\0';i++){
		n++;
	}
	for(i=0;i<n;i++){
		if(s__[i]==' '){
			s_[j][p]='\0';
			j++;
			p=0;
		}
		else{
			s_[j][p]=s__[i];
			p++;
		}
	}
	m=j;
	for(j=0;j<m-1;j++){
		if(strcmp(s_[j],a)==0){
			printf("%s ",b);
		}
		else{
			printf("%s ",s_[j]);
		}
	}
	if(strcmp(s_[m-1],a)==0){
		printf("%s",b);
	}
	else{
		printf("%s",s_[j]);
	}
	return 0;
}
int main()
{
	char zifu[101],word[100][20]={" "},x[20],y[20]; 
	int n,i,j,s,t=0,p=0,num;/*num?????????+1*/
	gets(zifu);
	gets(x);
	gets(y);
	n=strlen(zifu);
	for(i=0;i<n;i++)
	{
		if(zifu[i]!=' ')
		{
			word[t][p]=zifu[i];
			p++;
		}
		else if(zifu[i]==' ')
		{
			p=0;
			t++;
		}
		num=t+1;
	}
	for(i=0;i<num;i++)
	{
		if(!strcmp(word[i],x))
		{
			strcpy(word[i],y);
		}
	}
	printf("%s",word[0]);
	for(i=1;i<num;i++)
	{
	  printf(" %s",word[i]);
	}
   return 0;
}
int main()
{
	int n1,n2,n3,i,j;
	char a1[100]={'\0'},a2[100]={'\0'},a3[100]={'\0'};
	char *p1=&a1[0],*p2=&a2[0],*p3=&a3[0],*p_end,*p_in=&a1[0],*p,*p_cyc=&a1[0];
	
	gets(a1);
	gets(a2);
	gets(a3);
	n1=strlen(a1);
	n2=strlen(a2);
	n3=strlen(a3);
	p_end=&a1[n1-1];
	for(p1=&a1[0];p1<=p_end;p1++)
	{
		if(*p2==*p1)
		{
			p_in=p1;
			for(j=0;j<n2;j++)
			{
				if(*p2!=*p1)
				{
					p1--;
					break;
				}
				else
				{p2++;p1++;}
				
			}
			p2=&a2[0];
			if(j==n2&&*(p_in-1)==' ')//??
			{

				if(n3>n2)
				{
					p=p_end;
					
					//
					while(p>=p1)
					{
						*(p+n3-n2)=*p;
						p--;
					}
					p1=p1+n3-n2;
				}
				if(n3<n2)
				{
					p=p1;
					p1=p+n3-n2;
					
					while(p<=p_end)
					{
						*(p+n3-n2)=*p;
						p++;
					}
				}p_end=p_end+n3-n2;

			while(p_in<p1)//??
			{
				*p_in=*p3;
				p_in++;
				p3++;
			}
			}
			else if(j==n2&&p_in==&a1[0])//??
			{

				if(n3>n2)
				{
					p=p_end;
					
					//
					while(p>=p1)
					{
						*(p+n3-n2)=*p;
						p--;
					}
					p1=p1+n3-n2;
				}
				if(n3<n2)
				{
					p=p1;
					p1=p+n3-n2;
					
					while(p<=p_end)
					{
						*(p+n3-n2)=*p;
						p++;
					}
				}p_end=p_end+n3-n2;

			while(p_in<p1)//??
			{
				*p_in=*p3;
				p_in++;
				p3++;
			}
			}
			
			
			p3=&a3[0];
		}
	}
for(p=&a1[0];p<=p_end;p++)
{
	printf("%c",*p);
}


	return 0;
}
int main()
{
	char s[100];
	char a[100];
	char b[100];
	char c[100][100]={'\0'};
	int i,k=0,j=0;
	gets(s);
	gets(a);
	gets(b);
	for(i=0;s[i]!='\0';i++)
	{
		if(s[i]!=' ')
		{
			c[k][j]=s[i];
			j++;
		}
		if(s[i]==' ')
		{
			k++;
			j=0;
		}
	}
	for(i=0;i<=k;i++)
	{
		if(strcmp(c[i],a)==0)
		{
			strcpy(c[i],b);
		}
	}
	for(i=0;i<=k;i++)
	{
		if(i==0)
			printf("%s",c[i]);
		else 
			printf(" %s",c[i]);
	}
	return 0;
}
int main(int argc, char* argv[])
{
	char s[200],a[100],b[100];
	int l,result=0,i,j,l1;
	gets(s);
	gets(a);
	gets(b);
	l=strlen(s);
	l1=strlen(a);
	for (i=0;i<=l-1;i++)
	{
		result=0;
		if ((i==0)||(s[i-1]==' '))
		{
		result=1;
		for (j=i;j<=i+(l1-1);j++)
		{
			if (s[j]!=a[j-i]) result=0;			
		}
		}
		if (result==1) {printf("%s",b);i=i+l1-1;} else printf("%c",s[i]);
		
	}
	return 0;
}
void main()
{
	char str[1000],a[100],b[100],word[100];
	int i,j=0,flag=0;
	gets(str);
	gets(a);
	gets(b);
	i=0;
	while(str[i])
	{
		if (str[i]==' ')
		{
			if (flag!=0) printf(" ");
			flag=1;
			word[j]='\0';
			j=0;
			if (strcmp(word,a)==0)	printf("%s",b);
			else printf("%s",word);
		}
		else 
		{
			word[j]=str[i];
			j++;
		}
		i++;
	}
	word[j]='\0';
	if (flag!=0) printf(" ");
	if (strcmp(word,a)==0)	printf("%s",b);
	else printf("%s",word);
	
}
int main(int argc, char* argv[])
{
	char s1[100],s2[10],s3[10];
	gets(s1);
	gets(s2);
	gets(s3);
	char s4[10];
	int a, b=0;
	a=strlen(s1);
	for(int i=0;i<a;i++){
		if(s1[i]!=' '){
			if(i!=a-1){
				s4[b]=s1[i];
				b++;
			}
			if(i==a-1){
				s4[b]=s1[i];
				s4[b+1]='\0';
				if(strcmp(s4,s2)==0){
					printf("%s",s3);
				}
				else{
					printf("%s",s4);
				}
			}
		}
		else{
			s4[b]='\0';
			b=0;
			if(strcmp(s4,s2)==0){
				printf("%s ",s3);
			}
			else{
				printf("%s ",s4);
			}
		}
	}
	return 0;
}
int main(){
    char s[100],a[100],b[100];
    int i,l1,l2,e=0;
    gets(s);
    scanf("%s %s",a,b);
    getchar();
    l1=strlen(s);
    l2=strlen(a);
    for(i=0;i<l1;i++){
      if(i==0){
         if(a[0]==s[i]&&a[l2-1]==s[i+l2-1]&&s[i+l2]==' '){
              printf("%s", b);
              i +=l2-1;
         }else {
               printf("%c", s[i]);
               
         }
      }else{
          if(a[0]==s[i]&&a[l2-1]==s[i+l2-1]&&s[i-1]==' '){
              printf("%s", b);
              i +=l2-1;
         }else {
               printf("%c", s[i]);
               
         }  
      }
    }
    printf("\n");
    getchar();
    return 0;
}
int main(int argc, char* argv[])
{
	char s[100],a[100],b[100];
	char x[100],c[100]={'\0'};
	int i,t=0;
	gets(s);
	gets(a);
	gets(b);
	for(i=0;s[i]!='\0';i++)
	{
		if(s[i]!=' ')
		{
			x[t]=s[i];
			t++;
		}
		else
		{
			x[t]='\0';
			if(strcmp(x,a)==0)
			{
				strcat(c,b);
				strcat(c," ");
			}
			else
			{
				strcat(c,x);
				strcat(c," ");
			}
			t=0;
		}
	}
	x[t]='\0';
	if(strcmp(x,a)==0)
	{
		strcat(c,b);
	}
	else
	{
		strcat(c,x);
	}
	puts(c);
	return 0;
}