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 .

Solution (Python):
A,B = map(int,input().split())
A_sosu = []
B_sosu = []
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_sosu = set(prime_factorize(A))
B_sosu = set(prime_factorize(B))
cnt = 0
for a in A_sosu:
    if(a in B_sosu):
        cnt += 1
print(cnt+1)

Solution (Python):
import sys
import numpy as np


def input():
    return sys.stdin.readline()[:-1]


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


def factorize(n):
    res = dict()
    for i in range(2, int(np.sqrt(n)) + 10):
        if n % i:
            continue
        res.setdefault(i, 0)
        while (n % i == 0):
            n //= i
            res[i] += 1
    if n != 1:
        res.setdefault(n, 1)
    return res


def solve():
    a, b = map(int, input().split())
    n = gcd(a, b)
    print(len(factorize(n))+1)


if __name__ == "__main__":
    solve()

Solution (Python):
from fractions import gcd
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

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(n**0.5)+1):
        if n % k == 0:
            return False
    return True

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

ans = 0
GCD = gcd(a, b)

GCD_list = make_divisors(GCD)


for i in GCD_list:
    if is_prime(i):
        ans += 1

print(ans + 1)

Solution (Python):
def m_div(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

a,b = map(int, input().split())
lis = list(set(m_div(a)) & set(m_div(b)))
lis.sort()

anslis=[]

for num in lis[1:]:
    prime=True
    for p in anslis:
        if num % p == 0:
            prime=False
    if prime:
        anslis.append(num)
print(len(anslis)+1)

Solution (Python):
from fractions 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=map(int,input().split())
m=gcd(a,b)
P=prime_factorize(m)
print(1+len(list(set(P))))

Solution (Python):
A,B = [int(i) for i in input().split()]

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

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 = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return(data)

n=gcd(A,B)
ans = 1
if n==1:
    print(1)
else:
    
    
    for p in range(2,int(n**0.5)+3):
        if n%p==0:
            ans+=1
            while n%p==0:
                n = n//p
    if n!=1:
        ans+=1
    print(ans)

Solution (Python):
A, B = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
N = gcd(A,B)

def factorize(n):
  b = 2
  fct = []
  while b * b <= n:
    while n % b == 0:
      n //= b
      fct.append(b)
    b = b + 1
  if n > 1:
    fct.append(n)
  return fct

print(len(set(factorize(N)))+1)

Solution (Python):

from fractions import gcd
def divisor(N):
    
    divs = []
    for i in range(1, int(N**0.5)+1):
        if N % i == 0:
            divs.append(i)
            if i != N // i:
                divs.append(N//i)
    return divs
def eratosthenes(N):
    
    flag = True
    for i in range(2, int(N**0.5) + 1):
        if N % i == 0:
            flag = False
            break
    return flag

A, B = map(int, input().split())
A_divs = divisor(A)
B_divs = divisor(B)
ans = 1
L = list(set(A_divs) & set(B_divs))
ans = 0
for i in range(len(L)):
    if eratosthenes(L[i]):
        ans += 1
print(ans)

Solution (Python):
import math
import fractions

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

gcd = fractions.gcd(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)

    divisors.sort()
    return divisors

div = make_divisors(gcd)
ans = 1
for i in range(1,len(div)) :
  check = 0
  for j in range(2,math.floor(math.sqrt(div[i]))+1) :
    if div[i]%j == 0 :
      check = 1
      break
  if check == 0 :
    ans += 1

print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

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

kouyaku = (set(a) & set(b))






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

wa = 0
for i in kouyaku:
	if is_prime(i):
		wa += 1
print(wa)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

A, B = MAP()
a = divisor(A)
b = divisor(B)
a = set(a)
b = set(b)
kouyaku = a & b

ans = 1
for y in kouyaku:
    if is_prime(y):
        ans += 1
print(ans)

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

import fractions
c = fractions.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
print(len(set(prime_factorize(c))) + 1)

Solution (Python):


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

A, B = map(int, input().split())
Ap = set(decomposition_prime(A))
Bp = set(decomposition_prime(B))
print(len(Ap & Bp)+1)

Solution (Python):
import math 
import bisect
from collections import deque
a,b = map(int, input().split())
def pf(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_s = pf(a)
a_s = list(set(a_s))
b_s = pf(b)
count = 0

for i in range(len(a_s)):
    if a_s[i] in b_s: count += 1 

print(count + 1)

Solution (Python):
import fractions

A, B = map(int,input().split())
GCD = fractions.gcd(A, B)

def prime_factorize(n):
    a = [1]
    flag = 1
    while n % 2 == 0:
        if flag:
            a.append(2)
            flag = 0
        n //= 2
    f = 3
    flag = 1
    while f * f <= n:
        if n % f == 0:
            if flag:
                a.append(f)
                flag = 0
            n //= f
        else:
            f += 2
            flag = 1
    if n != 1 and n != a[-1]:
        a.append(n)
    return a

a = prime_factorize(GCD)

print(len(a))

Solution (Python):
from fractions import gcd
def Comon_divisor(a,b):
    GCD=gcd(a,b)
    num=int(GCD**0.5)
    Cd=[1]
    for i in range(2,num+2):
        if GCD%i == 0:
            Cd.append(i)
        while True:
            if GCD%i == 0:
                GCD //= i
            else:break

    if GCD != 1:
        Cd.append(GCD)
    return Cd
a,b = map(int, input().split())
Divisor = Comon_divisor(a, b)
print(len(Divisor))

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

def lcm(a, b):
    return a // gcd (a, b) * 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

n, m = map(int, input().split())
g = gcd(n,m)
if g == 1:
    print(1)
else:
    print(len(factorization(g))+1)

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]


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


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


def prime_factorization(n):
    arr = []
    tmp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if tmp % i == 0:
            while tmp % i == 0:
                arr.append(i)
                tmp //= i
    if(tmp != 1):
        arr.append(tmp)
    if not arr:
        arr.append(n)
    return arr 

def main():
    A, B = map(int, input().split())
    tmp = gcd(A, B)
    if tmp == 1:
        print(1)
    else:
        print(1 + len(set(prime_factorization(tmp))))

if __name__ == "__main__":
    main()

Solution (Python):
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
l=[]
a,b=map(int,input().split())
import fractions
g=fractions.gcd(a,b)
for i in range(len(prime_decomposition(g))):
  if prime_decomposition(g)[i] not in l:
    l.append(prime_decomposition(g)[i])
print(len(l)+1)

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

def prime_factorize(n):
    a = [1]
    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

d=set(prime_factorize(A)) & set(prime_factorize(B))

print(len(d))

Solution (Python):
A,B=map(int,input().split())
a=[1]
con=True
while con:
    con=False
    for i in range(2,int(A**0.5)+1):
        if A%i==0:
            con=True
            a.append(i)
            A=A//i
            break
a.append(A)
b=[1]
con=True
while con:
    con=False
    for i in range(2,int(B**0.5)+1):
        if B%i==0:
            con=True
            b.append(i)
            B=B//i
            break
b.append(B)
a=set(a)
b=set(b)
c=list(a&b)
from copy import copy
d=copy(c)
for i in range(len(d)):
    for j in range(len(c)):
        if i!=j:
            for k in range(2 ,min(d[i],c[j])):
                if d[i]%k==0 and c[j]%k==0:
                    c[j]=0
ans=0
for i in range(len(c)):
    if c[i]!=0:
        ans+=1
print(ans)

Solution (Python):
import fractions
a,b=map(int,input().split())
g=fractions.gcd(a,b)

import math
def findFactors(n):
    now=n
    f=[]
    while now%2==0:
        now//=2
        f.append(2)
    p=3
    while p<=math.sqrt(n):
        while now%p==0:
            now//=p
            f.append(p)
        p+=2
        if now==1:
            break
    if now>math.sqrt(n):
        f.append(now)
    return f

if g==1:
    print(1)
else:
    f=set(findFactors(g))
    print(len(f)+1)

Solution (Python):
def soin(N):
    res = [1]
    i = 2
    while i < round(N**(1/2)) + 3:
        if N%i == 0:
            res.append(i)
            N = N//i
            i = 2
        else:
            i += 1
    res.append(N)
    return set(res)

A, B =(int(i) for i in input().split())
print(len(soin(A)&soin(B)))

Solution (Python):

from collections import Counter, deque







import sys



ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def factorization(n):
    

    factor = []

    for i in list(range(2,3)) + list(range(3, int(n**0.5)+ 1, 2)):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                n //= i
                factor.append(i)
    if n != 1:
        factor.append(n)

    return factor

def main():
    a, b = list(map(int,ipti().split()))
    a_fac = set(factorization(a))
    b_fac = set(factorization(b))
    ab_common = a_fac & b_fac
    print(len(ab_common)+1)

if __name__ == '__main__':
    main()

Solution (Python):
m, n = map(int, input().split())
while True:
  if m < n:
    m, n = n, m
  if m%n:
    m, n = n, m%n
  else:
    break

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()
ans = [1]
notans = [False]*len(divisors)
for j in range(len(divisors)):
    if divisors[j] == 1 or notans[j] == True:
        continue
    ans.append(divisors[j])
    for i in range(j+1, len(divisors)):
        if divisors[i]%divisors[j] == 0:
            notans[i] = True

print(len(ans))

Solution (Python):
from fractions import gcd
import math
a,b = map(int,input().split())
n = gcd(a,b)
if n == 1:
    print(1)
    exit()
count = 1
for i in range(2,math.ceil(math.sqrt(n))+1):
    if n % i == 0:
        count += 1
        while n % i == 0:
            n //= i
if n > 1:
    count += 1
print(count)

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

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

def factorization(n):
  arr = {1}
  tmp = n
  for i in range(2,int(tmp**0.5)+1,1):
    while tmp % i == 0:
      tmp //= i
      arr.add(i)
  if tmp != 1:
    arr.add(tmp)
  return arr

g = gcd(a,b)
arr = factorization(g)
print(len(arr))

Solution (Python):
import math

a,b = map(int, input().split())
 
def gcd(a, b):
  while b:
      a, b = b, a % b
  return a
 
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

g = gcd(a,b)
fac = prime(g)
print(len(fac)+1)

Solution (Python):
from fractions import gcd


def main():
    A, B = map(int, input().split(" "))
    g = gcd(A, B)
    answer = [1]
    while not g % 2:
        g //= 2
        answer.append(2)
    i = 3
    while i * i <= g:
        if not g % i:
            g //= i
            answer.append(i)
        else:
            i += 2
    if not g == 1:
        answer.append(g)
    print(len(set(answer)))


if __name__ == '__main__':
    main()

Solution (Python):
import fractions
a,b = map(int,input().split())
g = fractions.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
  

lis = prime_factorize(g)
lis = list(set(lis)) 
print(len(lis)+1)

Solution (Python):
import sys
A,B = map(int,input().split())
def trial_division(n):
    if n < 2:
        return []

    prime_factors = []

    for i in range(2, int(n**0.5)+1):
        
        while n % i == 0:
            
            prime_factors.append(i)
            
            n //= i
    
    if n > 1:
        prime_factors.append(n)

    return prime_factors

A = set(trial_division(A))
B = set(trial_division(B))
print(len(A & B)+1)

Solution (Python):
from fractions import gcd
from math import sqrt


def prime_factorize(n):
    result = []
    for i in range(2, int(sqrt(n)) + 1):
        if n % i != 0:
            continue
        t = 0
        while n % i == 0:
            n //= i
            t += 1
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    return result


A, B = map(int, input().split())
print(len(prime_factorize(gcd(A, B))) + 1)

Solution (Python):
import math
import fractions

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

a = fractions.gcd(a,b)

i = 2
ans = 1

while i <= a**0.5:
  tmp = a
  while a%i==0:
    a /= i
  if not a == tmp:
    ans += 1
  i += 1
if a >1 :
  ans += 1
  
print(ans)

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

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

s=gcd(a,b)
x=[]
while s%2==0:
    s//=2
    x.append(2)
f=3
while f*f<=s:
    if s%f==0:
        s//=f
        x.append(f)
    else:
        f+=2
if s!=1:
    x.append(s)
      
print(len(set(x))+1)

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

a, b = map(int, input().split())
max = gcd(a, b)
pf=[]


tmp=max
i=2
while tmp % 2 == 0:
    pf.append(2)
    tmp //= 2
f = 3
while f * f <= tmp:
    if tmp % f == 0:
        pf.append(f)
        tmp //= f
    else:
        f += 2
if tmp != 1:
    pf.append(tmp)



spf = set(pf)

print(len(spf)+1)

Solution (Python):
from math import sqrt
def gcd(a,b):
  if a<b:
    a,b=b,a
  if b==0:
    return a
  else:
    return gcd(b,a%b)
a,b=map(int,input().split())
n=gcd(a,b)

ans=1
r=int(sqrt(n)+1)

for i in range(2,r):
  
  if n%i==0:
    cnt=0
    while n%i==0:
      
      n//=i
      cnt=1
    if cnt:
      ans+=1

if n>1:
  ans+=1

print(ans)

Solution (Python):
a, b = map(int, input().split())
c = min(a,b)
s = [1]
i = 2
while i <= c**0.5+1:
  if a%i==0 and b%i==0:
    a //= i
    b //= i
    if not(i in s):
      s.append(i)
  else:
    if a%i==0: a//=i
    if b%i==0: b//=i
    i += 1
  c = min(a,b)
if c!=1 and max(a,b)%c==0 and all([i==1 or c%i>0 for i in s]):
  s.append(c)
print(len(s))

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


A = set(make_divisors(A))
B = set(make_divisors(B))
C = A & B

cnt = 0
for i in C:
    if len(make_divisors(i)) == 1 or len(make_divisors(i)) == 2:
        cnt += 1
print(cnt)

Solution (Python):
a,b=map(int,input().split())
def get_prime_dic(n):
    dic = {}
 
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            if i in dic:
                dic[i] += 1
            else:
                dic[i] = 1
        i += 1
 
    if n > 1:
        dic[n] = 1
    return dic
c=get_prime_dic(a)
d=get_prime_dic(b)
ans=1

ans+=len(set(c)&set(d))

print(ans)

Solution (Python):
def gcd(a, b):
	return gcd(b, a % b) if b else a

A, B = map(int, input().split())
c = gcd(A, B)
d = set()
i = 2
while i * i <= c:
	while c % i == 0:
		c /= i
		d.add(i)
	i += 1
if c != 1:
	d.add(c)
print(len(d) + 1)

Solution (Python):
from math import sqrt

A, B = map(int, input().split())
rootA = int(sqrt(A))+1
rootB = int(sqrt(B))+1

PrimeFactorA = []
PrimeFactorB = []
for i in range(2, rootA+1):
	while A%i == 0:
		A //= i
		PrimeFactorA.append(i)
	if A == 1:
		break
else:
	PrimeFactorA.append(A)
PrimeFactorA = set(PrimeFactorA)

for i in range(2, rootB+1):
	while B%i == 0:
		B //= i
		PrimeFactorB.append(i)
	if B == 1:
		break
else:
	PrimeFactorB.append(B)
PrimeFactorB = set(PrimeFactorB)

count = 1
for a in PrimeFactorA:
	if a in PrimeFactorB:
		count += 1

print(count)

Solution (Python):
import itertools
a, b = map(int, input().split())


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

    
    return divisors
import math

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

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

    return True
c = make_divisors(a)
d = make_divisors(b)

f = list(set(c) & set(d))
ans = []

for s in f:
    if is_prime(s):
        ans.append(s)
print(len(ans)+1)

Solution (Python):
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])
  return arr
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)

g=gcd(a,b)
l=factorization(g)
print(len(l)+1)

Solution (Python):
from fractions import gcd
from math import ceil,sqrt
a, b = map(int, input().split())

g = gcd(a,b)

s = set()
for i in range(2,ceil(sqrt(g))+1):
    while g % i == 0:
        g //= i
        s.add(i)
if g != 1:
    s.add(g)


print(len(s)+1)

Solution (Python):
from fractions import gcd
from math import ceil,sqrt
a, b = map(int, input().split())

g = gcd(a,b)

s = set()
for i in range(2,ceil(sqrt(g))+1):
    while g % i == 0:
        g //= i
        s.add(i)
if g != 1:
    s.add(int(1e14))


print(len(s)+1)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

a, b = MAP()
kouyaku = list(set(divisor(a)) & set(divisor(b)))

ans = 0
for k in kouyaku:
    if is_prime(k):
        ans += 1
print(ans+1)

Solution (Python):
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def isPrime(x):
    for i in range(2, int(x**0.5)+1):
        if x % i == 0:
            return False
    return True

a,b=map(int,input().split())
div_a=divisor(a)
div_b=divisor(b)
div_ab=[]
for aa in div_a:
    if aa in div_b:
        div_ab.append(aa)
ans=0
for ab in div_ab:
    if isPrime(ab):
        ans+=1
print(ans)

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

def ssb(n):
    a = {1}
    while n % 2 == 0:
        a.add(2)
        n /= 2
    i = 3
    while i ** 2 <= n:
        if n % i == 0:
            a.add(i)
            n /= i
        else:
            i += 2
    if n != 1:
        a.add(n)
    return a

a = ssb(A)
b = ssb(B)

print(len(a&b))

Solution (Python):



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

def main():
  a, b = map(int, input().strip().split())
  g = gcd(a, b)
  
  count = 0
  for p in range(2, int(g ** 0.5 + 1)):
    if g % p == 0:
      count += 1
    while g % p == 0:
      g //= p
      
  if g != 1:
    count += 1
    
  print(count + 1)

if __name__=='__main__':
  main()

Solution (Python):
A,B = map(int,input().split())
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,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

m = gcd(A,B)
r = factorization(m)

for row in r:
  if row[0] == 1:
    print(len(r))
    exit()
print(len(r)+1)

Solution (Python):
from fractions import gcd
from collections import Counter
a,b=map(int,input().split())
g=gcd(a,b)
L=[]
for i in range(2,int(g**0.5)+1):
    while g%i==0:
        g//=i
        L.append(i)
if L==[]:
    L.append(g)
else:
    if g!=1:
        L.append(g)
LC=Counter(L)
r=len(LC)
if 1 not in LC.keys():
   r+=1
print(r)

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

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 

def main():
    A, B = map(int, input().split())
    div_A = set(divisor(A))
    div_B = set(divisor(B))
    com_div = div_A & div_B
    cnt = 1
    for a in com_div:
        if is_prime(a):
            cnt += 1

    print(cnt)



if __name__ == "__main__":
    main()

Solution (Python):
import math
a,b = map(int,input().split())
while b!= 0:
  a,b = b,a%b
n = a
rn = int(math.sqrt(n))
cnt = 1
for i in range(2,rn+1):
    if n%i == 0:
        while n%i == 0:
            n = n//i
        cnt += 1
if n == 1:
    print(cnt)
else:
    print(cnt+1)

Solution (Python):
A, B = (int(i) for i in input().split())
def euclid(a, b):
    while b:
        a, b = b, a%b
    return a
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
try:
  print(len(list(set(prime_decomposition(euclid(A,B)))))+1)
except:
  print(1)

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def divisor(n):
        i = 1
        table = []
        while i * i <= n:
            if n % i == 0:
                table.append(i)
                table.append(n // i)
            i += 1
        table = list(set(table))
        return table


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    
    A, B = Scanner.map_int()
    ans = 0
    for a in Math.divisor(Math.gcd(A, B)):
        if Math.isPrime(a):
            ans += 1
    ans += 1
    print(ans)
    return


if __name__ == "__main__":
    main()