Buggy python submission (verdict: Time Limit Exceeded):
S = input()
 
 
def solve():
    # print(S)
    diff = ord("a")
 
    head = 0
    while head < len(S):
        tail = head + 1
        while tail <= len(S):
            # print(S[head:tail])
            table = [0 for _ in range(abs(ord("z") - ord("a")) + 1)]
            for j in range(len(S[head:tail])):
                # print("\t{}".format(S[head:tail][j:j+1]))
                index = ord(S[head:tail][j:j+1]) - diff
                table[index] += 1
                # print(table[index], len(S[head:tail]), table[index] / len(S[head:tail]))
                if len(S[head:tail]) >= 2 and table[index] / len(S[head:tail]) > 0.5:
                    # print("hit:" + S[head:tail])
                    # print(head + 1, tail)
                    return head + 1, tail
 
            tail += 1
        head += 1
 
    # print("no hit")
    return -1, -1
 
res = solve()
print(res[0], res[1])

Fixed submission:
S = input()

def solve2():
    head = 0
    tail = 2
    while head < len(S):
        # print(S[head:tail])
        # print("\t" + S[head:tail][0:1])
        # print("\t" + S[head:tail][1:2])
        if S[head:tail][0:1] == S[head:tail][1:2]:
            return head + 1, tail
        head += 1
        tail += 1

    head = 0
    tail = 3
    while head < len(S):
        # print(S[head:tail])
        # print("\t" + S[head:tail][0:1])
        # print("\t" + S[head:tail][1:2])
        # print("\t" + S[head:tail][2:3])
        if S[head:tail][0:1] == S[head:tail][2:3]:
            return head + 1, tail
        head += 1
        tail += 1

    return -1, -1

res = solve2()
print(res[0], res[1])

Buggy python submission (verdict: Runtime Error):
S = input()


def solve():
    # print(S)
    diff = ord("a")

    head = 0
    while head < len(S):
        tail = head + 1
        while tail <= len(S):
            # print(S[head:tail])
            table = [0 for _ in range(abs(ord("z") - ord("a")))]
            for j in range(len(S[head:tail])):
                # print("\t{}".format(S[head:tail][j:j+1]))
                index = ord(S[head:tail][j:j+1]) - diff
                table[index] += 1
                # print(table[index], len(S[head:tail]), table[index] / len(S[head:tail]))
                if len(S[head:tail]) >= 2 and table[index] / len(S[head:tail]) > 0.5:
                    # print("hit:" + S[head:tail])
                    # print(head + 1, tail)
                    return head + 1, tail

            tail += 1
        head += 1

    # print("no hit")
    return -1, -1

res = solve()
print(res[0], res[1])


Fixed submission:
S = input()

def solve2():
    head = 0
    tail = 2
    while head < len(S):
        # print(S[head:tail])
        # print("\t" + S[head:tail][0:1])
        # print("\t" + S[head:tail][1:2])
        if S[head:tail][0:1] == S[head:tail][1:2]:
            return head + 1, tail
        head += 1
        tail += 1

    head = 0
    tail = 3
    while head < len(S):
        # print(S[head:tail])
        # print("\t" + S[head:tail][0:1])
        # print("\t" + S[head:tail][1:2])
        # print("\t" + S[head:tail][2:3])
        if S[head:tail][0:1] == S[head:tail][2:3]:
            return head + 1, tail
        head += 1
        tail += 1

    return -1, -1

res = solve2()
print(res[0], res[1])