Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**6)

def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a%b)

A, B = map(int, input().split())
g = gcd(A, B)


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def main():
    cnt = 1  # 1は必ず含まれるので
    data = primes(g)
    for d in data:
        if g % d == 0:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

Fixed submission:
# 1と素因数の個数の和が答え
# つまりAの素因数を求めて、その中でBの約数となっているものを数えればよい。

def p_factors(x): # prime_factors
    ret = [1]
    check = 2
    while (True):
        if x % check == 0:
            ret.append(check)
            while x % check == 0:
                x = x // check
        check += 1
        if x == 1 or check > int(x**0.5)+1:
            break
    if x != 1:
        ret.append(x)
    return ret

def main():
    A, B = map(int, input().split())
    factors = p_factors(A)
    cnt = 0
    for f in factors:
        if B % f == 0:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a%b)

A, B = map(int, input().split())
g = gcd(A, B)

cnt = 1  # 1は必ず含まれるので

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

data = primes(g)

for d in data:
    if g % d == 0:
        cnt += 1

print(cnt)

Fixed submission:
# 1と素因数の個数の和が答え
# つまりAの素因数を求めて、その中でBの約数となっているものを数えればよい。

def p_factors(x): # prime_factors
    ret = [1]
    check = 2
    while (True):
        if x % check == 0:
            ret.append(check)
            while x % check == 0:
                x = x // check
        check += 1
        if x == 1 or check > int(x**0.5)+1:
            break
    if x != 1:
        ret.append(x)
    return ret

def main():
    A, B = map(int, input().split())
    factors = p_factors(A)
    cnt = 0
    for f in factors:
        if B % f == 0:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a%b)

A, B = map(int, input().split())
g = gcd(A, B)

cnt = 1  # 1は必ず含まれるので

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

data = primes(g)

for d in data:
    if g % d == 0:
        cnt += 1

print(cnt)

Fixed submission:
# 1と素因数の個数の和が答え
# つまりAの素因数を求めて、その中でBの約数となっているものを数えればよい。

def p_factors(x): # prime_factors
    ret = [1]
    check = 2
    while (True):
        if x % check == 0:
            ret.append(check)
            while x % check == 0:
                x = x // check
        check += 1
        if x == 1 or check > int(x**0.5)+1:
            break
    if x != 1:
        ret.append(x)
    return ret

def main():
    A, B = map(int, input().split())
    factors = p_factors(A)
    cnt = 0
    for f in factors:
        if B % f == 0:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()