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


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

    return divisors

import math

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

import fractions
x = fractions.gcd(A, B)
divisors = make_divisors(x)
ans = 0
P = primes(x)
for d in divisors:
    if P[d]:
        ans += 1
print(ans)

Submission status: Runtime Error

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


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

    return divisors

import math

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

print(primes(10**5))

import fractions
x = fractions.gcd(A, B)
divisors = make_divisors(x)
ans = 0
P = primes(x)
for d in divisors:
    if P[d]:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin
from math import gcd

def factorization(a):
    if a < 2:
        return []
    fac = []
    lim = int(a ** 0.5)
    i = 2
    while a > 1 and i <= lim:
        n = 0
        while a % i == 0:
            a //= i
            n += 1
        if n > 0:
            fac += [(i, n)]
        i += 1
    if a > 1 or fac == []:
        fac += [(a, 1)]
    return fac

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

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

Submission status: Runtime Error

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

def bunkai(n):
    sosu= []
    tmp = n
    
    if tmp%2 == 0:
        while tmp%2==0:
            tmp //=2
        sosu.append(2)
    
    for i in range(3,int(n/2)+1,2):
        if tmp%i == 0:
            while tmp%i==0:
                tmp //=i
            sosu.append(i)

    if tmp!=1:
        sosu.append(tmp)
                
    if sosu==[]:
        sosu.append[n]
    
    return sosu

def check_sosu(n,x):
    ans=1
    tmp = n
    for i in x:
        if (tmp % i) == 0:
            ans+=1
    return ans

ans = check_sosu(B,bunkai(A))

print(ans)

Submission status: Runtime Error

Solution code:
def d_disjoint_set_of_common_divisors():
    from math import gcd
    A, B = [int(i) for i in input().split()]

    def prime_factorization_dict(n):
        """nを素因数分解したときの素数とその指数の辞書"""
        from collections import defaultdict
        if n == 1:
            return {2: 0}  # 1は素数の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 table
    g = gcd(A, B)
    return len(prime_factorization_dict(g).keys()) + 1 if g > 1 else 1

print(d_disjoint_set_of_common_divisors())

Submission status: Runtime Error

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

a, b = map(int, input().split())
lc = div(a,b)
print(len(lc) + 1)

Submission status: Runtime Error

Solution code:
import math
from collections import defaultdict
def A():
    num = int(input())
    odd_nums = math.ceil(num/2.0)
    print(odd_nums/num)

def B():
    temp = [int(i) for i in input().split()]
    N = temp[0]
    K = temp[1]
    heights = [int(i) for i in input().split()]
    ans = 0
    for h in heights:
        ans += 1 if h >= K else 0
    print(ans)

def C():
    N = int(input())
    A = list(enumerate([int(i) for i in input().split()]))
    A.sort(key = lambda x: x[1])
    #print(A)
    print(' '.join([str(a+1) for a, i in A]))

def D():
    temp = [int(i) for i in input().split()]
    num1 = temp[0]
    num2 = temp[1]
    
    def primeFactors(n): 
        ans = set()

        # Print the number of two's that divide n 
        while n % 2 == 0: 
            ans.add(2)
            n = n // 2
            
        # n must be odd at this point 
        # so a skip of 2 ( i = i + 2) can be used 
        for i in range(3,int(math.sqrt(n))+1,2): 
            
            # while i divides n , print i ad divide n 
            while n % i== 0: 
                ans.add(i)
                n = n // i 
                
        # Condition if n is a prime 
        # number greater than 2 
        if n > 2: 
            ans.add(n)
        
        return ans
    
    print(len(primeFactors(math.gcd(num1, num2)))+1)
    
    
D()

Submission status: Runtime Error

Solution code:
# 190928 D
from fractions import gcd
import sympy as sym

def divisor(n): #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 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 is_prime, table

A,B = list(map(int,input().split()))
koyaku = gcd(A,B)
solist = [i for i in sym.primerange(1, koyaku)]
kotable = sym.divisors(koyaku)
output = []
for i in range(len(kotable)):
    if kotable[i] in solist:
        output.append(kotable[i])

print(len(output)+1)

Submission status: Runtime Error

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数を２つのグループに分ける

import itertools

def main():
  a, b = map(int, input().split())
  c = gojo(a,b)
  
  fac = [1]
  fac = facto(c, fac)
  #print(fac)
  print(len(fac))  
  
def facto(n, fac):
  if n == 1:
    return [1]
  if n == 2:
    return[1, 2]
  if n % 2 == 0:
    fac = [1, 2]
  else:
    fac = [1]
  
  max_n = int(n + 1) ** 0.5 + 2
  is_prime = [True for x in range(max_n)]
  for cursor in range(3, max_n, 2):
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.apppend(cursor)
        n = n // cursor
        if n == 1:
          break
      for i in range(cursor, max_n, 2):
        is_prime[i] = False
        
    if len(fac) == 1:
      fac = [1, n]
      
  return fac
  
def gojo(a,b):
  if b > a:
    a, b = b, a
  c = a % b
  if c == 0:
    return(b)
  else:
    return gojo(b, c)

if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
import math
from collections import defaultdict
def A():
    num = int(input())
    odd_nums = math.ceil(num/2.0)
    print(odd_nums/num)

def B():
    temp = [int(i) for i in input().split()]
    N = temp[0]
    K = temp[1]
    heights = [int(i) for i in input().split()]
    ans = 0
    for h in heights:
        ans += 1 if h >= K else 0
    print(ans)

def C():
    N = int(input())
    A = list(enumerate([int(i) for i in input().split()]))
    A.sort(key = lambda x: x[1])
    #print(A)
    print(' '.join([str(a+1) for a, i in A]))

def D():
    temp = [int(i) for i in input().split()]
    num1 = temp[0]
    num2 = temp[1]
    
    def primeFactors(n): 
        ans = set()

        # Print the number of two's that divide n 
        while n % 2 == 0: 
            ans.add(2)
            n = n // 2
            
        # n must be odd at this point 
        # so a skip of 2 ( i = i + 2) can be used 
        for i in range(3,int(math.sqrt(n))+1,2): 
            
            # while i divides n , print i ad divide n 
            while n % i== 0: 
                ans.add(i)
                n = n // i 
                
        # Condition if n is a prime 
        # number greater than 2 
        if n > 2: 
            ans.add(n)
        
        return ans
    
    print(len(primeFactors(math.gcd(num1, num2)))+1)
    
    
D()

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 += [i]

    if temp!=1:
        arr += [temp]

    
     #if arr==[]:
     #   arr += [n]

    return arr

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

myset = set(factorization(A)) & set(factorization(B))

#print(myset)

print(len(myset) + 1)

Submission status: Runtime Error

Solution code:
# ユークリッドの互除法
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

# 約数の列挙
def make_divisions(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors

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

arr = make_divisions(num)
arr.sort()

ans = [arr[0]]
for i in range(1, len(arr)):
    if gcd(ans[i-1], arr[i]) == 1:
        ans.append(arr[i])

print(len(ans))

Submission status: Runtime Error

Solution code:
import fractions
import math
a,b = map(int, input().split())
g = fractions.gcd(a,b)
ans = 1

for i in range(2, math.sqrt(g)+1):
  if g%i == 0:
    ans += 1
    while True:
      g //= i
      if g%i != 0:
        break
print(ans)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
 
if A>=B:
  C = A%B
else:
  C = B%A
 
count = 0
 
now = 0
 
a = 2
 
while C >= a*a:
  if C%a == 0:
    if a != now:
      count += 1
      now = a
    C /= a
  else:
    a +=1
 
if C > 2 & C != now:
  count +=1
 
count += 1
 
print(count)

Submission status: Runtime Error

Solution code:
import math
def get_prime(n):
    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 main():
    A,B = map(int,input().split())
    # m = min(A,B)
    m = math.gcd(A,B)
    prime_count = 0
    # lim = m / 2 # 13と26だからこのフィルタはNG
    # lim = math.ceil(math.sqrt(m+1))
    lim = m
    if (m > 7) :
        prime_list = get_prime(int(lim))
    else :
        prime_list = [2,3,5,7]
    # print(prime_list)
    # for i in range(1,m+1) :
    for i in prime_list :
        # print(i)
        # if (m % i == 0) :
        if (A % i == 0 and B % i == 0) :
            if (i in  prime_list) :
                # print(i)
                prime_count += 1
    
    # 1を含むので+1しておく
    # a = (prime_count+1) * (prime_count)
    # print(int(a/2))
    # 問題読み違えてた！！！！！！
    print(prime_count+1)
    



# メモ
# 案1
# まずは公約数を列挙する
# 素数かどうかを調べる
# 素数のうち、組み合わせを数える
# 間に合わない気がする
# 案2
# A,Bのちいさいほうの半分までの素数を列挙
# 小さい方の公約数を求める
# nC2を出す
main()

Submission status: Runtime Error

Solution code:
import math
def get_prime(n):
    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 main():
    A,B = map(int,input().split())
    # m = min(A,B)
    m = math.gcd(min(A,B))
    prime_count = 0
    # lim = m / 2 # 13と26だからこのフィルタはNG
    # lim = math.ceil(math.sqrt(m+1))
    lim = m
    if (m > 7) :
        prime_list = get_prime(int(lim))
    else :
        prime_list = [2,3,5,7]
    # print(prime_list)
    # for i in range(1,m+1) :
    for i in prime_list :
        # print(i)
        # if (m % i == 0) :
        if (A % i == 0 and B % i == 0) :
            if (i in  prime_list) :
                # print(i)
                prime_count += 1
    
    # 1を含むので+1しておく
    # a = (prime_count+1) * (prime_count)
    # print(int(a/2))
    # 問題読み違えてた！！！！！！
    print(prime_count+1)
    



# メモ
# 案1
# まずは公約数を列挙する
# 素数かどうかを調べる
# 素数のうち、組み合わせを数える
# 間に合わない気がする
# 案2
# A,Bのちいさいほうの半分までの素数を列挙
# 小さい方の公約数を求める
# nC2を出す
main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

import math
gcd = math.gcd(A,B)

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

def prime_num_check(n):
    if n == 1:
        return False
    for i in range(2,int(math.sqrt(n))+1):
        if n % i == 0:
            return False
            break
    else:
        return True

count = 1
for i in range(len(div)):
    if prime_num_check(div[i]) == True:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
import collections
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 set(a)

A, B = list(map(int, input().split()))
print(len(fractions.gcd(A, B)) + 1)

Submission status: Runtime Error

Solution code:
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D != 1:
  for i in range(2, int(-(-D**0.5//1)+2)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
    if len(arr) == 0:
      append.arr(D)
print(len(arr)+1)

Submission status: Runtime Error

Solution code:
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D != 1:
  for i in range(2, int(-(-D**0.5//1)+2)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
    if len(arr) == 0:
      append.arr(D)
else:
  pass
print(len(arr)+1)

Submission status: Runtime Error

Solution code:
mport time
import math
a,b = map(int,input().split())
cnt = 0
if a >= b:
  A = int(math.sqrt(b))
else:
  A = int(math.sqrt(a))
pn=[2]

t1 = time.time()
for L in range(3,A):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:pn.append(L)
pn.append(1)
t2 = time.time()
for i in pn:
  if a%i ==0 and b%i == 0:
    cnt += 1
t3 = time.time()
print(cnt)

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 

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

listA = make_divisors(A)
listB = make_divisors(B)
lst = list(set(listA) & set(listB))

lst.sort()

if len(lst) == 1:
  print(1)
  
else:
  check = [lst[1]]
  for i in range(1, len(lst)):
    for c in check:
      if lst[i] % c == 0:
        break
      else:
        check.append(lst[i])
  print(len(check)+1)

Submission status: Runtime Error

Solution code:
import math
a,b=map(int,input().split())
n=min(a,b)
m=max(a,b)
if n==1:
  print(1)
  exit
else:
     prime = [2]
     for i in range(3, math.ceil(n**0.5)):
         for p in prime:
             if i % p == 0:
                 break
         else:
             prime.append(i)
ctr=1
for i in range(len(prime)):
  if n%prime[i]==0:
    if m%prime[i]==0:
      ctr+=1
print(ctr)

Submission status: Runtime Error

Solution code:
def div(N):
    ans = []
    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            ans.append(i)
            if N // i != i:
                ans.append(N // i)
    ans.sort()
    return ans
import math

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

g=math.gcd(A,B)

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

Submission status: Runtime Error

Solution code:
import fraction
a,b=map(int,input().split())
n=fraction.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

print(len(factorization(n))+1)

Submission status: Runtime Error

Solution code:
    return pow(2,q-1,q)==1

ans=0

a,b=map(int,input().split())
c=gcd(a,b)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
s=make_divisors(c)
print(s)
for i in s:
    ans=ans+is_prime(i)
print(ans+1)

Submission status: Runtime Error

Solution code:
# 190928 D
from math import gcd as bltin_gcd

if __name__ == "__main__":
    def coprime2(a, b):
        return bltin_gcd(a, b) == 1

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

    def divisor(n): #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 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 is_prime, table

    A,B = list(map(int,input().split()))
    koyaku = gcd(A,B)
    kotable = sorted(divisor(koyaku))
    isprim, solist = sieve(koyaku)
    output = []
    for i in range(len(kotable)):
        if kotable[i] in solist:
            output.append(kotable[i])

    print(len(output)+1)

Submission status: Runtime Error

Solution code:
#-------------------------------------------------------------------
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors
#-------------------------------------------------------------------
def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False
 
    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1
 
    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)
 
        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1
 
        if y != n - 1 and t & 1 == 0:
            return False
 
    return True

#-------------------------------------------------------------------
#Python -3.4.x
from fractions import gcd
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
a,b = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

g=gcd(a,b)
#p('g ', g)
L=make_divisors(g)

#p( gcd(a,b) )
#p( L )

ans=1
for l in L:
	#if a%l==0 and b%l==0: ans+=1
	if is_prime(l): ans+=1

print(ans)

Submission status: Runtime Error

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

ans = [1]

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
 
cflist = cf(a,b)
 
import fractions
import itertools
 
for i in cflist:
        ans.append(i)
        for j in itertools.combinations(ans, 2):
                if 1 == fractions.gcd(j[0],j[1]):
            		pass
                else:
                        ans.pop()
                        break
 
print(len(ans))

Submission status: Runtime Error

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


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

    # divisors.sort()
    return divisors


a = make_divisors(A)
b = make_divisors(B)
L = []
for x in a:
    if x in b:
        L.append(x)
L.sort()
L = L[1:]#1を消す

ans = 1
for l in L:
    for i in range(2, l):
        if l % i == 0:
            flag = True
            break
    if flag:
        continue
    ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
def check2(x,y,p,t):
    for i in range(p,t,1):
        if x % i == 0 and y % i == 0 :
            return int(i)
    if (i+1) == t :
        return 1
A,B = map(int,input().split())
ans = 1
p = 2
while True :
    t = min(A, B)
    p = check2(A,B,p,t)
    if p ==  1  :
        break
    while True :
        if A % p == 0 and B % p == 0 :
            A = (A//p)
            B = (B//p)
        else :
            break
    ans += 1
print(ans)

Submission status: Runtime Error

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

result = []

def gcd(A, B):
    i = A
    while i > 0:
        if A % i == 0 and B % i == 0:
            result.append(i)
        i -= 1
    return result

def pn(result):
    for i in range(len(result)):
        for j in range(2, result[i]):
            if i % j == 0:
                result.remove(i)
                break

result1 = gcd(A, B)
print(len(kobaisu(result1)))

Submission status: Runtime Error

Solution code:
from math import gcd, sqrt


def IsPrime(num):
    if num < 2:
        return True
    elif num == 2:
        return True
    elif num % 2 == 0:
        return False

    sqrtNum = sqrt(num)
    for i in range(3, int(sqrtNum) + 1, 2):
        if num % i == 0:
            return False

    return True


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

    # divisors.sort()
    return divisors


if __name__ == "__main__":
    A, B = map(int, input().split())

    gcd = gcd(A, B)

    div = make_divisors(gcd)

    ans = list()
    for i in div:
        if IsPrime(i):
            ans.append(i)

    print(len(ans))

Submission status: Runtime Error

Solution code:
import math
a,b=map(int,input().split())
n=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

print(len(factorization(n))+1)

Submission status: Runtime Error

Solution code:
import math

def sieve_of_eratosthenes(target):
    dest = int(math.sqrt(target))
    target_list = list(range(2, target + 1))
    prime_list = []
 
    while True:
        num_min = min(target_list)
        if num_min >= dest:
            prime_list.extend(target_list)
            break
        prime_list.append(num_min)
 
 
        i = 0
 
        while True:
            if i >= len(target_list):
                break
            elif target_list[i] % num_min == 0:
                target_list.pop(i)
            i += 1
 
    return (prime_list)

A, B  = map(int, input().split())
#N = int(input())
mymax = math.gcd(A, B)
myanslist = [1]

if A == 1 or B == 1:
    print(1)
else:
    mylist = sieve_of_eratosthenes(mymax)

    mylist.sort()
    #print(mylist)
    
    mycnt = 0
    for i in mylist:
        if A%i == 0 and B%i == 0:
            myanslist += [i]
            #print(i)
#print('myanslist =' , myanslist)

    mycnt = 0
    myflag = 0
    for i in range(len(myanslist)-1):
        for j in range(i + 1, len(myanslist)):
            #print(i, j ,math.gcd(myanslist[j],myanslist[i]))
            if math.gcd(myanslist[j],myanslist[i]) != 1:
                myflag =1
                break
                
        mycnt += 1
        
    if myflag == 1:
        print(mycnt)
    else:
        print(mycnt+1)