sequence = '112222555555444'
max_len = -1
tmp_len = 0
end_index = 0
prew_value = -1
for index, value in enumerate(sequence):
if value != prew_value:
if tmp_len > max_len:
max_len = tmp_len
end_index = index
tmp_len = 1
prew_value = value
else:
tmp_len += 1
print ("{} from {} to {}".format(sequence[end_index - max_len: end_index], end_index - max_len, end_index))
c2VxdWVuY2UgPSAnMTEyMjIyNTU1NTU1NDQ0JwoKbWF4X2xlbiA9IC0xCnRtcF9sZW4gPSAwCmVuZF9pbmRleCA9IDAKcHJld192YWx1ZSA9IC0xCgpmb3IgaW5kZXgsIHZhbHVlIGluIGVudW1lcmF0ZShzZXF1ZW5jZSk6CglpZiB2YWx1ZSAhPSBwcmV3X3ZhbHVlOgoJCWlmIHRtcF9sZW4gPiBtYXhfbGVuOgoJCQltYXhfbGVuID0gdG1wX2xlbgoJCQllbmRfaW5kZXggPSBpbmRleAoJCXRtcF9sZW4gPSAxCgkJcHJld192YWx1ZSA9IHZhbHVlCgllbHNlOgoJCXRtcF9sZW4gKz0gMQoJCQpwcmludCAoInt9IGZyb20ge30gdG8ge30iLmZvcm1hdChzZXF1ZW5jZVtlbmRfaW5kZXggLSBtYXhfbGVuOiBlbmRfaW5kZXhdLCAgZW5kX2luZGV4IC0gbWF4X2xlbiwgZW5kX2luZGV4KSk=