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:
import math
a,b=[int(i) for i in input().split()]
p=math.gcd(a,b)
def f(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 f(p)[0][0]==1:
    print(1)
else:
    print(len(f(p))+1)

Submission status: Runtime Error

Solution code:
import itertools as it

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

class Primes:
    def __init__(self):
        self.primes = it.count(2)

    def __iter__(self):
        return self

    def __next__(self):
        p = next(self.primes)
        # 素数の倍数を取り除く
        self.primes = filter(lambda x: x % p != 0, self.primes)
        return p

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    
    return list(set(table))
  
ma = max(A, B)
mi = min(A, B)

yakusu = [d for d in divisor(mi) if ma % d == 0]

prime = list(it.islice(Primes(), max(yakusu)))
prime.append(1)

c = 0
for y in yakusu:
  if y in prime:
    c += 1
print(c)

Submission status: Runtime Error

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

primes = 0

i = 1

def is_prime(n):
    """
    Assumes that n is a positive natural number
    """
    # We know 1 is not a prime number
    if n == 1:
        return True

    i = 2
    # This will loop from 2 to int(sqrt(x))
    while i*i <= n:
        # Check if i divides x without leaving a remainder
        if n % i == 0:
            # This means that n has a factor in between 2 and sqrt(n)
            # So it is not a prime number
            return False
        i += 1
    # If we did not find any factor in the above loop,
    # then n is a prime number
    return True

from math import gcd

while i <= gcd(a,b):
    if a%i == 0 and b%i == 0:
        if is_prime(i):
           primes += 1
    i += 1

print(primes)

Submission status: Runtime Error

Solution code:
#-------------------------------------------------------------------
# 【Python】エラトステネスの篩を使ってPythonで素数を探す
# https://a-zumi.net/python-prime/
def prime(n):
    seq = list(range(2, n))
    while len(seq) > 0:
        prime = seq.pop(0)
        yield prime
        # 素数で割り切れない数字のリストを作成
        seq = [i for i in seq if not i % prime == 0]

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

#L=list(prime(gcd(a,b)))

g=gcd(a,b)
p('g ', g)
L=list(prime(g))

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

ans=1
for l in L:
	if a%l==0 and b%l==0: ans+=1

print(ans)

Submission status: Runtime Error

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


def cf(x1,x2):
    cf=[1]
    counter = 1
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            for j in range(len(cf)):
                if math.gcd(i,cf[j])==1 :
                    tem = 0
                else:
                    tem = 1
                    break
            if tem == 0:

                cf.append(i)
                counter += 1
            else:
                    pass
    return cf

print(len(cf(a,b)))

Submission status: Runtime Error

Solution code:
def find_lcd(A,B):
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  sqrt_org=int(X**0.5)
  while X != 1:
    if i**2 > X:
      count += 1
      break
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = X/i
    if i== 2:
      i += 1
    else:
      i += 2
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))

Submission status: Runtime Error

Solution code:
import math
A,B=map(int,input().split())
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 coprime2(a, b):
    return math.gcd(a, b) == 1

test = cf(A, B)
test.append(1)
test = sorted(test)
cnt = 0
choice = set()
result = set()
for i in range(len(test)):
    for j in  range(0,len(test)):
        if test[i] in choice:
            break
        if coprime2(test[i], test[j]):
            t = (test[i],test[j])
            if test[i] > test[j]:
                tmp = test[j]
                t = (tmp,test[i])
            if test[i] != test[j]:

                result.add(t)
                choice.add(test[i])
print(len(result))

Submission status: Runtime Error

Solution code:
import math

A, B = (int(i) for i in input().split())
MAX = math.gcd(A, B)

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

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

    return True

cf=[]
for i in range(1,int(((MAX+1)/2)+1)):
    if MAX % i == 0:
        if is_prime(i):
            cf.append(i)

print(len(cf))

Submission status: Runtime Error

Solution code:
import math
a,b=map(int,input().split())
c=math.gcd(a,b)
d=[]
for i in range(2,int(c**0.5)+1):
    while c%i==0:
        c//=i
        d.append(i)
print(len(set(d))+1)

Submission status: Runtime Error

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

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 gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def coprime(a, b):
    return gcd(a, b) == 1
  
num = cf(a,b)
num_2 = [1,2]
for n in num:
    if not n %2 == 0:
        num_2.append(n)
if len(num_2) == 2:
    print(1)
else:
  ans_num = []
  m_n = len(num_2)
  for i in range(m_n):
      if i == m_n:
          break
      else:
          for j in range(i+1,m_n):
              if coprime(num_2[i],num_2[j]):
                  ans_num.append(num_2[i])
                  ans_num.append(num_2[j])
              else:
                  ans_num.remove(num_2[j])
    print(len(set(ans_num)))

Submission status: Runtime Error

Solution code:
import math

a, b = map(int, input().split())
count = 0
# a, b = (12, 18)

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


c = make_divisors(a)
d = make_divisors(b)
e = []
for i in c:
    if i in d:
        e.append(i)

print(e)
e.pop(0)
e.sort()

gcd_list = [1]
for i in e:
    count = 0
    for j in gcd_list:
        if math.gcd(i, j) != 1:
            break
        else:
            count += 1
        if count == len(gcd_list):
            gcd_list.append(i)

# for i in range(len(e)):
#     for j in range(i+1, len(e)):
#         if math.gcd(e[i], e[j]) == 1:
#             print(e[i], e[j])
#             count += 1

print(len(gcd_list))

Submission status: Runtime Error

Solution code:
import math
a,b = map(int, input().split())
ans = 1
count = 2
num = math.gcd(a,b)

if a==1 or b==1:
    print(1)
else:
    while num!=1:
        if num%count==0:
            ans+=1
            while num%count==0:
                num= num/count
            count+=1
        else:
            count+=1
print(ans)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
if a<b:
  a,b=b,a
def gcd(m,n):
  while n!=0:
    m,n=n,m%n
  return m
def div(n):
  division=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      division.append(i)
      if i!=(n//i):
        div.append(n//i)
  return division
lst=div(gcd(a,b))
cnt=1
for i in range((len(lst)+1)//2):
  if len(div(lst[i]))==2:
    cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
import sys


def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

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

    def divisors(n, div, ans):
        if n == 1:
            return
        if n % div == 0:
            ans.append(div)
            divisors(n // div, div, ans)
        else:
            divisors(n, div+1, ans)

    gcd_val = gcd(a, b)
    divs = []
    divisors(gcd_val, 2, divs)

    ans = 1
    for div in sorted(list(divs)):
        if div == 1:
            continue
        if gcd_val % div == 0:
            ans += 1
            while gcd_val % div == 0:
                gcd_val = gcd_val // div
    print(ans)


main()

Submission status: Runtime Error

Solution code:

from math import sqrt, ceil
def cf(x1,x2):
    cf=[1]
    x=era_prime(min(x1,x2)+1)
    for i in x:
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


def era_prime(N):
    temp = [True]*(N+1)
    temp[0] = temp[1] = False
    for i in range(2, ceil(sqrt(N+1))):
        if temp[i]:
            temp[i+i::i] = [False]*(len(temp[i+i::i]))                            
    primes = [ n for n in range(N+1) if temp[n] ]
    return primes

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

def resolve():
    a,b=map(int,input().split())
    g=cf(a,b)
#    print(g)
#    g=make_divisors(a,b)
#    print(g)
    ans=1
    for h in g:
        if is_prime(h):
            ans+=1
    print(ans)
resolve()

Submission status: Runtime Error

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

while A%C != 0 and B%C != 0:
  if A < B:
    B = C
  else:
    A = C
  C = abs(A-B)

i = 2
ans = 1
while C > 1:
  if C%i == 0:
    ans += 1
    while C%i == 0:
      C //= i
  i += 1

print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd


def answer():
    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())
    g = gcd(a, b)
    divisors = make_divisors(g)
    set_divisors = set(divisors)

    for div1 in divisors[1:]:
        for div2 in divisors[1:]:
            item = div1*div2
            if item in set_divisors:
                set_divisors.remove(item)

    print(len(set_divisors))


if __name__ == '__main__':
    answer()

Submission status: Runtime Error

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

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

def sieve(n):
    prime = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i, n+1, i):
                is_prime[j] = False
    return prime


A_div = make_divisors(A)
B_div = make_divisors(B)

cd = sorted([a for a in A_div if a in B_div])
prime = sieve(max(cd))

#print(cd)
#print(max(cd))
#print(prime)

ans = 1 # 1は絶対入る
for a in cd:
    if a in prime:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
https://atcoder.jp/contests/abc142/custom_test
def sieve(n):
    nums = [i+1 for i in range(2, n, 2) if (i+1) % 3 != 0 and (i+1) % 5 !=0] # リスト内包表記で3,5の倍数をはじく
    ans = [2,3,5] # 3,5は素数なので加えてしまう
    while nums[0] <= n**0.5:
        for i in range(nums[0]**2, nums[-1]+1, nums[0]):
            if i in nums: nums.remove(i)
            ans.append(nums.pop(0))
            ans += nums
    return ans


A,B =map(int,input().split())
if A<B:
    A,B =B,A
foo = 1
while foo != 0:
    A,B = B, A%B
    #print(A,B)
    foo = B

foo =A

plis = sieve(1000)
ans = 1
for p in plis:
    if foo%p==0:
        ans += 1
        foo = foo//p
    while foo%p ==0:
        foo = foo//p



plis = sieve(max(7,foo))

for p in plis:
    if  foo % p ==0:
        ans += 1
        foo = foo//p
        if foo < 1:
            break
print(ans)

Submission status: Runtime Error

Solution code:
import math
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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

g = gcd(a,b)


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

print(ans)

Submission status: Runtime Error

Solution code:
import math
a,b = map(int, input().split())
ans = 1
count = 2
num = math.gcd(a,b)

if a==1 or b==1:
    print(1)
else:
    while True:
        if num==1:
            print(ans)
            exit(0)
        else:
            if num%count==0:
                ans+=1
                while num%count==0:
                    num= num/count
                count+=1
            else:
                count+=1

Submission status: Runtime Error

Solution code:
import math
import collections

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

a, b = map(int, input().split())
g = math.gcd(a, b)
c = collections.Counter(fact(g))

print(len(c)+1)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
ls = [0]*(max(int(A**0.5)+1, int(B**0.5)+1)+1)
ans = 0
for i in range(1, max(int(A**0.5)+1, int(B**0.5)+1)):
  if A%i==0 and B%i==0:
    if ls[i]==0:
      ls[i]=1
    else:
      continue
    for n in range(2,int(i**0.5)+1):
      if i%n==0:
        break
    else:
      ans += 1
    j = A//i
    if B%j!=0:
      continue
    if ls[j]==0:
      ls[j] = 1
    else:
      continue
    for n in range(2,int(j**0.5)+1):
      if j%n==0:
        break
    else:
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
import math

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

if a>b:
  a,b = b,a
  
n=fractions.gcd(a,b)

t = [True]*(2*n)
d = [1]

for i in range(2, n):
  if t[i] is False:
    continue
  if n % i == 0:
    d.append(i)
    for j in range(i+1, n):
      if j%i==0:
        t[j] = False
print(len(d))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
l = []
x = fractions.gcd(a, b)
i = 1
# while i * i <= x:
#     if x % i == 0:
#         l.append(i)
#         l.append(x//i)
#     i += 1
# table = list(set(l))
for i in range(1, int(x**0.5)+1):
    if x % i == 0:
        l.append(i)
        if i**2 == x:
            continue
        l.append(x//i)
table = l
ans = []
for i in range(len(table)):
    check = True
    for j in range(2, int(table[i]**0.5)+1):
        if table[i] % j == 0:
            check = False
    if check:
        ans.append(table[i])
print(len(ans))

Submission status: Runtime Error

Solution code:
import math
a,b = map(int, input().split())
a,b = min(a,b),max(a,b)
c = list(range(2,math.ceil(a//2)))
d = 0
for i in c:
  c = [c[j] for j in range(len(c)) if c[j] % i != 0 or c[j] == i]
for i in c:
  if a % i == 0 and b % i == 0:
    d += 1
print(d+1)

Submission status: Runtime Error

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

MOD = 10**9+7

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

    max_gcd=gcd([A,B])
    P=primes(max_gcd)
    ans=1 # 1
    for p in P:
        if A%p==0 and B%p==0:
            ans+=1
    print(ans)

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

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

main()

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
yakusuu = []
ans = 1
for i in range (2,min(a,b)+1):
         if a % i == 0 and b% i == 0:
                  yakusuu.append(i)
for j in range(len(yakusuu)):
         for k in range(2,yakusuu[j]**(1/2)):
                  if yakusuu[j] % k == 0:
                           break
         else:
                  ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
A, B = (int(i) for i in input().split())

#A , B = 1, 2019
d = []
#print(A, B)

if A > B:
    for i in range(1, A + 1):
        if A % i == 0 and B % i  == 0:
            d.append(i)
else:
    for i in range(1, B + 1):
        if A % i == 0 and B % i  == 0:
            d.append(i)
ret = set()
import numpy as np
for i in d:
    for j in d:
        #print(np.gcd(i, j))
        if np.gcd(i, j) == 1:
            ret.add(j)
    
print(len(ret))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
import math
n = math.gcd(a, b)
devide = 2
l1 = []
while devide <= n:
    while n % devide == 0:
        n = n / devide
        l1.append(devide)
    devide += 1
l1 = list(set(l1))
print(int(len(l1) + 1))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys

# from math import gcd
from fraction import gcd

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



def solve(A: int, B: int):
    x = list(set(make_divisors(A)) & set(make_divisors(B)))
    
    ans = 0
    nn = len(x)
    for i in range(nn):
        t = [x[i]]
        for j in range(i+1,nn):
            f = True
            for k in t:
                if(coprime2(x[j],k) != 1):
                    f = False
            if(f):
                t.append(x[j])
                ans = max(ans, len(t))
    if(len(x) == 1 and x[0] == 1):
        print(1)
    else:
        print(ans)
            
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math as m

def is_prime(n): #素数かどうか判定
    if n == 1: return False
    for k in range(2, int(m.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

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   

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

tb = divisor(g)

count = 1
for i in tb:
    if is_prime(i):
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
def find_lcd(A,B):
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  sqrt_org=int(X**0.5)
  while X != 1 and i<=sqrt_org:
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = X/i
    if i== 2:
      i += 1
    else:
      i += 2
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))

Submission status: Runtime Error

Solution code:
A, B = (int(i) for i in input().split())

#A , B = 1, 2019
d = []
#print(A, B)

if A > B:
    for i in range(1, A + 1):
        if A % i == 0 and B % i  == 0:
            d.append(i)
else:
    for i in range(1, B + 1):
        if A % i == 0 and B % i  == 0:
             d.append(i)
ret = set()
import numpy as np
for i in d:
    for j in d:
        #print(np.gcd(i, j))
        if np.gcd(i, j) == 1:
            ret.add(j)
    
print(len(ret))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys

from math import gcd
# from fraction import gcd

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



def solve(A: int, B: int):
    x = list(set(make_divisors(A)) & set(make_divisors(B)))
    
    ans = 0
    nn = len(x)
    for i in range(nn):
        t = [x[i]]
        for j in range(i+1,nn):
            f = True
            for k in t:
                if(coprime2(x[j],k) != 1):
                    f = False
            if(f):
                t.append(x[j])
                ans = max(ans, len(t))
    if(len(x) == 1 and x[0] == 1):
        print(1)
    else:
        print(ans)
            
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

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

comdiv = [] 
div = make_divisors(A)
for i in div:
  if B % i == 0:
    comdiv.append(i)

def Eratosthenes(n):

    dp = [False]*n#sその値が素数かどうかを格納する。Falseなら素数。#場合によってはこちらをreturnしても良い。
    dp[0] = dp[1] = True#0,1はそれぞれ素数ではないのでTrueを入れる
    prime = []#素数列
    for i in range(2,n):
        if dp[i]:
            continue#素数でなければcontinue
        prime.append(i)#素数であれば足す
        #以下、iより大きいiの倍数を除外する処理
        for j in range(i*2,n,i):
          dp[j] = True
    return prime
  
flg = [False] * (max(A,B) + 1)
  
Era = Eratosthenes(max(A,B))
for e in Era:
  flg[e] = True

cnt = 0
for i in comdiv:
  if flg[i] == True:
    cnt += 1
print(cnt+1)

Submission status: Runtime Error

Solution code:
import math
a,b = list(map(int,input().split()))
g = math.gcd(a,b)
ans = 1
p = []
for i in range(2,g+1): #素数リスト
    k = True
    for j in p:
        if i%j==0:
            k = False
            break
    if k:
        p.append(i)
for i in p:
    if g%i == 0:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import itertools

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

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

def solve(A: int, B: int):
    G = gcd(A,B)
    P = primes(G)

    n = 1
    for p in P:
        if A % p == 0 and B % p == 0:
            n += 1

    print(n)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
import sys
a,b = map(int, input().split())
ans = 1
count = 2
num = math.gcd(a,b)

if a==1 or b==1:
    print(1)
else:
    while True:
        if num==1:
            print(ans)
            sys.exit(0)
        else:
            if num%count==0:
                ans+=1
                while num%count==0:
                    num= num/count
                count+=1
            else:
                count+=1

Submission status: Runtime Error

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

import numpy as np
gcd = np.gcd(a,b)

pn=[2];A=int(np.sqrt(gcd))+1
for L in range(3,A+1):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:pn.append(L)

count = 1
for i in pn:
    if gcd %i == 0:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
import math
from sympy import prime
    
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    


gcd = math.gcd(A, B)
divisors = make_divisors(gcd)
index = 1
result = list()
result
while True:
    num = prime(index)
    index += 1
    if num in divisors:
        result.append(num)
    elif num > divisors[-1]:
        break

print(len(result)+1)

Submission status: Runtime Error

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

    divisors.sort()
    return divisors

def is_prime(num):
    for i in range(2, num):  # 第二引数は sqrt(num)+1 でも良い
        if num % i == 0:
            return False

    return True

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

g = math.gcd(A, B)

# print(g)
div = make_divisors(g)
# print(div)
p = [i for i in div if is_prime(i)]
# print(p)
print(len(p))

Submission status: Runtime Error

Solution code:
from math import gcd


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


A, B = map(int, input().split())
cf = cf(A, B)
s = set()
for i in range(1, len(cf)):
    for j in range(1, len(cf)):
        if gcd(i, j) == 1:
            s.add(i)
            s.add(j)

print(max(s))

Submission status: Runtime Error

Solution code:
import collections
A, B = [int(x) for x in raw_input().split(' ')]
def reduceNum(n):
    res = collections.Counter()
    res[1] = 1
    while n != 1:
        for index in range(2, int(n + 1)):
            while n % index == 0:
                n /= index
                res[index] += 1
    return res
sa = reduceNum(A)
sb = reduceNum(B)
be = sa & sb
print(len(be))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
Z = primes(max(a, b))
ans = 1
for i in range(len(Z)):
  if a%Z[i] == b%Z[i] == 0:
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
def find_lcd(A,B):
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  while X != 1:
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = X/i
    if i== 2:
      i += 1
    else:
      i += 2
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))

Submission status: Runtime Error

Solution code:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	A := readInt()
	B := readInt()

	N := gcd(A, B)

	p := make([]bool, N+1)
	for i := 0; i < N+1; i++ {
		p[i] = true
	}
	p[0] = false
	p[1] = false
	n := int(math.Sqrt(float64(N)) + 1)
	for i := 4; i < N+1; i += 2 {
		p[i] = false
	}
	for i := 3; i < n+1; i += 2 {
		if p[i] {
			for j := i + i; j < N+1; j += i {
				p[j] = false
			}
		}
	}

	result := 1
	for i := 2; i < N+1; i++ {
		if N%i == 0 && p[i] {
			result++
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}