Buggy python submission (verdict: Time Limit Exceeded):
s = input()

al = [chr(ord('a') + i) for i in range(26)]
c = dict()
for _al in al:
    c[_al] = [0]

for i in range(len(s)):
    for _al in al:
        if _al == s[i]:
            c[_al].append(c[_al][-1] + 1)
        else:
            c[_al].append(c[_al][-1])

f = False
for _al in al:
    tmp = []
    curmin = []
    for i in range(len(c[_al])):
        cur = c[_al][i] * 2 - i

        tmp.append(cur)
        if i == 0:
            curmin.append(cur)
        else:
            curmin.append(min(cur, curmin[-1]))

        if i >= 2 and tmp[-1] > curmin[-3]:
            y = i
            f = True
            break

    if f:
        break

if f:
    for j in range(len(tmp)):
        if tmp[j] == curmin[-3]:
            x = j + 1
            break
    print(' '.join([str(x), str(y)]))
else:
    print('-1 -1')


Fixed submission:
s = input()

al = [chr(ord('a') + i) for i in range(26)]
c = dict()
for _al in al:
    c[_al] = [0]

for i in range(len(s)):
    for _al in al:
        if _al == s[i]:
            c[_al].append(c[_al][-1] + 1)
        else:
            c[_al].append(c[_al][-1])

f = False
for _al in al:
    tmp = []
    curmin = []
    for i in range(len(c[_al])):
        cur = c[_al][i] * 2 - i

        tmp.append(cur)
        if i == 0:
            curmin.append(cur)
        else:
            curmin.append(min(cur, curmin[-1]))

        if i >= 2 and tmp[-1] > curmin[-3]:
            y = i
            f = True
            break

    if f:
        break

if f:
    for j in range(len(tmp)):
        if tmp[j] == curmin[-3]:
            x = j + 1
            break
    print(' '.join([str(x), str(y)]))
else:
    print('-1 -1')

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

al = [chr(ord('a') + i) for i in range(26)]
c = dict()
for _al in al:
    c[_al] = [0]

for i in range(len(s)):
    for _al in al:
        if _al == s[i]:
            c[_al].append(c[_al][-1] + 1)
        else:
            c[_al].append(c[_al][-1])

f = False
for _al in al:
    tmp = []
    curmin = []
    for i in range(len(c[_al])):
        cur = c[_al][i] * 2 - i

        tmp.append(cur)
        if i == 0:
            curmin.append(cur)
        else:
            curmin.append(min(cur, curmin[-1]))

        if i >= 2:
            if tmp[-1] > curmin[-3]:
                y = i
                f = True

                for j in range(len(tmp)):
                    if tmp[j] == curmin[-3]:
                        x = j + 1
                        break

                if f:
                    break

    if f:
        break

if f:
    print(' '.join([str(x), str(y)]))
else:
    print('-1 -1')


Fixed submission:
s = input()

al = [chr(ord('a') + i) for i in range(26)]
c = dict()
for _al in al:
    c[_al] = [0]

for i in range(len(s)):
    for _al in al:
        if _al == s[i]:
            c[_al].append(c[_al][-1] + 1)
        else:
            c[_al].append(c[_al][-1])

f = False
for _al in al:
    tmp = []
    curmin = []
    for i in range(len(c[_al])):
        cur = c[_al][i] * 2 - i

        tmp.append(cur)
        if i == 0:
            curmin.append(cur)
        else:
            curmin.append(min(cur, curmin[-1]))

        if i >= 2 and tmp[-1] > curmin[-3]:
            y = i
            f = True
            break

    if f:
        break

if f:
    for j in range(len(tmp)):
        if tmp[j] == curmin[-3]:
            x = j + 1
            break
    print(' '.join([str(x), str(y)]))
else:
    print('-1 -1')