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:
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a, b = MAP()
gcd = 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

prime = prime_factorize(gcd)
print(len(set(prime))+1)

Submission status: Runtime Error

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


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

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


divs = divisor(n)
ans = 0

for d in divs:
    ans += is_prime(d)


print(ans+1)

Submission status: Runtime Error

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

max_num = max(A, B)
target = list(range(2, max_num + 1))
primes = set()
while True:
    if len(target) == 0:
        break

    num = min(target)

    if num * num > max_num:
        break

    primes.add(num)

    i = 0
    while i < len(target):
        if target[i] % num == 0:
            target.pop(i)
            continue
        i += 1

count = 1
for prime in primes:
    if A % prime == 0 and B % prime == 0:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
import math

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

n = math.gcd(a, b)

cd = []
for i in range(1, math.ceil(math.sqrt(n) + 1)):
    if n % i == 0:
        if n // i == i:
            cd.append(i)
        else:
            cd.append(i)
            cd.append(n // i)

cd.sort()

ans = 0
for i in range(len(cd)):
    for j in range(i + 1):
        if j == i:
            continue
        if cd[j] > 1 and cd[i] % cd[j] == 0:
            break
    else:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math
A, B = map(int, input().split())
g = gcd(A, B)
pn = [2]
for L in range(3, g):
    chk=True
    for L2 in pn:
        if L%L2==0:chk=False
    if chk==True and gcd(g,L)!=1:pn.append(L)
print(len(pn)+1)

Submission status: Runtime Error

Solution code:
import math
a,b = map(int,input().split())
x = math.gcd(a,b)
c= x
ans = 1
for i in range(2,min(int(math.sqrt(x))+1,x)):
    if(c%i==0):
        ans+=1
    while(c%i==0):
        c=c//i
if(c>1):
    ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
 
tmpA = max(a, b)
tmpB = min(a, b)
 
while tmpB != 0:
    newB = tmpA % tmpB
    tmpA = tmpB
    tmpB = newB
 
tmp = tmpA

ass = []
for i in range(2,int(tmp**0.5)+1):
    while tmp % i==0:
        ass.append(i)
        tmp = tmp//i
if tmp != 1:
    ass.append(n)

print(len(set(ass)) + 1)

Submission status: Runtime Error

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

n=min(a,b)
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
prime=[i for i in range(n+1) if is_prime[i]]

count=1
for i in prime:
    if i>n:break
    elif a%i==0 and b%i==0:
        count +=1

print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
A,B=np.array(list(map(int, input().split())))
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
C=np.array(prime_factorize(math.gcd(A,B)))
print(len(np.unique(C))+1)

Submission status: Runtime Error

Solution code:
from math import gcd


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 = tuple(map(int, input().split(" ")))

print(len(set(prime_factorize(gcd(A, B)))) + 1)

Submission status: Runtime Error

Solution code:
import math
import sys
a,b = map(int, input().split())
ans = 1
count = 2
num = math.gcd(a,b)

if a==1 or b==1:
    print(1)
else:
    while True:
        if num==1:
            print(ans)
            sys.exit()
        else:
            if num%count==0:
                ans+=1
                while num%count==0:
                    num= num/count
                count+=1
            else:
                count+=1

Submission status: Runtime Error

Solution code:
import math

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

# A, B の正の公約数から互いに素となる組み合わせを選ぶとき、最大でいくつ選べる？
# 最大公約数を求める
gcd = math.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


# 最大公約数を素因数分解する
f = factorization(gcd)
# 1のケースでは1を出力する
if f == [[1, 1]]:
    print(1)
else:
    # 要素数＋１が選択可能な個数
    ans = len(f) + 1
    print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
import math

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

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

print(len(factorization(math.gcd(A,B)))+1)

Submission status: Runtime Error

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


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

g = gcd(a,b)


ans = 1
for i in range(2,g):
    while g%i == 0:
        g=g//i
        isdevided = True
    if isdevided:
        ans += 1
        isdevided = False

print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd as bltin_gcd

def coprime2(a, b):
    return bltin_gcd(a, b) == 1

A,B = map(int, input().split())
num_set = set()
i=2
while True:
    if(A%i==0 and B%i==0):
        num_set.add(i)
        A = A//i
        B = B//i
        if(coprime2(A,B)==1):
            break
    else:
        i = i+1
print(len(num_set)+1)

Submission status: Runtime Error

Solution code:
import math
a,b = map(int,input().split())
x = math.gcd(a,b)
c= x
ans = 1
for i in range(2,min(int(math.sqrt(x))+1,x)):
    if(c%i==0):
        ans+=1
    while(c%i==0):
        c=c//i
        
if(c>1):
    ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import math
a,b=list(map(int,input().strip().split()))
c=math.gcd(a,b)
d=0
for i in range(2,math.ceil(math.sqrt(c)+1)):
    if c%i==0:
        d=d+1
        c=c//i
print(d+1)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
bigger_num = max([A, B])
common_divs = []

if bigger_num%2==0:
    div_num = int(bigger_num/2)
else:
    div_num = int((bigger_num+1)/2)

for i in range(1, div_num):
    if (A%i==0) and (B%i==0):
        common_divs.append(i)
common_divs.remove(1)

for c1 in common_divs:
    for c2 in common_divs[c1:]:
        if c2%c1==0: common_divs.remove(c2)

print(len(common_divs)+1)

Submission status: Runtime Error

Solution code:
import sys
from scipy.misc import comb
import numpy as np
 
# 約数を列挙
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
 
# n以下の素数を列挙
def primes(n):
    ass = [1]
    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 main():
    input = sys.stdin.readline
    AB = list(map(np.int64, input().split()))
    A = AB[0]
    B = AB[1]
    max_cd = np.gcd(A, B)
    divs = make_divisors(max_cd)
    ass = primes(max_cd)
    #print("divs : {0}".format(divs))
    #print("ass : {0}".format(ass))
 
    co = set(ass)&set(divs)
    #print(co)
    #ans = comb(len(co), 2, exact=True)
    ans = len(co)
    print(ans)
 
if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

max_num = max(A, B)
target = list(range(2, max_num + 1))
primes = set()
while True:
    num = min(target)

    if num * num > max_num:
        break

    primes.add(num)

    i = 0
    while i < len(target):
        if target[i] % num == 0:
            target.pop(i)
            continue
        i += 1

count = 1
for prime in primes:
    if A % prime == 0 and B % prime == 0:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
def find_lcd(A,B):
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  while X != 1:
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = X/i
    i += 1
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))

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] * (max(A,B) + 1)
  
Era = Eratosthenes(B)
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 sympy import isprime
a,b = map(int,input().split())
ans = 1
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

x = cf(a,b)
for i in (x):
    if isprime(i)==True:
        ans+=1

print(ans)

Submission status: Runtime Error

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

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

prime_num=prime(min(a,b))

count=1
min_num=min(a,b)
for i in prime_num:
    if i>min_num//2:break
    elif a%i==0 and b%i==0:
        count +=1

print(count)

Submission status: Runtime Error

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

n = math.gcd(A, B)


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

    print(len(arr)+1)

Submission status: Runtime Error

Solution code:
import math
a,b = map(int, input().split())
ans = 1
count = 2
num = math.gcd(a,b)

while True:
    if num==1:
        print(ans)
        exit()
    else:
        if num%count==0:
            ans+=1
            while num%count==0:
                num= num/count
            count+=1
        else:
            count+=1

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import collections

A,B=np.array(list(map(int, input().split())))

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

c = collections.Counter(prime_factorize(math.gcd(A,B)))
print(len(c)+1)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
kouyakusu = [i+1 for i in range(N) if (N%(i+1) == 0) and (M%(i+1) == 0)]
counter = 1

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

for i in kouyakusu:
  for j in kouyakusu:
    if i > j:
      if gcd(i, j) == 1:
        count += 1

print(count)

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)
    else:
        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:
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 += 1
                for j in range(i, len(ls), i):
                    ls[j] = False
        print(c)


if __name__ == '__main__':
    slove()

Submission status: Runtime Error

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


def dv(x1, x2):
    ret = []

    v = min(x1, x2) + 1
    check = [0] * v

    for n in range(2, v):
        if check[n] == 1:
            continue

        if x1 % n == 0 and x2 % n == 0:
            ret.append(n)

            cnt = 2
            while n * cnt <= v:
                check[n * cnt] = 1
                cnt += 1

    return ret


cf = [1] + dv(A, B)
print(len(cf))

Submission status: Runtime Error

Solution code:
import math
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)

    # divisors.sort()
    return divisors
y = sorted(make_divisors(math.gcd(a,b)))
r = []
for i in y[1:]:
    y_y = make_divisors(i)
    f = True
    for j in y_y:
        if j in r:
            f = False
            break
    if f:
        r.append(i)
print(len(r)+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 primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+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(2, n+1) if is_prime[i]]

def main():
    """ main """
    A,B = map(int, input().split())
    g = gcd(A,B)
    ps = primes(g)
    ans = 1
    for p in ps:
        if g%p == 0: ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import fractions


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


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

###############################


gcd_ab = fractions.gcd(A,B)	


primes_ab = primes(gcd_ab)

# 1は必ずはいる
count = 1
for t in primes_ab:
    if A % t == 0 and B % t == 0:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
def fatora(n):
	ans = []
	for i in range(1, n+1):
		if i*i > n:
			break
		if n % i == 0:
			ans.append(i)
			ans.append(n//i)
	ans.sort()
	return set(ans)

def eh_primo(n):
	if n <= 1:
		return True
	elif n == 2:
		return True
	else:
		for i in range(2, n+1):
			if i*i > n:
				break
			else:
				if n % i == 0:
					return False
		return True
	


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

new_gcd = math.gcd(a, b)

list_div = fatora(new_gcd)
list_primes = list(filter(eh_primo, list_div))

print(len(list_primes))

Submission status: Runtime Error

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

#print(gcd)
pnum = set()

if gcd == 1:
    print(1)
elif gcd == 2:
    print(2)
else:
    pnum.add(2)
    for num in range(3,gcd+1):
        if gcd%num ==0:
            ptf = True
            for p in pnum:
                if num%p==0:
                    ptf = False
                    break
            if ptf ==True:
                pnum.add(num)
            
    print(len(pnum)+1)#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 *

l=[i for i in range(10**6+10)]
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:
import math

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

g = math.gcd(a,b)


ans = 1
for i in range(2,g):
    while g%i == 0:
        g=g//i
        isdevided = True
    if isdevided:
        ans += 1
        isdevided = False

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(min(A, B))

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

print(len(ans))

Submission status: Runtime Error

Solution code:
import collections
import math
a, b = input().split()
A = int(a)
B = int(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


GCB = math.gcd(A, B)

C = collections.Counter(prime_factorize(GCB))

print(len(C) + 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=0

if len(cnt)>0:
    ma=max(cnt)


ans=0
d=dict()
e=dict()

for i in cnt:
    e[i]=1
#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 e.keys():
                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
import sys
A, B = map(int, input().split())

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

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

N = gcd(A, B)
if N == 1:
  print (1)
  sys.exit()

D = make_divisors(N)
L = []
for i in D:
  for j in L:
    if i % j == 0:
      break
  else:
    L.append(i)
print (len(L)+1)

Submission status: Runtime Error

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

if A==1 or B==1:
    print(1)
else:
    print(len(factorization(gcd_n))+1)

Submission status: Runtime Error

Solution code:
import math
ans=1
a,b=map(int, input().split())
c=math.gcd(a,b)
d = []
for i in range(1, int(c**0.5)+1):
    if a % i == 0 and b % i == 0:
        d.append(i)
        if i != c // i :
            d.append(c//i)
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 d:
    if is_prime(i):
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import random
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,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):
    is_prime = [True] * (n + 100)
    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)
#print(isp)

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

print(res)

Submission status: Runtime Error

Solution code:
import math
a,b=map(int,input().split())
gcd_ab=math.gcd(a, b)
i=2
d={}
ans=1
while(gcd_ab!=1):
    if(gcd_ab%i == 0):
        val=d.get(i, 0)
        val+=1
        d[i]=val
        gcd_ab//=i
    else:
        i+=1
ans+=len(list(d.keys()))
print(ans)

Submission status: Runtime Error

Solution code:
import sys
from scipy.misc import comb
import fractions

# 約数を列挙
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

# n以下の素数を列挙
def primes(n):
    ass = [1]
    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 main():
    input = sys.stdin.readline
    AB = list(map(int, input().split()))
    A = AB[0]
    B = AB[1]
    max_cd = fractions.gcd(A, B)
    divs = make_divisors(max_cd)
    ass = primes(max_cd)
    #print("divs : {0}".format(divs))
    #print("ass : {0}".format(ass))

    co = set(ass)&set(divs)
    #print(co)
    #ans = comb(len(co), 2, exact=True)
    ans = len(co)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math

d = math.gcd(*map(int, input().split()))
r = 1
i = 2
while i * i <= d:
    if d % i == 0:
        d //= i
        r += 1
    while d % i == 0:
        d //= i
    i += 1
print(r + (d > 1))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import itertools

def cf(x1,x2):
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            yield i

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

def solve(A: int, B: int):
    P = primes(min(A,B))

    n = 1
    for p in P:
        if A % p == 0 and B % p == 0:
            n += 1

    print(n)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

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

def main():
    """ main """
    A,B = map(int, input().split())
    _gcd = gcd(A,B)
    ps = primes(_gcd)
    ans = 1
    for p in ps:
        if _gcd%p == 0: ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#D
from fraction import gcd
#from math import gcd
import collections
a, b = map(int,input().split())
tmp = 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

if tmp == 1:
    l = 1
    ans = 1
else:
    l = prime_factorize(tmp)
    clist = collections.Counter(prime_factorize(840))
    ans = len(clist.keys())
print(ans)

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)
    else:
        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().split())
if A > B:
    A, B = B, A

s = [1] * (A+1)
ans, t = 1, set()
i, lim = 2, A ** 0.5
while i < lim:
    if s[i] == 1:
        for j in range(i*2, A+1, i):
            s[j] = 0
        if A % i == 0 and B % i == 0:
            ans += 1
    i += 1

print(ans)

Submission status: Runtime Error

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