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()))

sumt = 0
cnt = 0
    
while cnt < (N+M):
    
    if len(A) > 0:
        tmpA = A[0]
    else:
        tmpA = 10**10

    if len(B) > 0:
        tmpB = B[0]
    else:
        tmpA = 10**10

    if tmpA <= tmpB:
        sumt += A.pop(0)
    else:
        sumt += B.pop(0)

    if sumt > K:
        print(cnt)
        exit(0)
        
    cnt += 1
print(cnt)


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

SumA = [0]
SumB = [0]
cnt = 0
for i in range(N):
    SumA.append(SumA[i] + A[i])
for i in range(M):
    SumB.append(SumB[i] + B[i])

for i in range(N+1):
    if SumA[i] > K:
        break
    tmpcnt = bisect.bisect_right(SumB, K - SumA[i]) - 1
    #print([SumA,SumB])
    #print(SumA[i])
    #print(K - SumA[i])
    #print(tmpcnt)
    #print([i,tmpcnt])
    cnt = max(cnt, i + tmpcnt)
print(cnt)

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()))

sumt = 0
cnt = 0
    
for i in range(N+M):
    
    if len(A) > 0:
        tmpA = A[0]
    else:
        tmpA = 10**10

    if len(B) > 0:
        tmpB = B[0]
    else:
        tmpA = 10**10

    if tmpA <= tmpB:
        sumt += A.pop(0)
    else:
        sumt += B.pop(0)

    if sumt > K:
        print(cnt)
        exit(0)
        
    cnt += 1
print(cnt)


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

SumA = [0]
SumB = [0]
cnt = 0
for i in range(N):
    SumA.append(SumA[i] + A[i])
for i in range(M):
    SumB.append(SumB[i] + B[i])

for i in range(N+1):
    if SumA[i] > K:
        break
    tmpcnt = bisect.bisect_right(SumB, K - SumA[i]) - 1
    #print([SumA,SumB])
    #print(SumA[i])
    #print(K - SumA[i])
    #print(tmpcnt)
    #print([i,tmpcnt])
    cnt = max(cnt, i + tmpcnt)
print(cnt)

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()))

sumt = 0
cnt = 0
Ai = 0
Bi = 0

if (sum(A) + sum(B)) <= K:
    print(N+M)
    exit(0)
    
for i in range(N+M):
    if A[0] <= B[0]:
        sumt += A.pop(0)
    else:
        sumt += B.pop(0)

    if sumt > K:
        print(cnt)
        exit(0)
        
    cnt += 1



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

SumA = [0]
SumB = [0]
cnt = 0
for i in range(N):
    SumA.append(SumA[i] + A[i])
for i in range(M):
    SumB.append(SumB[i] + B[i])

for i in range(N+1):
    if SumA[i] > K:
        break
    tmpcnt = bisect.bisect_right(SumB, K - SumA[i]) - 1
    #print([SumA,SumB])
    #print(SumA[i])
    #print(K - SumA[i])
    #print(tmpcnt)
    #print([i,tmpcnt])
    cnt = max(cnt, i + tmpcnt)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ALLB = sorted(A+B)

sumt = 0
cnt = 0
summax = sum(ALLB)
if summax <= K:
    print(N+M)
    exit(0)
    
for i in range(N+M):
    sumt += ALLB.pop(0)
    if sumt > K:
        print(cnt)
        exit(0)
        
    cnt += 1



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

SumA = [0]
SumB = [0]
cnt = 0
for i in range(N):
    SumA.append(SumA[i] + A[i])
for i in range(M):
    SumB.append(SumB[i] + B[i])

for i in range(N+1):
    if SumA[i] > K:
        break
    tmpcnt = bisect.bisect_right(SumB, K - SumA[i]) - 1
    #print([SumA,SumB])
    #print(SumA[i])
    #print(K - SumA[i])
    #print(tmpcnt)
    #print([i,tmpcnt])
    cnt = max(cnt, i + tmpcnt)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):

N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ALLB = sorted(A+B)

sumt = 0
cnt = 0
for i in range(N+M):
    sumt += ALLB.pop(0)
    if sumt > K:
        print(cnt)
        exit(0)
    cnt += 1

print(N+M)



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

SumA = [0]
SumB = [0]
cnt = 0
for i in range(N):
    SumA.append(SumA[i] + A[i])
for i in range(M):
    SumB.append(SumB[i] + B[i])

for i in range(N+1):
    if SumA[i] > K:
        break
    tmpcnt = bisect.bisect_right(SumB, K - SumA[i]) - 1
    #print([SumA,SumB])
    #print(SumA[i])
    #print(K - SumA[i])
    #print(tmpcnt)
    #print([i,tmpcnt])
    cnt = max(cnt, i + tmpcnt)
print(cnt)