Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, a = map(int, input().split())
x = [int(i) for i in input().split()]

dp = [[[0 for i in range(n+1)] for j in range(n+1)] for k in range(50*n+1)]
count = 0

def dfs(i, j, sum):
    global count
    if dp[sum][j][i] != 0:
        return dp[sum][j][i]

    if i == n:
        if sum == a*j and j != 0:
            return 1
        else:
            return 0

    dp[sum][j][i] = dfs(i+1, j, sum) + dfs(i+1, j+1, sum + x[i])
    return dp[sum][j][i]

print(dfs(0, 0, 0))

Fixed submission:
import collections

n, a = [int(i) for i in input().split()]
x = [int(i) - a for i in input().split()]

ans = 0
sums = collections.Counter([0, x[0]])

for i in x[1:]:
    temp = collections.Counter()
    for s, c in sums.items():
        temp[s + i] += c
    sums += temp
    #print(sums)

print(sums[0] - 1)
Buggy python submission (verdict: Runtime Error):
S=long(input())
#N=list(map(int,input().split()))

ans=long((S-1)*S/2)

print(ans)

Fixed submission:
S=int(input())
#N=list(map(int,input().split()))
ans=(S-1)*S//2
print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
import numpy as np
from matplotlib import pyplot



N=list(map(int,input().split()))
#A=list(map(int,input().split()))

if N[0]%(2*N[1]+1)==0:
 S=int(N[0]/(2*N[1]+1))
else:
 S=int(N[0]/(2*N[1]+1))+1
    
print(S)    

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

if N[0]%(2*N[1]+1)==0:
 S=int(N[0]/(2*N[1]+1))
else:
 S=int(N[0]/(2*N[1]+1))+1
    
print(S)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(range(N))
S=list(range(N-1))

for i in range(N):
    A[i]=int(input())

for i in range(N):
    r=0
    for j in range(N):
     if j!=i:
       if A[j]>r:
          r=A[j]

    print(r)

Fixed submission:
N=int(input())
A=list(range(N))


r=0
count=0
for i in range(N):
    A[i]=int(input())
    if A[i]>r:
     r=A[i]
     count=i

for i in range(N):
    if i==count:
     del A[i]
     print(max(A))
    else:
     print(r)
Buggy python submission (verdict: Time Limit Exceeded):
N=input()
N=int(N)
M=list(map(int,input().split()))

for i in range(N):
  M[i]=M[i]-(i+1)


min=10**14
for i in range(N):
  sum=0
  p=M[i]
  for j in range(N):
      sum=sum+abs(M[j]-p)
  if sum<min:
    min=sum

print(min)



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

for i in range(N):
  M[i]=M[i]-(i+1)

M.sort()

if N%2==0:
  p=int((M[int(N/2)-1]+M[int(N/2)])/2)
else:
  p=M[int((N+1)/2)-1] 

sum=0
for i in range(N):
  sum=sum+abs(M[i]-p)

  
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
temp = 1
for i in a:
  temp *= i
if temp > 10**18:
  print(-1)
else:
  print(temp)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
temp = 1
if 0 in a:
  print(0)
else:
  for i in a:
    temp *= i
    if temp > 10**18:
      temp = -1
      break
  print(temp)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1, (n + 1)):
  print(a.count(i))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
anslist = [0] * n
for i in a:
  anslist[i - 1] += 1
for i in anslist:
  print(i)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
for i in range(10000):
  if int(i * 0.08) == a and int(i * 0.1) == b:
    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: Runtime Error):
a, b = map(int, input().split())
for i in range(10000):
  if int(i * 0.08) == a and int(i * 0.1) == b:
    print(i)
    exit()
print(=1)

Fixed submission:
a, b = map(int, input().split())
for i in range(10000):
  if int(i * 0.08) == a and int(i * 0.1) == b:
    print(i)
    exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
A, B = input().split()
1 <= A <= 100
1 <= B <= 100
sum = A*B
print(sum)

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

Buggy python submission (verdict: Runtime Error):
1<=A<=100
1<=B<=100
A = input(int())
B = input(int())
sum = A*B
print(sum)


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

Buggy python submission (verdict: Runtime Error):
A = 1<=A<=100
B = 1<=B<=100
sum = A*B
print(sum)

Fixed submission:
a, b =map(int,input().split())
print(a*b)
Buggy python submission (verdict: Runtime Error):
S = input()
if S = ABC:
  print("ARC")
elif S = ARC:
  print("ABC")
else:

Fixed submission:
S = input()
if S == "ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
cnt = 0
for i in range(1,min(b,c)):
  if a%i==0 and b%i==0:
    cnt++
    if cnt == c:
      print(i)
      break

Fixed submission:
a, b, c = map(int, input().split())
cnt = 0
for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        cnt += 1
        if cnt == c:
            print(i)
            break
Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split(" "))
if N != 0:
    p_list = list(map(int,input().split(" ")))
target = X
target_num_min = X
target_num_plus = X
if X in p_list:
    while True:
        target_num_min -= 1
        if target_num_min not in p_list:
            target = target_num_min
            break
        target_num_plus += 1
        if target_num_plus not in p_list:
            target = target_num_plus
            break
print(target)

Fixed submission:
X,N = map(int,input().split(" "))
target = X
if N != 0:
    p_list = list(map(int,input().split(" ")))

    target_num_min = X
    target_num_plus = X
    if X in p_list:
        while True:
            target_num_min -= 1
            if target_num_min not in p_list:
                target = target_num_min
                break
            target_num_plus += 1
            if target_num_plus not in p_list:
                target = target_num_plus
                break
print(target)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Alist = list(map(int,input().split(" ")))
ansList = list(range(N))
count = 0
for i in range(N):
    flag = False
    for j in range(N):
        if i != j:
            if (Alist[i]%Alist[j]==0):
                flag = True
    if flag==False:
        count+=1


print(count)

Fixed submission:
N = int(input())
Alist = list(map(int,input().split(" ")))
Alist.sort()
Amax = Alist[-1]
dp = [1]*(Amax+1)
count = 0
for i in range(len(Alist)-1):
    p = Alist[i]
    if dp[p] == 1:
        for j in range(Amax//p+1):
            dp[p*j] = 0
        if Alist[i] != Alist[i+1]:
            count+=1
if dp[Amax] == 1:
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
A,B,C,K = int(input().split(' '))
out = 0
if A>K:
  print(K)
else:
  out += A
  K -= A
  if B > K:
    print(out)
  else:
    K -= B
    out -= K
    print(out)

Fixed submission:
A,B,C,K = map(int,input().split(' '))
out = 0
if A>K:
  print(K)
else:
  out += A
  K -= A
  if B > K:
    print(out)
  else:
    K -= B
    out -= K
    print(out)
Buggy python submission (verdict: Runtime Error):
import math
x,y=input().split()
x=int(x)
y=int(y)
 
def lcm(x, y):
    return (x * y)/math.gcd(x, y)
 
print(lcm(x, y))

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

if (a<b):
  tmp = a
  a = b;
  b = tmp

r = a % b
while(r!=0):
  a = b
  b = r
  r = a % b

print(int(x/b))

Buggy python submission (verdict: Runtime Error):
x,y=input().split()
x=int(x)
y=int(y)

def lcm(x, y):
    return (x * y)/math.gcd(x, y)

print(lcm(x, y))

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

if (a<b):
  tmp = a
  a = b;
  b = tmp

r = a % b
while(r!=0):
  a = b
  b = r
  r = a % b

print(int(x/b))

Buggy python submission (verdict: Runtime Error):
import math
x,y=input().split()
x=int(x)
y=int(y)

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(x, y))

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

if (a<b):
  tmp = a
  a = b;
  b = tmp

r = a % b
while(r!=0):
  a = b
  b = r
  r = a % b

print(int(x/b))
Buggy python submission (verdict: Runtime Error):
word = {'A':0,'B':1,'C':2,'D':3,'E':4,'F':5,'G':6,'H':7,'I':8,'J':9,'K':10,'L':11,'M':12,'N':13,'O':14,'P':15,'Q':16,'R':17,'S':18,'T':19,'U':20,'V':21,'W':22,'X':23,'Y':24,'Z':25}
word_reverse={v: k for k, v in word.items()}
x=input()
y=input()
Ans=''
for i in x:
  Ans=Ans+word_reverse[word[i]+int(y)]

print(Ans)

Fixed submission:
word = {'A':0,'B':1,'C':2,'D':3,'E':4,'F':5,'G':6,'H':7,'I':8,'J':9,'K':10,'L':11,'M':12,'N':13,'O':14,'P':15,'Q':16,'R':17,'S':18,'T':19,'U':20,'V':21,'W':22,'X':23,'Y':24,'Z':25}
word_reverse={v: k for k, v in word.items()}
x=input()
y=input()
Ans=''
for i in y:
  if word[i]+int(x) > 25:
    z = (word[i]+int(x)) % 26
  else:z=word[i]+int(x)
  Ans=Ans+word_reverse[z]

print(Ans)
Buggy python submission (verdict: Runtime Error):
r=int(input())
R-r*r
print(R)

Fixed submission:
r=int(input())
R=r*r
print(R)

Buggy python submission (verdict: Runtime Error):
r=input()
R=r*r
print(R)

Fixed submission:
r=int(input())
R=r*r
print(R)
Buggy python submission (verdict: Runtime Error):
x = list(map(int, input().split()))
for i in range(0, len(x)):
  if x[i] == 0:
    print(i + 1)
    return


Fixed submission:
x = list(map(int, input().split()))
for i in range(0, len(x)):
  if x[i] == 0:
    print(i + 1)
    break
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input().strip()
after = []
for s in S:
  x = ord(s) + N
  if x > ord('Z'):
    x = x - ord('Z')
  after.append(chr(x))
print(''.join(x))

Fixed submission:
N = int(input())
S = input().strip()
after = []
for s in S:
  x = ord(s) + N
  if x > ord('Z'):
    x = x - 26
  after.append(chr(x))
print(''.join(after))
Buggy python submission (verdict: Runtime Error):
r = int(input().split())
print(r * r)


Fixed submission:
r = int(input().strip())
print(r * r)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

A = list(map(int, input().split()))
a = A[0]
for i in range(1, len(A)):
    a = math.gcd(a, A[i])

print(a)



Fixed submission:
def gcd(a,b): 
    if(b==0): 
        return a 
    else: 
        return gcd(b,a%b)


N = int(input())

A = list(map(int, input().split()))
a = A[0]
for i in range(1, len(A)):
    a = gcd(a, A[i])

print(a)
Buggy python submission (verdict: Runtime Error):


def update(M, S, i, j, H, W, cluster):
    for i_n in [i - 1, i, i + 1]:
        for j_n in [j - 1, j, j + 1]:
            if i_n >= H or i_n < 0:
                continue
            if j_n >= W or j_n < 0:
                continue

            if i_n == i and j_n == j:
                continue
            if abs(i - i_n) + abs(j - j_n) == 2:
                continue

            if S[i][j] != S[i_n][j_n] and M[i_n][j_n] == 0:
                # print(M)
                M[i_n][j_n] = cluster
                update(M, S, i_n, j_n, H, W, cluster)


H, W = list(map(int, input().split()))
S = []
for i in range(H):
    S.append(input().strip())

cluster = 1
counts_B = {}
counts_W = {}
M = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
    for j in range(W):
        if M[i][j] == 0:
            M[i][j] = cluster
            update(M, S, i, j, H, W, cluster)
            cluster = cluster + 1
        counts_B[M[i][j]] = 0
        counts_W[M[i][j]] = 0


for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            counts_B[M[i][j]] += 1
        else:
            counts_W[M[i][j]] += 1

    #     print(M[i][j], end=" ")
    # print("")

total = 0
for k in counts_B.keys():
    if k in counts_W:
        total += counts_B[k] * counts_W[k]
    # print(counts[k])

print(total)


Fixed submission:
import sys

sys.setrecursionlimit(2000000)


def update(M, S, i, j, H, W, cluster):
    for i_n in [i - 1, i, i + 1]:
        for j_n in [j - 1, j, j + 1]:
            if i_n >= H or i_n < 0:
                continue
            if j_n >= W or j_n < 0:
                continue

            if i_n == i and j_n == j:
                continue
            if abs(i - i_n) + abs(j - j_n) == 2:
                continue

            if S[i][j] != S[i_n][j_n] and M[i_n][j_n] == 0:
                # print(M)
                M[i_n][j_n] = cluster
                update(M, S, i_n, j_n, H, W, cluster)


H, W = list(map(int, input().split()))
S = []
for i in range(H):
    S.append(input().strip())

cluster = 1
counts_B = {}
counts_W = {}
M = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
    for j in range(W):
        if M[i][j] == 0:
            M[i][j] = cluster
            update(M, S, i, j, H, W, cluster)
            cluster = cluster + 1
        counts_B[M[i][j]] = 0
        counts_W[M[i][j]] = 0


for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            counts_B[M[i][j]] += 1
        else:
            counts_W[M[i][j]] += 1

    #     print(M[i][j], end=" ")
    # print("")

total = 0
for k in counts_B.keys():
    if k in counts_W:
        total += counts_B[k] * counts_W[k]
    # print(counts[k])

print(total)
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())

w = [0] * N
v = [0] * N
for i in range(N):
  w[i], v[i] = map(int, input().split())

# dp[i, w]:  i-r achaag oroltsuulaad , 
#            w hurtelh achaatai max value
# dp[i]: w1 ,,,,,wN

dp = [ {} for i in range(N)]

def DP(i, Wi):
  if Wi in dp[i]:
    return dp[i][Wi]

  if i == 0:
    if Wi >= w[i]:
      dp[i][Wi] = v[i]
    else:
      dp[i][Wi] = 0
    return dp[i][Wi]
  
  vmax = DP(i - 1, Wi)
  if Wi >= w[i]:
    vmax = max(vmax, v[i] + DP(i - 1, Wi - w[i]))
  dp[i][Wi] = vmax
  return dp[i][Wi]

print(DP(N - 1, W))


Fixed submission:
import numpy as np 

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

w_all = np.zeros(W + 1, dtype=int)

for i in range(N):
  w, v = map(int, input().split())
  w_all[w:] = np.maximum(w_all[w:], w_all[:-w] + v)

print(w_all[W])
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))

w, cnt = 0, 0
while True:
  w += ((-1) ** cnt) * cnt
  cnt += 1

  if x + w not in p:
  　print(x + w)
  	break

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

w, cnt = 0, 0
while cnt < 201:
  if x + w not in p:
    print(x + w)
    break

  w += ((-1) ** cnt) * cnt
  cnt += 1
Buggy python submission (verdict: Runtime Error):
c = 10**18

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

for i in a:
    b *= i
    if b > c:
        print(-1)
        return

print(b)

Fixed submission:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main()

Buggy python submission (verdict: Runtime Error):
c = 10**18

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

if 0 in a:
    print(0)
    return

for i in a:
    b *= i

if b > c:
    print('-1')
else:
    print(b)

Fixed submission:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main()

Buggy python submission (verdict: Time Limit Exceeded):
c = 10**18

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

for i in a:
    b *= i

if b > c:
    print('-1')
else:
    print(b)

Fixed submission:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main()
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 1000000007
# f(x) = f(x - 1) + f(x - 2)の場合のdp
def f_dp(x, a):
    dp = [0 for i in range(x + 1)]
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in range(2, x + 1):
        if i not in a:
            dp[i] = dp[i - 1] + dp[i -2]
    return dp[n] % MOD

if __name__ == "__main__":
    n, m = map(int, input().split())
    a = [int(input()) for i in range(m)]

    dp = f_dp(n, a)
    print(dp)

Fixed submission:
MOD = 1000000007
# f(x) = f(x - 1) + f(x - 2)の場合のdp
def f_dp(x, a):
    dp = [0] * (x + 1)
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in range(2, x + 1):
        if i not in a:
            dp[i] = dp[i - 1] + dp[i -2]
    return dp[n] % MOD

if __name__ == "__main__":
    n, m = map(int, input().split())
    a = set([int(input()) for i in range(m)])

    dp = f_dp(n, a)
    print(dp)

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 1000000007
# f(x) = f(x - 1) + f(x - 2)の場合のdp
def f_dp(x, a):
    dp = [0 for i in range(x + 1)]
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in range(2, x + 1):
        if i not in a:
            dp[i] = dp[i - 1] + dp[i -2]
    return dp[n] % MOD

if __name__ == "__main__":
    n, m = map(int, input().split())
    a = [int(input()) for i in range(m)]

    dp = f_dp(n, a)
    print(dp)

Fixed submission:
MOD = 1000000007
# f(x) = f(x - 1) + f(x - 2)の場合のdp
def f_dp(x, a):
    dp = [0] * (x + 1)
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in range(2, x + 1):
        if i not in a:
            dp[i] = dp[i - 1] + dp[i -2]
    return dp[n] % MOD

if __name__ == "__main__":
    n, m = map(int, input().split())
    a = set([int(input()) for i in range(m)])

    dp = f_dp(n, a)
    print(dp)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

adjusted_t = t[:-1]

if s==adjuested_t:
  print("Yes")
else:
  print("No")
  

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

adjusted_t = t[:-1]

if s==adjusted_t:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
A, B, N = map(int,input().split())
if(B-A < N) :
 cal = int((A*N)/B) - A*int(N/B)
 print(cal)
else 
 max = 0
 i=N
 while(1):
  cal = int((A*i)/B) - A*int(i/B)
  if(cal > max):
   max =cal
  i += -1
  if(i < 0):
   print(max)
   break;

Fixed submission:
K = int(input())
A, B = map(int,input().split())
number = A
count = 0
while(1):
 if(number%K == 0):
  count +=1
 number += 1  
 if(number > B):
  if(count >0):
    print("OK")
  else:
    print("NG")
  break;
Buggy python submission (verdict: Runtime Error):
import math
Target = int(input())
original = 100
i=0;
while(1)
 i=i+1;
 original = int(original + original*0.01)
 if(original > target)
   print(i)
   break;

Fixed submission:
Target = int(input())
original = 100
i=1;
while(1):
 original = original + int(original*0.01)
 if(original >= Target):
   print(i)
   break;
 i=i+1;
Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int,input().split()) 
P = [list(map(int,input().split())) for i in range(3)]
Red = sorted(P[0], reverse=True)
Green = sorted(P[1], reverse=True)
Trans = sorted(P[2], reverse=True)

pre_max = sum(Red[:X]) + sum(Green[:Y])
Red = Red[:X]
Green = Green[:Y]
for i in range (C):
  maxo = pre_max
  if (Trans[i] > Red[-1+i]):
    maxo= pre_max + Trans[i] - Red[-1+i]
for i in range (C):
  if (Trans[i] > Green[-1+i]):
    maxo = pre_max + Trans[i] - Green[-1+i]
    
print(maxo)

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):
number = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = int(input())
print(number[N+1])

Fixed submission:
number = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = int(input())
print(number[N-1])

Buggy python submission (verdict: Runtime Error):
number = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = int(input())
print(number[N])

Fixed submission:
number = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = int(input())
print(number[N-1])
Buggy python submission (verdict: Runtime Error):
N,b,r = input().split()
if(b==0 and r == 0):
  print(0)
else :
  sets = N/(b+r)
  surplus = N%(b+r)
  Numbe_of_Blue = sets * b + b
  print(Numbe_of_Blue

Fixed submission:
N,b,r = map(int,input().split())
if(b == 0 and r == 0):
  print(0)
elif (b ==0):
  print(0)
else :
  sets = N//(b+r)
  surplus = N%(b+r)
  if(surplus - b > 0):
    residue = b
  elif(surplus - b < 0):
    residue = surplus  
  Number_of_Blue = sets * b + residue
  print(Number_of_Blue)

Buggy python submission (verdict: Runtime Error):
N,b,r = input().split()
if(b==0 and r == 0):
  print(0)
else :
  set = N/(b+r)
  surplus = N%(b+r)
  Numbe_of_Blue = set * b + b
  print(Numbe_of_Blue)


Fixed submission:
N,b,r = map(int,input().split())
if(b == 0 and r == 0):
  print(0)
elif (b ==0):
  print(0)
else :
  sets = N//(b+r)
  surplus = N%(b+r)
  if(surplus - b > 0):
    residue = b
  elif(surplus - b < 0):
    residue = surplus  
  Number_of_Blue = sets * b + residue
  print(Number_of_Blue)
Buggy python submission (verdict: Time Limit Exceeded):
a,v = map(int, input().split())
b,w = map(int, input().split())
T = int(input())
if v == w:
  print("NO")
  exit()

for i in range(0,T+1):
  if a == b:
    print("YES")
    exit()
  else:
    if a < b:
      a = a+v
      b = b+w
    else:
      a = a-v
      b = b-w
    
print("NO")

Fixed submission:
a,v = map(int,input().split())
b,w = map(int,input().split())
T = int(input())
if abs((b-a))<=(v-w)*T:
	print("YES")
else:
	print("NO")
Buggy python submission (verdict: Runtime Error):
import numpy
n = int(input())
A = map(int, input().split())
ans = numpy.prod(A)
if ans > 10 ** 8:
  print(-1)
else:
  print(ans)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
  print(0)
  exit()
ans = 1
for i in range(len(A)):
  ans = ans * A[i]
  if ans > 10 ** 18:
    print(-1)
    exit()
  else:
    pass
  
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int, input().split())
print(int(math.floor(a*b)))

Fixed submission:
A, B = map(str, input().split())

A = int(A)
B = int(''.join(B.split('.')))
print(A*B//100)
Buggy python submission (verdict: Runtime Error):
a,b,c,k = map(int, input().split())

if k <= a:
  print(k)
elif a < k <= a+b:
  print(a):
else:
  print(a - (k - (a+b)))

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

if k <= a:
  print(k)
elif a <= k <= a+b:
  print(a)
else:
  print(a - (k - (a+b)))
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += math.gcd(a,math.gcd(b,c))
      
print(ans)

Fixed submission:
from math import gcd
k = int(input())
ans = 0

for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd(a,gcd(b,c))
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
k = int(input())
def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd(a,b,c)
      
print(ans)

Fixed submission:
from math import gcd
k = int(input())
ans = 0

for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd(a,gcd(b,c))
      
print(ans)
Buggy python submission (verdict: Runtime Error):
L = int(input().split())

print((L**3)/27)

Fixed submission:
L = int(input())

print((L**3)/27)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())

k = n//(a+b) + 1
L = ["b"]*a +["r"]*b
L = L*k
print(L[0:n].count("b"))


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

print((n//(a+b))*a + min(n%(a+b), a))

Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())

k = n//(a+b) + 
L = ["b"]*a +["r"]*b
L = L*k
print(L[0:n+1].count("b"))

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

print((n//(a+b))*a + min(n%(a+b), a))