Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
input = lambda: sys.stdin.readline().rstrip()


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def solve():
    A, B = map(int, input().split())

    ans = 1
    max_n = min(A, B)

    if A == B:
        if is_prime(A):
            print(2)
            exit()

    for n in range(2, max_n):
        if A == 1 or B == 1:
            break

        if A % n == 0 and B % n == 0:
            ans += 1

            while True:
                if A % n == 0 and B % n == 0:
                    A = A // n
                    B = B // n
                else:
                    break

    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
import math
input = lambda: sys.stdin.readline().rstrip()


def factorize(n):
    b = 2
    fct = set()
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct |= set([b])
        b = b + 1
    if n > 1:
        fct |= set([n])
    return fct


def solve():
    A, B = map(int, input().split())
    ap = factorize(A)
    bp = factorize(B)
    ans = 1 + len(ap & bp)
    print(ans)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
input = lambda: sys.stdin.readline().rstrip()


def solve():
    A, B = map(int, input().split())

    ans = 1
    max_n = min(A, B) + 1

    for n in range(2, max_n):
        if A == 1 or B == 1:
            break

        if A % n == 0 and B % n == 0:
            ans += 1

            while True:
                if A % n == 0 and B % n == 0:
                    A = A // n
                    B = B // n
                else:
                    break

    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
import math
input = lambda: sys.stdin.readline().rstrip()


def factorize(n):
    b = 2
    fct = set()
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct |= set([b])
        b = b + 1
    if n > 1:
        fct |= set([n])
    return fct


def solve():
    A, B = map(int, input().split())
    ap = factorize(A)
    bp = factorize(B)
    ans = 1 + len(ap & bp)
    print(ans)


if __name__ == '__main__':
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

input = lambda: sys.stdin.readline().rstrip()


def erastosthenes(num):

    if num <= 1:
        return []
    if num == 2:
        return [2]

    input_list = [False if i % 2 == 0 else True for i in range(num)]
    input_list[0] = False
    input_list[1] = False
    input_list[2] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            prime_list = [i for i, b in enumerate(input_list) if b]
            return prime_list

        for s in range(serial ** 2, num, serial):
            input_list[s] = False


def solve():
    A, B = map(int, input().split())
    prime_list = erastosthenes(min(A, B))
    ans = 1
    for pl in prime_list:
        if A % pl == 0 and B % pl == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    solve()


Fixed submission:
import sys
import math
input = lambda: sys.stdin.readline().rstrip()


def factorize(n):
    b = 2
    fct = set()
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct |= set([b])
        b = b + 1
    if n > 1:
        fct |= set([n])
    return fct


def solve():
    A, B = map(int, input().split())
    ap = factorize(A)
    bp = factorize(B)
    ans = 1 + len(ap & bp)
    print(ans)


if __name__ == '__main__':
    solve()