Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, A = nl()
X = nl()

dp = []
for i in range(N+1):
    r = []
    for j in range(N+1):
        r.append([0 for k in range(N*max(X)+1)])
    dp.append(r)

dp[0][0][0] = 1
for i in range(1, N+1):
    for j in range(0, N+1):
        for k in range(N*max(X)+1):
            if k < X[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0 and k >= X[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]]

total = 0
for k in range(1, N+1):
    total += dp[N][k][k*A]
print(total)




Fixed submission:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, A = nl()
X = nl()

dp = []
for i in range(N+1):
    r = []
    for j in range(N+1):
        r.append([0 for k in range(N*50+1)])
    dp.append(r)

dp[0][0][0] = 1
for i in range(1, N+1):
    for j in range(0, N+1):
        for k in range(N*50+1):
            if k < X[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0 and k >= X[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]]

total = 0
for k in range(1, N+1):
    total += dp[N][k][k*A]
print(total)

Buggy python submission (verdict: Runtime Error):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, A = nl()
X = nl()

dp = []
for i in range(N+1):
    r = []
    for j in range(N+1):
        r.append([0 for k in range(N*max(X)+1)])
    dp.append(r)

dp[0][0][0] = 1
for i in range(1, N+1):
    for j in range(0, N+1):
        for k in range(N*max(X)+1):
            if k < X[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]]

total = 0
for k in range(1, N+1):
    total += dp[N][k][k*A]
print(total)




Fixed submission:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, A = nl()
X = nl()

dp = []
for i in range(N+1):
    r = []
    for j in range(N+1):
        r.append([0 for k in range(N*50+1)])
    dp.append(r)

dp[0][0][0] = 1
for i in range(1, N+1):
    for j in range(0, N+1):
        for k in range(N*50+1):
            if k < X[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0 and k >= X[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i-1]]

total = 0
for k in range(1, N+1):
    total += dp[N][k][k*A]
print(total)
Buggy python submission (verdict: Runtime Error):
import itertools

N, K = map(int, input().split())
Ds = list(map(int, input().split()))
NDs = list(set([i for i in range(10)]) - set(Ds))
NDs = list(map(str, NDs))

min_price = 10000
for p in itertools.product(NDs, repeat=len(str(N))):
    if p[0] == '0':
        continue
    price = int(''.join(p))
    if price < N:
        continue
    min_price = min(price, min_price)

if min_price == 10000:
    for p in itertools.product(NDs, repeat=len(str(N)+1)):
        if p[0] == '0':
            continue
        price = int(''.join(p))
        min_price = min(price, min_price)

print(min_price)

Fixed submission:
import itertools

N, K = map(int, input().split())
Ds = list(map(int, input().split()))
NDs = list(set([i for i in range(10)]) - set(Ds))
NDs = list(map(str, NDs))

min_price = 100000
for p in itertools.product(NDs, repeat=len(str(N))):
    if p[0] == '0':
        continue
    price = int(''.join(p))
    if price < N:
        continue
    min_price = min(price, min_price)

if min_price == 100000:
    for p in itertools.product(NDs, repeat=len(str(N))+1):
        if p[0] == '0':
            continue
        price = int(''.join(p))
        min_price = min(price, min_price)

print(min_price)
Buggy python submission (verdict: Time Limit Exceeded):
def key_func(n):
	return n[0]

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

list_price_and_energydrink = []

for i in range(N):
	A_i, B_i = map(int, input().split())
	list_shop_number_i = [A_i, B_i]
	list_price_and_energydrink.append(list_shop_number_i)
	
list_price = []
list_possible_number_drink = []

count_number_drink = 0
count_price_drink = 0

while count_number_drink < M:
	list_minimum_i = min(list_price_and_energydrink, key=key_func)
	
	if count_number_drink + list_minimum_i[1] > M:
		count_price_drink += list_minimum_i[0] * (M - count_number_drink)
		count_number_drink = M
	else:
		count_number_drink += list_minimum_i[1]
		count_price_drink += list_minimum_i[0] * list_minimum_i[1]	
	
	list_price_and_energydrink.remove(list_minimum_i)

print(count_price_drink)

Fixed submission:
from operator import itemgetter

def key_func(n):
	return n[0]

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

list_price_and_energydrink = []

for i in range(N):
	A_i, B_i = map(int, input().split())
	list_shop_number_i = [A_i, B_i]
	list_price_and_energydrink.append(list_shop_number_i)

count_number_drink = 0
count_price_drink = 0

list_price_and_energydrink.sort(key=itemgetter(0))

while count_number_drink < M:
	list_minimum_i = list_price_and_energydrink[0]
	
	if count_number_drink + list_minimum_i[1] > M:
		count_price_drink += list_minimum_i[0] * (M - count_number_drink)
		count_number_drink = M
	else:
		count_number_drink += list_minimum_i[1]
		count_price_drink += list_minimum_i[0] * list_minimum_i[1]	
	
	list_price_and_energydrink.remove(list_minimum_i)

print(count_price_drink)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = []

for i in range(n):
    h.append(int(input()))
min = 10 ** 10
#  print(h)
h = sorted(h)
#  print(h)
for i in range(k):
    #  print(h[i:i+k-1])
    div = h[i+k-1] - h[i]
    if div < min:
        min = div
    if min == 0:
        print(min)
        exit()
print(min)


Fixed submission:
n, k = map(int, input().split())
h = []

for i in range(n):
    h.append(int(input()))
min = 10 ** 10
#  print(h)
h = sorted(h)
#  print(h)
for i in range(n-k+1):
    #  print(h[i:i+k-1])
    div = h[i+k-1] - h[i]
    if div < min:
        min = div
    if min == 0:
        print(min)
        exit()
print(min)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
if m % n == 0:
    print(m // n)
else:
    gcd = m // n
    for i in range(gcd, 0, -1):
        if m % i == 0:
            j = m // gcd
            if j >= n:
                print(i)
                exit()


Fixed submission:
import math
n, m = map(int, input().split())
root_m = int(math.sqrt(m))
ans = 1
for a in range(1, root_m):
    # print(a, ans)
    if m % a == 0:
        b = m // a
        if a * n <= m:
            ans = max(ans, a)
        if b * n <= m:
            ans = max(ans, b)
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd
n, m = map(int, input().split())
if m % n == 0:
    print(m // n)
else:
    gcd = m // n
    for i in range(gcd, 0, -1):
        if m % i == 0:
            j = m // gcd
            if j >= n:
                print(i)
                exit()


Fixed submission:
import math
n, m = map(int, input().split())
root_m = int(math.sqrt(m))
ans = 1
for a in range(1, root_m):
    # print(a, ans)
    if m % a == 0:
        b = m // a
        if a * n <= m:
            ans = max(ans, a)
        if b * n <= m:
            ans = max(ans, b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
ll = 2*n // k
ans = 0
for i in range(1, ll+1):
    for j in range(1, ll+1):
        for m in range(1, ll+1):
            if ((m+i-j)*k) % 2 == 0 and ((i-m+j)*k) % 2 == 0 and ((m-i+j)*k) % 2 == 0:
                if (m+i-j) > 0 and (i-m+j) > 0 and (m-i+j) > 0:
                    if (m+i-j)*k//2 <= n and (i-m+j)*k//2 <= n and (m-i+j)*k//2 <= n:
                        ans += 1
print(ans)


Fixed submission:
n, k = map(int, input().split())
ll = n // k
if ll % 2 == 0:
    l_odd = ll // 2
    l_even = ll // 2
else:
    l_odd = ll // 2 + 1
    l_even = ll // 2
if k % 2 == 0:
    ans = ll ** 3
    if n >= ll*k + k/2:
        ans += (ll+1)**3
    else:
        ans += ll**3
    print(ans)
else:
    print(ll ** 3)
Buggy python submission (verdict: Runtime Error):
d, g = map(int, input().split())
p = [[0,0] for i in range(d)]
for i in range(d):
    p[i][0], p[i][1] = map(int, input().split())
ans = 0
sum = 0
i = d
j = 0
extra_ans = [p[i][0] * (i+1) * 100 + p[i][1] for i in range(d)]
while sum < g:
    j += 1
    ans += 1
    sum += i * 100
    if j == p[i-1][0]:
        sum += p[i-1][1]
        i -= 1
        j = 0
    if sum + extra_ans[i-2] >= g :
        tmp = ans + p[i-2][0]
if tmp < ans:
    ans = tmp
for i in range(d):
    if p[i][0] * (i+1) * 100 + p[i][1] >= g and p[i][0] < ans:
        ans = p[i][0]
print(ans)


Fixed submission:
# &演算子は、bit形式には使えない。でも、数値には使える
d, g = map(int, input().split())
p = [[0, 0] for i in range(d)]
for i in range(d):
    p[i][0], p[i][1] = map(int, input().split())
## bit全探索

ans = 100000
for i in range(2 ** d):
    sum = 0
    ans_tmp = 0
    s = bin(i)
    #　得点の合計とそれまでの数を反映。
    for j in range(d):
        if bin(2 ** j) == bin(2 ** j & i):
            sum += p[j][0] * (j+1) * 100 + p[j][1]
            ans_tmp += p[j][0]
    if sum < g:
        for j in range(d-1, -1, -1):
            if bin(2 ** j) != bin(2 ** j & i):
                for k in range(p[j][0]-1):
                    sum += (j+1) * 100
                    ans_tmp += 1
                    if g <= sum:
                        break
                if g <= sum:
                    if ans_tmp < ans:
                        ans = ans_tmp
                    break
            else:
                continue
    else:
        if ans_tmp < ans:
            ans = ans_tmp
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
# stdin.readlines?
x = [[0, 0] for i in range(m)]
for i in range(m):
    x[i][0], x[i][1] = map(int, input().split())
x = sorted(x, key = lambda y: y[0])
ans = 1
mx = max(x[0])
while len(x) > 0:
    for i in range(len(x)):
        if mx <= x[i][1]:
            x.pop(i)
        else:
            mx = x[i][0]
            ans += 1
            break
prin(ans)


Fixed submission:
n, m = map(int, input().split())
# stdin.readlines?
x = [[0, 0] for i in range(m)]
for i in range(m):
    x[i][0], x[i][1] = map(int, input().split())
x = sorted(x, key=lambda y: y[0])
ans = 1
mx = max([x[i][0] for i in range(m)])
while len(x) > 0:
    for i in range(len(x)-1, -1, -1):
        if mx < x[i][1]:
            x.pop(i)
            break
        else:
            mx = x[i][0]
            ans += 1
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
a_tmp = input().split()
a = []
for i in range(n):
    a.append(int(a_tmp[i]))
a1 = []
for i in range(n):
    a1.append(a[i]-1-i)
b_max = max(a1)
b_min = min(a1)
sadness = []
for b in range(b_min, b_max+1):
    abs = [math.fabs(a1[i]-b) for i in range(n)]
    sadness.append(int(sum(abs)))
print(min(sadness))


Fixed submission:
import math
n = int(input())
a_tmp = input().split()
a_tmp1 = []
for i in range(n):
    a_tmp1.append(int(a_tmp[i])-i-1)
a = sorted(a_tmp1)
if n % 2 == 0:
    x = a[n//2]
else:
    x = a[n//2]
ans = 0
for _ in a:
    ans += math.fabs(_ - x)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a_tmp = input().split()
a = [[] for i in range(n)]
for i in range(n):
    a[i] = int(a_tmp[i])
if n != k:
a1 = a.index(1)
sol = 0
a_left = a1
a_right = len(a)-1-a1
if a_left % (k-1) == 0:
    sol += int(a_left / (k-1))
else:
    sol += int(a_left / (k-1)) + 1
if a_right % (k-1) == 0:
    sol += int(a_right / (k-1))
else:
    sol += int(a_right / (k-1)) + 1

if sol != 0:
    print(sol)
else:
    print(1)


Fixed submission:
# グループ分けの数を最初に分かっていれば、いい
n, k = map(int, input().split())
a_tmp = input().split()
a = []
for _ in a_tmp:
    a.append(int(_))
g = 1
while n > (k + (k-1)*(g-1)):
    g += 1
print(g)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')


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

if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
n1 = []
for i in range(n):
    s1 = set()
    for j in range(i):
        for k in range(i+1, n):
            # print(i, j, k, s[j], s[k])
            if s[j] == s[k] and set(s[j]).issubset(s1) is False:
                s1.add(s[j])
            # print('len', len(s1))
    n1.append(len(s1))
print(max(n1))


Fixed submission:
a, b = map(int, input().split())
lis = [a+b, a-b, a*b]
print(max(lis))

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
n1 = []
for i in range(n):
    s1 = set()
    for j in range(i):
        for k in range(i+1, n):
            # print(i, j, k, s[j], s[k])
            if s[j] == s[k] and set(s[j]).issubset(s1) is False:
                s1.add(s[j])
            # print('len', len(s1))
    n1.append(len(s1))
print(max(n1))


Fixed submission:
a, b = map(int, input().split())
lis = [a+b, a-b, a*b]
print(max(lis))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
num = [0 for i in range(n)]
for i in range(n):
    for j in range(0, i):
        if s[j] == "W":
            num[i] += 1
    for j in range(i+1, n):
        if s[j] == "E":
            num[i] += 1
    # print(num[i])
print(min(num))


Fixed submission:
n = int(input())
s = input()
num = [0 for i in range(n)]
w = [0 for i in range(n)]
if s[0] == 'W':
    w[0] = 1
for i in range(1, n):
    if s[i] == 'W':
        w[i] = (w[i-1] + 1)
    else:
        w[i] = w[i-1]
e = [0 for i in range(n)]
if s[n-1] == 'E':
    e[n-1] = 1
for i in range(2, n+1):
    if s[n-i] == 'E':
        e[n-i] = (e[n-i+1] + 1)
    else:
        e[n-i] = e[n-i+1]
sol = [0 for i in range(n)]
sol[0] = e[0]
sol[n-1] = w[n-2]
for i in range(1, n-1):
    sol[i] = w[i-1] + e[i+1]
print(min(sol))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
sbst = set()
for i in range(1, len(s)+1):
    for j in range(len(s)-i+1):
        sbst.add(s[j:j+i])
sbstl = sorted(list(sbst))
print(sbstl[k-1])


Fixed submission:
# 5000**2、5000**3
# 5文字以下だよ。辛いよ。
s = input()
k = int(input())
sbst = set()
for i in range(1, k+1):
    for j in range(len(s)-i+1):
        sbst.add(s[j:j+i])
sbstl = sorted(list(sbst))
print(sbstl[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
x_tmp = input().split()
x = []
for _ in x_tmp:
    x.append(int(_))
num = n//2
for i in range(n):
    tmp_x = copy.copy(x)  # listを普通に代入すると、ディープコピーになる
    tmp_x.pop(i)  # pop(index)の出力は、削除した要素の値
    # その上で、popするとリスト自体も改変される
    # print(tmp_x)
    tmp_x = sorted(tmp_x, reverse=True)
    # print(tmp_x)
    print(tmp_x[num-1])


Fixed submission:
n = int(input())
x_tmp = input().split()
x = [[0 for j in range(3)] for i in range(n)]
for i in range(n):
    x[i][0] = int(x_tmp[i])
    x[i][1] = i
x = sorted(x, key=lambda y: y[0])
mid = n//2
for i in range(n):
    if i <= mid-1:
        x[i][2] = x[mid][0]
    else:
        x[i][2] = x[mid-1][0]
x = sorted(x, key=lambda y: y[1])
for i in range(n):
    print(x[i][2])
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
x = []
for i in range(a, b+1):
    x.append(i)
lx = len(x)
if k < lx/2:
    for i in range(k):
        print(x[i])
    for i in range(lx-k, lx):
        print(x[i])
else:
    for i in x:
        print(i)


Fixed submission:
a, b, k = map(int, input().split())
x = []
lx = b-a+1
if k <= lx//2:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)
else:
    for i in range(a, b+1):
        print(i)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import itertools

N, D = [int(i) for i in input().split()]
X = []
for i in range(N):
    X.append(np.array([int(i) for i in input().split()]))

d = []
for c in itertools.combinations(X, 2):
    d.append(np.linalg.norm(c[1] - c[0]))

d = np.array(d)
print(len([True for x in d if x.is_integer()]))

Fixed submission:
import numpy as np
import itertools
 
N, D = [int(i) for i in input().split()]
X = []
for i in range(N):
    X.append(np.array([int(i) for i in input().split()]))

d = []
for c in itertools.combinations(X, 2):
    d.append(np.linalg.norm(c[1] - c[0]))

print(len([True for x in d if x.is_integer()]))
Buggy python submission (verdict: Time Limit Exceeded):
def solve(n, q, s):
    accm = [0]*n
    for i in range(n-1):
        if s[i:i+2] == 'AC':
            accm[i] = 1
    for j in range(q):
        l, r = map(int, input().split())
        ans = sum(accm[l-1:r])
        print(ans if accm[r-1] != 1 else ans-1)


if __name__ == '__main__':
    n, q = map(int, input().split())
    s = input()
    solve(n, q, s)


Fixed submission:
from itertools import accumulate


def solve(n, q, s):
    m = [0]*n
    for i in range(1, n):
        if s[i-1:i+1] == 'AC':
            m[i] = 1

    accm = list(accumulate(m))

    for j in range(q):
        l, r = map(int, input().split())
        print(accm[r-1]-accm[l-1])


if __name__ == '__main__':
    n, q = map(int, input().split())
    s = input()
    solve(n, q, s)
Buggy python submission (verdict: Runtime Error):
from sys import stdin


def dp_solve(k, h, dp):
    if 0 <= dp[k]:
        return dp[k]
    if k == 1:
        dp[1] = abs(h[1]-h[0])
        return dp[1]
    if k == 2:
        dp[2] = min(abs((h[2]-h[1])+abs(h[1]-h[0])), abs(h[2]-h[0]))
        return dp[2]

    dp[k] = min(abs(dp_solve(k-1, h, dp)) + abs(h[k-1]-h[k]),
                abs(dp_solve(k-2, h, dp))+abs(h[k-2]-h[k]))
    return dp[k]


if __name__ == "__main__":
    n = int(input())
    h = list(map(int, stdin.readline().split()))
    dp = [-1]*n

    print(dp_solve(n-1, h, dp))


Fixed submission:
from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10**8)


def dp_solve(k, h, dp):
    if dp[k] < inf:
        return dp[k]
    if k == 1:
        dp[1] = abs(h[1]-h[0])
        return dp[1]
    if k == 2:
        dp[2] = min(abs(h[2]-h[1])+abs(h[1]-h[0]), abs(h[2]-h[0]))
        return dp[2]

    dp[k] = min(dp_solve(k-1, h, dp) + abs(h[k]-h[k-1]),
                dp_solve(k-2, h, dp)+abs(h[k]-h[k-2]))
    return dp[k]


if __name__ == "__main__":
    n = int(input())
    h = list(map(int, stdin.readline().split()))
    inf = float('inf')
    dp = [inf]*n

    print(dp_solve(n-1, h, dp))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin


def dp_solve(i, h, dp, K):
    for i in range(1, n):
        if i <= K:
            dp1 = min(dp)
            dp[i] = [min(dp1[0]+abs(h[i] - h[dp1[1]]), abs(h[i]-h[0])), i]
        else:
            for d in dp[i-K:i]:
                dp[i] = min(dp[i], [d[0]+abs(h[i] - h[d[1]]), i])
    return dp[n-1][0]


if __name__ == "__main__":
    n, K = map(int, input().split())
    h = list(map(int, stdin.readline().split()))
    inf = float('inf')
    dp = []
    for i in range(n):
        dp.append([inf, i])

    print(dp_solve(n-1, h, dp, K))


Fixed submission:
from sys import stdin


def dp_solve(i, h, dp, K):
    for i in range(1, n):
        if i <= K:
            dp[i] = abs(h[i]-h[0])
        else:
            dp[i] = min([d + abs(h[i]-hk) for d, hk in zip(dp[i-K:i], h[i-K:i])])
    return dp[n-1]


if __name__ == "__main__":
    n, K = map(int, input().split())
    h = list(map(int, stdin.readline().split()))
    inf = float('inf')
    dp = [inf]*n

    print(dp_solve(n-1, h, dp, K))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import setrecursionlimit

setrecursionlimit(10**8)


def dp_solve(i, k, dp):
    if k == 0:
        if i == 0:
            return max(bx[i], cx[i])
        dp[i] = max(dp_solve(i-1, 1, dp)+ax[i], dp_solve(i-1, 2, dp)+ax[i])
    if k == 1:
        if i == 0:
            return max(ax[i], cx[i])
        dp[i] = max(dp_solve(i-1, 0, dp)+bx[i], dp_solve(i-1, 2, dp)+bx[i])
    if k == 2:
        if i == 0:
            return max(ax[i], bx[i])
        dp[i] = max(dp_solve(i-1, 0, dp)+cx[i], dp_solve(i-1, 1, dp)+cx[i])
    return dp[i]


if __name__ == "__main__":
    n = int(input())
    ax = []
    bx = []
    cx = []
    for i in range(n):
        a, b, c = map(int, input().split())
        ax.append(a)
        bx.append(b)
        cx.append(c)

    dp = [0]*n
    dp1 = dp_solve(n-1, 0, dp)
    dp = [0]*n
    dp2 = dp_solve(n-1, 1, dp)
    dp = [0]*n
    dp3 = dp_solve(n-1, 2, dp)
    print(max(dp1, dp2, dp3))


Fixed submission:

def dp_solve(dp0, dp1, dp2, n):
    for i in range(1, n):
        dp0[i] = max(dp1[i-1], dp2[i-1])+ax[i]
        dp1[i] = max(dp0[i-1], dp2[i-1])+bx[i]
        dp2[i] = max(dp0[i-1], dp1[i-1])+cx[i]
    return max(dp0[-1], dp1[-1], dp2[-1])


if __name__ == "__main__":
    n = int(input())
    ax = []
    bx = []
    cx = []
    for i in range(n):
        a, b, c = map(int, input().split())
        ax.append(a)
        bx.append(b)
        cx.append(c)

    dp0 = [ax[0]]+[0]*(n-1)
    dp1 = [bx[0]]+[0]*(n-1)
    dp2 = [cx[0]]+[0]*(n-1)
    print(dp_solve(dp0, dp1, dp2, n))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import numpy as np


def dp_solve(dp, lim, n):
    for i in range(n):
        w, v = map(int, input().split())
        for j in range(lim+1):
            if w <= j:
                dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v)
            else:
                dp[i+1][j] = dp[i][j]

    return dp[n][lim]


if __name__ == "__main__":
    n, lim = map(int, stdin.readline().split())
    items = []

    dp = np.zeros((n+1, lim+1), dtype='uint64')
    print(dp_solve(dp, lim, n))


Fixed submission:
from sys import stdin
import numpy as np


def dp_solve(dp, lim, n):
    for i in range(n):
        w, v = map(int, input().split())
        dp[i+1][:w] = dp[i][:w]
        dp[i+1][w:] = np.maximum(dp[i][w:], dp[i][:-w]+v)
    return np.max(dp[n])


if __name__ == "__main__":
    n, lim = map(int, stdin.readline().split())
    items = []

    dp = np.zeros((n+1, lim+1), dtype='uint64')
    print(dp_solve(dp, lim, n))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin


def dp_solve(n):
    dp = [[0.0]*(n+1) for _ in range(n+1)]
    dp[0][0] = 1.0
    pi = list(map(float, stdin.readline().split()))

    for i in range(n):
        for j in range(i+1):
            dp[i+1][j+1] += dp[i][j] * pi[i]
            dp[i+1][j] +=dp[i][j]*(1.0-pi[i])

    return dp[-1]


if __name__ == "__main__":
    n = int(input())
    res = dp_solve(n)
    m = int(n/2+1)
    print(sum(res[m:]))


Fixed submission:
import numpy as np
from sys import stdin


def dp_solve(n):
    dp = np.zeros(n+1)
    dp[0] = 1
    pi = list(map(float, stdin.readline().split()))

    for i, p in enumerate(pi):
        dp[1:] = dp[1:]*(1-pi[i]) + dp[:n]*pi[i]
        dp[0] = dp[0]*(1-pi[i])
    return dp


if __name__ == "__main__":
    n = int(input())
    res = dp_solve(n)
    print(sum(res[n//2+1:]))
Buggy python submission (verdict: Runtime Error):
import numpy as np


def solve(N, M):
    _p, _y = 0, 0
    py = []
    ans = np.zeros(M,dtype=object)
    rank = [1]*(M+1)

    for i in range(M):
        _p, _y = map(int, input().split())
        py.append((_y, _p, i))
    py.sort()

    for pyi in py:
        pi = pyi[1]
        ans[pyi[2]] = str(pi).zfill(6) + str(rank[pi]).zfill(6)
        rank[pi] += 1

    return ans


if __name__ == "__main__":
    N, M = map(int, input().split())
    ans = solve(N, M)
    for a in ans:
        print(a)


Fixed submission:
import numpy as np


def solve(N, M, py):
    ans = np.zeros(M, dtype=object)
    rank = [1]*(N+1)

    py.sort()

    for pyi in py:
        pi = pyi[1]
        ans[pyi[2]] = str(pi).zfill(6) + str(rank[pi]).zfill(6)
        rank[pi] += 1

    return ans


if __name__ == "__main__":
    _p, _y = 0, 0
    py = []

    N, M = map(int, input().split())
    for i in range(M):
        _p, _y = map(int, input().split())
        py.append((_y, _p, i))

    ans = solve(N, M, py)
    for a in ans:
        print(a)