Buggy python submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
minute=0
ans=0
for _ in range(100000000):
    if not A and not B:break
    if not A: minute+=B[0]
    if not B: minute+=A[0]
    if A[0]<B[0]: 
        del A[0]
        minute += min(A[0], B[0])
    elif B[0]<A[0]:
        del B[0]
        minute += min(A[0], B[0])
    else: 
        del A[0]
        minute += min(A[0], B[0])
    if minute>K: break
    ans += 1
print(ans)


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: Runtime Error):
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
minute=0
ans=0
while True:
    if not A and not B:
        break
    elif not A:
        x=B[0]
        del B[0]
    elif not B:
        x=A[0]
        del A[0]
    elif A[0] > K and B[0] > K:
        break
    elif A[0] > K:
        x = B[0]
        del B[0]
    elif B[0] > K:
        x = A[0]
        del A[0]
    elif A[0]!=B[0]:
        x=min(A[0],B[0])
        if A[0]<B[0]:
            del A[0]
        else:
            del B[0]
    else:
        x=A[0]
        while True:
            i=1
            if A[i]<B[i]:
                del A[0]
                break
            elif B[i]<A[i]:
                del B[0]
                break
            else:
                i+=1
    minute += x
    if minute > K:
        break
    ans += 1

print(ans)

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: Runtime Error):
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
minute=0
ans=0
while True:
    if A[0] > K and B[0] > K:
        break
    elif not A and not B:
        break
    elif not A:
        x=B[0]
        del B[0]
    elif not B:
        x=A[0]
        del A[0]
    elif A[0]!=B[0]:
        x=min(A[0],B[0])
        if A[0]<B[0]:
            del A[0]
        else:
            del B[0]
    else:
        x=A[0]
        while True:
            i=1
            if A[i]<B[i]:
                del A[0]
                break
            elif B[i]<A[i]:
                del B[0]
                break
            else:
                i+=1
    minute += x
    if minute > K:
        break
    ans += 1

print(ans)

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: Runtime Error):
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
minute=0
ans=0
if A[0]>K and B[0]>K: print(0)
while True:
    if not A and not B:
        break
    elif not A:
        x=B[0]
        minute += x
        del B[0]
        if minute > K:
            break
        ans += 1
    elif not B:
        x=A[0]
        minute += x
        del A[0]
        if minute > K:
            break
        ans += 1
    elif A[0]!=B[0]:
        x=min(A[0],B[0])
        if A[0]<B[0]:
            del A[0]
        else:
            del B[0]
        minute+=x
        if minute>K:
            break
        ans += 1
    else:
        x=A[0]
        while True:
            i=1
            if A[i]<B[i]:
                del A[0]
                break
            elif B[i]<A[i]:
                del B[0]
                break
            else:
                i+=1
        minute += x
        if minute > K:
            break
        ans += 1

print(ans)

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: Runtime Error):
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
minute=0
ans=0
if A[0]>K and B[0]>K: print(0)
while True:
    if not A and not B:
        break
    elif not A:
        x=B[0]
        minute += x
        del B[0]
        if minute > K:
            break
        ans += 1
    elif not B:
        x=A[0]
        minute += x
        del A[0]
        if minute > K:
            break
        ans += 1
    elif A[0]!=B[0]:
        x=min(A[0],B[0])
        if A[0]<B[0]:
            del A[0]
        else:
            del B[0]
        minute+=x
        if minute>K:
            break
        ans += 1
    else:
        x=A[0]
        while True:
            i=1
            if A[i]<B[i]:
                del A[0]
                break
            elif B[i]<A[i]:
                del B[0]
                break
            else:
                i+=1
        minute += x
        if minute > K:
            break
        ans += 1

print(ans)

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)