Buggy python submission (verdict: Time Limit Exceeded):
from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
b_tail = B[-1]
for i, a in enumerate(A):
    if a > k:
        break
    j = m
    if b_tail + a > k:
        for j, b in enumerate(B):
            if a + b > k:
                j -= 1
                break
    n_read = max(n_read, i + j)
print(n_read)


Fixed submission:
from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)

Buggy python submission (verdict: Runtime Error):
@profile
def main():
    from numpy import cumsum
    n, m, k = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    A = cumsum([0] + A)
    B = cumsum([0] + B)
    n_read = 0
    b_tail = B[-1]
    for i, a in enumerate(A):
        if a > k:
            break
        j = m
        if b_tail + a > k:
            for j, b in enumerate(B):
                if a + b > k:
                    break
        n_read = max(n_read, i + j)
    print(n_read)
main()


Fixed submission:
from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, m, k = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]

A = np.cumsum([0] + A)
B = np.cumsum([0] + B)
n_read = 0
for i, a in enumerate(A):
    if a > k:
        break
    if B[-1] + a > k:
        for j, b in enumerate(B[::-1]):
            if a + b <= k:
                n_read = max(n_read,  i + len(B) - j - 1)
                break
    else:
        n_read = max(n_read, i + len(B) - 1)
print(n_read)


Fixed submission:
from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, m, k = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]

A = [a for a in np.cumsum([0] + A) if a <= k]
B = [b for b in np.cumsum([0] + B) if b <= k]
n_read = 0
for i, a in enumerate(A):
    if B[-1] + a > k:
        for j, b in enumerate(B[::-1]):
            if a + b <= k:
                n_read = max(n_read,  i + len(B) - j - 1)
                break
    else:
        n_read = max(n_read, i + len(B) - 1)
print(n_read)


Fixed submission:
from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, m, k = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]

A = [a for a in np.cumsum([0] + A) if a <= k]
B = [b for b in np.cumsum([0] + B) if b <= k]
n_read = max([i + j for i, a in enumerate(A) for j, b in enumerate(B) if a + b <= k])
print(n_read)

Fixed submission:
from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, m, k = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]

A = np.cumsum([0] + A)
B = np.cumsum([0] + B)
n_read = 0
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B):
        if a + b > k:
            break
        if n_read < i + j:
            n_read = i + j
print(n_read)

Fixed submission:
from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, m, k = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]

A = np.cumsum([0] + A)
B = np.cumsum([0] + B)
n_read = 0
for i, a in enumerate(A):
    for j, b in enumerate(B):
        if a + b <= k and n_read < i + j:
            n_read = i + j
print(n_read)

Fixed submission:
from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)

Buggy python submission (verdict: Runtime Error):
from collections import deque
n, m, k = [int(n) for n in input().split()]
A = deque([int(n) for n in input().split()])
B = deque([int(n) for n in input().split()])
dp = [0] * k

t, n = 0, 0
while True:
    a = A[0] if A else None
    b = B[0] if B else None
    if a and a < b:
        d = A.popleft()
    elif b:
        d = B.popleft()
    t += d
    if t > k:
        break
    n += 1
print(n)


Fixed submission:
from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)

Buggy python submission (verdict: Runtime Error):
from collections import deque
n, m, k = [int(n) for n in input().split()]
A = deque([int(n) for n in input().split()])
B = deque([int(n) for n in input().split()])
dp = [0] * k

t, n = 0, 0
while True:
    a = A[0] if A else None
    b = B[0] if B else None
    if a and a < b:
        d = A.popleft()
    elif b:
        d = B.popleft()
    t += d
    if t > k:
        break
    n += 1
print(n)

Fixed submission:
from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)