Buggy python submission (verdict: Time Limit Exceeded):
# def max_comn_div(n, m):
#     """give max common divisor"""
#     if n > m:
#         a, b = n, m
#     else:
#         a, b = m, n
#     while b != 0:
#         a, b = b, a % b
#     return a


# a = int(input())
# b = int(input())
# print(max_comn_div(a, b))

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


def euc(a, b):
    return b if a % b == 0 else euc(b, a % b)


def div(n):
    """give divisors"""
    divisors = [1]
    i = 2
    while n > 1:
        if n % i == 0:
            divisors.append(i)
            while n % i == 0:
                n = n/i
        i += 1
    return divisors


a, b = map(int, input().split())
c = div(euc(a, b))
print(len(c))


Fixed submission:
# def max_comn_div(n, m):
#     """give max common divisor"""
#     if n > m:
#         a, b = n, m
#     else:
#         a, b = m, n
#     while b != 0:
#         a, b = b, a % b
#     return a


# a = int(input())
# b = int(input())
# print(max_comn_div(a, b))

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


def euc(a, b):
    return b if a % b == 0 else euc(b, a % b)


def div(n):
    """give divisors"""
    divisors = [1]
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            divisors.append(i)
            n /= i
    if n != 1:
        divisors.append(int(n))
    return set(divisors)


a, b = map(int, input().split())
# print(euc(a, b))
c = div(euc(a, b))
# print(c)
print(len(c))

Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())


def div(n):
    """give divisors"""
    divisors = [1]
    i = 2
    while n > 1:
        if n % i == 0:
            divisors.append(i)
            while n % i == 0:
                n = n/i
        i += 1
    return(divisors)


def comn_div(n, m):
    """give common divisors"""
    # 二つの約数を取って来てset&set
    cdiv_nm = set(div(n)) & set(div(m))
    return(list(cdiv_nm))
# 自然数以外が入ったら弾きたい気もする


cdiv_ab = comn_div(a, b)
disjoint = []
for i in range(len(cdiv_ab)):
    state = True
    # 自分より若い数字が約数の場合は除外
    for j in range(i):
        if comn_div(cdiv_ab[i], cdiv_ab[j]) != [1]:
            state = False
    if state:
        disjoint.append(i)
# print(cdiv_ab)
# print(disjoint)
print(len(disjoint))


Fixed submission:
# def max_comn_div(n, m):
#     """give max common divisor"""
#     if n > m:
#         a, b = n, m
#     else:
#         a, b = m, n
#     while b != 0:
#         a, b = b, a % b
#     return a


# a = int(input())
# b = int(input())
# print(max_comn_div(a, b))

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


def euc(a, b):
    return b if a % b == 0 else euc(b, a % b)


def div(n):
    """give divisors"""
    divisors = [1]
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            divisors.append(i)
            n /= i
    if n != 1:
        divisors.append(int(n))
    return set(divisors)


a, b = map(int, input().split())
# print(euc(a, b))
c = div(euc(a, b))
# print(c)
print(len(c))

Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())


# 公約数をリストとして得る
def comn_div(n, m):
    """give common divisor"""
    div_n = []
    div_m = []
    for i in range(1, n+1):
        if n % i == 0:
            div_n.append(i)
    for j in range(1, m+1):
        if m % j == 0:
            div_m.append(j)
    cdiv_nm = set(div_n) & set(div_m)
    return(list(cdiv_nm))
# 自然数以外が入ったら弾きたい


cdiv_ab = comn_div(a, b)
disjoint = []
for i in range(len(cdiv_ab)):
    state = True
    # 自分より若い数字が約数の場合は除外
    for j in range(i):
        if comn_div(cdiv_ab[i], cdiv_ab[j]) != [1]:
            state = False
    if state:
        disjoint.append(i)
# print(cdiv_ab)
# print(disjoint)
print(len(disjoint))


Fixed submission:
# def max_comn_div(n, m):
#     """give max common divisor"""
#     if n > m:
#         a, b = n, m
#     else:
#         a, b = m, n
#     while b != 0:
#         a, b = b, a % b
#     return a


# a = int(input())
# b = int(input())
# print(max_comn_div(a, b))

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


def euc(a, b):
    return b if a % b == 0 else euc(b, a % b)


def div(n):
    """give divisors"""
    divisors = [1]
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            divisors.append(i)
            n /= i
    if n != 1:
        divisors.append(int(n))
    return set(divisors)


a, b = map(int, input().split())
# print(euc(a, b))
c = div(euc(a, b))
# print(c)
print(len(c))