Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,m,k =map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = k
i = 0
asum = [0]* (n+1)
bsum = [0]* (m+1)
suma = 0
sumb = 0

for  i in range(n):
    suma += a[i]
    asum[i+1]= suma


for  i in range(m):
    sumb += b[i]
    bsum[i+1] = sumb

count = 1
ans = 0

for i in range(n+1):
    if ans < i :
        if asum[i] <= k:
            ans=i
    else:
        for j in range(ans-i,m+1,1):
            if asum[i] + bsum[j]<=k and i+j>ans:
                ans=i+j

print(min(ans,m+n))



Fixed submission:
import sys
n,m,k =map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = k
i = 0
asum = [0]* (n+1)
bsum = [0]* (m+1)
suma = 0
sumb = 0

for  i in range(n):
    suma += a[i]
    asum[i+1]= suma


for  i in range(m):
    sumb += b[i]
    bsum[i+1] = sumb

count = 1
ans = 0

for i in range(n+1):
    if ans < i :
        if asum[i] <= k:
            ans=i
    else:
        for j in range(ans-i,m+1,1):
            if asum[i] + bsum[j]<=k:
                if i+j>ans:
                    ans=i+j
            else:
                break

print(min(ans,m+n))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,m,k =map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = k
i = 0
asum = [0]* (n+1)
bsum = [0]* (m+1)
suma = 0
sumb = 0

for  i in range(n):
    suma += a[i]
    asum[i+1]= suma


for  i in range(m):
    sumb += b[i]
    bsum[i+1] = sumb

count = 1
ans = 0

for i in range(n+1):
    if ans < i :
        if asum[i] <= k:
            ans=i
    else:
        for j in range(ans-i,m+1,1):
            if asum[i] + bsum[j]<=k and i+j>ans:
                ans=i+j

print(min(ans,m+n))


Fixed submission:
import sys
n,m,k =map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = k
i = 0
asum = [0]* (n+1)
bsum = [0]* (m+1)
suma = 0
sumb = 0

for  i in range(n):
    suma += a[i]
    asum[i+1]= suma


for  i in range(m):
    sumb += b[i]
    bsum[i+1] = sumb

count = 1
ans = 0

for i in range(n+1):
    if ans < i :
        if asum[i] <= k:
            ans=i
    else:
        for j in range(ans-i,m+1,1):
            if asum[i] + bsum[j]<=k:
                if i+j>ans:
                    ans=i+j
            else:
                break

print(min(ans,m+n))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,m,k =map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = k
i = 0
asum = [0]* (n+1)
bsum = [0]* (m+1)
suma = 0
sumb = 0

for  i in range(n):
    suma += a[i]
    asum[i+1]= suma


for  i in range(m):
    sumb += b[i]
    bsum[i+1] = sumb

count = 1
ans = 0

for i in range(n+1):

    for j in range(m+1):
        if asum[i] + bsum[j]<=k and i+j>ans:
            ans=i+j

print(min(ans,m+n))




Fixed submission:
import sys
n,m,k =map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = k
i = 0
asum = [0]* (n+1)
bsum = [0]* (m+1)
suma = 0
sumb = 0

for  i in range(n):
    suma += a[i]
    asum[i+1]= suma


for  i in range(m):
    sumb += b[i]
    bsum[i+1] = sumb

count = 1
ans = 0

for i in range(n+1):
    if ans < i :
        if asum[i] <= k:
            ans=i
    else:
        for j in range(ans-i,m+1,1):
            if asum[i] + bsum[j]<=k:
                if i+j>ans:
                    ans=i+j
            else:
                break

print(min(ans,m+n))

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

t = k
i = 0
asum = [0]* (n+1)
bsum = [0]* (m+1)
suma = 0
sumb = 0

for  i in range(n):
    suma += a[i]
    asum[i+1]= suma


for  i in range(m):
    sumb += b[i]
    bsum[i+1] = sumb

count = 1
ans = 0

for i in range(n+1):
    for j in range(m+1):
        if asum[i] + bsum[j]<=k and i+j>ans:
            ans=i+j

print(min(ans,m+n))

Fixed submission:
import sys
n,m,k =map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = k
i = 0
asum = [0]* (n+1)
bsum = [0]* (m+1)
suma = 0
sumb = 0

for  i in range(n):
    suma += a[i]
    asum[i+1]= suma


for  i in range(m):
    sumb += b[i]
    bsum[i+1] = sumb

count = 1
ans = 0

for i in range(n+1):
    if ans < i :
        if asum[i] <= k:
            ans=i
    else:
        for j in range(ans-i,m+1,1):
            if asum[i] + bsum[j]<=k:
                if i+j>ans:
                    ans=i+j
            else:
                break

print(min(ans,m+n))

Buggy python submission (verdict: Runtime Error):
import sys
n,m,k =map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = k
i = 0
asum = [0]* n
bsum = [0]* m
suma = 0
sumb = 0
j =0
for  i in a:
    suma += i
    asum[j]= suma
    j +=1
j =0
for  i in b:
    sumb += i
    bsum[j] = sumb
    j +=0

count = 1
ans = 1

for j in range(m + n-1):
    count = 0
    for i in range(ans):
        if asum[ans-1]+bsum[ans]<=k:
            count = 1

    if count ==1:
        ans +=1
    else:
        break
print(min(ans,m+n))

Fixed submission:
import sys
n,m,k =map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

t = k
i = 0
asum = [0]* (n+1)
bsum = [0]* (m+1)
suma = 0
sumb = 0

for  i in range(n):
    suma += a[i]
    asum[i+1]= suma


for  i in range(m):
    sumb += b[i]
    bsum[i+1] = sumb

count = 1
ans = 0

for i in range(n+1):
    if ans < i :
        if asum[i] <= k:
            ans=i
    else:
        for j in range(ans-i,m+1,1):
            if asum[i] + bsum[j]<=k:
                if i+j>ans:
                    ans=i+j
            else:
                break

print(min(ans,m+n))