Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

KMIN = 2
KMAX = 10 ** 12 + 1  # Exclusive

def main():
    n = int(input())
    k = []
    k += dividor_of(n - 1)
    for d in range(42):
        if d > 0:
            x = round(n ** (1.0 / d))
            if x ** d == n:
                k.append(x)
    k += eq72(n)
    k = sorted(x for x in k if x >= 2)
    print(len(set(k)))

def dividor_of(m):
    res = set()
    for i in range(1, 10 ** 6 + 1):
        if m % i == 0:
            res.add(i)
            res.add(m // i)
        if i ** 2 >= m:
            return sorted(list(res))

def eq72(n):
    res = []
    for k in range(2, 10 ** 6 + 1):
        for e in range(1, n // (k * k) + 2):
            for d in range(1, 42):
                if k ** d * (e * k + 1) > n:
                    break
                if k ** d * (e * k + 1) == n:
                    res.append(k)
    return res

if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3

KMIN = 2
KMAX = 10 ** 12 + 1  # Exclusive

def main():
    n = int(input())
    k = []
    k += dividor_of(n - 1)
    for d in dividor_of(n):
        if d < 2:
            continue
        x = n
        while x % d == 0:
            x //= d
        if x % d == 1:
            k.append(d)
    k = sorted(x for x in k if x >= 2)
    print(len(set(k)))

def dividor_of(m):
    res = set()
    for i in range(1, 10 ** 6 + 1):
        if m % i == 0:
            res.add(i)
            res.add(m // i)
        if i ** 2 >= m:
            return sorted(list(res))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

KMIN = 2
KMAX = 10 ** 12 + 1  # Exclusive

def main():
    n = int(input())
    k = []
    k += dividor_of(n - 1)
    for d in range(42):
        if d > 0:
            x = round(n ** (1.0 / d))
            if x ** d == n:
                k.append(x)
    k += eq72(n)
    k = sorted(x for x in k if x >= 2)
    print(len(set(k)))

def dividor_of(m):
    res = set()
    for i in range(1, 10 ** 6 + 1):
        if m % i == 0:
            res.add(i)
            res.add(m // i)
        if i ** 2 >= m:
            return sorted(list(res))

def eq72(n):
    res = []
    for k in range(2, 10 ** 6 + 1):
        for e in range(1, n // (k * k) + 2):
            for d in range(1, 42):
                if k ** d * (e * k + 1) > n:
                    break
                if k ** d * (e * k + 1) == n:
                    res.append(k)
    return res

if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3

KMIN = 2
KMAX = 10 ** 12 + 1  # Exclusive

def main():
    n = int(input())
    k = []
    k += dividor_of(n - 1)
    for d in dividor_of(n):
        if d < 2:
            continue
        x = n
        while x % d == 0:
            x //= d
        if x % d == 1:
            k.append(d)
    k = sorted(x for x in k if x >= 2)
    print(len(set(k)))

def dividor_of(m):
    res = set()
    for i in range(1, 10 ** 6 + 1):
        if m % i == 0:
            res.add(i)
            res.add(m // i)
        if i ** 2 >= m:
            return sorted(list(res))

if __name__ == "__main__":
    main()