Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
from itertools import accumulate
#import numpy as np

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

sum_A = list(accumulate(A))
sum_B = list(accumulate(B))


#sum_A = np.cumsum(A)
#sum_B = np.cumsum(B)

list_N = [0 for i in range(len(A)+1)]

pre_n = len(B)

for i in range(len(A)+1):
    if i == 0:
        buf = sum_B[:pre_n]
        num_B = sum([1 if buf[j] <= K else 0 for j in range(len(buf))])
        #len(buf[buf<=K])
        pre_n = num_B
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            buf = sum_B[:pre_n]
            num_B = sum([1 if buf[j] <= (K-sum_A[i-1]) else 0 for j in range(len(buf))])
            #len(buf[buf<=(K-sum_A[i-1])])
            pre_n = num_B
            list_N[i] = i + num_B
            #print(K-sum_A[i-1])
            #print(i, num_B)
        else:
            list_N[i] = 0
    
#print(A)
#print(B)
#print(sum_A)
#print(sum_B)
#print(list_N)
print(max(list_N))

Fixed submission:
# coding: utf-8
# Your code here!
from itertools import accumulate
#import numpy as np

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

sum_A = list(accumulate(A))
sum_B = list(accumulate(B))


#sum_A = np.cumsum(A)
#sum_B = np.cumsum(B)

list_N = [0 for i in range(len(A)+1)]

pre_n = len(B)

for i in range(len(A)+1):
    if i == 0:
        num_B = 0
        for j in range(pre_n)[::-1]:
            if sum_B[j] <= K:
                num_B = j+1
                break
            else:
                continue
        #len(buf[buf<=K])
        pre_n = num_B
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            num_B = 0
            for j in range(pre_n)[::-1]:
                if sum_B[j] <= (K-sum_A[i-1]):
                    num_B = j+1
                    break
                else:
                    continue
            #len(buf[buf<=(K-sum_A[i-1])])
            pre_n = num_B
            list_N[i] = i + num_B
            #print(K-sum_A[i-1])
            #print(i, num_B)
        else:
            list_N[i] = 0
    
#print(A)
#print(B)
#print(sum_A)
#print(sum_B)
#print(list_N)
print(max(list_N))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
from itertools import accumulate
#import numpy as np

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

sum_A = list(accumulate(A))
sum_B = list(accumulate(B))


#sum_A = np.cumsum(A)
#sum_B = np.cumsum(B)

list_N = [0 for i in range(len(A)+1)]

pre_n = len(B)

for i in range(len(A)+1):
    if i == 0:
        buf = sum_B[:pre_n]
        num_B = sum([1 if buf[j] <= K else 0 for j in range(len(buf))])
        #len(buf[buf<=K])
        pre_n = num_B
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            buf = sum_B[:pre_n]
            num_B = sum([1 if buf[j] <= (K-sum_A[i-1]) else 0 for j in range(len(buf))])
            #len(buf[buf<=(K-sum_A[i-1])])
            pre_n = num_B
            list_N[i] = i + num_B
            #print(K-sum_A[i-1])
            #print(i, num_B)
        else:
            list_N[i] = 0
    
#print(A)
#print(B)
#print(sum_A)
#print(sum_B)
#print(list_N)
print(max(list_N))

Fixed submission:
# coding: utf-8
# Your code here!
from itertools import accumulate
#import numpy as np

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

sum_A = list(accumulate(A))
sum_B = list(accumulate(B))


#sum_A = np.cumsum(A)
#sum_B = np.cumsum(B)

list_N = [0 for i in range(len(A)+1)]

pre_n = len(B)

for i in range(len(A)+1):
    if i == 0:
        num_B = 0
        for j in range(pre_n)[::-1]:
            if sum_B[j] <= K:
                num_B = j+1
                break
            else:
                continue
        #len(buf[buf<=K])
        pre_n = num_B
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            num_B = 0
            for j in range(pre_n)[::-1]:
                if sum_B[j] <= (K-sum_A[i-1]):
                    num_B = j+1
                    break
                else:
                    continue
            #len(buf[buf<=(K-sum_A[i-1])])
            pre_n = num_B
            list_N[i] = i + num_B
            #print(K-sum_A[i-1])
            #print(i, num_B)
        else:
            list_N[i] = 0
    
#print(A)
#print(B)
#print(sum_A)
#print(sum_B)
#print(list_N)
print(max(list_N))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
from itertools import accumulate
import numpy as np

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

sum_A = list(accumulate(A))
sum_B = list(accumulate(B))

#sum_A = np.cumsum(A)
#sum_B = np.cumsum(B)

list_N = [0 for i in range(len(A)+1)]

pre_n = len(B)

for i in range(len(A)+1):
    if i == 0:
        buf = np.array(sum_B[:pre_n])
        num_B = len(buf[buf<=K])
        pre_n = num_B
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            buf = np.array(sum_B[:pre_n])
            num_B = len(buf[buf<=(K-sum_A[i-1])])
            pre_n = num_B
            list_N[i] = i + num_B
        else:
            list_N[i] = 0
    
print(np.max(list_N))

Fixed submission:
# coding: utf-8
# Your code here!
from itertools import accumulate
#import numpy as np

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

sum_A = list(accumulate(A))
sum_B = list(accumulate(B))


#sum_A = np.cumsum(A)
#sum_B = np.cumsum(B)

list_N = [0 for i in range(len(A)+1)]

pre_n = len(B)

for i in range(len(A)+1):
    if i == 0:
        num_B = 0
        for j in range(pre_n)[::-1]:
            if sum_B[j] <= K:
                num_B = j+1
                break
            else:
                continue
        #len(buf[buf<=K])
        pre_n = num_B
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            num_B = 0
            for j in range(pre_n)[::-1]:
                if sum_B[j] <= (K-sum_A[i-1]):
                    num_B = j+1
                    break
                else:
                    continue
            #len(buf[buf<=(K-sum_A[i-1])])
            pre_n = num_B
            list_N[i] = i + num_B
            #print(K-sum_A[i-1])
            #print(i, num_B)
        else:
            list_N[i] = 0
    
#print(A)
#print(B)
#print(sum_A)
#print(sum_B)
#print(list_N)
print(max(list_N))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import numpy as np

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


sum_A = np.cumsum(A)
sum_B = np.cumsum(B)
list_N = [0 for i in range(len(A)+1)]

pre_n = len(B)

for i in range(len(A)+1):
    if i == 0:
        buf = sum_B[:pre_n]
        num_B = len(buf[buf<=K])
        pre_n = num_B
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            buf = sum_B[:pre_n]
            num_B = len(buf[buf<=(K-sum_A[i-1])])
            pre_n = num_B
            list_N[i] = i + num_B
        else:
            list_N[i] = 0
    
print(np.max(list_N))

Fixed submission:
# coding: utf-8
# Your code here!
from itertools import accumulate
#import numpy as np

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

sum_A = list(accumulate(A))
sum_B = list(accumulate(B))


#sum_A = np.cumsum(A)
#sum_B = np.cumsum(B)

list_N = [0 for i in range(len(A)+1)]

pre_n = len(B)

for i in range(len(A)+1):
    if i == 0:
        num_B = 0
        for j in range(pre_n)[::-1]:
            if sum_B[j] <= K:
                num_B = j+1
                break
            else:
                continue
        #len(buf[buf<=K])
        pre_n = num_B
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            num_B = 0
            for j in range(pre_n)[::-1]:
                if sum_B[j] <= (K-sum_A[i-1]):
                    num_B = j+1
                    break
                else:
                    continue
            #len(buf[buf<=(K-sum_A[i-1])])
            pre_n = num_B
            list_N[i] = i + num_B
            #print(K-sum_A[i-1])
            #print(i, num_B)
        else:
            list_N[i] = 0
    
#print(A)
#print(B)
#print(sum_A)
#print(sum_B)
#print(list_N)
print(max(list_N))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import numpy as np

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


sum_A = np.cumsum(A)
sum_B = np.cumsum(B)
list_N = [0 for i in range(len(A)+1)]

for i in range(len(A)+1):
    if i == 0:
        num_B = len(sum_B[sum_B<=K])
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            num_B = len(sum_B[sum_B<=(K-sum_A[i-1])])
            list_N[i] = i + num_B
        else:
            list_N[i] = 0
    
print(np.max(list_N))

Fixed submission:
# coding: utf-8
# Your code here!
from itertools import accumulate
#import numpy as np

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

sum_A = list(accumulate(A))
sum_B = list(accumulate(B))


#sum_A = np.cumsum(A)
#sum_B = np.cumsum(B)

list_N = [0 for i in range(len(A)+1)]

pre_n = len(B)

for i in range(len(A)+1):
    if i == 0:
        num_B = 0
        for j in range(pre_n)[::-1]:
            if sum_B[j] <= K:
                num_B = j+1
                break
            else:
                continue
        #len(buf[buf<=K])
        pre_n = num_B
        list_N[i] = i + num_B
    else:
        if K>=sum_A[i-1]:
            num_B = 0
            for j in range(pre_n)[::-1]:
                if sum_B[j] <= (K-sum_A[i-1]):
                    num_B = j+1
                    break
                else:
                    continue
            #len(buf[buf<=(K-sum_A[i-1])])
            pre_n = num_B
            list_N[i] = i + num_B
            #print(K-sum_A[i-1])
            #print(i, num_B)
        else:
            list_N[i] = 0
    
#print(A)
#print(B)
#print(sum_A)
#print(sum_B)
#print(list_N)
print(max(list_N))