//Мне скучно, потому я пишу сомнительный код по примеру Эникея
//PascalABC.NET 3.2 сборка 1318
Var
s,t,snew,curr,add,currsave:string;
i,j,flag:integer;
begin
readln(s);
readln(t);
//s=lowcase(s);
t:=lowercase(t);
while pos(' ',s)<>0 do
begin
flag:=0;
curr:=copy(s,1,pos(' ',s));
currsave:=curr;
if pos(t,lowercase(curr))<>0 then
begin
flag:=1;
delete(curr,pos(t,lowercase(curr)),length(t));
for j:=1 to length(curr) do
if ((curr[j]>='a') and (curr[j]<='я')) or ((curr[j]>='А') and (curr[j]<='Я')) or ((curr[j]>='a') and (curr[j]<='z')) or ((curr[j]>='A') and (curr[j]<='Z')) then<br> flag:=0;
end;
if flag=1 then snew+=curr else snew+=currsave;
delete(s,1,pos(' ',s));
end;
curr:=s;
currsave:=curr;
flag:=0;
if pos(t,lowercase(curr))<>0 then
begin
flag:=1;
delete(curr,pos(t,lowercase(curr)),length(t));
for j:=1 to length(curr) do
if ((curr[j]>='a') and (curr[j]<='я')) or ((curr[j]>='А') and (curr[j]<='Я')) or ((curr[j]>='a') and (curr[j]<='z')) or ((curr[j]>='A') and (curr[j]<='Z')) then<br> flag:=0;
end;
if flag=1 then
snew+=curr
else
snew+=currsave;
writeln(snew);
end.
Пример ввода:
Который из всех котов кот съел мясо
Пример вывода:
Который из всех котов съел мясо