Problem p02900 (python)

Fixed submission:
a, b = map(int, input().split())

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
n = gcd(a, b)

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

ans = set(prime_factorize(n))
print(len(ans)+1)

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

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

ans = set(prime_factorize(n))
print(len(ans)+1)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
n = gcd(a, b)
def primes(n):
    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
    return [i for i in range(n + 1) if is_prime[i]]
l = primes(n)
count = 1
for p in l:
    if a % p == 0 and b % p == 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
n = gcd(a, b)
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
l = primes(n)
count = 1
for p in l:
    if a % p == 0 and b % p == 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
n =  math.gcd(a, b)
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
l = primes(n)
count = 1
for p in l:
    if a % p == 0 and b % p == 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
n =  math.gcd(a, b)
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
l = primes(n)
count = 1
for p in l:
    if a % p == 0 and b % p == 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
n = math.gcd(a, b)
l = []
for i in range(n):
    if a % (i+2) == 0 and b % (i+2) == 0:
        l.append(i+2)
primes = [2]
for x in l:
    if all(x % prime !=0 for prime in primes):
        primes.append(x)
if  a % 2 == 0 or b % 2 == 0:
    ans = len(primes) +1
else:
    ans = len(primes)
print(ans)

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


l = []
for i in range(n):
    if a % (i+2) == 0 and b % (i+2) == 0:
        l.append(i+2)

primes = [2]
for x in l:
    if all(x % prime !=0 for prime in primes):
        primes.append(x)

if  a % 2 == 0 or b % 2 == 0:
    ans = len(primes) +1
else:
    ans = len(primes)
print(ans)

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

l = []
for i in range(n):
    if a % (i+2) == 0 and b % (i+2) == 0:
        l.append(i+2)

primes = [2]
for x in l:
    if all(x % prime !=0 for prime in primes):
        primes.append(x)

if  a % 2 == 0 or b % 2 == 0:
    ans = len(primes) +1
else:
    ans = len(primes)
print(ans)

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

l = []
for i in range(n):
    if a % (i+2) == 0 and b %1 (i+2) == 0:
        l.append(i+2)
    
primes = [2]
for x in l:
    if all(x % prime !=0 for prime in primes):
        primes.append(x)

if  a % 2 == 0 or b % 2 == 0:
    ans = len(primes) +1
else:
    ans = len(primes)
print(ans)

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
n = gcd(a, b)

for i in range(n):
    if a % (i+2) == 0 and b % (i +2) == 0:
        l.append(i+2)
    
primes = [2]
for x in l:
    if all(x % prime !=0 for prime in primes):
        primes.append(x)

if  a % 2 == 0 or b % 2 == 0:
    ans = len(primes) +1
else:
    ans = len(primes)
print(ans)

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

count = 1
for i in range(n//2 + 1):
    if a % p == 0 and b % p == 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
n = min(a, b)
def primes(n):
    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
    return [i for i in range(n + 1) if is_prime[i]]
l = primes(n)
count = 1
for p in l:
    if a % p == 0 and b % p == 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
n = min(a, b)
def primes(n):
    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
    return [i for i in range(n + 1) if is_prime[i]]
l = primes(n)
count = 1
for p in l:
    if a % p == 0 and b % p == 0:
        count += 1
print(count)