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):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, 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 is_prime(p):
    if p == 1:
        return False
    for i in range(2, int(p ** 0.5) + 1):
        if p % i == 0:
            return False
    return True


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

g = gcd(A, B)
d = make_divisors(g)

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

print(ans)

Solution (Python):
import fractions
import collections
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])

    
    return arr
Gcd = fractions.gcd(A,B)
ans = factorization(Gcd)
print(len(ans)+1)

Solution (Python):
a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math
import collections


def prime_factorization(num, divisors=None):
    if num <= 1:
        assert False
    factors = []

    
    
    
    if not divisors:
        divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]

    for d in divisors:
        
        if num < d:
            break
        while num % d == 0:
            factors.append(d)
            num //= d

    if num != 1:
        factors.append(num)
    return factors




small_factors = set(prime_factorization(small))
big_factors = set(prime_factorization(big))

print(len(small_factors.intersection(big_factors)) + 1)

Solution (Python):
a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math
import collections


def prime_factorization(num, divisors=None):
    if num <= 1:
        assert False
    factors = []

    
    
    
    if not divisors:
        divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]

    for d in divisors:
        
        if num < d:
            break
        while num % d == 0:
            factors.append(d)
            num //= d

    if num != 1:
        factors.append(num)
    return factors

divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]
small_factors = set(prime_factorization(small, divisors))
big_factors = set(prime_factorization(big, divisors))

print(len(small_factors.intersection(big_factors)) + 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
    
a,b = map(int,input().split())

aset = set(divisor(a))
bset = set(divisor(b))

cset = aset & bset
clist = list(cset)
"""
if len(clist) == 1:
    print(1)
    exit()

coprime = [1]
coprime.append(clist[1])



for j in range(2,len(clist)):
    for k in range(1,len(coprime)):
        if clist[j] % coprime[k] == 0:
            break
    else:
        coprime.append(clist[j])


print(len(coprime))
"""

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

cop = 1
for j in range(1,len(clist)):
    if is_prime(clist[j]) == True:
        cop += 1

print(cop)

Solution (Python):
a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math
import collections


def prime_factorization(num, divisors=None):
    if num <= 1:
        assert False
    factors = []

    
    
    
    if not divisors:
        divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]

    for d in divisors:
        
        if num < d:
            break
        while num % d == 0:
            factors.append(d)
            num //= d

    if num != 1:
        factors.append(num)
    return factors




small_factors = set(prime_factorization(small))
big_factors = set(prime_factorization(big))

print(len(small_factors.intersection(big_factors)) + 1)

Solution (Python):
def prime_factorize(n):
    a = set([1])
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    a.add(n)
    return a
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  
a, b = list(map(int, input().split()))
x = gcd(a, b)
print(len(prime_factorize(x)))

Solution (Python):
a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math
import collections


def prime_factorization(num, divisors=None):
    if num <= 1:
        assert False
    factors = []

    
    
    
    if not divisors:
        divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]

    for d in divisors:
        
        if num < d:
            break
        while num % d == 0:
            factors.append(d)
            num //= d

    if num != 1:
        factors.append(num)
    return factors

divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]
small_factors = set(prime_factorization(small, divisors))
big_factors = set(prime_factorization(big, divisors))

print(len(small_factors.intersection(big_factors)) + 1)

Solution (Python):
def pf(n:int):
    r = []
    while n%2==0:
        r.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            r.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        r.append(n)
    return r

a, b = map(int, input().split())
a = pf(a)
b = pf(b)
a = set(a)
b = set(b)
print(len(set(a&b))+1)

Solution (Python):
import fractions


def 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

def factor(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():
    A, B = map(int, input().split())
    d = fractions.gcd(A, B)
    

    if d == 1:
        print(1)
    else:
        print(1 + len(factor(d)))

if __name__ == '__main__':
    main()

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

res = 1
for i in range(2, int(B**0.5)+1):
    if B % i == 0:
        if A % i == 0:
            for j in range(2, int(i**0.5)+1):
                if i % j == 0:
                    break
            else:
                res += 1
        t = B // i
        if t != i and A % t == 0:
            for j in range(2, int(t**0.5)+1):
                if t % j == 0:
                    break
            else:
                res += 1

print(res if res > 1 else (1 if (A == B == 1) or A != B else 2))

Solution (Python):
import collections

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

S = list(map(int,input().split()))
A = min(S)
B = max(S)
  
C = collections.Counter(prime_factorize(A))
count = 1
for p in C.keys():
    if B % p == 0:
        count += 1
print(count)

Solution (Python):
from fractions import gcd
from math import sqrt
import sys
def input() -> str:
    return sys.stdin.readline()
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            divisors.add(n//i)
    return list(divisors)
def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
a, b = map(int, input().split())
print(len([div for div in make_divisors(gcd(a, b)) if is_prime(div)]) + 1)

Solution (Python):
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()
cnt=0
di=div(g)

for i in di:
    f=True
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            f=False
            break
    if f:
        cnt+=1
print(cnt)

Solution (Python):
from sys import stdin


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


def factorization(a):
    if a < 2:
        return []
    fac = []
    lim = int(a ** 0.5)
    i = 2
    while a > 1 and i <= lim:
        n = 0
        while a % i == 0:
            a //= i
            n += 1
        if n > 0:
            fac += [(i, n)]
        i += 1
    if a > 1 or fac == []:
        fac += [(a, 1)]
    return fac


a, b = [int(x) for x in stdin.readline().split()]

print(len(factorization(gcd(a, b))) + 1)

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2

    i = 3
    while i * i <= n:
        if n % i == 0:
            a.append(i)
            n //= i
        else:
            i += 2

    if n != 1:
        a.append(n)
    return a

a_fact = prime_factorize(A)
b_fact = prime_factorize(B)

print(len(set(a_fact) & set(b_fact)) + 1)

Solution (Python):
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D == 1:
  pass
else:
  for i in range(2, int(-(-D**0.5//1)+1)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
  if temp != 1:
    arr.append(D)
print(len(arr)+1)

Solution (Python):
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())
apri = set(prime_factorize(a))
bpri = set(prime_factorize(b))
print(len(apri & bpri)+1)

Solution (Python):
import sys
input=sys.stdin.readline

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

def main():
    A,B = map(int, input().split())
    ps = set(prime_factorize(A)) & set(prime_factorize(B))
    print(len(ps)+1)

if __name__ == '__main__':
    main()

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

    primeFactorA = prime_factorize(A)
    primeFactorB = prime_factorize(B)

    commonFactor = [1]
    for f in primeFactorB:
        if f in primeFactorA:
            commonFactor.append(f)
    
    print(len(commonFactor))


def prime_factorize(num):
    a = set() 
    while num % 2 == 0:
        a.add(2)
        num //= 2
    
    f = 3
    while f * f <= num:
        if num % f == 0:
            a.add(f)
            num //= f
        else:
            f += 2
    if num != 1:
        a.add(num)
    
    return a

if __name__ == '__main__':
    solve()

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




def getPrimeFactorsList(num):
  pn = 2 
  pflist = [] 
  while pn * pn <= num: 
    while num % pn == 0: 
      num = num / pn
      pflist.append(pn)
    pn += 1 
  if num > 1:
    pflist.append(int(num))
    
  return pflist

pf_A = getPrimeFactorsList(A)
pf_B = getPrimeFactorsList(B)
ans = len(set(pf_A) & set(pf_B)) + 1
print(ans)

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

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

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


A_yaku = []

now = 0

a = 2

while A >= a*a:
  if A%a == 0:
    if a != now:
      A_yaku.append(a)
      now = a
    A /= a
  else:
    a +=1

if A != now and A != 1:
  A_yaku.append(A)

B_yaku = []

now = 0

a = 2

while B >= a*a:
  if B%a == 0:
    if a != now:
      B_yaku.append(a)
      now = a
    B /= a
  else:
    a +=1

if B != now and B != 1:
  B_yaku.append(B)

count = 0

if(len(A_yaku) >= len(B_yaku)):
  for i in range(0,len(B_yaku)):
    if(B_yaku[i] in A_yaku):
      count += 1
else:
  for i in range(0,len(A_yaku)):
    if(A_yaku[i] in B_yaku):
      count += 1

count += 1

print(count)

Solution (Python):
def d_disjoint_set_of_common_divisors():
    from fractions import gcd
    A, B = [int(i) for i in input().split()]

    def prime_factorization_dict(n):
        """nを素因数分解したときの素数とその指数の辞書"""
        from collections import defaultdict
        if n == 1:
            return {2: 0}  
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table
    g = gcd(A, B)
    return len(prime_factorization_dict(g).keys()) + 1 if g > 1 else 1

print(d_disjoint_set_of_common_divisors())

Solution (Python):
import math
import sys

M=list(map(int,input().split()))


def prime(i):
  k=[]
  num=i
  j=2
  while j*j<=num:
    if i%j==0:
      i//=j
      k.append(j)
    else:
      j+=1
  if i!=1:
    k.append(i)
  k.append(1)
  return k

a=set(prime(M[0]))
b=set(prime(M[1]))
print(len(list(a&b)))

Solution (Python):
from collections import Counter
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

if __name__ == "__main__":
    A, B = list(map(int, input().split()))
    x = gcd(A, B)
    print(len(Counter(prime_factorize(x)).keys())+1)

Solution (Python):
x,y=map(int,input().split())
if x < y: x, y = y, x
while x % y != 0:
    x, y = y, x % y
ans=1
for i in range(2,int(y**0.5)+1):
    if y%i==0:
        ans+=1
        while y%i==0:
            y//=i
if y>1:ans+=1
print(ans)

Solution (Python):
import math

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


def prime_factorize(n):
    res = [] 
    tmp = n 

    for i in range(2, int(math.sqrt(n))+1):
        if tmp % i == 0:
            while tmp % i == 0:
                tmp //= i
            res.append(i)

    
    if tmp != 1:
        res.append(tmp)

    
    if res == [] and n != 1:
        res.append(n)

    return(res)

A_fac = set(prime_factorize(A))
B_fac = set(prime_factorize(B))

C = A_fac & B_fac
ans = len(C) + 1
print(ans)

Solution (Python):
from itertools import combinations
from fractions import gcd


import random

def is_prime3(q,k=50):
    q = abs(q)
    
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

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

a,b=map(int,input().split())
c=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)

    
    return divisors
s=make_divisors(c)
for i in s:
    ans=ans+is_prime3(i)
print(ans+1)

Solution (Python):


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 = list(map(int,input().split()))
soA = prime_factorize(A)
soB = prime_factorize(B)
output = []
for i in range(len(soA)):
    if soA[i] in soB:
        output.append(soA[i])

print(len(list(set(output))) + 1)

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

a,b=map(int,input().split())
x=gcd(a,b)
if(x==1):
    print(1)
    exit()
s=[]
i=2
while(i*i<=x):
    if(x%i==0):
        s.append(i)
        x/=i
    else:
        i+=1
s.append(x)
print(len(set(s))+1)

Solution (Python):

import sys
import math
import fractions
input = sys.stdin.readline


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


a, b = map(int, input().split())
x = fractions.gcd(a, b)
check_list = []
i = 2

while x % 2 == 0:
    check_list.append(2)
    x //= 2
i = 3
while i * i <= x:
    if x % i == 0:
        check_list.append(i)
        x //= i
    else:
        i += 2
if x != 1:
    check_list.append(x)

print(len(set(check_list))+1)

Solution (Python):
from sys import stdin

input = stdin.readline
mi = lambda: map(int, input().split())
lmi = lambda: list(mi())
si = lambda: input().strip('\a')
ii = lambda: int(input())


a, b = mi()
ap = set()
for i in range(2, int(a**.5) + 1):
    while a%i == 0:
        ap.add(i)
        a/=i
if a != 1:
    ap.add(a)

bp = set()
for i in range(2, int(b**.5) + 1):
    while b%i == 0:
        bp.add(i)
        b/=i
if b != 1:
    bp.add(b)

print(len(bp.intersection(ap))+1)

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


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


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(gcd(A, B)))) + 1)

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

for i in range(2, int(math.sqrt(g))+1):
  if g%i == 0:
    ans += 1
    while True:
      g //= i
      if g%i != 0:
        break
if (g != 1):
  ans += 1
print(ans)

Solution (Python):

import sys
import math
import fractions
input = sys.stdin.readline


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


a, b = map(int, input().split())
x = fractions.gcd(a, b)
check_list = []
i = 2
"""
while (1):
    flag = False
    if i > x:
        break
    while(x % i == 0):
        x /= i
        flag = True

    if flag == True:
        check_list.append(i)
    i += 1
"""
while x % 2 == 0:
    check_list.append(2)
    x //= 2
i = 3
while i * i <= x:
    if x % i == 0:
        check_list.append(i)
        x //= i
    else:
        i += 2
if x != 1:
    check_list.append(x)

print(len(set(check_list))+1)


"""
ans = 1
for check in check_list:
    if is_prime(check):
        ans += 1

print(ans)
"""

Solution (Python):
import fractions
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())
ans = fractions.gcd(A,B)
lists = []
cnt = 0
ansr = prime_factorize(ans)
print(len(set(ansr))+1)

Solution (Python):
import fractions

A,B = 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

g = fractions.gcd(A,B)

p = prime_factorize(g)
p = list(set(p))

print(len(p)+1)

Solution (Python):
from fractions import gcd
def f(n):
    tmp = n
    cnt = 0
    i = 2
    while i <= n**0.5 + 1:
        if tmp < i:
            break
        if tmp % i == 0:
            cnt += 1
            while tmp % i == 0:
                tmp //= i
        i += 1
    if tmp != 1:
        cnt += 1
    return cnt

A, B = map(int, input().split())
g = gcd(A, B)
ans = f(g) + 1
print(ans)

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)
            ass.append(n//i)
    return ass  




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


if __name__ == '__main__':
    ta, tb = map(int, input().split())

    
    if ta > tb:
        a = tb
        b = ta
    else:
        a = ta
        b = tb

    a_div_set = set(divisor(a))
    b_div_set = set(divisor(b))
    common_div_set = (a_div_set & b_div_set)

    answer = 0
    for e in common_div_set:
        if e == 1 or is_prime(e):
            answer += 1
    print(answer)

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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, 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(gcd(a,b))))+1)

Solution (Python):
import fractions as fra
a,b=map(int,input().split())
c=fra.gcd(a,b)
cnt=0
for i in range(2,int(c**0.5)+1):
    if(c%i==0):
        cnt+=1
        while(True):
            c//=i
            if(c%i != 0):
                break
if(c!=1):
    cnt+=1
print(cnt+1)

Solution (Python):
import fractions
A, B = map(int, input().split())
MAX = 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(MAX)))+1)

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


def gcd(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


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

Solution (Python):
n = list(map(int, input().split()))

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

def factorization(m):
    arr = [1]
    temp = m
    for i in range(2, int(-(-m**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(m)

    return arr

d = gcd(n[0],n[1])

c = factorization(d)


print(len(c))

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

if n==1:
  print(1)
  exit()
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(n))+1)

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

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())
gcd_AB = gcd(A, B)

p_list = prime_factorize(gcd_AB)

print(len(set(p_list))+1)

Solution (Python):
n, m = map(int, input().split())

while m:
    n, m = m, n % m

pf = {}
for i in range(2, int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i, 0)+1
        n //= i
if n > 1:
    pf[n] = 1

if pf == {}:
    print(1)
else:
    print(len(pf)+1)

Solution (Python):
import collections
import fractions

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 set(a)


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

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


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


def count_prime(n):
    i = 2
    primes = set()
    while i * i <= n:
        while n % i == 0:
            n /= i
            primes.add(i)
        i += 1
    if n > 1:
        primes.add(n)
    return len(primes)


print(count_prime(gcd(a, b)) + 1)

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

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


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(gcd(A, B)))) + 1)

Solution (Python):

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)

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

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

    return arr



a, b = map(int, input().split())
if a==1 and b==1:
    print(1)
else:
    
    prime_a = factorization(a)
    prime_b = factorization(b)
    
    print(1+len(set(prime_a)&set(prime_b)))

Solution (Python):
import math
import fractions

def is_one_or_prime(num):
    dest = int(math.sqrt(num))
    for i in range(2, dest+1):
        if num % i == 0:
            return False
    return True

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, b = map(int, input().split())
g = fractions.gcd(a, b)
l = make_divisors(g)
count = 0
for e in l:
  if is_one_or_prime(e):
    count += 1
print(count)

Solution (Python):
import math
ab = list(map(int,input().split()))
a = ab[0]
b = ab[1]
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
a_div = make_divisors(a)
b_div = make_divisors(b)

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
def primer(n):
    an = []
    for i in range(0,len(n)):
        if is_prime(n[i]) == True:
            an.append(n[i])
    return an
a_pri = primer(a_div)
b_pri = primer(b_div)
c =[]
for i in range(0,len(a_pri)):
    if b_pri.count(a_pri[i]) > 0:
        c.append(a_pri[i])
print(len(c))

Solution (Python):
def trial_divishion(n):
    factors = []

    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            factors.append(i)
            
    if n != 1:
        factors.append(n)
        
    return factors
    
a, b = map(int, input().split())
print(len(set(trial_divishion(a)) & set(trial_divishion(b))) + 1)

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


def prime_factorize(n):
    """Return the prime factorization of n > 1.
    >>> prime_factorize(36)
    [2, 2, 3, 3]
    """
    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


def main(a, b):
    pf_a = set(prime_factorize(a))
    pf_b = set(prime_factorize(b))
    return len(pf_a & pf_b) + 1


print(main(a, b))

Solution (Python):
a, b = map(int, input().split())
a, b = min(a, b), max(a, b)
cd = []
for i in range(1,int(a**0.5)+1):
    if a % i == 0:
        if b % i == 0:
            cd.append(i)
        if i != a // i and b % (a//i) == 0:
            cd.append(a//i)
ans = 1
for n in cd:
    prime = True
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            prime = False
            break
    if n == 1:
        prime = False
    if prime == True:
        ans += 1
print(ans)

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

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

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

g = fractions.gcd(A, B)

div = make_divisors(g)
ans = 1
for i in div:
    if is_prime(i):
        ans += 1
print(ans)