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):
    while y:
        x, y = y, x % y
    return x


a, b = [int(x) for x in input().split(' ')]

g = gcd(a,b)
print("g =", g)
ret: int = 1
i = 2
while i * i <= g:
    if g % i == 0:
        print("i =", i)
        while g % i == 0:
            g /= i
        ret += 1
    i += 1     
        
if g > 1:
    ret += 1
    
print(ret)

import math

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


a, b = [int(x) for x in input().split(' ')]

g = gcd(a,b)
ret = 1

for i in range(2, int(math.sqrt(g))):
    if g % i == 0:
        while g % i == 0:
            g /= i
        ret += 1
        
if g > 1:
    ret += 1
    
print(ret)


def divisors(n, limit):
    # get factors and their counts
    factors = {}
    nn = n
    i = 2
    while i*i <= nn and i <= limit:
        while nn % i == 0:
            factors[i] = factors.get(i, 0) + 1
            nn //= i
        i += 1
    if nn > 1:
        factors[nn] = factors.get(nn, 0) + 1
 
    primes = list(factors.keys())
 
    # generates factors from primes[k:] subset
    def generate(k):
        if k == len(primes):
            yield 1
        else:
            rest = generate(k+1)
            prime = primes[k]
            for factor in rest:
                prime_to_i = 1
                # prime_to_i iterates prime**i values, i being all possible exponents
                for _ in range(factors[prime] + 1):
                    yield factor * prime_to_i
                    prime_to_i *= prime
 
    # in python3, `yield from generate(0)` would also work
    for factor in generate(0):
        yield factor
 
def common_elements(list1, list2):
    return list(set(list1).intersection(list2))
 
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
 
def coprime(a, b):
    return gcd(a, b) == 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 False
 
  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
 
a, b = [int(x) for x in input().split(' ')]
 
a, b = (a, b) if a <= b else (b, a)
 
la = list(divisors(a, 1e12 + 10))
lb = list(divisors(b, a))
la, lb = (la, lb) if len(la) <= len(lb) else (lb, la)
 
commonDivs = common_elements(la, lb)
 
primes = [x for x in commonDivs if is_prime(x)]
 
count = 0
 
for i in range(len(primes) - 1):
  x = primes[i]
  for j in range(i+1, len(primes)):
    y = primes[j]
    if coprime(x, y) == 1:
      count += 1
 
if primes == [1]:
  print(1)
else: 
  print(count + 1)

import math

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


a, b = [int(x) for x in input().split(' ')]

g = gcd(a,b)
print("g =", g)
ret: int = 1

for i in range(2, int(math.sqrt(g))+1):
    if g % i == 0:
        print("i =", i)
        while g % i == 0:
            g /= i
        ret += 1
        
if g > 1:
    ret += 1
    
print(ret)

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


a, b = [int(x) for x in input().split(' ')]

g = gcd(a, b)
ret = 1
i = 2
while i * i <= g:
    if g % i == 0:
        while g % i == 0:
            g /= i
        ret += 1
    i += 1

if g > 1:
    ret += 1

print(ret)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted