Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)

N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Asum = []
Bsum = []
count = 0
for p in A:
    count += p
    Asum.append(count)
count = 0
for p in B:
    count += p
    Bsum.append(count)
best = 0
Blast = M-1
for t in range(N):
    if Asum(t) > K:
        break
    if best < t+1:
        best=t+1
    for s in reversed(range(0,Blast+1)):
        if Asum[t]+Bsum[s]<=K:
            if best < t+1+s+1:
                best=t+1+s+1
            Blast = s
            break
print(best)



Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Asum = [0]
Bsum = [0]
count = 0
for p in A:
    count += p
    Asum.append(count)
count = 0
for p in B:
    count += p
    Bsum.append(count)
best = 0
Blast = M
for t in range(N+1):
    if Asum[t] > K:
        break
    if best < t:
        best=t
    for s in reversed(range(0,Blast+1)):
        if Asum[t]+Bsum[s]<=K:
            if best < t+s:
                best=t+s
            Blast = s
            break
print(best)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(2147483647)

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

def calc(k,i,j):
    c1 = 0
    c2 = 0
    global N,M,K,A,B
    if N-1>=i and A[i]+k <= K:
        c1 = 1+calc(A[i]+k,i+1,j)
    if M-1>=j and B[j]+k <= K:
        c2 = 1+calc(B[j]+k,i,j+1)
    return max(c1,c2)
count = calc(0,0,0)
print(count)



Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Asum = [0]
Bsum = [0]
count = 0
for p in A:
    count += p
    Asum.append(count)
count = 0
for p in B:
    count += p
    Bsum.append(count)
best = 0
Blast = M
for t in range(N+1):
    if Asum[t] > K:
        break
    if best < t:
        best=t
    for s in reversed(range(0,Blast+1)):
        if Asum[t]+Bsum[s]<=K:
            if best < t+s:
                best=t+s
            Blast = s
            break
print(best)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(2147483647)

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

def calc(k,i,j):
    c1 = 0
    c2 = 0
    global N,M,K,A,B
    if N-1>=i and A[i]+k <= K:
        c1 = 1+calc(A[i]+k,i+1,j)
    if M-1>=j and B[j]+k <= K:
        c2 = 1+calc(B[j]+k,i,j+1)
    return max(c1,c2)
count = calc(0,0,0)
print(count)



Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Asum = [0]
Bsum = [0]
count = 0
for p in A:
    count += p
    Asum.append(count)
count = 0
for p in B:
    count += p
    Bsum.append(count)
best = 0
Blast = M
for t in range(N+1):
    if Asum[t] > K:
        break
    if best < t:
        best=t
    for s in reversed(range(0,Blast+1)):
        if Asum[t]+Bsum[s]<=K:
            if best < t+s:
                best=t+s
            Blast = s
            break
print(best)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)

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

def calc(k,i,j):
    c1 = 0
    c2 = 0
    global N,M,K,A,B
    if N-1>=i and A[i]+k <= K:
        c1 = 1+calc(A[i]+k,i+1,j)
    if M-1>=j and B[i]+k <= K:
        c2 = 1+calc(B[j]+k,i,j+1)
    return max(c1,c2)
count = calc(0,0,0)
print(count)



Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Asum = [0]
Bsum = [0]
count = 0
for p in A:
    count += p
    Asum.append(count)
count = 0
for p in B:
    count += p
    Bsum.append(count)
best = 0
Blast = M
for t in range(N+1):
    if Asum[t] > K:
        break
    if best < t:
        best=t
    for s in reversed(range(0,Blast+1)):
        if Asum[t]+Bsum[s]<=K:
            if best < t+s:
                best=t+s
            Blast = s
            break
print(best)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000)

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

def calc(k,i,j):
    c1 = 0
    c2 = 0
    global N,M,K,A,B
    if N-1>=i and A[i]+k <= K:
        c1 = 1+calc(A[i]+k,i+1,j)
    if M-1>=j and B[i]+k <= K:
        c2 = 1+calc(B[j]+k,i,j+1)
    return max(c1,c2)
count = calc(0,0,0)
print(count)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Asum = [0]
Bsum = [0]
count = 0
for p in A:
    count += p
    Asum.append(count)
count = 0
for p in B:
    count += p
    Bsum.append(count)
best = 0
Blast = M
for t in range(N+1):
    if Asum[t] > K:
        break
    if best < t:
        best=t
    for s in reversed(range(0,Blast+1)):
        if Asum[t]+Bsum[s]<=K:
            if best < t+s:
                best=t+s
            Blast = s
            break
print(best)

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

def calc(k,i,j):
    c1 = 0
    c2 = 0
    global N,M,K,A,B
    if N-1>=i and A[i]+k <= K:
        c1 = 1+calc(A[i]+k,i+1,j)
    if M-1>=j and B[i]+k <= K:
        c2 = 1+calc(B[j]+k,i,j+1)
    return max(c1,c2)
count = calc(0,0,0)
print(count)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Asum = [0]
Bsum = [0]
count = 0
for p in A:
    count += p
    Asum.append(count)
count = 0
for p in B:
    count += p
    Bsum.append(count)
best = 0
Blast = M
for t in range(N+1):
    if Asum[t] > K:
        break
    if best < t:
        best=t
    for s in reversed(range(0,Blast+1)):
        if Asum[t]+Bsum[s]<=K:
            if best < t+s:
                best=t+s
            Blast = s
            break
print(best)

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

def calc(k,i,j):
    c1 = 0
    c2 = 0
    global N,M,K,A,B
    if N-1>=i and A[i]+k <= K:
        c1 = 1+calc(A[i]+k,i+1,j)
    if M-1>=j and B[i]+k <= K:
        c2 = 1+calc(B[j]+k,i,j+1)
    return max(c1,c2)
count = calc(0,0,0)
print(count)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)

N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Asum = [0]
Bsum = [0]
count = 0
for p in A:
    count += p
    Asum.append(count)
count = 0
for p in B:
    count += p
    Bsum.append(count)
best = 0
Blast = M
for t in range(N+1):
    if Asum[t] > K:
        break
    if best < t:
        best=t
    for s in reversed(range(0,Blast+1)):
        if Asum[t]+Bsum[s]<=K:
            if best < t+s:
                best=t+s
            Blast = s
            break
print(best)