Buggy python submission (verdict: Runtime Error):
N, M, k = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if i < N: 
    if A[i] < B[j] and k-A[i] >= 0: 
      ct +=1
      k -= A[i]
      i += 1
      continue
  if j < M: 
    if k-B[j] >= 0: 
      ct +=1
      k -= B[j]
      j +=1
    else: 
      break
  else: 
    break
print(ct)

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 = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if i < N: 
    if A[i] < B[j] and k-A[i] >= 0: 
      ct +=1
      k -= A[i]
      i += 1
      continue
  if j < M: 
    if k-B[j] >= 0: 
      ct +=1
      k -= B[j]
      j +=1
    else: 
      break
  else: 
    break
print(ct)

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):
Source Code 

Copy
Copy
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if i < N: 
    if A[i] < B[j] and k-A[i] >= 0: 
      ct +=1
      k -= A[i]
      i += 1
      continue
  if j < M: 
    if k-B[j] >= 0: 
      ct +=1
      k -= B[j]
      j +=1
    else: 
      break
  else: 
    break
print(ct)
print(ct)

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 = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k> 0: 
  if A[i] < B[j] and k-A[i] > 0: 
    k -= A[i]
    i +=1
    ct +=1
  elif k-B[j] > 0: 
    k -= B[j]
    j +=1
  	ct += 1
print(ct)

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 = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if A[i] < B[j] and k - A[i] > 0: 
    k -= A[i]
    i +=1
  elif k - B[j] > 0: 
    k -= B[j]
    j +=1
  ct += 1
print(ct)

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 = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if A[i] < B[j]: 
    k -= A[i]
    i +=1
  else: 
    k -= B[j]
    j +=1
  ct += 1
print(ct)
    

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)