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

comdiv = [] 
A_div = make_divisors(A)
for i in A_div:
  if B % i == 0:
    comdiv.append(i)

def Eratosthenes(n):

    dp = [False]*n#sその値が素数かどうかを格納する。Falseなら素数。#場合によってはこちらをreturnしても良い。
    dp[0] = dp[1] = True#0,1はそれぞれ素数ではないのでTrueを入れる
    prime = []#素数列
    for i in range(2,n):
        if dp[i]:
            continue#素数でなければcontinue
        prime.append(i)#素数であれば足す
        #以下、iより大きいiの倍数を除外する処理
        for j in range(i*2,n,i):
          dp[j] = True
    return prime
  
flg = [False] * (B + 1) 
  
Era = Eratosthenes(B+1)
for e in Era:
  flg[e] = True

cnt = 0
for i in comdiv:
  if flg[i] == True:
    cnt += 1
print(cnt+1)

Submission status: Runtime Error

Solution code:
from math import sqrt
A,B = map(int,input().split())
dA = set()
dB = set()
r = int(sqrt(max(A,B))) + 1
for i in range(1,r):
    if A % i == 0:
        dA.add(i)
        dA.add(A//i)
    if B % i == 0:
        dB.add(i)
        dB.add(B//i)
# print(dA,dB)
CD = dA & dB
#print(CD)
#print(len(CD))

m = max(CD)
flg = [True] * (m+1)
flg[0] = False
for i in range(2,m+1):
    if i not in CD: flg[i] = False
    if flg[i]:
        t = i
        i += t
        while i <= m:
            flg[i] = False
            i += t
# print(flg)
print(sum(flg))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000000000)

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

def gcd(a,b):
  if a < b: a,b = b,a
  if a % b == 0:
    return b
  else:
    return gcd(b, a%b)

def make_primeset(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]]

  
gcd_ = gcd(A,B)
if gcd_ == 1:
  print(1)
else:
  ans = 1  # 1のぶん
   # 素因数の種類数+1
  for p in make_primeset(gcd_):
    if gcd_ % p == 0:
      ans += 1
  print(ans)

Submission status: Runtime Error

Solution code:
#def make_divisors(n,m):
#    divisors = []
#    for i in range(1, int(min(n,m)**0.5)+1):
#        if n % i == 0 and m%i == 0:
#            divisors.append(i)
#            if i != min(n,m) // i:
#                divisors.append(min(n,m)//i)
#
#    # divisors.sort()
#    return divisors

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

C = make_divisors(A)
D = make_divisors(B)
C.sort()
D.sort()
E = []

idx1 = 0
idx2 = 0
L = min(len(C),len(D))
while idx1 < L and idx2 < L:
    if C[idx1] == D[idx2] :
        E.append(C[idx1])
        idx1 += 1
        idx2 += 1
    elif C[idx1] > D[idx2]:
        idx2 += 1
    else:
        idx1 += 1
        
        
memo = [False] * (10**6+10)
ans = 0
for e in E:
    if not(memo[e]):
        ans += 1
        j = e
        if e == 1:continue
        while j < len(memo):
            memo[j] = True
            j += e

print(ans)

Submission status: Runtime Error

Solution code:
import fractions
import collections
A, B = map(int, input().split())
tmp_list = collections.defaultdict(int)


def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass


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


make_divisors(A)
make_divisors(B)

tmp = list(tmp_list.items())
divisors = [tmp[i][0] for i in range(len(tmp)) if tmp[i][1] >= 2]

prime_list = primes(max(A, B))

ans = []
for x in divisors:
    if x in prime_list or x == 1:
        ans.append(x)

print(len(ans))

Submission status: Runtime Error

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

import math


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    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]
Max = max(A,B)
def koyaku(a,b,arr):
    for i in range(2,Max+1):
        if a%i==0 and b%i==0:
            arr.append(i)
    return arr
Koyaku =[]
cnt = 0
Koyaku = koyaku(A,B,Koyaku)
data = get_sieve_of_eratosthenes(Max)
for i in Koyaku:
    if i in data:
        cnt+=1
print(cnt+1)

Submission status: Runtime Error

Solution code:
def PrimeNumber(N):
    if N==2:
        ans=[2]
        return ans
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans

def div(N):
    ans = []
    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            ans.append(i)
            if N // i != i:
                ans.append(N // i)
    ans.sort()
    return ans


import fractions

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

g=fractions.gcd(A,B)

if g==1:
    print(1)
    exit()

d_list=[]
d_list=div(g)
PN=[1]
PN.extend(PrimeNumber(g))

cnt=0
for i in d_list:
    if i in PN:
        cnt+=1

print(cnt)

Submission status: Runtime Error

Solution code:
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
E = [1] * (GCD + 1)
E[0], E[1] = 0, 0
P = []
for i, e in enumerate(E):
  if e == 0:
    continue
  P.append(i)
  for j in range(i, GCD + 1, i):
    E[j] = 0
print(len([p for p in P if GCD % p == 0]) + 1)

Submission status: Runtime Error

Solution code:
from math import gcd

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

g=gcd(a,b)
cnt=[]

for i in range(1,g+1):
    if i*i>g:
        break
    if g%i==0:
        if g//i==i:
            cnt.append(i)
        else:
            cnt.append(i)
            cnt.append(g//i)


ma=max(cnt)

ans=0
d=dict()
#cnt=sorted(cnt)

for i in range(len(cnt)):
    if cnt[i]!=1:
        for j in range(2*cnt[i],ma+1,cnt[i]):
            if j in cnt:
                d[j]=1


for i in cnt:
    if i not in d.keys():
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

N = math.gcd(A, B)
primes = []
if N % 2 == 0:
    primes.append(2)
for i in range(3, int(math.sqrt(N)) + 2, 2):
    if N % i == 0:
        for p in primes:
            if i % p == 0:
                break
        else:
            primes.append(i)
print(len(primes) + 1)

Submission status: Runtime Error

Solution code:
import sys
from collections import defaultdict, deque
from functools import reduce
import math

input = sys.stdin.readline


def sieve_of_eratosthenes(target):
    dest = int(math.sqrt(target))
    target_list = list(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)

        i = 0

        while True:
            if i >= len(target_list):
                break
            elif target_list[i] % num_min == 0:
                target_list.pop(i)
            i += 1

    return(prime_list)


def main():
    A, B = map(int, input().split())
    k = [1]
    if min(A, B) == 1:
        print(1)
        return
    prime_list = sieve_of_eratosthenes(min(A, B))

    for p in prime_list:
        if A % p == 0 and B % p == 0:
            k.append(p)
    print(len(k))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

def gcd(a,b):
  if a < b: a,b = b,a
  if a % b == 0:
    return b
  else:
    return gcd(b, a%b)

def make_primeset(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]]

  
gcd_ = gcd(A,B)
if gcd_ == 1:
  print(1)
else:
  ans = 1  # 1のぶん
   # 素因数の種類数+1
  for p in make_primeset(gcd_):
    if gcd_ % p == 0:
      ans += 1
  print(ans)

Submission status: Runtime Error

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

ans = 0
C = min(A,B)
X = [True]*(C+1)
X[0] = X[1] = False
for i in range(2,C+1):
    if i*i>C:break
    if X[i]:
        X[i::i] = [False]*(C//i)
        if A%i==0 and B%i==0:
            ans+=1
print(ans+1)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**8)

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

primes = []
for i in range(2, 10**3+10):
    if all(i%p for p in primes):
        primes.append(i)
# print(primes)

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

g = gcd(A, B)
count = 0
for p in primes:
    if g < p:
        break
    if g%p == 0:
        c += 1

print(count+1)

Submission status: Runtime Error

Solution code:
mod = 1000000007
MOD = 998244353
ii = lambda :  int(input())
si = lambda :  input()
dgl = lambda : list(map(int, input()))
f = lambda :   map(int, input().split())
il = lambda :  list(map(int, input().split()))
it = lambda :  tuple(map(int, input().split()))
ls = lambda :  list(input())
from math import *
n=10**6+1
l=[i for i in range(10**6+1)]
for i in range(2,10**3+1):
   if l[i]!=0:
       for j in range(2*i,10**3+1,i):
           l[j]=0


a,b=f()
gd=gcd(a,b)
sm=0
for i in range(2,int(gd**0.5)+1):
    if i*i!=gd and l[i]!=0:
        if gd%i==0:
            sm+=1
        if l[gd//i]!=0:
            sm+=1
print(sm+1)

Submission status: Runtime Error

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

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]]


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

GCD = gcd(a,b)
count = 0
Primes = primes(GCD//2+1)

for prime in Primes:
    if GCD % prime == 0:
        count += 1
print(count+1)

Submission status: Runtime Error

Solution code:
import math
from fractions import gcd

def era(n):
    if n == 1:
        return []
    prime_list = []
    # 2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,n+1))
    while True:
      # search_listの先頭の値が√nの値を超えたら処理終了
        if search_list[0] > math.sqrt(n):
            # prime_listにsearch_listを結合
            prime_list.extend(search_list)
            break
        else:
            # search_listの先頭をprime_listに入れる
            head_num = search_list[0]
            prime_list.append(head_num)
            # search_listの先頭をpopする
            search_list.pop(0)
            # head_numの倍数を取り除く
            search_list = [num for num in search_list if num % head_num != 0]

    return prime_list

def main():
    a,b = map(int, input().split())

    g = gcd(a, b)
    p_nums = era(g)

    ans = 1
    if len(p_nums) >= 1:
        for p in p_nums:
            if g % p == 0:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math
n=[int(i) for i in input().split()]
ans=[]
g=math.gcd(n[0],n[1])
prime = [0 for i in range(g+1)]
ans.append(1)
p = 2
while (p <=g):

    # If prime[p] is not changed, then it is a prime
    if (prime[p] == 0):
        if n[0] % p == 0 and n[1] % p == 0:
            ans.append(p)
        # Update all multiples of p
        for i in range(p * p, g+1, p):
            prime[i] = 1
    p += 1
print(len(ans))

Submission status: Runtime Error

Solution code:
from math import gcd

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

g=gcd(a,b)
cnt=[]

for i in range(1,g+1):
    if i*i>g:
        break
    if g%i==0:
        if g//i==i:
            cnt.append(i)
        else:
            cnt.append(i)
            cnt.append(g//i)


ma=max(cnt)

ans=0
d=dict()
cnt=sorted(cnt)

for i in range(len(cnt)):
    if cnt[i]!=1:
        for j in range(2*cnt[i],ma+1,cnt[i]):
            if j in cnt:
                d[j]=1


for i in cnt:
    if i not in d.keys():
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import math
A,B=map(int,input().split(" "))
r=math.gcd(A,B)
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

cnt=1
for i in range(r):
    if is_prime(i+1) and A%(i+1)==0 and B%(i+1)==0:
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
import sys,math
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int,ins()))
def lin(): return list(input())
def iin(): return map(int,ins())

a,b = iin()
t = math.gcd(a,b)

p=[0,0]+[1]*999999
k=len(p)
for i in range(k//2+1):
    if p[i]==0:continue
    for q in range(2*i,k,i):
        p[q]=0
cnt = 1
for i,j in enumerate(p):
    if j==1 and t%i==0:
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
import math

def read():
    A, B = map(int, input().strip().split())
    return A, B

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

def solve(A, B):
    gcd = math.gcd(A, B)
    divisors = sorted(make_divisors(gcd))
    table = [True] * len(divisors)
    for i in range(1, len(divisors)):
        for j in range(i+1, len(divisors)):
            if table[j] and divisors[j] % divisors[i] == 0:
                table[j] = False
    divisors = [divisors[i] for i in range(len(divisors)) if table[i]]
    return len(divisors)

if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

Submission status: Runtime Error

Solution code:
import math

a, b = [int(i) for i in input().split()]
d = math.gcd(a,b)
if d == 1:
    print(1)
else:
    ans = set([1])
    while d % 2 == 0: 
        ans.add(2) 
        d //= 2
    for i in range(3,int(math.sqrt(d))+1,2): 
        while d % i== 0: 
            ans.add(i) 
            d //= i 
    if d > 2: 
        ans.add(d)
    print(len(ans))

Submission status: Runtime Error

Solution code:
A,B = (int(i) for i  in input().split())
from math import gcd,sqrt
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 is_prime(n):
    if n == 1: return True
    for k in range(2, int(sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
ans = 0
for d in divisors:
    ans += is_prime(d)
print(ans)

Submission status: Runtime Error

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

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

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

res = len([i for i in lst if is_prime(i)])

print(res)

Submission status: Runtime Error

Solution code:
import math

a, b = map(int, input().split())
x    = math.gcd(a, b)
y    = int(math.sqrt(x))
ps   = [1, 2, 3, 5, 7, 11, 13]
p    = ps[-1]

def check(p):
	q = int(math.sqrt(p))
	
	for i in range(2, len(ps)):
		if p % ps[i] == 0:
			return False
		if q < ps[i]:
			break
	
	return True

while p <= y:
	p += 2
	while check(p) == False:
		p += 2
	ps.append(p)

print(sum(1 for p in ps if x % p == 0))

Submission status: Runtime Error

Solution code:
import math
a, b = map(int, input().split())
gcd = math.gcd(a, b)
primes = []
for i in range(2, int(gcd) + 1):
    if gcd % i == 0:
        isPrime = True
        for j in range(2, i):
            if i % j == 0:
                isPrime = False
                break
        if isPrime:
            primes.append(i)
print(len(primes) + 1)

Submission status: Runtime Error

Solution code:
import sys
from collections import defaultdict, deque
from functools import reduce
import math

input = sys.stdin.readline


def sieve_of_eratosthenes(target):
    dest = int(math.sqrt(target))
    target_list = list(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)

        i = 0

        while True:
            if i >= len(target_list):
                break
            elif target_list[i] % num_min == 0:
                target_list.pop(i)
            i += 1

    return(prime_list)

def main():
    A, B = map(int, input().split())
    k = set([1])
    if min(A, B) == 1:
        print(1)
        return
    prime_list = sieve_of_eratosthenes(min(A, B))

    for p in prime_list:
        if A % p == 0 and B % p == 0:
            k.add(p)
    print(len(k))

if __name__ == '__main__':
    main()

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

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

number=prime(min(a,b))
answer=cf(a,b)
flag=0
count=1
for i in answer:
    if i==number[flag]:
        count +=1
        flag +=1

print(count)

Submission status: Runtime Error

Solution code:
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#リスト l の最大公約数
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

#a*x+b*y=gcd(a,b)の一つの解
def extgcd_2(a,b):    
    g = gcd(a,b)
    a = a//g
    b = b//g
    return extgcd(a,b)

#a,bの最小公倍数
def lcm(a, b):
	return a * b // gcd (a, b)

#nの約数列挙
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass

#n以下の素数列挙(O(n log(n))
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    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


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

g = gcd(a,b)
d = divisor(g)
d.sort()

res = 0

isp = primes(g)

for e in d:
    if isp[e]:
        res += 1
print(res)

Submission status: Runtime Error

Solution code:
import math
from collections import defaultdict
a, b = map(int, input().split())

g = math.gcd(a, b)
l = defaultdict(int)
for i in range(2, int(g**0.5)+1):
    if g % i == 0:
        while g % i == 0:
            l[i] += 1
            g = g // i
if g != 1:
    l[g] += 1
print(len(l)+1)

Submission status: Runtime Error

Solution code:
mod = 1000000007
MOD = 998244353
ii = lambda :  int(input())
si = lambda :  input()
dgl = lambda : list(map(int, input()))
f = lambda :   map(int, input().split())
il = lambda :  list(map(int, input().split()))
it = lambda :  tuple(map(int, input().split()))
ls = lambda :  list(input())
from math import *
n=10**6+1
l=[i for i in range(10**6+1)]
for i in range(2,int(10**3+1)+1):
   if l[i]!=0:
       for j in range(2*i,10**3+1,i):
           l[j]=0


a,b=f()
gd=gcd(a,b)
sm=0
for i in range(2,int(gd**0.5)+1):
    if i*i==gd:
        if l[i]!=0:
            sm+=1
    else:
        if l[i] != 0:
            if gd%i==0:
                sm+=1
            if l[gd//l[i]]!=0:
                sm+=1
print(sm+1)

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    A,B = LMIIS()
    import math
    g = math.gcd(A,B)
    cds = [1]
    d = 2
    while g != 1:
        if g % d == 0:
            g //= d
            if cds[-1] != d:
                cds.append(d)
        else:
            d += 1
    print(len(cds))
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
gcd = gcd(a, b)

def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass, is_prime

ass, is_prime = primes(gcd)
is_prime[1] = True

ans = 0
for p, isprime in enumerate(is_prime):
    
    if p == 0:
        continue
    if is_prime[p] == True and a%p==0 and b%p==0:
#         print(p, isprime)
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**8)

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

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

primes = []
for i in range(2, 10**3+10):
    if all(i%p for p in primes):
        primes.append(i)

g = gcd(A, B)
l = [0]*(g+1)
for p in primes:
    if g < p:
        break
    while g%p == 0:
        l[p] = 1
        g //= p
        if g == 1:
            break
    if g == 1:
        break

print(sum(l)+1)

Submission status: Runtime Error

Solution code:
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    if gcd == 1:
        print(1)
    else:
        ls = [True] * (gcd + 1)
        ls[0] = False
        ls[1] = False
        c = [1]
        for i in range(int(len(ls) ** 0.5) + 2):
            if ls[i]:
                if a % i == 0 and b % i == 0:
                    c.append(i)
                for j in range(i, len(ls), i):
                    ls[j] = False
        print(len(c))


if __name__ == '__main__':
    slove()

Submission status: Runtime Error

Solution code:
# from math import factorial
# from collections import defaultdict, deque
#  from heapq import heappush, heappop, heapify

# A, B = [int(i) for i in input().split(" ")]
# A = int(input())
# As = [int(i) for i in input().split(" ")]
# Ss = ["".join(sorted(input())) for _ in range(N)]
# edges = defaultdict(list)
# for _ in range(N - 1):
#     a, b = [int(i) for i in input().split(" ")]
#     edges[a-1].append(b-1)
import math

A, B = [int(i) for i in input().split(" ")]
a, b = [], []
m = math.gcd(A, B)
# print(m)
i = 1
while i <= m:
  if A % i == 0:
     a.append(i)
  if B % i == 0:
     b.append(i)
  i += 1
c = list(sorted(set(a) & set(b)))
ans = []
# print(c)
for i in c:
   for a in ans:
       if a == 1: continue
       if i % a == 0:
          break
   else:
      ans.append(i) 
print(len(ans))

Submission status: Runtime Error

Solution code:
from math import gcd

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

ans = 1
n = d
for i in range(2, d + 1):
    if n % i == 0:
        ans += 1
        while n % i == 0:
            n //= i
    if n < i * i:
        if 1 < n:
            ans += 1
        break
print(ans)

Submission status: Runtime Error

Solution code:
import math


def f(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append(i)

    if temp != 1:
        arr.append(temp)

    if arr == []:
        arr.append(n)

    return arr


def main():
    # return
    # N = int(input())
    # N,= [int(a) for a in input().split()]
    A, B = [int(a) for a in input().split()]

    gcd = math.gcd(A, B)

    if gcd == 1:
        print(1)
    else:
        print(len(f(gcd)) + 1)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math

A, B = map(int, input().split())
d = math.gcd(A, B)
#print('d={}'.format(d))

# make a prime list
# nまでの自然数が素数かどうかを表すリストを返す、エラストテネスの篩 O(nloglogn)
def make_prime_checker(n):
    is_prime = [False, True, False, False, False, True] * (n//6+1)
    del is_prime[n+1:]
    is_prime[1:4] = False, True, True
    for i in range(5, int(n**0.5)+1):
        if is_prime[i]:
            is_prime[i*i::i] = [False] * (n//i-i+1)
    return is_prime
 
primes = [p for p, is_prime in enumerate(make_prime_checker(10**6)) if is_prime]
 
ans = 1
for p in primes:
    if d % p == 0:
        ans += 1
        #print('p={}'.format(p))
    elif p > d:
        print(ans)
        exit()

Submission status: Runtime Error

Solution code:
import numpy as np
import math
a, b = map(int, input().split())
gcd = np.gcd(a, b)

def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass, is_prime

ass, is_prime = primes(gcd)
is_prime[1] = True

ans = 0
for p, isprime in enumerate(is_prime):
    
    if p == 0:
        continue
    if is_prime[p] == True and a%p==0 and b%p==0:
#         print(p, isprime)
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
def divisors(N):
    U = int(N ** 0.5) + 1
    L = [i for i in range(1, U) if N % i == 0]
    return L + [N // i for i in reversed(L) if N != i * i]

def primes(n):
    memo = [True] * (n + 1)
    i = 2
    while i * i <= n:
        if memo[i]:
            j = i << 1
            while j <= n:
                memo[j] = False
                j += i
        i += 1
    return {i for i in range(n + 1) if memo[i] and i >= 2}

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

if A > B:
    A, B = B, A

D = set(primes(A))
E = {d for d in divisors(A) if B % d == 0}

print(len(D & E) + 1)

Submission status: Runtime Error

Solution code:
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

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

# def lcm(a, b):
#     return a*b//gcd(a,b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    """ main """
    A,B = map(int, input().split())
    gc = gcd(A,B)
    if gc == 1:
        print(1)
    else:
        a = factorization(gcd(A,B))
        print(len(a)+1)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

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

primes = []
for i in range(2, 10**3+10):
    if all(i%p for p in primes):
        primes.append(i)

g = gcd(A, B)
l = [0]*(g+1)
for p in primes:
    if g < p:
        break
    while g%p == 0:
        l[p] = 1
        g //= p
        if g == 1:
            break
    if g == 1:
        break

print(sum(l)+1)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
a, b = map(int, input().split())
gcd = math.gcd(a, b)

def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass, is_prime

ass, is_prime = primes(gcd)
is_prime[1] = True

ans = 0
for p, isprime in enumerate(is_prime):
    
    if p == 0:
        continue
    if is_prime[p] == True and a%p==0 and b%p==0:
#         print(p, isprime)
        ans += 1
print(ans)

Submission status: Runtime Error

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

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

primes = []
for i in range(2, 10**3+10):
    if all(i%p for p in primes):
        primes.append(i)

g = gcd(A, B)
l = [0]*(g+1)
for p in primes:
    while g%p == 0:
        l[p] = 1
        g //= p
        if g == 1:
            break
    if g == 1:
        break

print(sum(l)+1)

Submission status: Runtime Error

Solution code:
from math import gcd

a, b = map(int, input().split())
g = gcd(a, b)
ans = set([1])
for i in range(2, 1000000):
    while g % i == 0:
        g = g // i
        ans.add(i)

print(len(ans))