Buggy python submission (verdict: Time Limit Exceeded):
def divisors(n):
    import math
    ret = set()
    for i in range(1, math.ceil(n**0.5)+1):
        if n % i == 0:
            if i != 1:
                ret.add(i)
            ret.add(n // i)
    return ret


def main():

    N = int(input())
    s = divisors(N)
    ans = divisors(N-1)

    for x in s:
        n = N
        while(n % x == 0):
            n = n // x
        if n % x == 1:
            ans.add(x)

    print(len(ans))

main()


Fixed submission:
def divisors(n):
    ret = set()
    for i in range(1, int(n**0.5)+2):
        if n % i == 0:
            ret.add(i)
            ret.add(n // i)
    ret.remove(1)
    return ret


def main():
    N = int(input())
    s = divisors(N)
    ans = divisors(N-1)

    for x in s:
        n = N
        if x == 1:
            continue
        while(n % x == 0):
            n = n // x
        if n % x == 1:
            ans.add(x)
    print(len(ans))


main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import math
    N = int(input())


    def divisors(n):
        ret = set()
        for i in range(1, math.ceil(n**0.5)+1):
            if n % i == 0:
                if i != 1:
                    ret.add(i)
                ret.add(n // i)
        return ret


    s = divisors(N)
    ans = divisors(N-1)

    for x in s:
        n = N
        while(n % x == 0):
            n = n // x
        if n % x == 1:
            ans.add(x)

    print(len(ans))
main()

Fixed submission:
def divisors(n):
    ret = set()
    for i in range(1, int(n**0.5)+2):
        if n % i == 0:
            ret.add(i)
            ret.add(n // i)
    ret.remove(1)
    return ret


def main():
    N = int(input())
    s = divisors(N)
    ans = divisors(N-1)

    for x in s:
        n = N
        if x == 1:
            continue
        while(n % x == 0):
            n = n // x
        if n % x == 1:
            ans.add(x)
    print(len(ans))


main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import math
    N = int(input())


    def divisors(n):
        ret = set()
        for i in range(1, math.ceil(n**0.5)+1):
            if n % i == 0:
                if i != 1:
                    ret.add(i)
                ret.add(n // i)
        return ret


    s = divisors(N)
    ans = divisors(N-1)

    for x in s:
        n = N
        while(n % x == 0):
            n = n // x
        if n % x == 1:
            ans.add(x)

    print(len(ans))
main()

Fixed submission:
def divisors(n):
    ret = set()
    for i in range(1, int(n**0.5)+2):
        if n % i == 0:
            ret.add(i)
            ret.add(n // i)
    ret.remove(1)
    return ret


def main():
    N = int(input())
    s = divisors(N)
    ans = divisors(N-1)

    for x in s:
        n = N
        if x == 1:
            continue
        while(n % x == 0):
            n = n // x
        if n % x == 1:
            ans.add(x)
    print(len(ans))


main()

Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())


def divisors(n):
    ret = set()
    for i in range(1, math.ceil(n**0.5)+1):
        if n % i == 0:
            if i != 1:
                ret.add(i)
            ret.add(n // i)
    return ret


s = divisors(N)
ans = divisors(N-1)

for x in s:
    n = N
    while(n % x == 0):
        n = n // x
    if n % x == 1:
        ans.add(x)

print(len(ans))


Fixed submission:
def divisors(n):
    ret = set()
    for i in range(1, int(n**0.5)+2):
        if n % i == 0:
            ret.add(i)
            ret.add(n // i)
    ret.remove(1)
    return ret


def main():
    N = int(input())
    s = divisors(N)
    ans = divisors(N-1)

    for x in s:
        n = N
        if x == 1:
            continue
        while(n % x == 0):
            n = n // x
        if n % x == 1:
            ans.add(x)
    print(len(ans))


main()