Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
ten = a//10 + b//10 + c//10 + d//10 + e//10

aa = [a%10,b%10,c%10,d%10,e%10]
zero = aa.count(0)

if zero == 5:
	print(ten)
else:
	for i in range(1,10):
		if  i in aa:
			one = i
			break
	print(ten*10 + (4-zero)*10 +one)

Fixed submission:

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())


ten = a//10 + b//10 + c//10 + d//10 + e//10

aa = [a%10,b%10,c%10,d%10,e%10]
zero = aa.count(0)

if zero == 5:
	print(ten*10)
else:
	for i in range(1,10):
		if  i in aa:
			one = i
			break
	print(ten*10 + (4-zero)*10 +one)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())


ten = a//10 + b//10 + c//10 + d//10 + e//10

aa = [a%10,b%10,c%10,d%10,e%10]
zero = aa.count(0)

if zero == 5:
	print(ten)
else:
	for i in range(1,9):
		if  i in aa:
			one = i
			break
	print(ten*10 + (4-zero)*10 +one)

Fixed submission:

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())


ten = a//10 + b//10 + c//10 + d//10 + e//10

aa = [a%10,b%10,c%10,d%10,e%10]
zero = aa.count(0)

if zero == 5:
	print(ten*10)
else:
	for i in range(1,10):
		if  i in aa:
			one = i
			break
	print(ten*10 + (4-zero)*10 +one)
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
s = input()
lr = list(map(str, [input() for i in range(q)]))

ac = [0]*n


for i in range(1,n):
	if s[i] =='C':
		if s[i-1] == 'A':
			ac[i-1] = 1

for i in range(q):
	l,r = map(int, lr[i].split())
	answer = sum(ac[l-1:r])
	if answer >= 1:
		if ac[r-1] == 1:
			answer -= 1
	print(answer)


Fixed submission:
#累積和　なるほど！

n,q = map(int, input().split())
s = input()
lr = list(map(str, [input() for i in range(q)]))

ac = [0]*n
#012345678
# ACACTACG
# 01122233

for i in range(1,n):
	if s[i-1:i+1] =='AC':
		ac[i] = ac[i-1] + 1
	else:
		ac[i] = ac[i-1]

for i in range(q):
	l,r = map(int, lr[i].split())
	answer = ac[r-1]-ac[l-1] 

	print(answer)

Buggy python submission (verdict: Runtime Error):
n,q = map(int, input().split())
s = input()
lr = list(map(str, [input() for i in range(q)]))

ac = [0]*n


for i in range(1,n):
	if s[i] =='C':
		if s[i-1] == 'A':
			ac[i-1] = 1

for i in range(q):
	answer = sum(ac[int(lr[i][0])-1:int(lr[i][2])])
	if answer >= 1:
		if ac[int(lr[i][2])-1] == 1:
			answer -= 1
	print(answer)


Fixed submission:
#累積和　なるほど！

n,q = map(int, input().split())
s = input()
lr = list(map(str, [input() for i in range(q)]))

ac = [0]*n
#012345678
# ACACTACG
# 01122233

for i in range(1,n):
	if s[i-1:i+1] =='AC':
		ac[i] = ac[i-1] + 1
	else:
		ac[i] = ac[i-1]

for i in range(q):
	l,r = map(int, lr[i].split())
	answer = ac[r-1]-ac[l-1] 

	print(answer)

Buggy python submission (verdict: Runtime Error):
n,q = map(int, input().split())
s = input()
lr = list(map(str, [input() for i in range(q)]))

ac = [0]*n


for i in range(1,n):
	if s[i] =='C':
		if s[i-1] == 'A':
			ac[i-1] = 1

for i in range(q):
	answer = sum(ac[int(lr[i][0])-1:int(lr[i][2])])
	if ac[int(lr[i][2])-1] == 1:
		answer -= 1
	print(answer)


Fixed submission:
#累積和　なるほど！

n,q = map(int, input().split())
s = input()
lr = list(map(str, [input() for i in range(q)]))

ac = [0]*n
#012345678
# ACACTACG
# 01122233

for i in range(1,n):
	if s[i-1:i+1] =='AC':
		ac[i] = ac[i-1] + 1
	else:
		ac[i] = ac[i-1]

for i in range(q):
	l,r = map(int, lr[i].split())
	answer = ac[r-1]-ac[l-1] 

	print(answer)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))

#ユーグリッドの互除法で、a,bを与えて、aをbで割ってあまりを計算する
#あまりがないときは、最後に割った数を返す（最大公約数）
#あまりがあるときは、bにあまりを入れて、再び計算する
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)


x = A[0]
for i in a[1:]:
	x = gcd(x,i)
print(x)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))

#ユーグリッドの互除法で、a,bを与えて、aをbで割ってあまりを計算する
#あまりがないときは、最後に割った数を返す（最大公約数）
#あまりがあるときは、bにあまりを入れて、再び計算する
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)


x = A[0]
for i in A[1:]:
	x = gcd(x,i)
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
ans = min(a)
for j in range(min(a)):
	for i in range(n):
		b[i] = a[i]%ans
	if max(b) == 0:
		break
	else:
		ans = max(b)
print(ans)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))

#ユーグリッドの互除法で、a,bを与えて、aをbで割ってあまりを計算する
#あまりがないときは、最後に割った数を返す（最大公約数）
#あまりがあるときは、bにあまりを入れて、再び計算する
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)


x = A[0]
for i in A[1:]:
	x = gcd(x,i)
print(x)
Buggy python submission (verdict: Runtime Error):
S = str(input())
T = str(input())

from collections import defaultdict
s = defaultdict(int)
t = defaultdict(int)

for i in S:
	s[i] += 1

for j in T:
	t[j] += 1

ss = sorted(s.values())
tt = sorted(t.values())

if ss == tt:
	print('Yes')
else:
	print('No')
		

Fixed submission:
A = list(map(int, input().split()))
A.sort()
A.reverse()

answer = A[0]*10 + A[1] + A[2] 

print(answer)

Buggy python submission (verdict: Runtime Error):
S = str(input())
T = str(input())

#辞書型を使ってみる。defaultdictは便利らしい。どこがかはちょっとよく分からなかった。
from collections import defaultdict
s = defaultdict(int)
t = defaultdict(int)


for i in S:
	s[i] += 1

for j in T:
	t[j] += 1

#辞書型をソートできるsoted()を使う。
#values()で辞書型のkey valueのvalueだけを取り出している。

ss = sorted(s.values())
tt = sorted(t.values())

if ss == tt:
	print('Yes')
else:
	print('No')
		

Fixed submission:
A = list(map(int, input().split()))
A.sort()
A.reverse()

answer = A[0]*10 + A[1] + A[2] 

print(answer)
Buggy python submission (verdict: Runtime Error):
n,i = int(input())
print(n-(i-1))

Fixed submission:
n,i = map(int,input().split())
print(n-(i-1))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print((a-1)＊(b-1))

Fixed submission:
a,b = map(int,input().split())
print((a-1)*(b-1))
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
a.sort()
print(0+abs(a[2]-a[1])+abs(a[3]-a[2]))

Fixed submission:
a = list(map(int, input().split()))
a.sort()
print(0+abs(a[1]-a[0])+abs(a[2]-a[1]))
Buggy python submission (verdict: Runtime Error):
dpの基本形
#漸化式を立てる
#nを与えられて求めるので、求める物をdp[n]とおいてみる
#dp[1]は１円払うのに必要な回数、dp[2]は...dp[n-1]まで知っている状態で、dp[n]はn円払うのに必要な回数を調べていくと考える


#場合１：dp[n]は、dp[n-1]にさらに1円を払う回数１回を足した回数である
#場合２：dp[n]は、dp[n-6]にさらに6円を払う回数１回を足した回数
#場合３：...

#これら全部の最小値を取れば良い！なるほど。
#でも参照できない物もあるから、参照できるやつだけ取り出すと良いだろう。



n = int(input())
pre_list = [1,6,9,36,81,216,729,1296,6561,7776,46656,59049]

#nをn+1個並べたリストを作る
dp = [n]*(n+1)
#0を初期化する
dp[0] = 0


#dp[i]について一つずつ考える
for i in range(1,n+1):
#dp[i]のそれぞれの場合分けについて考える。場合はpre_listの中身の分だけ回せばいい
	for j in pre_list:
		if i - j >= 0:
			dp[i] = min(dp[i],dp[i-j]+1)

print(dp[n])


Fixed submission:

n = int(input())
pre_list = [1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
 
#nをn+1個並べたリストを作る
dp = [n]*(n+1)
#0を初期化する
dp[0] = 0
 
 
#dp[i]について一つずつ考える
for i in range(1,n+1):
#dp[i]のそれぞれの場合分けについて考える。場合はpre_listの中身の分だけ回せばいい
	for j in pre_list:
		if i - j >= 0:
			dp[i] = min(dp[i],dp[i-j]+1)
 
print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
answer = n

for i in range(n):
	a = s[:i].count('W')
	b = s[i:].count('E')
	answer = min(answer, a+b)
	
print(answer)

Fixed submission:
n = int(input())
s = str(input())
answer = n
dpa = [-1]*(n+1)
dpa[0] = 0
dpb = [-1]*(n+1)
dpb[0] = s.count('E')

for i in range(1,n+1):
	if s[i-1] == 'W':
		dpa[i] = dpa[i-1] + 1
		dpb[i] = dpb[i-1]	
	else:
		dpa[i] = dpa[i-1]
		dpb[i] = dpb[i-1] - 1

for i in range(n+1):
	answer = min(answer, dpa[i]+dpb[i])
	
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
k = int(input())
substring = []

for i in range(len(s)+1):
	for j in range(i,len(s)+1):
		if len(s[i:j]) <= 5:
			substring.append(s[i:j])

		
sub = list(set(substring))
sub.remove('')
sub.sort()

print(sub[k-1])


Fixed submission:
#5番目までに大きな数値を探すということは、5文字以内の文字列だけを検索すれば良い
s = str(input())
k = int(input())
substring = []

for i in range(len(s)+1):
	for j in range(i,i+6):
		substring.append(s[i:j])

		
sub = list(set(substring))
sub.remove('')
sub.sort()

print(sub[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
k = int(input())
substring = []

for i in range(len(s)+1):
	for j in range(i,len(s)+1):
		substring.append(s[i:j])
		
sub = list(set(substring))
sub.remove('')
sub.sort()

print(sub[k-1])


Fixed submission:
#5番目までに大きな数値を探すということは、5文字以内の文字列だけを検索すれば良い
s = str(input())
k = int(input())
substring = []

for i in range(len(s)+1):
	for j in range(i,i+6):
		substring.append(s[i:j])

		
sub = list(set(substring))
sub.remove('')
sub.sort()

print(sub[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
#93B
a,b,k = map(int,input().split())

for i in range(a,b+1):
	if i < k+a:
		print(i)
		continue
	if i > b-k:
		print(i)

Fixed submission:
#93B
a,b,k = map(int,input().split())

if a+k <= b-k:
	for i in range(a, a+k):
		print(i)
	for i in range(b-k+1, b+1):
		print(i)
else:
	for i in range(a,b+1):
		print(i)
Buggy python submission (verdict: Runtime Error):
c1, c2, c3 = map(list,map(int, [input() for i in range(3)]))
print(c1[0]+c2[1]+c3[2])

Fixed submission:
c1, c2, c3 = map(list,map(str, [input() for i in range(3)]))
print(c1[0]+c2[1]+c3[2])
Buggy python submission (verdict: Runtime Error):
n = int(input())
march = ['M','A','R','C','H']
counter = [0]*5
for i in range(n):
	s = input()
	if s[0] in march:
		counter[march.index(s[0])] += 1

ans = 0

while 0 in counter:
	counter.pop(counter.index(0))

if len(counter) <= 2:
	ans = 0
elif len(counter) == 3:
	ans = counter[0]*counter[1]*counter[2]
elif len(counter) == 4:
	ans = counter[0]*counter[1]*counter[2] + counter[0]*counter[1]*counter[3] + counter[0]*counter[2]*counter[3] + counter[1]*counter[2]*counter[3]
elif len(counter) == 5:
	ans = counter[0]*counter[1]*counter[2] + counter[0]*counter[1]*counter[3] + counter[0]*counter[1]*counter[4] + counter[0]*counter[2]*counter[3] + counter[0]*counter[2]*counter[4] + counter[0]*counter[3]*counter[4] + counter[1]*counter[2]*counter[3] + counter[1]*counter[2]*counter[4] + counter[1]*counter[3]*counter[4] + counter[3]*counter[4]*counter[5]

print(ans)

Fixed submission:
n = int(input())
march = ['M','A','R','C','H']
counter = [0]*5
for i in range(n):
	s = input()
	if s[0] in march:
		counter[march.index(s[0])] += 1

ans = 0
for i in range(3):
	for j in range(1+i,4):
		for k in range(1+j,5):
			ans += counter[i]*counter[j]*counter[k]

print(ans)
Buggy python submission (verdict: Runtime Error):
n,a = map(int, [input() for i range(2)])
if n%500 <= a:
  print('Yes')
else:
  print('No')

Fixed submission:
n = int(input())
a = int(input())
if n%500 <= a:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
import math
a,b = int(input())
print(math.ceil(a+b/2))

Fixed submission:
import math
a,b = map(int,input().split())
print(math.ceil((a+b)/2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
aa = list(set(a))
ans = 0

for i in aa:
	if i == 1:
		ans += a.count(i)-1
	else:
		ans += a.count(i)%i
print(ans)

Fixed submission:
#Counterめちゃべんり！！ 辞書型のkey(),value(),items()をつかえるようにしよう
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
aa = Counter(a)

ans = 0
for i,j in aa.items():
	if i > j:
		ans += j
	elif i < j:
		ans += j-i
print(ans)
Buggy python submission (verdict: Runtime Error):
#二分探索...ソートした配列を二つに分けて、どちらに入るか調べることで高速化
import bisect

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

#リストを整列する
a.sort()
b.sort()
c.sort()

#二分探索で、それぞれのbについて、a<bになるaの個数を調べる
#二分探索で、それぞれのbについて、c>bになるcの個数を調べる
ans = 0
for i in range(n):
	ab = bisect.bisect_left(a,b[i])	#a==bの場合を除外する
	tmpbc = bisect.bisect_right(c,b[i])#b==cの場合を一度含んでおく
	bc = n-tmpbc
	
	ans += ab*bc
	
print(ans)


Fixed submission:
c1 = input()
c2 = input()
print('YES' if c1 == c2[::-1] else 'NO')
Buggy python submission (verdict: Runtime Error):

n = input()
a = input()

print(n**n-a)

Fixed submission:
n = int(input())
a = int(input())

print((n**2)-a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
for i in range(1,n+1):
	ans = ans*i
print(ans%(10**9+7))

Fixed submission:
n = int(input())
ans = 1
for i in range(1,n+1):
	ans = (ans*i)%(10**9+7)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = 0

N, A, B = [int(i) for i in input().split()]

n += int(N/(A+B)) * A

amari = N % (A+B)
n += min(amari, A)

print(n)

Fixed submission:
s = input()
if "A" in s and "B" in s:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
n = 0

N, A, B = [int(i) for i in input().split()]

n += int(N/(A+B)) * A

amari = N % (A+B)
n += min(amari, A)

print(n)


Fixed submission:
s = input()
if "A" in s and "B" in s:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
A, B = [int(i) for i in input().split()]

if A<0 or B<0:
    print("-1")
    exit()

minA = int(A/0.08)
maxA = int((A+1)/0.08)
minB = int(B/0.1)
maxB = int((B+1)/0.1)

for i in range(minA, maxA):
    if i >= minB and i < maxB:
        print(i)
        exit()

print("-1")

Fixed submission:
s = input()
if "A" in s and "B" in s:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):

S = input()

ql = []
for i in range(int(input())):
    ql.append(input())


for query in ql:
    if query == "1":
        S = S[::-1]
    else:
        _, tp, s2 = query.split(" ")
        if tp == "1":
            S = s2 + S
        else:
            S = S + s2
print(S)

Fixed submission:

S = input()

ql = []
for i in range(int(input())):
    ql.append(input())

rev = False
add_head = ""
add_tail = ""

for query in ql:
    if query == "1":
        rev = not rev
    else:
        _, tp, s2 = query.split(" ")

        if tp == "1":
            if not rev:
                add_head = s2 + add_head
            if rev:
                add_tail = add_tail + s2[::-1]
        else:
            if not rev:
                add_tail = add_tail + s2
            if rev:
                add_head = s2[::-1] + add_head

S = add_head + S + add_tail
if rev:
    S = S[::-1]

print(S)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import sys
import time

sys.setrecursionlimit(2000)
N, M, K = [int(i) for i in input().split(" ")]

class UnionNode():
    def __init__(self, number):
        self.number = number
        self.volume = 1
        self.master = None

    @property
    def rootnum(self):
        return self.root.number

    @property
    def root(self):
        if self.master:
            return self.master.root
        else:
            return self


    def same(self, target):
        if self.root == target.root:
            return True
        else:
            return False

    def unite(self, target):
        seroot = self.root
        taroot = target.root
        if seroot.number == taroot.number:
            pass
        else:
            #print(f"unite {target.rootnum}({target.root.volume}), {self.rootnum}({self.root.volume})")
            if seroot.number < taroot.number:
                seroot.volume += taroot.volume
                taroot.master = seroot
            else:
                taroot.volume += seroot.volume
                seroot.master = taroot

nodes = [UnionNode(i) for i in range(N)]

outlist = defaultdict(lambda :[])

for i in range(M):
    s = input()
    a, b = s.split(" ")
    a = int(a) - 1
    b = int(b) - 1
    nodes[a].unite(nodes[b])
    outlist[a].append(b)
    outlist[b].append(a)

for i in range(K):
    s = input()
    a, b = s.split(" ")
    a = int(a) - 1
    b = int(b) - 1
    outlist[a].append(b)
    outlist[b].append(a)

result = []
for i in range(N):
    node = nodes[i]
    ret = node.root.volume - 1
    for out in outlist[i]:
        if nodes[out].rootnum == node.rootnum:
            ret -=1
    result.append(ret)

#for i in range(100):
#    print(result[i])

print(" ".join([str(i) for i in result]))

Fixed submission:

a = int(input()) + 1
print(int(a/2))
Buggy python submission (verdict: Runtime Error):
mod = 10**9 + 7
def iip(listed = False):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret

n = iip()
A = iip()

def main():
    ss = []
    for a_i in A:
        for s in ss:
            if a_i % s == 0:
                a_i //= s

        ss.extend(soinsuu_bunkai(a_i))

    #print(ss)
    all = 1
    for s in ss:
        all *= s
        all %= mod

    ans = 0
    for a_i in A:
        ans += (all * inv(a_i, mod)) % mod
        ans %= mod
    print(ans)


main()

Fixed submission:
import math
import time


t = time.time()
def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret

def fkc(keta):
    return 10**keta

def pat_b(a, n):
    tail = a % 10

    if tail == 0:
        return 0

    head = int(str(a)[0])

    ret = 0
    if tail == head: #１桁解
        ret += 1

    if n >= tail*10+head: #２桁解は１通りあるかないか
        ret += 1

    for free_keta in range(1, 6): # 3桁以上解
        mincase = 10**(free_keta+1) * tail + head

        if n < mincase:
            break
        if n >= 10**(free_keta+1) + mincase + head - 10:
            ret += fkc(free_keta)
            continue
        else:
            ret += int(int(n-mincase)/10) + 1
    return ret

def main():
    n = iip()
    result = 0
    for i in range(n+1):
        result += pat_b(i, n)
    print(result)


main()
Buggy python submission (verdict: Time Limit Exceeded):
def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret

n = iip()
al = iip()

mod = 10**9 + 7
num1 = [0 for i in range(60)]

for a in al:
    b = bin(a)[2:].zfill(60)
    #print(b)
    for i in range(60):
        if b[i] == "1":
            num1[i] += 1

result = 0
for i, a in enumerate(num1):
    a1 = 2**(59-i) % mod
    a2 = (a * (n-a)) % mod
    result += a1*a2 % mod
    result = result % mod


#print(num1)
print(result)

Fixed submission:
def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret

n = iip()
al = iip()
#al = [2**60 - 114514 - i for i in range(1000)]

mod = 10**9 + 7
num1 = [0 for i in range(60)]

for a in al:
    b = bin(a)[2:].zfill(60)
    #print(b)
    for i in range(60):
        if b[i] == "1":
            num1[i] += 1

result = 0
for i, a in enumerate(num1):
    a1 = 2**(59-i) % mod
    a2 = (a * (n-a)) % mod
    result += a1*a2 % mod
    result = result % mod


#print(num1)
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import time
from collections import deque
from collections import defaultdict
from copy import deepcopy

mod = 10 ** 9 + 7
t = time.time()


def inv(n, mod):
    return power(n, mod-2)

def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, n):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    return ret


def main():
    A, B = iip()

    a = set(soinsuu_bunkai(A))
    b = set(soinsuu_bunkai(B))

    ans = 1 # 1の場合
    for aa in a:
        if aa in b:
            ans+=1

    print(ans)

main()

Fixed submission:
import math
import time
from collections import deque
from collections import defaultdict
from copy import deepcopy

mod = 10 ** 9 + 7
t = time.time()



def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def main():
    A, B = iip()

    a = set(soinsuu_bunkai(A))
    b = set(soinsuu_bunkai(B))

    ans = 1 # 1の場合
    for aa in a:
        if aa in b:
            ans+=1

    print(ans)

main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
inp = list(map(lambda x: int(x), input().split(" ")))

counts = {}
for i in range(N):
    counts[inp[i]] = 0
for i in range(N):
    counts[inp[i]] += 1

ret = {}

for i in range(N):
    ret[inp[i]] = -1

for i in range(N):
    if (ret[inp[i]] != -1):
        print(ret[inp[i]])
    else:
        sum1 = 0
        for k in counts.keys():
            if (k==inp[i]):
                sum1 += (counts[k]-1)*(counts[k]-2)//2
            else:
                sum1 += (counts[k])*(counts[k]-1)//2
        ret[inp[i]] = sum1
        print(sum1)


Fixed submission:
N = int(input())
inp = list(map(lambda x: int(x), input().split(" ")))

counts = {}
for i in range(N):
    counts[inp[i]] = 0
for i in range(N):
    counts[inp[i]] += 1

ret = {}

allsum = 0
for k in counts.keys():
    allsum += counts[k]*(counts[k]-1)//2

for i in range(N):
    print(allsum - counts[inp[i]]+1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

inp = list(map(lambda x: int(x), input().split(" ")))
n = inp[0]
k = inp[1]
inp = list(map(lambda x: int(x), input().split(" ")))

dp = [0]*(n)

for i in range(n-1):
    dp[i+1] = dp[i] + abs(inp[i+1]-inp[i])
    for j in range(2,k+1):
        if (i+1-j>=0):
            dp[i+1] = min(dp[i+1], dp[i+1-j] + abs(inp[i+1]-inp[i+1-j]))

print(dp[-1])

Fixed submission:
import sys

inp = list(map(lambda x: int(x), input().split(" ")))
n = inp[0]
k = inp[1]
inp = list(map(lambda x: int(x), input().split(" ")))

dp = [0]*(n)

for i in range(n-1):
    dp[i+1] = dp[i] + abs(inp[i+1]-inp[i])
    for j in range(2,k+1):
        if (i+1-j>=0):
            dp[i+1] = min(dp[i+1], dp[i+1-j] + abs(inp[i+1]-inp[i+1-j]))

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys

inp = list(map(lambda x: int(x), input().split(" ")))
n = inp[0]
k = inp[1]
inp = list(map(lambda x: int(x), input().split(" ")))

dp = [0]*(n)

for i in range(n-1):
    dp[i+1] = dp[i] + abs(inp[i+1]-inp[i])
    for j in range(2,k+1):
        if (i+1-j>=0):
            dp[i+1] = min(dp[i+1], dp[i+1-j] + abs(inp[i+1]-inp[i+1-j]))
        else:
            break

print(dp[-1])

Fixed submission:
import sys

inp = list(map(lambda x: int(x), input().split(" ")))
n = inp[0]
k = inp[1]
inp = list(map(lambda x: int(x), input().split(" ")))

dp = [0]*(n)

for i in range(n-1):
    dp[i+1] = dp[i] + abs(inp[i+1]-inp[i])
    for j in range(2,k+1):
        if (i+1-j>=0):
            dp[i+1] = min(dp[i+1], dp[i+1-j] + abs(inp[i+1]-inp[i+1-j]))

print(dp[-1])