Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M,K = list(map(int,input().split()))
A = np.array(list(map(int,input().split())))
B = np.array(list(map(int,input().split())))

sum_A = sum(A)
sum_B = sum(B)
if sum_A > K: # 時間を超過する場合
    tmp_cnt = 0
    for i,a in enumerate(A):
        tmp_cnt += a
        if tmp_cnt > K:
            break
    A_n_max = i
else: #時間を超過しない場合
    A_n_max = len(A)
    
cnt = 0
best_cnt = 0
b_start=0
A_t = A[:A_n_max].sum()
B_t = 0
b_j = 0
for a_sub_i in range(A_n_max):
    cnt = A_n_max - a_sub_i
    time_left = K - A_t
   # print(a_sub_i)
   # print(time_left)
    while ((time_left - B_t) > 0) :
        if b_j == len(B):
            b_j += 1
            break
        B_t += B[b_j]
        b_j += 1
            
            
    A_t -= A[A_n_max -1 - a_sub_i]
    cnt = A_n_max - a_sub_i + b_j -1
    if cnt > best_cnt:
        best_cnt = cnt
    
        
print(best_cnt)

Fixed submission:
N, M, K = list(map(int, input().split()))
A = [0] + [int(i) for i in input().split() ]
B = [0] + [int(i) for i in input().split() ]

best = 0
a_time = 0
b_time = sum(B)
b_i = len(B)-1
end_flag = False
for a_i in range(N+1):
    a_time += A[a_i]
    while a_time + b_time > K:
        if b_i == 0:
            end_flag = True
            break
        b_time -= B[b_i]
        b_i -= 1

    if end_flag == True:
        break
    if a_i + b_i > best:
        best = a_i + b_i

print(best)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,M,K = list(map(int,input().split()))
A = np.array(list(map(int,input().split())))
B = np.array(list(map(int,input().split())))

sum_A = sum(A)
sum_B = sum(B)
if sum_A > K: # 時間を超過する場合
    tmp_cnt = 0
    for i,a in enumerate(A):
        tmp_cnt += a
        if tmp_cnt > K:
            break
    A_n_max = i
else: #時間を超過しない場合
    A_n_max = len(A)
    
cnt = 0
best_cnt = 0
b_start=0
for a_sub_i in range(A_n_max):
    cnt = A_n_max - a_sub_i
    time_left = K - A[:(A_n_max - a_sub_i)].sum()
   # print(a_sub_i)
   # print(time_left)
    for b_j in range(b_start, len(B)):
      #  print(b_j)
        if (time_left - B[:(b_j+1)].sum()) < 0:
            cnt = cnt + b_j
    #        print(f"b done {b_j}")
            break
        if b_j == (len(B)-1):
            cnt = cnt + b_j +1
     #       print(f"b done__ {b_j}")
            break
    b_start = b_j        
    if cnt > best_cnt:
        best_cnt = cnt
        
print(best_cnt)

Fixed submission:
N, M, K = list(map(int, input().split()))
A = [0] + [int(i) for i in input().split() ]
B = [0] + [int(i) for i in input().split() ]

best = 0
a_time = 0
b_time = sum(B)
b_i = len(B)-1
end_flag = False
for a_i in range(N+1):
    a_time += A[a_i]
    while a_time + b_time > K:
        if b_i == 0:
            end_flag = True
            break
        b_time -= B[b_i]
        b_i -= 1

    if end_flag == True:
        break
    if a_i + b_i > best:
        best = a_i + b_i

print(best)

Buggy python submission (verdict: Time Limit Exceeded):

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

sum_A = sum(A)
sum_B = sum(B)
if sum_A > K: # 時間を超過する場合
    tmp_cnt = 0
    for i,a in enumerate(A):
        tmp_cnt += a
        if tmp_cnt > K:
            break
    A_n_max = i
else: #時間を超過しない場合
    A_n_max = len(A)
    
cnt = 0
best_cnt = 0
b_start=0
for a_sub_i in range(A_n_max):
    cnt = A_n_max - a_sub_i
    time_left = K - sum(A[:(A_n_max - a_sub_i)])
   # print(a_sub_i)
   # print(time_left)
    for b_j in range(b_start, len(B)):
      #  print(b_j)
        if (time_left - sum(B[:(b_j+1)])) < 0:
            cnt = cnt + b_j
    #        print(f"b done {b_j}")
            break
        if b_j == (len(B)-1):
            cnt = cnt + b_j +1
     #       print(f"b done__ {b_j}")
            break
    b_start = b_j        
    if cnt > best_cnt:
        best_cnt = cnt
        
print(best_cnt)

Fixed submission:
N, M, K = list(map(int, input().split()))
A = [0] + [int(i) for i in input().split() ]
B = [0] + [int(i) for i in input().split() ]

best = 0
a_time = 0
b_time = sum(B)
b_i = len(B)-1
end_flag = False
for a_i in range(N+1):
    a_time += A[a_i]
    while a_time + b_time > K:
        if b_i == 0:
            end_flag = True
            break
        b_time -= B[b_i]
        b_i -= 1

    if end_flag == True:
        break
    if a_i + b_i > best:
        best = a_i + b_i

print(best)

Buggy python submission (verdict: Time Limit Exceeded):
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))

sum_A = sum(A)
sum_B = sum(B)
if sum_A > K: # 時間を超過する場合
    tmp_cnt = 0
    for i,a in enumerate(A):
        tmp_cnt += a
        if tmp_cnt > K:
            break
    A_n_max = i
else: #時間を超過しない場合
    A_n_max = len(A)
    
cnt = 0
best_cnt = 0
for a_sub_i in range(A_n_max):
    cnt = A_n_max - a_sub_i
    time_left = K - sum(A[:(A_n_max - a_sub_i)])
   # print(a_sub_i)
   # print(time_left)
    for b_j in range(len(B)):
      #  print(b_j)
        if (time_left - sum(B[:(b_j+1)])) < 0:
            cnt = cnt + b_j
    #        print(f"b done {b_j}")
            break
        if b_j == (len(B)-1):
            cnt = cnt + b_j +1
     #       print(f"b done__ {b_j}")
            break
            
    if cnt > best_cnt:
        best_cnt = cnt
        
print(best_cnt)

Fixed submission:
N, M, K = list(map(int, input().split()))
A = [0] + [int(i) for i in input().split() ]
B = [0] + [int(i) for i in input().split() ]

best = 0
a_time = 0
b_time = sum(B)
b_i = len(B)-1
end_flag = False
for a_i in range(N+1):
    a_time += A[a_i]
    while a_time + b_time > K:
        if b_i == 0:
            end_flag = True
            break
        b_time -= B[b_i]
        b_i -= 1

    if end_flag == True:
        break
    if a_i + b_i > best:
        best = a_i + b_i

print(best)

Buggy python submission (verdict: Time Limit Exceeded):
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))

sum_A = sum(A)
sum_B = sum(B)
if sum_A > K: # 時間を超過する場合
    tmp_cnt = 0
    for i,a in enumerate(A):
        tmp_cnt += a
        if tmp_cnt > K:
            break
    A_n_max = i
else: #時間を超過しない場合
    A_n_max = len(A)
    
cnt = 0
best_cnt = 0
for a_sub_i in range(A_n_max):
    cnt = A_n_max - a_sub_i
    time_left = K - sum(A[:(A_n_max - a_sub_i)])
   # print(a_sub_i)
   # print(time_left)
    for b_j in range(len(B)):
      #  print(b_j)
        if (time_left - sum(B[:(b_j+1)])) < 0:
            cnt = cnt + b_j
    #        print(f"b done {b_j}")
            break
        if b_j == (len(B)-1):
            cnt = cnt + b_j +1
     #       print(f"b done__ {b_j}")
            break
            
    if cnt > best_cnt:
        best_cnt = cnt
        
print(best_cnt)

Fixed submission:
N, M, K = list(map(int, input().split()))
A = [0] + [int(i) for i in input().split() ]
B = [0] + [int(i) for i in input().split() ]

best = 0
a_time = 0
b_time = sum(B)
b_i = len(B)-1
end_flag = False
for a_i in range(N+1):
    a_time += A[a_i]
    while a_time + b_time > K:
        if b_i == 0:
            end_flag = True
            break
        b_time -= B[b_i]
        b_i -= 1

    if end_flag == True:
        break
    if a_i + b_i > best:
        best = a_i + b_i

print(best)