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

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + a[i])

acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1]+b[i])
i = 0
ans = 0
j = m
while acum1[i]<=k:
    while acum2[j]>k-acum1[i] and j>0:
        j -= 1
    ans = max(ans,i+j)
    i+=1
print(ans)
        

Fixed submission:
#　変数 n, m, k, arr1, arr2, acum1, acum2, ans

n, m, k = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + arr1[i])
acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1] + arr2[i])

ans = 0
j = m
for i in range(n+1):
    if acum1[i] > k:
        break
    while acum2[j] > k - acum1[i] and j > 0:
        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()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + a[i])

acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1]+b[i])
i = 0
ans = 0
j = m
while acum1[i]<k:
    while acum2[j]>k-acum1[i] and j>0:
        j -= 1
    ans = max(ans,i+j)
    i+=1
print(ans)
        

Fixed submission:
#　変数 n, m, k, arr1, arr2, acum1, acum2, ans

n, m, k = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + arr1[i])
acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1] + arr2[i])

ans = 0
j = m
for i in range(n+1):
    if acum1[i] > k:
        break
    while acum2[j] > k - acum1[i] and j > 0:
        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()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + a[i])

acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1]+b[i])
i = 0
ans = 0
while acum1[i]<k:
    j = m
    while acum2[j]>k-acum1[i] and j>0:
        j -= 1
    ans = max(ans,i+j)
    i+=1
print(ans)
        

Fixed submission:
#　変数 n, m, k, arr1, arr2, acum1, acum2, ans

n, m, k = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + arr1[i])
acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1] + arr2[i])

ans = 0
j = m
for i in range(n+1):
    if acum1[i] > k:
        break
    while acum2[j] > k - acum1[i] and j > 0:
        j -= 1
    ans = max(ans, i+j)
print(ans)

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

s1 = [0]
for i in range(n):
    s1.append(s1[-1]+a[i])

s2 = [0]
for i in range(m):
    s2.append(s2[-1]+b[i])
ans = 0
for i in range(n+1):
    p = k-s1[i]
    j = m
    if p<0:
        break
    while p-s2[j]<0 and j>0:
            j -= 1 
    ans = max(i+j,ans)
print(ans)




Fixed submission:
#　変数 n, m, k, arr1, arr2, acum1, acum2, ans

n, m, k = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + arr1[i])
acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1] + arr2[i])

ans = 0
j = m
for i in range(n+1):
    if acum1[i] > k:
        break
    while acum2[j] > k - acum1[i] and j > 0:
        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()))

s1 = [0]
for i in range(n):
    s1.append(s1[-1]+a[i])

s2 = [0]
for i in range(m):
    s2.append(s2[-1]+b[i])
ans = 0
for i in range(1,n):
    p = k-s1[i]
    j = 0
    while p-s2[j]>0:
        if p-s2[j]>0:
            p -= s2[j]
            j += 1
        else:
            break
    ans = max(i+j-1,ans)
print(ans)




Fixed submission:
#　変数 n, m, k, arr1, arr2, acum1, acum2, ans

n, m, k = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + arr1[i])
acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1] + arr2[i])

ans = 0
j = m
for i in range(n+1):
    if acum1[i] > k:
        break
    while acum2[j] > k - acum1[i] and j > 0:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque

n,m,k = map(int,input().split(" "))

a = deque(list(map(int,input().split())))
b = deque(list(map(int,input().split())))
cnt = 0
total = 0

while total+a[0] < k or total+b[0] < k:
    if len(a) > 0 and len(b) > 0:
        picked = min(a[0],b[0])
        if picked == a[0]:
            total += a.popleft()
            cnt += 1
        else:
            total += b.popleft()
            cnt += 1
    elif len(a) > 0 and len(b)==0:
        total +=a.popleft()
        cnt += 1
    elif len(b) > 0 and len(a)==0:
        total += b.popleft()
        cnt += 1
print(cnt)

Fixed submission:
#　変数 n, m, k, arr1, arr2, acum1, acum2, ans

n, m, k = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))

acum1 = [0]
for i in range(n):
    acum1.append(acum1[-1] + arr1[i])
acum2 = [0]
for i in range(m):
    acum2.append(acum2[-1] + arr2[i])

ans = 0
j = m
for i in range(n+1):
    if acum1[i] > k:
        break
    while acum2[j] > k - acum1[i] and j > 0:
        j -= 1
    ans = max(ans, i+j)
print(ans)