Buggy python submission (verdict: Time Limit Exceeded):
# from collections import deque
import numpy as np
def main():
    n, m, k = map(int, input().split())
    A = np.array([0] + list(map(int, input().split())))
    B = np.array([0] + list(map(int, input().split())))
    X = np.cumsum(A)
    Y = np.cumsum(B)
    P = X[X <= k]
    Q = Y[Y <= k]
    n = len(P)
    m = len(Q)
    # print(P,Q)

    cnt = 0
    # Aをi個、Bをj個選ぶ
    for i in range(n)[::-1]:
        if i + m <= cnt:
            break
        else:
            for j in range(m)[::-1]:
                #print(i,j,X[i],Y[j])
                if X[i] + Y[j] <= k:
                    cnt = max(cnt, i + j)
                    break
    print(cnt)



if __name__ == "__main__":
    main()


Fixed submission:
# from collections import deque
import numpy as np
def main():
    n, m, k = map(int, input().split())
    A = np.array([0] + list(map(int, input().split())))
    B = np.array([0] + list(map(int, input().split())))
    X = np.cumsum(A)
    Y = np.cumsum(B)
    # print(P,Q)

    cnt = 0
    j = m
    # Aをi個、Bをj個選ぶ
    for i, x in enumerate(X):
        if x > k:
            break

        while x + Y[j] > k:
            j -= 1
        cnt = max(cnt, i + j)

    print(cnt)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# from collections import deque
import numpy as np
def main():
    n, m, k = map(int, input().split())
    A = np.array([0] + list(map(int, input().split())))
    B = np.array([0] + list(map(int, input().split())))
    X = np.cumsum(A)
    Y = np.cumsum(B)
    P = X[X <= k]
    Q = Y[Y <= k]
    n = len(P)
    m = len(Q)
    # print(P,Q)

    cnt = 0
    # Aをi個、Bをj個選ぶ
    for i in range(n):
        for j in range(m)[::-1]:
            #print(i,j,X[i],Y[j])
            if X[i] + Y[j] <= k:
                cnt = max(cnt, i + j)
                break
    print(cnt)



if __name__ == "__main__":
    main()


Fixed submission:
# from collections import deque
import numpy as np
def main():
    n, m, k = map(int, input().split())
    A = np.array([0] + list(map(int, input().split())))
    B = np.array([0] + list(map(int, input().split())))
    X = np.cumsum(A)
    Y = np.cumsum(B)
    # print(P,Q)

    cnt = 0
    j = m
    # Aをi個、Bをj個選ぶ
    for i, x in enumerate(X):
        if x > k:
            break

        while x + Y[j] > k:
            j -= 1
        cnt = max(cnt, i + j)

    print(cnt)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# from collections import deque
import numpy as np
from itertools import accumulate
def main():
    n, m, k = map(int, input().split())
    A = np.array([0] + list(map(int, input().split())))
    B = np.array([0] + list(map(int, input().split())))
    X = np.cumsum(A)
    Y = np.cumsum(B)
    P = X[X <= k]
    Q = Y[Y <= k]
    n = len(P)
    m = len(Q)
    # print(P,Q)

    cnt = 0
    # Aをi個、Bをj個選ぶ
    for i in range(n):
        for j in range(m):
            # print(i,j,X[i],Y[j])
            if X[i] + Y[j] <= k:
                cnt = max(cnt, i + j)
    print(cnt)



if __name__ == "__main__":
    main()


Fixed submission:
# from collections import deque
import numpy as np
def main():
    n, m, k = map(int, input().split())
    A = np.array([0] + list(map(int, input().split())))
    B = np.array([0] + list(map(int, input().split())))
    X = np.cumsum(A)
    Y = np.cumsum(B)
    # print(P,Q)

    cnt = 0
    j = m
    # Aをi個、Bをj個選ぶ
    for i, x in enumerate(X):
        if x > k:
            break

        while x + Y[j] > k:
            j -= 1
        cnt = max(cnt, i + j)

    print(cnt)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# from collections import deque
from itertools import accumulate
def main():
    n, m, k = map(int, input().split())
    A = [0] + list(map(int, input().split()))
    B = [0] + list(map(int, input().split()))
    X = list(accumulate(A))
    Y = list(accumulate(B))

    cnt = 0
    # Aをi個、Bをj個選ぶ
    for i in range(n + 1):
        for j in range(m + 1):
            #print(i,j,X[i],Y[j])
            if X[i] + Y[j] <= k:
                cnt = max(cnt, i + j)
    print(cnt)



if __name__ == "__main__":
    main()


Fixed submission:
# from collections import deque
import numpy as np
def main():
    n, m, k = map(int, input().split())
    A = np.array([0] + list(map(int, input().split())))
    B = np.array([0] + list(map(int, input().split())))
    X = np.cumsum(A)
    Y = np.cumsum(B)
    # print(P,Q)

    cnt = 0
    j = m
    # Aをi個、Bをj個選ぶ
    for i, x in enumerate(X):
        if x > k:
            break

        while x + Y[j] > k:
            j -= 1
        cnt = max(cnt, i + j)

    print(cnt)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
# from collections import deque
def main():
    n, m, k = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cnt_A = 0
    cnt_B = 0
    time = 0
    cnt = 0

    while time <= k:
        # Aの本がまだ無くなっていない時
        if cnt_A < n:
            # Aの本の方が読みやすい
            if A[cnt_A] < B[cnt_B]:
                time += A[cnt_A]
                cnt_A += 1
                cnt += 1

            # Bの本の方が読みやすい
            else:
                time += B[cnt_B]
                cnt_B += 1
                cnt += 1

        # Aの本がなくなっている時
        else:
            if cnt_B < m:
                time += B[cnt_B]
                cnt_B += 1
                cnt += 1
            else:
                break

        #print(cnt,time)


    if time > k:
        print(cnt - 1)
    else:
        print(cnt)




if __name__ == "__main__":
    main()


Fixed submission:
# from collections import deque
import numpy as np
def main():
    n, m, k = map(int, input().split())
    A = np.array([0] + list(map(int, input().split())))
    B = np.array([0] + list(map(int, input().split())))
    X = np.cumsum(A)
    Y = np.cumsum(B)
    # print(P,Q)

    cnt = 0
    j = m
    # Aをi個、Bをj個選ぶ
    for i, x in enumerate(X):
        if x > k:
            break

        while x + Y[j] > k:
            j -= 1
        cnt = max(cnt, i + j)

    print(cnt)

if __name__ == "__main__":
    main()