Problem p02900 (python)

Fixed submission:
def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct
a,b = map(int,input().split())
ap = set()
for prime,count in factorize(a):
    ap.add(prime)
bp = set()
for prime,count in factorize(b):
    bp.add(prime)
print(len(ap&bp)+1)

Buggy submission (verdict: Runtime Error):
from math import *
import sympy
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors

def eratosthenes(n):
    table = [0] * (n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
                
    return prime_list
a,b = map(int,input().split())
upper = int(sqrt(min(a,b))) + 1
pl = set(eratosthenes(upper))
common_factor = make_divisors(a)&make_divisors(b)
#print(*sorted(list(common_factor)))
#common_factor = [ i for i in range(1,min(a,b)) if a % i == 0 and b % i == 0]
#print(*common_factor)
ans = 0
for i in common_factor:
    if i in pl:
        ans += 1
print(ans + 1)

Buggy submission (verdict: Runtime Error):
from math import *
import sympy
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors

def eratosthenes(n):
    table = [0] * (n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
                
    return prime_list
a,b = map(int,input().split())
upper = int(sqrt(min(a,b))) + 1
pl = set(eratosthenes(upper))
common_factor = make_divisors(a)&make_divisors(b)
ans = 0
for i in common_factor:
    if i in pl:
        ans += 1
print(ans + 1)

Buggy submission (verdict: Runtime Error):
from math import *
import sympy
def eratosthenes(n):
    table = [0] * (n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
                
    return prime_list
a,b = map(int,input().split())
upper = int(sqrt(min(a,b))) + 1
pl = set(eratosthenes(upper))
common_factor = set(sympy.divisors(a))|set(sympy.divisors(b))
ans = 0
for i in common_factor:
    if i in pl:
        ans += 1
print(ans + 1)

Buggy submission (verdict: Runtime Error):
def eratosthenes(n):
    table = [0] * (n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
                
    return prime_list
a,b = map(int,input().split())
pl = set(eratosthenes(min(a,b)))
common_factor = [ i for i in range(1,min(a,b)) if a % i == 0 and b % i == 0]
ans = 0
for i in common_factor:
    if i in pl:
        ans += 1
print(ans + 1)