TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
from collections import defaultdict


def gcd(a, b):
    if a > b:
        return gcd(b, a)
    # a <= b
    if a == 0:
        return b
    else:
        r = b % a
        return gcd(r, a)


def prime_factorization(n):
    factors = defaultdict(int)
    i = 1
    n_sub = n
    while True:
        i += 1
        if i * i > n or n_sub == 1:
            break

        while n_sub % i == 0:
            n_sub = n_sub // i
            factors[i] += 1

    if len(factors) == 0:
        factors[n] = 1
    return factors


def main():
    a, b = map(int, input().split())
    g = gcd(a, b)
    if g == 1:
        return 1
    primes = prime_factorization(g)
    # add "1"
    return len(primes) + 1
    

print(main())


from collections import defaultdict


def gcd(a, b):
    if a > b:
        return gcd(b, a)
    # a <= b
    if a == 0:
        return b
    else:
        r = b % a
        return gcd(r, a)


def prime_factorization(n):
    factors = defaultdict(int)
    i = 1
    n_sub = n
    while True:
        i += 1
        if i * i > n or n_sub == 1:
            break

        while n_sub % i == 0:
            n_sub = n_sub // i
            factors[i] += 1

    if n_sub != 1:
        factors[n_sub] = 1
    return factors


def main():
    a, b = map(int, input().split())
    g = gcd(a, b)
    if g == 1:
        return 1
    primes = prime_factorization(g)
    # add "1"
    return len(primes) + 1
    

print(main())


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def pf(N):
    res = []
    x = N
    y = 2
    while y*y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1:
        res.append(x)
    return res

def main():
    a, b = map(int, input().split())
    print(len(Counter(pf(gcd(a,b)))))

if __name__ == "__main__":
    main()

from collections import Counter

def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def pf(N):
    res = []
    x = N
    y = 2
    while y*y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1:
        res.append(x)
    return res

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

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math

a, b = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
ab_gcd = gcd(a, b)
gcd_sq = int(math.sqrt(ab_gcd) + 1)
ans = []
curr_num = ab_gcd
for i in range(2, gcd_sq + 1):
    print(i, curr_num)
    if curr_num % i != 0:
        continue
    cnt = 0
    while curr_num % i == 0:
        curr_num = curr_num // i
        cnt += 1
    ans.append([i, cnt])
print(len(ans) + 1)

import math

a, b = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
ab_gcd = gcd(a, b)

gcd_sq = int(math.sqrt(ab_gcd) + 1)

ans = []
curr_num = ab_gcd
for i in range(2, gcd_sq):
    if curr_num % i != 0:
        continue
    cnt = 0
    while curr_num % i == 0:
        curr_num = curr_num // i
        cnt += 1
    ans.append([i, cnt])
if curr_num != 1:
    ans.append([curr_num, 1])
print(len(ans) + 1)    

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys
sys.setrecursionlimit(10**8)

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

primes = []
for i in range(2, 10**3+10):
    if all(i%p for p in primes):
        primes.append(i)


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

g = gcd(A, B)
count = 0
for p in primes:
    if g < p:
        break
    if g%p == 0:
        count += 1
    while g%p == 0:
        g //= p
if g:
    count += 1

print(count+1)


import sys
sys.setrecursionlimit(10**8)

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

primes = []
for i in range(2, 10**3+10):
    if all(i%p for p in primes):
        primes.append(i)


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

g = gcd(A, B)
count = 0
for p in primes:
    if g < p:
        break
    if g%p == 0:
        c += 1

print(count+1)


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

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

g = gcd(A, B)
print(g)
primes = []
l = [1]
for i in range(2, g+1):
    # print(l)
    if all(i%p for p in primes):
        primes.append(i)
        if g%i == 0:
            l.append(i)

print(len(l))


import sys
sys.setrecursionlimit(10**8)

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

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

g = gcd(A, B)
count = 0
for i in range(2, 10**6+3):
    if g%p == 0:
        count += 1
    while g%p == 0:
        g //= p
if g != 1:
    count += 1

print(count+1)

import sys
sys.setrecursionlimit(10**8)

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

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

g = gcd(A, B)
count = 0
for i in range(2, 10**6+3):
    if g%i == 0:
        count += 1
    while g%i == 0:
        g //= i
if g != 1:
    count += 1

print(count+1)


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def gcd(x,y):
  n,m = min(x,y), max(x,y)
  while n!=0:
    n, m = m%n, n
  
  return m

def prime(N):
  p = [i+1 for i in range(N)]
  for i in range(2,N+1):
    p = [i_p for i_p in p if i_p%i!=0 or i_p/i==1]

  return p
def prime_factorization(N):
  n = N
  P = prime(int(N**0.5))
  p_f = [1]
  while n != 1:
    for p in P[1:]:
      if n%p == 0:
        p_f.append(p)
        n = n / p
        break
  return p_f

A, B = list(map(int, input().split(" ")))
print(len(set(prime_factorization(gcd(A, B)))))

def gcd(x,y):
  n,m = min(x,y), max(x,y)
  while n!=0:
    n, m = m%n, n
  
  return m

def prime(N):
  p = [i+1 for i in range(N)]
  for i in range(2,N+1):
    p = [i_p for i_p in p if i_p%i!=0 or i_p/i==1]

  return p
def prime_factorization(N):
  n = N
  P = prime(int(N**0.5))
  p_f = [1]
  while n != 1:
    for p in P[1:]:
      if n%p == 0:
        p_f.append(p)
        n = n / p
        break
  return p_f
A, B = list(map(int, input().split(" ")))
print(len(set(prime_factorization(gcd(A, B))))

def gcd(x,y):
  n,m = min(x,y), max(x,y)
  while n!=0:
    n, m = m%n, n
  
  return m

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

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

Verdicts: Time Limit Exceeded

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math
import fractions

def divisors(n):
    s = set()
    for x in range(2, math.ceil(n ** 0.5) + 1):
        while n % x == 0:
            s.add(x)
            n //= x
    return s

a, b = map(int, input().split())
print(len(divisors(fractions.gcd(a, b))) + 1)


def divisors(n):
    s = set()
    for x in range(2, int(n ** 0.5) + 1):
        if n % x == 0:
            s.add(x)
            s.add(n // x)
    return s

a, b = map(int, input().split())
d = divisors(a) & divisors(b)
print(len(d) + 1)


import math

def divisors(n):
    s = set()
    for x in range(2, math.ceil(n ** 0.5) + 1):
        while n % x == 0:
            s.add(x)
            n /= x
            if n == 1:
                break
    if n > 1:
        s.add(n)
    return s
 
a, b = map(int, input().split())
d = divisors(a) & divisors(b)
print(len(d) + 1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from fractions import gcd
import functools
a,b=map(int,input().split())

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

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

frac=cf(a,b)
n=len(frac)
ans=0
for i in range(n):
  if is_prime(frac[i]):
    ans+=1
print(ans+1)

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 random

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

    
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        
        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
  
div=list(set(make_divisors(a))&set(make_divisors(b)))
n=len(div)
ans=0
for i in range(n):
  if is_prime(div[i]):
    ans+=1
print(ans+1)

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
a, b = map(int, input().split())
yakusu_a = []
import math
for i in range(1, int(math.sqrt(a))):
  if a % i == 0:
    yakusu_a.append(i)
    if i != a//i:
      yakusu_a.append(a//i)

cd_list = []
for e in yakusu_a:
  if b % e == 0:
    cd_list.append(e)

cd_list = sorted(cd_list)
def furui(lst):
  data = lst
  ans = []
  while len(data) > 0:
    sentou = data[0]
    ans.append(sentou)
    data = [i for i in data if i % sentou != 0]
  return ans

print(len(furui(cd_list[1:]))+1)

a, b = map(int, input().split())
yakusu_a = []
import math
for i in range(1, int(math.sqrt(a))+1):
  if a % i == 0:
    yakusu_a.append(i)
    if i != a//i:
      yakusu_a.append(a//i)

cd_list = []
for e in yakusu_a:
  if b % e == 0:
    cd_list.append(e)

cd_list = sorted(cd_list)

def furui(lst):
  data = lst
  ans = []
  while len(data) > 0:
    sentou = data[0]
    ans.append(sentou)
    data = [i for i in data if i % sentou != 0]
  return ans

print(len(furui(cd_list[1:]))+1)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
global primeList
primeList = []

def primeFactorize(X):
  global primeList
  result = set()
  for prime in primeList:
      if X % prime == 0:
        result.add(prime)
  return result

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

isPrime = [True for i in range(1000001)]
isPrime[0] = isPrime[1] = False;
primeList.append(2)
for i in range(4,1000001,2):
  isPrime[i] = False

for i in range(3,1000001,2):
    if not isPrime[i]:
      continue
    primeList.append(i)
    for j in range(i, 1000001//i + 1):
      isPrime[i*j] = False

pA = primeFactorize(A)
pB = primeFactorize(B)
print(len(pA.intersection(pB)) + 1)




global primeList
primeList = []

def primeFactorize(X):
  global primeList
  result = set()
  for prime in primeList:
      while X % prime == 0:
        result.add(prime)
        X //= prime
  if X != 1:
      result.add(X)
  return result

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

isPrime = [True for i in range(1000001)]
isPrime[0] = isPrime[1] = False;
primeList.append(2)
for i in range(4,1000001,2):
  isPrime[i] = False

for i in range(3,1000001,2):
    if not isPrime[i]:
      continue
    primeList.append(i)
    for j in range(i, 1000000//i + 1):
      isPrime[i*j] = False

pA = primeFactorize(A)
pB = primeFactorize(B)
print(len(pA.intersection(pB)) + 1)




Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

    
    return divisors

A,B=map(int, input().split())
if (A==1)or(B==1)or(coprime(A,B)):
  print(1)
else:
  A=make_divisors(A)
  B=make_divisors(B)
  C=list(set(A)&set(B))
  C=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)

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)

    
    return divisors

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):

a,b = map(int,input().split())
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
def waru(max_gcd,x):
    if max_gcd%x != 0:
        return max_gcd
    else:
        return waru(max_gcd/i,x)

count = 0
max_gcd = gcd(a,b)

for i in range(2,max_gcd+1):
    if i > max_gcd//2:
        break
    if max_gcd%i == 0:
        count += 1
        max_gcd = waru(max_gcd,i)
print(count+1)



a,b = map(int,input().split())
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
def waru(max_gcd,x):
    if max_gcd%x != 0:
        return max_gcd
    else:
        return waru(max_gcd//i,x)

count = 0
max_gcd = gcd(a,b)

for i in range(2,max_gcd+1):
    if i*i > max_gcd:
        break
    if max_gcd%i == 0:
        count += 1
        max_gcd = waru(max_gcd,i)
if max_gcd == 1:
    print(count+1)
else:
    print(count+2)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b = list(map(int,input().split()))
l = []

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

dl = list(set(make_divisors(a)) & set(make_divisors(b)))
dl.sort(reverse = True)

del dl[dl.index(1)]
ans = [1]
flag=True

while(dl!=[]):
    x = dl.pop(0)
    print(x)
    for i in dl:
        if x%i==0:
            flag=False
            break
    if flag:
        ans.append(x)
    flag=True
print(len(ans))

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

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

dl = list(set(make_divisors(a)) & set(make_divisors(b)))
dl.sort(reverse = True)


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

del dl[dl.index(1)]
ans = [1]
flag=True
j=0
while(j<len(dl)):
    x = dl.pop(0)
    for i in dl:
        if gcd(x,i)==1:
            next
        else:
            flag=False
            break
    if flag:
        ans.append(x)
    flag=True
print(len(ans))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# from pprint import pprint
# import math
# import collections

# n = int(input())
a, b = map(int, input().split(' '))


# a = list(map(int, input().split(' ')))


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

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

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

    return arr


fact_a = set([f[0] for f in factorization(a)])
fact_b = set([f[0] for f in factorization(b)])

ans = fact_a & fact_b

print(len(ans))


# from pprint import pprint
# import math
# import collections

# n = int(input())
a, b = map(int, input().split(' '))


# a = list(map(int, input().split(' ')))


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.55 // 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


fact_a = set([f[0] for f in factorization(a)])
fact_b = set([f[0] for f in factorization(b)])

ans = fact_a & fact_b
ans.add(1)

# print(fact_a, fact_b)
print(len(ans))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math

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

G = math.gcd(a,b)
L = []

for i in range(2,int(math.sqrt(G))+1):
    if G%i==0:
        for j in L:
            if i%j==0:
                break
        else:
            L.append(i)

print(len(L)+1)

from math import sqrt

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

L = []

if a < b: a,b = b,a
while b!=0:
    r = a%b
    a,b = b,r
    
G = a

for i in range(2,G+1):
    for j in L:
        if i%j==0: 
            break
        if G%i==0: 
            L.append(i)

print(len(L)+1)   

from math import sqrt

a,b = map(int,input().split())
 
L = []
 
if a < b: a,b = b,a
while b!=0:
    r = a%b
    a,b = b,r
 
G = a
 
for i in range(2,int(sqrt(G))+1):
    if G%i==0:
        L.append(i)
        while G%i==0:
            G/=i

if G!=1:
    L.append(G)

print(len(L)+1) 

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
A,B = [int(i) for i in input().split()]

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

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return(data)

n=gcd(A,B)
ans = 1
if n==1:
    print(1)
else:
    
    #for p in plist:
    for p in range(2,int(n**0.5)+1):
        if n==1:
            break
        if n%p==0:
            n = n//p
            ans+=1

    print(ans)


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

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

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return(data)

n=gcd(A,B)
ans = 1
if n==1:
    print(1)
else:
    
    #for p in plist:
    for p in range(2,int(n**0.5)+3):
        if n%p==0:
            ans+=1
            while n%p==0:
                n = n//p
    if n!=1:
        ans+=1
    print(ans)



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from math import sqrt

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

p = a
q = b
r = p % q
while r > 0:
  p = q
  q = r
  r = p % q
sgd = q

d = 2
max_d = int(sqrt(sgd))
count = 1
while sgd > 1 and d <= max_d:
  d_flag = False
  while sgd % d == 0:
    d_flag = True
    sgd //= d
  if d_flag:
    count += 1
    
print(count)

from math import sqrt

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

p = a
q = b
r = p % q
while r > 0:
  p = q
  q = r
  r = p % q
sgd = q

d = 2
max_d = int(sqrt(sgd))
count = 1
while sgd > 1 and d <= max_d:
  d_flag = False
  while sgd % d == 0:
    d_flag = True
    sgd //= d
  if d_flag:
    count += 1
  d += 1
    
print(count)

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

p = a
q = b
r = p % q
while r > 0:
  p = q
  q = r
  r = p % q
sgd = q

d = 2
count = 1
while d * d <= sgd:
  d_flag = False
  while q % d == 0:
    d_flag = True
    q //= d
  if d_flag:
    count += 1
  if d == 2:
    d = 3
  else:
    d += 2
if q > 1:
  count += 1
    
print(count)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def gcd(a,b):
	if a==0:
		return(b)
	return(gcd(b%a,a))
a,b=map(int,input().split())
g=gcd(a,b)
divide=2
ans=1
if g%divide==0:
	ans+=1
	while(g%divide==0 and g!=0):
		g//=divide
for divide in range(3,int(g**(1/2))+1,2):
	if g%divide==0:
		ans+=1
		while(g%divide==0 and g!=0):
			g//=divide
	divide+=1
print(ans)

def gcd(a,b):
	if a==0:
		return(b)
	return(gcd(b%a,a))
a,b=map(int,input().split())
g=gcd(a,b)
ans=1
if g%2==0:
	ans+=1
	while(g%2==0):
		g//=2
for divide in range(3,g,2):
	if g%divide==0:
		ans+=1
		while(g%divide==0):
			g//=divide
print(ans)

def gcd(a,b):
	if a==0:
		return(b)
	return(gcd(b%a,a))
a,b=map(int,input().split())
g=gcd(a,b)
divide=2
ans=1
if g%divide==0:
	ans+=1
	while(g%divide==0):
		g//=divide
for divide in range(3,int(g**(1/2))+2,2):
	if g%divide==0:
		ans+=1
		while(g%divide==0):
			g//=divide
	divide+=1
print(ans)

from math import sqrt
def gcd(a,b):
	if a==0:
		return(b)
	return(gcd(b%a,a))
a,b=map(int,input().split())
g=gcd(a,b)
ans=1
if g%2==0:
	ans+=1
	while(g%2==0):
		g//=2
for divide in range(3,int(sqrt(g))+1,2):
	if g%divide==0:
		ans+=1
		while(g%divide==0):
			g//=divide
if g>2:
	ans+=1
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math


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


def trial_division(n):
    
    factor = []
    
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor


a, b = map(int, input().split())
c = gcd(a, b)
d = trial_division(c)
print(len(set(d)))


import math


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


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


a, b = map(int, input().split())
c = gcd(a, b)
d = factorize(c)
print(len(set(d))+1)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math
from itertools import combinations
A,B = map(int,input().split())

def make_co_divisors(a,b):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= a:
        if a % i == 0:
            lower_divisors.append(i)
            if i != a // i:
                upper_divisors.append(a//i)
        i += 1
    divisors = lower_divisors + upper_divisors[::-1]
    co_divisors = []
    for d in divisors:
      if b % d == 0:
        co_divisors.append(d)
    return co_divisors
  
def gcd_checker(x,y):
  if math.gcd(x,y) == 1:
    return True
  else:
    return False

xy = list(combinations(make_co_divisors(A,B),2))
cnt = 0
for (x,y) in xy:
  if gcd_checker(x,y):
    cnt += 1

if cnt == 0:
  print(1)
else:
  print(cnt)

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

def prime_num_check(x):
  ls = []
  ls.append(1)
  for i in range(2,x+1):
    factor = 0
    if i%2 == 0 and i != 2:
      continue
    for divisor in range(2,math.floor(math.sqrt(i))+1):
      if i%divisor == 0:
        factor += 1
    if factor == 0:
      ls.append(i)
    return ls
  
x = math.gcd(A,B)

c_divisor = prime_num_check(x)
res = len(c_divisor) * (len(c_divisor) - 1) // 2

print(res)

import math
A,B = map(int,input().split())
x = math.gcd(A,B)

def prime_decomposition(x):
  i = 2
  ls = []
  while i * i <= x:
    while x % i == 0:
      x /= i
      ls.append(i)
    i += 1
  if x > 1:
    ls.append(x)
  return ls

cnt = len(set(prime_decomposition(x)))

print(cnt+1)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import fractions
A,B = map(int,input().split())

L = range(2,fractions.gcd(A,B)+1)
# print(list(L))
prime = []

for i in L:
    if (A%i != 0) or (B%i != 0):
        continue

    primecheck = True
    for j in prime:
        if i%j == 0:
            primecheck = False

    if primecheck == True:
        prime.append(i)
prime.append(1)


print(len(prime))

A,B = map(int,input().split())
N = max(A,B)
prime = []

tA = A
tB = B
for i in range(2, int(-(-N**0.5//1))+1):
    if tA%i==0 and tB%i==0:
        while tA%i==0:
            tA //= i
        while tB%i==0:
            tB //= i
        prime.append(i)

if tA!=1 and tA == tB:
    prime.append(tA)

if prime==[]:
    prime.append(1)



print(len(prime))

A,B = map(int,input().split())
N = max(A,B)
prime = []

tA = A
tB = B
for i in range(2, int(-(-N**0.5//1))+1):
    if tA%i==0 and tB%i==0:
        while tA%i==0:
            tA //= i
        while tB%i==0:
            tB //= i
        prime.append(i)

if tA!=1 and tA == tB:
    prime.append(tA)


print(prime)
print(len(prime)+1)

import math
A,B = map(int,input().split())
N = max(A,B)
prime = []

tA = A
tB = B
for i in range(2, math.ceil(N**0.5)+1):
    Aflag = False
    Bflag = False
    if tA%i==0:
        Aflag = True
        while tA%i==0:
            tA //= i
    if tB%i==0:
        Bflag = True
        while tB%i==0:
            tB //= i
    if Aflag == True and Bflag == True:
        prime.append(i)

if tA!=1 and tA == tB:
    prime.append(tA)


print(len(prime)+1)

Verdicts: Time Limit Exceeded

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b = map(int,input().split())

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

n = gcd(a,b)
m = n//2
x = [(i+1) for i in range(m)]
ans = 1

for i in range(m):
    if x[i]!=1:
        if n % x[i]==0:
            ans += 1
        tmp = x[i]
        for j in range(m//tmp):
            x[j*tmp-1] = 1
       

print(ans)

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

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

n = gcd(a,b)
m = n
ans = 1

if m%2==0:
    ans += 1
    while m%2==0:
        m //= 2
f = 3

while f*f <= n:
    if m%f==0:
        ans += 1
        while m%f==0:
            m //= f
    f+=2

if m!=1:
    ans += 1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from math import sqrt

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

divisors = []

mini = min(a, b)
maxi = max(a, b)


x = 2
while mini > 1:
    for i in range(x, mini+1):
        if mini % i == 0 and maxi % i == 0:
            divisors.append(i)
            while mini % i == 0:
                mini //= i
                x = i + 1
            break
    break

        



if len(divisors) <= 1:
    ans = 1
else:
    
    divisors = divisors[1:]
    p = 0
    idx = 0
    while p <= sqrt(divisors[-1]):
        p = divisors[idx]
        for div in divisors[1:]:
            if div % p == 0:
                divisors.remove(div)
        idx += 1

    ans = len(divisors)

print(ans)



from math import sqrt, ceil

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

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

d = gcd(a, b)
ans = 1
for i in range(2, ceil(sqrt(d))+1):
  if d % i == 0:
    ans += 1
    while(d % i == 0):
      d = d / i
if d != 1:
    ans += 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
A, B = map(int, input().split())

def mygcd(a, b):
    if a < b:
        return mygcd(b, a)
    elif b == 0:
        return a
    else:
        return mygcd(b, a % b)

gcd = mygcd(A, B)

import math

pfac = {}
gcd_tmp = gcd
for p in range(2, int(math.sqrt(gcd)) + 1):
    if gcd_tmp < 2: break
    if gcd_tmp % p == 0:
        i_p = 0
        while gcd_tmp % p == 0:
            gcd_tmp //= p
            i_p += 1
        #
        pfac[str(p)] = i_p

# print("#", pfac)
        
print(1 + len(pfac))

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

def mygcd(a, b):
    if a < b:
        return mygcd(b, a)
    elif b == 0:
        return a
    else:
        return mygcd(b, a % b)

gcd = mygcd(A, B)

import math

pfac = {}
gcd_tmp = gcd
for p in range(2, int(math.sqrt(gcd)) + 1):
    if gcd_tmp < 2: break
    if gcd_tmp % p == 0:
        i_p = 0
        while gcd_tmp % p == 0:
            gcd_tmp //= p
            i_p += 1
        #
        pfac[str(p)] = i_p
else:
    if gcd_tmp > 1: pfac[str(gcd_tmp)] = 1
    
# print("#", pfac)
        
print(1 + len(pfac))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
A, B = map(int, input().split())
cf = []
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

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

for i in range(1, min(A, B) + 1):
  if A % i == 0 and B % i == 0:
    cf.append(i)
ans = set()
for i in range(len(cf)):
  j = i + 1
  for j in range(len(cf)):
    if coprime(cf[i], cf[j]) == True:
      ans.add(cf[i])
      ans.add(cf[j])
print(len(ans))
    


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

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

x = set(prime_decomposition(A))
y = set(prime_decomposition(B))
print(len(x & y) + 1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
A, B = map(int, input().split())


def prime_numbers(N):
    n = N
    res = []
    for i in range(2, n):
        if i * i >= n: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.append(i)
    res.append(N)
    return res


a = prime_numbers(A)
b = prime_numbers(B)
ans = min(len(a), len(b)) + 1
print(ans)


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


def prime_numbers(N):
    n = N
    res = set()
    for i in range(2, n):
        if i * i >= n: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.add(i)
    res.add(N)
    res.add(1)
    return res


a = prime_numbers(A)
b = prime_numbers(B)
#print(a, b)
#print(a.intersection(b))
ans = len(a.intersection(b))
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from math import *
def eratosthenes(n):
    table = [0] * (n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
                
    return prime_list
a,b = map(int,input().split())
pl = set(eratosthenes(int(sqrt(min(a,b)))))
common_factor = [ i for i in range(1,int(sqrt(min(a,b)))) if a % i == 0 and b % i == 0]
ans = 0
for i in common_factor:
    if i in pl:
        ans += 1
print(ans + 1)

from math import *

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 eratosthenes(n):
    table = [0] * (n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
                
    return prime_list

a,b = map(int,input().split())
upper = 10**8
ans = set(eratosthenes(upper)) & make_divisors(a) & make_divisors(b)
print(len(ans) + 1)

def factorize(n):
    fct = set()
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.add(b)
        b,e = b+1,0
    if n > 1:
        fct.add(n)
    return fct
a,b = map(int,input().split())
print(len(factorize(a)&factorize(b))+1)

Verdicts: Wrong Answer

Time Limit Exceeded

Accepted