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

gcd = gcd(A, B)
divisors = make_divisors(gcd)

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

count = 0
for i in range(len(divisors)):
    if is_prime(divisors[i]):
        count += 1

print(count)

Solution (Python):
from fractions import *;g=gcd(*map(int,input().split()));c=i=1
while i*i<=g and g>1:
  i+=1;c+=g%i<1
  while g%i<1:g/=i
print(c+(g>1))

Solution (Python):
import math
import collections

def trial_division(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(int(n))
    return a
A, B= map(int,input().split())

Adev = list(collections.Counter(trial_division(A)).keys())
Bdev = list(collections.Counter(trial_division(B)).keys())
print(len(list(set(Adev) & set(Bdev)))+1)

Solution (Python):
def main():
    a, b = map(int, input().split())
    common_divisors = set(get_divisors(a)) & set(get_divisors(b))
    number_of_prime_common_divisor = sum([is_prime(i) for i in common_divisors])
    print(number_of_prime_common_divisor+1)

def get_divisors(n):
    out = []
    if n < 1:
        return out
    m = int(n**0.5)
    for i in range(1, m+1):
        if not n%i:
            out.append(i)
            if n != i**2:
                out.append(n//i)
    return out

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

if __name__ == "__main__":
    main()

Solution (Python):
from fractions import gcd
a, b = map(int, input().split())
work = gcd(a, b)
count = 1
for i in range(2, int(work**0.5)+1):
    flag = False
    while work%i == 0:
        work //= i
        if not flag:
            count += 1
        flag = True
if work > 2:
    count += 1
print(count)

Solution (Python):
from fractions import *
g=gcd(*map(int,input().split()))
c=i=1
while i*i<=g and g>1:
  i+=1; c+=g%i<1
  while g%i<1: g//=i
print(c+(g>1))

Solution (Python):
from fractions import *
g=gcd(*map(int,input().split()))
c=1
for i in range(2,int(g**.5)+1):
  if g<2: break
  if g%i<1: c+=1
  while g%i<1: g//=i
print(c+(g>1))

Solution (Python):
from fractions import *
a,b=map(int,input().split())
g=gcd(a,b)
l=[g]
for i in range(2,int(g**.5)+1):
  if g%i<1: l+=[i,g//i]
c=1
for i in sorted(l):
  if g<2: break
  if g%i<1: c+=1
  while g%i<1: g//=i
print(c)

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


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

    if n != 1:
        arr.add(n)

    if not arr:
        arr.add(n)

    arr.add(1)
    return arr


a = factorization(A)
b = factorization(B)
inter = a & b

print(len(inter))

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

def fctr1(n): 
    f = {}
    c = 0
    r = int(n ** 0.5)
    for i in range(2, r + 2):
        while n % i == 0:
            c += 1
            n = n // i
        if c != 0:
            f[i] = c
            c = 0
    if n != 1:
        f[n] = 1
    return f


a = fctr1(A)
b = fctr1(B)


cd_dic = {1: 1}
key_list = [1]

for k, v in a.items():
    if k in b:
        key_list.append(k)
        n = min(v, b[k])
        cd_dic[k] = n

print(len(cd_dic))

Solution (Python):
from fractions import gcd
from math import sqrt
A, B = map(int, input().split())
n = gcd(A,B)
ans = 0
i = 2
while i ** 2 <= n:
    if n%i == 0:
        ans += 1
        while n%i == 0:
            n //= i
    i += 1
if n > 1:
    ans += 1
print(ans+1)

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

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




def is_prime(num):
    if num == 2:
        return True
    if num < 2 or num % 2 == 0:
        return False
    sqrt_num = num ** 0.5
    i = 2
    while i <= sqrt_num:
        if num % i == 0:
            return False
        i += 1
    return True

def lc(n):
    l = set()
    i = 1
    while i ** 2 <= n:
        if n % i == 0:
            l.add(i)
            l.add(n // i)
        i += 1
    return l
A = lc(a)
B = lc(b)
LC = list(A & B)

primes = []
for n in LC:
    if n == 1:
        primes.append(n)
    elif is_prime(n):
        primes.append(n)
ans = len(primes)
print(ans)

Solution (Python):
from collections import defaultdict
from itertools import count


def prime_factors(n):
  counter = defaultdict(int)  
  for i in count(2):
    if i * i > n:
      break
    while n % i == 0:
      n //= i
      counter[i] += 1
  if n != 1:
    counter[n] = 1
  return counter


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

a = prime_factors(A)
b = prime_factors(B)

print(len({k for k in a} & {k for k in b}) + 1)

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

gcd = fractions.gcd(a,b)

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

ans = len(set(prime_factorize(gcd)))

print(ans+1)

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

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

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline


def calc_prime_factors(n):
    """Trial division"""
    factors = []
    
    while n % 2 == 0:
        factors.append(2)
        n //= 2
    
    f = 3
    while f ** 2 <= n:
        if n % f == 0:
            factors.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        factors.append(n)
    return Counter(factors).keys()


def main():
    A, B = map(int, input().split())

    A_keys = calc_prime_factors(A)
    B_keys = calc_prime_factors(B)
    ans = len(set(A_keys) & set(B_keys)) + 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') 
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(sys.stdin.readline()) 
def ifn(): return float(sys.stdin.readline()) 
def isn(): return sys.stdin.readline().split() 
def imn(): return map(int, sys.stdin.readline().split()) 
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) 
def fmn(): return map(float, sys.stdin.readline().split()) 
def iln(): return list(map(int, sys.stdin.readline().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, sys.stdin.readline().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(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 is_prime


def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0: continue
        ex = 0

        while (n % i == 0):
            ex += 1
            n //= i
        res.append((i, ex))
    if n != 1: res.append((n, 1))
    return res

A,B = imn()

pf = prime_factorize(gcd(A,B))

print(len(pf)+1)

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

a,b=map(int,input().split())
import collections
da = collections.Counter(factorize(a))
db = collections.Counter(factorize(b))
ans = 0
for num,cnt in da.items():
    if db[num]!=0:
        ans+=1
print(ans)

Solution (Python):
from fractions import gcd
from math import sqrt
a,s=map(int,input().split())
f=gcd(a,s)
ans=1
if f<=3:print(1+(f!=1));exit()
for i in range(2,int(sqrt(f))+1):

  if f%i==0:
    ans+=1
    while f%i==0:f//=i
print(ans+(f!=1))

Solution (Python):
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0 :
        a, b = b, a % b
    return a

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+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 == [] and n != 1:
        arr.append([n, 1])
    return arr

a, b = map(int, input().split())
gcd_ab = gcd(a, b)
print(len(factorization(gcd_ab)) + 1)

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


def prime_factorize(n):
    primelist=[]
    a=2
    while a*a<=n:
        if n%a!=0:
            a+=1
            continue
        ex=0
        while n%a==0:
            ex+=1
            n=n//a
        primelist.append([a,ex])
        a+=1
    if n!=1:
        primelist.append([n,1])
    return primelist

import fractions
g=fractions.gcd(a,b)

pfs=prime_factorize(g)

print(1+len(pfs))

Solution (Python):
A,B = map(int,input().split())
divA = []
divB = []

for i in range(2,int(A**0.5)+2):
    if A % i == 0:
        divA.append(i)
    while(A % i == 0):
        A = A//i
if A != 1:
    divA.append(A)

for i in range(2,int(B**0.5)+2):
    if B % i == 0:
        divB.append(i)
    while(B % i == 0):
        B = B//i
if B != 1:
    divB.append(B)

print(len(set(divA)&set(divB))+1)

Solution (Python):
A,B = map(int,input().split())
c = 1
t = int(max(A,B)**0.5)

for i in range(2,t+2):
    k = 0
    while(A % i == 0 and B % i == 0):
        k = 1
        A = A//i
        B = B//i
    c += k

for i in range(2,int(A**0.5)+2):
    while(A % i == 0):
        A = A//i

for i in range(2,int(B**0.5)+2):
    while(B % i == 0):
        B = B//i

if A == B and A > t:
    c += 1

print(c)

Solution (Python):
import fractions
A,B=map(int,input().split())
gcdlist=[]
pf={}
m=fractions.gcd(A,B)
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1

keys=list(pf.keys())
val=list(pf.values())
ans=1
for i in range(len(keys)):
    gcdlist.append([keys[i],val[i]])

print(len(gcdlist)+1)

Solution (Python):

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


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

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

print(len(set(prime_factor(gcd(a,b))))+1)

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

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

A=list(primes(a).keys())
B=list(primes(b).keys())
ans=1
for i in A:
    if i in B:
        ans+=1
print(ans)

Solution (Python):
def main():
    import fractions
    import math
    A, B = map(int, input().split())

    gcd = fractions.gcd(A, B)

    tmp = gcd
    ans = 1
    for i in range(2, int(-(-gcd**0.5//1))+1):
        if tmp % i == 0:
            ans += 1
            while(tmp % i == 0):
                tmp = tmp//i
    if tmp != 1:
        ans += 1
    print(ans)


main()

Solution (Python):
from collections import Counter

def euclid(x, y):
    r = x % y
    if r == 0:
        return y
    else:
        return euclid(y, r)

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())
if A > B:
    A, B = B, A
print(len(Counter(prime_factorize(euclid(A, B)))) + 1)

Solution (Python):
from fractions import gcd
def gen(x):
    i = 2
    while i * i <= x:
        yield i
        i += 1

def main():
    a,b = map(int,input().split())
    g = gcd(a,b)
    ans = 1
    for i in gen(g):
        if g % i == 0:
            ans += 1
            while(g % i == 0):g //= i
    if g != 1:ans += 1

    print(ans)
    

if __name__ == '__main__':
    main()

Solution (Python):
from fractions import gcd
def gen(x):
    i = 1
    while i * i <= x:
        yield i
        i += 1

def main():
    a,b = map(int,input().split())
    g = gcd(a,b)
    gl = []
    for i in gen(g):
        if (g % i) == 0:
            gl.append(i)
            gl.append(g // i)
    gl =set(gl)
    p = []
    for i in gl:
        b = True
        for j in gen(i):
            if j == 1:continue
            if (i % j) == 0:
                b = False
                break
        if b:
            p.append(i)
    
    print(len(p))
    

if __name__ == '__main__':
    main()

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

gcd=fractions.gcd(A,B)
count=1

for i in range(2,int(pow(gcd,1/2))+1):
    if gcd==1:
        break
    else:
        if gcd%i==0:
            count+=1
            while gcd%i==0:
                gcd//=i
if gcd!=1:
    count+=1
print(count)

Solution (Python):
from fractions import gcd
def gen(x):
    i = 1
    while i * i <= x:
        yield i
        i += 1

def main():
    a,b = map(int,input().split())
    g = gcd(a,b)
    gl = []
    for i in gen(g):
        if (g % i) == 0:
            gl.append(i)
            gl.append(g // i)
    gl =set(gl)
    p = []
    for i in gl:
        b = True
        for j in gen(i):
            if j == 1:continue
            if (i % j) == 0:
                b = False
                break
        if b:
            p.append(i)
    ans = 0
    for i in p:
        if i in p:ans+=1

    
    print(ans)
    

if __name__ == '__main__':
    main()

Solution (Python):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])

prime = [1]
for i in range(2, math.ceil(g**0.5)+1):
  while g % i == 0:
    g /= i
    prime.append(i)
prime.append(g)
print(len(set(prime)))

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

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

X = gcd(A, B)

ans_l = []
while X % 2 == 0:
    X //= 2
    ans_l.append(2)
f = 3
while f * f <= X:
    if X % f == 0:
        X //= f
        ans_l.append(f)
    else:
        f += 2
if X != 1:
    ans_l.append(X)

print(len(set(ans_l))+1)

Solution (Python):

a, b = map(int, input().split())
ans = 1
for i in range(2, 1000001):
	if a%i==0 and b%i==0: ans += 1
	while a%i==0: a //= i
	while b%i==0: b //= i
if (a!=1 and b!=1) and (a%b==0 or b%a==0): ans += 1
print(ans)

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

    def trial_division(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 set(divs)
    dA = trial_division(A)
    dB = trial_division(B)
    C = sorted(dA & dB)
    N = len(C)
    seen = [True]*(N)
    for i in range(1, N):
        for j in range(i+1, N):
            if seen[j] and C[j] % C[i] == 0:
                seen[j] = False
    print(seen.count(True))


if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def PrimeFactorization(x):
    def plist(x):
        if x < 2: return []
        if x & 1 == 0: return [2] + plist(x >> 1)
        for p in range(3, x + 1, 2):
            if x % p == 0: return [p] + plist(x // p)
            if p ** 2 > x: return [x]

    pl = plist(x)
    pp, ee = [], []
    for p in pl:
        if not pp or p != pp[-1]:
            pp += [p]
            ee += [0]
        ee[-1] += 1
    return [(p, e) for p, e in zip(pp, ee)]

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

def main():
    a,b=MI()
    g=gcd(a,b)
    pe=PrimeFactorization(g)
    print(len(pe)+1)

main()

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

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


def prime_factorization(n):
    res = []
    for i in range(2, int(pow(n, 0.5)) + 1):
        if n % i == 0:
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append([i, ex])
    if n != 1:
        res.append([n, 1])
    prime = []
    for p in res:
        for _ in range(p[1]):
            prime.append(p[0])
    return prime

n = gcd(a,b)
prime = set(prime_factorization(n))
print(len(prime) + 1)

Solution (Python):
from fractions import gcd
A,B = map(int,input().split())
g = gcd(A,B)

from collections import Counter
def factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d
f = factorize(g)
print(len(f) + 1)

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)

    divisors.sort()
    return divisors

l=make_divisors(a)
ll=[]

def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y


for x in l:
    if x==1:
        continue
    if b%x==0:
        ll.append(x)
ansl=[1]
for x in ll:
    f=1
    for y in ansl:
        if gcd(x,y)!=1:
            f=0
    if f:
        ansl.append(x)


print(len(set(ansl)))

Solution (Python):
from fractions import gcd

def prime_factor(n):
    factors = set()
    i = 2
    while i * i <= n:
        while n % i == 0:
            factors.add(i)
            n //= i
        i += 1
    if n != 1:
        factors.add(n)
    return factors

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().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


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 = inpl()
d = make_divisors(fractions.gcd(a,b))
res = 0
for i in d:
    if is_prime(i):
        res += 1
print(res+1)

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

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, b = map(int, input().split())
pa = set(pf(a))
pb = set(pf(b))
s = pa & pb
print(len(s) + 1)

Solution (Python):
def make_prime_factors_distinct(n: int) -> list:
    """自然数nの素因数(重複なし)を列挙したリストを出力する
    計算量: O(sqrt(N))
    入出力例: 156 -> [2, 3, 13]
    """
    prime_factors = []
    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            prime_factors.append(k)
            while n % k == 0:
                n = n // k
    if n != 1:
        prime_factors.append(n)
    return prime_factors


def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


a, b = map(int, input().split()) 
res = gcd(a, b)
print(len(make_prime_factors_distinct(res)) + 1)

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

def primeCount(N):
    R = int(N**(0.5)) + 1  
    primes = {}  
    n = N
    for num in range(2, R):
        primes[num] = 0
        while n % num == 0:
            n //= num
            primes[num] += 1
    if n > 1 :
        primes[n] = 1
    return { key : val for key, val in primes.items() if val > 0}  

primeA = primeCount(A)
ans = 1
prd = 1
for p in sorted(primeA.keys()):
    if B % p == 0 and prd % p != 0:
        prd *= p
        ans += 1
print(ans)

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

A, B = map(int, input().split())
X = gcd(A, B)
primes = []
while X % 2 == 0:
    primes.append(2)
    X //= 2
f = 3
while f * f <= X:
    if X % f == 0:
        primes.append(f)
        X //= f
    else:
        f += 2
if X != 1:
    primes.append(X)
print(len(set(primes))+1)

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

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

dlist = fctr1(a)

ans = 1
for i in range(len(dlist)):
    if b%dlist[i][0] == 0:
        ans += 1
print(ans)

Solution (Python):
import collections

x,y = 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
    
print(len(list(set(prime_factorize(x)) & set(prime_factorize(y)))) + 1)

Solution (Python):
import collections

x,y = 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


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

    limit = n ** 0.5
    for i in range(2 , n):
        if n % i == 0:
            return False
        if i >= limit: 
            return True
    print('err')

    

uoo = list(set(prime_factorize(x)) & set(prime_factorize(y)))


print(len(uoo) + 1)

Solution (Python):
def prime_factorize(n):
    ans = []
    for i in range(2, int(n ** (1 / 2)) + 1):
        while True:
            if not n % i == 0:
                break
            ans.append(i)
            n /= i
        if n == 1:
            break
    if n != 1:
        ans.append(int(n))
    return ans

a, b = map(int, input().split())
s = set(prime_factorize(a))
t = prime_factorize(b)
ans = 1
for i in s:
    if i in t:
        ans += 1
print(ans)

Solution (Python):
A,B=map(int,input().split())
ans=0
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
c=gcd(max(A,B),min(A,B))
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
div=divisor(c)
for i in range(len(div)):
    n=div[i]
    flag=1
    for i in range(2,n+1):
        if i*i>n:
            break
        if n%i==0:
            flag=0
            break
    if flag==1:
        ans+=1
print(ans)

Solution (Python):
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
    
def factorize(n):
    fct = []
    
    for i in range(2, int(n**0.5)+1):
        c = 0
        
        while n%i==0:
            n //= i
            c += 1
            
        if c>0:
            fct.append((i, c))
    
    if n>1:
        fct.append((n, 1))
    
    return fct

A, B = map(int, input().split())
G = gcd(A, B)
fct = factorize(G)
ans = 1+len(fct)

print(ans)

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

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

    return arr

primef_a = factorization(a)
primef_b = factorization(b)

primef_a = [i[0] for i in primef_a]
primef_b = [i[0] for i in primef_b]

common_prime = []

for i in primef_a:
    if i != 1:
        if i in primef_b:
            common_prime.append(i)

print(len(common_prime)+1)

Solution (Python):
import collections

def gcd(a,b):
  if a < b:
    a,b = b,a
  while a % b != 0:
    r = a % b
    a,b = b,r
  return 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

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

c = collections.Counter(prime_factorize(t))
print(len(c.keys())+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
from decimal import *


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 divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

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

    @staticmethod
    def is_prime(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


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    
    A, B = Scanner.map_int()
    A = Math.divisor(A)
    B = Math.divisor(B)
    ans = set(A) & set(B)
    print(sum(a == 1 or Math.is_prime(a) for a in ans))


if __name__ == "__main__":
    main()

Solution (Python):
from math import sqrt

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

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

def count_prime(n):
    
    if n == 1:
        return 0
    n_is_prime = True
    P = []
    for i in range(2,int(sqrt(n))+1):
        if n % i == 0:
            n_is_prime = False
            P.append(i)
            while n % i == 0:
                n //= i
    if n_is_prime:
        return 1
    elif n == 1:
        return len(P)
    else:
        
        return len(P)+1

g = gcd(A,B)
c_p = count_prime(g)
print(c_p+1)

Solution (Python):
import fractions
import math

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

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

d = fractions.gcd(a, b)

l = factorize(d)

print(len(l) + 1)

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

a, b = A, B
set_a = set([1])
set_b = set([1])

for n in range(2, int(A ** 0.5) + 1):
    if a % n == 0:
        set_a.add(n)
    while a % n == 0:
        a //= n

if a != 1:
    set_a.add(a)

for n in range(2, int(B ** 0.5) + 1):
    if b % n == 0:
        set_b.add(n)
    while b % n == 0:
        b //= n

if b != 1:
    set_b.add(b)

ans = len(set_a & set_b)
print(ans)