Problem p02900 (python)

Fixed submission:
A, B = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

import math

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

import fractions
x = fractions.gcd(A, B)
divisors = make_divisors(x)
ans = 0
for d in divisors:
    if is_prime(d):
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

import math

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = True
    is_prime[1] = True
    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 is_prime

import fractions
x = fractions.gcd(A, B)
divisors = make_divisors(x)
ans = 0
P = primes(x)
for d in divisors:
    if P[d]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

import math

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = True
    is_prime[1] = True
    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 is_prime

print(primes(10**5))

import fractions
x = fractions.gcd(A, B)
divisors = make_divisors(x)
ans = 0
P = primes(x)
for d in divisors:
    if P[d]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
 
def common_divisors(a, b):
    a = fractions.gcd(a, b)
    divisors =  [d for d in range(2, a // 2 + 1) if a % d == 0] + [a]
    if not 1 in divisors:
        divisors.append(1) 
    return divisors, a

CommonDivs, _ =  common_divisors(A, B)   
#print(CommonDivs)
 
from collections import deque
CommonDivs.reverse()
q = deque(CommonDivs)
ans = [q.pop()]
max_n = max(CommonDivs)
while len(q) > 0:
    a = q.pop()
    ans.append(a)
    if max_n/2 < a:
        break
    for _ in range(len(q)):
        b = q.pop()
        if b % a != 0:
            q.appendleft(b)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())




import fractions
def common_divisors(a, b):
    a = fractions.gcd(a, b)
    divisors =  [d for d in range(2, a // 2 + 1) if a % d == 0] + [a]
    if not 1 in divisors:
        divisors.append(1) 
    return divisors, a


from collections import deque
CommonDivs.reverse()
q = deque(CommonDivs)
ans = [q.pop()]
max_n = max(CommonDivs)
while len(q) > 0:
    a = q.pop()
    ans.append(a)
    if max_n/2 < a:
        break
    for _ in range(len(q)):
        b = q.pop()
        if b % a != 0:
            q.appendleft(b)
            
print(len(ans)+len(q))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())

def gcd( x, y ):
    count = 0
    while y != 0:
        x, y = y, x%y        
    return x


def primes(n):
    is_prime = [True] * (n + 1)
    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: True for i in range(n + 1) if is_prime[i]}

def make_divisors(n):
    divisors = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i in p:
                divisors+=1
            if i != n // i and n//i in p:
                divisors+=1

    return divisors
x = gcd(A, B)
p = primes(x)
x = make_divisors(x)
print(x)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())

def gcd( x, y ):
    count = 0
    while y != 0:
        x, y = y, x%y        
    return x


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = True
    is_prime[1] = True
    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: True for i in range(n + 1) if is_prime[i]}

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i in p:
                divisors.append(i)
            if i != n // i and n//i in p:
                divisors.append(n//i)

    return divisors
x = gcd(A, B)
p = primes(x)
x = make_divisors(x)
print(len(x))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())

def gcd( x, y ):
    count = 0
    while y != 0:
        x, y = y, x%y        
    return x


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: True for i in range(n + 1) if is_prime[i]}

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i in p:
                divisors.append(i)
            if i != n // i and n//i in p:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
x = gcd(A, B)
p = primes(x)
x = make_divisors(x)
print(len(x)+1)