Buggy python submission (verdict: Runtime Error):
a,n,m = input(), input(), input()
first = a.split(" ")
N = n.split(" ")
M = m.split(" ")
overflow = 0
for i in N:
    if int(i) >= 10**9:
        overflow = 1
        break
        
for i in M:
    if int(i) >= 10**9:
        overflow = 1
        break
if int(first[0]) >= 200000 or int(first[1]) >= 200000:
    overflow = 1
if int(first[2]) >= 10**9:
    overflow = 1
         
if overflow == 0:
    totaltime = 0
    count = 0
    for i in range(int(first[1]) + int(first[0])):
      if int(N[0]) < int(M[0]):
        totaltime += int(N[0])
        N.remove(N[0])
        count += 1
      elif int(M[0]) < int(N[0]):
        totaltime += int(M[0])
        M.remove(M[0])
        count += 1
      if totaltime + min(int(N[0]),int(M[0])) > int(first[2]):
          break
    print(count)
else:
    print(0)

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):
a = input()
n = input()
m = input()
first = a.split(" ")
N = n.split(" ")
M = m.split(" ")
overflow = 0
for i in N:
    if int(i) >= 10**9:
        overflow = 1
        break
        
for i in M:
    if int(i) >= 10**9:
        overflow = 1
        break
if int(first[0]) >= 200000 or int(first[1]) >= 200000:
    overflow = 1
if int(first[2]) >= 10**9:
    overflow = 1
         
if overflow == 0:
    totaltime = 0
    count = 0
    for i in range(int(first[1]) + int(first[0])):
      if int(N[0]) < int(M[0]):
        totaltime += int(N[0])
        N.remove(N[0])
        count += 1
      elif int(M[0]) < int(N[0]):
        totaltime += int(M[0])
        M.remove(M[0])
        count += 1
      if totaltime + min(int(N[0]),int(M[0])) > int(first[2]):
          break
    print(count)
else:
    print(0)

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):
a = input()
n = input()
m = input()
first = a.split(" ")
N = n.split(" ")
M = m.split(" ")
overflow = 0
for i in N:
    if int(i) >= 10**9:
        overflow = 1
        break
        
for i in M:
    if int(i) >= 10**9:
        overflow = 1
        break
if first[0] >= 200000 or first[1] >= 200000:
    overflow = 1
if first[2] >= 10**9:
    overflow = 1
         
if overflow == 0:
    totaltime = 0
    count = 1
    for i in range(int(first[1]) + int(first[0])):
      if i == 6:
        break
      if  len(N) != 0 and len(M) != 0:
        if totaltime + int(N[0]) > int(first[2]) or totaltime + int(M[0]) > int(first[2]):
          break
      if len(N) == 0:
        totaltime += int(M[0])
        M.remove(M[0])
        count += 1
        if totaltime > int(first[2]):
          break
      elif len(M) == 0:
        totaltime += int(N[0])
        N.remove(N[0])
        count += 1
        if totaltime > int(first[2]):
          break
      elif int(N[0]) < int(M[0]):
        totaltime += int(N[0])
        N.remove(N[0])
        count += 1
      elif int(M[0]) < int(N[0]):
        totaltime += int(M[0])
        M.remove(M[0])
        count += 1
    print(count)
else:
    print(0)

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):
a = input()
n = input()
m = input()
first = a.split(" ")
N = n.split(" ")
M = m.split(" ")

overflow = 0
for i in N:
    if int(i) > 10**9:
        overflow = 1
        break
        
for i in M:
    if int(i) > 10**9:
        overflow = 1
        break


if overflow == 0:
    totaltime = 0
    count = 1
    for i in range(int(first[1]) + int(first[0])):
      if totaltime + int(N[0]) > int(first[2]) or totaltime + int(M[0]) > int(first[2]):
        break
      if int(N[0]) < int(M[0]):
        totaltime += int(N[0])
        N.remove(N[0])
        count += 1
      elif int(M[0]) < int(N[0]):
        totaltime += int(M[0])
        M.remove(M[0])
        count += 1
    print(count)
else:
    print(0)

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):
a = input()
n = input()
m = input()
first = a.split(" ")
N = n.split(" ")
M = m.split(" ")

totaltime = 0
count = 1
for i in range(int(first[1]) + int(first[0])):
  if totaltime + int(N[0]) > int(first[2]) or totaltime + int(M[0]) > int(first[2]):
    break
  if int(N[0]) < int(M[0]):
    totaltime += int(N[0])
    N.remove(N[0])
    count += 1
  elif int(M[0]) < int(N[0]):
    totaltime += int(M[0])
    M.remove(M[0])
    count += 1
print(count)

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)