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.



Sample input:
12 18


Sample output:
3

Submission status: Runtime Error

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

def coprime(a, b):
    return gcd(a, b) == 1

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

    # divisors.sort()
    return divisors

A,B=map(int, input().split())
if (A==1 and B!=1)or(A!=1 and B==1)or(coprime(A,B)):
  print(1)
else:
  A=make_divisors(A)
  B=make_divisors(B)
  C=list(set(A)&set(B))
  C.sort(reverse=True)
  count=0
  for i in range(len(C)):
    for j in range(i+1,len(C)):
      if (C[j]!=1)and(C[i]%C[j]==0):
        count=count+1
        break
print(len(C)-count)

Submission status: Runtime Error

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

def coprime(a, b):
    return gcd(a, b) == 1

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

    # divisors.sort()
    return divisors

A,B=map(int, input().split())
if A==B:
  print(0)
elif (A==1 and B!=1)or(A!=1 and B==1)or(coprime(A,B)):
  print(1)
else:
  A=make_divisors(A)
  B=make_divisors(B)
  C=list(set(A)&set(B))
  C.sort(reverse=True)
  count=0
  for i in range(len(C)):
    for j in range(i+1,len(C)):
      if (C[j]!=1)and(C[i]%C[j]==0):
        count=count+1
        break
print(len(C)-count)

Submission status: Runtime Error

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

def coprime(a, b):
    return gcd(a, b) == 1

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

    # divisors.sort()
    return divisors

A,B=map(int, input().split())
if (A==0 and B!=1)or(A!=1 and B==0):
  print(0)
elif coprime(A,B):
  print(1)
else:
  A=make_divisors(A)
  B=make_divisors(B)
  C=list(set(A)&set(B))
  C.sort(reverse=True)
  count=0
  for i in range(len(C)):
    for j in range(i+1,len(C)):
      if (C[j]!=1)and(C[i]%C[j]==0):
        count=count+1
        break
print(len(C)-count)

Submission status: Runtime Error

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

def coprime(a, b):
    return gcd(a, b) == 1

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

    # divisors.sort()
    return divisors

A,B=map(int, input().split())
if coprime(A,B):
  print(1)
else:
  A=make_divisors(A)
  B=make_divisors(B)
  C=list(set(A)&set(B))
  C.sort(reverse=True)
  count=0
  for i in range(len(C)):
    for j in range(i+1,len(C)):
      if (C[j]!=1)and(C[i]%C[j]==0):
        count=count+1
        break
print(len(C)-count)

Submission status: Runtime Error

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

def primes(n):
    if n==1:return [1]
    
    p_max = int(n**0.5)
    primes = list(range(3,n+1,2))
    n_primes = len(primes)
    
    for i, prime in enumerate([j for j in primes if j!=0]):
        for k in range(i+prime, n_primes, prime):
            primes[k] = 0
    prime_a = list([j for j in primes if j!=0])
    
    if n%2==0:prime_a.append(2)
      
    for i, prime_ai in enumerate(prime_a):
        if n%prime_ai!=0:prime_a[i]=0
    return list([j for j in prime_a if j!=0])

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

c = a & b
print(len(c)+1)

Submission status: Runtime Error

Solution code:
import sys
import random
import numpy as np
from fractions import gcd
def main(a, b):
    #a, b = [int(i) for i in sys.stdin.readline().split()]
    _gcd = gcd(a,b)
    memo_ls = np.zeros(_gcd).flatten()
    #memo_set = set()
    cnt = 0
    if _gcd == 1:
        print(1)
    else:
        for i in range(2, _gcd+1):
            if _gcd % i == 0 and memo_ls[i-1] != 1:
                #memo_ls[i-1::i] = 1
                cnt += 1
                #memo_set.add(i)
        #print(memo_set)
        print(cnt + 1)

if __name__ == "__main__":
    a, b = [int(i) for i in sys.stdin.readline().split()]
    main(a, b)

Submission status: Runtime Error

Solution code:
import sys
import random
import numpy as np
from fractions import gcd
def main(a, b):
    #a, b = [int(i) for i in sys.stdin.readline().split()]
    _gcd = gcd(a,b)
    memo_ls = np.zeros(_gcd).flatten()
    #memo_set = set()
    cnt = 0
    if _gcd == 1:
        print(1)
    else:
        for i in range(2, _gcd+1):
            if _gcd % i == 0 and memo_ls[i-1] != 1:
                memo_ls[i-1::i] = 1
                cnt += 1
                #memo_set.add(i)
        #print(memo_set)
        print(cnt + 1)

if __name__ == "__main__":
    a, b = [int(i) for i in sys.stdin.readline().split()]
    main(a, b)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from fractions import gcd
a, b = [int(i) for i in sys.stdin.readline().split()]
_gcd = gcd(a,b)
memo_ls = np.zeros(_gcd).flatten()
#memo_set = set()
cnt = 0
if _gcd == 1:
    print(1)
else:
    for i in range(2, _gcd+1):
        if _gcd % i == 0 and memo_ls[i-1] != 1:
            memo_ls[i-1::i] = 1
            cnt += 1
            #memo_set.add(i)
    #print(memo_set)
    print(cnt + 1)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from fractions import gcd
a, b = [int(i) for i in sys.stdin.readline().split()]
_gcd = gcd(a,b)
memo_ls = np.zeros(_gcd+1)
#memo_set = set()
cnt = 0
if _gcd == 1:
    print(1)
else:
    for i in range(2, _gcd+1):
        if _gcd % i == 0 and memo_ls[i-1] != 1:
            memo_ls[i-1::i] = 1
            cnt += 1
            #memo_set.add(i)
    #print(memo_set)
    print(cnt + 1)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from fractions import gcd
a, b = [int(i) for i in sys.stdin.readline().split()]
_gcd = gcd(a,b)
memo_ls = np.zeros(_gcd)
#memo_set = set()
cnt = 0
if _gcd == 1:
    print(1)
else:
    for i in range(2, _gcd+1):
        if _gcd % i == 0 and memo_ls[i-1] != 1:
            memo_ls[i-1::i] = 1
            cnt += 1
            #memo_set.add(i)
    #print(memo_set)
    print(cnt + 1)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from fractions import gcd
a, b = [int(i) for i in sys.stdin.readline().split()]
_gcd = gcd(a,b)
memo_ls = np.zeros(_gcd)
#memo_set = set()
cnt = 0
if gcd == 1:
    print(1)
else:
    for i in range(2, _gcd):
        if _gcd % i == 0 and memo_ls[i-1] != 1:
            memo_ls[i-1::i] = 1
            cnt += 1
            #memo_set.add(i)
    #print(memo_set)
    print(cnt + 1)

Submission status: Runtime Error

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

def gcd(num):
    k = []
    for i in [1,2]+list(range(3, num+1, 2)):
      if i > 2 and i%2 ==0:
        continue
      else:
        if num%i == 0:
            k.append(i) 
    return k

def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

ka = gcd(a)
kb = []
for i in ka:
  if b%i == 0:
    if is_prime(i):
        kb.append(i)

print(len(kb))

Submission status: Runtime Error

Solution code:
import math
A, B = map(int,input().split())

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

l = factorization(GCD)
if len(l) == 1:
    print(len(l))
else:
    print(len(l)+1)

Submission status: Runtime Error

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

cdMap = [0] * min(A, B)
count = 0
tmp = 1

for i in range(1, min(A, B)+1):
    if A%i==0 and B%i==0 and gcd(i, tmp) == 1:
        tmp *= i
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
import math
A, B = map(int,input().split())

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

l = factorization(GCD)
if len(l) == 1:
    print(len(l))
else:
    print(len(l)+1)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from fractions import gcd
a, b = [int(i) for i in sys.stdin.readline().split()]
_gcd = gcd(a,b)
memo_ls = np.zeros(_gcd)
#memo_set = set()
cnt = 0
if gcd == 1:
    print(1)
else:
    for i in range(2, _gcd+1):
        if _gcd % i == 0 and memo_ls[i-1] != 1:
            memo_ls[i-1::i] = 1
            cnt += 1
            #memo_set.add(i)
    #print(memo_set)
    print(cnt + 1)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from fractions import gcd
a, b = [int(i) for i in sys.stdin.readline().split()]
_gcd = gcd(a,b)
memo_ls = np.zeros(_gcd)
#memo_set = set()
cnt = 0
for i in range(2, _gcd):
    if _gcd % i == 0 and memo_ls[i-1] != 1:
        memo_ls[i-1::i] = 1
        cnt += 1
        #memo_set.add(i)
#print(memo_set)
print(cnt + 1)

Submission status: Runtime Error

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

n = 0

for i in range(1, min(a[0], a[1])+1): 
	if a[i]%i==a[i+1]%i==0: 
		if i%2!=0:
          n+=1
print(n)

Submission status: Runtime Error

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

n = 0

for i in range(1, min(a[0], a[1])+1): 
	if a[i]%i==a[i+1]%i==0: 
		n+=1
	
print(n)

Submission status: Runtime Error

Solution code:
n=list(map(int,input().split()))
l=[]
c=0
for i in range(1,n[1]+1):
  if n[0]%i==0 and n[1]%i==0:
    l.append(i)
for j in range(len(l)):
  if l[j]%2!=0 and l[j+1]%2!=0:
    c+=1
print(c)

Submission status: Runtime Error

Solution code:
from math import gcd, sqrt
import re


def int_check(n):
    n_type = type(n)
    if n_type != int:
        n_type_str = re.search(r'\'.+\'', str(n_type)).group()
        raise TypeError(n_type_str + ' object cannot be interpreted as an integer')


def eratosthenes(n):
    int_check(n)
    if n == 1:
        return []

    int_list = list(range(2, n+1))
    bottom_index = 0

    while int_list[bottom_index] <= sqrt(n):
        prime = int_list[bottom_index]
        bottom_index += 1
        top_index = bottom_index

        for num in int_list[bottom_index:]:
            if num % prime != 0:
                int_list[top_index] = num
                top_index += 1

        del int_list[top_index:]

    return int_list


def naive_method(n):
    int_check(n)
    if n == 1:
        return []

    prime_divisors = []
    for prime in eratosthenes(int(sqrt(n))):
        if n % prime == 0:
            remain_factor = n
            exponent = 0
            while remain_factor % prime == 0:
                remain_factor //= prime
                exponent += 1
            prime_divisors.append((prime, exponent))
            prime_divisors.extend(naive_method(remain_factor))

    prime_factors = []
    if len(prime_divisors) == 0:
        prime_factors.append((n, 1))
    else:
        prime_divisors.append((float('inf'), -float('inf')))
        prime_divisors.sort(key=lambda t: t[0])
        current_factor, max_exponent = prime_divisors[0]
        for factor in prime_divisors:
            if factor[0] == current_factor:
                max_exponent = max(max_exponent, factor[1])
            else:
                prime_factors.append((current_factor, max_exponent))
                current_factor, max_exponent = factor

    return prime_factors


def main():
    a, b = map(int, input().split())
    print(len(naive_method(gcd(a, b))) + 1)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math

a, b = map(int, input().split())
g = math.gcd(a, b)
g_2 = int(math.sqrt(g))
cnt = 1

for i in range(2, g_2+1):
    if g % i == 0:
        while g % i == 0:
            g //= i
        cnt += 1
if g > 1:
    cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
import math
def gcd(n, m):
  while m % n != 0:
    m, n = n, m % n
  return m
def div(n):
  d = []
  for i in range(2, int(math.sqrt(n))+2):
    if n % i == 0:
      for j in d:
        if i % j == 0:
          break
      else:
        d.append(i)
  if len(d) == 0 and n > 1:
    return 1
  return len(d)

a, b = map(int, input().split())
if a > b:
  a, b = b, a
c = math.gcd(a,b)
print(div(c) + 1)

Submission status: Runtime Error

Solution code:
import math

a, b = map(int, input().split())
x = math.gcd(a, b)
k = []
for i in range(1, x+1):
    if x % i == 0:
        k.append(i)
cnt = 0
for n in k:
    if n == 1:
        cnt += 1
    elif n == 2:
        cnt += 1
    else:
        flg = ""
        for p in range(2, n):
            if n % p == 0:
                flg = "composite"
                break
            else:
                flg = "prime"
        if flg == "prime":
            cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
import math
def div(n):
  d = []
  for i in range(2, int(math.sqrt(n))+2):
    if n % i == 0:
      for j in d:
        if i % j == 0:
          break
      else:
        d.append(i)
  if len(d) == 0 and n > 1:
    return 1
  return len(d)

a, b = map(int, input().split())
if a > b:
  a, b = b, a
c = math.gcd(a,b)
print(div(c) + 1)

Submission status: Runtime Error

Solution code:
from fractions import gcd

def FindAllDivisors(x):
    divList = []
    y = 1
    while y <= math.sqrt(x):
        if x % y == 0:
            divList.append(y)
            divList.append(int(x / y))
        y += 1
    return sorted(divList)

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

max_divs = gcd(A, B)

divs = FindAllDivisors(max_divs)

results = []
for div in divs[1:]:
    flag = True
    for result in results:
        if div % result == 0:
            flag = False
            break
    if flag:
        results.append(div)

print(len(results) + 1)

Submission status: Runtime Error

Solution code:
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

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

if math.gcd(a, b) == 1:
    print(1)
else:
    print(len(factorization(math.gcd(a, b))) + 1)

Submission status: Runtime Error

Solution code:
import math

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

max_divs = math.gcd(A, B)

divs = []
for i in range(1, max_divs+1):
    if max_divs % i == 0:
        divs.append(i)

results = []
for div in divs[1:]:
    flag = True
    for result in results:
        if div % result == 0:
            flag = False
            break
    if flag:
        results.append(div)

print(len(results) + 1)

Submission status: Runtime Error

Solution code:

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

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        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

import math
a, b = map(int,input().split())
ans = 1
gcd_div = make_divisors(math.gcd(a, b))
for i in gcd_div:
    if is_prime(i) == True:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from functools import gcd
from math import sqrt
A, B = map(int, input().split())

n = gcd(A, B)

ans = set()
for i in range(2, int(sqrt(n)+1)+1):
    while n % i == 0:
        n = n // i
        ans.add(i)

print(len(ans)+1)

Submission status: Runtime Error

Solution code:
from math import gcd
from math import sqrt
A, B = map(int, input().split())

n = gcd(A, B)

ans = set()
for i in range(2, int(sqrt(n)+1)+1):
    while n % i == 0:
        n = n // i
        ans.add(i)

print(len(ans)+1)

Submission status: Runtime Error

Solution code:
import sympy
a, b = map(int,input().split())
ans = 1
gcd_div = sympy.divisors(sympy.gcd(a, b))[:-1]
for i in gcd_div:
    if sympy.isprime(i) == True:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N)) 
    seachList = [i for i in range(2, N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    primeNum.append(1)
    return set(primeNum)

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

divs_A = set()
for i in range(1, A+1):
    if A % i == 0:
        divs_A.add(i)
        
divs_B = set()
for i in range(1, B+1):
    if B % i == 0:
        divs_B.add(i)

divs = list(divs_A & divs_B)

print(len(set(divs) & seachPrimeNum(max(divs))))

Submission status: Runtime Error

Solution code:
import fractions

def return_prime(aa):
    a_list = [1]
    if aa % 2 == 0:
        a_list.append(2)
    prime_list = list(range(3, aa + 1, 2))
    for d in prime_list:
        prime_list = [x for x in prime_list if (x == d or x % d != 0)]
    for p in prime_list:
        if aa % p == 0:
            a_list.append(p)
    return a_list

a, b = map(int, input().split())
a_list = return_prime(fractions.gcd(a, b))
print(len(set(a_list)))

Submission status: Runtime Error

Solution code:
import math
import sys

input = sys.stdin.readline


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

        gcd = math.gcd(A, B)

        root_gcd = gcd ** 0.5
        p = 2
        prim_num = 1
        while p <= root_gcd or gcd > 1:
            tmp = gcd
            while True:
                if gcd % p == 0:
                    gcd /= p
                else:
                    break
            if tmp != gcd:
                prim_num += 1

            p += 1
        print(prim_num)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Runtime Error

Solution code:
from fractions import gcd
from sympy import sieve

def create_primNum(N):
    primelist=[]
    [primelist.append(i) for i in sieve.primerange(2, N)]
    return primelist

if __name__ == "__main__":
    a,b = map(int,input().split())
    N = gcd(a, b)
    print(len(create_primNum(N)))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())


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

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return table


l = gcd(n, m)

ans = 0
i = 0

while(l != 1):
    if(n % i == 0 and m % i == 0 and l % i == 0):
        ans += 1

    while(l % i == 0):
        l //= i
    i += 1

print(ans + 1)

Submission status: Runtime Error

Solution code:
from sympy import isprime
from sympy import prime

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

S=[]
for i in range(2,min(A,B)+1):
    if A % i == 0 and B % i == 0:
        S.append(i)

Z = []

for i in S:
  if isprime(i) == True:
    Z.append(i)

print(len(Z)+1)

Submission status: Runtime Error

Solution code:
from sympy import isprime
from sympy import prime

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

# Ax = []
# for i in range(A+1):
#   if i == 0:
#     pass

#   elif A%i ==0:
#     Ax.append(i)

# Bx = []
# for i in range(B+1):
#   if i == 0:
#     pass

#   elif B%i ==0:
#     Bx.append(i)

S=[]
for i in range(2,min(A,B)+1):
    if A % i == 0 and B % i == 0:
        S.append(i)


# # S = list(set(Ax) & set(Bx)) 

Z = []

for i in S:
  if isprime(i) == True:
    Z.append(i)

print(len(Z)+1)

Submission status: Runtime Error

Solution code:
from math import gcd

def main():
    A, B = [int(i) for i in input().split()]

    G = gcd(A, B)
    factor = set()
    for i in range(2, G + 1):
        while G % i == 0:
            factor.add(i)
            G = G // i
    print(len(list(factor))+1)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from fractions import gcd
import numpy as np

def create_primeNum(N):
    if N == 1:
        return [1]
    primeNum=0
    for k in range(2, max + 1):
        # 2以外の偶数は素数ではないので無視する
        if k % 2 == 0 and k != 2:
            continue
        if pow(2, k - 1, k) == 1:
            primeNum += 1
    return primeNum

if __name__ == "__main__":
    a,b = map(int,input().split())
    N = gcd(a, b)
    print(len(create_primeNum(N)))

Submission status: Runtime Error

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

Ax = []
for i in range(A+1):
  if i == 0:
    pass

  elif A%i ==0:
    Ax.append(i)

Bx = []
for i in range(B+1):
  if i == 0:
    pass

  elif B%i ==0:
    Bx.append(i)

S = list(set(Ax) & set(Bx)) 

Z = []
from sympy import isprime

for i in S:
  if isprime(i) == True:
    Z.append(i)

print(len(Z)+1)

Submission status: Runtime Error

Solution code:
from math import gcd
a, b = map(int, input().split())
x = gcd(a, b)
z = []
for i in range(2, x):
    flag = True
    if x % i == 0:
        for j in z:
            if i % j == 0:
                flag = False
                break
    if flag == True and x % i == 0:
        z.append(i)
print len(z) + 1

Submission status: Runtime Error

Solution code:
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
#import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
#ts=time.time()
#sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
show_flg=True


a,b=MI()
g=math.gcd(a,b)
ans=[1]

for i in range(2,int(g**0.5)+2):
    if g%i==0:
        ans.append(i)
        while g%i==0:
            g//=i
    
    
print(len(ans))

Submission status: Runtime Error

Solution code:
from math import gcd
a, b = map(int, input().split())
x = gcd(a, b)
z = []
for i in range(2, x):
    flag = True
    if x % i == 0:
        for j in z:
            if i % j == 0:
                flag = False
                break
    if flag == True and x % i == 0:
        z.append(i)
print(len(z) + 1)

Submission status: Runtime Error

Solution code:
from math import gcd
a, b = map(int, input().split())
x = gcd(a, b)
z = []
for i in range(2, x):
    if x % i == 0 and all(i % j for j in z):
        z.append(i)

print(len(z) + 1)

Submission status: Runtime Error

Solution code:
import fractions
import numpy as np

def create_primeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

if __name__ == "__main__":
    a,b = map(int,input().split())
    N = fractions.gcd(a, b)
    print(len(create_primeNum(N)))

Submission status: Runtime Error

Solution code:
import math
import numpy as np

def create_primeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

if __name__ == "__main__":
    a,b = map(int,input().split())
    N = math.gcd(a, b)
    print(len(create_primeNum(N)))

Submission status: Runtime Error

Solution code:
import numpy as np
N=list(map(int,input().split()))
A,B=max(N),min(N)
#ユーグリッド
GCD=1
while True:
    r=A%B
    if r==0:
        GCD=B
        break
    else:
        A=B
        B=r

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

_GCD=factorization(GCD)
num_list=[]
for num in _GCD:
    num_list+=[num[0]]*num[1]
ans_list=np.array([1])
for n in num_list:
    ans_list=np.r_[ans_list,ans_list*n]
#これで素因数分解の加工が完全に完了

count=0
while not list(ans_list) == [] :
    num=ans_list[0]
    if A%num==0 and B%num==0:
        count+=1
        if num==1:
            ans_list=ans_list[~(ans_list==1)]
        else:
            ans_list=ans_list[~(ans_list % num == 0)]
    else:
        ans_list=ans_list[~(ans_list % num == 0)]
        
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
N=list(map(int,input().split()))
A,B=max(N),min(N)
#ユーグリッド
GCD=1
while True:
    r=A%B
    if r==0:
        GCD=B
        break
    else:
        A=B
        B=r

num_list=np.arange(1,GCD+1)
count=0

#1から調べていき、逐一倍数をリストから消していく
while not list(num_list) == [] :
    num=num_list[0]
    if A%num==0 and B%num==0:
        count+=1
        if num==1:
            num_list=num_list[~(num_list==1)]
        else:
            num_list=num_list[~(num_list % num == 0)]
    else:
        num_list=num_list[~(num_list % num == 0)]
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
N=list(map(int,input().split()))
A,B=max(N),min(N)
#ユーグリッド
GCD=1
while True:
    r=A%B
    if r==0:
        GCD=B
        break
    else:
        A=B
        B=r

num_list=np.arange(1,GCD+1)
count=0
while not list(num_list) == [] :
    num=num_list[0]
    if A%num==0 and B%num==0:
        count+=1
        if num==1:
            num_list=num_list[~(num_list==1)]
        else:
            num_list=num_list[~(num_list % num == 0)]
    else:
        num_list=num_list[~(num_list % num == 0)]
print(count)

Submission status: Runtime Error

Solution code:
# 所持している鍵の集合をbitで表現する
#　鍵の集合を表す2進数が少なくなる方向に遷移することはないから，for文for文でかける

N, M = map(int, input().split())
status_money = [float('inf')] * (1 << N)
key_money = []

# 初期状態からの遷移を記録
for _ in range(M) :
    a, b = map(int, input().split())
    key_money.append(a)
    C = 0
    for c in input().split() :
        C |= (1 << int(c) - 1)
    status_money[C] = min(status_money[C], a)
    
# ある状態とある状態の組合せを全部取る
for c in range(1 << N):
    # どんな鍵の組合せでも到達できない宝箱の組合せがあるかもしれない
    if status_money[c] == float('inf'):
        continue
    for d in range(1 << N):
        # c と d の論理和をとって新しく生成される状態 e を考える
        e = c | d
        # eにあらかじめ格納されている最小コストと，今生成したコストとのminをとる
        status_money[e] = min(status_money[c] + status_money[d], status_money[e])

# そもそも到達できない場合の処理を記述       
if status_money[-1] == float('inf'):
    print(-1)
else:
    print(status_money[-1])

Submission status: Runtime Error

Solution code:
import fractions

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

C = fractions.gcd(A, B)

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

print(len(list(set(factorize(C)))) + 1)

Submission status: Runtime Error

Solution code:
import fractions

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

C = fractions.gcd(A, B)

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

print(len(list(set(factorize(C))) + 1)

Submission status: Runtime Error

Solution code:
import math

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

C = math.gcd(A, B)

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

    return count

print(factorization(C) + 1)

Submission status: Runtime Error

Solution code:
import math
#最大公約数
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
#因数分解
def factorize(x):
    ans=1#約数１
    div=2
    while div**2<=x:
        while x%div==0:
            x=x//div
            flag=1
        if flag==1:
            ans+=1
        div+=1
        flag=0
    if x>1:
        ans+=1
    return ans

a,b=map(int,input().split())
g=gcd(a,b)
f=factorize(g)
print(f)

Submission status: Runtime Error

Solution code:
import math

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
      
def factorize(x):
    ans=1
    div=2
    while div**2<=x:
        while x%div==0:
            x=x//div
            flag=1
        if flag==1:
            ans+=1
        div+=1
        flag=0
    if x>1:
        ans+=1
    return ans

a,b=map(int,input().split())
g=gcd(a,b)
f=factorize(g)
print(f)

Submission status: Runtime Error

Solution code:
import math
#最大公約数
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
#因数分解
def factorize(x):
    ans=1#約数１
    div=2
    while div**2<=x:
        while x%div==0:
            x=x//div
            flag=1
        if flag==1:
            ans+=1
        div+=1
        flag=0
    if n>1:
        ans+=1
    return ans

a,b=map(int,input().split())
g=gcd(a,b)
f=factorize(g)
print(f)