Problem p02900 (python)

Fixed submission:
import fractions
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A,B = map(int,input().split())
GCD = fractions.gcd(A,B)
pf = prime_factorize(GCD)
print(len(set(pf))+1)

Buggy submission (verdict: Runtime Error):
import math
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A,B = map(int,input().split())
GCD = math.gcd(A,B)
pf = prime_factorize(GCD)
print(len(set(pf))+1)

Buggy submission (verdict: Runtime Error):
import math,fractions
A,B = map(int,input().split())
def get_sieve_of_eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

GCD = fractions.gcd(A,B)
 
prime_list = get_sieve_of_eratosthenes(GCD)
counter = 1
for p in prime_list:
    if GCD % p == 0:
        counter += 1
        while(GCD % p == 0):
            GCD = GCD // p
        
print(counter)

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
def get_sieve_of_eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

GCD = math.gcd(A,B)
 
prime_list = get_sieve_of_eratosthenes(GCD)
counter = 1
for p in prime_list:
    if GCD % p == 0:
        counter += 1
        while(GCD % p == 0):
            GCD = GCD // p
        
print(counter)

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
def get_sieve_of_eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

GCD = math.gcd(A,B)
 
prime_list = get_sieve_of_eratosthenes(GCD)
counter = 1
for p in prime_list:
    if GCD % p == 0:
        counter += 1
        while(GCD % p == 0):
            GCD = GCD // p
        
print(counter)

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
def get_sieve_of_eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

GCD = math.gcd(A,B)

prime_list = get_sieve_of_eratosthenes(GCD)
counter = 1
for p in prime_list:
    if GCD % p == 0:
        counter += 1
        while(GCD % p == 0):
            GCD = GCD // p
        
print(counter)

Buggy submission (verdict: Runtime Error):

import math
def get_sieve_of_eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

A,B = map(int,input().split())
d = max(A,B,A-B)

prime_list = get_sieve_of_eratosthenes(d)
ans = []
for p in prime_list:
    if A % p == 0 and B % p == 0:
        ans.append(p)
    while(A % p == 0):
        A = A // p
    while(B % p == 0):
        B = B // p
print(len(ans)+1)