Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03136 (python)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L_copy = L.copy()
MAX = max(L)
L_copy.pop(L.index(MAX))


if MAX < sum(L_copy):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
L = list(map(int,input().split()))
L_copy = L.copy()
max = max(L)
L_copy.pop(L.index(min))

if max > sum(L_copy):
  print("Yes")
else:
  print("No")
Problem p03273 (python)

Fixed submission:
H, W = map(int,input().split())
a = []
for i in range(H):
  a1 = input()
  if "#" in a1:
    a.append(a1)

b = []
for i in range(W):
  for j in range(len(a)):
    if a[j][i] == "#":
      break
  else:
      b.append(i)

for i in range(len(a)):
  ans = ""
  for j in range(W):
    if not j in b:
      ans += a[i][j]
  print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
a = []
for i in range(H):
  a1 = input()
  if "#" in a1:
    a.append(a1)

b = []
for i in range(W):
  bi = [""] * W
  for j in range(len(a)):
    if j == len(a) - 1 and "#" in a[j - 2][i] + a[j - 1][i] + a[j][i]:
      b.append(a[j - 2][i] + a[j - 1][i] + a[j][i])
      
for i in range(len(b)):
  ans = 0
  for j in range(len(b[0])):
    ans = b[j - 2][i] + b[j - 1][i] + b[j][i]
  print(ans)
Problem p03408 (python)

Fixed submission:
from collections import Counter

N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
a = Counter(s)
a = a.most_common()


ans = 0
for i in a:
  if i[0] not in t:
    ans = max(i[1],ans)

  elif i[0] in t:
    ans = max(i[1] - t.count(i[0]),ans)


print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

ans = 0
for i in a:
  ans = max(ans, s.count(i) - t.count(i))

print(ans)
Problem p02554 (python)

Fixed submission:
N = int(input())
mod = 10**9 + 7


def powmod(val, n, mod):
    ret = 1
    for i in range(n):
        ret = ret * val % mod

    return ret


all = powmod(10, N, mod)
b = powmod(9, N, mod)
c = powmod(8, N, mod)

ans = (all - (2*b - c))%mod

print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce

N = int(input())
mod = 10**9 + 7


def powmod(val, n, mod):
    # vals = [val]*n
    # ret = reduce(lambda x, y: x * y % mod, vals)

    # return ret

    for i in range(n):
        ret = ret * val % mod

    return ret


all = powmod(10, N, mod)
b = powmod(9, N, mod)
c = powmod(8, N, mod)

ans = (all - (2*b - c))%mod

print(ans)
Problem p02573 (python)

Fixed submission:
from copy import deepcopy

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

pairs = [0] * M
for i in range(M):
    pairs[i] = list(map(int, input().split()))


# N = 5
# pairs = [[1,2], [3,4], [5,1]]


class UnionFind:
    def __init__(self, N):
        self.r = [-1] * N

    def root(self, x):
        if self.r[x] < 0:
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]


    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.r[x] > self.r[y]:
            x, y = y, x

        self.r[x] += self.r[y]
        self.r[y] = x
        return True

    def size(self, x):
        return -self.r[self.root(x)]

uf = UnionFind(N)
for pair in pairs:
    a = pair[0] - 1
    b = pair[1] - 1
    uf.unite(a, b)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)

Buggy submission (verdict: Runtime Error):
from copy import deepcopy

n, m = map(int, input().split())

pairs = [0] * m
for i in range(m):
    pairs[i] = list(map(int, input().split()))


# N = 5
# pairs = [[1,2], [3,4], [5,1]]

print(pairs)

class UnionFind:
    def __init__(self, N):
        self.r = [-1] * N

    def root(self, x):
        if self.r[x] < 0:
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]


    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.r[x] > self.r[y]:
            x, y = y, x

        self.r[x] += self.r[y]
        self.r[y] = x
        return True

    def size(self, x):
        return -self.r[self.root(x)]

uf = UnionFind(N)
for pair in pairs:
    a = pair[0] - 1
    b = pair[1] - 1
    uf.unite(a, b)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)
Problem p03389 (python)

Fixed submission:
import numpy as np

# A, B, C = [11, 12, 15]
A, B, C = list(map(int, input().split()))


vals = np.array([A, B, C])
vals = np.sort(vals)

sumval = vals.sum()



cn = vals[-1] + np.sum(vals[:2]) % 2

n = (3 * cn - sumval) // 2

print(n)

Buggy submission (verdict: Runtime Error):
lst = list(map(int, input().split())).sort()

mval = lst[-1]
sval = sum(lst)
cn = mval + (sval-mval) % 2
n = (cn * 3 - sval) // 2
print(n)
Problem p02675 (python)

Fixed submission:
N = str(input())
n = int(N[len(N)-1])
if n==3:
    print('bon')
elif n==0 or n==1 or n==6 or n==8:
    print('pon')
else:
    print('hon')

Buggy submission (verdict: Runtime Error):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class a168{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String N = reader.readLine();
            int len = (int)N.length()-1;
            String last = N.substring(len);
            System.out.println(last);
            if(last.equals("3")){
                System.out.println("bon");
            }else if(last.equals("0") || last.equals("1") || last.equals("6") || last.equals("8")){
                System.out.println("pon");
            }else{
                System.out.println("hon");
            }
        }catch(IOException e){
            System.out.println("aaaa");
        }
    }
}
Problem p02706 (python)

Fixed submission:
N,M = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(M):
    ans+=A[i]
ans = N - ans
if ans >= 0:
    print(ans)
else :
    print(-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
A = 0
for i in range(M):
    A = A + int(input())
ans = N - A
if ans >= 0:
    print(ans)
else :
    print(-1)
Problem p02719 (python)

Fixed submission:
N,K = map(int, input().split())
syou = N//K
min_1 = N - syou*K
min_2 = -(N - (syou+1)*K)
if min_1 < min_2:
    print(min_1)
else :
    print(min_2)

Buggy submission (verdict: Runtime Error):
if N > 100000000:
    N /= 10000000
syou = int(N/K)
print(syou)
min_1 = int(N - syou*K + 0.5)
min_2 = -int(N - (syou+1)*K - 0.5)
print('{} {}'.format(min_1,min_2))
if min_1 < min_2:
    print(min_1)
else :
    print(min_2)
Problem p02958 (python)

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

if p == sorted(p):
    print('YES')
else:
    ret = 'NO'
    is_sorted = False
    # 全通りの組み合わせをみて、昇順かどうか調べる
    for i in range(N-1):
        for j in range(i+1, N):
            # p[i]とp[j]より小さければ抜ける
            if p[i] < p[j]:
                continue
            else:
                k = p.copy()
                k[i], k[j] = k[j], k[i]

#             for l in range(N-1):
#                 if k[l+1] < k[l]:
#                     is_sorted = False
#                     break

            if k == sorted(p):
                ret = 'YES'
                is_sorted = True
                break
        if is_sorted:
            break

    print(ret)

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list(map(int,input().split()))

if p == sorted(p):
    print('YES')
else:
    ret = 'NO'
    # 全通りの組み合わせをみて、昇順かどうか調べる
    for i in range(N-1):
        for j in range(i+1, N):

            # p[i]とp[j]より小さければ抜ける
            if p[i] < p[j]:
                continue
            else:
                k = p.copy()
                k[i], k[j] = k[j], k[i]

            is_sorted = True
            for l in range(N-1):
                if k[l+1] < k[l]:
                    is_sorted = False
                    break

            if is_sorted:
                ret = 'YES'
                break
        if is_sorted:
            break

    print(ret)
Problem p03029 (python)

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

P = P + A*3

apple_pie = 0

while  P>1:
    
    apple_pie = apple_pie + 1
    P = P - 2
    
print(apple_pie)

Buggy submission (verdict: Runtime Error):
N = int(input())

my_list = []

for i in range(N):
    sp = input().split()
    sp[1] = int(sp[1])
    sp.insert(0, i+1)
    
    my_list.append(sp)
    
my_list.sort(key = lambda x: x[2], reverse=True)
my_list.sort(key = lambda x: x[1])

for i in my_list:
    print(i[0])
Problem p03697 (python)

Fixed submission:
A, B = list(map(int,input().split()))
if A+B < 10:
    print(A+B)
else:
    print('error')

Buggy submission (verdict: Runtime Error):
A, B = int(input().split())
if A+B < 10:
    print(A+B)
else:
    print('error')
Problem p03777 (python)

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

if a == 'H' and b == 'H':
    result = 'H'
    
if a == 'D' and b == 'H':
    result = 'D'
    
if a == 'D' and b == 'D':
    result = 'H'
    
if a == 'H' and b == 'D':
    result = 'D'
    
print(result)

Buggy submission (verdict: Runtime Error):
a, b = input().split()

if a == 'H' and b == 'H':
    result = 'H'
    
if a == 'D' and b == 'H':
    result = 'D'
    
if a == 'D' and b == 'D':
    result = 'H'

    
print(result)
Problem p02658 (python)

Fixed submission:
N=int(input())
As=list(map(int,input().split()))
ans=1

if 0 in As:
    print(0)
else:
    for i in range(N):
        ans*=As[i]
        if ans>int(1e18):
            break
    print(ans if ans<=int(1e18) else -1)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=1
for i in range(N):
   A=A*int(input())
print(A if A<=100000000000000000 else -1)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=1
for i in range(N):
   A=A*int(input())
print(A if len(A)<=18 else -1)
Problem p03059 (python)

Fixed submission:
A,B,C = map(int, input().split())
print(round(C//A*B))

Buggy submission (verdict: Runtime Error):
N = int(input())
C = list(map(int, input().split()))
V = list(map(int, input().split()))
sum = 0
for i in range(N):
    sum += max(0, V[i]-C[i])
print(sum)
Problem p03102 (python)

Fixed submission:
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for _ in range(n)]
count=0
for i in range(n):
    total=0
    for j in range(m):
        total+=b[j]*a[i][j]
    if total>-c:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for _ in range(n)]
count=0
for i in range(n-1):
    for j in range(m-1):
        total+=b[j]*a[i][j]
    if total>-c:
        count+=1
print(count)
Problem p03408 (python)

Fixed submission:
n=int(input())
sn=[input() for _ in range(n)]
m=int(input())
sm=[input() for _ in range(m)]
l=list(set(sn))
print(max(0,max([sn.count(l[i])-sm.count(l[i]) for i in range(len(l))])))

Buggy submission (verdict: Runtime Error):
n=int(input())
sn=[input() for _ in range(n)]
m=int(input())
sm=[input() for _ in range(m)]
l=list(set(sn))
print(max(0,max([sn.count(l[i])-sm.count(l[i]) for i in range(n)])))
Problem p02606 (python)

Fixed submission:
l,r,d = map(int, input().split())
var=l//d
var1=r//d
ans=var1-var
if l%d==0:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
l,r,d = map(int, input().split())
var=l//d
var1=r//d
ans=var1-var
if l%d==0:
ans+=1
print(ans)
Problem p02628 (python)

Fixed submission:
n,m=map(int,input().split())
arr=sorted(list(map(int,input().split())))
print(sum(arr[:m]))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
arr=list(map(int,input().split())
arr.sort()
print(sum(arr[:m]))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
arr=list(map(int,input().split())
 arr.sort()
print(sum(arr[:m]))
Problem p03160 (python)

Fixed submission:
n=int(input())
cst=list(map(int,input().split()))
arr=[0]*10**5
arr[0]=0
arr[1]=abs(cst[1]-cst[0])
if n==2:
    print(arr[1])
else:
    for i in range(2, n):
        arr[i] = min(abs(cst[i - 1] - cst[i]) + arr[i - 1], abs(cst[i - 2] - cst[i]) + arr[i - 2])
    print(arr[i])

Buggy submission (verdict: Runtime Error):
import sys

def input():
    return sys.stdin.readline().strip()


n,k=map(int,input().split())
cst=list(map(int,input().split()))
arr=[0]*n
arr[1]=abs(cst[1]-cst[0])
for i in range(2, n):
    arr[i]=min(abs(cst[j]-cst[i])+arr[j] for j in  range(max(i-k,0),i))
print(arr[n-1])

#print(arr)
Problem p03161 (python)

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    n, k = map(int, input().split())
    cst = list(map(int, input().split()))
    arr = [0] * n
    arr[1] = abs(cst[1] - cst[0])
    for i in range(2, n):
        arr[i] = min(abs(cst[j] - cst[i]) + arr[j] for j in range(max(i - k, 0), i))
    print(arr[n - 1])
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
cst=list(map(int,input().split()))
arr=[0]*10
arr[0]=0
arr[1]=abs(cst[1]-cst[0])
if n==2:
    print(arr[1])
else:
    for i in range(2, n):
        #arr[i] = min(abs(cst[i - 1] - cst[i]) + arr[i - 1], abs(cst[i - 2] - cst[i]) + arr[i - 2])
        #t=cst.index(min(cst[max(i-k,0):i]))
        arr[i]=min(abs(cst[max(i-j,0)]-cst[i])+arr[i-j] for j in range(1,k+1))
    print(arr[n-1])

#print(arr)
Problem p02953 (python)

Fixed submission:
N = int(input())
inputs = [int(i) for i in input().split()]

for i in range(N-1, 1, -1):
    if inputs[i-1] > inputs[i]:
        inputs[i-1] -= 1

for i in range(1, N):
    if inputs[i-1] > inputs[i]:
        print('No')
        break
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
inputs = [int(i) for i in input().split()]

for i in range(1, N):
    if inputs[i-1] > inputs[i] and inputs[i-1] >= 1:
        inputs[i-1] -= 1

if inputs[-1] < inputs[-2] and inputs[-1] >= 1:
    inputs[-2] -= 1

for i in range(1, N):
    if inputs[i-1] > inputs[i]:
        print('No')
        break
else:
    print('Yes')
Problem p02963 (python)

Fixed submission:
import math

S = int(input())

ans = [0, 0]
if S <= 10 ** 9:
    ans += [S, 0, 0, 1]
else:
    root = math.ceil(math.sqrt(S))
    ans += [root ** 2 - S, root, root, 1]

print(*ans)

Buggy submission (verdict: Runtime Error):
import math

S = int(input())

ans = [0, 0]
if S <= 10 ** 9:
    ans += [S, 0, 0, 1]
else:
    root = int(matn.sqrt(S))
    ans += [root ** 2 - S, root, root, 1]

print(*ans)

Buggy submission (verdict: Runtime Error):
import math

S = int(input())

ans = [0, 0]
limit = 10 ** 9
seki = S + 10 ** 6
for i in range(1, 10**9):
    div = seki % j
    if div == 0:
        if j > limit or seki // j > limit:
            continue
        ans += [j, 1, 10 ** 9, seki // j]
        print(*ans)
        exit()
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())

print(W * H / 2, 1 if W / 2 == x and H / 2 == y else 0)

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

ans = [min(x, W - x) * H, min(y, H - y) * W]

if (x == 0 and y == 0) or (x == W and y == 0) or (x == 0 and y == H) or (x == W and y == H):
    print(W * H / 2, 0)
elif y / x == H / W:
    if x == W / 2 and y == H / 2:
        print(W * H / 2, 1)
    else:
        print(W * H / 2, 0)
else:
    print(max(ans), int(ans[0] == ans[1]))

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

ans = [min(x, W - x) * H, min(y, H - y) * W]

if y / x == H / W:
    print(W * H / 2, 1)
elif (x == 0 and y == 0) or (x == W and y == 0) or (x == 0 and y == H) or (x == W and y == H):
    print(W * H / 2, 0)
else:
    print(max(ans), int(ans[0] == ans[1]))

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

ans = [min(x, W - x) * H, min(y, H - y) * W]

if (x == 0 and y == 0) or (x == 1 and y == 0) or (x == 0 and y == 1) or (x == 1 and y == 1):
    print(W * H / 2, 0)
elif W == 
else:
    print(max(ans), int(ans[0] == ans[1]))
Problem p03006 (python)

Fixed submission:
N = int(input())
inputs = [[int(i) for i in input().split()] for _ in range(N)]

ans = 1
rates = {0: 0}
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        vector = (inputs[i][0] - inputs[j][0], inputs[i][1] - inputs[j][1])
        rates[vector] = rates.get(vector, 0) + 1

print(N - max(rates.values()))

Buggy submission (verdict: Runtime Error):
N = int(input())
inputs = [[int(i) for i in input().split()] for _ in range(N)]

ans = 1
rates = {}
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        vector = (inputs[i][0] - inputs[j][0], inputs[i][1] - inputs[j][1])
        rates[vector] = rates.get(vector, 0) + 1

print(N - max(rates.values()))
Problem p03048 (python)

Fixed submission:
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N // R + 1):
    for g in range((N - R * r) // G + 1):
        tmp = N - r * R - g * G
        if tmp % B == 0:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N // R + 1):
    if N - r * R < 0:
        break
    for g in range((N - R * i) // G + 1):
        tmp = N - r * R - g * G
        if tmp < 0:
            break
        if tmp % B == 0 and tmp // B >= 0:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())

ans = 0
for r in range(3000 // R + 1):
    if N - r * R < 0:
        continue
    for g in range(3000 // G + 1):
        tmp = N - r * R - g * G
        if tmp < 0:
            break
        if tmp % B == 0 and tmp // B >= 0:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())

ans = 0
for r in range(3001):
    if N - r * R < 0:
        continue
    for g in range(3001):
        tmp = N - r * R - g * G
        if tmp < 0:
            break
        if tmp % B == 0 and tmp // B >= 0:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())

ans = 0
count = N // min(R, G, B) + 1
for r in range(count):
    if r * R > N:
        break
    for g in range(count):
        if r * R + g * G > N:
            break
        for b in range(count):
            if r * R + g * G + b * B == N:
                ans += 1
                break

print(ans)
Problem p03109 (python)

Fixed submission:
import datetime

# if not (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')):
#     print('Heisei')
# else:
#     print('TBD')
a  = (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')).days
if a >= 0:
    print('Heisei')
else:
    print('TBD')

Buggy submission (verdict: Runtime Error):
import datetime

a  = (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')).days

print('Heisei' a >= 0 else 'TBD')

Buggy submission (verdict: Runtime Error):
import datetime

a  = (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')).days

print('Heisei'a >= 0 else 'TBD')
Problem p03126 (python)

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

inputs = [[i for i in input().split()] for _ in range(N)]

ans = set(inputs[0])
for item in range(N):
    ans = ans & set(inputs[item][1:])

print(len(ans))

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

inputs = [[i for i in input().split()] for _ in range(N)]

ans = set(inputs[0])
for item in inputs:
    ans &= set(inputs[1:])

print(len(ans))
Problem p03141 (python)

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

dicts = {}
for i in range(N):
    dicts[i] = sum(inputs[i])

t = 0
a = 0
count = 0
for key, value in sorted(dicts.items(), key=lambda x: -x[1]):
    if count % 2 == 0:
        t += inputs[key][0]
    else:
        a += inputs[key][1]
    count += 1

print(t - a)

Buggy submission (verdict: Runtime Error):
N = int(input())
inputs = [list(map(int, input().split())) for _ in range(N)]

dicts = {}
for i in range(N):
    dicts[i] = sum(inputs[i])

ans = ~
count = 0
for key, value in sorted(dicts.items(), key=lambda x: -x[1]):
    if count % 2 == 0:
        ans += inputs[key][0]
    else:
        ans -= inputs[key][1]
    count += 1

print(ans)
Problem p03150 (python)

Fixed submission:
N = input()

S = 'keyence'
if S == N[:len(S)]:
    print('YES')
elif S == N[-len(S):]:
    print('YES')
else:
    for index in range(len(S)):
        if S[:index] == N[:index] and S[-(len(S) - index):] == N[-(len(S) - index):]:
            print('YES')
            break
    else:
        print('NO')

Buggy submission (verdict: Runtime Error):
N = input()

S = 'keyence'
index = 0
for item in N:
    if S[index] == item:
        index += 1

print('YES' if index == len(S) else 'NO')
Problem p03161 (python)

Fixed submission:
import numpy as np


N, K = map(int, input().split())
inputs = np.array([int(i) for i in input().split()])

dp = np.zeros(N, dtype=int)
for i in range(1, N):
    start = max(0, i-K)
    dp[i] = (dp[start:i] + abs(inputs[i] - inputs[start:i])).min()

print(dp[-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
inputs = [int(i) for i in input().split()]

dp = [10 ** 9 for _ in range(N)]
dp[0] = 0
for i in range(1, N):
    if i == 1:
        dp[i] = abs(inputs[i] - inputs[i-1])
    else:
        tmp = 10 ** 9
        start = max(0, i-K)
        dp[i] = min([dp[start] + abs(inputs[i-(j+1)] - inputs[i]) for j in range(start, i-1)])

print(dp[-1])
Problem p03164 (python)

Fixed submission:
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.full(N*1000+1, 10 ** 10, dtype=np.int64)
dp[0] = 0
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[value:] = np.minimum(dp[value:], dp[:-value] + weight)

print(np.max(np.where(dp <= W)))

Buggy submission (verdict: Runtime Error):
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.full(N*1000+1, 10 ** 10, dtype=np.int64)
dp[0] = 0
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[value:] = np.minimum(dp[value:], dp[:-value] + weight)

print(np.max(np.where(dp <=

Buggy submission (verdict: Runtime Error):
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.zeros(W+1, dtype=np.int64)
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.zeros(W+1, dtype=np.int64)
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.zeros(W+1, dtype=np.int64)
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value)

print(dp[-1])
Problem p03239 (python)

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

ans = 10 ** 9

for _ in range(N):
    a, b = map(int, input().split())
    if b <= T:
        ans = min(ans, a)

if ans == 10 ** 9:
    print('TLE')
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())

ans = 10 ** 9

for _ in rnage(N):
    a, b = map(int, input().split())
    if b <= T:
        ans = min(ans, b)

if ans == 10 ** 9:
    print('TLE')
else:
    print(ans)