import re
def func(in_str):
print('-------')
print('in : ' + in_str)
print('out:')
print(in_str)
s = in_str
while True:
in_str = re.sub(r'(.)\1{3,}', '', in_str, 1)
if in_str == s:
return
print(in_str)
s = in_str
if __name__ == '__main__':
func('11233344433331111143322211')
func('1122224411112222')
func('211222211333312')
aW1wb3J0IHJlCgoKZGVmIGZ1bmMoaW5fc3RyKToKICAgIHByaW50KCctLS0tLS0tJykKICAgIHByaW50KCdpbiA6ICcgKyBpbl9zdHIpCiAgICBwcmludCgnb3V0OicpCiAgICBwcmludChpbl9zdHIpCiAgICBzID0gaW5fc3RyCiAgICB3aGlsZSBUcnVlOgogICAgICAgIGluX3N0ciA9IHJlLnN1YihyJyguKVwxezMsfScsICcnLCBpbl9zdHIsIDEpCiAgICAgICAgaWYgaW5fc3RyID09IHM6CiAgICAgICAgICAgIHJldHVybgogICAgICAgIHByaW50KGluX3N0cikKICAgICAgICBzID0gaW5fc3RyCgppZiBfX25hbWVfXyA9PSAnX19tYWluX18nOgogICAgZnVuYygnMTEyMzMzNDQ0MzMzMzExMTExNDMzMjIyMTEnKQogICAgZnVuYygnMTEyMjIyNDQxMTExMjIyMicpCiAgICBmdW5jKCcyMTEyMjIyMTEzMzMzMTInKQo=