Buggy python submission (verdict: Runtime Error):
def main():
    n, m, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    a_sum = [0 for x in range(n)]
    b_sum = [0 for x in range(m)]

    a_sum[0] = a[0]
    b_sum[0] = b[0]

    max_counter = 0

    for i in range(1, n):
        a_sum[i] = a[i] + a_sum[i - 1]

    for i in range(1, n):
        b_sum[i] = b[i] + b_sum[i - 1]

    for i in range(n):
        for j in range(m):
            if k >= a_sum[i] + b_sum[j] and max_counter < i + j + 2:
                max_counter = i + j + 2
        
    print(max_counter)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n, m, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    a_sum = [0]
    b_sum = [0] 

    max_counter = 0

    j = m

    for i in range(n):
        a_sum.append(a_sum[i] + a[i])

    for i in range(m):
        b_sum.append(b_sum[i] + b[i])

    for i in range(n + 1):
        if a_sum[i] > k:
            break

        while k < a_sum[i] + b_sum[j]:
            j -= 1
        
        max_counter = max(max_counter, i + j)

    print(max_counter)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
max_counter = 0

def check(limit, a, b, i, j, counter):
    global max_counter

    if len(a) > i:
        if limit - a[i] >= 0:

            check(limit - a[i], a, b, i + 1, j, counter + 1)

    if len(b) > j:
        if limit - b[j] >= 0:

            check(limit - b[j], a, b, i, j + 1, counter + 1)

    if counter > max_counter:
        max_counter = counter

    return

def main():
    global max_counter
    n, m, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    check(k, a, b, 0, 0, 0)

    print(max_counter)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n, m, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    a_sum = [0]
    b_sum = [0] 

    max_counter = 0

    j = m

    for i in range(n):
        a_sum.append(a_sum[i] + a[i])

    for i in range(m):
        b_sum.append(b_sum[i] + b[i])

    for i in range(n + 1):
        if a_sum[i] > k:
            break

        while k < a_sum[i] + b_sum[j]:
            j -= 1
        
        max_counter = max(max_counter, i + j)

    print(max_counter)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
max_counter = 0

def check(limit, a, b, i, j, counter):
    global max_counter
    
    if len(a) > i:
        if limit - a[i] >= 0:

            check(limit - a[i], a, b, i + 1, j, counter + 1)

            if counter > max_counter:
                max_counter = counter

    if len(b) > j:
        if limit - b[j] >= 0:

            check(limit - b[j], a, b, i, j + 1, counter + 1)

            if counter > max_counter:
                max_counter = counter

    return

def main():
    global max_counter
    n, m, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    check(k, a, b, 0, 0, 1)

    print(max_counter)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n, m, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    a_sum = [0]
    b_sum = [0] 

    max_counter = 0

    j = m

    for i in range(n):
        a_sum.append(a_sum[i] + a[i])

    for i in range(m):
        b_sum.append(b_sum[i] + b[i])

    for i in range(n + 1):
        if a_sum[i] > k:
            break

        while k < a_sum[i] + b_sum[j]:
            j -= 1
        
        max_counter = max(max_counter, i + j)

    print(max_counter)

if __name__ == '__main__':
    main()