Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
from collections import Counter
H,W,M=map(int,input().split())

X=[]
Y=[]
tt=[]
for i in range(M):
    inp=list(map(int,input().split()))
    X.append(inp[0])
    Y.append(inp[1])
    tt.append((inp[0],inp[1]))
Z1=Counter(X)
Z2=Counter(Y)
maxmax=0
for i in Z1.keys():
    for j in Z2.keys():
        aa=0
        if (i,j) in tt:
            aa=-1
        if maxmax<(aa+Z1[i]+Z2[j]):
            maxmax=(aa+Z1[i]+Z2[j])
print(maxmax)


Fixed submission:
N,X,T=map(int,input().split())

if N%X==0:
    print(str(((N//X))*T))
else:
    print(str(((N//X)+1)*T))

Buggy python submission (verdict: Runtime Error):
import numpy as np
H,W,M=map(int,input().split())

B=np.zeros((H,W))
for i in range(M):
    inp=list(map(int,input().split()))
    B[inp[0]-1][inp[1]-1]=1
BT=B.T
maxmax=0
for i in range(H):
    for j in range(W):
        sumsum=0
        sumsum=np.sum(B[i])+np.sum(BT[j])-B[i][j]
        #print((np.sum(B[i]),np.sum(BT[j]),B[i][j]))
        if maxmax<sumsum:
            maxmax=sumsum
print(int(maxmax))

Fixed submission:
N,X,T=map(int,input().split())

if N%X==0:
    print(str(((N//X))*T))
else:
    print(str(((N//X)+1)*T))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())

result = 1
for a in A:
    result *= a
if result > 10 ** 18:
    result = '-1'
print(result)


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

result = 1
if 0 in A:
    print("0")
else:
    for a in A:
        result *= a
        if result > 10**18:
            result = -1
            break
    print(result)

Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())

result = "No"
for i in range(X + 1):
    if 2 * i + (X - i) * 4 == Y:
        result = "Yes"

print(result)

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

result = 1
if 0 in A:
    print("0")
else:
    for a in A:
        result *= a
        if result > 10**18:
            result = -1
            break
    print(result)
Buggy python submission (verdict: Runtime Error):
k = int(input())

mod = 7%k
period = [mod]

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    period.append(mod)
    if mod == period[0]:
        ans = '-1'
        break

print(ans)

Fixed submission:
k = int(input())

mod = 7%k
path = [mod]
ans = '-1'

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    path.append(mod)
    if mod == path[0]:
        ans = '-1'
        break

print(ans)

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

cnt = 0
mod = 7%k
period = [mod]

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    period.append(mod)
    if period[i] == period[0]:
        ans = '-1'
        break

print(ans)

Fixed submission:
k = int(input())

mod = 7%k
path = [mod]
ans = '-1'

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    path.append(mod)
    if mod == path[0]:
        ans = '-1'
        break

print(ans)

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

cnt = 0
mod = 7%k
period = [mod]

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    period.append(mod)
    if period[i] == period[0]:
        ans = -1
        break

print(ans)

Fixed submission:
k = int(input())

mod = 7%k
path = [mod]
ans = '-1'

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    path.append(mod)
    if mod == path[0]:
        ans = '-1'
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
cal = 0
for i in range(30000):
    cal += 7*(10**i)
    if cal % K == 0:
        print(len(str(cal)))
        exit()
print("-1")

Fixed submission:
k = int(input())

mod = 7%k
path = [mod]
ans = '-1'

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    path.append(mod)
    if mod == path[0]:
        ans = '-1'
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
cal = 0
for i in range(50000):
    cal += 7*(10**i)
    if cal % K == 0:
        print(len(str(cal)))
        exit()
print("-1")

Fixed submission:
k = int(input())

mod = 7%k
path = [mod]
ans = '-1'

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    path.append(mod)
    if mod == path[0]:
        ans = '-1'
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

s = int(N*(N+1)/2)
for k in range(2,N+1):
    i = 1
    while k*i <= N:
        s += k*i
        i += 1

print(s)

Fixed submission:
N = int(input())

s = int(N*(N+1)/2)
for k in range(2,N+1):
    i = 1
    while k*i <= N:
        s += k*i
        i += 1

print(s)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

a = int(x**(1/5))
b = -150

flag = 0
if flag == 0:
    for i in range(a,a+2000):
        for j in range(b,b+2000):
            if i**5 - j**5 == x:
                print(i,j)
                flag = 1
                break

if flag == 0:
    b = 0
    for i in range(a,a-2000):
        for j in range(b,b-2000):
            if i**5 - j**5 == x:
                print(i,j)
                break

Fixed submission:
x = int(input())

for a in range(-200,200):
    for b in range(-200,200):
        if a**5 - b**5 == x:
            print(a,b)
            break
    else:
        continue
    break

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

a = int(x**(1/5))
b = -150

flag = 0
if flag == 0:
    for i in range(a,a+3000):
        for j in range(b,b+3000):
            if i**5 - j**5 == x:
                print(i,j)
                flag = 1
                break

if flag == 0:
    b = 0
    for i in range(a,a-3000):
        for j in range(b,b-3000):
            if i**5 - j**5 == x:
                print(i,j)
                break

Fixed submission:
x = int(input())

for a in range(-200,200):
    for b in range(-200,200):
        if a**5 - b**5 == x:
            print(a,b)
            break
    else:
        continue
    break
Buggy python submission (verdict: Runtime Error):
S = input()
if S = "AAA" or S = "BBB":
  print("No")
else:
  print("Yes")

Fixed submission:
S = input()
if S == "AAA" or S == "BBB":
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
S = 0
for i in range(2*N):
  if i%2 == 0:
    S += A
  else:
    S += B:
  if S >= N:
    if i%2 == 0:
      ans = (i-1)/2*A + N - (i-1)/2*(A+B)
    else:
      ans = i/2 * A
    break
print(ans)

Fixed submission:
n, a,b = map(int, input().split())
ans = n//(a+b)*a
rem = n%(a+b)
ans+=min(a,rem)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = int(input())
print(max(a+b,a-b,a*b))

Fixed submission:
a,b = map(int,input().split())
print(max(a+b,a-b,a*b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
H = list(map(int, input().split()))
for i in reversed(range(n)):
    if i == 0:
        print("Yes")
    elif H[i] - H[i - 1] == -1:
        H[i - 1] -= 1
    elif H[i] - H[i - 1] < -1:
        print("No")
        break
    else:
        continue

Fixed submission:
a,b,c = map(int,input().split())
d = b + c - a
if d >= 0:
  print(d)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
for i in reversed(range(n)):
    if i == 0:
        print("Yes")
    elif H - H[i - 1] == -1:
        H[i - 1] -= 1
    elif H[i] - H[i - 1] < -1:
        print("No")
        break
    else:
        continue

Fixed submission:
n = int(input())
H = list(map(int, input().split()))
for i in reversed(range(n)):
    if i == 0:
        print("Yes")
    elif H[i] - H[i - 1] == -1:
        H[i - 1] -= 1
    elif H[i] - H[i - 1] < -1:
        print("No")
        break
    else:
        continue
Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
X = max(C,D)
Y = min(C,D)
def gcd(a,b):
  while b!= 0:
    a,b = b,a%b
  return a
l = C*D/ gcd(X,Y)
def f(x):
  return x - (x//C + x//D - x//l)
ans = f(B) - f(A-1)
print(ans)

Fixed submission:
S = input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
  print("Bad")
else:
  print("Good")

Buggy python submission (verdict: Runtime Error):
N,L = map(int,input().split())
S = 0
b = abs(L)
for i in range(1,N+1):
  a = L + i - 1
  S += a
  b = min(abs(a),b)
if -N < L:
  ans = S - b
else:
  ans = S + b
print(ans)

Fixed submission:
S = input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
  print("Bad")
else:
  print("Good")
Buggy python submission (verdict: Runtime Error):
W,H,x,y = map(int,input().split())
if x==0 or x==W or y==0 or y==H:
  s = H*W/2
  print('{:.10f}'.format(s))
else:
  a = min(x*H,(W-x)*H)
  b = min(y*W,(H-y)*W)
  s = max(a,b)
  print('{:.10f}'.format(s))
if x==0 and y==0:
  print(0)
elif x==W and y==0:
  print(0)
elif x==0 and y==H:
  print(0)
elif x==W and y==H:
  print(0)
elif y == H*x/W or y == (-1)*H*x/W:
  print(1)
else:
  print(0)

Fixed submission:
X,A = map(int,input().split())
if X<A:
  print(0)
if X>=A:
  print(10)

Buggy python submission (verdict: Runtime Error):
W,H,x,y = map(int,input().split())
if x==0 or x==W or y==0 or y==H:
  s = H*W/2
  print('{:.10f}'.format(s))
else:
  a = min(x*H,(W-x)*H)
  b = min(y*W,(H-y)*W)
  s = max(a,b)
  print('{:.10f}'.format(s))
if y == H*x/W:
  print(1)
else:
  print(0)

Fixed submission:
X,A = map(int,input().split())
if X<A:
  print(0)
if X>=A:
  print(10)

Buggy python submission (verdict: Runtime Error):
A,X = map(int,imput().split())
if X<A:
  print(0)
if x>=A:
  print(10)

Fixed submission:
X,A = map(int,input().split())
if X<A:
  print(0)
if X>=A:
  print(10)
Buggy python submission (verdict: Runtime Error):
rom math import ceil

D, G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]

ans = float("inf")
for bit in range(1 << D):
    cnt = 0
    sum = 0
    remain = set(range(1,D+1))

    for i in range(D):
        if bit & (1 << i):
            cnt += pc[i][0]
            sum += pc[i][0]*(i+1)*100 + pc[i][1]
            remain.discard(i+1)

    if sum < G:
        use = max(remain)
        n = min(pc[use-1][0], ceil((G-sum)/(use*100)))
        """
        if use == 0:
            n = 0
        elif (G - sum)%(use%100) == 0:
            n = min(pc[use-1][0], (G - sum)//(use*100))
        else:
            n = min(pc[use-1][0], (G - sum)//(use*100)+1)
        """
        cnt += n
        sum += n*use*100

    if sum >= G:
        ans = min(ans,cnt)

print(ans)

Fixed submission:
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

for bit in range(1 << d):
    count = 0
    sum = 0
    nokori = set(range(1, d + 1))

    for i in range(d):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
            nokori.discard(i + 1)

    # G 点に満たなければ nokori のうち一番大きいものを解く
    if sum < g:
        use = max(nokori)
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100

    if sum >= g:
        ans = min(ans, count)

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

l=len(n)


if n[l-1]=="3":
    print("bon")
elif (n[l-1]==="0" or n[l-1]==="1" or n[l-1]==="6" or n[l-1]==="8"):
    print("pon")

else :
    print("hon")

Fixed submission:
n=str(input())

l=len(n)


if n[l-1]=="3":
    print("bon")
elif (n[l-1]=="0" or n[l-1]=="1" or n[l-1]=="6" or n[l-1]=="8"):
    print("pon")

else :
    print("hon")
Buggy python submission (verdict: Runtime Error):
n=int(input())

s=input().split()

ans=[0 for i in range(n)]
for i in range(0,n-1):
    s[i]=int(s[i])
    ans[s[i]-1]+=1

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




Fixed submission:
n=int(input())

s=[0]*n

for i in range(0,n):
    s[i]=input()


s_set=set(s)
ans=len(s_set)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())

def gcd2(a,b,c):
    d=math.gcd(a,b)
    e=math.gcd(c,d)
    return e
    
s=0
for i1 in range(1,n+1):
    for i2 in range(1,n+1):
        for i3 in range(1,n+1):
            s+=gcd2(i1,i2,i3)

print(s)



Fixed submission:
import math
n=int(input())

def gcd2(a,b,c):
    d=math.gcd(a,b)
    e=math.gcd(c,d)
    return e
    
s=0
s1=0
s2=0
s3=0

for i in range(1,n+1):
    s1+=i
    for i2 in range(i+1,n+1):
        s2+=math.gcd(i,i2)
        for i3 in range(i2+1,n+1):
            s3+=gcd2(i,i2,i3)

s=s1+6*s2+6*s3

print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

def gcd(a,b,c):
    d=min(a,b,c)
    for i in range(0,d):
        if a%(d-i)==0 and b%(d-i)==0 and c%(d-i)==0:
            return d-i
            break

s=0
for i1 in range(1,n+1):
    for i2 in range(1,n+1):
        for i3 in range(1,n+1):
            s+=gcd(i1,i2,i3)

print(s)



Fixed submission:
import math
n=int(input())

def gcd2(a,b,c):
    d=math.gcd(a,b)
    e=math.gcd(c,d)
    return e
    
s=0
s1=0
s2=0
s3=0

for i in range(1,n+1):
    s1+=i
    for i2 in range(i+1,n+1):
        s2+=math.gcd(i,i2)
        for i3 in range(i2+1,n+1):
            s3+=gcd2(i,i2,i3)

s=s1+6*s2+6*s3

print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
m = 1
for a in A:
  m *= a
print(m if m <= 10**18 else -1)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
m = 1
for a in A:
  m *= a
  if m > 10**18:
    break
if min(A) == 0:
  m = 0
print(m if m <= 10**18 else -1)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
print(max(N - sum([int(x) for x in input.split()]), -1))

Fixed submission:
N, M = map(int, input().split())
print(max(N - sum([int(x) for x in input().split()]), -1))
Buggy python submission (verdict: Runtime Error):
N = int(input)
P = [int(x) for x in input().split()]
pmin = max(P)
cnt = 0
for p in P:
  if p <= pmin:
    cnt += 1
    pmin = p
print(cnt)

Fixed submission:
N = int(input())
P = [int(x) for x in input().split()]
pmin = max(P)
cnt = 0
for p in P:
  if p <= pmin:
    cnt += 1
    pmin = p
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
p = 1000000007
N = int(input())
T = [[] for _ in range(N)]
for _ in range(N - 1):
  (a, b) = (int(x) - 1 for x in input().split())
  T[a].append(b)
  T[b].append(a)
P = [-1] * N
P[0] = 0
Q = [0]
for i in range(N):
  q = Q[i]
  for adj in T[q]:
    if 0 <= P[adj]:
      continue
    P[adj] = q
    Q.append(adj)
ST = [[] for _ in range(N)]
for q in Q[N - 1:0:-1]:
  s = sum(ST[q]) + 1
  ST[P[q]].append(s)
  ST[q].append(N - s)
B = [pow(1 << i, p - 2, p) for i in range(N)]
H = [0] * N
ans = 0
for S in ST:
  ans += B[1] * ((1 - B[-1] - sum([(B[N - 1 - s] * (1 - B[s])) % p for s in S])) % p)
  ans %= p
print(ans)

Fixed submission:
p = 1000000007
N = int(input())
T = [[] for _ in range(N)]
for _ in range(N - 1):
  (a, b) = (int(x) - 1 for x in input().split())
  T[a].append(b)
  T[b].append(a)
P = [-1] * N
P[0] = 0
Q = [0]
for i in range(N):
  q = Q[i]
  for adj in T[q]:
    if 0 <= P[adj]:
      continue
    P[adj] = q
    Q.append(adj)
ST = [[] for _ in range(N)]
for q in Q[N - 1:0:-1]:
  s = sum(ST[q]) + 1
  ST[P[q]].append(s)
  ST[q].append(N - s)
B = [1] * N
B[-1] = pow(1 << (N - 1), p - 2, p)
for i in range(N - 1, 0, -1):
  B[i - 1] = B[i] * 2 % p
H = [0] * N
ans = 0
for S in ST:
  ans += B[1] * ((1 - B[-1] - sum([(B[N - 1 - s] * (1 - B[s])) % p for s in S])) % p)
  ans %= p
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
p = 1000000007
N = int(input())
T = [[] for _ in range(N)]
for _ in range(N - 1):
  (a, b) = (int(x) - 1 for x in input().split())
  T[a].append(b)
  T[b].append(a)
P = [-1] * N
P[0] = 0
Q = [0]
for i in range(N):
  q = Q[i]
  for adj in T[q]:
    if 0 <= P[adj]:
      continue
    P[adj] = q
    Q.append(adj)
ST = [[] for _ in range(N)]
for q in Q[N - 1:0:-1]:
  s = sum(ST[q]) + 1
  ST[P[q]].append(s)
  ST[q].append(N - s)
B = [pow(1 << i, p - 2, p) for i in range(N)]
H = [0] * N
ans = 0
for S in ST:
  ans += B[1] * ((1 - B[-1] - sum([(B[N - 1 - s] * (1 - B[s])) % p for s in S])) % p)
  ans %= p
print(ans)

Fixed submission:
p = 1000000007
N = int(input())
T = [[] for _ in range(N)]
for _ in range(N - 1):
  (a, b) = (int(x) - 1 for x in input().split())
  T[a].append(b)
  T[b].append(a)
P = [-1] * N
P[0] = 0
Q = [0]
for i in range(N):
  q = Q[i]
  for adj in T[q]:
    if 0 <= P[adj]:
      continue
    P[adj] = q
    Q.append(adj)
ST = [[] for _ in range(N)]
for q in Q[N - 1:0:-1]:
  s = sum(ST[q]) + 1
  ST[P[q]].append(s)
  ST[q].append(N - s)
B = [1] * N
B[-1] = pow(1 << (N - 1), p - 2, p)
for i in range(N - 1, 0, -1):
  B[i - 1] = B[i] * 2 % p
H = [0] * N
ans = 0
for S in ST:
  ans += B[1] * ((1 - B[-1] - sum([(B[N - 1 - s] * (1 - B[s])) % p for s in S])) % p)
  ans %= p
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
k = 0
while k ** 2 < N:
  k++
for i in range(k, 0, -1):
  if N % i:
    continue
  print(N // i + i - 2)
  break

Fixed submission:
N = int(input())
k = 0
while k ** 2 < N:
  k += 1
for i in range(k, 0, -1):
  if N % i:
    continue
  print(N // i + i - 2)
  break
Buggy python submission (verdict: Runtime Error):
N = input()
even = N // 2
print((N - even) / N)

Fixed submission:
N = int(input())
even = N // 2
print((N - even) / N)
Buggy python submission (verdict: Runtime Error):
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
def eratosthenes(limit):
  E = [1] * (limit + 1)
  E[0], E[1] = 0, 0
  prime_table = []
  for i, e in enumerate(E):
    if e == 0:
      continue
    prime_table.append(i)
    for j in range(i, limit + 1, i):
      E[j] = 0
  return prime_table
P = eratosthenes(GCD)
print(len([p for p in P if GCD % p == 0]) + 1)

Fixed submission:
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
k = 1
cnt = 1
while GCD > 1:
  k += 1
  if k ** 2 > GCD:
    cnt += 1
    break
  if GCD % k:
    continue
  cnt += 1
  while GCD % k == 0:
    GCD //= k
print(cnt)

Buggy python submission (verdict: Runtime Error):
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
E = [1] * (GCD + 1)
E[0], E[1] = 0, 0
P = []
for i, e in enumerate(E):
  if e == 0:
    continue
  P.append(i)
  for j in range(i, GCD + 1, i):
    E[j] = 0
print(len([p for p in P if GCD % p == 0]) + 1)

Fixed submission:
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
k = 1
cnt = 1
while GCD > 1:
  k += 1
  if k ** 2 > GCD:
    cnt += 1
    break
  if GCD % k:
    continue
  cnt += 1
  while GCD % k == 0:
    GCD //= k
print(cnt)

Buggy python submission (verdict: Runtime Error):
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
E = [1] * (GCD + 1)
E[0], E[1] = 0, 0
P = []
for i, e in enumerate(E):
  if e == 0:
    continue
  P.append(i)
  for j in range(i, GCD + 1, i):
    E[j] = 0
print(len([p for p in P if GCD % p == 0]) + 1)

Fixed submission:
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
k = 1
cnt = 1
while GCD > 1:
  k += 1
  if k ** 2 > GCD:
    cnt += 1
    break
  if GCD % k:
    continue
  cnt += 1
  while GCD % k == 0:
    GCD //= k
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
k = 1
cnt = 1
while GCD > 1:
  k += 1
  if GCD % k:
    continue
  cnt += 1
  while GCD % k == 0:
    GCD //= k
print(cnt)

Fixed submission:
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
k = 1
cnt = 1
while GCD > 1:
  k += 1
  if k ** 2 > GCD:
    cnt += 1
    break
  if GCD % k:
    continue
  cnt += 1
  while GCD % k == 0:
    GCD //= k
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
k = 1
cnt = 1
while GCD > 1:
  k += 1
  if GCD % k:
    continue
  cnt += 1
  while GCD % k == 0:
    GCD //= k
print(cnt)

Fixed submission:
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
k = 1
cnt = 1
while GCD > 1:
  k += 1
  if k ** 2 > GCD:
    cnt += 1
    break
  if GCD % k:
    continue
  cnt += 1
  while GCD % k == 0:
    GCD //= k
print(cnt)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = 'R' + input() + 'L'
UH = [0] * (N + 1)
d = 'R'
for i, s in enumerate(S):
  if s == 'R':
    if S[i + 1] == 'L':
      UH[i] += 1
  else:
    if S[i - 1] == 'R':
      UH[i - 1] += 1
UH[0] = min(UH[0], 1)
UH[N] = min(UH[N], 1)
UH.sort(reverse=True)
for i in range(K):
  UH[i] = 0
if sum(UH) == 0:
  UH[0] = 1
print(N - sum(UH))

Fixed submission:
N, K = map(int, input().split())
S = 'R' + input() + 'L'
UH = [0] * (N + 1)
d = 'R'
for i, s in enumerate(S):
  if s == 'R':
    if S[i + 1] == 'L':
      UH[i] += 1
  else:
    if S[i - 1] == 'R':
      UH[i - 1] += 1
UH[0] = min(UH[0], 1)
UH[N] = min(UH[N], 1)
UH.sort(reverse=True)
for i in range(min(K, N + 1)):
  UH[i] = 0
if sum(UH) == 0:
  UH[0] = 1
print(N - sum(UH))
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
E = [[] for _ in range(N)]
C = [0] * N
C[0] = 0
for _ in range(N - 1):
  a, b = map(int, input().split())
  E[a - 1].append(b - 1)
  E[b - 1].append(a - 1)
for _ in range(Q):
  p, x = map(int, input().split())
  C[p - 1] += x
D = [-1] * N
D[0] = 0
Q = [0]
while Q:
  q = Q.pop(0)
  for adj in E[q]:
    if D[adj] >= 0:
      continue
    D[adj] = D[q] + 1
    C[adj] += C[q]
    Q.append(adj)
print(' '.join([str(c) for c in C]))

Fixed submission:
N, Q = map(int, input().split())
E = [[] for _ in range(N)]
C = [0] * N
C[0] = 0
for _ in range(N - 1):
  a, b = map(int, input().split())
  E[a - 1].append(b - 1)
  E[b - 1].append(a - 1)
for _ in range(Q):
  p, x = map(int, input().split())
  C[p - 1] += x
D = [-1] * N
D[0] = 0
Q = [0] * N
enq = 0
for pos in range(N):
  q = Q[pos]
  for adj in E[q]:
    if D[adj] >= 0:
      continue
    D[adj] = D[q] + 1
    C[adj] += C[q]
    enq += 1
    Q[enq] = adj
print(' '.join([str(c) for c in C]))

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
E = [[] for _ in range(N)]
C = [0] * N
C[0] = 0
for _ in range(N - 1):
  a, b = map(int, input().split())
  E[a - 1].append(b - 1)
  E[b - 1].append(a - 1)
for _ in range(Q):
  p, x = map(int, input().split())
  C[p - 1] += x
D = [-1] * N
D[0] = 0
Q = [0]
while Q:
  q = Q.pop(0)
  for adj in E[q]:
    if D[adj] >= 0:
      continue
    D[adj] = D[q] + 1
    C[adj] += C[q]
    Q.append(adj)
print(' '.join([str(c) for c in C]))

Fixed submission:
N, Q = map(int, input().split())
E = [[] for _ in range(N)]
C = [0] * N
C[0] = 0
for _ in range(N - 1):
  a, b = map(int, input().split())
  E[a - 1].append(b - 1)
  E[b - 1].append(a - 1)
for _ in range(Q):
  p, x = map(int, input().split())
  C[p - 1] += x
D = [-1] * N
D[0] = 0
Q = [0] * N
enq = 0
for pos in range(N):
  q = Q[pos]
  for adj in E[q]:
    if D[adj] >= 0:
      continue
    D[adj] = D[q] + 1
    C[adj] += C[q]
    enq += 1
    Q[enq] = adj
print(' '.join([str(c) for c in C]))
Buggy python submission (verdict: Runtime Error):
N = int(input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
L = 0
for i in range(N):
  l = min(A[i], B[i])
  r = min(A[i + 1], B[i])
  A[i + 1] -= r
  L += l + r
print(L)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
L = 0
for i in range(N):
  l = min(A[i], B[i])
  B[i] -= l
  r = min(A[i + 1], B[i])
  A[i + 1] -= r
  L += l + r
print(L)
Buggy python submission (verdict: Runtime Error):
n = int(input())
P = [int(x) for x in input().split()]
cnt = 0
for i in range(1, n - 1):
  if p[i - 1] < p[i] and p[i + 1] < p[i]:
    continue
  if p[i] < p[i - 1] and p[i] < p[i + 1]:
    continue
  cnt += 1
print(cnt)

Fixed submission:
n = int(input())
P = [int(x) for x in input().split()]
cnt = 0
for i in range(1, n - 1):
  if P[i - 1] < P[i] and P[i + 1] < P[i]:
    continue
  if P[i] < P[i - 1] and P[i] < P[i + 1]:
    continue
  cnt += 1
print(cnt)