Problem p02900 (python)

Fixed submission:
import numpy as np
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
n = gcd(a, b)

table = []
i = 2
while i*i <= n:
    if n%i == 0:
        table.append(i)
        n //= i
    else:
        i += 1
if n > 1:
    table.append(n)

print(len(set(table))+1)

Buggy submission (verdict: Runtime Error):
import numpy as np
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
gcd = gcd(a, b)

def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass, is_prime

ass, is_prime = primes(gcd)
is_prime[1] = True

ans = 0
for p, isprime in enumerate(is_prime):
    
    if p == 0:
        continue
    if is_prime[p] == True and a%p==0 and b%p==0:
#         print(p, isprime)
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
a, b = map(int, input().split())
gcd = np.gcd(a, b)

def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass, is_prime

ass, is_prime = primes(gcd)
is_prime[1] = True

ans = 0
for p, isprime in enumerate(is_prime):
    
    if p == 0:
        continue
    if is_prime[p] == True and a%p==0 and b%p==0:
#         print(p, isprime)
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
a, b = map(int, input().split())
gcd = math.gcd(a, b)

def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass, is_prime

ass, is_prime = primes(gcd)
is_prime[1] = True

ans = 0
for p, isprime in enumerate(is_prime):
    
    if p == 0:
        continue
    if is_prime[p] == True and a%p==0 and b%p==0:
#         print(p, isprime)
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
a, b = map(int, input().split())
gcd = math.gcd(a, b)

def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass, is_prime

ass, is_prime = primes(gcd)
is_prime[1] = True

ans = 0
for p, isprime in enumerate(is_prime):
    
    if p == 0:
        continue
    if is_prime[p] == True and a%p==0 and b%p==0:
#         print(p, isprime)
        ans += 1
print(ans)