Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = input()
B = list(map(int, input().split()))
A = []
for i in range(N):
  if i == 0:
    A.append(B[0])
  elif i == N-1:
    A.append(B[N-2])
  else:
    A.append(min(B[i], B[i-1]))
print(sum(A))

Fixed submission:
N = int(input())
B = list(map(int, input().split()))
A = []
for i in range(N):
  if i == 0:
    A.append(B[0])
  elif i == N-1:
    A.append(B[N-2])
  else:
    A.append(min(B[i], B[i-1]))
print(sum(A))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
import numpy as np
A = np.array(A)
1_A = 1/A
print(1/np.sum(1_A))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
import numpy as np
A = np.array(A)
A_inv = 1/A
print(1/np.sum(A_inv))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S =[[] for _ in range(N)]
for i in range(N):
  s = list(str(input()))
  s.sort()
  s = ''.join(s)
  S[i].append(s)
from collections import Counter
l = Counter(S)
count = []
for i in l.values:
  count.append(i*(i-1)/2)
print(sum(count))
  



Fixed submission:
N = int(input())
S =[]
for i in range(N):
  s = list(str(input()))
  s.sort()
  s = ''.join(s)
  S.append(s)
from collections import Counter
l = Counter(S)
count = []
for i in l.values():
  count.append(i*(i-1)/2)
print(int(sum(count)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
key = 0
for i in range(N-1, 1, -1):
    if H[i]>H[i+1]:
      H[i]-=1
    if H[i]>H[i+1]:
      key += 1
      break
if key == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
 
for i in range(1, N):
    if H[i] < H[i - 1]:
        H[i] += 1
for i in range(1, N):
    if H[i] < H[i - 1]:
        print('No')
        exit(0)
print('Yes')
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(N):
  if p[i] != i+1:
    count ++
if count >=3:
  print("NO")
else:
  print("YES")
    

Fixed submission:
N = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(N):
  if p[i] != i+1:
    count += 1
if count >=3:
  print("NO")
else:
  print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
amari = np.array([[i] for i in range(10)])
p = 10**9 + 7
s =  str(input())
n = len(s)
ans = np.zeros(13, dtype = np.int64)
ans[0] = 1
for i in reversed(s):
  dp = np.zeros(13, dtype = np.int64)
  if i == '?':
    for j in range(13):
      dp[(j + amari)%13] += ans[j]
  else:
    for j in range(13):
      dp[(j + amari[int(i)])%13] += ans[j]
  dp %= p
  ans = dp
  amari = amari*10 %13
print(ans[5])

Fixed submission:
amari = [i for i in range(10)]
p = 10**9 + 7
s =  str(input())
n = len(s)
ans = [0]*13
ans[0] = 1
for i in reversed(s):
  dp = [0]*13
  if i == '?':
    for j in range(13):
      for k in amari:
        dp[(j + k)%13] += ans[j]
  else:
    for j in range(13):
      dp[(j + amari[int(i)])%13] += ans[j]
      
  for i in range(len(dp)):
    dp[i] %= p
  ans = dp
  for i in range(len(amari)):
    amari[i] = amari[i]*10%13
print(ans[5])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
amari = np.array([[i] for i in range(10)])
p = 10**9 + 7
s =  str(input())
n = len(s)
dp = np.zeros((n+1, 13))
dp[0, 0] = 1
for i in range(n):
  if s[n-1-i] == '?':
    for j in range(13):
      dp[i+1][(j + amari)%13] += dp[i][j]
  else:
    for j in range(13):
      dp[i+1][(j + amari[int(s[n-1-i])])%13] += dp[i][j]
  dp[i + 1, :] %= p
  amari = amari*10 %13
print(int(dp[n, 5]))

Fixed submission:
amari = [i for i in range(10)]
p = 10**9 + 7
s =  str(input())
n = len(s)
ans = [0]*13
ans[0] = 1
for i in reversed(s):
  dp = [0]*13
  if i == '?':
    for j in range(13):
      for k in amari:
        dp[(j + k)%13] += ans[j]
  else:
    for j in range(13):
      dp[(j + amari[int(i)])%13] += ans[j]
      
  for i in range(len(dp)):
    dp[i] %= p
  ans = dp
  for i in range(len(amari)):
    amari[i] = amari[i]*10%13
print(ans[5])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import heapq
N = int(input())
A = []
for _ in range(N):
  A.append(-1*int(input()))
A = np.array(A)
answer = []
for i in range(N):
  A_temp = np.delete(A, i).tolist()
  heapq.heapify(A_temp)
  answer.append(heapq.heappop(A_temp))
for i in range(N):
  print(-1*answer[i])

Fixed submission:
import numpy as np
#import heapq
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
A = np.array(A)
A_max_1 = np.max(A)
A_max_index = np.argmax(A)
A = np.delete(A, A_max_index)
A_max_2 = np.max(A)
answer = []
for i in range(N):
  if not i == A_max_index:
    answer.append(A_max_1)
  else:
    answer.append(A_max_2)
for i in range(N):
  print(answer[i])

Buggy python submission (verdict: Runtime Error):
import numpy as np
import heapq
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
A = np.array(A)
answer = []
for i in range(N):
  A_temp = np.delete(A, i)
  answer.append(heapq.pop(A_temp))
for i in range(N):
  print(answer[i])


Fixed submission:
import numpy as np
#import heapq
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
A = np.array(A)
A_max_1 = np.max(A)
A_max_index = np.argmax(A)
A = np.delete(A, A_max_index)
A_max_2 = np.max(A)
answer = []
for i in range(N):
  if not i == A_max_index:
    answer.append(A_max_1)
  else:
    answer.append(A_max_2)
for i in range(N):
  print(answer[i])
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

def main():
  N = int(input())
  ans = 1
  lis_min = [int(input())]
  for i in range(N-1):
    a = int(input())
    index = bisect.bisect_left(lis_min, a)
    if index != 0:
      lis_min[index-1] = a
    else:
      ans += 1
      lis_min.insert(index, a)
  print(ans)
if __name__ == "__main__":
  main()
      

Fixed submission:
def bisect_right_reverse(a, x):
    '''
    reverseにソートされたlist aに対してxを挿入できるidxを返す。
    xが存在する場合には一番右側のidx+1となる。
    '''
    if a[0] < x:
        return 0
    if x <= a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok

def main():
  N = int(input())
  ans = 1
  lis_min = [int(input())]
  for i in range(N-1):
    a = int(input())
    index = bisect_right_reverse(lis_min, a)
    if index != len(lis_min):
      lis_min[index] = a
    else:
      ans += 1
      lis_min.append(a)
  print(ans)
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
import heapq
A.reverse()

count = 0
for i in range(N):
  if A:
    count += 1
    num_temp = A[0]
    while num_temp >= 0:
      try:
      	A.remove(num_temp)
      	num_temp -= 1
      except ValueError:
        num_temp-=1
  else:
    break

print(count)
  
  

Fixed submission:
def bisect_right_reverse(a, x):
    '''
    reverseにソートされたlist aに対してxを挿入できるidxを返す。
    xが存在する場合には一番右側のidx+1となる。
    '''
    if a[0] < x:
        return 0
    if x <= a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok

def main():
  N = int(input())
  ans = 1
  lis_min = [int(input())]
  for i in range(N-1):
    a = int(input())
    index = bisect_right_reverse(lis_min, a)
    if index != len(lis_min):
      lis_min[index] = a
    else:
      ans += 1
      lis_min.append(a)
  print(ans)
if __name__ == "__main__":
  main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
import numpy as np
left = []
a = []
for i in range(N):
  if (i == 0 or i == 1):
      a.append(0.5)
  else:
    a.append(0)
a = np.array(a)
for i in range(N):
  left.append(np.roll(a, i))
left = np.array(left)
from numpy.linalg import solve
answer = solve(left, A)
answer = list(map(int, answer))
print(*answer)

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

X = []
X.append(sum(A)-2*sum(A[2*i+1] for i in range(N//2)))
for i in range(N-1):
  X.append(2*A[i]-X[-1])
print(*X)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

left = [[] for _ in range(N)]
for i in range(N):
  for j in range(N):
    if (j-i == 0 or j-i == 1) and not i == N-1:
      left[i].append(0.5)
    else:
      left[i].append(0)
left[N-1][0] = 0.5
left[N-1][N-1] = 0.5
from numpy.linalg import solve
answer = solve(left, A)
answer = list(map(int, answer))
print(*answer)

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

X = []
X.append(sum(A)-2*sum(A[2*i+1] for i in range(N//2)))
for i in range(N-1):
  X.append(2*A[i]-X[-1])
print(*X)
Buggy python submission (verdict: Runtime Error):
from math import factorial
 
def comb(n, k):
  return int(factorial(n))/int(factorial(n-k))/int(factorial(k))
 
N, K = map(int, input().split())
 
for i in range(1, K+1):
  if N-K-i+1 < 0:
    print(0)
  else:
    a = comb(N-K+1, i)%(10**9+7)
    b = comb(K-1, i-1)%(10**9+7)
    print(int((a*b)%(10**9+7)))

Fixed submission:
from math import factorial
 
def comb(n, k):
  return int(factorial(n))//int(factorial(n-k))//int(factorial(k))
 
N, K = map(int, input().split())
 
for i in range(1, K+1):
  if N-K-i+1 < 0:
    print(0)
  else:
    a = comb(N-K+1, i)%(10**9+7)
    b = comb(K-1, i-1)%(10**9+7)
    print(int((a*b)%(10**9+7)))

Buggy python submission (verdict: Runtime Error):
from math import factorial
 
def comb(n, k):
  return factorial(n)/factorial(n-k)/factorial(k)
 
N, K = map(int, input().split())
 
for i in range(1, K+1):
  if N-K-i+1 < 0:
    print(0)
  else:
    a = comb(N-K+1, i)%(10**9+7)
    b = comb(K-1, i-1)%(10**9+7)
    print(int((a*b)%(10**9+7)))

Fixed submission:
from math import factorial
 
def comb(n, k):
  return int(factorial(n))//int(factorial(n-k))//int(factorial(k))
 
N, K = map(int, input().split())
 
for i in range(1, K+1):
  if N-K-i+1 < 0:
    print(0)
  else:
    a = comb(N-K+1, i)%(10**9+7)
    b = comb(K-1, i-1)%(10**9+7)
    print(int((a*b)%(10**9+7)))

Buggy python submission (verdict: Runtime Error):
from math import factorial

def comb(n, k):
  return factorial(n)/factorial(n-k)/factorial(k)

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

for i in range(1, K+1):
  a = comb(N-K+1, i)%(10**9+7)
  b = comb(K-1, i-1)%(10**9+7)
  print(int((a*b)%(10**9+7)))

Fixed submission:
from math import factorial
 
def comb(n, k):
  return int(factorial(n))//int(factorial(n-k))//int(factorial(k))
 
N, K = map(int, input().split())
 
for i in range(1, K+1):
  if N-K-i+1 < 0:
    print(0)
  else:
    a = comb(N-K+1, i)%(10**9+7)
    b = comb(K-1, i-1)%(10**9+7)
    print(int((a*b)%(10**9+7)))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  N, M = map(int, input().split())
  edge = [[] for _ in range(N)]
  for i in range(M):
    u, v = map(int, input().split())
    edge[u-1].append(v-1)
  d = [-1]*N
  S, T = map(int, input().split())
  d[S-1] = 0
  que = [S-1]
  while len(que)>0:
    now = que.pop(0)
    for i in edge[now]:
      for j in edge[i]:
        for k in edge[j]:
          if d[k] == -1:
            que.append(k)
            d[k] = d[now]+1 
  print(d[T-1])
  
if __name__ == "__main__":
  main()

Fixed submission:
def main():
  N, M = map(int, input().split())
  edge = [[[] for _ in range(3)] for _ in range(N)]
  for i in range(M):
    u, v = map(int, input().split())
    edge[u-1][0].append([v-1,1])
    edge[u-1][1].append([v-1,2])
    edge[u-1][2].append([v-1,0])
  d = [[-1]*3 for _ in range(N)]
  S, T = map(int, input().split())
  d[S-1][0] = 0
  que = [[S-1, 0]]
  while len(que)>0:
    now = que.pop(0)
    for nex in edge[now[0]][now[1]]:
      if d[nex[0]][nex[1]] != -1:continue
      d[nex[0]][nex[1]] = d[now[0]][now[1]]
      if now[1] == 2:
        d[nex[0]][nex[1]] += 1
      que.append(nex)
  print(d[T-1][0])
  
if __name__ == "__main__":
  main()
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B, C, D = map(int, input().split())

div_A_C = (A-1)//C
div_A_D = (A-1)//D

div_B_C = B//C
div_B_D = B//D

CD = lcm(C, D)

div_A_CD = (A-1)//CD
div_B_CD = B // CD
C_or_D = (div_B_C+div_B_D-div_B_CD)-(div_A_C+div_A_D-div_A_CD) 
print(B-A+1-C_or_D)

Fixed submission:
from fractions import gcd

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

A, B, C, D = map(int, input().split())

div_A_C = (A-1)//C
div_A_D = (A-1)//D

div_B_C = B//C
div_B_D = B//D

CD = lcm(C, D)

div_A_CD = (A-1)//CD
div_B_CD = B // CD
C_or_D = (div_B_C+div_B_D-div_B_CD)-(div_A_C+div_A_D-div_A_CD) 
print(B-A+1-C_or_D)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = []
for i in range(M):
  a.append(int(input()))
dp = []
dp.append(1)
if a:
  cantuse = a.pop(0)
  if cantuse == 1:
    dp.append(0)
    cantuse = a.pop(0)
  else:
    dp.append(1)
else:
  cantuse = -1
  dp.append(1)

for i in range(N-1):
  if (i+2) == cantuse:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(dp[-1]+dp[-2])
print(dp[-1]%1000000007)

Fixed submission:
N, M = map(int, input().split())
a = []
for i in range(M):
  a.append(int(input()))
dp = []
dp.append(1)
if a:
  cantuse = a.pop(0)
  if cantuse == 1:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(1)
else:
  cantuse = -1
  dp.append(1)

for i in range(N-1):
  if (i+2) == cantuse:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(dp[-1]+dp[-2])
print(dp[-1]%1000000007)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = []
for i in range(M):
  a.append(int(input()))
dp = []
dp.append(1)
if a:
  cantuse = a.pop(0)
  if cantuse == 1:
    dp.append(0)
  cantuse = a.pop(0)
else:
  cantuse = -1
  dp.append(1)

for i in range(N-1):
  if (i+2) == cantuse:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(dp[-1]+dp[-2])
print(dp[-1]%1000000007)

Fixed submission:
N, M = map(int, input().split())
a = []
for i in range(M):
  a.append(int(input()))
dp = []
dp.append(1)
if a:
  cantuse = a.pop(0)
  if cantuse == 1:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(1)
else:
  cantuse = -1
  dp.append(1)

for i in range(N-1):
  if (i+2) == cantuse:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(dp[-1]+dp[-2])
print(dp[-1]%1000000007)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = []
for i in range(M):
  a.append(int(input()))
dp = []
if a:
  cantuse = a.pop(0)
dp.append(1)
if cantuse == 1:
  dp.append(0)
  cantuse = a.pop(0)
else:
  dp.append(1)

for i in range(N-1):
  if (i+2) == cantuse:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(dp[-1]+dp[-2])
print(dp[-1]%1000000007)

Fixed submission:
N, M = map(int, input().split())
a = []
for i in range(M):
  a.append(int(input()))
dp = []
dp.append(1)
if a:
  cantuse = a.pop(0)
  if cantuse == 1:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(1)
else:
  cantuse = -1
  dp.append(1)

for i in range(N-1):
  if (i+2) == cantuse:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(dp[-1]+dp[-2])
print(dp[-1]%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(list(str(input())))
import numpy as np
S = np.array(S)

left = np.zeros((H, W))
right = np.zeros((H, W))
up = np.zeros((H, W))
down = np.zeros((H, W))

for i in range(H):
  point = 0
  for j in range(W):
    if S[i, j] == ".":
      point += 1
      left[i, j] = point
    elif S[i, j] == "#":
      point = 0

for i in range(H):
  point = 0
  for j in range(W-1, -1, -1):
    if S[i, j] == ".":
      point += 1
      right[i,j] = point
    elif S[i, j] == "#":
      point = 0
    
for i in range(W):
  point = 0
  for j in range(H):
    if S[j, i] == ".":
      point += 1
      up[j, i] = point
    elif S[j, i] == "#":
      point = 0
      
for i in range(W):
  point = 0
  for j in range(H-1, -1, -1):
    if S[j, i] == ".":
      point += 1
      down[j, i] = point
    elif S[j, i] == "#":
      point = 0
score = right + left + up + down
print(int(np.max(score)-3))

Fixed submission:
import numpy as np 
H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'
 

up = np.zeros((H, W), dtype=int)
down = np.zeros((H, W), dtype=int)
left = np.zeros((H, W), dtype=int)
right = np.zeros((H, W), dtype=int)
 
for i in range(H):
    up[i] = (up[i-1] + 1) * S[i]
    down[-i-1] = (down[-i] + 1) * S[-i-1]
    
for i in range(W):
    left[:, i] = (left[:, i-1] + 1) * S[:, i]
    right[:, -i-1] = (right[:, -i] + 1) * S[:, -i-1]

print(np.max(up+down+left+right) - 3)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
import numpy as np
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for i in range(M):
  b, c = map(int, input().split())
  A.extend([c]*b)
A.sort()
print(int(sum(A[len(A)-N:])))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
a = []

for i in range(M):
  b = list(map(int, input().split()))
  a.append(b)
  
from operator import itemgetter
A.sort()
a.sort(key = itemgetter(1))
count = 0
for i in range(N):
  if A[i] < a[-1-count][1]:
    A[i] =  a[-1-count][1]
    a[-1-count][0] -= 1
    if a[-1-count][0] == 0:
      count += 1
    if count == M:
      break
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
import numpy as np
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
A.sort()
A = np.array(A)
for i in range(M):
  b, c = map(int, input().split())
  BC.append([b, c])
  
for i in range(M):
  place = np.where(A < BC[i][1])
  if len(place[0]) >= BC[i][0]:
    A[:BC[i][0]] = BC[i][1]
  else:
    A[:len(place[0])] = BC[i][1]
  A.sort()
print(int(np.sum(A)))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
a = []

for i in range(M):
  b = list(map(int, input().split()))
  a.append(b)
  
from operator import itemgetter
A.sort()
a.sort(key = itemgetter(1))
count = 0
for i in range(N):
  if A[i] < a[-1-count][1]:
    A[i] =  a[-1-count][1]
    a[-1-count][0] -= 1
    if a[-1-count][0] == 0:
      count += 1
    if count == M:
      break
print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))
z = sorted(list(map(int, input().split())))
import heapq
shou = 3 * 10**10 + 1
ans = []
for i in range(X-1, -1, -1):
  for j in range(Y-1, -1, -1):
    for k in range(Z-1, -1, -1):
      if (X-i)*(Y-j)*(Z-k) <= K:
        sub = x[i]+y[j]+z[k]
        ans.append(sub)
ans = list(map(lambda x: x*(-1), ans)) 
heapq.heapify(ans)
for i in range(K):
  print(heapq.heappop(ans)*(-1))

Fixed submission:
X, Y, Z, K = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))
z = sorted(list(map(int, input().split())))


import heapq
ans = []
for i in range(X-1, -1, -1):
  for j in range(Y-1, -1, -1):
    for k in range(Z-1, -1, -1):
      if (X-i)*(Y-j)*(Z-k) <= K:
        sub = x[i]+y[j]+z[k]
        ans.append(sub)
      else:
        break
ans = list(map(lambda x: x*(-1), ans)) 
heapq.heapify(ans)
for i in range(K):
  print(heapq.heappop(ans)*(-1))

Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))
z = sorted(list(map(int, input().split())))
import heapq
shou = 3 * 10**10 + 1
ans = []
heapq.heapify(ans)
for i in range(X-1, -1, -1):
  if len(ans) == K:
    sub = x[i]+y[Y-1]+z[Z-1]
    if sub < shou:
      break
  for j in range(Y-1, -1, -1):
    if len(ans) == K:
      sub = x[i]+y[j]+z[Z-1]
      if sub < shou:
        break
    for k in range(Z-1, -1, -1):
      sub = x[i]+y[j]+z[k]
      if len(ans) < K:
        heapq.heappush(ans, sub)
        shou = min(shou, sub)
      else:
        if sub < shou:
          break
        else:
          heapq.heappush(ans, sub)
          show = heapq.heappop(ans)
ans = list(map(lambda x: x*(-1), ans)) 
heapq.heapify(ans)
for i in range(len(ans)):
  print(heapq.heappop(ans)*(-1))

Fixed submission:
X, Y, Z, K = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))
z = sorted(list(map(int, input().split())))


import heapq
ans = []
for i in range(X-1, -1, -1):
  for j in range(Y-1, -1, -1):
    for k in range(Z-1, -1, -1):
      if (X-i)*(Y-j)*(Z-k) <= K:
        sub = x[i]+y[j]+z[k]
        ans.append(sub)
      else:
        break
ans = list(map(lambda x: x*(-1), ans)) 
heapq.heapify(ans)
for i in range(K):
  print(heapq.heappop(ans)*(-1))
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
v = list(map(int, input().split()))
gu = [0] * (10**5)
ki = [0] * (10**5)

for i in range(n):
  if i % 2:
    ki[v[i]] += 1
  else:
    gu[v[i]] += 1
import numpy as np
ki = np.array(ki)
gu = np.array(gu)

a = np.argmax(ki)
b = np.argmax(gu)

if a != b:
  print(n-ki[a]-gu[b])
else:
  if a > b:
    gu = sorted(gu)
    print(n-ki[a] - gu[-2])
  else:
    ki = sorted(ki)
    print(n-ki[-2]-gu[b])
  

Fixed submission:
import numpy as np
n = int(input())
v = list(map(int, input().split()))
gu = [0] * (10**5 + 5)
ki = [0] * (10**5 + 5)

for i in range(n):
  if i % 2:
    ki[v[i]] += 1
  else:
    gu[v[i]] += 1
ki = np.array(ki)
gu = np.array(gu)

a = np.argmax(ki)
b = np.argmax(gu)

if a != b:
  print(n-ki[a]-gu[b])
else:
  gu = sorted(gu)
  ki = sorted(ki)
  print(min(n-ki[-1] - gu[-2], n-ki[-2]-gu[-1]))
Buggy python submission (verdict: Runtime Error):
def main():
  A, B, C, X, Y = map(int, input().split())
  if A + B <= 2*C:
    print(A*X + B*Y)
  elif 2*C < A and 2*C < B:
    print(C*max(X,  Y)*2)
      print(A*X + B*Y)
  elif 2*C < A or 2*C < B:
    print(C*max(X,  Y)*2)
  else:
    if X < Y:temp = B
    else:  temp = A
    print(C*min(X, Y)*2 + temp*(abs(X-Y)))
if __name__ == "__main__":
  main()

Fixed submission:
def main():
  A, B, C, X, Y = map(int, input().split())
  print(min([C*max(X, Y)*2, A*X + B*Y, 2*C*Y+A*(max(0, X-Y)), 2*C*X + B*(max(0, Y-X))]))
if __name__ == "__main__":
  main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def main():
  N = int(input())
  
  print(0, flush = True)
  s = str(input())
  if s == "Vacant":sys.exit()
  l = [0, s]
  
  print((N-1), flush = True)
  r =  [N-1, str(input())]
  if r[1] == "Vacant":sys.exit()
  
  while True:
    print((l[0] + r[0])//2, flush = True)
    c = [(l[0] + r[0])//2, str(input())]
    if c[1] == "Vacant":sys.exit()
    if ((c[0]-l[0])%2 == 1 and nex[1] == bef[1]) or (c[0]-l[0])%2 == 0 and nex[1] != bef[1]:
      r = c
    else:
      l = c
          
if __name__ == "__main__":
  main()

Fixed submission:
import sys
def main():
  N = int(input())
  
  print(0, flush = True)
  s = str(input())
  if s == "Vacant":sys.exit()
  l = [0, s]
  
  print((N-1), flush = True)
  r =  [N-1, str(input())]
  if r[1] == "Vacant":sys.exit()
  
  while True:
    print((l[0] + r[0])//2, flush = True)
    c = [(l[0] + r[0])//2, str(input())]
    if c[1] == "Vacant":sys.exit()
    if ((c[0]-l[0])%2 == 1 and c[1] == l[1]) or (c[0]-l[0])%2 == 0 and c[1] != l[1]:
      r = c
    else:
      l = c
          
if __name__ == "__main__":
  main()