Перевод из паскаля в питон var
len, max, count: longint;
s, s1: string;
maxC: char;
f: text;
begin
assign(f,'C:\24.txt');
reset(f);
readln(f, s);
len := length(s);
s1 := '';
for i:integer := 1 to len-2 do begin
if (s[i] = s[i+2]) then
s1 := s1.Substring(0, s1.LastIndexOf(s[i+1])) + s[i+1] + s1.Substring(s1.LastIndexOf(s[i+1]));
end;
len := length(s1);
max := 1;
count := 0;
for i:integer := 1 to len-1 do begin
if (s1[i] = s1[i+1]) then count := count + 1
else count := 0;
if count > max then begin
max := count;
maxC := s1[i];
end;
end;
writeln(maxC);
end.