Problem:
 Score : 400 points    Problem Statement Given are positive integers A and B .  Let us choose some number of positive common divisors of A and B .  Here, any two of the chosen divisors must be coprime.  At most, how many divisors can we choose?  Definition of common divisor  An integer d is said to be a common divisor of integers x and y when d divides both x and y .   Definition of being coprime  Integers x and y are said to be coprime when x and y have no positive common divisors other than 1 .   Definition of dividing  An integer x is said to divide another integer y when there exists an integer \alpha such that y = \alpha x .       Constraints  All values in input are integers.  1 \leq A, B \leq 10^{12}         Input Input is given from Standard Input in the following format:  A  B       Output Print the maximum number of divisors that can be chosen to satisfy the condition.        Sample Input 1 12 18      Sample Output 1 3  12 and 18 have the following positive common divisors: 1 , 2 , 3 , and 6 .  1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1 , 2 , and 3 , which achieve the maximum result.       Sample Input 2 420 660      Sample Output 2 4       Sample Input 3 1 2019      Sample Output 3 1  1 and 2019 have no positive common divisors other than 1 .

Solution (Python):
from fractions import gcd
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == [] and n != 1:
        arr.append([n, 1])
    return arr

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

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

from fractions import gcd
from collections import Counter






gcd_ab = gcd(a, b)
if gcd_ab == 1:
    print(1)
    exit()

def get_divisor(n):
    divisor = Counter()
    while n % 2 == 0:
        divisor[2] += 1
        n //= 2
        
    i = 3
    while i*i <= n:
        while n % i == 0:
            divisor[i] += 1
            n //= i
        i += 2
    if n > 1:
        divisor[n] += 1
    return divisor

divisor = get_divisor(gcd_ab)
print(len(divisor)+1)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd

import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b = Is()

def factorization(n):
    arr = []
    tmp = n
    for i in range(2, int(floor(sqrt(n)))+1):
        if tmp % i == 0:
            count = 0
            while tmp % i == 0:
                count += 1
                tmp //= i
            arr.append([i, count])

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

    return arr


g = gcd(a, b)
A = factorization(g)
print(len(A)+1)

Solution (Python):
import string
import collections
a_prime=[]
b_prime=[]
a,b = map(int, input().split())
def getPrime(a):
  prime=[]
  for i in range(2,int(a**0.5//1)+1):
    if a%i==0:
      while a%i == 0:
        a=a//i
      prime+=[i]
  if a!=1:
    prime.append(a)

  return prime
a_prime=getPrime(a)
b_prime=getPrime(b)
print(len(set(a_prime) & set(b_prime))+1)

Solution (Python):
import sys
from fractions import gcd
from collections import Counter


def prime_factorization(n):
    """nを素因数分解する

    Return d(dict):
        素因数をキー、素因数の指数部を値とするディクショナリを返す

    Example:
        n=140 -> d = {2: 2, 5: 1, 7: 1}
    """
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m = m + 1 if m == 2 else m + 2  

    if n > 1:
        d[n] += 1
    return d


def solve():
    A, B = list(map(int, sys.stdin.readline().split()))
    cd = gcd(A, B)

    if cd == 1:  
        print(1)
        return

    
    prime_d = prime_factorization(cd)
    print(len(prime_d)+1)


if __name__ == "__main__":
    solve()

Solution (Python):
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(int(n))
  return table

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

print(len(a&b)+1)

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

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

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

gcdAB = gcd(A, B)
pf = prime_factorize(gcdAB)

print(len(pf)+1)

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

input = sys.stdin.readline

def prime(n):
    primes = {}
    bound = int(math.sqrt(n)) + 1
    for i in range(2, bound):
        while n % i == 0:
            n //= i
            if not i in primes.keys():
                primes[i] = 1
            else:
                primes[i] += 1
    if n != 1:
        if n not in primes.keys():
            primes[n] = 1
        else:
            primes[n] += 1
    return primes

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

Solution (Python):
inf = 10**15
mod = 10**9+7
a,b = map(int, input().split())
import fractions

f=fractions.gcd(a,b)           

def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    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

arr = factorization(f)
print(len(arr)+1)

Solution (Python):
'''ベスパリブ  takeg
（gcd(A, B)を素因数分解したときの素因数の個数）+1が答え。
入力例2。「420と660の正の公約数の中から、いくつか約数を選んで、
選んだやつの、どの異なる2つの整数も互いに素となる最大の約数の
個数は何か？」という問題。
420と660の正の公約数は、必ず最大公約数以下の値。
よって約数のとりうる範囲は1 ~ 最大公約数。
420と660 の最大公約数gcd(420, 660)は60。60の約数を列挙。
1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60
このうち、どの2つの整数も互いに素となる約数の個数が最大となる選び方は、
1, 2, 3, 5 の4つ。
60の約数	1	2	3	4	5	6	10	12	15	20	30	60
答え	     1	 2   3		 5							
たとえば15はなぜいけないのでしょうか？それは15を素因数分解すると
15=3^1∗5^1 なので、15を選ぶと3と5が選べなくなってしまいます。 
よって15を選ぶより3と5を選んだほうが多くを選べるということ。
12や20なんかも同様の理由で選べません。
4はどうでしょうか？これは素因数分解すると4=2^2になります。
つまり4を選ぶと2を選べなくなります。この2を選ばないパターンの
1 3 4 5は、どの2つの整数も互いに素となっているのでOKです。
よって2の代わりに4を選ぶのはありですが、選ぶメリットは特にない。
素数しか選ばないというルールのほうが問題を簡単化できます。
ということで入力例2の場合では、gcd(420, 660)で最大公約数を求めて、
その最大公約数を素因数分解したときの素因数を選べば、
どの2つの整数も互いに素となります。あとついでに1も約数なので
これも加えます。これが答えになります。
制約A,B≦10^12を考えます。Nがでかすぎるので、O(N)の解法はTLE。
この問題におけるNとは、AとBの最大公約数gcd(A, B)の値です。
1～gcd(A, B)の範囲で素因数を数えることになります。
gcd(A, B)の最大値は10^12なので、O(N)は無理です。
ですが実は、最大公約数Nが何かの整数pで割り切れるときは、
N=p∗q と書けますので、p≦√N(例：N=10^12 のとき、p=10^6、q=10^6)。
なのでNまで調べる必要はなく、O(√N)で解くことができます。
コーナーケース:最大公約数が1のとき、1を出力して終了
'''
import sys
from fractions import gcd
from collections import Counter

def prime_factorization(n):
    """nを素因数分解する
    Return d(dict):
        素因数をキー、素因数の指数部を値とするディクショナリを返す
    Example:
        n=140 -> d = {2: 2, 5: 1, 7: 1}
    """
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m = m + 1 if m == 2 else m + 2  
        

    if n > 1:
        d[n] += 1
    return d

def solve():
    A, B = list(map(int, sys.stdin.readline().split()))
    cd = gcd(A, B)

    if cd == 1:  
        print(1)
        return

    
    prime_d = prime_factorization(cd)
    print(len(prime_d)+1)

if __name__ == "__main__":
    solve()

Solution (Python):
'''
（gcd(A, B)を素因数分解したときの素因数の個数）+1が答え。
入力例2を考えます。
「420と660の正の公約数の中からいくつか約数を選んで、
選んだやつのどの異なる2つの整数も互いに素となる最大の約数の個数は何か？」
という問題になります。
420と660の正の公約数は、必ず最大公約数以下の値になります。
よって約数のとりうる範囲は1 ~ 最大公約数になります。
420と660 の最大公約数gcd(420, 660)は60です。
60の約数を列挙してみます。
1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60
このうち、どの2つの整数も互いに素となる約数の個数が最大となる選び方は、
1, 2, 3, 5 の4つです。見やすく表にして整理すると、
60の約数	1	2	3	4	5	6	10	12	15	20	30	60
答え	     1	 2   3		 5							
たとえば15はなぜいけないのでしょうか？それは15を素因数分解すると
15=3^1∗5^1 なので、15を選ぶと3と5が選べなくなってしまいます。 
よって15を選ぶより3と5を選んだほうが多くを選べるということになります。
12や20なんかも同様の理由で選べません。
4はどうでしょうか？これは素因数分解すると4=2^2になります。
つまり4を選ぶと2を選べなくなります。この2を選ばないパターンの
1 3 4 5は、どの2つの整数も互いに素となっているのでOKです。
よって2の代わりに4を選ぶのはありですが、選ぶメリットは特にない。
素数しか選ばないというルールのほうが問題を簡単化できます。
ということで入力例2の場合では、gcd(420, 660)で最大公約数を求めて、
その最大公約数を素因数分解したときの素因数を選べば、
どの2つの整数も互いに素となります。あとついでに1も約数なので
これも加えます。これが答えになります。
制約A,B≦10^12を考えます。Nがでかすぎるので、O(N)の解法はTLEします。
この問題におけるNとは、AとBの最大公約数gcd(A, B)の値です。
1～gcd(A, B)の範囲で素因数を数えることになります。
gcd(A, B)の最大値は10^12なので、O(N)は無理です。
ですが実は、最大公約数Nが何かの整数pで割り切れるときは、
N=p∗q と書けますので、p≦√Nとなります.
（例：N=10^12 のとき、p=10^6、q=10^6 ）。
なのでNまで調べる必要はなく、O(√N)で解くことができます。
コーナーケース:最大公約数が1のとき、1を出力して終了
'''
import sys
from fractions import gcd
from collections import Counter

def prime_factorization(n):
    """nを素因数分解する
    Return d(dict):
        素因数をキー、素因数の指数部を値とするディクショナリを返す
    Example:
        n=140 -> d = {2: 2, 5: 1, 7: 1}
    """
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m = m + 1 if m == 2 else m + 2  
        

    if n > 1:
        d[n] += 1
    return d

def solve():
    A, B = list(map(int, sys.stdin.readline().split()))
    cd = gcd(A, B)

    if cd == 1:  
        print(1)
        return

    
    prime_d = prime_factorization(cd)
    print(len(prime_d)+1)

if __name__ == "__main__":
    solve()

Solution (Python):
import collections
import math

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


smaller = min(A, B)
larger = max(A, B)

max_cd = 1
for i in range(1, int(math.sqrt(smaller))+1):
    if smaller % i == 0:
        if larger % i == 0:
            max_cd = i
        if larger % (smaller // i) == 0:
            max_cd = smaller // i
            break




c = collections.Counter()
i = 2
while i*i <= max_cd:
    if max_cd % i == 0:
        max_cd = max_cd // i
        c[i] += 1
    else:
        i += 1

if max_cd != 1:
    c[max_cd] += 1


ans = len(c.keys()) + 1
print(ans)

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    a, b = MII()
    a_f = set(prime_factor(a))
    b_f = set(prime_factor(b))
    a_f.add(1)
    b_f.add(1)
    c = a_f & b_f
    print(len(c))

if __name__ == '__main__':
    main()

Solution (Python):


import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

def prime_factorize(N):
    res = []
    for i in range(2, int(math.sqrt(N)) + 1):
        if N % i != 0:
            continue

        num = 0
        while N % i == 0:
            N //= i
            num += 1
        
        res.append([i, num])

    if N != 1:
        res.append([N, 1])

    return res

A, B = LI()

g = gcd(A, B)
pf = prime_factorize(g)

print(len(pf) + 1)

Solution (Python):
import fractions
import math
import sys
def input(): return sys.stdin.readline().strip()


def resolve():
    a, b = map(int, input().split())
    m = fractions.gcd(a, b)

    

    def make_prime_list_2(num):
        if num < 2:
            return []

        
        prime_list = [i for i in range(num + 1)]
        prime_list[1] = 0  
        num_sqrt = math.sqrt(num)

        for prime in prime_list:
            if prime == 0:
                continue
            if prime > num_sqrt:
                break

            for non_prime in range(2 * prime, num, prime):
                prime_list[non_prime] = 0

        return [prime for prime in prime_list if prime != 0]

    def prime_factorization_2(num):
        """numの素因数分解
        素因数をkeyに乗数をvalueに格納した辞書型dict_counterを返す"""

        if num <= 1:
            
            
            return False
        else:
            num_sqrt = math.floor(math.sqrt(num))
            prime_list = make_prime_list_2(num_sqrt)
            dict_counter={}
            
            

            for prime in prime_list:
                while num % prime == 0:
                    if prime in dict_counter:
                        dict_counter[prime] += 1
                    else:
                        dict_counter[prime] = 1
                    num //= prime
            if num != 1:
                if num in dict_counter:
                    dict_counter[num] += 1
                else:
                    dict_counter[num] = 1

            return dict_counter
    if m==1:
        print(1)
    else:
        d=prime_factorization_2(m)
        print(len(d)+1)


resolve()

Solution (Python):

import sys
from fractions import gcd
from collections import Counter
def prime_factorization(n):
    """nを素因数分解する
    Return d(dict):
        素因数をキー、素因数の指数部を値とするディクショナリを返す
    Example:
        n=140 -> d = {2: 2, 5: 1, 7: 1}
    """
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m = m + 1 if m == 2 else m + 2  
    if n > 1:
        d[n] += 1
    return d

def solve():
    A, B = list(map(int, sys.stdin.readline().split()))
    cd = gcd(A, B)
    if cd == 1:  
        print(1)
        return
    
    prime_d = prime_factorization(cd)
    print(len(prime_d)+1)
if __name__ == "__main__":
    solve()

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

prime_count = Counter()
for i in range(2, math.ceil(math.sqrt(C))+1):
  while C % i == 0:
    C /= i
    prime_count[i] += 1
if C > 1:
  prime_count[int(C)] += 1

print(len(prime_count)+1)

Solution (Python):
def factorization(n):
    s = set()
    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
            s.add(i)

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

    if len(s) == 0:
        s.add(n)

    return s


A, B = map(int, input().split())
mini = min(A, B)
maxi = max(A, B)

ss = factorization(mini)

res = 1
for i in ss:
    if maxi % i == 0:
        res += 1

if mini == 1:
    res = 1

print(res)

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

"""素因数分解"""
def factorization(n):
    array = [[1,1]]
    temp = n
    for i in range(2, int(math.sqrt(n))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            array.append([i, cnt])

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

    return array

factorization_array = factorization(gcd)
print(len(factorization_array))

Solution (Python):
from fractions import gcd

if __name__ == '__main__':
    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())
    facts = factorize(gcd(a, b))
    print(len(facts) + 1)

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

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

A_s = set(prime_factor(A))
B_s = set(prime_factor(B))

from fractions import gcd

print(len(A_s&B_s)+1)

Solution (Python):
from fractions import gcd  
from collections import defaultdict


def prime_factorization(x):
    res = defaultdict(int)
    n = 2
    while n**2 <= x:
        while x % n == 0:
            res[n] += 1
            x //= n
        n += 1
    if x != 1:
        res[x] += 1
    return res


def main():
    A, B = list(map(int, input().split(' ')))
    gcd_ab = gcd(A, B)
    pf = prime_factorization(gcd_ab)
    print(1 + len(pf.keys()))  


if __name__ == '__main__':
    main()

Solution (Python):
import fractions
import math 
def trial_division(n):
    
    factor = [1]
    
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    
    if not factor:
        return [1, n]
    else:
        factor.append(n)
        return factor

A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
N = len(set(trial_division(gcd)))
print(N)

Solution (Python):
def main():
    a, b = map(int, input().split())
    x = gcd(a, b)
    ans = prime_factorize(x)
    print(len(set(ans)) + 1)


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


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


if __name__ == '__main__':
    main()

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


def primes(n):
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1, int(n**0.5)//3+1):
        if sieve[i]:
            k = 3*i+1|1
            sieve[k*k//3::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2, 3] + [3*i+1|1 for i in range(1, n//3-correction) if sieve[i]]


from collections import defaultdict
primelist=primes(int(n**0.5+1))+[n+1]
factors=defaultdict(lambda :0)
for prime in primelist:
    if prime>n:
        factors[n]+=1
        break
    while n%prime==0:
        n=n//prime
        factors[prime]+=1
factors[n]=1
factors[1]=0
print(len(factors))

Solution (Python):
import fractions

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

print(len(set(prime))+1)

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

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


def calculate(a,b):
    s1 = yinshufenjie(a)
    s2 = yinshufenjie(b)

    set1 = set()
    set2 = set()
    for key in s1.keys():
        set1.add(key)

    for key in s2.keys():
        set2.add(key)

    a = set1 & set2
    print(len(a)+1)


calculate(A,B)

Solution (Python):
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)
def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g
def lcm_core(a,b):
    g = gcd_core(a,b)
    return (a*b)//g
def lcm(arr):
    l = lcm_core(arr[0],arr[1])
    for i in range(2,len(arr)):
        l = lcm_core(l,arr[i])
    return l
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
def isprime(p):
    x = 2
    while x*x <= p:
        if p%x == 0:
            return False
        x += 1
    return True

A, B = map(int, input().split())
ans = 0
for i in set(divisor(A)) & set(divisor(B)):
    if isprime(i):
        ans += 1
print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


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


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


a, b = map(int, read().split())
cnt = 1
for n in set(prime_decomposition(b)) & set(prime_decomposition(a)):
    if is_prime(n):
        cnt += 1
print(cnt)

Solution (Python):
A, B = [int(x) for x in 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

a = prime_decomposition(A)
b = prime_decomposition(B)

a = set(a)
b = set(b)
ab = a.intersection(b)
ab.add(1)

print(len(ab))

Solution (Python):
import numpy as np


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

lisa = prime_factorize(a)
lisb = prime_factorize(b)
lis = set(lisa) & set(lisb)
lis.add(1)
lis = sorted(list(lis))
devil = (max(a,b)/lis[-1])
if len(prime_factorize(devil)) == 1:
  if min(a,b) % devil == 0:
    lis.append(devil)
print(len(set(lis)))

Solution (Python):
import math 

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

def gdc(A, B):
    if B == 0:
        return A
    else:
        return gdc(B, A % B)

def chk_pn(num):
    flag = True
    if num  <= 3:
        pass
    else:    
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                flag = False
                break
    return flag

def mk_factor(num):
    max_divisor = int(math.sqrt(num))+1
    divisor = 2
    factor_list = [1]

    while divisor <= max_divisor:
        if num % divisor == 0:
            factor_list.append(divisor)
            num /= divisor
        else:
            divisor += 1

    factor_list.append(num) 
    return factor_list

GDC = gdc(A, B)
pn_factor = [i for i in mk_factor(GDC) if chk_pn(i) is True]

print(len(set(pn_factor)))

Solution (Python):
import sys
if sys.version_info.minor < 5:
    from fractions import gcd
else:
    from math import gcd
import math

DEBUG = False

A, B = map(int, input().split())
g = gcd(A, B)
if DEBUG:
    print("gcd(A, B): {}".format(g))

ans = [1]
i= 2
temp = g
while i <= int(-(-g**0.5//1))+1:
    if DEBUG:
        print("i: {}, g: {}".format(i, g))

    if temp % i == 0:
        if DEBUG:
            print("This is a cd of A and B.")
        ans.append(i)

    while temp % i == 0:
        temp //= i

    i += 1

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

if DEBUG:
    print(ans)

print(len(ans))

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

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

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

  return arr

set_a = set(factorize(a))
set_b = set(factorize(b))

set_ab = set(set_a) & set(set_b)
ans = len(set_ab) + 1
print(ans)

Solution (Python):
import itertools

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 = map(int, input().split())
    a = set(make_divisors(A))
    b = set(make_divisors(B))
    ans = 0
    union_ab = a & b
    
    tmp = [1]
    for s in union_ab:
        if s >= 4 and s%2 == 0:
            continue
        if len(make_divisors(s)) == 2:
            tmp.append(s)
    
    ans = len(tmp)
    print(ans)

if __name__ == "__main__":
    main()

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

pf={}

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

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

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

ans = 1
if not n % 2: ans += 1

while not n % 2:
    n //= 2

i = 3

while i <= n**0.5:
    if not n % i: ans += 1
    while not n % i:
        n //= i
    i += 2

if 1 < n: ans += 1
print(ans)

Solution (Python):
import fractions

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

if __name__=="__main__":
    main()

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

    def prime_factorize(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])

        arr.append([1, 1])

        return arr

    a = prime_factorize(A)
    set_a = set(i for i, j in a)
    b = prime_factorize(B)
    set_b = set(i for i, j in b)

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



if __name__ == "__main__":
    main()

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

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

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

    cd = gcd(A, B)
    ans = len(prime_factorize(cd)) + 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *
































def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




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

	As = factorize(A)
	As = list(set(As))
	bs = factorize(B)
	bs = list(set(bs))

	ans = 0
	for i in As:
		if i in bs:
			ans += 1

	print(ans+1)

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





def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y



def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv



def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()