Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <string>

using namespace std;

int main(){
  int a; 
  string s;
  cin >> a >> s;

  if (a < 3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }
}

Fixed submission:
N = int(input())
S = input()

if N >= 3200:
  print(S)
else:
  print("red")

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

stdin = sys.stdin
na = lambda: map(int, stdin.readline().split())

def main():
  N, Q = na()

  ab = []
  for _ in range(N-1):
    a, b = na()
    ab.append([a, b])
  ab.sort()

  counter = [0] * (N+1)
  for _ in range(Q):
    p, x = na()
    counter[p] += x
  for i in range(N - 1):
    counter[ab[i][1]] += counter[ab[i][0]]
  print(*counter[1:])

if __name__ == "__main__":
  main()


Fixed submission:
N = int(input())
S = input()

if N >= 3200:
  print(S)
else:
  print("red")
Buggy python submission (verdict: Runtime Error):
A, B = map(int,inpt().split())
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: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
  print(max(A[i+1:]+A[:i]))

Fixed submission:

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

m = [0, 0]
for i in range(N):
  if A[i] > m[0]:
    m[0] = A[i]
    m[1] = i  

m2 = 0
for i in range(N):
  if i == m[1]:
    continue
  m2 = max(A[i], m2)

res = []
for i in range(N):
  if i != m[1]:
    print(m[0])
  else:
    print(m2)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int,input().split())

R = min(R, L+2019*2)
ans = 2018
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i*j%2019)
print(ans)

Fixed submission:
L, R = map(int,input().split())

R = min(R, L+673)
ans = 2018
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i*j%2019)
print(ans)

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

mod = 2019
for i in range(500):
  if L <= (3**i)%(1e9+7) <= R or L <= (673**i)%(1e9+7) <= R or L <= (3*673*i)%(1e9+7) <= R or L <= (3*i)%(1e9+7) <= R or L <= (673*i)%(1e9+7) <= R:
    print(0)
    exit()
else:
  print(min((L*(L+1))%mod, R*(R-1)%mod, R*L%mod))

Fixed submission:
L, R = map(int,input().split())

R = min(R, L+673)
ans = 2018
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i*j%2019)
print(ans)

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

mod = 2019
for i in range(100):
  if L <= (3**i)%(1e9+7) <= R or L <= (673**i)%(1e9+7) <= R or L <= (3*673*i)%(1e9+7) <= R or L <= (3*i)%(1e9+7) <= R or L <= (673*i)%(1e9+7) <= R or L <= ((3*673)**i)%(1e9+7) <= R:
    print(0)
    exit()
else:
  print(min((L*(L+1))%mod, R*(R-1)%mod, R*L%mod))

Fixed submission:
L, R = map(int,input().split())

R = min(R, L+673)
ans = 2018
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i*j%2019)
print(ans)

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

mod = 2019
for i in range(500):
  if L <= 3**i%(1e9+7) <= R or L <= 673**i%(1e9+7) <= R or L <= 3*673*i%(1e9+7) <= R or L <= 3*i%(1e9+7) <= R or L <= 673*i%(1e9+7) <= R or L <= 3*673**i%(1e9+7) <= R:
    print(0)
    exit()
else:
  print(min((L*(L+1))%mod, R*(R-1)%mod, R*L%mod))

Fixed submission:
L, R = map(int,input().split())

R = min(R, L+673)
ans = 2018
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i*j%2019)
print(ans)

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

mod = 2019
for i in range(1000):
  if L <= 3**i%(1e9+7) <= R or L <= 673**i%(1e9+7) <= R or L <= 3*673*i%(1e9+7) <= R or L <= 3*i%(1e9+7) <= R or L <= 673*i%(1e9+7) <= R or L <= 3*673**i%(1e9+7) <= R:
    print(0)
    exit()
else:
  print(min((L*(L+1))%mod, R*(R-1)%mod, R*L%mod))

Fixed submission:
L, R = map(int,input().split())

R = min(R, L+673)
ans = 2018
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i*j%2019)
print(ans)

Buggy python submission (verdict: Runtime Error):
mod = 2019
for i in range(100):
  if L <= 3**i <= R or L <= 673**i <= R or L <= 3*673*i <= R or L <= 3*i <= R or L <= 673*i <= R or L <= 3*673**i <= R:
    print(0)
    exit()
else:
  print(min((L*(L+1))%mod, R*(R-1)%mod, R*L%mod))

Fixed submission:
L, R = map(int,input().split())

R = min(R, L+673)
ans = 2018
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i*j%2019)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
LR = set(list(map(int,input().split())) for _ in range(M))

cnt = 0
for i in range(N):
  tmp = 0
  for L, R in LR:
    if L-1 <= i <= R-1:
      tmp += 1
    else:
      break
    if tmp == M:
      cnt += 1
      break
print(cnt)

Fixed submission:
N, M = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(M)]

Lma = 0
Rmi = N + 1
for L, R in LR:
  Lma = max(L, Lma)
  Rmi = min(R, Rmi)

print(max(0, Rmi - Lma + 1))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(M)]

cnt = 0
for i in range(N):
  tmp = 0
  for L, R in LR:
    if L-1 <= i <= R-1:
      tmp += 1
    else:
      break
    if tmp == M:
      cnt += 1
      break
print(cnt)

Fixed submission:
N, M = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(M)]

Lma = 0
Rmi = N + 1
for L, R in LR:
  Lma = max(L, Lma)
  Rmi = min(R, Rmi)

print(max(0, Rmi - Lma + 1))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(M)]

cnt = 0
for i in range(N):
  tmp = 0
  for L, R in LR:
    if L-1 <= i <= R-1:
      tmp += 1
    if tmp == M:
      cnt += 1
      break
print(cnt)

Fixed submission:
N, M = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(M)]

Lma = 0
Rmi = N + 1
for L, R in LR:
  Lma = max(L, Lma)
  Rmi = min(R, Rmi)

print(max(0, Rmi - Lma + 1))
Buggy python submission (verdict: Time Limit Exceeded):
N =  int(input())
S = [input() for _ in range(N)]
S = [s for s in S if "AB" in s or s[0] == "B" or s[-1] == "A"]
n = len(S)

import itertools
perm = itertools.permutations
ans = 0
for per in perm(S, n):
  x = "".join(per)
  ans = max(ans, x.count("AB"))
print(ans)


Fixed submission:

N =  int(input())
S = [input() for _ in range(N)]

cnt = 0
b, a = 0, 0
ab = 0
for s in S:
  cnt += s.count("AB")
  if s[0] == "B" and s[-1] == "A":
    ab += 1
  elif s[0] == "B":
    b += 1
  elif s[-1] == "A":
    a += 1
if ab > 1:
  cnt += ab-1
  ab = 1
if ab:
  if a:
    cnt += 1
    a -= 1
  if b:
    cnt += 1
    b -= 1
at = 0
bt = 0
while a > 0 and b > 0:
  if a:
    at += 1
    a -= 1
  if b:
    bt += 1
    b -= 1
  if at + bt == 2:
    cnt += 1
  at = 0
  bt = 0
print(cnt)
Buggy python submission (verdict: Runtime Error):
#include "bits/stdc++.h"

using namespace std;

int main(){
  int A, B, T;
  cin >> A >> B >> T;

  cout << T/A*B << endl;
}

Fixed submission:
A, B, T = map(int,input().split())
T += 0.5
print(int(T//A*B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

res = []
for i in range(1 << N):
  X = Y = 0
  for j in range(N):
    if ((i >> j) & 1):
      X += V[j]
      Y += C[j]
  res.append(X-Y)
print(max(res))

Fixed submission:
def ans():
  N = int(input())
  V = list(map(int,input().split()))
  C = list(map(int,input().split()))
  ans = 0
  for i in range(N):
    if V[i] > C[i]:
      ans += V[i] - C[i]
  print(ans)

ans()
Buggy python submission (verdict: Runtime Error):
#include "bits/stdc++.h"

using namespace std;

int i;

int main(){
  int N, neg_cnt = 0;
  cin >> N;
  vector<int> A(N), B(N);
  for (i = 0; i < N; i++){
    cin >> A[i];
    if (A[i] < 0){
      neg_cnt++;
    }
  }
  for (i = 0; i < N; i++){
    B[i] = abs(A[i]);
  }
  int acm = 0;
  int min = *min_element(B.begin(), B.end());
  acm = accumulate(B.begin(), B.end(), 0);
  if (neg_cnt%2 == 0){
    cout << acm << endl;
  }else{
    cout << acm - 2*min << endl;
  }
}

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

neg_cnt = 0
for a in A:
  if a < 0:
    neg_cnt += 1

B = list(map(abs, A))
if neg_cnt%2 == 0:
  print(sum(B))
else:
  print(sum(B) - 2*min(B))
Buggy python submission (verdict: Runtime Error):
from itertools import groupby
N = int(input())
S = input()
b = 0
w = 0
x = ""
for i, (k, v) in enumerate(groupby(S)):
  if not x:
    if k == ".":
      continue
  v = len(list(v))
  if k == "#":
    b += v
  else:
    w += v
  x += k
if x[-1] == "#":
  b -= v
print(min(b,w))

Fixed submission:
N = int(input())
S = input()
  
v = [S.count(".")]
for i in range(N):
  if S[i] == "#":
    v.append(v[i]+1)
  else:
    v.append(v[i]-1)
print(min(v))
Buggy python submission (verdict: Runtime Error):
X = [str(input()) for _ in range(5)]
endzero = 0
elesnum = []
for x in X:
  if x[-1] == "0":
    endzero += int(x)
  else:
    elesnum.append(x)
elesnum.sort(key = lambda x: x[-1])
min_ = int(elesnum[0])
for e in elesnum[1:]:
  endzero += (int(e)//10+1)*10
print(endzero+min_)

Fixed submission:
X = [input() for _ in range(5)]
endzero = 0
elesnum = []
for x in X:
  if x[-1] == "0":
    endzero += int(x)
  else:
    elesnum.append(x)
if elesnum:
  elesnum.sort(key = lambda x: x[-1])
  min_ = int(elesnum[0])
  for e in elesnum[1:]:
    endzero += (int(e)//10+1)*10
  print(endzero+min_)
else:
  print(endzero)

Buggy python submission (verdict: Runtime Error):
a = str(input())
b = str(input())
c = str(input())
d = str(input())
e = str(input())
X = [a, b, c, d, e]
endzero = 0
elesnum = []
for x in X:
  if x[-1] == "0":
    endzero += int(x)
  else:
    elesnum.append(x)
elesnum.sort(key = lambda x: x[-1])
min_ = int(elesnum[0])
for e in elesnum[1:]:
  endzero += (int(e)//10+1)*10
print(endzero+min_)

Fixed submission:
X = [input() for _ in range(5)]
endzero = 0
elesnum = []
for x in X:
  if x[-1] == "0":
    endzero += int(x)
  else:
    elesnum.append(x)
if elesnum:
  elesnum.sort(key = lambda x: x[-1])
  min_ = int(elesnum[0])
  for e in elesnum[1:]:
    endzero += (int(e)//10+1)*10
  print(endzero+min_)
else:
  print(endzero)

Buggy python submission (verdict: Runtime Error):
X = [str(input()) for _ in range(5)]

endzero = 0
elesnum = []
for x in X:
  if x[-1] == "0":
    endzero += int(x)
  else:
    elesnum.append(x)
elesnum.sort(key = lambda x: x[-1])
last = elesnum[0]
for e in elesnum[1:]:
  endzero += (int(e)//10+1)*10
print(endzero+int(last))

Fixed submission:
X = [input() for _ in range(5)]
endzero = 0
elesnum = []
for x in X:
  if x[-1] == "0":
    endzero += int(x)
  else:
    elesnum.append(x)
if elesnum:
  elesnum.sort(key = lambda x: x[-1])
  min_ = int(elesnum[0])
  for e in elesnum[1:]:
    endzero += (int(e)//10+1)*10
  print(endzero+min_)
else:
  print(endzero)
Buggy python submission (verdict: Runtime Error):
from math import modf

n, a, b, c, d, e = [int(input()) for _ in range(6)]
r = min([h for h in [a,b,c,d,e] if h != 1])
if 1 in [a,b,c,d,e]:
  r -= 1
dd, ii = modf(n/r)
ll = int(ii)+int(dd*10)
print(5 if ll == 0 else ll)

Fixed submission:
n, a, b, c, d, e = [int(input()) for _ in range(6)]
x = min(a,b,c,d,e)
print((n+x-1)//x+4)

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

n, a, b, c, d, e = [int(input()) for _ in range(6)]
r = [h for h in [a,b,c,d,e] if h != 1]
if 1 in [a,b,c,d,e]:
  r = min(r)-1
dd, ii = modf(n/min(r))

print(max(5, int(ii)+int(dd*10)))

Fixed submission:
n, a, b, c, d, e = [int(input()) for _ in range(6)]
x = min(a,b,c,d,e)
print((n+x-1)//x+4)

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

n, a, b, c, d, e = [int(input()) for _ in range(6)]
r = [h for h in [a,b,c,d,e] if h != 1]
if 1 in [a,b,c,d,e]:
  r -= 1
dd, ii = modf(n/min(r))

Fixed submission:
n, a, b, c, d, e = [int(input()) for _ in range(6)]
x = min(a,b,c,d,e)
print((n+x-1)//x+4)

Buggy python submission (verdict: Runtime Error):
n, a, b, c, d, e = [int(input()) for _ in range(6)]
r = [h for h in [a,b,c,d,e] if h != 1]
if 1 in [a,b,c,d,e]:
  r -= 1
dd, ii = modf(n/min(r))

Fixed submission:
n, a, b, c, d, e = [int(input()) for _ in range(6)]
x = min(a,b,c,d,e)
print((n+x-1)//x+4)

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

n, a, b, c, d, e = [int(input()) for _ in range(6)]

dif = 0
ss = [a,b,c,d,e]
for i in range(N-1):
  if ss[i] > ss[i+1]:
    dif += ss[i]-ss[i+1]
dd, ii = modf(n/max(dif, min(ss)))
print(max(5, int(ii)+int(dd*10)))

Fixed submission:
n, a, b, c, d, e = [int(input()) for _ in range(6)]
x = min(a,b,c,d,e)
print((n+x-1)//x+4)
Buggy python submission (verdict: Runtime Error):
import re
ptn = re.compile(r"(A|C|T|G)*")

S = input()
T = set()
for i in range(len(S)):
  for j in range(len(S)):
    x = ptn.match(S[i:i+j+1])
    if(x.group(0)):
      T.add(len(x.group(0)))
print(max(T))

Fixed submission:
import re
ptn = re.compile(r"(A|C|T|G)*")

S = input()
T = set()
xx=ptn.match("FAFA")
for i in range(len(S)):
  for j in range(len(S)):
    x = ptn.match(S[i:i+j+1])
    if(x.group(0)):
      T.add(len(x.group(0)))
try:
  print(max(T))
except:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

S = input()
T = set()
for i in range(len(S)):
  for j in range(len(S)):
    T.add(S[i:i+j+1])

check = []
for i in range(len(S)+1):
  for per in product(["A","C","G","T"], repeat = i):
    per = "".join(per)
    check.append(per)
check = list(set(check))

ans = 0
for t in T:
  tt = "".join(t)
  if(tt in check):
    ans = max(ans, len(tt))
print(ans)

Fixed submission:
import re
ptn = re.compile(r"(A|C|T|G)*")

S = input()
T = set()
xx=ptn.match("FAFA")
for i in range(len(S)):
  for j in range(len(S)):
    x = ptn.match(S[i:i+j+1])
    if(x.group(0)):
      T.add(len(x.group(0)))
try:
  print(max(T))
except:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int,input().split())
S = input()

import re
ptn = re.compile(r"AC")

for _  in range(Q):
  l, r = map(int,input().split())
  x = re.findall(ptn,S[l-1:r])
  print(len(x))

Fixed submission:
N, Q = map(int,input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
  t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for _ in range(Q):
  l, r = map(int,input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int,input().split())
S = input().replace("G","").replace("T","")

for _  in range(Q):
  l, r = map(int,input().split())
  x = S[l-1:r]
  if(x):
    print(x.count("AC"))
  else:
    print(0)

Fixed submission:
N, Q = map(int,input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
  t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for _ in range(Q):
  l, r = map(int,input().split())
  print(t[r-1] - t[l-1])

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

for _  in range(Q):
  l, r = map(int,input().split())
  x = S[l-1:r]
  if("AC" in x):
    print(x.count("AC"))
  else:
    print(0)


Fixed submission:
N, Q = map(int,input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
  t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for _ in range(Q):
  l, r = map(int,input().split())
  print(t[r-1] - t[l-1])

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

for _  in range(Q):
  l, r = map(int,input().split())
  x = S[l-1:r]
  print(x.count("AC"))

Fixed submission:
N, Q = map(int,input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
  t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for _ in range(Q):
  l, r = map(int,input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int,input().split())
S = input()
LR = [list(map(int,input().split())) for _ in range(Q)]

import re
ptn = re.compile(r"(A|C|T|G)*")

for l, r in LR:
  x = ptn.match(S[l-1:r])
  if(x.group(0)):
    xx = x.group(0)
    print(xx.count("AC"))

Fixed submission:
N, Q = map(int,input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
  t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for _ in range(Q):
  l, r = map(int,input().split())
  print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
import sys 
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())

n = ni()
btc = 380000
ans = 0
for _ range(n):
  a, b = ns().split()
  if b == "BTC":
    ans += float(a) * btc
  else:
    ans += int(a)
print(ans)

Fixed submission:
N = int(input())
btc = 380000
cnt = 0
for _ in range(N):
  x, u = input().split()
  x = float(x)
  if(u == 'JPY'):
    cnt += x
  else:
    cnt += 380000*x
print(cnt)
Buggy python submission (verdict: Runtime Error):
S, A, B = map(int,input().split())

bis = 1
while K > 0:
  if(bis+1 > B):
    bis += 1
    K -= 1
  else:
    if(bis%A == 0):
      bis = 0
    else:
      bis //= A
    bis += B*max(bis//A, 1)
    K -= 2
print(bis)

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

if(A >= B-1 or 1+K <= A):
  print(K+1)
else:
  print((K-(A-1))//2*(B-A)+A+(K-(A-1))%2)
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
X = sorted(list(map(int,input().split())))

tmp = [abs(X[i+1] - X[i]) for i in range(M-1)]
if(tmp != []):
  for _ in range(N-1):
    tmp.remove(max(tmp))
  print(sum(tmp))
else:
  print(0)

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

tmp = sorted([X[i+1] - X[i] for i in range(M-1)])
if(tmp != []):
  if(len(tmp) == 1):
    print(*tmp)
  elif(N == 1):
    print(sum(tmp))
  else:
    print(sum(tmp[:-(N-1)]))
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
X = sorted(list(map(int,input().split())))

tmp = [abs(X[i+1] - X[i]) for i in range(M-1)]
if(tmp != []):
  tmp.remove([max(tmp) for _ in range(N-1)]
  print(sum(tmp))
else:
  print(0)

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

tmp = sorted([X[i+1] - X[i] for i in range(M-1)])
if(tmp != []):
  if(len(tmp) == 1):
    print(*tmp)
  elif(N == 1):
    print(sum(tmp))
  else:
    print(sum(tmp[:-(N-1)]))
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
X = sorted(list(map(int,input().split())))
tmp = []
for i in range(M-1):
  tmp.append(X[i+1] - X[i])
if(tmp != []):
  for i in range(N-1):
    tmp.remove(max(tmp))
  print(sum(tmp))
else:
  print(0)

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

tmp = sorted([X[i+1] - X[i] for i in range(M-1)])
if(tmp != []):
  if(len(tmp) == 1):
    print(*tmp)
  elif(N == 1):
    print(sum(tmp))
  else:
    print(sum(tmp[:-(N-1)]))
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int,input().split())))
B =list(map(int,input().split()))
if(sum(A) < sum(B)):
  print(-1)
  exit()
cnt = 0
for i in range(N):
  if(A[i] >= B[i]):
    cnt += 1
if(cnt == N):
  print(0)
  exit()
C = []
tmp = []
for b in B:
  for a in A:
    if(a not in tmp):
      tmp.append(a)
    if(a >= b):
      C.append(a)
      A.remove(a)
      break
ans = 0
for i in range(len(C)):
  if(C[i] != tmp[i]):
    ans += 1
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if(sum(A) < sum(B)):
  print(-1)
else:
  C = [A[i] - B[i] for i in range(N)]
  D = sorted([c for c in C if c > 0])
  E = [c for c in C if c < 0]
  ans = 0
  num = sum(E)
  while num < 0:
    num += D.pop()
    ans += 1
  print(ans + len(E))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A, B = map(int,input().split())
P = list(map(int,input().split()))

cnt = 0
for i in range(N):
  if(P[i] <= A):
    if(A+1 <= P[i+1] <= B):
      if(P[i+2] >= B+1):
        cnt += 1
print(cnt)

Fixed submission:
N = int(input())
A, B = map(int,input().split())
P = list(map(int,input().split()))
a, b, c = 0, 0, 0
for p in P:
  if p <= A:
    a += 1
  elif A+1 <= p <= B:
    b += 1
  elif p >= B+1:
    c += 1
print(min(a, b, c))
Buggy python submission (verdict: Runtime Error):
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<int> H(N);
  rep(i, N) cin >> H[i];

  vector<int> dp(N, INT_MAX);
  dp[0] = 0;
  rep(i, N)
  for (int j = 1; j <= K; j++){
    if (i+j < N){
      dp[i+j] = min(dp[i+j], dp[i]+abs(H[i]-H[i+j]));
    }else{
      break;
    }
  }
  cout << dp[N-1] << endl;
}

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

dp = [1e9]*N
dp[0] = 0
for i, b in enumerate(H):
  if i != 0:
    x = max(0, i-K)
    dp[i] = min([abs(b-d)+p for d, p in zip(H[x:i], dp[x:i])])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  N, K = map(int,input().split())
  H = list(map(int,input().split()))

  dp = [1e9]*N
  dp[0] = 0
  for i in range(N):
    for j in range(1,K+1):
      if i+j < N:
        dp[i+j] = min(dp[i+j], dp[i]+abs(H[i]-H[i+j]))
      else:
        break
  print(dp[N-1])

if __name__ == "__main__":
  main()

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

dp = [1e9]*N
dp[0] = 0
for i, b in enumerate(H):
  if i != 0:
    x = max(0, i-K)
    dp[i] = min([abs(b-d)+p for d, p in zip(H[x:i], dp[x:i])])
print(dp[-1])

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

dp = [10**9+7]*N
dp[0] = 0
for i in range(N):
  for j in range(1,K+1):
    if((i+j) < N):
      dp[i+j] = min(dp[i+j], dp[i]+abs(H[i]-H[i+j]))
    else:
      break
print(dp[N-1])

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

dp = [1e9]*N
dp[0] = 0
for i, b in enumerate(H):
  if i != 0:
    x = max(0, i-K)
    dp[i] = min([abs(b-d)+p for d, p in zip(H[x:i], dp[x:i])])
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
h = sorted(int(input()) for _ in range(N))

ans = 1e9+7
for i in range(N-K+1):
  ans = min(ans, h[i+K]-h[i])
print(ans)

Fixed submission:
N, K = map(int,input().split())
h = sorted([int(input()) for i in range(N)])
trees = [h[i+K-1] - h[i] for i in range(N-K+1)]
print(min(trees))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
h = sorted(int(input()) for _ in range(N))

ans = 1e9+7
for i in range(N-K+1):
  x = h[i:i+K]
  ans = min(ans, x[-1]-x[0])
print(ans)

Fixed submission:
N, K = map(int,input().split())
h = sorted([int(input()) for i in range(N)])
trees = [h[i+K-1] - h[i] for i in range(N-K+1)]
print(min(trees))

Buggy python submission (verdict: Time Limit Exceeded):
def ans():
  N, K = map(int,input().split())
  H = sorted([int(input()) for _ in range(N)])
  res = 1e9+7
  for i in range(N-K+1):
    tmp = H[i:i+K]
    res = min(res, max(tmp)-min(tmp))
  print(res)
ans()

Fixed submission:
N, K = map(int,input().split())
h = sorted([int(input()) for i in range(N)])
trees = [h[i+K-1] - h[i] for i in range(N-K+1)]
print(min(trees))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
h = [int(input()) for i in range(N)]
h.sort()
for i in list(set(h)):
  if(h.count(i) >= K):
    print('0')
    exit()
trees = h[:K]
h_max = max(trees)
h_min = min(trees)
print(h_max - h_min)

Fixed submission:
N, K = map(int,input().split())
h = sorted([int(input()) for i in range(N)])
trees = [h[i+K-1] - h[i] for i in range(N-K+1)]
print(min(trees))