Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    ma = 0
    a2 = [0]
    b2 = [0]
    for i in range(len(a)):
        a2.append(a[i]+a2[i])
    for i in range(len(b)):
        b2.append(b[i]+b2[i])
    jj = len(b2)-1
    for i in range(len(a2)):
        if(a2[i]>k):
            break
        j = jj
        while((a2[i]+b2[j])>k):
            j -= 1
        ma = max(ma,i+j)

    print(ma)
            
main()

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    ma = 0
    a2 = [0]
    b2 = [0]
    for i in range(len(a)):
        a2.append(a[i]+a2[i])
    for i in range(len(b)):
        b2.append(b[i]+b2[i])
    jj = len(b2)-1
    for i in range(len(a2)):
        cnt = i
        if(a2[i]>k):
            break
        j = jj
        while((a2[i]+b2[j])>k):
            j -= 1
        ma = max(ma,i+j)


    print(ma)
            
main()

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    ma = 0
    a2 = [0]
    b2 = [0]
    for i in range(len(a)):
        a2.append(a[i]+a2[i])
    for i in range(len(b)):
        b2.append(b[i]+b2[i])

    for i in range(len(a2)):
        cnt = i
        if(a2[i]>k):
            break
        j = len(b2) -1
        while((a2[i]+b2[j])>k):
            j -= 1
        ma = max(ma,i+j)

    print(ma)
            
main()

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    ma = 0
    a2 = [0]
    b2 = [0]
    for i in range(len(a)):
        a2.append(a[i]+a2[i])
    for i in range(len(b)):
        b2.append(b[i]+b2[i])

    for i in range(len(a2)):
        #print(i)
        sum = a2[i]
        cnt = i
        if(a2[i]>k):
            break
        for j in range(len(b2)-1,0,-1):
            #print("i:{},j:{},b2[j]:{}".format(i,j,b2[j]))
            if(a2[i]+b2[j]<=k):
                cnt += j
                break
        ma = max(ma,cnt)
        #print("ma:",ma)

    print(ma)
            
main()

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    ma = 0
    a2 = [0]
    for i in range(len(a)):
        a2.append(a[i]+a2[i])
        
    for i in range(len(a2)):
        sum = a2[i]
        cnt = i
        if(sum>k):
            break
        for j in range(len(b)):
            sum += b[j]
            if(sum>k):
                break
            else:
                cnt += 1
        ma = max(ma,cnt)

    print(ma)
            
main()

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    ma = 0

    for i in range(len(a)+1):
        sum = 0
        cnt = i
        for j in range(i):
            sum += a[j]
        if(sum>k):
            break
        for j in range(len(b)):
            sum += b[j]
            if(sum>k):
                break
            else:
                cnt += 1
        ma = max(ma,cnt)
        
    print(ma)
            
main()

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)