Buggy python submission (verdict: Time Limit Exceeded):
import bisect
from collections import deque
n,m,k=map(int,input().split())
a=deque(map(int,input().split()))
b=deque(map(int,input().split()))
a_sum=deque()
b_sum=deque()
a_sum.append(0)
b_sum.append(0)
for i in range(n):
    a_sum.append(a_sum[i]+a[i])
for j in range(m):
    b_sum.append(b_sum[j]+b[j])
ans=0
for x in range(n+1):
    timecount=k-a_sum[x]
    if timecount>=0:
        y=bisect.bisect_right(b_sum,k-a_sum[x])-1
        ans=max(x+y,ans)
    else:
        break
print(ans)
    

Fixed submission:
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_sum=[]
b_sum=[]
a_sum.append(0)
b_sum.append(0)
for i in range(n):
    a_sum.append(a_sum[i]+a[i])
for j in range(m):
    b_sum.append(b_sum[j]+b[j])
ans=0
for x in range(n+1):
    timecount=k-a_sum[x]
    if timecount>=0:
        y=bisect.bisect_right(b_sum,k-a_sum[x])-1
        ans=max(x+y,ans)
    else:
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,m,k=map(int,input().split())
a=deque(map(int,input().split()))
b=deque(map(int,input().split()))
b_sum=deque()
b_sum.append(b[0])
b_j=b[0]
for j in range(1,m):
    b_j=b_j+b[j]
    b_sum.append(b_j)
b_sum.append(10**10)
b_sum.appendleft(0)
b_sum.appendleft(-1)
ans=0
a.append(0)
a_sum=0
for l in range(n+1):
    timecount=k-a_sum
    a_sum+=a[l]
    if timecount>=0:
        ok=0
        ng=m+2
        while ng-ok>1:
            midlle=(ng+ok)//2
            if b_sum[midlle]<=timecount:
                ok=midlle
            else:
                ng=midlle
        ans=max(l+ng-2,ans)
    else:
        break
print(ans)
    

Fixed submission:
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_sum=[]
b_sum=[]
a_sum.append(0)
b_sum.append(0)
for i in range(n):
    a_sum.append(a_sum[i]+a[i])
for j in range(m):
    b_sum.append(b_sum[j]+b[j])
ans=0
for x in range(n+1):
    timecount=k-a_sum[x]
    if timecount>=0:
        y=bisect.bisect_right(b_sum,k-a_sum[x])-1
        ans=max(x+y,ans)
    else:
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,m,k=map(int,input().split())
a=deque(map(int,input().split()))
b=deque(map(int,input().split()))
a_sum=deque()
b_sum=deque()
a_sum.append(a[0])
b_sum.append(b[0])
a_i=a[0]
b_j=b[0]
for i in range(1,n):
    a_i=a_i+a[i]
    a_sum.append(a_i)
for j in range(1,m):
    b_j=b_j+b[j]
    b_sum.append(b_j)
b_sum.append(10**10)
b_sum.appendleft(0)
b_sum.appendleft(-1)
a_sum.appendleft(0)
ans=0
for l in range(n+1):
    timecount=k-a_sum[l]
    if timecount>=0:
        ok=0
        ng=m+2
        while ng-ok>1:
            midlle=(ng+ok)//2
            if b_sum[midlle]<=timecount:
                ok=midlle
            else:
                ng=midlle
        ans=max(l+ng-2,ans)
    else:
        break
print(ans)
    

Fixed submission:
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_sum=[]
b_sum=[]
a_sum.append(0)
b_sum.append(0)
for i in range(n):
    a_sum.append(a_sum[i]+a[i])
for j in range(m):
    b_sum.append(b_sum[j]+b[j])
ans=0
for x in range(n+1):
    timecount=k-a_sum[x]
    if timecount>=0:
        y=bisect.bisect_right(b_sum,k-a_sum[x])-1
        ans=max(x+y,ans)
    else:
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,m,k=map(int,input().split())
a=deque(map(int,input().split()))
b=deque(map(int,input().split()))
a_sum=deque()
b_sum=deque()
a_sum.append(a[0])
b_sum.append(b[0])
a_i=a[0]
b_j=b[0]
for i in range(1,n):
    a_i=a_i+a[i]
    a_sum.append(a_i)
for j in range(1,m):
    b_j=b_j+b[j]
    b_sum.append(b_j)
b_sum.append(10**10)
b_sum.appendleft(0)
b_sum.appendleft(-1)
a_sum.appendleft(0)
ans=0
for l in range(n+1):
    timecount=k-a_sum[l]
    if timecount>=0:
        ok=0
        ng=m+2
        while ng-ok>1:
            midlle=(ng+ok)//2
            if b_sum[midlle]<=timecount:
                ok=midlle
            else:
                ng=midlle
        ans=max(l+ng-2,ans)
    else:
        break
print(ans)
    

Fixed submission:
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_sum=[]
b_sum=[]
a_sum.append(0)
b_sum.append(0)
for i in range(n):
    a_sum.append(a_sum[i]+a[i])
for j in range(m):
    b_sum.append(b_sum[j]+b[j])
ans=0
for x in range(n+1):
    timecount=k-a_sum[x]
    if timecount>=0:
        y=bisect.bisect_right(b_sum,k-a_sum[x])-1
        ans=max(x+y,ans)
    else:
        break
print(ans)