Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())

if N == 1:
    print(1)
    sys.exit(0)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


P = prime_factorize(N)

ans = len(str(N))

for i in range(2 ** (len(P) - 1)):
    a = 1
    b = 1
    for j in range(len(P)):
        if (i >> j) & 1 == 1:
            a *= P[j]
        else:
            b *= P[j]

    ans = min(ans, max(len(str(a)), len(str(b))))

print(ans)


Fixed submission:
import sys
N = int(input())

if N == 1:
    print(1)
    sys.exit(0)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


P = prime_factorize(N)

ans = len(str(N))

for i in range(2 ** (len(P) - 1)):
    a = 1
    b = 1
    for j in range(len(P)):
        if (i >> j) & 1 == 1:
            a *= P[j]
        else:
            b *= P[j]

    ans = min(ans, max(len(str(a)), len(str(b))))

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


P = prime_factorize(N)

ans = len(str(N))

for i in range(2 ** (len(P) - 1)):
    a = 1
    b = 1
    for j in range(len(P)):
        if (i >> j) & 1 == 1:
            a *= P[j]
        else:
            b *= P[j]

    ans = min(ans, max(len(str(a)), len(str(b))))

print(ans)


Fixed submission:
import sys
N = int(input())

if N == 1:
    print(1)
    sys.exit(0)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


P = prime_factorize(N)

ans = len(str(N))

for i in range(2 ** (len(P) - 1)):
    a = 1
    b = 1
    for j in range(len(P)):
        if (i >> j) & 1 == 1:
            a *= P[j]
        else:
            b *= P[j]

    ans = min(ans, max(len(str(a)), len(str(b))))

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
A.sort()
B = []

if len(A) % 2 == 0:
    ans = 2 ** (len(A)/2)
    for i in range(len(A)//2):
        B.append(2 * i + 1)
        B.append(2 * i + 1)

else:
    ans = 2 ** (len(A)//2)
    B.append(0)
    for i in range(len(A)//2):
        B.append(2 * i + 2)
        B.append(2 * i + 2)

if A == B:
    print(int(ans/MOD))
else:
    print(0)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
A.sort()
B = []

ans = 1

if len(A) % 2 == 0:
    for i in range(len(A)//2):
        ans *= 2
        ans %= MOD
        B.append(2 * i + 1)
        B.append(2 * i + 1)

else:
    B.append(0)
    for i in range(len(A)//2):
        ans *= 2
        ans %= MOD
        B.append(2 * i + 2)
        B.append(2 * i + 2)

if A == B:
    print(int(ans))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
A.sort()
B = []

if len(A) % 2 == 0:
    ans = 2 ** (len(A)/2)
    for i in range(len(A)//2):
        B.append(2 * i + 1)
        B.append(2 * i + 1)

else:
    ans = 2 ** (len(A)//2)
    B.append(0)
    for i in range(len(A)//2):
        B.append(2 * i + 2)
        B.append(2 * i + 2)

if A == B:
    print(int(ans))
else:
    print(0)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
A.sort()
B = []

ans = 1

if len(A) % 2 == 0:
    for i in range(len(A)//2):
        ans *= 2
        ans %= MOD
        B.append(2 * i + 1)
        B.append(2 * i + 1)

else:
    B.append(0)
    for i in range(len(A)//2):
        ans *= 2
        ans %= MOD
        B.append(2 * i + 2)
        B.append(2 * i + 2)

if A == B:
    print(int(ans))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = list(map(int,input().split()))
m = 10 ** 18
ans = 1
for i in range(n):
	ans *= a[i]

if ans > m:
	print(-1)
else:
	print(ans)


Fixed submission:
n = int(input())

a = list(map(int,input().split()))
a.sort(reverse=True)

if a[-1] == 0:
	print(0)
	exit()

m = 10 ** 18
ans = 1
for i in range(n):
	ans *= a[i]
	if ans > m:
		print(-1)
		exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

n,a,b,c = map(int,input().split())
d = {'A':a,'B':b,'C':c}

s = []
for _ in range(n):
	s.append(input())

ans = []
for i in range(n):

	if d[s[i][0]] <= 0 and d[s[i][1]] <= 0:
		print('No')
		sys.exit()
	if d[s[i][0]] < d[s[i][1]]:
		d[s[i][1]] -= 1
		d[s[i][0]] += 1
		ans.append(s[i][0])
	elif d[s[i][0]] > d[s[i][1]]:
		d[s[i][0]] -= 1
		d[s[i][1]] += 1
		ans.append(s[i][1])
	else:
		if i < n-1 and d[s[i+1].strip(s[i])] == 0:
			d[s[i+1].strip(s[i+1].strip(s[i]))] += 1
			ans.append(s[i+1].strip(s[i+1].strip(s[i])))
		else:
			d[s[i][0]] += 1
			ans.append(s[i][0])
print('Yes')
for i in range(len(ans)):
	print(ans[i])



Fixed submission:
import sys

n,a,b,c = map(int,input().split())
d = {'A':a,'B':b,'C':c}

s = []
for _ in range(n):
	s.append(input())

ans = []
for i in range(n):

	if d[s[i][0]] <= 0 and d[s[i][1]] <= 0:
		print('No')
		sys.exit()
	if d[s[i][0]] < d[s[i][1]]:
		d[s[i][1]] -= 1
		d[s[i][0]] += 1
		ans.append(s[i][0])
	elif d[s[i][0]] > d[s[i][1]]:
		d[s[i][0]] -= 1
		d[s[i][1]] += 1
		ans.append(s[i][1])
	else:
		if i < n-1 and s[i+1].strip(s[i]) != '' and d[s[i+1].strip(s[i])] == 0:
			string = s[i+1].strip(s[i+1].strip(s[i]))
			d[string] += 1
			d[s[i].strip(string)] -= 1
			ans.append(s[i+1].strip(s[i+1].strip(s[i])))
		else:
			d[s[i][0]] += 1
			d[s[i][1]] -= 1
			ans.append(s[i][0])
print('Yes')
for i in range(len(ans)):
	print(ans[i])

Buggy python submission (verdict: Runtime Error):
import sys

n,a,b,c = map(int,input().split())
d = {'A':a,'B':b,'C':c}

s = []
for _ in range(n):
	s.append(input())

ans = []
for i in range(n):

	if d[s[i][0]] <= 0 and d[s[i][1]] <= 0:
		print('No')
		sys.exit()
	if d[s[i][0]] < d[s[i][1]]:
		d[s[i][1]] -= 1
		d[s[i][0]] += 1
		ans.append(s[i][0])
	elif d[s[i][0]] > d[s[i][1]]:
		d[s[i][0]] -= 1
		d[s[i][1]] += 1
		ans.append(s[i][1])
	else:
		if i < n-1 and d[s[i+1].strip(s[i])] == 0:
			d[s[i+1].strip(s[i+1].strip(s[i]))] += 1
			ans.append(s[i+1].strip(s[i+1].strip(s[i])))
print('Yes')
for i in range(len(ans)):
	print(ans[i])



Fixed submission:
import sys

n,a,b,c = map(int,input().split())
d = {'A':a,'B':b,'C':c}

s = []
for _ in range(n):
	s.append(input())

ans = []
for i in range(n):

	if d[s[i][0]] <= 0 and d[s[i][1]] <= 0:
		print('No')
		sys.exit()
	if d[s[i][0]] < d[s[i][1]]:
		d[s[i][1]] -= 1
		d[s[i][0]] += 1
		ans.append(s[i][0])
	elif d[s[i][0]] > d[s[i][1]]:
		d[s[i][0]] -= 1
		d[s[i][1]] += 1
		ans.append(s[i][1])
	else:
		if i < n-1 and s[i+1].strip(s[i]) != '' and d[s[i+1].strip(s[i])] == 0:
			string = s[i+1].strip(s[i+1].strip(s[i]))
			d[string] += 1
			d[s[i].strip(string)] -= 1
			ans.append(s[i+1].strip(s[i+1].strip(s[i])))
		else:
			d[s[i][0]] += 1
			d[s[i][1]] -= 1
			ans.append(s[i][0])
print('Yes')
for i in range(len(ans)):
	print(ans[i])
Buggy python submission (verdict: Runtime Error):
import bisect

s = input()
n = len(s)

s2 = [0 for _ in range(n)]

zero = []
one = []
two = []

for i in range(n):
  s2[i] = int(s[i]) % 3

for i in range(1,n):
  s2[i] += s2[i-1]
  s2[i] %= 3

for i in range(n):
  if s2[i] == 0:
    zero.append(i)
  elif s2[i] == 1:
    one.append(i)
  elif s2[i] == 2:
    two.append(i)
ans = 0
length = len(zero)
for i in range(length):
    if int(s[:zero[i]+1]) % 2019 == 0:
      ans += 1
length = len(zero)
for i in range(length-1):
  tmp = s[zero[i]+1:]
  for j in range(i+1,length):
    if int(tmp[:zero[j]-zero[i]]) % 2019 == 0:
      ans += 1

length = len(one)
for i in range(length-1):
  tmp = s[one[i]+1:]
  for j in range(i+1,length):
    if int(tmp[:one[j]-one[i]]) % 2019 == 0:
      ans += 1

length = len(two)
for i in range(length-1):
  tmp = s[two[i]+1:]
  for j in range(i+1,length):
    if int(tmp[:two[j]-two[i]]) % 2019 == 0:
      ans += 1
print(ans)


Fixed submission:
s,w = map(int,input().split())

if s <= w:
  print('unsafe')
else:
  print('safe')
Buggy python submission (verdict: Runtime Error):
n,x,y = map(int,input().split())

for i in range(1,n):
	ans = 0
	for j in range(1,n-i+1):
		if i+j <= x:
			ans += 1
			continue
		elif j >= y and i+j < n:
			ans += 1
			continue
		else:
			# x-j+1 = jからyまでの距離
			# y-i-j = yからi+j(目的地)までの距離
			#print(abs(x-j)+1+abs(y-i-j))
			if min(abs(x-j)+1+abs(y-i-j),i) == i:
				ans += 1
		num = i-(abs(x-j)+1)
		if num >= 0:
			d1 = y+num
			d2 = y-num
			if i+j < d1 and d1 <= n:
				ans += 1
			if i+j < d2 and d1 != d2:
				ans += 1
		#print(i,j,ans)
	print(ans)


Fixed submission:
s = input()

if s[2] == s[3] and s[4] == s[5]:
	print('Yes')
else:
	print('No')

Buggy python submission (verdict: Runtime Error):
def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0

    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True

        for j in range(n):
            d[j] = min(d[j],d[v]+cost[v][j])
    return tuple(d)

n,x,y = map(int,input().split())

#cost[u][v] : 辺uvのコスト(存在しないときはinf この場合は10**10)
cost = [[float("inf") for i in range(n)] for i in range(n)]

for i in range(n-1):
    cost[i][i+1] = 1
    cost[i+1][i] = 1
cost[x-1][y-1] = 1
cost[y-1][x-1] = 1

ans = [0 for _ in range(n)]
for i in range(n):
    #nは頂点数、wは辺の数
    res = dijkstra(i,n,n,cost)
    for j in range(i+1,n):
        ans[res[j]] += 1

for i in range(1,n):
    print(ans[i])


Fixed submission:
s = input()

if s[2] == s[3] and s[4] == s[5]:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
from collections import deque

s = list(input())
q = int(input())

count = 0
l = []
for i in range(q):
	tmp = list(map(str,input().split()))
	if len(tmp) == 1:
		count += 1
		for j in range(len(l)):
			l[j][0] += 1
	elif tmp[1] == '1':
		l.append([1, tmp[2]])
	elif tmp[1] == '2':
		l.append([2, tmp[2]])

for i in range(len(l)):
	l[i][0] %= 2

if count % 2 == 1:
	s = s[::-1]
s = deque(s)

for i in range(len(l)):
	if l[i][0] == 0:
		s.append(l[i][1])
	else:
		s.appendleft(l[i][1])
print("".join(s))


Fixed submission:
s = list(input())

if 'A' not in s or 'B' not in s:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int,input().split())

mod = 10**9 + 7

if a > n//2:
	a = -1 * (a-n)
if b > n//2:
	b = -1 * (b-n)

#print(a,b)

num = 1
ans = 1
for i in range(n//2):
	num = (num * (n-i)) // (i+1)
	ans += num * 2
	if a == i+1:
		ans -= num
	if b == i+1:
		ans -= num
if n % 2 == 0:
	ans -= num
if a == 0:
	ans -= 1
if b == 0:
	ans -= 1

print(ans)


Fixed submission:
def pow_k(x, n):
    """
    O(log n)
    """
    MOD = 10 ** 9 + 7
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K %= MOD
        x *= x
        x %= MOD
        n //= 2

    return K * x

def cmb(n, r):
	MOD = 10**9+7
	if n - r < r: r = n - r
	if r == 0: return 1
	if r == 1: return n

	numerator = [n - r + k + 1 for k in range(r)]
	denominator = [k + 1 for k in range(r)]

	for p in range(2,r+1):
		pivot = denominator[p - 1]
		if pivot > 1:
			offset = (n - r) % p
			for k in range(p-1,r,p):
				numerator[k - offset] /= pivot
				denominator[k] /= pivot

	result = 1
	for k in range(r):
		if numerator[k] > 1:
			result *= int(numerator[k])
			result %= MOD

	return result

n,a,b = map(int,input().split())
MOD = 10**9+7

ans = pow_k(2,n)-1

print((ans - cmb(n,a) - cmb(n,b))%MOD)

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

mod = 10**9 + 7

ans = 0
num = 1
for i in range(n):
	num = (num * (n-i)) // (i+1)
	if a != i+1 and b != i+1:
		ans += num

print(ans)


Fixed submission:
def pow_k(x, n):
    """
    O(log n)
    """
    MOD = 10 ** 9 + 7
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K %= MOD
        x *= x
        x %= MOD
        n //= 2

    return K * x

def cmb(n, r):
	MOD = 10**9+7
	if n - r < r: r = n - r
	if r == 0: return 1
	if r == 1: return n

	numerator = [n - r + k + 1 for k in range(r)]
	denominator = [k + 1 for k in range(r)]

	for p in range(2,r+1):
		pivot = denominator[p - 1]
		if pivot > 1:
			offset = (n - r) % p
			for k in range(p-1,r,p):
				numerator[k - offset] /= pivot
				denominator[k] /= pivot

	result = 1
	for k in range(r):
		if numerator[k] > 1:
			result *= int(numerator[k])
			result %= MOD

	return result

n,a,b = map(int,input().split())
MOD = 10**9+7

ans = pow_k(2,n)-1

print((ans - cmb(n,a) - cmb(n,b))%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())

p = list(map(int,input().split()))

iter_num = n - k + 1

ans = []
for i in range(iter_num):
	ans.append((sum(p[i:k+i])+k)/2)

print(max(ans))


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

p = list(map(int,input().split()))

iter_num = n - k + 1

num = sum(p[0:k])
ans = [(num+k)/2]
for i in range(iter_num-1):
	num = num - p[i] + p[k+i]
	ans.append((num+k)/2)

print(max(ans))
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left
import math
import sys
readlines = sys.stdin.readline

def main():
  n,d,a = map(int,input().split())
  xx = []
  hh = []
  X = []
  H = []
  for _ in range(n):
    tmp = list(map(int,input().split()))
    xx.append(tmp[0])
    hh.append(tmp[1])

  k = zip(xx,hh)
  q = sorted(k)
  for xxx,hhh in q:
    X.append(xxx)
    H.append(hhh)
  X = tuple(X)
  ans = 0
  end = n-1
  while True:
    x = X[end] - d
    start = bisect_left(X,x-d)
    num = math.ceil(H[end] / a)
    ans += num
    H[end] = 0
    e = end
    end = start-1
    for i in range(start,e):
      H[i] -= a * num
      if H[i] > 0:
        end = i
    if end < 0:
      break

  print(ans)
if __name__ == '__main__':
  main()

Fixed submission:
import math

h,a = map(int,input().split())

print(int(math.ceil(h / a)))

Buggy python submission (verdict: Runtime Error):
import sys

def dp_all(dp):
  length = len(dp)
  for i in range(length):
    print(dp[i])

H,N= map(int,input().split())

a = []
b = []

for i in range(N):
  a_dash,b_dash = map(int,input().split())
  a.append(a_dash)
  b.append(b_dash)

#dp[i+1][j] = i番目までの魔法で体力jのモンスターに
#勝つことができる、魔力の最小値
INF = 10**9
dp = [[INF for _ in range(H+1)] for _ in range(N+1)]

for i in range(N+1):
  dp[i][0] = 0

for i in range(N):
  for j in range(H+1):
    if a[i] > j:
      dp[i+1][j] = min(dp[i][j],b[i])
    else:
      dp[i+1][j] = min(dp[i][j],dp[i+1][j-a[i]]+ b[i])

print(dp[N][H])


Fixed submission:
import math

h,a = map(int,input().split())

print(int(math.ceil(h / a)))
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())

if (b-a) % 2 == 0:
	print((b-a) // 2)
else:
	if a-1 < n-b:
		ans = b-1
		x = b-(a-1)-1
		ans = min(ans, a + (x-1) // 2)
	else:
		ans = n-a
		x = a + (n-b) + 1
		ans = min(ans, (n-b) + 1 + (n-x) // 2)

print(ans)


Fixed submission:
n,a,b = map(int,input().split())

if (b-a) % 2 == 0:
	ans = (b-a) // 2
else:
	if a-1 < n-b:
		ans = b-1
		x = b-(a-1)-1
		ans = min(ans, a + (x-1) // 2)
	else:
		ans = n-a
		x = a + (n-b) + 1
		ans = min(ans, (n-b) + 1 + (n-x) // 2)

print(ans)
Buggy python submission (verdict: Runtime Error):
x = input()

x1 = int(x[:-2])
x2 = int(x[-2:])

c = int(x2 // 5) + 1

if x1 >= c:
	print(1)
else:
	print(0)


Fixed submission:
import sys

x = input()
X = int(x)

if X < 100:
	print(0)
	sys.exit()
elif X >= 100 and X <= 105:
	print(1)
	sys.exit()
elif X % 105 == 0:
	print(1)
	sys.exit()

x1 = int(x[:-2])
x2 = int(x[-2:])

c = int(x2 // 5) + 1

if x1 >= c:
	print(1)
else:
	print(0)
Buggy python submission (verdict: Runtime Error):
import math

a,b,x = map(int,input().split())

i = 1
num = 1
while (x - b*i) / a >= num:
	i += 1
	num *= 10

i -= 1
num //= 10
hikaku = (x - b*i) / a
#hikaku = min(hikaku,10**i-1)

if i > 9:
	print(1000000000)
elif i == 0:
	print(0)
else:
	#print(math.floor(hikaku))
	for n in range(math.floor(hikaku)-2,num*10):
		if a * n + b * i >= x:
			break
	print(n-1)


Fixed submission:
s = input()

if s == 'SUN':
	print(7)
elif s == 'MON':
	print(6)
elif s == 'TUE':
	print(5)
elif s == 'WED':
	print(4)
elif s == 'THU':
	print(3)
elif s == 'FRI':
	print(2)
elif s == 'SAT':
	print(1)
else:
	print(0)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x,y):
	while y!=0:
		x,y=y,x%y
	return x

a,b = map(int,input().split())

k = []
r = gcd(a,b)
for i in range(1,r+1):
	if a % i == 0 and b % i == 0:
		if i % 2 != 0 or i == 2:
			k.append(i)

l = []
l.append(k[0])
ans = 1

for i in range(1,len(k)):
	flag = True
	for j in range(len(l)):
		if gcd(k[i],l[j]) != 1:
			flag = False
			break
	if flag:
		l.append(k[i])
		ans += 1

print(ans)


Fixed submission:
a,b = map(int,input().split())

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)
	# divisors.sort()
	return divisors

def gcd(x,y):
	while y!=0:
		x,y=y,x%y
	return x

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

#factorization(24)
## [[2, 3], [3, 1]]
##  24 = 2^3 * 3^1

g = gcd(a,b)
#gcd_list = make_divisors(g)
bunkai = factorization(g)

if len(bunkai) == 1 and bunkai[0][0] == 1:
	print(1)
else:
	print(len(bunkai) + 1 )

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

k = []
for i in range(1,min(a,b)+1):
	if a % i == 0 and b % i == 0:
		k.append(i)

def gcd(x,y):
	while y!=0:
		x,y=y,x%y
	return x == 1

l = []
l.append(k[0])
ans = 1

for i in range(1,len(k)):
	flag = True
	for j in range(len(l)):
		if not gcd(k[i],l[j]):
			flag = False
			break
	if flag:
		l.append(k[i])
		ans += 1

print(ans)


Fixed submission:
a,b = map(int,input().split())

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)
	# divisors.sort()
	return divisors

def gcd(x,y):
	while y!=0:
		x,y=y,x%y
	return x

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

#factorization(24)
## [[2, 3], [3, 1]]
##  24 = 2^3 * 3^1

g = gcd(a,b)
#gcd_list = make_divisors(g)
bunkai = factorization(g)

if len(bunkai) == 1 and bunkai[0][0] == 1:
	print(1)
else:
	print(len(bunkai) + 1 )
Buggy python submission (verdict: Runtime Error):
n = int(input()

print(n**3)

Fixed submission:
n = int(input())

print(n**3)
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline

n = int(input())
a = []
for _ in range(n):
	a.append(tuple(map(int,input().split())))
a = tuple(a)

play = [0 for _ in range(n)]
flag = [True for _ in range(n)]
count = 0
ans = 0
while True:
	break_flag = True
	for i in range(n):
		if flag[i]:
			num = a[i][play[i]]-1
			if flag[num] and a[num][play[num]]-1 == i:
				play[num] += 1
				play[i] += 1
				flag[num] = False
				flag[i] = False
				break_flag = False
				count += 1
	if break_flag:
		print(-1)
		sys.exit()
		break
	ans += 1
	if count == n*(n-1)//2:
		break
	for i in range(n):
		if play[i] < n-1:
			flag[i] = True
		else:
			flag[i] = False

if ans == 0:
	print(-1)
else:
	print(ans)


Fixed submission:
s = input()
t = input()

ans = 0

for i in range(3):
	if s[i] == t[i]:
		ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())

class Node(object):
	def __init__(self, num):
		self.num = num #各ノードの数字0〜9
		self.children = []
		self.c = 0
	#heapq.heapify()する際に必要となる比較関数
	def __lt__(self, x):
		return self.value < x.value
	#子どもをセットする
	def setChildren(self, x):
		self.children.append(x)
	def solve(self,x):
		self.c += x
		for child in self.children:
			table[child].solve(x)


table = [Node(i+1) for i in range(n)]
counter = [0 for _ in range(n)]

for i in range(n-1):
	a,b = map(int,input().split())
	table[a-1].setChildren(b-1)

for i in range(q):
	p,x = map(int,input().split())
	counter[p-1] += x

for i in range(n):
	if counter[i] != 0:
		table[i].solve(counter[i])

ans = [str(table[i].c) for i in range(n)]
print(" ".join(ans))

Fixed submission:
import sys
sys.setrecursionlimit(10**7) #追加

n,q = map(int,input().split())

counter = [0 for _ in range(n)]
E = [[] for _ in range(n)]

#辺の定義
#辺E(u,v)の重みがw
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  E[b].append(a)
  E[a].append(b)

for i in range(q):
	p,x = map(int,input().split())
	counter[p-1] += x

res = 0
#行ったかどうか
color = [-1 for _ in range(n)]

#dfsで色を塗っていく
stack = [0]
color[0] = counter[0]
while stack:
  u = stack.pop()
  for v in E[u]:
    if color[v] == -1:
      stack.append(v)
      color[v] = color[u] + counter[v]

ans = [str(color[i]) for i in range(n)]
print(" ".join(ans))

Buggy python submission (verdict: Runtime Error):
import sys

def search(a,b,c,no,num):
	c[no-1] += num
	for k in range(len(a)):
		if a[k] == no:
			search(a,b,c,b[k],num)

n,q = map(int,input().split())
a = []
b = []
c = [0,0,0,0]

for i in range(n-1):
	a_dash, b_dash = map(int,input().split())
	a.append(a_dash)
	b.append(b_dash)
	#c.append(0)

for i in range(q):
	no,num = map(int,input().split())
	search(a,b,c,no,num)

for i in range(len(c)):
	sys.stdout.write(str(c[i]))
	sys.stdout.write(" ")

Fixed submission:
import sys
sys.setrecursionlimit(10**7) #追加

n,q = map(int,input().split())

counter = [0 for _ in range(n)]
E = [[] for _ in range(n)]

#辺の定義
#辺E(u,v)の重みがw
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  E[b].append(a)
  E[a].append(b)

for i in range(q):
	p,x = map(int,input().split())
	counter[p-1] += x

res = 0
#行ったかどうか
color = [-1 for _ in range(n)]

#dfsで色を塗っていく
stack = [0]
color[0] = counter[0]
while stack:
  u = stack.pop()
  for v in E[u]:
    if color[v] == -1:
      stack.append(v)
      color[v] = color[u] + counter[v]

ans = [str(color[i]) for i in range(n)]
print(" ".join(ans))