Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x = int(input())
a = int(input())
if x < a:
  print("0")
else:
  print("10")

Fixed submission:
i = list(map(int, input().split()))
if i[0] < i[1]:
  print("0")
else:
  print("10")

Buggy python submission (verdict: Runtime Error):
x = input()
a = input()
y = int(x)
b = int(a)
 
 
 
 
if y < b:
  print(0)
else:
  print(10)

Fixed submission:
i = list(map(int, input().split()))
if i[0] < i[1]:
  print("0")
else:
  print("10")

Buggy python submission (verdict: Runtime Error):
x = input()
a = intput()
 
 
 
 
if x < a:
  print("0")
else:
  print("10")

Fixed submission:
i = list(map(int, input().split()))
if i[0] < i[1]:
  print("0")
else:
  print("10")

Buggy python submission (verdict: Runtime Error):
x = int
a = int



 
if x < a:
  print(0)
else:
  print(10)

Fixed submission:
i = list(map(int, input().split()))
if i[0] < i[1]:
  print("0")
else:
  print("10")

Buggy python submission (verdict: Runtime Error):
x = int
a = int


 
if x < a:
  print(0)
else:
  print(10)

Fixed submission:
i = list(map(int, input().split()))
if i[0] < i[1]:
  print("0")
else:
  print("10")

Buggy python submission (verdict: Runtime Error):
x >= 0
x <= 9
a >= 0
a <= 9

if x < a 
  print(0)
else
  print(10)

Fixed submission:
i = list(map(int, input().split()))
if i[0] < i[1]:
  print("0")
else:
  print("10")
Buggy python submission (verdict: Runtime Error):
W,H,x,y = map(int, input().split())
answer = W*H/2
print(answer)
if W/2 == x && H/2 == y:
  print(1)
else:
  print(0)

Fixed submission:
W,H,x,y = map(int, input().split())
answer = W*H/2
print(answer)
if W/2 == x and H/2 == y:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
N,A,B,C,D = map(int,input().split())
S = str(input())
E = max(C,D)
AE = S[A:E+1]
BD = S[B-2:D+1]
check = 0
if "##" in AE:
  check = 1
  break
else:
  check = 0
if check == 0 and C > D:
  if "..." in BD:
    check = 0
  else:
    check = 1
    break
if check == 0
  print("OK")
else:
  print("MISS")


Fixed submission:
N,A,B,C,D = map(int,input().split())
S = str(input())
E = max(C,D)
AE = S[A:E]
BD = S[B-2:D+1]
if "##" in AE:
  print("No")
elif C > D and "..." not in BD:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
S = S.replace("BC","D")
ans = 0
while S.count("AD") > 0:
  ans += S.count("AD")
  S = S.replace("AD","DA")

print(ans)

Fixed submission:
S = str(input())
S = S.replace("BC","D")
A_count = 0
ans = 0

for i in range(len(S)):
  if S[i] == 'A':
    A_count += 1
  elif S[i] == 'D':
    ans += A_count
  else:
    A_count = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
SP = []
for i in range(N):
  S,P = input().split()
  P = int(P)
  SP.append(S,-P,i+1)
SP.sort()
for a,b,c in SP:
  print(c)

Fixed submission:
N = int(input())
SP = []
for i in range(N):
  S,P = input().split()
  P = int(P)
  SP.append((S,-P,i+1))
SP.sort()
for a,b,c in SP:
  print(c)

Buggy python submission (verdict: Runtime Error):
N = int(input())
SP = []
for i in range(N):
  S,P = input().split()
  P = int(P)
  SP.append(S,P,i+1)
SP.sort()
for a,b,c in SP:
  print(c)

Fixed submission:
N = int(input())
SP = []
for i in range(N):
  S,P = input().split()
  P = int(P)
  SP.append((S,-P,i+1))
SP.sort()
for a,b,c in SP:
  print(c)

Buggy python submission (verdict: Runtime Error):
N = int(input())
SP = []
for i in range(N):
  S,P = map(int,input().split())
  P = int(P)
  SP.append(S,P,i+1)
SP.sort()
for a,b,c in SP:
  print(c)

Fixed submission:
N = int(input())
SP = []
for i in range(N):
  S,P = input().split()
  P = int(P)
  SP.append((S,-P,i+1))
SP.sort()
for a,b,c in SP:
  print(c)

Buggy python submission (verdict: Runtime Error):
N = int(input())
SP = [list(map(int,input().split()))for _ in range(N)]
SP.sort()
for i in SP.values():
  print(i)
  

Fixed submission:
N = int(input())
SP = []
for i in range(N):
  S,P = input().split()
  P = int(P)
  SP.append((S,-P,i+1))
SP.sort()
for a,b,c in SP:
  print(c)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = str(input())
if S[K-1] == 'A':
  S[K-1] = 'a'
elif S[K-1] == 'B':
  S[K-1] = 'b'
else:
  S[K-1] = 'c'
print(S)

Fixed submission:
N,K = map(int,input().split())
S = list(str(input()))
if S[K-1] == 'A':
  S[K-1] = 'a'
elif S[K-1] == 'B':
  S[K-1] = 'b'
else:
  S[K-1] = 'c'
print(''.join(S))
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
point = 0
for i in range(1,N+1):
  for j in range(N):
    if  i**j >= K:
      point += (1/N)*(1/2)**j
      i += 1
    else:
      j += 1
print(point)

Fixed submission:
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
  j = 0
  point = i
  while point < K:
    point *= 2
    j += 1
  ans += (1/N)*(0.5**j)
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
K = int(input())
win = [0]
win = np.array(win,dtype=np.float64)
for i in range(1,N+1):
  for j in range(N):
    if  i**j >= K:
      win[i] = (1/N)*(1/2)**j
      i += 1
    else:
      j += 1
ans = sum(win)
print(ans)

Fixed submission:
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
  j = 0
  point = i
  while point < K:
    point *= 2
    j += 1
  ans += (1/N)*(0.5**j)
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
K = int(input())
win = [0]
win = np.array(win)
point = 0
for i in range(1,N+1):
  for j in range(1,K):
    if  i**j >= K:
      win[i] = (1/N)*{(1/2)**j}
      i += 1
    else:
      j += 1
ans = sum(win)
print(ans)

Fixed submission:
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
  j = 0
  point = i
  while point < K:
    point *= 2
    j += 1
  ans += (1/N)*(0.5**j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
win = []
win[0] = 0
point = 0
for i in range(1,N+1):
  for j in range(1,K):
    if  i**j >= K:
      win[i] = (1/N)*{(1/2)**j}
      i += 1
    else:
      j += 1
ans = sum(win)
print(ans)

Fixed submission:
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
  j = 0
  point = i
  while point < K:
    point *= 2
    j += 1
  ans += (1/N)*(0.5**j)
print(ans)
Buggy python submission (verdict: Runtime Error):
R,G,B = map(int,input().split())
N = int(input())
count = 0
for r in range(R):
  for g in range(G):
    for b in range(B):
      if r*R+g*G+b*B == N:
        count += 1
      else:
        r += 1
print(count)

Fixed submission:
R,G,B,N = map(int,input().split())
count = 0
 
for i in range(0,N+1,R):
    for j in range(0,N+1,G):
        sum = i + j
        if N - sum < 0:
            break
        elif (N - sum) % B == 0:
            count += 1
 
print(count)
Buggy python submission (verdict: Runtime Error):
import numpy
import sys
input = sys.stdin.readline
H,W = map(int,input().split())
INF = H * W
S = numpy.array([[INF if i == '.' else 0 for i in input().strip()] for _ in range(H)])

for h in range(1, H):
    S[h, :] = numpy.minimum(S[h,:],S[h-1,:] + 1)
for h in range(H - 2, -1, -1):
    S[h, :] = numpy.minimum(S[h,:],S[h+1,:] + 1)
for w in range(1, W):
    S[:, w] = numpy.minimum(S[:,w],S[:,w-1] + 1)
for w in range(w - 2, -1, -1):
    S[:, w] = numpy.minimum(S[:,w],S[:,w+1] + 1)

print(numpy.max(S))

Fixed submission:
import numpy
import sys
input = sys.stdin.readline
H,W = map(int,input().split())
INF = H * W
S = numpy.array([[INF if i == '.' else 0 for i in input().strip()] for _ in range(H)])

for h in range(1, H):
    S[h, :] = numpy.minimum(S[h,:],S[h-1,:] + 1)
for h in range(H - 2, -1, -1):
    S[h, :] = numpy.minimum(S[h,:],S[h+1,:] + 1)
for w in range(1, W):
    S[:, w] = numpy.minimum(S[:,w],S[:,w-1] + 1)
for w in range(W - 2, -1, -1):
    S[:, w] = numpy.minimum(S[:,w],S[:,w+1] + 1)

print(numpy.max(S))

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

H,W = map(int,input().split())
INF = H * W
S = numpy.array([[INF if i == '.' else 0 for i in input().strip()] for _ in range(H)])

for h in range(1, H):
    S[h, :] = numpy.minimum(S[h,:],S[h-1,:] + 1)
for h in range(H - 2, -1, -1):
    S[h, :] = numpy.minimum(S[h,:],S[h+1,:] + 1)
for w in range(1, W):
    S[:, w] = numpy.minimum(S[:,w],S[:,w-1] + 1)
for w in range(w - 2, -1, -1):
    S[:, w] = numpy.minimum(S[:,w],S[:,w+1] + 1)

print(numpy.max(S))

Fixed submission:
import numpy
import sys
input = sys.stdin.readline
H,W = map(int,input().split())
INF = H * W
S = numpy.array([[INF if i == '.' else 0 for i in input().strip()] for _ in range(H)])

for h in range(1, H):
    S[h, :] = numpy.minimum(S[h,:],S[h-1,:] + 1)
for h in range(H - 2, -1, -1):
    S[h, :] = numpy.minimum(S[h,:],S[h+1,:] + 1)
for w in range(1, W):
    S[:, w] = numpy.minimum(S[:,w],S[:,w-1] + 1)
for w in range(W - 2, -1, -1):
    S[:, w] = numpy.minimum(S[:,w],S[:,w+1] + 1)

print(numpy.max(S))
Buggy python submission (verdict: Runtime Error):
menu = [int(input()) for _ in range(5)]
last = 10**18
last_menu = 0
for i in range(5):
  if menu[i]%10 != 0:
    last = min(last, menu[i]%10)
  if last == menu[i]%10:
    num = i
last_menu = menu.pop(num)

time = 0
for j in range(len(menu)):
  if menu[j]%10 == 0:
    time += menu[j]
  else:
    time += menu[j] + (10 - menu[j]%10)
time += last_menu

print(time)

Fixed submission:
menu = [int(input()) for _ in range(5)]
last = 10**18
last_menu = 0
num = -1
for i in range(len(menu)):
  if menu[i]%10 != 0:
    last = min(last, menu[i]%10)
  if last == menu[i]%10:
    num = i
if num >= 0:
  last_menu = menu.pop(num)

time = 0
for j in range(len(menu)):
  if menu[j]%10 == 0:
    time += menu[j]
  else:
    time += menu[j] + (10 - menu[j]%10)
time += last_menu

print(time)

Buggy python submission (verdict: Runtime Error):
menu = [int(input()) for _ in range(5)]
last = 10**18
last_menu = 0
for i in range(5):
  if menu[i]%10 != 0:
    last = min(last, menu[i]%10)
  if last == menu[i]%10:
    num = i
last_menu = menu.pop(num)

time = 0
for j in range(4):
  if menu[j]%10 == 0:
    time += menu[j]
  else:
    time += menu[j] + (10 - menu[j]%10)
time += last_menu

print(time)

Fixed submission:
menu = [int(input()) for _ in range(5)]
last = 10**18
last_menu = 0
num = -1
for i in range(len(menu)):
  if menu[i]%10 != 0:
    last = min(last, menu[i]%10)
  if last == menu[i]%10:
    num = i
if num >= 0:
  last_menu = menu.pop(num)

time = 0
for j in range(len(menu)):
  if menu[j]%10 == 0:
    time += menu[j]
  else:
    time += menu[j] + (10 - menu[j]%10)
time += last_menu

print(time)
Buggy python submission (verdict: Time Limit Exceeded):
P = [int(input()) for _ in range(6)]
N,A,B,C,D,E = P[0],P[1],P[2],P[3],P[4],P[5]
N1,N2,N3,N4,N5,goal = P[0],0,0,0,0,0
ans = 0

while goal < N:
  if N5 > 0:
    goal += min(E,N5)
    N5 -= min(E,N5)
    
  if N4 > 0:
    N5 += min(D,N4)
    N4 -= min(D,N4)
    
  if N3 > 0:
    N4 += min(C,N3)
    N3 -= min(C,N3)
    
  if N2 > 0:
    N3 += min(B,N2)
    N2 -= min(B,N2)
    
  if N1 > 0:
    N2 += min(A,N1)
    N1 -= min(A,N1)

  ans += 1

print(ans)

Fixed submission:
from math import ceil
P = [int(input()) for _ in range(6)]
N,A,B,C,D,E = P[0],P[1],P[2],P[3],P[4],P[5]
N2,N3,N4,N5,N6 = ceil(N/A),ceil(N/B),ceil(N/C),ceil(N/D),ceil(N/E)

ans = max(N2,N3,N4,N5,N6) + 4
print(ans)
Buggy python submission (verdict: Runtime Error):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

l = [0]*(X*Y*Z)
c = 0

from decimal import *

for x in range(X):
  for y in range(Y):
    for z in range(Z):
      l[c] = Decimal(A[x]+B[y]+C[z])
      c += 1

ans = sorted(l,reverse = True)

for k in range(K):
  print(ans[k])

Fixed submission:
from heapq import *
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A = sorted(A,reverse = True)
B = sorted(B,reverse = True)
C = sorted(C,reverse = True)

cake = []
heapify(cake)
for x in range(X):
  for y in range(min(Y,K//(x+1)+1)):
    for k in range(min(Z,K//((x+1)*(y+1))+1)):
      heappush(cake,-(A[x]+B[y]+C[k]))
for _ in range(K):
  print(abs(heappop(cake)))

Buggy python submission (verdict: Runtime Error):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

l = [0]*(X*Y*Z)
c = 0

for x in range(X):
  for y in range(Y):
    for z in range(Z):
      l[c] = A[x]+B[y]+C[z]
      c += 1

ans = sorted(l,reverse = True)

for k in range(K):
  print(ans[k])

Fixed submission:
from heapq import *
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A = sorted(A,reverse = True)
B = sorted(B,reverse = True)
C = sorted(C,reverse = True)

cake = []
heapify(cake)
for x in range(X):
  for y in range(min(Y,K//(x+1)+1)):
    for k in range(min(Z,K//((x+1)*(y+1))+1)):
      heappush(cake,-(A[x]+B[y]+C[k]))
for _ in range(K):
  print(abs(heappop(cake)))
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = str(input())
lr = [list(map(int,input().split())) for _ in range(Q)]

for l,r in lr:
  l -= 1
  print(S[l:r].count("AC"))

Fixed submission:
from itertools import accumulate
N,Q = map(int,input().split())
S = str(input())
lr = [list(map(int,input().split())) for _ in range(Q)]
sl = [0]*N
for i in range(N):
  if S[i:i+2] == "AC":
    sl[i] = 1
slr = [0]+list(accumulate(sl))
ans = 0
for l,r in lr:
  ans = slr[r-1]-slr[l-1]
  print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
S = str(input())
SC = Counter(S)
v,c = zip(*SC.most_common())
print(len(S) - abs(c[1]-c[0]))

Fixed submission:
S = str(input())
zero = 0
one = 0
for i in S:
  if i == "0":
    zero += 1
  else:
    one += 1
ans = min(zero,one)*2
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N,M = map(int,input().split())
X = list(map(int,input().split()))
x = []
ans = 0
X.sort()
for i in range(M-1):
  x.append(abs(X[i]-X[i+1]))
xx = sorted(x,reverse=True)
for j in range(math.ceil(N/2)):
  xx.pop(0)
ans = sum(xx)
print(ans)

Fixed submission:
N,M = map(int,input().split())
X = list(map(int,input().split()))
x = []
ans = 0
X.sort()
if N >= M:
  print(0)
  exit()
for i in range(M-1):
  x.append(abs(X[i]-X[i+1]))
xx = sorted(x,reverse=True)
for j in range(N-1):
  xx[j] = 0
ans = sum(xx)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
N,M = map(int,input().split())
X = list(map(int,input().split()))
x = []
count = 0
ans = 0
X.sort()
if N >= M:
  print(0)
for i in range(M-1):
  x.append(abs(X[i]-X[i+1]))
xx = sorted(x,reverse=True)
for j in range(math.ceil(N/2)):
  xx.pop(0)
ans = sum(xx)
print(ans)

Fixed submission:
N,M = map(int,input().split())
X = list(map(int,input().split()))
x = []
ans = 0
X.sort()
if N >= M:
  print(0)
  exit()
for i in range(M-1):
  x.append(abs(X[i]-X[i+1]))
xx = sorted(x,reverse=True)
for j in range(N-1):
  xx[j] = 0
ans = sum(xx)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
X = list(map(int,input().split()))
x = []
count = 0
ans = 0
X.sort()
if N >= M:
  print(0)
for i in range(M-1):
  x.append(abs(X[i]-X[i+1]))
xx = sorted(x,reverse=True)
for j in range(N//2):
  xx.pop(j)
ans = xx[-1] - xx[0]
print(ans)

Fixed submission:
N,M = map(int,input().split())
X = list(map(int,input().split()))
x = []
ans = 0
X.sort()
if N >= M:
  print(0)
  exit()
for i in range(M-1):
  x.append(abs(X[i]-X[i+1]))
xx = sorted(x,reverse=True)
for j in range(N-1):
  xx[j] = 0
ans = sum(xx)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*N
dp[0] = 0
for i in range(1,N):
  l = max(0, i-K)
  dp[i] += min(dpj+abs(hj-h[i]) for dpj,hj in zip(dp[l:i],h[l:i]))
print(dp[-1])

Fixed submission:
import numpy as np
N,K = map(int,input().split())
h = list(map(int,input().split()))
h = np.array(h)
dp = [0]*N
dp = np.array(dp)
dp[1]=abs(h[1]-h[0])
for i in range(1,N):
  j = max(0,i-K)
  dp[i] = min(dp[j:i]+abs(h[i]-h[j:i]))
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*N
dp[0] = 0
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
  dp[i] += min(dpj+abs(hj-h[i]) for dpj,hj in zip(dp[i-K:i],h[i-K:i]))
print(dp[-1])

Fixed submission:
import numpy as np
N,K = map(int,input().split())
h = list(map(int,input().split()))
h = np.array(h)
dp = [0]*N
dp = np.array(dp)
dp[1]=abs(h[1]-h[0])
for i in range(1,N):
  j = max(0,i-K)
  dp[i] = min(dp[j:i]+abs(h[i]-h[j:i]))
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*N
dp[0] = 0
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
  dp[i] += min(dpj+abs(hj-h[i]) for dpj,hj in zip(dp[i-K:i],h[i-K:i])
print(dp[-1])

Fixed submission:
import numpy as np
N,K = map(int,input().split())
h = list(map(int,input().split()))
h = np.array(h)
dp = [0]*N
dp = np.array(dp)
dp[1]=abs(h[1]-h[0])
for i in range(1,N):
  j = max(0,i-K)
  dp[i] = min(dp[j:i]+abs(h[i]-h[j:i]))
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*N
dp[0] = 0
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
  dp[i] += min(dpj+abs(hj-h[i]) for dpj,hj in zip(dp[i-k:i],h[i-k:i])
print(dp[-1])

Fixed submission:
import numpy as np
N,K = map(int,input().split())
h = list(map(int,input().split()))
h = np.array(h)
dp = [0]*N
dp = np.array(dp)
dp[1]=abs(h[1]-h[0])
for i in range(1,N):
  j = max(0,i-K)
  dp[i] = min(dp[j:i]+abs(h[i]-h[j:i]))
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
abc = [list(map(int,input().split())) for _ in range(N)]
dp = np.array([[0]*3]*N)
dp[0][0],dp[0][1],dp[0][2] = abc[0][0],abc[0][1],abc[0][2]

for i in range(1,N):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i][k] = max(dp[i][k], dp[i-1][j] + abc[i][k])

ans = max(dp[N-1])
print(ans)


Fixed submission:
N = int(input())
abc = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N)]
dp[0][0],dp[0][1],dp[0][2] = abc[0][0],abc[0][1],abc[0][2]

for i in range(1,N):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i][k] = max(dp[i][k], dp[i-1][j] + abc[i][k])

ans = max(dp[N-1])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
abc = [list(map(int,input().split())) for _ in range(N)]
dp = np.array([[0]*3]*N)
dp[0][0],dp[0][1],dp[0][2] = abc[0][0],abc[0][1],abc[0][2]

for i in range(1,N):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i][k] = max(dp[i][k], dp[i-1][j] + abc[i][k])

ans = 0

for l in range(N):
  ans = max(ans, max(dp[l]))
print(ans)

Fixed submission:
N = int(input())
abc = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N)]
dp[0][0],dp[0][1],dp[0][2] = abc[0][0],abc[0][1],abc[0][2]

for i in range(1,N):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i][k] = max(dp[i][k], dp[i-1][j] + abc[i][k])

ans = max(dp[N-1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)]
 
for i in range(N):
  for j in range(W+1):
    if j - wv[i][0] >= 0:
      dp[i+1][j] = max(dp[i+1][j], dp[i][j-wv[i][0]] + wv[i][1])
    dp[i+1][j] = max(dp[i+1][j], dp[i][j])
 
ans = 0
 
print(dp[N][W])

Fixed submission:
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)]
 
for i in range(N):
  for j in range(W+1):
    if j - wv[i][0] >= 0:
      dp[i+1][j] = max(dp[i+1][j], dp[i][j-wv[i][0]] + wv[i][1])
    dp[i+1][j] = max(dp[i+1][j], dp[i][j])
 
ans = 0

print(dp[N][W])
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
ans = 0
while S.count('BW') > 0:
  ans += S.count('BW')
  S = S.replace('BW','WB')

print(ans)

Fixed submission:
S = str(input())
ans = 0
B = 1
for i in range(len(S)-1,-1,-1):
  if S[i] == "B":
    ans += len(S[i:-B])
    B += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
ans = 0
while S.count('BW') > 0:
  ans += S.count('BW')
  S = S.replace('BW','WB')

print(ans)

Fixed submission:
S = str(input())
ans = 0
B = 1
for i in range(len(S)-1,-1,-1):
  if S[i] == "B":
    ans += len(S[i:-B])
    B += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse = True)
l = [0]*(N-(K-1))
for i in range(N-(K-1)):
  l[i] = h[i]-h[i+K-1]
ans = min(l)
print(ans)

Fixed submission:
N,K = map(int,input().split())
h = [int(input()) for i in range(N)]
h.sort(reverse = True)
l = [0]*(N-(K-1))
for i in range(N-(K-1)):
  l[i] = h[i]-h[i+K-1]
ans = min(l)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
h.sort()
ans = min(h[i]-h[i+K] for i in range(N-K))
print(ans)

Fixed submission:
N,K = map(int,input().split())
h = [int(input()) for i in range(N)]
h.sort(reverse = True)
l = [0]*(N-(K-1))
for i in range(N-(K-1)):
  l[i] = h[i]-h[i+K-1]
ans = min(l)
print(ans)
Buggy python submission (verdict: Runtime Error):
A.sort()
n = N//2
if N%2 != 0:
    ans1,ans2,ans = 0,0,0
    ar1,ar2 = A[:n],A[n+1:]
    ar = []
    for i in range(n):
        ar.append(ar2[i])
        ar.append(ar1[i])
    ar.append(A[n])
    for i in range(N-1):
        ans1 += abs(ar[i]-ar[i+1])
    ar = [A[n]]+ar[:-1]
    for i in range(N-1):
        ans2 += abs(ar[i]-ar[i+1])
    ans = max(ans1,ans2)
else:
    ans = 0
    ar1,ar2 = A[:n],A[n:]
    ar = []
    for i in range(n):
        ar.append(ar2[i])
        ar.append(ar1[i])
    for i in range(N-1):
        ans += abs(ar[i]-ar[i+1])
 
print(ans)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
n = N//2
if N%2 != 0:
    ans1,ans2,ans = 0,0,0
    ar1,ar2 = A[:n],A[n+1:]
    ar = []
    for i in range(n):
        ar.append(ar2[i])
        ar.append(ar1[i])
    ar.append(A[n])
    for i in range(N-1):
        ans1 += abs(ar[i]-ar[i+1])
    ar = [A[n]]+ar[:-1]
    for i in range(N-1):
        ans2 += abs(ar[i]-ar[i+1])
    ans = max(ans1,ans2)
else:
    ans = 0
    ar1,ar2 = A[:n],A[n:]
    ar = []
    for i in range(n):
        ar.append(ar2[i])
        ar.append(ar1[i])
    for i in range(N-1):
        ans += abs(ar[i]-ar[i+1])
 
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
n = N//2
if N%2 != 0:
    ar1,ar2 = [],[]
    ans1,ans2 = 0,0

    for i in range(n):
        ar1.append(A[-1-i])
        ar1.append(A[i])
        
    for i in range(1,len(ar1)):
        ans1 += abs(ar1[i]-ar1[i-1])
    ans1 += max(abs(ar1[0]-A[n]), abs(ar1[-1]-A[n]))
    for i in range(n):
        ar2.append(A[-1-i])
        ar2.append(A[i])
        
    for i in range(1,len(ar1)):
        ans2 += abs(ar2[i]-ar2[i-1])
    ans2 += max(abs(ar2[0]-A[n]), abs(ar2[-1]-A[n]))
    ans = max(ans1,ans2)
else:
    ar = []
    ans = 0
    for i in range(n-1):
        ar.append(A[-1-i])
        ar.append(A[i])
    for i in range(1,len(ar)):
        ans += abs(ar[i]-ar[i-1])
    ans += max(abs(ar[0]-A[n])+abs(ar[-1]-A[n+1]), abs(ar[-1]-A[n])+abs(ar[0]-A[n+1]))
        
    
print(ans)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
n = N//2
if N%2 != 0:
    ans1,ans2,ans = 0,0,0
    ar1,ar2 = A[:n],A[n+1:]
    ar = []
    for i in range(n):
        ar.append(ar2[i])
        ar.append(ar1[i])
    ar.append(A[n])
    for i in range(N-1):
        ans1 += abs(ar[i]-ar[i+1])
    ar = [A[n]]+ar[:-1]
    for i in range(N-1):
        ans2 += abs(ar[i]-ar[i+1])
    ans = max(ans1,ans2)
else:
    ans = 0
    ar1,ar2 = A[:n],A[n:]
    ar = []
    for i in range(n):
        ar.append(ar2[i])
        ar.append(ar1[i])
    for i in range(N-1):
        ans += abs(ar[i]-ar[i+1])
 
print(ans)