Buggy python submission (verdict: Runtime Error):
def get(a: list, b: list, pointer1: int, pointer2: int, k: int):
    # print(pointer1, len(a), pointer2, len(b))
    if pointer1 >= len(a) or pointer2 >= len(b) or a[pointer1] + b[pointer2] > k:
           return 0
    return max(pointer1 + pointer2, get(a, b, pointer1 + 1, pointer2, k), get(a, b, pointer1, pointer2 + 1, k))

def main():
    line1 = input()
    line2 = input()
    line3 = input()
    n, m, k = list(map(int, line1.split()))
    a = [0] + list(map(int, line2.split()))
    b = [0] + list(map(int, line3.split()))
    mark1, mark2 = 0, 0
    for i in range(1, len(a)):
        a[i] += a[i-1]
        if a[i] > k:
            mark1 = i
            break
    for i in range(1, len(b)):
        b[i] += b[i-1]
        if b[i] > k:
            mark2 = i
            break
    if mark1:
        a = a[:mark1]
    if mark2:
        b = b[:mark2]
    book = get(a, b, 0, 0, k)
    print(book)
    return

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    line1 = input()
    line2 = input()
    line3 = input()
    n, m, k = list(map(int, line1.split()))
    a = [0] + list(map(int, line2.split()))
    b = [0] + list(map(int, line3.split()))
    mark1, mark2 = 0, 0
    for i in range(1, len(a)):
        a[i] += a[i-1]
        if a[i] > k:
            mark1 = i
            break
    for i in range(1, len(b)):
        b[i] += b[i-1]
        if b[i] > k:
            mark2 = i
            break
    if mark1:
        a = a[:mark1]
    if mark2:
        b = b[:mark2]
    ans = 0
    for i in range(len(a)):
        target = k - a[i]
        tmp = 0
        low, high = 0, len(b)
        while low < high:
            mid = (low + high) // 2
            if b[mid] <= target:
                tmp = mid
                low = mid + 1
            else:
                high = mid - 1
        ans = max(ans, i + tmp)
    print(ans)
    return

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def cul(lists):
    culist = []
    lene = len(lists)
    culist = [sum(lists[0:x:1]) for x in range(0, lene + 1)]
    return culist[1:]


n, m, k = map(int, input().split())
li = list(map(int, input().split()))[:n]
li2 = list(map(int, input().split()))[:m]
all = 0
all2 = 0
g = 0
z = 0
a = cul(li)
b = cul(li2)
for i in range(n):
    if a[i] <= k:
        g += 1
    else:
        break

all += a[i-1]

for i in range(m):
    if all + b[i] <= k:
        g += 1
    else:
        break

for i in range(m):
    if b[i] <= k:
        z += 1
    else:
        break

all2 += b[i-1]
for i in range(n):
    if all2 + a[i] <= k:
        z += 1
    else:
        break

print(max(g, z))


Fixed submission:
def main():
    line1 = input()
    line2 = input()
    line3 = input()
    n, m, k = list(map(int, line1.split()))
    a = [0] + list(map(int, line2.split()))
    b = [0] + list(map(int, line3.split()))
    mark1, mark2 = 0, 0
    for i in range(1, len(a)):
        a[i] += a[i-1]
        if a[i] > k:
            mark1 = i
            break
    for i in range(1, len(b)):
        b[i] += b[i-1]
        if b[i] > k:
            mark2 = i
            break
    if mark1:
        a = a[:mark1]
    if mark2:
        b = b[:mark2]
    ans = 0
    for i in range(len(a)):
        target = k - a[i]
        tmp = 0
        low, high = 0, len(b)
        while low < high:
            mid = (low + high) // 2
            if b[mid] <= target:
                tmp = mid
                low = mid + 1
            else:
                high = mid - 1
        ans = max(ans, i + tmp)
    print(ans)
    return

if __name__ == "__main__":
    main()