Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03289 (python)

Fixed submission:
s = input()

if s[0]=='A' and s[2:-1].count('C')==1 and (s[1:s.find('C')]+s[s.find('C')+1:]).islower():
    print('AC')
else:
    print('WA')

Buggy submission (verdict: Runtime Error):
s = input()
j = len(s)-2

if s.index('A')==0 and s[2:-1].count('C')==1:
    for i in s:
        j -= i.islower()

if j > 0:
    print('WA')
else:
    print('AC')
Problem p03523 (python)

Fixed submission:
import re

S = input()
L = 'A?KIHA?BA?RA?$'

if re.match(L, S):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
S = input()
len_s = len(S)
L = 'AKIHABARA'

if S == L:
    print('YES')
    exit()
if len_s > 9:
    print('NO')
    exit()

S = [s for s in S]

for i in range(9):
    if S[i] == L[i]:
        pass
    elif S[i] == L[i+1]:
        S.insert(i, 'A')
    else:
        print('NO')
        exit()
    if i == 7:
        S.append('A')

S = ''.join(S)
if S == L:
    print('YES')
else:
    print('NO')
Problem p03633 (python)

Fixed submission:
import fractions
from functools import reduce

def lcm_base(A, B):
    return (A * B) // fractions.gcd(A, B)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
T = [int(input()) for _ in range(N)]

print(lcm(T))

Buggy submission (verdict: Runtime Error):
import fractions

N = int(input())
T = [int(input()) for _ in range(N)]

def lcm(A, B):
    return (A * B) // fractions.gcd(A, B)

num = lcm(T[0], T[1])
for i in range(2, N):
    num = lcm(num, T[i])

print(num)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
T = [int(input()) for _ in range(N)]

def lcm(A, B):
    return (A * B) // math.gcd(A, B)

num = lcm(T[0], T[1])
for i in range(2, N):
    num = lcm(num, T[i])

print(num)
Problem p03957 (python)

Fixed submission:
s = input()

if 'C' in s and 'F' in s:
    c = int(s.index('C'))
    f = max(int(s.index('F')), int(s.rindex('F')))
    if c <= f:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()

c = int(s.index('C'))
f = max(int(s.index('F')), int(s.rindex('F')))

if c <= f:
    print('Yes')
else:
    print('No')
Problem p03738 (python)

Fixed submission:
a=int(input())
b=int(input())
if a>b:
	print("GREATER")
elif a<b:
	print("LESS")
else:
	print("EQUAL")

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;

using ll=long long; 

void solve(){
	string a,b;
	cin>>a>>b;
	if(a.size()!=b.size()){
		if(a.size()>b.size()){
			cout<<"GREATER"<<endl;
		}
		else if (a.size()<b.size()){
			cout<<"LESS"<<endl;
		}
		else{
			cout<<"EQUAL"<<endl;
		}
	}
	else{
		for(int i=0; i<a.size(); i++){
			if(a[i]>b[i]){
				cout<<"GREATER"<<endl;
				return;
			}
			else if(a[i]<b[i]){
				cout<<"LESS"<<endl;
				return;
			}
		}
		cout<<"EQUAL"<<endl;
		return;
	}

}

signed main(){
	//while(1)
	solve();
}
Problem p02608 (python)

Fixed submission:
N = int(input())
t = 1
if N > 1:
    t = int((N-2)**0.5)
ans = [0]*(N+1)
for i in range(1,t):
    for j in range(1,i+1):
        for k in range(1,j+1):
            a = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if a > N:
                continue
            t = 1
            if (i == j and j > k) or (i>j and j==k):
                t = 3
            elif i > j and j > k:
                t = 6
            ans[a] += t
for i in range(1,N+1):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = [0]*(N+1)
for i in range(1,int((N-2)**0.5)):
    for j in range(1,i+1):
        for k in range(1,j+1):
            a = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if a > N:
                continue
            t = 1
            if (i == j and j > k) or (i>j and j==k):
                t = 3
            elif i > j and j > k:
                t = 6
            ans[a] += t
for i in range(1,N+1):
    print(ans[i])
Problem p02609 (python)

Fixed submission:
def popcnt(n):
    return bin(n).count("1")
N = int(input())
L = [0]*(N+1)
for i in range(1,N+1):
    L[i] = L[i%popcnt(i)]+1
L[N] = -1
X = input()
M = X.count("1")+1
m = max(1,M-2)
X = list(X)
XM = int(X[-1])
Xm = int(X[-1])
tM = 1
tm = 1
X.reverse()
for i in range(1,N):
    tM = tM*2%M
    tm = tm*2%m
    if X[i] == "1":
        XM = (XM + tM)%M
        Xm = (Xm + tm)%m
ans = []
tM = 1
tm = 1
for i in range(N):
    A = 0
    if X[i] == "0":
        A = (XM + tM)%M
    else:
        A = (Xm + m - tm)%m
        if M == 2:
            A = N
    ans.append(A)
    tM = (tM*2)%M
    tm = (tm*2)%m
ans.reverse()
for a in ans:
    print(L[a]+1)

Buggy submission (verdict: Runtime Error):
def popcnt(n):
    return bin(n).count("1")
N = int(input())
L = [0]*(N+1)
for i in range(1,N+1):
    L[i] = L[i%popcnt(i)]+1
X = input()
M = X.count("1")+1
m = M-2
X = list(X)
XM = int(X[-1])
Xm = int(X[-1])
tM = 1
tm = 1
X.reverse()
for i in range(1,N):
    tM = tM*2%M
    tm = tm*2%m
    if X[i] == "1":
        XM = (XM + tM)%M
        Xm = (Xm + tm)%m
ans = []
tM = 1
tm = 1
for i in range(N):
    A = 0
    if X[i] == "0":
        A = (XM + tM)%M
    else:
        A = (Xm + m - tm)%m
    ans.append(A)
    tM = (tM*2)%M
    tm = (tm*2)%m
ans.reverse()
for a in ans:
    print(L[a]+1)
Problem p02618 (python)

Fixed submission:
D = int(input())
c = [int(i) for i in input().split()]
days = [0]*26
ans = []
for k in range(D):
    s = [int(i) for i in input().split()]
    t = 0
    for i in range(1,26):
        if s[t] + days[t]*c[t] <= s[i] + days[i]*c[i]:
            t = i
    ans.append(t)
    for i in range(26):
        if i == t:
            days[i] = 0
        else:
            days[i] += 1
ans = [str(i+1) for i in ans]
print("\n".join(ans))

Buggy submission (verdict: Runtime Error):
import random

D = int(input())
c = [int(i) for i in input().split()]
s = []
for _ in range(D):
    s.append([int(i) for i in input().split()])
score = 0
days = [[0]*26 for i in range(D+1)]
T = []
for k in range(D):
    t = int(input())-1
    T.append(t)
    for i in range(26):
        if i == t:
            days[k+1][i] = 0
        else:
            days[k+1][i] = days[k][i]+1
    score += s[k][t]
    for i in range(26):
        score -= days[k+1][i]*c[i]
for _ in range(10**5):
    d = random.randint(0, D-1)
    q = random.randint(0, 25)
    diff = s[d][q] - s[d][T[d]]
    i = d+1
    for k in range(d+1,D):
        if T[k] == q:
            i = k
            break
    else:
        i = D
    j = d+1
    for k in range(d+1,D):
        if T[k] == T[d]:
            j = k
            break
    else:
        j = D
    diff -= c[T[d]]*(days[d][T[d]]+1)*(j-d) - c[q]*days[d+1][q]*(i-d)
    if diff <= 0:
        continue
    score += diff
    L = days[d+1][q]
    for k in range(d+1,i+1):
        days[k][q]  -= L
    L = days[d][T[d]]+1
    for k in range(d+1,j+1):
        days[k][T[d]] += L
    T[d] = q
T = [str(i) for i in T]
print("\n".join(T))

Buggy submission (verdict: Runtime Error):
import random
import datetime
start = datetime.datetime.now()

D = int(input())
c = [int(i) for i in input().split()]
s = []
for _ in range(D):
    s.append([int(i) for i in input().split()])
score = 0
days = [[0]*26 for i in range(D+1)]
T = []
for k in range(D):
    t = int(input())-1
    T.append(t)
    for i in range(26):
        if i == t:
            days[k+1][i] = 0
        else:
            days[k+1][i] = days[k][i]+1
    score += s[k][t]
    for i in range(26):
        score -= days[k+1][i]*c[i]
now = datetime.datetime.now()
while not (now.second - start.second == 1 and (now.microsecond - start.microsecond + 100000)%100000 > 90000):
    d = random.randint(0, D-1)
    q = random.randint(0, 25)
    diff = s[d][q] - s[d][T[d]]
    i = d+1
    for k in range(d+1,D):
        if T[k] == q:
            i = k
            break
    else:
        i = D
    j = d+1
    for k in range(d+1,D):
        if T[k] == T[d]:
            j = k
            break
    else:
        j = D
    diff -= c[T[d]]*(days[d][T[d]]+1)*(j-d) - c[q]*days[d+1][q]*(i-d)
    now = datetime.datetime.now()
    if diff <= 0:
        continue
    score += diff
    L = days[d+1][q]
    for k in range(d+1,i+1):
        days[k][q]  -= L
    L = days[d][T[d]]+1
    for k in range(d+1,j+1):
        days[k][T[d]] += L
    T[d] = q
T = [str(i) for i in T]
print("\n".join(T))
Problem p02662 (python)

Fixed submission:
import numpy as np
p = 998244353

N,S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
dp = np.zeros(S+1)
dp[0] = 1
for a in A:
  if S < a:
    dp *= 2
    dp %= p
    continue
  tmp = 2*dp
  dp = np.append(np.zeros(a),dp[:S-a+1])
  dp += tmp
  dp %= p
print(int(dp[S]))

Buggy submission (verdict: Runtime Error):
import numpy as np
p = 998244353

N,S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
dp = np.zeros(S+1)
dp[0] = 1
for a in A:
  if S < a:
    dp = 2*dp
    continue
  tmp = 2*dp
  dp = np.append(np.zeros(a),dp[:S-a+1])
  dp += tmp
  dp %= p
print(int(dp[S]))
Problem p02691 (python)

Fixed submission:
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])

H = [0]*(5*(10**5))
L = [0]*(5*(10**5))

for i in range(N):
    if A[i] <= 2*(10**5):
        H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(5*(10**5)):
    ans += H[i]*L[i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
A = A[A<=2*(10**5)]

H = [0]*(5*(10**5))
L = [0]*(5*(10**5))

for i in range(N):
    H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(5*(10**5)):
    ans += H[i]*L[i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
A = A[A<=2*(10**5)]

H = [0]*(5*(10**5))
L = [0]*(5*(10**5))

for i in range(N):
    H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(N):
    ans += H[i]*L[i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
A = A[A<=2*(10**5)]

H = [0]*(4*(10**5))
L = [0]*(4*(10**5))

for i in range(N):
    H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(N):
    ans += H[i]*L[i]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
A = A[A<=2*(10**5)]

H = [0]*(3*(10**5))
L = [0]*(3*(10**5))

for i in range(N):
    H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(N):
    ans += H[i]*L[i]

print(ans)
Problem p02583 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement, groupby
from math import sqrt, ceil, floor, factorial, gcd
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
import sys  # def input(): return sys.stdin.readline().rstrip() # sys.setrecursionlimit(10**6)

n = int(input())
L = list(int(x) for x in input().split())
if n <= 2:
    print(0)
    exit()
ans = 0
for a, b, c in combinations(L, 3):
    if a != b and b != c and c != a:
        if a + b > c and b + c > a and c + a > b:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
L = list(int(x) for x in input().split())
if n <= 2:
    print(0)
    exit()
ans = 0
for a, b, c in combinations(L, 3):
    if a != b and b != c and c != a:
        if a + b > c and b + c > a and c + a > b:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
L = list(int(x) for x in input().split())
if n <= 2:
    print(0)
    exit()
ans = 0
for a, b, c in combinations(L, 3):
    if a != b and b != c and c != a:
        if a + b > c and b + c > a and c + a > b:
            ans += 1
print(ans)
Problem p02585 (python)

Fixed submission:
n, k = (int(x) for x in input().split())
P = list(int(x) - 1 for x in input().split())
C = list(int(x) for x in input().split())

ans = -1e18
for si in range(n):
    S = [C[si]]
    x = P[si]
    while x != si:
        S.append(S[-1] + C[x])
        x = P[x]
    m = len(S)
    if k <= m:
        tmp = max(S[:k])
    else:
        loop = k // m
        r = k % m
        tmp = max(S[-1] * (loop - 1) + max(S), max(S))
        if r != 0:
            tmp = max(tmp, S[-1] * loop + max(S[:r]))
    ans = max(ans, tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = (int(x) for x in input().split())
P = list(int(x) - 1 for x in input().split())
C = list(int(x) for x in input().split())

ans = -1e18
for si in range(n):
    S = [C[si]]
    x = P[si]
    while x != si:
        S.append(S[-1] + C[x])
        x = P[x]
    m = len(S)
    if k <= m:
        tmp = max(S[:k])
    else:
        loop = k // m
        r = k % m
        tmp = max(S[-1] * loop + max(S[:r]), S[-1] * (loop - 1) + max(S), max(S))
    ans = max(ans, tmp)
print(ans)
Problem p02609 (python)

Fixed submission:
def popcount(n):
    return bin(n).count("1")

n = int(input())
x = input()
px = x.count("1")
a = px + 1
b = px - 1
tmpa = 0
tmpb = 0

if b == 0:
    for i in range(n):
        if x[i] == "1":
            tmpa += pow(2, n - i - 1, a)
            tmpa %= a

    for i in range(1, n + 1):
        count = 1
        if x[i - 1] == "1":  # x[i] == "1" -> "0"
            print(0)
            continue

        else:  # x[i] == "0" -> "1"
            y = tmpa + pow(2, n - i, a)
            y %= a
        while y:
            y %= popcount(y)
            count += 1
        print(count)

else:
    for i in range(n):
        if x[i] == "1":
            tmpa += pow(2, n - i - 1, a)
            tmpa %= a
            tmpb += pow(2, n - i - 1, b)
            tmpb %= b

    for i in range(1, n + 1):
        count = 1
        if x[i - 1] == "1":  # x[i] == "1" -> "0"
            y = tmpb - pow(2, n - i, b)
            y %= b
        else:  # x[i] == "0" -> "1"
            y = tmpa + pow(2, n - i, a)
            y %= a
        while y:
            y %= popcount(y)
            count += 1
        print(count)

Buggy submission (verdict: Runtime Error):
def popcount(n):
    return bin(n).count("1")

n = int(input())
x = input()
px = x.count("1")
a = px + 1
b = px - 1
tmpa = 0
tmpb = 0

A = [False] * n
for i in range(n):
    if x[i] == "1":
        tmpa += pow(2, n - i - 1, a)
        tmpa %= a
        tmpb += pow(2, n - i - 1, b)
        tmpb %= b

for i in range(1, n + 1):
    count = 1
    if x[i - 1] == "1":  # x[i] == "1" -> "0"
        y = tmpb - pow(2, n - i, b)
        y %= b
    else:  # x[i] == "0" -> "1"
        y = tmpa + pow(2, n - i, a)
        y %= a
    while y:
        y %= popcount(y)
        count += 1
    print(count)
Problem p02692 (python)

Fixed submission:
n, a, b, c = (int(x) for x in input().split())
d = {"A": a, "B": b, "C": c}
S = [input() for _ in range(n)]
ANS = []

for i, s in enumerate(S):
    if d[s[0]] == 0 and d[s[1]] == 0:
        print("No")
        exit()
    else:
        if d[s[0]] > d[s[1]] or (d[s[0]] == d[s[1]] == 1 and i < n - 1 and s[1] in S[i + 1]):
            d[s[1]] += 1
            d[s[0]] -= 1
            ANS.append(s[1])
        else:
            d[s[0]] += 1
            d[s[1]] -= 1
            ANS.append(s[0])
print("Yes")
for ans in ANS:
    print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b, c = (int(x) for x in input().split())
d = {"A": a, "B": b, "C": c}
S = [input() for _ in range(n)]
ANS = []

for i, s in enumerate(S):
    if d[s[0]] == 0 and d[s[1]] == 0:
        print("No")
        exit()
    else:
        if d[s[0]] > d[s[1]] or (d[s[0]] == d[s[1]] == 1 and i < n and s[1] in S[i + 1]):
            d[s[1]] += 1
            d[s[0]] -= 1
            ANS.append(s[1])
        else:
            d[s[0]] += 1
            d[s[1]] -= 1
            ANS.append(s[0])
print("Yes")
for ans in ANS:
    print(ans)
Problem p02817 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

s, t = Ss()
print(t+s)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial, gcd
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

s, t = Ss()
print(t+s)
Problem p02818 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

a, b, k = Is()
if a > k:
    print("{} {}".format(a-k, b))
elif a + b > k:
    print(("0 {}".format(b-k+a)))
else:
    print("0 0")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial, gcd
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

a, b, k = Is()
if a > k:
    print("{} {}".format(a-k, b))
elif a + b > k:
    print(("0 {}".format(b-k+a)))
else:
    print("0 0")
Problem p02900 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b = Is()

def factorization(n):
    arr = []
    tmp = n
    for i in range(2, int(floor(sqrt(n)))+1):
        if tmp % i == 0:
            count = 0
            while tmp % i == 0:
                count += 1
                tmp //= i
            arr.append([i, count])

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

    return arr


g = gcd(a, b)
A = factorization(g)
print(len(A)+1)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b = Is()

def factorization(n):
    arr = []
    tmp = n
    for i in range(2, int(floor(sqrt(n)))+1):
        if tmp % i == 0:
            count = 0
            while tmp % i == 0:
                count += 1
                tmp //= i
            arr.append([i, count])

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

    return arr


g = gcd(a, b)
A = factorization(g)
print(len(A)+1)