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):
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
if A != 1 and B != 1:
    AB = set(prime_factorize(A)) & set(prime_factorize(B))
    print(len(AB)+1)
else:
    print(1)

Solution (Python):
def gcd(n,m):
    while n:
        m,n = [n,m%n]
    return m

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

S = gcd(A,B)

s = 1
i = 2
while True:
    if S == 1:
        break
    if i ** 2 >= S:
        break
    hoge = 0
    while S % i == 0:
        hoge += 1
        S //= i
    if hoge:
        s += 1
    i += 1

print(s + (S != 1))

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
import fractions
readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    
    return divisors
def is_prime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True
a, b = readl()
mx = max(a,b)
t = make_divisors(min(a,b))
count = 0
for i in t:
    if mx % i == 0:
        if is_prime(i):
            count += 1
print(count)

Solution (Python):

import sys
import heapq
import math
import fractions
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

a, b = map(int, input().split())
cd = []


def prime_decomposition(n):
    i = 2
    table = set()
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.add(i)
        i += 1
    if n > 1:
        table.add(n)
    return table


print(len(prime_decomposition(a).intersection(prime_decomposition(b)))+1)
exit()

for i in range(1, fractions.gcd(a, b) + 1):
    if (a % i != 0 or b % i != 0):
        continue
    flag = True
    for j in cd:
        if (j == 1):
            continue
        if (i % j == 0):
            flag = False
            break
    if (flag):
        cd.append(i)
print(len(cd))

Solution (Python):
def d_disjoint_set_of_common_divisors():
    A, B = [int(i) for i in input().split()]
    if A == 1 or B == 1:
        return 1

    def prime_factorization_dict(n):
        """nを素因数分解したときの素数の辞書"""
        from collections import defaultdict
        if n == 1:
            return {2: 0}  
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return set(table.keys())
    a_primekey = prime_factorization_dict(A)
    b_primekey = prime_factorization_dict(B)
    ans = []
    for a in a_primekey:
        if a in b_primekey:
            ans.append(a)
    return len(ans) + 1

print(d_disjoint_set_of_common_divisors())

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 set(a)
f1 = prime_factorize(a)
f2 = prime_factorize(b)

print(len(f1.intersection(f1, f2)) + 1)

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

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

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

div.sort()
ans = []
while len(div) != 0:
  d = div.pop(0)
  if d == 1:
    ans.append(d)
    continue
  div_c = div.copy()
  for i in range(len(div_c)):
    if div_c[i] % d == 0:
      div.remove(div_c[i])
  ans.append(d)

print(len(ans))

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
from queue import PriorityQueue
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)
"""
互いに素な整数の組を選ぶ
A.Bの公約数は
12 18なら
1, 2, 3, 6
ってやっていくと無理がある
そもそも約数がある時点でだめでは？

"""

A, B = LI()
if A == B == 1:
    print(1)
    exit()
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    print(a)
    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 get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

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_fac = factorization(A)
B_fac = factorization(B)
perr(A_fac)
perr(B_fac)
ans = 1
b_fac = [b[0] for b in B_fac]
for a in A_fac:
    if a[0] in b_fac:
        ans += 1




print(ans)

Solution (Python):
from fractions import gcd

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

def divisor(n: int) -> list:
    list_of_divisor = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            list_of_divisor.append(i)
            if i != n//i:
                list_of_divisor.append(n//i)
    list_of_divisor.sort()
    return list_of_divisor

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

g = gcd(a, b)
li = divisor(g)

cnt = 1
for i in li:
    if is_prime(i) == True:
        cnt += 1
    
print(cnt)

Solution (Python):
from fractions import gcd

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

ans = 1
n = d
for i in range(2, d + 1):
    if n % i == 0:
        ans += 1
        while n % i == 0:
            n //= i
    if n < i * i:
        if 1 < n:
            ans += 1
        break
print(ans)

Solution (Python):
from sys import stdin

def prime_factors(n):
    ret = []
    apnd = ret.append
    while n >= 4:
        if n % 2:
            break
        else:
            n //= 2
            apnd(2)
    i = 3
    while n >= i * i:
        if n % i:
            i += 2
        else:
            n //= i
            apnd(i)
    apnd(n)
    return ret

def main():
    input = lambda: stdin.readline()[:-1]
    A, B = map(int, input().split())

    num = [1] + prime_factors(A) + prime_factors(B)
    num = set(num)
    ans = 0
    for i in num:
        if not A % i and not B % i:
            ans += 1
    print(ans)

main()

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] = list(map(int,input().split()))

Ad = prime_factor(A)
Bd = prime_factor(B)
ABd = set(Ad) & set(Bd)
print(len(ABd)+1)

Solution (Python):
import itertools

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)
    return ass

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

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

    div_A = divisor(A)
    div_B = divisor(B)
    C = list(set(div_A) & set(div_B))
    cnt = 1
    for c in C:
        if is_prime(c):
            cnt += 1

    print(cnt)

main()

Solution (Python):


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

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

A, B = map(int, input().split())
Scount = []
ans = int(0)
count= int(0)
a = int(0)
b = int(0)

a = gcd(A, B)

b = pff(a)

ans = len(b)+1

print(ans)

Solution (Python):
from sys import stdin
import fractions
A,B = [int(x) for x in stdin.readline().rstrip().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
ans = len(set(prime_factorize(GCD)))
print(ans+1)

Solution (Python):
import fractions

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)

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

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

    return arr


f = fractions.gcd(a, b)

t = len(factorization(f))

if t == 1 and factorization(f)[0] == 1:
    print(t)
else:
    print(t + 1)

Solution (Python):
import math
import fractions
import sys
sys.setrecursionlimit(2000000000)
a,b= list(map(int, input().split()))
ma=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)
    return divisors

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

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

    return True
ans=1
for i in make_divisors(ma):
    if is_prime(i):
        ans+=1
print(ans)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def divisor(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            yield i
            if i != n // i:
                yield n // i


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


@mt
def slv(A, B):
    ad = [v for v in divisor(A)]
    bd = [v for v in divisor(B)]
    cd = list(set(ad) & set(bd))
    cd.sort()
    ans = [1]
    for i in range(1, len(cd)):
        for j in range(1, i):
            if cd[i] % cd[j] == 0:
                break
        else:
            ans.append(cd[i])
    
    return len(ans)




def main():
    A, B = read_int_n()
    print(slv(A, B))

    
    
    
    


if __name__ == '__main__':
    main()

Solution (Python):
import math


def trial_division(n):
    
    factor = set()
    
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.add(num)
    
    if not factor:
        return set((1, n))
    else:
        factor.add(n)
        factor.add(1)
        return factor


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


print(len(trial_division(A) & trial_division(B)))

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)


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

factorization(24)

def solve():
    A, B = LI()

    if A == 1 and B == 1:
        print(1)
        return

    a_primes = factorization(A)
    b_primes = factorization(B)

    dprint(a_primes)
    dprint(b_primes)

    print(len(set([x[0] for x in a_primes])&set([y[0] for y in b_primes]))+1)
solve()

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

a, b = map(int, input().split())
g = gcd(a, b)
ans = set([1])
for i in range(2, 1000000):
    while g % i == 0:
        g = g // i
        ans.add(i)
if g > 1:
    ans.add(g)

print(len(ans))

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

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

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

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

    return arr

def main():
    A, B = map(int, input().split())
    C = gcd(A, B)
    l = factorization(C)
    if l == [[1, 1]]:
        print(1)
    else:
        ans = len(l) + 1
        print(ans)


if __name__ == '__main__': main()

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

hoge_a = set(prime_factorize(a))
hoge_b = set(prime_factorize(b))
ans = len(hoge_a & hoge_b) +1
print(ans)

Solution (Python):
import math
import heapq
from bisect import bisect_right, bisect_left
from collections import defaultdict, Counter
import itertools
import sys
from fractions import gcd
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
INF = float("inf")


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 lcm(a, b):
    return a * b / gcd(a, b)


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 main():
    a, b = map(int, input().split())
    l = make_divisors(a)
    d = Counter(l)
    ll = make_divisors(b)
    lll = []
    for i in range(len(ll)):
        if d[ll[i]] > 0:
            lll.append(ll[i])
    ans = 1
    for i in range(len(lll)):
        if is_prime(lll[i]):
            ans += 1
    print(ans)


    

if __name__ == '__main__':
    main()

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

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
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(a,b):
  while b!=0:
    a,b=b,a%b
  return a

  
n = gcd(A,B)
if(n == 1): ans = 1
else: ans = len(factorization(n))+1
print(ans)

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

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

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

    return arr

def main():
    A,B=map(int,input().split())
    if A==1 and B==1:
        return 1
    AF=[x[0] for x in factorization(A)]
    BF=[x[0] for x in factorization(B)]
    return len(set(AF)&set(BF))+1
    

print(main())

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


"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    if n == 1:
      return []
    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

import fractions

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

Solution (Python):
import numpy as np
import fractions

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(e) for e in input().strip().split()]
g = fractions.gcd(a, b)
f = prime_factorize(g)
print(len(set(f)) + 1)

Solution (Python):
a, b = map(int, input().split())
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, 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

f = factorization(gcd(a,b))
if f[0] != [1, 1]:
    f.append([1,1])
print(len(f))

Solution (Python):
import math
import fractions
from collections import Counter

def read():
    return int(input())

def readmap():
    return map(int, input().split())

def readlist():
    return list(map(int, input().split()))

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

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

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 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__":
    a, b = readmap()
    g = fractions.gcd(a, b)

    c = Counter(prime_factorize(g))

    print(len(c) + 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 set(divisors)

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

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

    return True

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

common_divisors = make_divisors(a) & make_divisors(b)

ans = 1
for common_divisor in common_divisors:
    if is_prime(common_divisor):
        ans += 1

print(ans)

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

big=max(a,b)
sma=min(a,b)

while sma>0:
    mod=big%sma
    big=sma
    sma=mod



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 big==1:
    print(1)
else:
    print(len(factorization(big))+1)

Solution (Python):
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())
x = set(factorize(a))
x = list(x)
y = set(factorize(b))
y = list(y)
z = x+y
z = [i for i in set(z) if z.count(i) > 1]
print(len(z)+1)

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

a,b = [list(map(int, s.split())) for s in open(0)][0]

al = set(prime_factorize(a))
bl = set(prime_factorize(b))
print(len(al & bl)+1)

Solution (Python):
a,b=[int(j) for j 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
la=set(make_divisors(a))
lb=set(make_divisors(b))
l=list(la&lb)
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

ans=0
ll=set([1])
l.sort()
for i in l:
    if i==1:
        continue
    if set(make_divisors(i))&ll=={1}:
        ll.add(i)
print(len(ll))

Solution (Python):
a,b=map(int,input().split())
def gcd(a,b):
    if b==0:
        return a 
    return gcd(b,a%b)
g=gcd(a,b)

from math import sqrt as S

def get_div(x):
    if x==1:
        return [1]
    div=[1,x]
    for i in range(2,int(S(x))+1):
        if x%i==0:
            div.append(i)
            if i!=x//i:
                div.append(x//i)
    return div 
div=get_div(g)
p=10**6+5 
def sieve():
    l=[1]*p 
    i=2 
    while i*i<=p:
        if l[i]:
            for j in range(i*i,p,i):
                l[j]=0 
        i+=1 
    l[0]=0 
    return l 
isp=sieve()
cnt=0 
def pr(n):
    if n<=1:
        return 0 
    return all(n%i for i in range(2,int(S(n))+1))
for i in div:
    if i<=10**6:
        if isp[i]:
            cnt+=1 
    else:
        if pr(i):
            cnt+=1 
print(cnt)

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


def is_prime(p):
    if p == 1:
        return False
    for i in range(2, int(p ** .5) + 1):
        if p % i == 0:
            return False
    return True


a, b = map(int, input().split())
g = gcd(a, b)
kouyakusu = make_divisors(g)
ans = 1
for i in kouyakusu:
    if is_prime(i):
        ans += 1
print(ans)

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

def Prime_factorization(n):
    ans = []
    tmp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if tmp%i == 0:
            count = 0
            while tmp%i == 0:
                count += 1
                tmp //= i
            ans.append([i,count])
    if tmp != 1:
        ans.append([tmp, 1])
    return ans
print(len(Prime_factorization(fractions.gcd(A,B)))+1)

Solution (Python):
def gcd(a,b):
    while b!=0:
         a,b=b,a%b
    return a
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+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
if __name__ == "__main__":
    A,B = map(int,input().split())
    d = gcd(A,B)
    if d == 1:
        print(1)
    else:
        D = factorization(d)
        print(len(D)+1)

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



import fractions
gcd = fractions.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:
  primes = factorization(gcd)
  print(len(primes)+1)

Solution (Python):
import fractions
a, b = map(int, input().split())
 
c =fractions.gcd(a,b)
c2 = c
F = []
while c2%2==0:
    c2 //= 2
if c2<c:
    F.append(2)
f = 3
while f*f<c2:
    while c2 %f ==0:
        c2//=f 
        if F:
            if F[-1]<f:
                F.append(f)
        else:
            F.append(f)
    f += 2
if c2>1:
    F.append(f)
print(len(F)+1)

Solution (Python):
import fractions as fr
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
p = fr.gcd(A,B)

ans = len(set(prime_factorize(p)))+1
print(ans)

Solution (Python):
import math

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)

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

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

    arr.append(1)
    return arr

A_ = set(factorization(A))
B_ = set(factorization(B))

print(len(A_ & B_))

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

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

Solution (Python):
A, B = map(int, input().split())
a = set()
b = set()
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
"""
i = 2
temp = A + 0
while i * i <= temp:
  if A <= 1:
    break
  while A % i == 0:
    a.add(i)
    A //= i
  i += 1
i = 2
temp = B + 0
while i * i <= temp:
  if B <= 1:
    break
  while B % i == 0:
    b.add(i)
    B //= i
  i += 1
"""
a = set([i[0] for i in factorization(A)])
b = set([i[0] for i in factorization(B)])
inter = a.intersection(b)
if A == 1 and B == 1:
  print(1)
else:
  print(len(inter) + 1)

Solution (Python):
import sys
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def gcd(a,b):
    if a==0:
        return b
    else:
        return gcd(b%a,a)
def all_factors(n):
    small, large = [], []
    for i in range(1, int(n**0.5) + 1, 2 if n & 1 else 1):
        if not n % i:
            small.append(i)
            large.append(n // i)
    if small[-1] == large[-1]:
        large.pop()
    large.reverse()
    small.extend(large)
    return small
def is_prime(n):
    if n < 5 or n & 1 == 0 or n % 3 == 0:
        return 2 <= n <= 3
    s = ((n - 1) & (1 - n)).bit_length() - 1
    d = n >> s
    for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
        p = pow(a, d, n)
        if p == 1 or p == n - 1 or a % n == 0:
            continue
        for _ in range(s):
            p = (p * p) % n
            if p == n - 1:
                break
        else:
            return False
    return True

a,b=get_ints()
g=gcd(a,b)
lst=all_factors(g)
count=1
for i in lst:
    if is_prime(i):
        count+=1
print(count)

Solution (Python):
from fractions import gcd

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a, b = nm()

def prime_factorize(n):
    a = set()
    a.add(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



ps = prime_factorize(gcd(a,b))

print(len(ps))