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):
    while a != 0:
        a, b = b % a, a
    return b


def pf(v):
    result = 1
    for i in range(2, v + 1):
        if v < i * i:
            if v > 1:
                result += 1
            break
        if v % i == 0:
            result += 1
        while v > 1 and v % i == 0:
            v //= i
    return result


a, b = list(map(int, input().split()))
print(pf(gcd(a, b)))

Solution (Python):
a,b=map(int,input().split())
c=1
for i in range(2,int(max(a**.5,b**.5))+2):
    if a%i==0==b%i:
        c+=1
    while a%i==0:
        a//=i
    while b%i==0:
        b//=i
if a==b!=1:
    c+=1
print(c)

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

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

a, b = [int(i) for i in input().split()]
ma = gcd(a, b)
st = set()
for i in range(1, int(math.sqrt(ma) + 1)):
	if ma % i == 0:
		flg = True
		for j in st:
			if gcd(i, j) != 1:
				if i < j:
					st.remove(j)
					st.add(i)
				flg = False
				break
		if flg:
			st.add(i)
		flg = True
		ii = ma // i
		for j in st:
			if gcd(ii, j) != 1:
				if ii < j:
					st.remove(j)
					st.add(ii)
				flg = False
				break
		if flg:
			st.add(ii)
print (len(st))

Solution (Python):




from collections import Counter 


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


A, B = [int(s) for s in input().split()]

prime_A = calc_prime_factor(A)
prime_B = calc_prime_factor(B)

print(len(list(set(Counter(prime_A).keys()) & set(Counter(prime_B).keys()))) + 1)

Solution (Python):
a, b = list(map(int, input().split(' ')))
def gcd(l, s):
  return l if s == 0 else gcd(s, l % s)

temp = gcd(a, b)

ans = 0
for i in range(2,1000000):
  if temp % i == 0:
    ans += 1
    while temp % i == 0:
      temp = temp // i
  if temp == 1:
    break
if temp != 1:
  ans += 1

print(ans+1)

Solution (Python):
a, b = map(int, input().split())
while a > 0:
    a, b = b % a, a
ret = 1
d = 2
while b >= d * d:
    if b % d == 0:
        ret += 1
        while b % d == 0:
            b //= d
    d += 1
if b > 1:
    ret += 1
print(ret)

Solution (Python):

"""
Created on Wed Jun  3 14:11:35 2020

@author: NEC-PCuser
"""
def gcd(a, b):
    
    if (a % b == 0):
        return b
    return gcd(b, a % b)

def factorize(num):
    i = 2
    factorize_list = []
    num_tmp = num
    while i * i <= num_tmp:
        count = 0
        if num % i == 0:
            while num % i == 0:
                count += 1
                num //= i
            factorize_list.append([i, count])
        i += 1
    if num != 1:
        factorize_list.append([num, 1])
    return factorize_list 
                


if __name__ == "__main__":
    A, B =  map(int, input().split())
    big_num = max(A, B)
    short_num = min(A, B)
    gcd_num = gcd(big_num, short_num)
    print(len(factorize(gcd_num)) + 1)

Solution (Python):
def pfact(n):
    d = {}
    while n % 2 == 0:
        d[2] = 1 if 2 not in d else d[2] + 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            d[f] = 1 if f not in d else d[f] + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = 1 if n not in d else d[n] + 1
    return d

a, b = map(int, input().split())
A = pfact(a)
B = pfact(b)
d = {}
ans = 1
for k in A.keys():
    if k in B:
        ans += 1
print(ans)

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

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return int(a*b/gcd(a,b))

g=gcd(a,b)
def prime_factorization(n):
    
    m=n
    ans = []
    p = 2

    while p<m**0.5:
        if n%p == 0:
            ans.append(p)
            while n%p==0:
                n /= p
        else:
            p += 1
            
    if n!=1:
        ans.append(int(n))
    
    return ans

l=prime_factorization(g)
print(len(l)+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())
C, D = prime_factorize(A), prime_factorize(B)
C.append(1)
D.append(1)
C = set(C)
D = set(D)
print(len(C & D))

Solution (Python):
from fractions import gcd


def prime_factorize(n):
    result = []
    if n % 2 == 0:
        t = 0
        while n % 2 == 0:
            n //= 2
            t += 1
        result.append((2, t))
    for i in range(3, int(n ** 0.5) + 1, 2):
        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):
from fractions import gcd


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


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

li = make_prime_factors2(gcd(a, b))
print(len(li) + 1)

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

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

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

def is_prime(num):
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if b > a:
    a, b = b, a
c = []
for i in range(1, int(math.sqrt(b))+1):
    if b%i == 0:
        k = b//i
        if a%k == 0:
            if is_prime(k):
                c.append(k)
        if a%i == 0:
            if is_prime(i):
                c.append(i)
print(len(set(c))+1)

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

def is_prime(num):
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if b > a:
    a, b = b, a
c = []
for i in range(1, int(math.sqrt(b))+1):
    if a%i == 0 and b%i == 0:
        if is_prime(i):
            c.append(i)
    k = b//i
    if a%k == 0:
        if is_prime(k):
            c.append(k)
print(len(set(c))+1)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush
from fractions import gcd

def solve():
    a, b = MI()

    g = gcd(a, b)

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

    fact = prime_factorization(g)
    print(len(fact) + 1)

if __name__ == '__main__':
    solve()

Solution (Python):
from fractions import gcd

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

gcd=gcd(a,b)
ab_gcd=gcd

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

print(len(set(f))+1)

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


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


def solve():
    A, B = map(int, input().split())
    ap = factorize(A)
    bp = factorize(B)
    ans = 1 + len(ap & bp)
    print(ans)


if __name__ == '__main__':
    solve()

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

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

print(len(prime_factor(g))+1)

Solution (Python):
def f(a,b):
    if b:return f(b,a%b)
    p=set()
    for i in range(2,int(a**0.5)+1):
        while True:
            if a%i==0:
                a//=i
                p.add(i)
            else:
                break
    if a!=1:
        return len(p)+2
    return len(p)+1
print(f(*map(int,input().split())))

Solution (Python):
from sys import stdin, setrecursionlimit


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


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 main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())

    g = gcd(a, b)

    ans = 0

    for i in range(1, int(g ** 0.5) + 1):
        if g % i == 0:
            if is_prime(i) or i == 1:
                ans += 1
            if is_prime(g // i) and i != g // i:
                ans += 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Solution (Python):
import fractions

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

l = sorted(list(set(make_divisors(A)) & set(make_divisors(B))))

i = 0
while i < len(l):
    v = l[i]
    if v == 1:
        i += 1
        continue
    l = l[0:i+1] + list(filter(lambda x: x % v != 0, l[i+1:]))

    i += 1
print(len(l))

Solution (Python):
import fractions

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

def make_divisors(n):
    lower_divisors = []
    upper_divisors = []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

l = sorted(list(set(make_divisors(A)) & set(make_divisors(B))))

i = 0
while i < len(l):
    v = l[i]
    if v == 1:
        i += 1
        continue
    l = l[0:i+1] + list(filter(lambda x: x % v != 0, l[i+1:]))

    i += 1
print(len(l))

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

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

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

    return arr


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

pa = factorization(a)
pb = factorization(b)

print(len(({1} | {x for x, y in pa}) & ({1} | {x for x, y in pb})))

Solution (Python):

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  
a,b = map(int,input().split())
a_list = make_divisors(a)
b_list = make_divisors(b)
a_b_and = set(a_list) & set(b_list)
a_b_and = list(a_b_and)


count = 1
for a_b in a_b_and:
  if is_prime(a_b) == True:
    count += 1
    
print(count)

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

a,b = list(map(int,input().split()))
c = gcd(a,b)
c0 = c
r = 2
lis = [1]
count = 1
while c != 1:
    if c%r == 0:
        c = c//r
        lis.append(r)
        r = 2
    else:
        r += 1
    if r > int(pow(c0,0.5))+1:
        lis.append(c)
        break
d = list(set(lis))
print(len(d))

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

s = set([i for i,k in factorization(a)])
t = set([i for i,k in factorization(b)])
if a==1 and b==1:
  print(1)
else:
  print(len(s&t)+1)

Solution (Python):
import fractions

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

g = fractions.gcd(A, B)

def prime_decompose(x):
    decomposed = []
    for i in range(2,int(pow(x,0.5))+1):
        while x % i == 0:
            x //= i
            decomposed.append(i)
    if x > 1:
        decomposed.append(x)
    return decomposed

g_dec = set(prime_decompose(g))
print(len(g_dec)+1)

Solution (Python):
import fractions

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

g = fractions.gcd(A, B)

def prime_decompose(x):
    decomposed = []
    for i in range(2,int(pow(x,0.5))+1):
        while x % i == 0:
            x //= i
            decomposed.append(i)
    if x > 1:
        decomposed.append(x)
    return decomposed

g_dec = set(prime_decompose(g))
print(len(g_dec)+1)

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

def prime_decompose(x):
    decomposed = []
    for i in range(2,int(pow(x,0.5))+1):
        while x % i == 0:
            x //= i
            decomposed.append(i)
    if x > 1:
        decomposed.append(x)
    return decomposed

A_dec = set(prime_decompose(A))
B_dec = set(prime_decompose(B))

ans = 1
for a in A_dec:
    if a in B_dec:
        ans += 1

print(ans)

Solution (Python):
a,b = [int(x) for x in input().split()]
import fractions
g = fractions.gcd(a,b)
ans = 1
mama = int(g ** (1/2))
flag = 0
for i in range(2,mama+2):
    while True:
        if g%i != 0:
            break
        else:
            g = g/i
            flag = 1
    if flag == 1:
        ans += 1
    flag = 0
if g != 1:
    ans += 1
print(ans)

Solution (Python):
import fractions

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

g = fractions.gcd(A, B)
d = []
p = []

for i in range(1,int(pow(g, 0.5))+1):
    if g % i == 0:
        d.append(i)
        if i != g//i:
           d.append(g//i)

for i in d:
    s = 0
    for j in range(1,int(pow(i, 0.5))+1):
        if i % j == 0:
            s += 1

    if s == 1:
        p.append(i)

print(len(p))

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)








a,b=n1()

from fractions import gcd
m=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

gcd_list=make_divisors(m)
if len(gcd_list)==1:
    print(1)
else:
    prime=[]
    for i in gcd_list[1:]:
        for j in prime:
            if i%j==0:
                break
        else:
            prime.append(i)
    print(len(prime)+1)

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)








a,b=n1()

from fractions import gcd
m=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

gcd_list=make_divisors(m)
if len(gcd_list)==1:
    print(1)
else:
    prime=[]
    for i in gcd_list[1:]:
        for j in prime:
            if i%j==0:
                break
        else:
            prime.append(i)
    print(len(prime)+1)

Solution (Python):
from fractions import gcd
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
print(len(set(prime_factorize(gcd(a, b)))) + 1)

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

a,b = map(int,input().split())
n = gcd(a,b)
k = n
s = set()
s.add(1)
for i in range(2,int(sqrt(n))+1):
  while n%i == 0:
    n = n//i
    s.add(i)
  if n == 1:
    break
s.add(n)
print(len(s))

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


def main():
    from fractions import gcd
    a, b = map(int, input().split())
    g = gcd(a, b)
    print(len(set(p(g))) + 1)


if __name__ == '__main__':
    main()

Solution (Python):
def c(n):
    b = 2
    f = set()
    while b * b <= n:
        while n % b == 0:
            n //= b
            f |= {b}
        b += 1
    if n > 1:
        f |= {n}
    return f
a, b = map(int, input().split())
print(len(c(a) & c(b)) + 1)

Solution (Python):

from fractions import gcd

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



g=gcd(a,b)

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(g)))+1)

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

from fractions import gcd

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

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

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

    return arr

if gcd(A,B)==1:
  temp = 0
else:
  temp = 1

print(len(factorization(gcd(A,B)))+temp)

Solution (Python):
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    A, B = ZZ()

    def bunkai(num):
        p = set()
        p.add(1)
        i = 2
        while i * i <= num:
            while num%i == 0:
                p.add(i)
                num //= i
            i += 1
        p.add(num)
        return p

    a = bunkai(A)
    b = bunkai(B)
    print(len(a & b))

    return

if __name__ == '__main__':
    main()

Solution (Python):
from fractions import gcd
import sys
a,b = map(int,input().split())
g = gcd(a,b)
ans = 1
if g % 2 == 0:
    ans += 1
    while g % 2 == 0:
        g //= 2
if g == 1:
    print(ans)
    sys.exit()
for i in range(3,int(g**(0.5))+2,2):
    if g % i == 0:
        ans += 1
        while g%i == 0:
            g //= i
    if g == 1:
        break
else:
    ans += 1
print(ans)

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

g = fractions.gcd(a, b)
gs = [1]

f = 2
if g % 2 == 0:
  gs.append(2)
while g % 2 == 0:
  g = g // 2
f = 3
while f * f <= g:
  if g % f == 0:
    gs.append(f)
  while g % f == 0:
    g = g // f
  f += 2
if g != 1:
  gs.append(g)
print(len(gs))

Solution (Python):
import math
A,B = map(int,input().split())
Anum=[]
Bnum=[]

for i in range(2,int(math.sqrt(A)+1)):
    while A % i ==0:
        A //= i
        if i not in Anum:
            Anum.append(i)
if A!=1:
    Anum.append(A)


for i in range(2,int(math.sqrt(B)+1)):
    while B % i ==0:
        B //= i
        if i not in Bnum:
            Bnum.append(i)
if B!=1:
    Bnum.append(B)

ABnum=set(Anum) & set(Bnum)
print(len(ABnum)+1)

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

print(len(set(prime_factorize(a))&set(prime_factorize(b)))+1)

Solution (Python):
from fractions import gcd

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

c = set(prime_factorize(g))
print(len(c)+1)

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


from fractions import gcd

g = gcd(a,b)

pf = {}

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

ans = 1 + len(pf.keys()) 

print(ans)

Solution (Python):
def factorization(n,m):
    temp = n
    temp2 = m
    cnt=1
    for i in range(2, int(-(-min(n,m)**0.5//1))+1):
        if temp%i==0:
            if temp2%i == 0:
                cnt += 1
                while temp2%i==0:
                    temp2 //= i
            while temp%i==0:
                temp //= i
        elif temp2%i == 0:
            while temp2%i==0:
                temp2 //= i

    if temp != 1 and temp2 != 1:
        if max(temp, temp2) % min(temp, temp2) == 0: cnt += 1

    return cnt

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

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

from itertools import combinations

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

gcd_n = gcd(a,b)



def div(num):
    l = [1]
    if(num==1):
        return [1]
    while(num%2==0):
        num //=2
        l.append(2)
    f = 3
    while(f*f<=num):
        if num%f==0:
            num //= f
            l.append(f)
        else:
            f += 2
    
    if num!=1:
        l.append(num)
    return l

l = div(gcd_n)
cnt = 0
pre = 0
for i in range(len(l)):
    if pre==l[i]:
        continue
    pre = l[i]
    cnt += 1
print(cnt)

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


def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)


def lcm(x, y):
    return (x * y) // gcd(x, y)


def prime_numbers(n):
    if n < 2:
        return [1]
    primes = []
    for p in range(2, int(pow(n, 0.5)) + 1):
        if p * p > n:
            break
        while n % p == 0:
            primes.append(p)
            n //= p
    if n > 1:
        primes.append(n)
    return primes


def m():
    a, b = map(int, input().split())
    x = gcd(a, b)
    p = prime_numbers(x)
    p.append(1)

    return len((set(p)))


print(m())

Solution (Python):

import fractions

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f**2 <= 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())
    C = fractions.gcd(A,B)
    if C == 1:
        print(1)
    else:
        ans = prime_factorize(C)
        print(len(set(ans)) + 1)


if __name__ == "__main__":
    main()

Solution (Python):
def prime_factorization(n):
    P = set()
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            P.add(i)
        i += 1
    if n > 1:
        P.add(n)

    return P

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

Solution (Python):
from fractions import gcd

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

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

g = gcd(A, B)

print(len(set(prime_decomposition(g)))+1)

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

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

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
L = make_divisors(a)
cv=[]
for i in range(len(L)):
	if b % L[i] == 0:
		cv.append(L[i])
cnt=1
cv=set(cv)
for d in cv:
	if is_prime(d):
		cnt+=1
print(cnt)

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

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

print(len(set(prime_factorize(fractions.gcd(a,b))))+1)

Solution (Python):

import math

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

def f(n):
  p_lis = []
  temp = n

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

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

  return p_lis

ans = set(f(A)) & set(f(B))
ans.add(1)

print(len(ans))

Solution (Python):
from itertools import chain

from math import sqrt
from collections import Counter

def prime_factorization(n):
    counter = Counter()
    for i in range(2, int(sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            counter[i] += 1
    
    if n != 1:
        counter[n] += 1

    return counter.items()

def get_prime_facts(n):
    return set(map(lambda x: x[0], prime_factorization(n)))

def solution(A, B):
    s = get_prime_facts(A) & get_prime_facts(B) | {1}
    return len(s)

if __name__ == '__main__': 
    A, B = map(int, input().split())
    a = solution(A, B)

    print(a)

Solution (Python):


from itertools import chain
from math import ceil




















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

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

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

    return arr

def get_prime_facts(n):
    return set(map(lambda x: x[0], factorization(n)))

def solution(A, B):
    s = get_prime_facts(A) & get_prime_facts(B) | {1}

    return len(s)

if __name__ == '__main__': 
    A, B = map(int, input().split())
    a = solution(A, B)

    print(a)

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

a = set(prime_factorize(A))
b = set(prime_factorize(B))

ans = 1
for i in b:
  if i in a:
    ans += 1
    
print(ans)

Solution (Python):
from fractions import gcd
 
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
 
a,b = map(int,input().split())
 
x = gcd(a,b)
 
ans = len(factorization(x))+1
if factorization(x) == [[1,1]]:
  ans -= 1
print(ans)

Solution (Python):
from fractions import gcd

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

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

x = gcd(a,b)

ans = len(factorization(x))+1
if factorization(x) == [[1,1]]:
  ans -= 1
print(ans)

Solution (Python):
import fractions
A,B=map(int,input().split())
A,B=min(A,B),max(A,B)
g=fractions.gcd(A,B)
ans=1
for i in range(2,int(g**0.5+1)):
  if g%i==0:
    ans+=1
    while g%i==0:
      g/=i
    if g==1:
      break
if g!=1:
  ans+=1
print(ans)