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 collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue


Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): 
    a,b = map(int,input().split())
    d = gcd(a,b)
    p = int(math.sqrt(d))+1
    div = []
    for i in range(1,p):
        if d%i==0:
            if d//i != i:
                div.append(i)
                div.append(d//i)
            else:
                div.append(i)
    div.sort()
    n = len(div)
    sgn = [1]*(n)
    if len(sgn) != 1:
        for i in range(1,len(sgn)):
            if sgn[i] == 1:
                for j in range(i+1,n):
                    if div[j]%div[i] == 0:
                        sgn[j] = 0
        res = []
        for i in range(n):
            if sgn[i] == 1:
                res.append(div[i])
        print(len(res))
    else:
        print(1)
if __name__ == "__main__":
    main()

Solution (Python):
import math

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

def get_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 sorted(divisors)[::-1]

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

gcd = get_gcd(a, b)
list = get_divisors(gcd)



count = 0
length = len(list)
for i in range(length):
    is_ok = True
  
    for j in range(i+1, length):
        if (get_gcd(list[i], list[j]) != 1):
            is_ok = False
            break
    
    if is_ok:
        count += 1

print(count)

Solution (Python):
import fractions


def div(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)

    return divisors
a,b=map(int,input().split())
x=div(a)
y=div(b)

z=list(x&y)
z.sort()
t=len(z)
ans=1
for i in range(1,t):
    f=1
    for j in range(1,i):
        if (z[i]%z[j]==0):
            f=0
            break
    if f:
        ans+=1
print(ans)

Solution (Python):
import math

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

def func(n):
    num=1
    for i in range(2,int(math.sqrt(n) + 1e-9) +3):
        if n%i==0 and n!=i:
            num=0
            break
        else:
            continue
    return num

p=min(A,B)
q=max(A,B)

ans=0
check=[]
for i in range(1, int(math.sqrt(p)+ 1e-9)+3):
    if p%i==0:
        if i not in check:
            check.append(i)
        if p//i not in check:
            check.append(p//i)

for i in check:
    if q%i==0:
        ans+=func(i)

print(ans)

Solution (Python):
import math

def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False
  
  
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 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

def main():
    A, B = [int(i) for i in input().split()]
    count = 0
    a = []
    prime = []
    if A > B:
        temp = A
        A = B
        B = temp
    a = make_divisors(A)
    
    for i in a:
        if isPrime(i) == True:
            prime.append(i)
    for i in prime:
        if B % i == 0:
            count += 1

    print(count)

if __name__ == "__main__":
    main()

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : map(int, stdin.readline().split())

def divi(n):
  res = []
  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

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

def main():
  a, b = sorted(na())
  x = divi(a)
  cnt = 1
  for bb in divi(b):
    if bb in x and isprime(bb):
      cnt += 1
  print(cnt)
main()

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

def gcd(x,y):
    while y:
        x,y = y, x%y
    return x

g = gcd(A,B)

count = 0
l = []

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

print(len(set(l))+1)

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

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 isPrime(n):
  if n <= 2:
    return True
  m = int((n**0.5)//1 + 1)
  for p in range(2, m):
      if n % p == 0:
        return False
  return True
    
a,b = map(int,input().split())
gcd = gcd(a,b)
yks = make_divisors(gcd)
ans = 0
for i in yks:
  if isPrime(i):
    ans +=1
print(ans)

Solution (Python):
import math
A, B = map(int,input().split())
A_cf = []
B_cf = []
for i in range(1,int(A**0.5)+1):
    if A % i == 0:
        A_cf.append(i)
        if i != A // i:
            A_cf.append(A//i)
for i in range(1,int(B**0.5)+1):
    if B % i == 0:
        B_cf.append(i)
        if i != B // i:
            B_cf.append(B//i)
DA = dict()
for i in range(len(A_cf)):
    DA[A_cf[i]] = False

for i in range(len(B_cf)):
    if B_cf[i] in DA:
        DA[B_cf[i]] = True
cf = []
for i in range(len(A_cf)):
    if DA[A_cf[i]]:
        if A_cf[i] % 2 == 0 and A_cf[i] != 2:
            continue
        cf.append(A_cf[i])
prime_num = []
cf.sort()

def isPrime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
for i in range(len(cf)):
    if isPrime(cf[i]):
        prime_num.append(cf[i])

ans = len(prime_num) + 1
print(ans)

Solution (Python):

import fractions
import math


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

    if flag:
        return n


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 main():
    a, b = map(int, input().split())
    coms = make_divisors(fractions.gcd(a, b))
    ans = [is_prime(i) for i in coms]
    ans2 = [a for a in ans if a is not None]
    print(len(ans2))


if __name__ == "__main__":
    main()

Solution (Python):
import fractions
import heapq
import itertools


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


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

cd = []
max_cd = fractions.gcd(A, B)

if max_cd == 1:
    cd.append(1)
else:
    heapq.heappush(cd, 1)

    f = [k[0] for k in factorize(max_cd)]
    for v in f:
        heapq.heappush(cd, v)

l = []

for i in range(0, len(cd)):
    c = heapq.heappop(cd)
    if not l:
        l.append(c)
    else:
        join = True
        for j in range(0, len(l)):
            k = l[j]
            if fractions.gcd(c, k) != 1:
                join = False
                break
        if join:
            l.append(c)

print(len(l))

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

import fractions

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

PF = prime_factorize(GCD)

PF = set(PF)

res = len(PF) + 1

print(res)

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

A_divs = make_divisors(A)
B_divs = make_divisors(B)

A_divs_len = len(B_divs)
B_divs_len = len(B_divs)
AB_divs = []

if A_divs_len >= B_divs_len:
    for v in B_divs:
        if v in A_divs:
            AB_divs.append(v)
        else:
            continue
else:
    for w in A_divs:
        if w in B_divs:
            AB_divs.append(w)

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

primes = []

for v in AB_divs:
    if is_prime(v):
        primes.append(v)

primes.insert(0, 1)
print(len(primes))

Solution (Python):
aa,bb = map(int,input().split())
n = min(aa,bb)
b = max(aa,bb)
ans = 1
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
         if temp%i==0:
                  cnt=0
                  while temp%i==0:
                           cnt+=1
                           temp //= i
                  arr.append(i)

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

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

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

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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
k=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(reverse=True)
    return divisors
m=make_divisors(k)
x=len(m)
n=len(m)

for _ in range(n-1):
  for i in range(1,len(m)):
    if gcd(m[i],m[0])!=1:
      x-=1
      m.pop(0)
      break
    if i+1 == len(m):
      m.pop(0)
      break
print(x)

Solution (Python):
import math

def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False
  
  
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 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

def main():
    A, B = [int(i) for i in input().split()]
    count = 0
    a = []
    prime = []
    if A > B:
        temp = A
        A = B
        B = temp
    a = make_divisors(A)
    
    for i in a:
        if isPrime(i) == True:
            prime.append(i)
    for i in prime:
        if B % i == 0:
            count += 1

    print(count)

if __name__ == "__main__":
    main()

Solution (Python):

import numpy as np 
import math


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


    return arr

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


print(len(factorization(x))+1)

Solution (Python):
AB = input().split(' ')
A = int(AB[0])
B = int(AB[1])
'''
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
                cf.append(i)
    return cf
 
def check_cf(x1,x2):
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            return False
    return True
candidate = cf(A,B)
'''
'''
decided_list = [candidate[0]]
 
for i in range(1,len(candidate)):
    flag = True
    for s in range(2,candidate[i]):
        if candidate[i]%s == 0:
            flag = False
            break
    if flag:
        decided_list.append(candidate[i])
'''

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 gcd(num1: int, num2: int) -> int:
    if num2 == 0:
        return num1
    else:
        return gcd(num2,num1%num2)
max_gcd = gcd(A,B)
result = factorization(max_gcd)

if len(result) == 1 and result[0][0] == 1:
    print(1)
else:
    print(len(result)+1)

Solution (Python):
import sys
readline = sys.stdin.readline
A,B = list(map(int, readline().split()))

def factorization(n):
    arr = [[1,1]]
    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 gdc(x,y):
    if y == 0:
        return x
    return gdc(y, x % y)

g = gdc(B,A)
res = factorization(g)

print(len(res))

Solution (Python):
import math
import fractions

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


l = []
x = fractions.gcd(a,b)
for i in range(1, x):
    if i ** 2 > x : break
    if x % i == 0:
        l.append(i)
        if i != x // i:
            l.append(x//i)

if l == []:
    l.append(1)


def isprime(x):
    if x <= 3:
        return True
    elif x % 2 == 0:
        return False
    else:
        i = 3
        while i <= math.sqrt(x):
            if x % i == 0:
                return False
            i = i +2
        return True

ans = []
for i in l:
    if isprime(i):
        ans.append(i)

print(len(ans))

Solution (Python):
import math


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

def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  
  
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True


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

    
    return divisors

a=set(make_divisors(a))
b=set(make_divisors(b))

cout=0
for i in a&b:
  if isPrime(i) == True:
    cout+=1

print(cout)

Solution (Python):
import fractions
A,B = map(int,input().split())
gcd = 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
prime_num = prime_factorize(gcd)
print(len(set(prime_num))+1)

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

xx = []
for n in [a, b]:
    x = []
    if n == 1:
        xx.append([n])
        continue

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

print(len(set(xx[0]) & set(xx[1])))

Solution (Python):
def get_gcd(x, y):
    if x < y:
        y, x = x, y

    while y > 0:
        r = x % y
        x = y
        y = r

    return x

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

a, b = map(int, input().split())
gcd = get_gcd(a, b)
common_divisors = prime_factorize(gcd)
print(len(set(common_divisors)) + 1)

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

yakusu=[]
ans=[]
bigger_val=max(A,B)
gcd_AB=gcd(A,B)

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

    
    return divisors

yakusu=sorted(make_divisors(gcd_AB))

for i in yakusu:
  if i==1:
    ans.append(i)
  else:
    if len(ans)==1:
      ans.append(i)
      
    else:
      flag=True
      for j in ans:
        if j>1:
          if gcd(i,j)==1:
            pass
          else:
            
            flag=False
      else:
        if flag==True:
          ans.append(i)
          
        







      


print(len(ans))

Solution (Python):
A, B=[int(i) for i in input().split()]
from copy import deepcopy as dp
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=make_divisors(A)
b=make_divisors(B)
a_b_and = list(set(a) & set(b))
l=dp(a_b_and)
ll=[]
for i in a_b_and:
    if i==1:continue
    for j in l:
        if j%i==0 and j!=i:
            ll.append(j)
    if len(ll)>0:
        for j in ll:
            if j in l:
                l.remove(j)
print(len(l))

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

import math

def tn(n):
  m=n
  factor=[]
  tmp=int(math.sqrt(n))+1
  for num in range(2,tmp):
    t=0
    while n%num==0:
      n//=num
      if t==0:
        factor.append(num)
        t=1
  if factor==[]:
    factor.append(m)
  factor.append(1)
  factor.append(n)
  return factor

listA=tn(A)
listB=tn(B)
anslist=set(listA) & set(listB)
ans=len(anslist)
print(ans)

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

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

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

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

ld=divisor(gcd(a,b))
ld.sort()



cnt=0

ansl=[]
for i in ld:
    flg=0
    for j in ansl:
        
        
        if gcd(i,j) !=1:
            flg = 1
            
            
            
            
            break
        
    if flg == 0:
        ansl.append(i)
    


print(len(ansl))

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

A_B_and = set(prime_factorize(A)) & set(prime_factorize(B))
print(len(A_B_and)+1)

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

glst = []
tmp = gcd(A, B)
for i in range(1, int(tmp ** 0.5) + 1):
    if tmp % i == 0:
        glst.append(i)
        if i != tmp // i:
            glst.append(tmp // i)

glst.sort()
cnt = 0
for i in range(1, len(glst) + 1):
    cntF = True
    for j in range(i + 1, len(glst) + 1):
        if gcd(glst[-i], glst[-j]) != 1:
            cntF = False
            break

    if cntF:
        cnt += 1

print(cnt)

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

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

def yakusuu(n, r):
  res = []
  i = 0
  while True:
    i += 1
    if i*i > n:
      break
    if (n % i) != 0:
      continue
    if i <= r:
      res.append(i)
    if (n/i) == i:
      continue
    if (n/i) <= r:
      res.append(int(n/i));
  return res;

ay = yakusuu(a, r)
by = yakusuu(b, r)
l = min(len(ay), len(by))
rlist = list(set(ay) & set(by))
rlist.sort()
ans = []
for i in range(len(rlist)):
  ok = True
  for j in ans:
    if gcd(rlist[i], j) != 1:
      ok = False
      break
  if ok:
    ans.append(rlist[i])
print(len(ans))

Solution (Python):
import fractions

A, B = list(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 = 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
import collections
import math

AB = list(map(int, input().split()))
A = AB[0]
B = AB[1]

GCM = fractions.gcd(A, B)

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

    divisors.sort()
    return divisors

def isPrime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    for p in range(2,n):
        if n % p == 0:
            return False
    return True

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 = collections.Counter(prime_factorize(GCM))
print(len(list(c.keys()))+1)

Solution (Python):
import fractions
import copy

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

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

la=calc_divisore(a)
lb=calc_divisore(b)
ll=sorted(list(set(la)&set(lb)))



ansl=[1]

ll_c=copy.copy(ll)

for i in ll_c:

    len_s=len(ll)
    ll=list(filter(lambda x: fractions.gcd(i,x)==1, ll))
    if len(ll)!=len_s:
        ansl.append(i)




print(len(ansl))

Solution (Python):
import fractions

A, B = map(int, input().split())
divisors = []
ans = 0
flag = 0
ans_list = []

myGCD = fractions.gcd(A, B)

for i in range(1, int(myGCD**0.5)+1):
  if myGCD % i == 0:
    divisors.append(i)
    if i != myGCD // i:
      divisors.append(myGCD//i)

divisors.sort()

for j, d in enumerate(divisors):
  for k in range(j):
    if fractions.gcd(d, divisors[k]) != 1:
      flag = 1
      break
    else:
      continue
  if flag != 1:
    ans += 1
  flag = 0

print(ans)

Solution (Python):
def euc(x,y):
  while x != y:
    if x > y:
      x -= y
    if x < y:
      y -= x
  return x

A,B = list(map(int, input().split()))
k = l = euc(A,B)
r = 1
s = 0
w = 1
while r**2 <= k:
  r += 1
  if k % r == 0:
    s += 1
    while k % r == 0:
      k /= r
    if k == 1:
      w = 0
s += w
if l != 1:
  s += 1
print(s)

Solution (Python):

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


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


Ps = primes(1000001)
Plen = len(Ps)
As = [0] * Plen
Bs = [0] * Plen
for i, p in enumerate(Ps):
    while A % p == 0:
        A = A // p
        As[i] += 1
    while B % p == 0:
        B = B // p
        Bs[i] += 1
ans = 1
if A > 1000001 and B > 1000001 and A == B:
    ans += 1
for _ in range(Plen):
    if As[_] != 0 and Bs[_] != 0:
        ans += 1
print(str(ans))

Solution (Python):
import math
def euclid(a,b):
    if b==0:
        return a
    else:
        return euclid(b,a%b)
def 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
z=list(map(int,input().split()))
print(len(set(factorize(euclid(z[0],z[1]))))+1)

Solution (Python):
import math
from fractions import gcd
A,B = (int(i) for i in 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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = gcd(A,B)
N_divisors = make_divisors(N)
prime_nums = []
for i in range(1,len(N_divisors)):
  if i == 1:
    prime_nums.append(N_divisors[i])
  else:
    for j in range(1,i):
      if N_divisors[i]%N_divisors[j] == 0:
        break
      if j == i-1:
        prime_nums.append(N_divisors[i])

ans = 1 + len(prime_nums)
print(ans)

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline


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

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

def main():
    """ main """
    A,B = map(int, input().split())
    ds = divisor(gcd(A,B))
    if len(ds) == 1:
        print(1)
        return 0
    ds = ds[1:]
    dp = [1]*len(ds)
    for i in range(len(ds)):
        if dp[i]:
            for j in range(i+1,len(ds)):
                if ds[j]%ds[i] == 0:
                    dp[j] = 0
    ans = 1
    for d in dp:
        if d == 1: ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def fatora(n):
	ans = []
	for i in range(1, n+1):
		if i*i > n:
			break
		else:
			if n % i == 0:
				ans.append(i)
				ans.append(n//i)
	return set(ans)

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


def eh_primo(n):
	if n == 0:
		return False
	elif n == 1:
		return True
	elif n == 2:
		return True
	else:
		for i in range(2, n+10):
			if i*i > n:
				break
			else:
				if n % i == 0:
					return False
		return True



a, b = map(int, input().split())
print(len(list(filter(eh_primo, fatora(gcd(a, b))))))

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


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

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

yaku = sorted(divisor(A) + divisor(B))
y_list = [x for x in set(yaku) if yaku.count(x) > 1]


for r in y_list:

    if is_prime(r):
        cnt += 1

print(cnt + 1)

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

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

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

    return arr
a = factorization(A)
b = factorization(B)
ans = len(set(a) & set(b))
print(ans)

Solution (Python):
import math

input = raw_input

def isprime(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(" "))

a = []
for i in range(1,int(math.sqrt(A))+1):
    if A % i == 0:
        a.append(i)
        if i != A / i:
            a.append(A/i)

b = []
for i in range(1,int(math.sqrt(B))+1):
    if B % i == 0:
        b.append(i)
        if i != B / i:
            b.append(B/i)
c = 0
for i in a:
    if i in b and isprime(i):
        c += 1
print(c)

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

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

import random

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
  
div=list(set(make_divisors(a))&set(make_divisors(b)))
n=len(div)
ans=0
for i in range(n):
  if is_prime(div[i]):
    ans+=1
print(ans+1)