help me. >> WA 2 <<
this my code:
var
a,b,s,ms:string[50];
ss,mss,k,n,i,j:integer;
begin
readln(s);
n:=length(s);
mss:=0;
for i := 2 to n div 2 do
for j := 1 to n-i-1 do
begin
a:=copy(s,j,i);
ss:=1;
for k := j+1 to n-i+1 do
begin
b:=copy(s,k,i);
if a=b then inc(ss,1);
end;
if mss<=ss then
begin
mss:=ss;
ms:=a;
end;
end;
if mss=1 then write(s) else write(ms);
end.
OR
var
a,b,s,ms:string[50];
ss,mss,k,n,i,j:integer;
begin
readln(s);
n:=length(s);
mss:=0;
for i := 2 to n div 2 do
for j := 1 to n-i-1 do
begin
a:=copy(s,j,i);
ss:=1;
for k := j+1 to n-i+1 do
begin
b:=copy(s,k,i);
if a=b then inc(ss,1);
end;
if mss<=ss then
begin
mss:=ss;
ms:=a;
end;
end;
write(ms);
end.