Problem p02900 (python)

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


a, b = map(int, input().split())

g = gcd(a, b)
num = g

ans = 1

for i in range(2, int(g ** 0.5) + 1):

    if num % i == 0:
        ans += 1
        while num % i == 0:
            num = num // i

if num != 1:
    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
def sieve(n, a, b):
    ans = 0
    can_divide = [False] * (n + 1)
    can_divide[0] = False
    can_divide[1] = True
    ans += 1
    for i in range(2, int(n ** 0.5) + 1):
        if can_divide[i] is False and a % i == 0 and b % i == 0:
            ans += 1
            for j in range(i * 2, n + 1, i):
                can_divide[j] = True

    return ans


a, b = map(int, input().split())

m = min(a, b)

ans = sieve(m, a, b)

print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

a, b = map(int, input().split())

limit = int((10**12 + 1)**0.5)
prime_table = [True] * (limit + 1)

for i in range(2, limit):
    if prime_table[i] is True:
        for j in range(i + i, limit, i):
            prime_table[j] = False

ans = set()
g = gcd(a, b)

for i in range(1, g + 1):
    if a % i == 0 and b % i == 0 and prime_table[i] is True:
        ans.add(i)

print(len(ans))

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())

limit = int((10**12 + 1)**0.5)
prime_table = [True] * (limit + 1)

for i in range(2, limit):
    if prime_table[i] is True:
        for j in range(i + i, limit, i):
            prime_table[j] = False

ans = set()
g = math.gcd(a, b)

for i in range(1, g + 1):
    if a % i == 0 and b % i == 0 and prime_table[i] is True:
        ans.add(i)

print(len(ans))

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())

limit = int((10**12 + 1)**0.5)
prime_table = [True] * (limit + 1)

for i in range(2, limit):
    if prime_table[i] is True:
        for j in range(i + i, limit, i):
            prime_table[j] = False

ans = set()
g = math.gcd(a, b)

for i in range(1, g + 1):
    if a % i == 0 and b % i == 0 and prime_table[i] is True:
        ans.add(i)

print(len(ans))

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())

limit = int((10**12 + 1)**0.5)
prime_table = [True] * (limit + 1)

for i in range(2, limit):
    if prime_table[i] is True:
        for j in range(i + i, limit, i):
            prime_table[j] = False

ans = set()
g = math.gcd(a, b)

for i in range(1, g + 1):
    if a % i == 0 and b % i == 0 and prime_table[i] is True:
        ans.add(i)

print(len(ans))

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())

limit = int((10**12 + 1)**0.5)
prime_table = [True] * (limit + 1)

for i in range(2, limit):
    if prime_table[i] is True:
        for j in range(i + i, limit, i):
            prime_table[j] = False

ans = set()
g = math.gcd(a, b)

for i in range(1, g + 1):
    if a % i == 0 and b % i == 0 and prime_table[i] is True:
        ans.add(i)

print(len(ans))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

limit = int((10**12 + 1)**0.5)
prime_table = [True] * (limit + 1)

for i in range(2, limit):
    if prime_table[i] is True:
        for j in range(i + i, limit, i):
            prime_table[j] = False

ans = set()

for i in range(1, a + 1):
    if a % i == 0 and prime_table[i] is True:
        ans.add(i)

for i in range(1, b + 1):
    if a % i == 0 and prime_table[i] is True:
        ans.add(i)

print(len(ans))