Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import numpy as np 
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# -------------------
n, m, k = map(int, readline().split())
#print(n)
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))
a = [0] + a
b = [0] + b
acc = list(itertools.accumulate(a))
bcc = list(itertools.accumulate(b))

#acc = np.array(acc)
#print(acc)
#bcc = np.array(bcc)

ans = 0

for i, val in enumerate(acc):
  if (val > k):
    break
  else:
    rest = k - val
    #print(rest)
    for j, val2 in enumerate(bcc):
      if (val2 <= rest):
        ans = max(ans, j + i)
      else:
        break

print(ans)
  


Fixed submission:
import itertools
import numpy as np 
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# -------------------
n, m, k = map(int, readline().split())
#print(n)
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))
a = [0] + a
b = [0] + b
acc = list(itertools.accumulate(a))
bcc = list(itertools.accumulate(b))

#acc = np.array(acc)
#print(acc)
#bcc = np.array(bcc)

ans = 0
j = m
for i, val in enumerate(acc):
  if (val > k):
    break
  else:
    rest = k - val
    #print(rest)
    #j = m
    #一ループ目がJの最大になるので、外側に置いてOK
    while (bcc[j] > rest):
      j -= 1

    ans = max(ans, j + i)


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import numpy as np 
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = [0] + a
b = [0] + b
acc = list(itertools.accumulate(a))
bcc = list(itertools.accumulate(b))

acc = np.array(acc)
#print(acc)
bcc = np.array(bcc)

ans = 0

for i, val in enumerate(acc):
  if (val > k):
    break
  else:
    rest = k - val
    #print(rest)
    for j, val2 in enumerate(bcc):
      if (val2 <= rest):
        ans = max(ans, j + i)
      else:
        break

print(ans)
  


Fixed submission:
import itertools
import numpy as np 
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# -------------------
n, m, k = map(int, readline().split())
#print(n)
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))
a = [0] + a
b = [0] + b
acc = list(itertools.accumulate(a))
bcc = list(itertools.accumulate(b))

#acc = np.array(acc)
#print(acc)
#bcc = np.array(bcc)

ans = 0
j = m
for i, val in enumerate(acc):
  if (val > k):
    break
  else:
    rest = k - val
    #print(rest)
    #j = m
    #一ループ目がJの最大になるので、外側に置いてOK
    while (bcc[j] > rest):
      j -= 1

    ans = max(ans, j + i)


print(ans)

Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np 
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
acc = list(itertools.accumulate(a))
bcc = list(itertools.accumulate(b))

acc = np.array(acc)
#print(acc)
bcc = np.array(bcc)

checkA = np.where(acc <= k)
chA = checkA[0]
checkB = np.where(bcc <= k)
chB = checkB[0]

if (len(chA) > len(chB)):
  a1 = chA
  b1 = chB
else:
  a1 = chB
  b1 = chA

if (len(a1) == 0):
  print(0)
  exit()

ans = 0

for i in range(len(a1) -1, -1, -1):
  #print(i, acc[a1[i]])
  rest = k - acc[a1[i]]
  tar = np.where(bcc <= rest)
  if (len(tar[0]) == 0):
    num = 0
  else:
    num = tar[0][-1]

  #print('num', num)
  ans = max(num + i + 2, ans)
    

print(ans)

Fixed submission:
import itertools
import numpy as np 
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# -------------------
n, m, k = map(int, readline().split())
#print(n)
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))
a = [0] + a
b = [0] + b
acc = list(itertools.accumulate(a))
bcc = list(itertools.accumulate(b))

#acc = np.array(acc)
#print(acc)
#bcc = np.array(bcc)

ans = 0
j = m
for i, val in enumerate(acc):
  if (val > k):
    break
  else:
    rest = k - val
    #print(rest)
    #j = m
    #一ループ目がJの最大になるので、外側に置いてOK
    while (bcc[j] > rest):
      j -= 1

    ans = max(ans, j + i)


print(ans)