Language: C++

from collections import defaultdict
from itertools import chain


def gcd(a, b):
    # 最大公約数
    while b:
        a, b = b, a % b
    return a


def fast_prime_set(n):
    # nまでの素数リスト高速版 setで返す
    # chainの読み込みが必要！
    if n < 4:
        return ({}, {}, {2}, {2, 3})[n]
    n_sqrt = int(n ** 0.5) + 1
    primes = {2, 3} | set(chain(range(5, n + 1, 6), range(7, n + 1, 6)))
    for i in range(5, n_sqrt, 2):
        if i in primes:
            primes.difference_update(range(i * i, n, i * 2))
    return primes


def prime_factorization(x):
    # 素因数分解
    # 事前に素数のセットが必要
    primes = fast_prime_set(10 ** 6)

    fact = defaultdict(int)
    for prime in primes:
        while x % prime == 0:
            fact[prime] += 1
            x //= prime
        if x == 1:
            break
        if x in primes:
            fact[x] += 1
            break
    return fact


if __name__ == '__main__':
    a, b = map(int, input().split())
    gcd_a_b = gcd(a, b)
    prime_fact = prime_factorization(gcd_a_b)
    print(1 + len(prime_fact))

Compiler output:
a.cc:6:7: error: invalid preprocessing directive #\U00006700\U00005927\U0000516c\U00007d04\U00006570
    6 |     # 最大公約数
      |       ^~~~~~~~~~
a.cc:13:7: error: invalid preprocessing directive #n\U0000307e\U00003067\U0000306e\U00007d20\U00006570\U000030ea\U000030b9\U000030c8\U00009ad8\U0000901f\U00007248
   13 |     # nまでの素数リスト高速版 setで返す
      |       ^~~~~~~~~~~~~~~~~~~~~~~
a.cc:14:7: error: invalid preprocessing directive #chain\U0000306e\U00008aad\U0000307f\U00008fbc\U0000307f\U0000304c\U00005fc5\U00008981\U0000ff01
   14 |     # chainの読み込みが必要！
      |       ^~~~~~~~~~~~~~~~~~~~~~~
a.cc:26:7: error: invalid preprocessing directive #\U00007d20\U000056e0\U00006570\U00005206\U000089e3
   26 |     # 素因数分解
      |       ^~~~~~~~~~
a.cc:27:7: error: invalid preprocessing directive #\U00004e8b\U0000524d\U0000306b\U00007d20\U00006570\U0000306e\U000030bb\U000030c3\U000030c8\U0000304c\U00005fc5\U00008981
   27 |     # 事前に素数のセットが必要
      |       ^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:43:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   43 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import defaultdict
      | ^~~~
a.cc:16:19: error: expected unqualified-id before ',' token
   16 |         return ({}, {}, {2}, {2, 3})[n]
      |                   ^
a.cc:16:21: error: expected unqualified-id before '{' token
   16 |         return ({}, {}, {2}, {2, 3})[n]
      |                     ^
a.cc:16:23: error: expected unqualified-id before ',' token
   16 |         return ({}, {}, {2}, {2, 3})[n]
      |                       ^
a.cc:16:25: error: expected unqualified-id before '{' token
   16 |         return ({}, {}, {2}, {2, 3})[n]
      |                         ^
a.cc:16:28: error: expected unqualified-id before ',' token
   16 |         return ({}, {}, {2}, {2, 3})[n]
      |                            ^
a.cc:16:30: error: expected unqualified-id before '{' token
   16 |         return ({}, {}, {2}, {2, 3})[n]
      |                              ^
a.cc:16:36: error: expected unqualified-id before ')' token
   16 |         return ({}, {}, {2}, {2, 3})[n]
      |                                    ^
a.cc:18:21: error: expected unqualified-id before '|' token
   18 |     primes = {2, 3} | set(chain(range(5, n + 1, 6), range(7, n + 1, 6)))
      |                     ^