Problem:


Score : 400 points

Problem Statement

Given are positive integers A and B.

Let us choose some number of positive common divisors of A and B.

Here, any two of the chosen divisors must be coprime.

At most, how many divisors can we choose?

Definition of common divisor

An integer d is said to be a common divisor of integers x and y when d divides both x and y.

Definition of being coprime

Integers x and y are said to be coprime when x and y have no positive common divisors other than 1.

Definition of dividing

An integer x is said to divide another integer y when there exists an integer \alpha such that y = \alpha x.

Constraints

All values in input are integers.

1 \leq A, B \leq 10^{12}

Input

Input is given from Standard Input in the following format:

A B

Output

Print the maximum number of divisors that can be chosen to satisfy the condition.

Sample Input 1

12 18

Sample Output 1

3

12 and 18 have the following positive common divisors: 1, 2, 3, and 6.

1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.

Sample Input 2

420 660

Sample Output 2

4

Sample Input 3

1 2019

Sample Output 3

1

1 and 2019 have no positive common divisors other than 1.



Sample input:
12 18


Sample output:
3

Submission status: Runtime Error

Solution code:
ef 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())

ans_a=prime_factorize(a)
ans_b=prime_factorize(b)

count=0
if a or b ==1:
        count+=1

for i in range(len(ansa)):
    if ansa[i] in ansb:
        count+=1
   

print(count)

Submission status: Runtime Error

Solution code:
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

print(prime_factorize(a))

a,b=map(int,input().split())

ansa=prime_factorize(a)
ansb=prime_factorize(b)
count=0

for i in range(len(ansa)):
    if ansa[i] in ansb:
        count+=1
    


print(count)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
import math
x=math.gcd(a,b)
ans=1
n=2
while n <= x:
	if x%n==0:
		ans=ans+1
	while x%n==0:
		x=x/n
	n=n+1
print(ans)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
max_num = 10**6
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

is_prime = [1 for i in range(max_num+1)]
primes = [0 for i in range(max_num+1)]
primes[0] = 2
index = 1
for i in range(3, max_num, 2):
    if is_prime[i] == 0:
        continue
    primes[index] = i
    index += 1
    for j in range(i, max_num, i):
        is_prime[j] = 0

r = gcd(A, B)
ans = 1
index = 0
while r != 1:
    mod = primes[index]
    if r % mod == 0:
        ans += 1
        i=1
        while r % mod**(i+1) == 0:
            i+=1
        r = r // mod**i
    index+=1
print(ans)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
max_num = 10**6
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

is_prime = [1 for i in range(max_num+1)]
primes = [0 for i in range(max_num+1)]
primes[0] = 2
index = 1
for i in range(3, max_num, 2):
    if is_prime[i] == 0:
        continue
    primes[index] = i
    index += 1
    for j in range(i, max_num, i):
        is_prime[j] = 0

r = gcd(A, B)
index = 0
while r != 1:
    if r % primes[index] == 0:
        r = r // primes[index]
    if r % primes[index] != 0:
        index+=1
print(index+1)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
def kannsuu(a,b):
    
    h = [i for i in range(1,max(a, b))if a % i == 0 and b % i == 0]
    import itertools
    import math
    y = 2
    kotae = []

    if len(h) ==[1]:
        return(1)
    else:
        while y <= len(h):
            ln2 = list(itertools.combinations(h, y))
            kotae.extend(ln2)
            for q in range(0, len(ln2)):
                ln3 = list(itertools.combinations(ln2[q],2))
                for p in range(0, len(ln3)):
                    if math.gcd(ln3[p][0], ln3[p][1]) != 1:
                        if ln2[q] in kotae:
                            kotae.remove(ln2[q])                
                p = p + 1
            y = y + 1
        t = max(len(v) for v in(kotae))
        return(t)
x = kannsuu(a,b)
print(x)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
h = [i for i in range(1,max(a, b))if a % i == 0 and b % i == 0]
import itertools
import math
y = 2
kotae = []
if h ==[1]:
    print(1)
else:
        while y <= len(h):
            ln2 = list(itertools.combinations(h, y))
            kotae.extend(ln2)
            for q in range(0, len(ln2)):
                ln3 = list(itertools.combinations(ln2[q],2))
                for p in range(0, len(ln3)):
                    if math.gcd(ln3[p][0], ln3[p][1]) != 1:
                        if ln2[q] in kotae:
                            kotae.remove(ln2[q])                
                p = p + 1
            y = y + 1
        a = max(len(v) for v in(kotae))
        print(a)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
h = [i for i in range(1,max(a, b))if a % i == 0 and b % i == 0]
import itertools
import math
y = 2
kotae = []
if h ==[1]:
    print(2)
else:
        while y <= len(h):
            ln2 = list(itertools.combinations(h, y))
            kotae.extend(ln2)
            for q in range(0, len(ln2)):
                ln3 = list(itertools.combinations(ln2[q],2))
                for p in range(0, len(ln3)):
                    if math.gcd(ln3[p][0], ln3[p][1]) != 1:
                        if ln2[q] in kotae:
                            kotae.remove(ln2[q])                
                p = p + 1
            y = y + 1
        a = max(len(v) for v in(kotae))
        print(a)

Submission status: Runtime Error

Solution code:
import numpy as np

A, B = map(int, input().split())

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

n = gcd(A, B)

is_prime = np.array([True] * (n + 1))
is_prime[0] = False
is_prime[1] = True

for i in range(2, int(n**0.5) + 1):
    if is_prime[i]:
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False

take_l = [i for i in range(1, n + 1) if is_prime[i] and n%i == 0]
print(len(take_l))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
h = [i for i in range(1,max(a, b))if a % i == 0 and b % i == 0]
import itertools
import math
y = 2
kotae = []
if h ==[1]:
    print(2)
else:
        while y <= len(h):
            ln2 = list(itertools.combinations(h, y))
            kotae.extend(ln2)
            for q in range(0, len(ln2)):
                ln3 = list(itertools.combinations(ln2[q],2))
                for p in range(0, len(ln3)):
                    if math.gcd(ln3[p][0], ln3[p][1]) != 1:
                        if ln2[q] in kotae:
                            kotae.remove(ln2[q])                
                p = p + 1
        y = y + 1
        a = max(len(v) for v in(kotae))
        from scipy.special import comb
        print(comb(a,2, exact = True))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
h = [i for i in range(1,max(a, b))if a % i == 0 and b % i == 0]
import itertools
import math
y = 2
kotae = []
while y <= len(h):
    ln2 = list(itertools.combinations(h, y))
    kotae.extend(ln2)
    for q in range(0, len(ln2)):
        ln3 = list(itertools.combinations(ln2[q],2))
        for p in range(0, len(ln3)):
            if math.gcd(ln3[p][0], ln3[p][1]) != 1:
                if ln2[q] in kotae:
                    kotae.remove(ln2[q])                
            p = p + 1
    y = y + 1
a = max(len(v) for v in(kotae))
from scipy.special import comb
print(comb(a,2, exact = True))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
h = [i for i in range(1,max(a, b))if a % i == 0 and b % i == 0]
import itertools
import math
y = 2
kotae = []
while y <= len(h):
    ln2 = list(itertools.combinations(h, y))
    kotae.extend(ln2)
    for q in range(0, len(ln2)):
        ln3 = list(itertools.combinations(ln2[q],2))
        for p in range(0, len(ln3)):
            if math.gcd(ln3[p][0], ln3[p][1]) != 1:
                if ln2[q] in kotae:
                    kotae.remove(ln2[q])                
            p = p + 1
    y = y + 1
print(max(len(v) for v in(kotae)))

Submission status: Runtime Error

Solution code:
A, B = map(int,input().split())

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

n = gcd(max(A,B),min(A,B))

is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = True

for i in range(2, int(n**0.5) + 1):
    if is_prime[i]:
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False

take_l = [i for i in range(1, n + 1) if all([is_prime[i], A%i == 0, B%i == 0])]
print(len(take_l))

Submission status: Runtime Error

Solution code:
A, B = map(int,input().split())

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

n = gcd(A,B)

is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = True

for i in range(2, int(n**0.5) + 1):
    if is_prime[i]:
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False

take_l = [i for i in range(1, n + 1) if all([is_prime[i], A%i == 0, B%i == 0])]
print(len(take_l))

Submission status: Runtime Error

Solution code:
a,b = map(int ,input().split())

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

list = cf(a,b)
#print(list)                                                                   
def is_prime(n):
    if n == 1: return False
 
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True

for i in list:
    if is_prime(i):
        count += 1

print(count+1)

Submission status: Runtime Error

Solution code:
from collections import Counter
from math import gcd
a, b = map(int, input().split())
n = int(max(a, b)**(1/2)) + 1
prime_num_cnt = [0]*(n + 1)
prime_num = []
for i in range(2, n+1):
    if prime_num_cnt[i] == 0:
        prime_num.append(i)
        tmp = i
        for j in range(1, n):
            if tmp*j > n:
                break
            prime_num_cnt[tmp*j] = 1


g = gcd(max(a, b), min(a, b))
cnt = Counter()
m = 2
while m <= g:
    while g % m == 0:
        g //= m
        cnt[m] += 1
    m += 1

print(len(cnt) + 1)

Submission status: Runtime Error

Solution code:
from collections import Counter
from math import gcd
a, b = map(int, input().split())
n = int(max(a, b)**(1/2)) + 1
prime_num_cnt = [0]*(n + 1)
prime_num = []
for i in range(2, n+1):
    if prime_num_cnt[i] == 0:
        prime_num.append(i)
        tmp = i
        for j in range(1, n):
            if tmp*j > n:
                break
            prime_num_cnt[tmp*j] = 1


g = gcd(max(a, b), min(a, b))
cnt = Counter()
m = 2
while m*m < g:
    while g % m == 0:
        g //= m
        cnt[m] += 1
    m += 1

print(len(cnt) + 1)

Submission status: Runtime Error

Solution code:
from sys import setrecursionlimit

def read_key():
    a, _ = map(int, input().split())
    m = 0
    for c in map(int, input().split()):
        m |= 1 << (c - 1)
    return (a, m)

def solve(keys, amount, cm, dp):
  if cm == (1 << N) - 1:
    return amount
  if len(keys) == 0:
    return INF
  a, m = keys[0]
  if dp[cm | m] < amount + a:
    return solve(keys[1:], amount, cm, dp)
  else:
    dp[cm | m] = amount + a
    return min(solve(keys[1:], amount + a, cm | m, dp), solve(keys[1:], amount, cm, dp))

setrecursionlimit(1000000)
INF = float('inf')

N, M = map(int, input().split())
keys = [read_key() for _ in range(M)]

dp = [INF] * (1 << N)
t = solve(keys, 0, 0, dp)
if t == INF:
  print(-1)
else:
  print(t)

Submission status: Runtime Error

Solution code:
import math
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

a, b = map(int, input().split())
gcd = gcd(a, b)
divisor = [1]
for i in range(2, int(math.sqrt(gcd))+1):
    while gcd % i == 0:
        gcd = gcd // i
        if i not in divisors:
            divisors.append(i)
print(len(divisors))

Submission status: Runtime Error

Solution code:
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

a, b = map(int, input().split())
gcd = gcd(a, b)
divisor = [1]
for i in range(2, int(math.sqrt(gcd))+1):
    while gcd % i == 0:
        gcd = gcd // i
        if i not in divisors:
            divisors.append(i)
print(len(divisors))

Submission status: Runtime Error

Solution code:
import math
a, b = map(int, input().split())
gcd = math.gcd(a, b)
divisors = [1]
for i in range(2, gcd):
    if gcd % i == 0:
        gcd = gcd // i
        if i not in divisors:
            divisors.append(i)
print(len(divisors))

Submission status: Runtime Error

Solution code:
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

#targetまでの素数の数
import math
def sieve_of_eratosthenes2(target):
    dest = math.ceil(math.sqrt(target))
    target_list = [i for i in range(2, dest//2+1) if target%i==0]
    prime_num = 0
 
    while True:
        num_min = target_list[0]
        if num_min > dest:
            prime_num += len(target_list)
            break
        prime_num += 1        
        target_list = [i for i in target_list if i%num_min!=0]
        if target_list==[]:
            break
 
    return prime_num

import random
def is_prime(q, k=50):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q % 2 == 0:
        return False

    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
elif is_prime(gcd):
    print(2)
else:
    ans = sieve_of_eratosthenes2(gcd)    
    print(ans+1)

Submission status: Runtime Error

Solution code:
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a
 
#targetまでの素数の数
import math
def sieve_of_eratosthenes2(target):
    dest = math.ceil(math.sqrt(target))
    target_list = [i for i in range(2, dest+2) if target%i==0]
    prime_num = 0
 
    while True:
        num_min = target_list[0]
        if num_min > dest:
            prime_num += len(target_list)
            break
        prime_num += 1        
        target_list = [i for i in target_list if i%num_min!=0]
        if target_list==[]:
            break
 
    return prime_num
 
a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
else:
    ans = sieve_of_eratosthenes2(gcd)    
    print(ans+1)

Submission status: Runtime Error

Solution code:
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a
 
#targetまでの素数の数
import math
def sieve_of_eratosthenes2(target):
    dest = int(math.sqrt(target))
    target_list = [i for i in range(2, dest+2) if target%i==0]
    prime_num = 0
 
    while True:
        num_min = min(target_list)
        if num_min > dest:
            prime_num += len(target_list)
            break
        prime_num += 1        
        target_list = [i for i in target_list if i%num_min!=0]
        if target_list==[]:
            break
 
    return prime_num   
 
a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
else:
    ans = sieve_of_eratosthenes2(gcd)    
    print(ans+1)

Submission status: Runtime Error

Solution code:
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a
 
#targetまでの素数の数
import math
def sieve_of_eratosthenes2(target):
    dest = int(math.sqrt(target))
    target_list = [i for i in range(2, dest+1) if target%i==0]
    prime_num = 0
 
    while True:
        num_min = min(target_list)
        if num_min > dest:
            prime_num += len(target_list)
            break
        prime_num += 1        
        target_list = [i for i in target_list if i%num_min!=0]
        if target_list==[]:
            break
 
    return prime_num   
 
a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
else:
    ans = sieve_of_eratosthenes2(gcd)    
    print(ans+1)

Submission status: Runtime Error

Solution code:
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

import math
import numpy as np
def primes_num(target):
    dest = int(math.sqrt(target))
    datas = np.array([i for i in range(2, target)], dtype="object")
    mask = target%datas == 0
    prime_num = 0
    while True:
        num_min = np.min(datas[mask])
        if num_min > dest:
            prime_num += len(datas[mask])
            break
        prime_num += 1
        mask[num_min-2::num_min] = False
        if True in mask:
            pass
        else:
            break
    return prime_num
    
    

a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
else:
    ans = primes_num(gcd)    
    print(ans+1)

Submission status: Runtime Error

Solution code:
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

#targetまでの素数の数
import math
def sieve_of_eratosthenes(target):
    dest = int(math.sqrt(target))
    target_list = [i for i in range(2, target+1)]
    prime_list = []
 
    while True:
        num_min = min(target_list)
        if num_min > dest:
            prime_list.extend(target_list)
            break
        prime_list.append(num_min)        
        target_list = [i for i in target_list if i%num_min!=0]
 
    return prime_list

def sieve_of_eratosthenes2(target):
    dest = int(math.sqrt(target))
    target_list = [i for i in range(2, target+1) if target%i==0]
    prime_list = []
 
    while True:
        num_min = min(target_list)
        if num_min > dest:
            prime_list.extend(target_list)
            break
        prime_list.append(num_min)        
        target_list = [i for i in target_list if i%num_min!=0]
 
    return prime_list


a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
else:
    lis = sieve_of_eratosthenes2(gcd)
    ans = len(lis) + 1
    print(ans)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
prime1 = get_prime(A)
prime2 = get_prime(B)
ans_prime = prime1 & prime2
print(len(ans_prime) + 1)

def get_prime(n):
    prime = []
    while n % 2 == 0:
        prime.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            prime.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        prime.append(n)
    return prime

Submission status: Runtime Error

Solution code:
I = list(map(int,input().split()))

a = I[0]
b = I[1]

if a > b:
    a, b = b, a

L = [True] * (a+1)


L[0] = False
if b % a != 0:
    L[a]= False

for i in range(2,a):
    if a % i != 0 or b % i != 0:
        L[i] = False
    if L[i]:
        for j in range(i+1, a+1):
            if j % i == 0:
                L[j] = False

print(L.count(True))

Submission status: Runtime Error

Solution code:
I = list(map(int,input().split()))

a = I[0]
b = I[1]

if a > b:
    a, b = b, a

L = [True] * (a+1)


L[0] = False
if b % a != 0:
    L[a]= False

for i in range(2,a+1):
    if a % i != 0 or b % i != 0:
        L[i] = False
    if L[i]:
        for j in range(i+1, a+1):
            if j % i == 0:
                L[j] = False

print(L.count(True))

Submission status: Runtime Error

Solution code:
a=12
b=18
v=[]
#最大公約数
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
    return a
c=gcd(a,b)
for i in range (2,c):
  for j in range(2,i+1):
  	if i % j == 0:
    	if i == j:
      		v[i] == i
    	else:
      		break
print(v)

Submission status: Runtime Error

Solution code:
I = list(map(int,input().split()))

a = I[0]
b = I[1]

if a > b:
    a, b = b, a

L = [True] * (a+1)


L[0] = False
for i in range(2,a+1):
    if a % i != 0 or b % i != 0:
        L[i] = False
    if L[i]:
        for j in range(i+1, a+1):
            if j % i == 0:
                L[j] = False

print(L.count(True))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Oct  1 07:06:32 2019

@author: avina
"""

def gcd(a,b): 
      
    # Everything divides 0  
    if (b == 0): 
         return a 
    return gcd(b, a%b) 

a,b = map(int, input().split())

num = gcd(a,b)
prime = [1]*(a +1)
prime[0] = 0;prime[1] = 0
for i in range(2,a+1):
    if prime[i] == 1:
        j = 2
        while j*i <= a:
            prime[i*j] = 0
            j+=1
prime2 = [1]*(b+1)
for i in range(2,b+1):
    if prime2[i] ==1:
        j = 2
        while j*i <= b:
            prime2[i*j] = 0
            j+=1
q = set()
for i in range(a):
    if prime[i] == 1:
        q.add(i)
q2 = set()
for j in range(b):
    if prime2[j] == 1:
        q2.add(j)
w = q.intersection(q2)
ans = 1

for i in w:
    if i > num:
        break
    if num % i == 0:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Oct  1 07:06:32 2019

@author: avina
"""

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

a,b = map(int, input().split())

num = gcd(a,b)
prime = [1]*(a +1)
prime[0] = 0;prime[1] = 0
for i in range(2,a+1):
    if prime[i] == 1:
        j = 2
        while j*i <= a:
            prime[i*j] = 0
            j+=1
prime2 = [1]*(b+1)
for i in range(2,b+1):
    if prime2[i] ==1:
        j = 2
        while j*i <= b:
            prime2[i*j] = 0
            j+=1
q = set()
for i in range(a):
    if prime[i] == 1:
        q.add(i)
q2 = set()
for j in range(b):
    if prime2[j] == 1:
        q2.add(j)
w = q.intersection(q2)
ans = 1

for i in w:
    if i > num:
        break
    if num % i == 0:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
from math import sqrt

A, B = map(int, input().split())

G = fractions.gcd(A, B)
N = sqrt(G)+1
g = G
ans = 1


for i in range(2, N+1):
    if (g < i):
        break
    if(g % (i) == 0):
        ans += 1
        while(g % (i) == 0):
            g /= i

print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Oct  1 07:06:32 2019

@author: avina
"""

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

a,b = map(int, input().split())

num = gcd(a,b)
prime = [1]*(a +1)
prime[0] = 0;prime[1] = 0
for i in range(2,a+1):
    if prime[i] == 1:
        j = 2
        while j*i <= a:
            prime[i*j] = 0
            j+=1
prime2 = [1]*(b+1)
for i in range(2,b+1):
    if prime2[i] ==1:
        j = 2
        while j*i <= b:
            prime2[i*j] = 0
            j+=1
q = set()
for i in range(a):
    if prime[i] == 1:
        q.add(i)
q2 = set()
for j in range(b):
    if prime2[j] == 1:
        q2.add(j)
w = q.intersection(q2)
ans = 1
for i in w:
    if num % i == 0:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import math

a,b = map(int,input().split())

n = math.gcd(a,b)
m = n
x = 2
ans = 1

while m!=1:
    if m%x !=0:
        if x==2:
            x += 1
        else:
            x += 2
        continue
    ans += 1
    while m%x == 0:
        m /= x
    if x==2:
        x += 1
    else:
        x += 2

print(ans)

Submission status: Runtime Error

Solution code:
import math

a,b = map(int,input().split())

'''
def gcd(a,b):
    if a>b:
        a,b = b,a
    if b%a == 0:
        return a
    return gcd(a,b%a)
'''

n = math.gcd(a,b)
m = n
x = 2
ans = 1

while m!=1:
    if m%x !=0:
        if x==2:
            x += 1
        else:
            x += 2
        continue
    ans += 1
    while m%x == 0:
        m /= x
    if x==2:
        x += 1
    else:
        x += 2

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
primes = np.ones(g+2)
primes[0:2] = 0
for i in range(2, int(np.sqrt(g))+1+1):
  if primes[i] and i * 2 < g + 2:
    primes[i*2::i] = 0

count = 0
for i in range(2,g+1):
  if primes[i] and g%i == 0:
    count += 1
print(count + 1)

Submission status: Runtime Error

Solution code:
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
primes = np.ones(g+1)
primes[0:2] = 0
for i in range(2, int(math.sqrt(g))+1+1):
  if primes[i] and i * 2 < g + 1:
    primes[i*2::i] = 0

count = 0
for i in range(2,g+1):
  if primes[i] and g%i == 0:
    count += 1
print(count + 1)

Submission status: Runtime Error

Solution code:
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
primes = np.ones(g+2)
primes[0:2] = 0
for i in range(2, int(math.sqrt(g))+1+1):
  if primes[i]:
    primes[i*2::i] = 0

count = 0
for i in range(2,g+1):
  if primes[i] and g%i == 0:
    count += 1
print(count + 1)

Submission status: Runtime Error

Solution code:
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
primes = np.ones(g+1)
primes[0:2] = 0
for i in range(2, int(math.sqrt(g))+1+1):
  if primes[i]:
    primes[i*2::i] = 0

count = 0
for i in range(g+1):
  if primes[i] and g%i == 0:
    count += 1
print(count + 1)

Submission status: Runtime Error

Solution code:
from fractions import gcd
import math
def solve(string):
    a, b = map(int, string.split())
    g = math.gcd(a, b)
    ans = 1 if g % 2 else 2
    while g % 2 == 0:
        g //= 2
    for i in range(3, int(g**0.5) + 1, 2):
        if g % i == 0:
            ans += 1
        while g % i == 0:
            g //= i
    return str(ans + 1) if g > 1 else str(ans)

if __name__ == '__main__':
    print(solve(input()))

Submission status: Runtime Error

Solution code:
import fractions

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
A, B = map(int, input().split())

m = min(A, B)
i = 1
res = 0
while i*i <= m:
  if m%i == 0:
    if is_pricec(i) or i == 1:
      res += 1
  i += 1

print(res)

Submission status: Runtime Error

Solution code:
import math
A, B = map(int, input().split())

_gcd = math.gcd(A, B)
print(_gcd)

Submission status: Runtime Error

Solution code:
import math
  
A, B = map(int, input().split())
n = math.gcd(A, B)
res = 0
for i in range(1, n+1):
        if A%i == 0 and B%i == 0:
                res += 1
print(res)

Submission status: Runtime Error

Solution code:
import math

A, B = map(int, input().split())
n = math.gcd(A, B)
res = 0
for i in range(1, n+1):
  if A%i == 0 and B%i == 0:
	res += 1
print(res)

Submission status: Runtime Error

Solution code:
import math

A, B = map(int, input().split())
gcd = math.gcd(A, B)
res = 0
for i in range(1, gcd+1):
  if A%i == 0 and B%i == 0:
    res += 1
print(res)

Submission status: Runtime Error

Solution code:
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

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


a,b = map(int,input().split())
gcd = gcd(a ,b)
print(len(np.unique(prime_decomposition(gcd)))+1)

Submission status: Runtime Error

Solution code:
from fractions import gcd


def get_primes(n):
    ans = []
    flags = [1] * (n + 1)
    for i in range(2, n + 1):
        if flags[i]:
            ans.append(i)
            for j in range(i, n + 1, i):
                flags[j] = 0
    return ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(len([p for p in get_primes(g) if g % p == 0]) + 1)


if __name__ == '__main__':
    print(solve(input()))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())

h = [i for i in range(1,max(a, b))if a % i == 0 and b % i == 0]
ln = list(range(2, len(h)))

import itertools
import math
y = 2
for c in itertools.combinations(h, y):
    for d in itertools.combinations(c,2):
        if math.gcd(d[0], d[1])!=1:
            if y in ln:
                ln.remove(y)
    y = y + 1         
print(max(ln))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())

h = [i for i in range(1,max(a, b))if a % i == 0 and b % i == 0]
ln = list(range(2, len(h)))

import itertools
import math
y = 2
for c in itertools.combinations(h, y):
    for d in itertools.combinations(c,2):
        if math.gcd(d[0], d[1])!=1:
            if y in ln:
                ln.remove(y)
    y = y + 1
print(ln)            
print(max(ln))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())

h = [i for i in range(1,max(a, b))if a % i == 0 and b % i == 0]

import itertools
import math
y = 2
list =list(range(2,len(h))
for v in itertools.combinations(h, y):
    for d in itertools.combinations(c,2):
        if math.gcd(d[0], d[1])!=1:
            list.remove(y)
    y = y + 1
print(list)            
print(max(list))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Oct  1 07:06:32 2019

@author: avina
"""

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

a,b = map(int, input().split())

num = gcd(a,b)
prime = [1]*(num +1)
prime[0] = 0;prime[1] = 0
for i in range(2,num):
    if prime[i] == 1:
        j = 2
        while j*i < num:
            prime[i*j] = 0
            j+=1

l = []
ans = 0
for i in range(1,num+1):
    if a%i == 0 and b%i == 0 and prime[i] == 1:
        ans+=1;l.append(i)
print(ans)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p
  
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)
    divisors.sort()
    return divisors

divisors = make_divisors(gcd(a, b))

def prime(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for j in range(4, n+1, 2):
        is_prime[j] = False
    for i in range(3, int(n**0.5) + 1, 2):
        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]]

prime = [1] + prime(divisors[-1])
ans = set(divisors) & set(prime)
print(len(ans))