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 GCD(a,b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    else:
        return GCD(b, a % b)

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

g = GCD(A,B)
P = primes(g)
Q = []
for p in P:
    if g % p == 0:
        Q.append(p)

n = len(Q)
print(n + 1)

Submission status: Runtime Error

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

minAB = min(A,B);

hurui = [True] * (minAB+1)
"""
upper = int(math.sqrt(minAB+1))
ans = 1

for i in range(2, upper+1):

    if not(hurui[i]):
        continue
    
    for j in range(2*i, minAB+1, i):
        hurui[j] = False

    if A % i == 0  and B % i == 0:
        ans += 1
"""
print(ans)

Submission status: Runtime Error

Solution code:
# from math import gcd, sqrt
# import fractions
import math


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

    if flag:
        return n


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 main():
    a, b = map(int, input().split())
    coms = make_divisors(math.gcd(a, b))
    ans = [is_prime(i) for i in coms]
    ans2 = [a for a in ans if a is not None]
    print(len(ans2))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from fractions import gcd
a,b=map(int,input().split())
c=gcd(a,b)
if c==1:
  print(1)
  exit()
D=[]
P=[]
def E(c):
    P=[]
    E=[i+1 for i in range(1,int(c**0.5)+1)]
    while True:
        p=E[0]
        if int(c**0.5)+1<=p:
            return P+E
        P.append(p)
        E=[e for e in E if e%p!=0]
P=E(c)
f=True
for p in P:
  if c%p==0:
    f=False
    break
if f:
  print(2)
  exit()
for i in range(2, int(-(-gcd(a,b)**0.5//1))+1):
  if c%i==0:
    D.append(i)
    while c%i==0:
      c//=i
  if c==1:
    break
print(len(D)+1)

Submission status: Runtime Error

Solution code:
def check2(x,y,p):
    t = min(x,y)
    for i in range(p+1,t):
        if x % i == 0 and y % i == 0 :
            return i
        if i * i >= t :
            return 0
A,B = map(int,input().split())
ans = 1
p = 1
while True :
    p = check2(A,B,p)
    if p == 0 :
        break
    A = (A // p)
    B = (B // p)
    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:
#!/usr/bin/env python3
import sys
import sympy as sym
import numpy as np


def solve(A: int, B: int):
    divA = sym.divisors(A)
    divB = sym.divisors(B)

    divs = list(set(divA) & set(divB))
    #print(divs)
    #cd = np.array(divs[1])
    if len(divs) == 1:
        print(1)
        sys.exit(0)
    cd = []
    cd.append(divs[1])
    #print(cd)
    for i in divs[2:]:
        w = [(i % j) for j in cd]
        #print(i, w)

        if all(w):
            #np.append(cd, i)
            cd.append(i)
    
    print(len(cd)+1)





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 cf(x1,x2):
    cf=[]
    for i in range(3,x1+1,2):
        if  is_prime(i):
            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

num_2 = [1,2]
num_2.extend(num)
print(len(num_2))

Submission status: Runtime Error

Solution code:
import fractions
a, b = map(int, input().split())
n = fractions.gcd(a, b)
*t, = range(2, n+1)
#for i in range(len(t)):
#    if t[i] == -1:
#        continue
#    if a % t[i] == 0 and b % t[i] == 0:
#        for j in range(i+1, len(t)):
#            if t[j] == -1:
#                continue
#            if t[j] % t[i] == 0:
#                print(t[j], t[i])
#                t[j] = -1
#    else:
#        t[i] = -1
print(1)

Submission status: Runtime Error

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

minAB = min(A,B);

hurui = [True] * (minAB+1)

upper = int(math.sqrt(minAB+1))
ans = 1
"""
for i in range(2, upper+1):

    if not(hurui[i]):
        continue
    
    for j in range(2*i, minAB+1, i):
        hurui[j] = False

    if A % i == 0  and B % i == 0:
        ans += 1
"""
print(ans)

Submission status: Runtime Error

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

# ABが互いにそなら答えは１

ans = 0
import math

if math.gcd(A,B) == 1:
  ans = 1
else:
  # 公約数を求める
  cdlist =[]

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

  # print(cdlist)

  for i,cd1 in enumerate(cdlist):
    for cd2 in cdlist[i+1:]:
      # print(cd1,cd2)
      if math.gcd(cd1,cd2) == 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:

#from math import gcd
from fractions import gcd

def proto():
    print(gcd(420,660))

    for x in []:
        x = 10
        print(x)

#proto()

def make_pt(n:int):
    #print(n)

    length = (n+1 if n+1 > 2 else 10)
    ptab=[0]*length

    ptab[2]=2
    for i in range(3, n+1, 2):

        #print("AAAA")
        ppp = [p for p in ptab if p > 0]
        if all([True for p in ppp if i%p!=0]):
            ptab[i]=i


    #print(range(3,2,n+1))
    #print("BBB")
    pbtab=[False]*length
    for p in ptab:
        pbtab[p] = True

    return (ptab, pbtab)
    

def dcount(n:int,btab_):

    map_ ={1:1}

    counter = 0
    while n % 2 == 0:
        n //= 2
        counter += 1

    if counter > 0:
        map_[2]=counter


    for i in range(3,n+1,2):
        if not btab_[i]:
            continue

        if n < i:
            break

        counter = 0
        while n % i == 0:
            n //= i
            counter += 1

        if counter > 0:
            map_[i] = counter

    return map_


def main():

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

    gcd_ = gcd(a,b)
    #print(gcd_)

    ptab, btab = make_pt(gcd_)

    #print(ptab)
    #print(btab)
    #print(btab.count(True))
    #print("///_____________________///")

    map_ = dcount(gcd_, btab)

    #print(map_)
    ans = len(map_)
    print(ans)



main()

Submission status: Runtime Error

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


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

if is_prime(a) and is_prime(b):
    print(1)
    import sys
    sys.exit()

a_L = divisor(a)
b_L = divisor(b)

kouyaku = set(a_L) & set(b_L)

new_L = []


for val in kouyaku:
    if is_prime(val):
        new_L.append(val)


new_L.append(1)


import itertools
import math 

counter =0

v = itertools.combinations(list(new_L),2)


for i in v:

    if math.gcd(i[0], i[1]) == 1:
        #print(i[0],i[1])
        counter +=1
#print(counter)

print(len(new_L))

Submission status: Runtime Error

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

minAB = min(A,B);

hurui = [True] * (minAB+1)

upper = int(math.sqrt(minAB+1))
ans = 1
for i in range(2, upper+1):
    """
    if not(hurui[i]):
        continue
    
    for j in range(2*i, minAB+1, i):
        hurui[j] = False
    """
    if A % i == 0  and B % i == 0:
        ans += 1

print(ans)

Submission status: Runtime Error

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

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

for i in range(n):
    if a % (i+2) == 0 and b % (i +2) == 0:
        l.append(i+2)
    
primes = [2]
for x in l:
    if all(x % prime !=0 for prime in primes):
        primes.append(x)

if  a % 2 == 0 or b % 2 == 0:
    ans = len(primes) +1
else:
    ans = len(primes)
print(ans)

Submission status: Runtime Error

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

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

def cf(x1, x2):
    array = [1]
    for i in primes(gcd(x1, x2)):
        if x1 % i == 0 and x2 % i == 0:
            array.append(i)
    return array 

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

cf_array = cf(A, B)

print(len(cf_array))

Submission status: Runtime Error

Solution code:
import math


def sieve_of_eratosthenes(n):
    candidate = [i for i in range(2, n+1)]
    prime = []
    limit = math.sqrt(n) + 1

    while True:
        p = min(candidate)
        if limit <= p:
            prime.extend(candidate)
            break
        prime.append(p)

        candidate = [i for i in candidate if i % p != 0]
    return prime


a, b = map(int, input().split())
if a > b:
    a, b = b, a
prime = sieve_of_eratosthenes(b)
res = 1
for p in prime:
    if a %p == b % p == 0:
        res += 1
print(res)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
from math import gcd as bltin_gcd
import math

def isPrime(n):
  if n < 2:
    return False
  if n == 2:
    return True
  if n % 2 == 0:
    # ２ではない偶数は素数ではない
    return False
  
  # nの半分まで計算する範囲を絞る
  m = math.floor(n / 2) + 1
  for p in range(3, m, 2): # 奇数だけ計算する
      if n % p == 0:
        return False
  return True

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()) 

a_d = set(make_divisors(a))
b_d = set(make_divisors(b))
lists = list(a_d & b_d)
res = 1
for i in lists:
    if isPrime(i):
        res +=1
print(res)

Submission status: Runtime Error

Solution code:
from math import gcd as bltin_gcd


def coprime2(a, b):
    return bltin_gcd(a, b) == 1


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


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

# 公約数
divisor_list = cf(A, B)

# print(divisor_list)

counts = []
for i in divisor_list:
    if i == 1:
        continue

    other_list = list(filter(lambda x: x != i, divisor_list))

    count = 0
    nums = []
    for j in other_list:
        if coprime2(i, j):
            for n in nums:
                if not coprime2(j, n):
                    break
            else:
                nums.append(j)
                count = count + 1

    counts.append(count)

if not counts:
    print(1)
else:
    print(max(counts) + 1)

Submission status: Runtime Error

Solution code:
import math
A,B=map(int,input().split())
large=math.gcd(A,B)
ans=[]
for i in range(2,large+1): 
  if len(ans)>=1:
    if large%i==0: 
        count=0
        for k in ans:
            a=i%k
            if a!=0:
                count+=1
        if count==len(ans):
            ans.append(i)                
  else:
    if large%i==0:
      ans.append(i)

print(len(ans)+1)

Submission status: Runtime Error

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

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


def primes(n):
    is_prime = [True] * (n + 1)
    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: True for i in range(n + 1) if is_prime[i]}

def make_divisors(n):
    divisors = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i in p:
                divisors+=1
            if i != n // i and n//i in p:
                divisors+=1

    return divisors
x = gcd(A, B)
p = primes(x)
x = make_divisors(x)
print(x)

Submission status: Runtime Error

Solution code:
import fractions

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

# 2つの数字の公約数を求める
C = A
if A > B:
    C = B
nums = [i for i in range(1,C) if A % i == 0 and B % i == 0]
print(hoge)

Submission status: Runtime Error

Solution code:
from math import gcd

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

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

count = 0
if len(CD) == 1:
    count += 1
else:
    for i in range(len(CD)):
        for k in range(i+1,len(CD)):
            if ((i != k) and gcd(CD[i],CD[k]) == 1):
                count += 1

print(count)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    x1, x2 = map(int, input().split())
    if x1 >= x2 > 1:
        x1 = x1 - x2
    elif x1 > 1:
        x2 = x2 - x1
    cf = []
    # print("{}, {}".format(x1, x2))

    divisors1 = []
    for i in range(1, int(x1 ** 0.5) + 1):
        if x1 % i == 0:
            divisors1.append(i)
            if i != x1 // i:
                divisors1.append(x1 // i)
    divisors2 = []
    for i in range(1, int(x2 ** 0.5) + 1):
        if x2 % i == 0:
            divisors2.append(i)
            if i != x2 // i:
                divisors2.append(x2 // i)

    koyakusu = set(divisors1) & set(divisors2)
    koyakusu.remove(1)
    # print(list(koyakusu))

    for i in list(koyakusu):
        appendable = True
        for j in cf:
            if i % j == 0:
                appendable = False
                break
        if appendable:
            cf.append(i)
    # cfは公約数のリスト
    # このリストの中で互いに素のものだけを残す
    # for i in range(len(cf)):
    #   fractions.gcd()
    # print(cf)
    print(len(cf) + 1)

Submission status: Runtime Error

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

import math

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

PF = prime_factorize(GCD)

PF = set(PF)

res = len(PF) + 1

print(res)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

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

	lis = getPrimeNumList(an)
	print(len(lis))


def getPrimeNumList(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]]

def gcd(a, b):
	if a > b:
		a, b = b, a

	while a > 0:
		a, b = b % a, a
	return b

if __name__ == "__main__":
	main()

Submission status: Runtime Error

Solution code:
from sympy import isprime

lines = input.split(" ")
numline = [int(i) for i in lines]
A = numline[0] if numline[0] >= numline[1] else numline[1]
B = numline[1] if numline[0] >= numline[1] else numline[0]
arr = []
arr2 = []
arr3 = []

for i in range(1, A+1):
    if A % i == 0:
        arr.append(i)
    
for j in arr:
    if j <= B and B % j == 0:
        arr2.append(j)

for k in arr2:
    if k == 1:
        arr3.append(k)
    else:
        if isprime(k) == True:
            arr3.append(k)

print(len(arr3))

Submission status: Runtime Error

Solution code:
#include <stdio.h>
#include <iostream>

using namespace std;

int compute_greatest_common_divisor(int x, int y){
    // ユークリッド互除法
    int max_num = max(x, y);
    int min_num = min(x, y);

    int tmp1, tmp2;
    while (true){
        tmp1 = max_num;
        tmp2 = min_num;
        max_num = max(tmp1, tmp2);
        min_num = min(tmp1, tmp2);

        max_num = max_num % min_num;

        if (max_num == 0){
            break;
        }
    }

    return tmp2;
}

int search_answer(int N){
    // エラトステネスのふるい
    int data[N + 1];  // 探索したところに1が入る
    int result[N + 1];
    for (int i = 0; i <= N; i++){
        data[i] = 0;
        result[i] = 0;
    }
    
    int m = 2;
    int n = 0;

    while (true){
        if (data[m] == 0){
            for (int i = m; i <= N; i += m){
                data[i] = 1;
            }
        result[n] = m;
        n++;
        }
        m++;

        // 高々Nの半分まで素数を求めれば十分
        if (m > N / 2){
            break;
        }
    }

    // for (int i = 0; i <= N; i++){
        // cout << result[i] << " ";
    // }

    int cnt = 0;
    for (int i = 0; i <= N; i++){
        if (result[i] == 0){
            break;
        }
        if (N % result[i] == 0){
            cnt++;
        }
    }
    cnt++;  // 1の分必ず+1

    return cnt;
}


int main(){
    int A, B;
    cin >> A >> B;
    int x = compute_greatest_common_divisor(A, B);
    
    int p = search_answer(x);

    cout << p << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
from math import gcd as bltin_gcd


def coprime2(a, b):
    return bltin_gcd(a, b) == 1


a, b = 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


c = cf(a, b)
len_c = len(c)

d = [1]
for i in range(1, len(c)):
    coprime_flag = True
    for j in range(0, len(d)):
        if not coprime2(c[i], d[j]):
            coprime_flag = False
            break
    if coprime_flag:
        d.append(c[i])
print(len(d))

Submission status: Runtime Error

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


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


prime_list = era_prime(min(A, B))
ans = 1


for i in range(2, min(A, B)+1):
    if A % i == 0 and B % i == 0:
        if i in prime_list:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import numpy as np 
import math

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])


    return arr

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

Submission status: Runtime Error

Solution code:
from itertools import combinations
import math

ans=0
aaa=0

a,b=map(int,input().split())
c=(math.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:
    aaa=0
    if i>=3:
        for j in range(2,i):
            #print(i,j)
            if i%j==0:
                aaa=1
                break
            else:
                aab=0
    if aaa==0:
        ans+=1
print(ans)

Submission status: Runtime Error

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

minAB = min(A,B);

hurui = [True] * (minAB+1)

upper = int(math.sqrt(minAB+1))
ans = 1
for i in range(2, upper+1):
    if not(hurui[i]):
        continue
    
    for j in range(2*i, minAB+1, i):
        hurui[j] = False
    
    if A % i == 0  and B % i == 0:
        ans += 1
        
print(ans)

Submission status: Runtime Error

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

"""
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 cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
"""

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


a_L = divisor(a)
b_L = divisor(b)

kouyaku = set(a_L) & set(b_L)

new_L = []


for val in kouyaku:
    if is_prime(val):
        new_L.append(val)


new_L.append(1)


import itertools
import math 

counter =0

v = itertools.combinations(list(new_L),2)


for i in v:

    if math.gcd(i[0], i[1]) == 1:
        #print(i[0],i[1])
        counter +=1
#print(counter)

print(len(new_L))

Submission status: Runtime Error

Solution code:
import math

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

A,B=map(int,input().split())
#numには入力値の大きいほうの数字が入る
num = (min(A,B))
primeNum=[]
j=result=0
for i in range(2,num):
    if is_prime(i)==True:
      while A % i == 0 and B % i == 0:
        A = A // i
        B = B // i
        flag=True
      j+=1
      if flag==True:
        result+=1

      if min(A,B)<i:
        break  


# print("jikankeisoku")

# #primeNumにはmax(A,B)までの素数が入っている。素因数分解に使用する。
# resultNum=[0]*len(primeNum)
# result=1


# j=0
# result=0
# for i in primeNum:
#   flag=False
#   while A % i == 0 and B % i == 0:
#     A = A // i
#     B = B // i
#     resultNum[j]+=1
#     flag=True
#   j+=1
#   if flag==True:
#     result+=1

#   if min(A,B)<i:
#     break  
# # print(resultNum)
print(result+1)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(int(1e6))

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

import math
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]]

min_v = min(A, B)
if min_v < 2:
    primes = list()
else:
    primes = primes(min_v)

prime_factors_count = 0
for f in primes:
    if A % f:
        pass
    elif B % f:
        pass
    else:
        prime_factors_count += 1

print(prime_factors_count + 1)

Submission status: Runtime Error

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

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


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 {i: True for i in range(n + 1) if is_prime[i]}

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

    return divisors
x = gcd(A, B)
p = primes(x)
x = make_divisors(x)
print(len(x))

Submission status: Runtime Error

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

A,B=map(int,input().split())
#numには入力値の大きいほうの数字が入る
num = (min(A,B))
primeNum=[]
j=result=0
for i in range(2,100000):
    if is_prime(i)==True:
      while A % i == 0 and B % i == 0:
        A = A // i
        B = B // i
        flag=True
      j+=1
      if flag==True:
        result+=1

      if min(A,B)<i:
        break  


# print("jikankeisoku")

# #primeNumにはmax(A,B)までの素数が入っている。素因数分解に使用する。
# resultNum=[0]*len(primeNum)
# result=1


# j=0
# result=0
# for i in primeNum:
#   flag=False
#   while A % i == 0 and B % i == 0:
#     A = A // i
#     B = B // i
#     resultNum[j]+=1
#     flag=True
#   j+=1
#   if flag==True:
#     result+=1

#   if min(A,B)<i:
#     break  
# # print(resultNum)
print(result+1)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
n = min(a, b) // 2
t = list(range(2, n+1))
#for i in range(len(t)):
#    if t[i] == -1:
#        continue
#    if a % t[i] == 0 and b % t[i] == 0:
#        for j in range(i+1, len(t)):
#            if t[j] == -1:
#                continue
#            if t[j] % t[i] == 0:
#                print(t[j], t[i])
#                t[j] = -1
#    else:
#        t[i] = -1
print(1)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(int(1e6))

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

import math
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]]

min_v = min(A, B)
if min_v < 2:
    primes = list()
else:
    primes = primes(min_v//2)

prime_factors_count = 0
for f in primes:
    if A % f:
        pass
    elif B % f:
        pass
    else:
        prime_factors_count += 1

print(prime_factors_count + 1)

Submission status: Runtime Error

Solution code:
import numpy as np
import fractions
import sys

input = sys.stdin.readline


def primesfrom2to(n):
    """ Input n>=6, Returns a array of primes, 2 <= p < n """
    sieve = np.ones(n // 3 + (n % 6 == 2), dtype=np.bool)
    for i in range(1, int(n ** 0.5) // 3 + 1):
        if sieve[i]:
            k = 3 * i + 1 | 1
            sieve[k * k // 3 :: 2 * k] = False
            sieve[k * (k - 2 * (i & 1) + 4) // 3 :: 2 * k] = False
    return np.r_[1, 2, 3, ((3 * np.nonzero(sieve)[0][1:] + 1) | 1)]


def main():
    a, b = list(map(int, input().split()))
    # 10 ** 12
    # 愚直だと公約数を求めるだけでも時間切れする
    # 互いに素な公約数がほぼ素数などでは？
    g = fractions.gcd(a, b)
    print(len([i for i in primesfrom2to(g) if g % i == 0]))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from sympy import isprime
A,B = 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
result = cf(A,B)
res = 1
for i in result:
  a=isprime(i)
  if a==True:
    res += 1
print(res)

Submission status: Runtime Error

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

import numpy as np

if A > B:
    A_arr = np.array([A] * B)
    B_arr = np.array([B] * B)
    arr = np.arange(1, B + 1)
else:
    A_arr = np.array([A] * A)
    B_arr = np.array([B] * A)
    arr = np.arange(1, A + 1)

gcds = np.nonzero((A_arr % arr == 0) * (B_arr % arr == 0))[0] + 1

ret = set()

for i in gcds:
    for j in gcds:
        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

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

PF = prime_factorize(GCD)

PF = list(set(PF))

res = len(PF) + 1

print(res)

Submission status: Runtime Error

Solution code:
import math
A,B=map(int,input().split())
large=math.gcd(A,B)
ans=[]
for i in range(2,large+1): 
  if len(ans)>=1:
    if large%i==0: 
        count=0
        for k in ans:
            a=i%k
            if a!=0:
                count+=1
        if count==len(ans):
            ans.append(i)                
  else:
    if large%i==0:
      ans.append(i)

print(len(ans)+1)

Submission status: Runtime Error

Solution code:
import fractions

primes = [2]


def is_prime(n):
    for p in primes:
        if p * p > n:
            break
        if n % p == 0:
            return False

    return True


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

G = fractions.gcd(A, B)

res = 1

if G % 2 == 0:
    res += 1
    G /= 2

for i in range(3, G, 2):
    if i > G:
        break
    if not is_prime(i):
        continue
    primes.append(i)
    if G % i == 0:
        res += 1
        G /= i

if G > 1 and is_prime(G) and G not in primes:
    res += 1

print(res)