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):
import sys
def divisor(a,b): 
  if a>b:
  	a,b = b,a
  i = 2
  table = []
  table2 = []
  table3 = []
  
  while i * i <= min(a**2,b):
    if a%i==0:
      table2.append(a//i)
      if b%i==0:
        table.append(i)
        table3.append(b//i)
    else:
      if b%i==0:
        table3.append(b//i)
    i += 1
    
  table2.append(a)
  table3.append(b)
  
  
  
  s_inter = set(table) | (set(table2) & set(table3))
  table = list(s_inter)
  return table

 
a,b = map(int, input().split())
if a==1 and b==1:
  print(1)
  sys.exit(0)
if a>b:
  a,b = b,a

ret = divisor(a,b)

if 2 in ret:
  ret = [2] + [t1 for t1 in ret if t1%2!=0]
elif 3 in ret:
  ret = [3] + [t1 for t1 in ret if t1%3!=0]
elif 5 in ret:
  ret = [5] + [t1 for t1 in ret if t1%5!=0]
elif 7 in ret:
  ret = [7] + [t1 for t1 in ret if t1%7!=0]
elif 11 in ret:
  ret = [11] + [t1 for t1 in ret if t1%11!=0]
elif 13 in ret:
  ret = [13] + [t1 for t1 in ret if t1%13!=0]

ret = [t1 for t1 in ret if sum([t1%t2==0 for t2 in ret])==1]

print(1+len(ret))

Solution (Python):
import math

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

def common_divisor(n):
  if n == 1:
    return [1]
  ret = []
  for i in range(1,math.ceil(math.sqrt(n))+1):
    if n%i==0:
      ret.append(i)
      ret.append(n//i)      
  return list(set(ret))

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

ca = common_divisor(a)
cb = common_divisor(b)

sa = set(ca)
c = sa.intersection(cb)

count = 1
for ci in c:
  if trial_division(ci):
    count+=1

print(count)

Solution (Python):
import math

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

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

	return gcd(b, a%b)


G = gcd(A,B)


def sosuhantei(n):
	d = math.floor(n**(1/2))
	cond = True
	for i in range(2,d+1):
		if n % i == 0:
			cond = False
			break
	return cond 


sosu = []
g = math.ceil(G**(1/2)) 

yaku = []

for i in range(1,g+1):
	if G % i == 0:
		yaku.append(i)
		yaku.append(G//i)

yaku = list(set(yaku))

cnt = 0
for i in range(len(yaku)):
	if sosuhantei(yaku[i]):
		cnt += 1

print(cnt)

Solution (Python):
import random

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

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

c = 1
m = gcd(a,b)

i = 1
while i * i <=m:
        if a%i == 0 and b%i == 0:
                if is_prime(i):
                        c+=1
                if is_prime(m//i):
                        c+=1
        i+=1
print(c)

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

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
    if n != 1:
        a.add(n)
    return a
s1 = prime_factorize(A)
s2 = prime_factorize(B)
s3 = s1 & s2
print(len(s3))

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

    
    return divisors
    
    
a, b = map(int,input().split())
a_d = make_divisors(a)
b_d = make_divisors(b)

yakusu = []

for i in a_d:
    if i in b_d:
        yakusu.append(i)

ans = [yakusu.pop(0)]
for i in yakusu:
    flg=0
    tmp = 0
    for j,num in enumerate(ans):
        if gcd(num,i) != 1:
            ans[j] = min(i,num)
            flg = 1
            break
    if flg == 0:
        ans.append(i)

print(len(ans))

Solution (Python):
def trial_divishion(n):
    factors = []
    while n % 2 == 0:
        factors.append(2)
        n //= 2
    
    f = 3
    while f * f <= n:
        if n % f == 0:
            factors.append(f)
            n //= f
        else:
            f += 2
            
    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):
import math


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


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


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

Solution (Python):
import math
def prime(n):
    set1 = set()
    while n % 2 == 0: 
        set1.add(2) 
        n = n / 2
    for i in range(3,int(math.sqrt(n))+1,2): 
        while n % i== 0: 
            set1.add(i)
            n = n / i 
    if n > 2: 
        set1.add(n)
    return set1

a,b = map(int, input().split())
ans1 = prime(a)
ans2 = prime(b)
ans3 = ans1.intersection(ans2)
print(len(ans3)+1)

Solution (Python):

import sys
import os

import math
import random


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 = [int(i) for i in input().split(' ')]


ap = list(set(prime_factorize(a)))
bp = list(set(prime_factorize(b)))



al = []
bl = []

al = ap
bl = bp






if len(al) == 0 or len(bl) == 0:
    print(1)
else:
    print(len(list(set(al) & set(bl))) + 1)

Solution (Python):
from math import sqrt
def gcd(a,b):
	if a==0:
		return(b)
	return(gcd(b%a,a))
a,b=map(int,input().split())
g=gcd(a,b)
ans=1
if g%2==0:
	ans+=1
	while(g%2==0):
		g//=2
for divide in range(3,int(sqrt(g))+1,2):
	if g%divide==0:
		ans+=1
		while(g%divide==0):
			g//=divide
if g>2:
	ans+=1
print(ans)

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

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

x = gcd(A, B)

res = 1
temp = x
for i in range(2, int(-(-x**0.5//1))+1):
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp //= i
        res += 1

if temp!=1:
    res += 1

print(res)

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

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

X = list(set(D))
print(len(X)+1)

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

a, b = map(int,input().split())
new_gcd = fractions.gcd(a, b)

new_a = a//new_gcd
new_b = b//new_gcd

tmp = make_divisors(new_gcd)
tmp = list(set(tmp))
tmp.sort()

new_tmp = []
for i in range(len(tmp)):
    flg = 0
    for j in range(1,len(tmp)-i):
        if tmp[-i]%tmp[j]==0:
            flg = 1
            break
    if flg == 0:
        new_tmp.append(tmp[-i])
        
print(len(new_tmp))

Solution (Python):
from fractions import gcd

def answer():
    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, b = map(int, input().split())
    g = gcd(a, b)
    divisors = make_divisors(g)

    length = len(divisors)
    removed = 1

    for i in range(1, length):
        d1 = divisors[i]
        for d2 in divisors[i:-1]:
            if d1 * d2 in divisors:
                divisors.remove(d1*d2)
                removed += 1
        if i + removed >= length:
            break

    print(length - removed + 1)


if __name__ == '__main__':
    answer()

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

def main():
    r = input().split()
    a = int(r[0])
    b = int(r[1])
    dd = set(make_divisors(a)) & set(make_divisors(b))
    dd = sorted(list(dd))
    res = 0
    
    for i in dd:
        if i == 1:
            res += 1
            continue
        else:
            flag = True
            for j in dd:
                if j == 1:
                    continue
                if j < i and i % j == 0:
                    flag = False
                    break
            if flag:
                res += 1
    print(res)

main()

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

def common_divisors(a, b):
    cd = []
    n = min(a, b)
    m = max(a, b)
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if m % i == 0:
                cd.append(i)
            if i != n // i and m % (n//i) == 0:
                cd.append(n//i)
    return cd

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

def sieve(n):
    prime = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i, n+1, i):
                is_prime[j] = False
    return prime


cd = common_divisors(A, B)


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





ans = 1 
for a in cd:
    if is_prime(a):
        ans += 1

print(ans)

Solution (Python):
from fractions import gcd
a, b = [int(i) for i in input().split(' ')]
gcd = gcd(a, b)

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

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

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

    return arr

if gcd == 1:
    print(1)
else:
    print(len(factorization(gcd)) + 1)

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


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


ans = 1

tmp = make_divisors(fractions.gcd(A, B))

for x in tmp:
    if is_prime(x):
        ans += 1

print(ans)

Solution (Python):
import fractions, math

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(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
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
  
A, B = map(int, input().split()) 
ans = set(make_divisors(A)) &  set(make_divisors(B))
print(sum([is_prime3(i) for i in ans])+1)

Solution (Python):

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

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

    
    return divisors

C = gcd(A,B)
E = make_divisors(C)
E.sort()

sosuu = []
ans = 0
for e in E:
    if e == 1:continue
    for s in sosuu:
        if e%s == 0:
            break
    else:
        sosuu.append(e)

print(len(sosuu)+1)

Solution (Python):
from fractions import gcd


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

a, b = map(int, input().split())
p = primes(10 ** 6 +1)
ans = 1
g = gcd(a, b)
for pp in p:
    f = False
    while g % pp == 0:
        g = (g // pp)
        f = True
    if f:
        ans += 1
if g > 1:
    ans += 1
print(ans)

Solution (Python):
from sys import stdin

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

while b != 0:
    a, b = b, a % b

c = 1
lim = a ** 0.5 + 2
n = 0
i = 2
while a > 1 and i <= lim:
    n = 0
    while a % i == 0:
        a //= i
        n += 1
    if n > 0:
        c += 1
    i += 1
if a > 1:
    c += 1

print(c)

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

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

    return arr

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

max_gcd = fractions.gcd(A,B)
list_n = factorization(max_gcd)
if list_n == [[1,1]]:
    print(len(list_n))
else:
    print(len(list_n) + 1)

Solution (Python):
import math

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(n):
    if n == 1: return True

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

    return True

A, B = map(int, input().split())
AY = make_divisors(A)
BY = make_divisors(B)
AB = set(AY) & set(BY)
AB = list(AB)
cnt = [i for i in range(len(AB)) if is_prime(AB[i])]
print(len(cnt))

Solution (Python):
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
  
a, b = map(int, input().split())
la = prime_decomposition(a)
lb = prime_decomposition(b)
la_lb_and = list(set(la) & set(lb))
    
print(len(la_lb_and) + 1)

Solution (Python):
from fractions import gcd
a,b=map(int,input().split())
c=gcd(a,b)
d=1
for i in range(2, int(-(-gcd(a,b)**0.5//1))+1):
  if c%i==0:
    d+=1
    while c%i==0:
      c//=i
  if c==1:
    break
if c!=1:
  d+=1
print(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:
            while temp%i==0:
                temp //= i
            arr.append(i)
    if temp!=1:
        arr.append(temp)

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

    return arr
aa=factorization(a)
bb=factorization(b)
n=len(aa)
ans=[]
if n>len(bb):
    n=len(bb)
    for i in range(n):
        if bb[i] in aa:
            ans.append(bb[i])
else:
    for i in range(n):
        if aa[i] in bb:
            ans.append(aa[i])
ans.append(1)
ans=set(ans)
print(len(ans))

Solution (Python):
from sys import stdin

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

while b != 0:
    a, b = b, a % b

c = 1
lim = a ** 0.5 + 10
n = 0
i = 2
while a > 1 and i <= lim:
    n = 0
    while a % i == 0:
        a //= i
        n += 1
    if n > 0:
        c += 1
    i += 1
if a > 1:
    c += 1

print(c)

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
c=set(prime_factorize(A))
d=set(prime_factorize(B))
ans=len(c.intersection(d))
print(ans+1)

Solution (Python):
a,s=map(int,input().split())
def c(d,f):
  if d==0:return f
  else:return c(f%d,d)
  
j=c(a,s)
if j==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(j))+1)

Solution (Python):
A,B = map(int,input().split())
import math
import fractions
def factorization(n):
    arr = []
    temp = n
    if n!=1:
      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 len(arr)
    else:
      return 0
print(factorization(fractions.gcd(A,B))+1)

Solution (Python):
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

a,b = inpl()

A = max(a,b)
B = min(a,b)

Alist =list()
i = 1
while i <= A/i :
    if A%i==0:
        Alist.append(i)
        Alist.append(A/i)
    i += 1
i=1
Blist =list()
while i <= B/i :
    if B%i==0:
        Blist.append(i)
        Blist.append(B/i)
    i += 1

Clist = list()
for i in range (len(Alist)):
    if Alist[i] in Blist:
        Clist.append(Alist[i])

Clist = list(set(Clist))
Clist.sort()

anslist = list()
for i in range(len(Clist)):
    if Clist[i]==1:
        anslist.append(Clist[i])
    elif len(anslist) == 1:
        anslist.append(Clist[i])
    elif len(anslist) >= 2:
        for j in range(1,len(anslist)):
            if Clist[i] % anslist[j] == 0:
                break
        else:
            anslist.append(Clist[i])

print(len(anslist))

Solution (Python):
import fractions
import heapq

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

cd = []
for i in range(1, int(gcd**0.5)+1):
    if gcd % i == 0:
        heapq.heappush(cd, i)
        i2 = gcd//i
        if i != i2:
            heapq.heappush(cd, i2)

heapq.heappop(cd)

ans = set()
for i in range(len(cd)):
    n = heapq.heappop(cd)
    for j in ans:
        if n % j == 0:
            break
    else:
        ans.add(n)

print(len(ans)+1)

Solution (Python):
from fractions import gcd
import collections

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

gcd = gcd(a, b)


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


c = collections.Counter(prime_factorize(gcd))
print(len(c.keys()) + 1)

Solution (Python):

import fractions

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

kouyaku = 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
import collections
c = collections.Counter(prime_factorize(kouyaku))
d =list(c.values())
print(len(d) +1)

Solution (Python):
import math
import fractions
import copy
def prime_factorize(n):
  d = {}
  f = 2
  while f * f <= n:
    if n % f == 0:
      n //= f
      if not f in d.keys():
        d[f] = 1
      else:
        d[f] += 1
    else:
      f += 1
  if n != 1:
    if not n in d.keys():
      d[n] = 1
    else:
      d[n] += 1 
  return d

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

Solution (Python):
from fractions import gcd
a,b=[int(i) for i in input().split()]
res=set()
x=gcd(a,b)
y=2
while y*y<=x:
  while x%y==0:
    res.add(y)
    x//=y
  y+=1
if x>1:
  res.add(x)
print(len(res)+1)

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)
    divisors.sort()
    return divisors

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


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

a_divsrs = set(make_divisors(a))
b_divsrs = set(make_divisors(b))




comm_divsrs = sorted(a_divsrs & b_divsrs)



ans = []
for i in range(len(comm_divsrs)):
    if not (comm_divsrs[i] % 2 == 0 and comm_divsrs[i] != 2):
        ans.append(comm_divsrs[i])



final_ans = ans[0:2]


"""
    ans[i] に対して、すべての ans[j] (j: range[1:i]) が gcd(ans[i], ans[j]) == 1
    ならば final_ans に追加。ひとつでも違えば追加しない
"""
for i in range(2, len(ans)):
    is_ok = True
    for j in range(1, i):
        if gcd(ans[i], ans[j]) != 1:
            is_ok = False
            break
    if is_ok:
        final_ans.append(ans[i])


print(len(final_ans))

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

A_divisors = make_divisors(A)
ans = 1
m = []
for d in A_divisors:
    if d == 1: continue
    if B%d==0:
        for mi in m:
            if d%mi == 0:
                break
        else:
            ans += 1
            m.append(d)
            continue
        
print(ans)

Solution (Python):
import math
A,B = map(int,input().split())
N = max(A,B)
prime = []

tA = A
tB = B
for i in range(2, math.ceil(N**0.5)+1):
    Aflag = False
    Bflag = False
    if tA%i==0:
        Aflag = True
        while tA%i==0:
            tA //= i
    if tB%i==0:
        Bflag = True
        while tB%i==0:
            tB //= i
    if Aflag == True and Bflag == True:
        prime.append(i)

if tA!=1 and tA == tB:
    prime.append(tA)


print(len(prime)+1)

Solution (Python):
from collections import defaultdict
A, B = map(int, input().split())
ls = defaultdict(int)
ans = 0
for i in range(1, max(int(A**0.5)+1, int(B**0.5)+1)):
  if A%i==0 and B%i==0:
    if ls[i]==0:
      ls[i]=1
      for n in range(2,int(i**0.5)+1):
        if i%n==0:
          break
      else:
        ans += 1
  if A%i==0:
    j = A//i
    if B%j!=0:
      continue
  elif B%i==0:
    j = B//i
    if A%j!=0:
      continue
  else:
    continue
  if ls[j]==0:
    ls[j] = 1
  else:
    continue
  for n in range(2,int(j**0.5)+1):
    if j%n==0:
      break
  else:
    ans += 1
print(ans)

Solution (Python):
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
def gcd( x, y ):
    while y != 0:
        x, y = y, x%y
    return x

def coprime(a, b):
    return gcd(a, b) == 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)

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




gcd_value = gcd(A , B)
cd = []
div = make_divisors(gcd_value)

for i in range(len(div)):
    if A % div[i] == 0 and B % div[i] == 0 and is_prime(div[i]):
        cd.append(div[i])
print(len(cd) + 1)

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

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

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

    return arr
lis = list(factorization(A))
counter = 0
for i in range(len(lis)):
  jud = B/lis[i][0]
  if jud.is_integer():
    counter += 1
if A == 1 or B == 1:
  print(1)
else:
  print(counter+1)

Solution (Python):
A,B = map(int,input().split())
C = []
D = []
def prime_factor(n):
  E = []
  for i in range(2, int(n ** 0.5) + 1):
    while n % i == 0:
      E.append(i)
      n = n // i
  if n != 1:
    E.append(n)
  return E
C = prime_factor(A)
D = prime_factor(B)
f = set(C) & set(D)
print(len(f)+1)

Solution (Python):
import fractions as fra
import math
a,b = map(int,input().split())
n = fra.gcd(a,b)
tmp = int(math.sqrt(n)) + 1
l = [1]
ans = 0
for i in range(2,tmp):
  while n % i == 0:
    n //= i
    if i not in l:
      l.append(i)
      ans += 1
if n not in l:
  ans += 1
  
print(ans+1)

Solution (Python):
aa, bb = map(int, input().split())
A = max(aa, bb)
B = min(aa, bb)


def get_max(a, b):
    while True:
        c = a % b
        if c == 0:
            return b
        a = b
        b = c


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


B = get_max(A, B)
factors = factorize(B)

if len(factors) == 0:
    print(1)
else:
    count = 1
    for i in range(0, len(factors) - 1):
        if factors[i] != factors[i + 1]:
            count += 1
    print(count + 1)

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

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

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

    if not arr:
        arr.add(n)

    return arr

if a == b == 1:
    print(1)
else:
    fa = factorization(a)
    fb = factorization(b)
    res = 1
    for n in fa:
        if n in fb:
            res += 1
    print(res)

Solution (Python):



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


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

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

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

ans = list()
a = divisor(A)
b = divisor(B)
d = a + b
l = list()
for i in set(d):
    if d.count(i) > 1:
        l.append(i)

if len(l) > 1:
    ans.append(l[0])
    for i in range(1, len(l)):
        if is_prime(l[i]):
            ans.append(l[i])
else:
    ans = l


print(len(ans))

Solution (Python):

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


A, B  = map(int, input().split())
ans =  fac(A) & fac(B)
print(len(ans))

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

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 = input().split()
 
A = int(A)
B = int(B)

gcd_num =gcd(A,B)

gcd_list = factorization(gcd_num)

t = len(gcd_list)
if gcd_list == [[1, 1]]:
  print(t)
else:
  print(t+1)

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

A,B = list(map(int,input().split()))
GCD = gcd(A,B)
CD = []
for i in range(1,int(GCD**(0.5))+1):
    if GCD % i == 0:
        CD.append(i)
        if not i == GCD//i:
            CD.append(GCD//i)
CD.sort()
ans = 1
tmp_idx = 0
CD.pop(0)
CD_old = CD[:]
while (len(CD_old)>0):
    tmp = CD_old.pop(0)
    CD_new = []
    for i in range(len(CD_old)):
        if not CD_old[i] % tmp == 0:
            CD_new.append(CD_old[i])
    ans += 1
    CD_old = CD_new
print(ans)