Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
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


#nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

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

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

di_A = make_divisors(A)
di_B = make_divisors(B)

di_C = list(set(di_A) & set(di_B))
if len(di_C)==1:
    print(1)
    exit()

ans = 0
array = []
array_not = []
edges = [[False] * len(di_C) for _ in range(len(di_C))]
for i in range(len(di_C)):
    for j in range(i+1, len(di_C)):
        if gcd(di_C[i], di_C[j])==1:
            edges[i][j]=True

for num in range(len(di_C), 0, -1):
    fraction = combinations(range(len(di_C)), num)
    for relation in fraction:
        judge = []
        for i, j in combinations(relation, 2):
            judge.append(edges[i][j])
        if all(judge):
            ans = num
            print(ans)
            exit()
print(ans)



Fixed submission:


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



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

fac_A = factorization(A)
fac_B = factorization(B)

prime_A = [f[0] for f in fac_A]
prime_B = [f[0] for f in fac_B]

if 1 in prime_A: prime_A.remove(1)
if 1 in prime_B: prime_B.remove(1)
common = set(prime_A) & set(prime_B)
print(len(common)+1)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
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


#nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

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

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

di_A = make_divisors(A)
di_B = make_divisors(B)

di_C = list(set(di_A) & set(di_B))
if len(di_C)==1:
    print(1)
    exit()

ans = 0
array = []
array_not = []
edges = [[False] * len(di_C) for _ in range(len(di_C))]
for i in range(len(di_C)):
    for j in range(i+1, len(di_C)):
        if gcd(di_C[i], di_C[j])==1:
            edges[i][j]=True

for num in range(len(di_C), 0, -1):
    fraction = combinations(range(len(di_C)), num)
    for relation in fraction:
        judge = []
        for i, j in combinations(relation, 2):
            judge.append(edges[i][j])
        if all(judge):
            ans = num
            print(ans)
            # 最大派閥議員数が分かればよいので終了
            exit()
print(ans)



Fixed submission:


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



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

fac_A = factorization(A)
fac_B = factorization(B)

prime_A = [f[0] for f in fac_A]
prime_B = [f[0] for f in fac_B]

if 1 in prime_A: prime_A.remove(1)
if 1 in prime_B: prime_B.remove(1)
common = set(prime_A) & set(prime_B)
print(len(common)+1)