Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())

counts = [0] * (N+1)
counts[0] = 1
for i in range(1, N+1):
    counts[i] = 2 * counts[i-1] + 3

def req(n, x):
    if n == 0 and x == 1:
        return 1

    if x == 1:
        return 0
    elif x > 1 and x <= counts[n-1] + 1:
        return req(n - 1, x - 1)
    elif x == counts[n-1] + 2:
        return req(n - 1, counts[n-1]) + 1
    elif x > counts[n-1] + 2:
        if x == 2*counts[n-1] + 3:
            return req(n-1, counts[n-1])*2+1
        else:
            return req(n-1, x - (counts[n-1] + 2) - 1) + req(n - 1, counts[n-1])


print(req(N, X))


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

counts = [0] * (N+1)
counts[0] = 1
for i in range(1, N+1):
    counts[i] = 2 * counts[i-1] + 3


def req(n, x):
    if n == 0:
        return 1

    if x == 1:
        return 0
    elif x > 1 and x <= counts[n-1] + 1:
        return req(n - 1, x - 1)
    elif x == counts[n-1] + 2:
        return req(n - 1, counts[n-1]) + 1
    else:
        if x == 2*counts[n-1] + 3:
            return req(n-1, counts[n-1]) * 2 + 1
        else:
            return req(n-1, x - (counts[n-1] + 2)) + req(n - 1, counts[n-1]) + 1


print(req(N, X))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

def solve():
    res = 1
    for i in range(1, m//n+1):
        if m % i == 0:
            if (m // i) >= n:
                res = max(res, i)
    print(res)

solve()


Fixed submission:
n, m = map(int, input().split())

def solve():
    res = 1
    for i in range(m//n+1, 0, -1):
        if m % i == 0:
            if (m // i) >= n:
                res = i
                break
    print(res)

solve()
Buggy python submission (verdict: Runtime Error):
n, m, d = map(int, input().split())
print(((n-d)*(m-1)/n)/(n-1))


Fixed submission:
n, m, d = map(int, input().split())
if d == 0:
    print((m-1)/n)
else:
    print((2*(n-d)/ n**2)*(m-1))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
minIndex = [i for i, x in enumerate(A) if x == min(A)]
print((minIndex[0]+1)//K+(len(A)-max(minIndex[0], 1))//K+1)


Fixed submission:
import math
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
minIndex = A.index(min(A))
if K == len(A):
    print(1)
else:
    print(math.ceil((N-1)/(K-1)))
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B, K = map(int, input().split())
mod = 998244353
f_table = [1, 1]
inverse_table = {}


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return f_table[n] * inverse(r) * inverse(n-r) % mod

  
def inverse(x):
    if x in inverse_table:
        return inverse_table[x]
    res = pow(f_table[x], mod-2, mod)
    inverse_table[x] = res
    return res


for i in range(2, N + 1):
    f_table.append((f_table[-1] * i) % mod)

res = 0
for a in range(0, N+1):
    b = (K - A*a) // B
    if (K - A * a) % B == 0 and 0 <= b <= N:
        res += cmb(N, a) * cmb(N, b) % mod
print(res % mod)


Fixed submission:
import math

N, A, B, K = map(int, input().split())
mod = 998244353
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

res = 0
for a in range(0, N+1):
    b = (K - A*a) // B
    if (K - A * a) % B == 0 and 0 <= b <= N:
        res += cmb(N, a) * cmb(N, b) % mod
print(res % mod)

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

n, A, B, k = map(int, input().split())

def combination(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

res = 0
for a in range(0, n+1):
    if (k - A * a) % B == 0:
        b = (k - A*a) // B
        res += combination(n, a) * combination(n, b) % 998244353
print(res)


Fixed submission:
import math

N, A, B, K = map(int, input().split())
mod = 998244353
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

res = 0
for a in range(0, N+1):
    b = (K - A*a) // B
    if (K - A * a) % B == 0 and 0 <= b <= N:
        res += cmb(N, a) * cmb(N, b) % mod
print(res % mod)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [int(input()) for _ in range(n)]
q = [0] * (n+1)

for i in range(n):
    q[p[i]] = i
maxl = 1
cnt = 1
last = p[0]
for i in range(1, n):
    if q[i+1] > q[i]:
        cnt += 1
    else:
        maxl = max(maxl, cnt)
        cnt = 1

print(n - maxl)


Fixed submission:
a, b, c, k = map(int, input().split())
res = b - a
if k % 2 ==0:
    res = a - b

if res > 10 ** 18:
    print('Unfair')
else:
    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
substrings = set()
for i in range(len(s)):
    for j in range(len(s), 0, -1):
        if j - i <= 0:
            continue
        substrings.add(s[i:j])
s_list = list(substrings)
s_list.sort()
print(s_list[k-1])


Fixed submission:
s = input()
k = int(input())
substrings = set()
s_list = []
for i in range(len(s)):
    for j in range(i+1, i+6):
        substrings.add(s[i:j])
s_list = list(substrings)
s_list.sort()
print(s_list[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
substrings = set()
for i in range(len(s)):
    for j in range(len(s), 0, -1):
        if j - i <= 0:
            continue
        substrings.add(s[i:j])
s_list = list(substrings)
s_list.sort()
print(s_list[k-1])


Fixed submission:
s = input()
k = int(input())
substrings = set()
s_list = []
for i in range(len(s)):
    for j in range(i+1, i+6):
        substrings.add(s[i:j])
s_list = list(substrings)
s_list.sort()
print(s_list[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, c = map(int, input().split())
xv = [[int(x) for x in input().split()] for _ in range(n)]
n += 1
oa = [0] * n
ob = [0] * n
xv.insert(0, [0, 0])
maxcal = 0
for i in range(1,n):
    oa[i] = oa[i-1] + xv[i][1]
ob[n-1] = xv[i][1]
for i in reversed(range(0,n-1)):
    ob[i] = xv[i][1] + ob[i+1]
for i in range(n):
    for j in range(n):
        cal = oa[i]
        d = 0
        if i != j:
            cal += ob[j]
            d = xv[i][0] * 2 + (c - xv[j][0])
            d2 = xv[i][0] + (c - xv[j][0]) * 2
            d = min(d, d2)
        else:
            d = xv[i][0]
        if d < c:
            maxcal = max(maxcal, cal - d)
print(maxcal)


Fixed submission:
n, c = map(int, input().split())
xv = [[int(x) for x in input().split()] for _ in range(n)]
xv.insert(0, [0, 0])
n += 1
oa = [0] * (n + 1)
ob = [0] * (n + 1)
maxr = [0] * (n + 1)
maxl = [0] * (n + 1)
for i in range(1, n):
    oa[i] = oa[i - 1] + xv[i][1]
    maxr[i] = max(maxr[i - 1], oa[i] - xv[i][0])
ob[n - 1] = xv[i][1]
for i in range(n - 1, -1, -1):
    ob[i] = xv[i][1] + ob[i + 1]
    maxl[i] = max(maxl[i + 1], ob[i] - (c - xv[i][0]))
cal1 = max(maxr[n-1], maxl[0])
cal2 = 0
cal3 = 0
for i in range(n):
    cal2 = max(cal2, oa[i] - 2 * xv[i][0] + maxl[i+1])
    cal3 = max(cal3, ob[i] - 2 * (c - xv[i][0]) + maxr[i-1])
print(max(cal1, cal2, cal3))

Buggy python submission (verdict: Time Limit Exceeded):
n, c = map(int, input().split())
xv = [[int(x) for x in input().split()] for _ in range(n)]
n += 1
xv.insert(0, [0, 0])
maxcal = 0

for i in range(n):
    for j in range(n):
        cal = 0
        d = 0
        for k in range(0, i + 1):
            cal += xv[k][1]
        if i != j:
            for k in range(j, n):
                cal += xv[k][1]
            d = xv[i][0] * 2 + (c - xv[j][0])
            d2 = xv[i][0] + (c - xv[j][0]) * 2
            d = min(d, d2)
        else:
            d = xv[i][0]
        if d < c:
            maxcal = max(maxcal, cal - d)
print(maxcal)


Fixed submission:
n, c = map(int, input().split())
xv = [[int(x) for x in input().split()] for _ in range(n)]
xv.insert(0, [0, 0])
n += 1
oa = [0] * (n + 1)
ob = [0] * (n + 1)
maxr = [0] * (n + 1)
maxl = [0] * (n + 1)
for i in range(1, n):
    oa[i] = oa[i - 1] + xv[i][1]
    maxr[i] = max(maxr[i - 1], oa[i] - xv[i][0])
ob[n - 1] = xv[i][1]
for i in range(n - 1, -1, -1):
    ob[i] = xv[i][1] + ob[i + 1]
    maxl[i] = max(maxl[i + 1], ob[i] - (c - xv[i][0]))
cal1 = max(maxr[n-1], maxl[0])
cal2 = 0
cal3 = 0
for i in range(n):
    cal2 = max(cal2, oa[i] - 2 * xv[i][0] + maxl[i+1])
    cal3 = max(cal3, ob[i] - 2 * (c - xv[i][0]) + maxr[i-1])
print(max(cal1, cal2, cal3))
Buggy python submission (verdict: Time Limit Exceeded):
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
a = [int(x) for x in input().split()]

x = max(a)
maxc = 0
maxy = 0
for y in sorted(a):
    if x == y or y < x // 2:
        continue
    c = comb(x, y)
    if maxc < c:
        maxc = c
        maxy = y

print(str(x) + ' ' + str(maxy))


Fixed submission:
import math

n = int(input())
a = [int(x) for x in input().split()]
a.sort()
x = max(a)
a.remove(x)
maxi = 0
mind = x
for i in range(len(a)):
    d = abs((x+1) // 2 - a[i])
    if d < mind:
        maxi = i
        mind = d
print(str(x) + ' ' + str(a[maxi]))

Buggy python submission (verdict: Time Limit Exceeded):
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
a = [int(x) for x in input().split()]

x = max(a)
maxc = 0
maxy = 0
for y in sorted(a):
    if x == y or y < x // 2:
        continue
    c = comb(x, y)
    if maxc < c:
        maxc = c
        maxy = y

print(str(x) + ' ' + str(maxy))


Fixed submission:
import math

n = int(input())
a = [int(x) for x in input().split()]
a.sort()
x = max(a)
a.remove(x)
maxi = 0
mind = x
for i in range(len(a)):
    d = abs((x+1) // 2 - a[i])
    if d < mind:
        maxi = i
        mind = d
print(str(x) + ' ' + str(a[maxi]))

Buggy python submission (verdict: Time Limit Exceeded):
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
a = [int(x) for x in input().split()]

x = max(a)
maxc = 0
maxy = 0
for y in a:
    if x == y:
        continue
    if maxc < comb(x, y):
        maxc = comb(x, y)
        maxy = y

print(str(x) + ' ' + str(maxy))


Fixed submission:
import math

n = int(input())
a = [int(x) for x in input().split()]
a.sort()
x = max(a)
a.remove(x)
maxi = 0
mind = x
for i in range(len(a)):
    d = abs((x+1) // 2 - a[i])
    if d < mind:
        maxi = i
        mind = d
print(str(x) + ' ' + str(a[maxi]))
Buggy python submission (verdict: Runtime Error):
a = []
for _ in range(4):
    a.append(int(input))

print(min(min(a[0],a[1]), min(a[2],a[3])))


Fixed submission:
a = []
for _ in range(4):
    a.append(int(input()))

print(min(a[0],a[1])+ min(a[2],a[3]))
Buggy python submission (verdict: Runtime Error):
n = input()
a = input()

r = n % 500
if r > a:
  print('No')
else:
  print('Yes')

Fixed submission:
n = int(input())
a = int(input())

r = n % 500
if r > a:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
c = [list(map(int, input().split())) for _ in range(3)]
ok = False
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1 = c[0][0] - a1
            b2 = c[0][1] - a1
            b3 = c[0][2] - a1
            a = [a1, a2, a3]
            b = [b1, b2, b3]
            ok_sub = True
            for i in range(3):
                for j in range(3):
                    if a[i] + b[j] != c[i][j]:
                        ok_sub = False
            if ok_sub:
                ok = True

print('Yes') if ok else print('No')

Fixed submission:
c = [list(map(int, input().split())) for _ in range(3)]
ok = False
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1 = c[0][0] - a1
            b2 = c[0][1] - a1
            b3 = c[0][2] - a1

            a = [a1, a2, a3]
            b = [b1, b2, b3]
            ok_sub = True
            for i in range(3):
                for j in range(3):
                    if a[i] + b[j] != c[i][j]:
                        ok_sub = False
            if ok_sub:
                ok = True

print('Yes') if ok else print('No')
Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())
res = [-1, -1, -1]
for a in range(n + 1):
    for b in range(n - a + 1):
        if 10000 * a + 5000 * b + 1000 * (n - a - b) == y:
            res[0] = a
            res[1] = b
            res[2] = n - a - b
print(' '.join(map(str, res)))


Fixed submission:
s = list(input())
s[3] = '8'
s2 = "".join(s)
print(s2)
Buggy python submission (verdict: Runtime Error):
a, b, c, d, e, f = map(int, input().split())
max_concentration = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f - i + 1, 100 * b):
        if i == 0 and j == 0:
            continue
        y = min((i + j) * e // 100, f - i - j)
        for k in range(0, y + 1, c):
            for l in range(0, y - k + 1, d):
                concentration = 100 * (k + l) / (i + j + k + l)
                if max_concentration < concentration:
                    max_concentration = concentration
                    res1 = i + j + k + l
                    res2 = k + l
print(str(res1) + ' ' + str(res2))


Fixed submission:
a, b, c, d, e, f = map(int, input().split())
max_concentration = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f - i + 1, 100 * b):
        if i == 0 and j == 0:
            continue
        y = min((i + j) * e // 100, f - i - j)
        for k in range(0, y + 1, c):
            for l in range(0, y - k + 1, d):
                concentration = 100 * (k + l) / (i + j + k + l)
                if max_concentration <= concentration:
                    max_concentration = concentration
                    res1 = i + j + k + l
                    res2 = k + l
print(str(res1) + ' ' + str(res2))

Buggy python submission (verdict: Runtime Error):
a, b, c, d, e, f = map(int, input().split())
max_concentration = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f - i + 1, 100 * b):
        if i == 0 and j == 0:
            continue
        y = min((i + j) * e // 100, f - i - j)
        for k in range(0, y + 1, c):
            for l in range(0, y - k + 1, d):
                concentration = 100 * (k + l) // (i + j + k + l)
                if max_concentration < concentration:
                    max_concentration = concentration
                    res1 = i + j + k + l
                    res2 = k + l
print(str(res1) + ' ' + str(res2))


Fixed submission:
a, b, c, d, e, f = map(int, input().split())
max_concentration = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f - i + 1, 100 * b):
        if i == 0 and j == 0:
            continue
        y = min((i + j) * e // 100, f - i - j)
        for k in range(0, y + 1, c):
            for l in range(0, y - k + 1, d):
                concentration = 100 * (k + l) / (i + j + k + l)
                if max_concentration <= concentration:
                    max_concentration = concentration
                    res1 = i + j + k + l
                    res2 = k + l
print(str(res1) + ' ' + str(res2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for x in range(100000):
    cnt = 0
    for elem in a:
        if elem == x-1 or elem == x or elem == x + 1:
            cnt += 1
    ans = max(ans, cnt)
print(ans)


Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
counta = [0 for _ in range(100000)]
ans = 0

for elem in a:
    counta[elem] += 1

for x in range(1, 100000 - 1):
    ans = max(ans, counta[x-1] + counta[x] + counta[x+1])

print(ans)
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
str_list = [input() for i in range(l)]

str_list.sort()

print("".join(str_list))



Fixed submission:
n, l = map(int, input().split())
str_list = [input() for i in range(n)]

str_list.sort()

print("".join(str_list))

Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
str_list = [input() for i in range(3)]

str_list.sort()

print("".join(str_list))



Fixed submission:
n, l = map(int, input().split())
str_list = [input() for i in range(n)]

str_list.sort()

print("".join(str_list))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = 1
for x in a:
    ans *= x

if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)


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

if 0 in a:
    print(0)
else:
    ans = 1
    for x in a:
        ans *= x
        if ans > 10 ** 18:
            ans = -1
            break

    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = (map(int, input().split()))
h = list(map(int, input().split()))

dp = [0, abs(h[0] - h[1])]

for i in range(2, n):
    cost = []
    jump_range = min(i, k) + 1
    for n_jump in range(1, jump_range):
        jump_cost = dp[i - n_jump] + abs(h[i] - h[i - n_jump])
        cost.append(jump_cost)
    dp.append(min(cost))
    cost.clear()

print(dp[-1])


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

dp = [0, abs(h[0] - h[1])]

for i in range(2, n):
    cost = []
    jump_range = min(i, k) + 1
    for n_jump in range(1, jump_range):
        jump_cost = dp[i - n_jump] + abs(h[i] - h[i - n_jump])
        cost.append(jump_cost)
    dp.append(min(cost))
    cost.clear()

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                ans += 1
            if x + y + z > s:
                break

print(ans)


Fixed submission:
k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y <= k:
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                ans += 1

print(ans)


Fixed submission:
k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y <= k:
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                ans += 1

print(ans)


Fixed submission:
k, s = map(int, input().split())

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y <= k:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
ANS=[]
for start in range(len(S)-len(T)):
  ans = 0
  for j in range(len(T)):
    if S[start+j] != T[j]:
      ans += 1
  ANS.append(ans)
print(min(ANS))
  

Fixed submission:
S = input()
T = input()
ans = len(T)
for start in range(len(S) - len(T) + 1):
  dif = 0
  for i in range(len(T)):
    if T[i] != S[start + i]:
      dif += 1
  ans = min(ans, dif) 
print(ans)

Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
ANS=[]
for start in range(len(S)-len(T)):
  ans = 0
  for j in range(len(T)):
    if S[start] != T[j]:
      ans += 1
  ANS.append(ans)
print(min(ANS))
  

Fixed submission:
S = input()
T = input()
ans = len(T)
for start in range(len(S) - len(T) + 1):
  dif = 0
  for i in range(len(T)):
    if T[i] != S[start + i]:
      dif += 1
  ans = min(ans, dif) 
print(ans)

Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
ANS=[]
for start in range(len(S)-len(T)):
  ans = 0
  for j in range(len(T)):
    if S[start] != T[j]:
      ans += 1
  ANS.append(ans)
print(min(ANS))
  

Fixed submission:
S = input()
T = input()
ans = len(T)
for start in range(len(S) - len(T) + 1):
  dif = 0
  for i in range(len(T)):
    if T[i] != S[start + i]:
      dif += 1
  ans = min(ans, dif) 
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
count = 0
for i in [0:len(S)]:
  if S[i] != T[i]:
    count += 1
print(count)


Fixed submission:
S = input()
T = input()
count = 0
for i in range(len(S)):
  if S[i] != T[i]:
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
count = 0
for i in [:len(S)]:
  if S[i] != T[i]:
    count += 1
print(count)


Fixed submission:
S = input()
T = input()
count = 0
for i in range(len(S)):
  if S[i] != T[i]:
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
count = 0
for i in [:len(S)]:
  if S[i] == T[i]:
    count += 1
print(count)

Fixed submission:
S = input()
T = input()
count = 0
for i in range(len(S)):
  if S[i] != T[i]:
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(N):
  a.append(a[i] + A[i])
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
  

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

a, b = [0], [0]

for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(N):
  a.append(a[i] + A[i])
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[i] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
  

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

a, b = [0], [0]

for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().splilt())
p = list(map(int, input().splilt()))
print(sum(sorted(p)[:M]))

Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
print(sum(sorted(p)[:K]))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().splilt())
L = list(map(int, input().splilt()))
print(sum(sorted(L)[:M]))

Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
print(sum(sorted(p)[:K]))

Buggy python submission (verdict: Runtime Error):
N, M = int(input().split())
list = str(input().split())
list.sort()
total = 0
for i in [0:M]:
  total += list[i]
print(total)



Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
print(sum(sorted(p)[:K]))