Problem p02900 (python)

Fixed submission:
def calc_gcd(a, b):
    return calc_gcd(b, a % b) if b else a


def p_d():
    a, b = map(int, input().split())
    gcd = calc_gcd(a, b)
    ans = 1
    cnt = 2
    while cnt * cnt < gcd:
        up = True
        while gcd % cnt == 0:
            if up:
                ans += 1
                up = False
            gcd //= cnt
        cnt += 1
    ans += 1 if gcd != 1 else 0
    print(ans)


if __name__ == '__main__':
    p_d()

Buggy submission (verdict: Runtime Error):
import math


def p_d():
    a, b = map(int, input().split())
    gcd = math.gcd(a, b)
    ans = 1
    cnt = 2
    while cnt * cnt < gcd:
        up = True
        while gcd % cnt == 0:
            if up:
                ans += 1
                up = False
            gcd //= cnt
        cnt += 1
    ans += 1 if ans != 1 else 0
    print(ans)


if __name__ == '__main__':
    p_d()

Buggy submission (verdict: Runtime Error):
from sys import stdin

input = stdin.readline

import math


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


def seachPrimeNum(N):
    max = int(math.sqrt(N))
    seachList = [i for i in range(2, N + 1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


def p_d():
    a, b = map(int, input().split())
    gcd = euclid(max(a, b), min(a, b))

    ans = 1
    nums = seachPrimeNum(gcd)
    for i in nums:
        if gcd % i == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    p_d()

Buggy submission (verdict: Runtime Error):
from sys import stdin

input = stdin.readline


def p_a():
    n = int(input())
    print(((n + 1) // 2) / n)


def p_b():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    print(sum(map(lambda x: x >= k, h)))


def p_c():
    n = int(input())
    k = list(map(int, input().split()))

    print(*[i[0] for i in sorted(enumerate(k, start=1), key=lambda x: x[1])])


import math


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


def seachPrimeNum(N):
    max = int(math.sqrt(N))
    seachList = [i for i in range(2, N + 1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


def p_d():
    a, b = map(int, input().split())
    gcd = euclid(max(a, b), min(a, b))

    ans = 1
    nums = seachPrimeNum(gcd)
    for i in nums:
        if gcd % i == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    p_d()

Buggy submission (verdict: Runtime Error):
import math


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


def seachPrimeNum(N):
    max = int(math.sqrt(N))
    seachList = [i for i in range(2, N + 1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


def p_d():
    a, b = map(int, input().split())
    gcd = euclid(max(a, b), min(a, b))

    ans = 1
    nums = seachPrimeNum(gcd)
    for i in nums:
        if gcd % i == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    p_d()