Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02762 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2**20)
n, m, k = map(int, input().split())
ab = []
for _ in range(m):
    ab.append([int(x)-1 for x in input().split()])
cd = []
for _ in range(k):
    cd.append([int(x)-1 for x in input().split()])
group = [-1 for _ in range(n)]
lis = [[] for _ in range(n)]
for x in ab:
    a = x[0]
    b = x[1]
    lis[a].append(b)
    lis[b].append(a)
g_n = 0
def dfs(now):
    global g_n
    group[now] = g_n
    global group_len_n
    group_len_n += 1
    for i in lis[now]:
        if group[i] == -1:
            dfs(i)
group_len = []
for i in range(n):
    if group[i] == -1:
        group_len_n = 0
        dfs(i)
        group_len.append(group_len_n)
        g_n += 1
friend = [0 for _ in range(n)]
block = [0 for _ in range(n)]
for x in ab:
    a = x[0]
    b = x[1]
    if group[a] == group[b]:
        friend[a] += 1
        friend[b] += 1
for x in cd:
    c = x[0]
    d = x[1]
    if group[c] == group[d]:
        block[c] += 1
        block[d] += 1
ans = []
for i in range(n):
    ans.append(str(group_len[group[i]] - friend[i] - block[i] -1))
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
ab = []
for _ in range(m):
    ab.append([int(x)-1 for x in input().split()])
cd = []
for _ in range(k):
    cd.append([int(x)-1 for x in input().split()])
group = [-1 for _ in range(n)]
lis = [[] for _ in range(n)]
for x in ab:
    a = x[0]
    b = x[1]
    lis[a].append(b)
    lis[b].append(a)
g_n = 0
def dfs(now):
    global g_n
    group[now] = g_n
    global group_len_n
    group_len_n += 1
    for i in lis[now]:
        if group[i] == -1:
            dfs(i)
group_len = []
for i in range(n):
    if group[i] == -1:
        group_len_n = 0
        dfs(i)
        group_len.append(group_len_n)
        g_n += 1
friend = [0 for _ in range(n)]
block = [0 for _ in range(n)]
for x in ab:
    a = x[0]
    b = x[1]
    if group[a] == group[b]:
        friend[a] += 1
        friend[b] += 1
for x in cd:
    c = x[0]
    d = x[1]
    if group[c] == group[d]:
        block[c] += 1
        block[d] += 1
ans = []
for i in range(n):
    ans.append(str(group_len[group[i]] - friend[i] - block[i] -1))
print(" ".join(ans))
Problem p03221 (python)

Fixed submission:
N, M =map(int, input().split())
ls = []
pcount =[]
for i in range(N):
    pcount.append(0)
for i in range(M):
    p, y = map(int, input().split())
    ls.append([i, p, y])
ls.sort(key = lambda x:x[2])

for l in ls:
    pcount[l[1]-1] += 1
    l.append(pcount[l[1]-1])
ls.sort(key = lambda x:x[0])
for l in ls:
    print(str(l[1]).zfill(6) + str(l[3]).zfill(6))

Buggy submission (verdict: Runtime Error):
N, M =map(int, input().split())
Ps =[]
Ys =[]
dic = {}
for i in range(M):
    p, y = map(int, input().split())
    Ps.append(p)
    Ys.append(y)
    ls = dic.get(p, [])
    ls.append(y)
for p in Ps:
    ls = dic[p]
    ls.sort()
    dic[p] = ls
for i in range(M):
    p = Ps[i]
    y = Ys[i]
    number = dic[p].index(y) + 1
    strp = str(p)
    strn = str(number)
    print(strp.zfill(6) + strn.zfill(6))

Buggy submission (verdict: Runtime Error):
N, M =map(int, input().split())
Ps =[]
Ys =[]
dic = {}
for i in range(M):
    p, y = map(int, input().split())
    Ps.append(p)
    Ys.append(y)
    ls = dic.get(p, [])
    ls.append(y)
    dic[p] = ls.sort()
for i in range(M):
    p = Ps[i]
    y = Ys[i]
    number = dic[p].index(y) + 1
    strp = str(p)
    strn = str(number)
    print(strp.zfill(6) + strn.zfill(6))
Problem p03250 (python)

Fixed submission:
A, B, C = map(int, input().split())
s = max([10*A+B+C, A +10*B + C, A + B + 10*C])
print(s)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
def factor(n):
    for i in range(2, int(n)):
        if n%i == 0:
            return(i)
            break
    else:
        return(int(n))
M2 = M
dic = {}
flag = True
while flag:
    p = factor(M2)
    dic[p] = dic.get(p, 0) + 1
    M2 = M2/p
    if M2 ==1:
        flag = False

def comb(n, r):
    s = 1
    for i in range(1, r+1):
        s *= (n-r+i)/i
    return(int(s%(10**9+7)))
s = 1
print(dic)
for value in dic.values():
    s *= int(comb(value+N-1, value)%(10**9+7))
print(s%(1e9+7))

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
alphs = "abcdefghijklmnopqrstuvwxyz"
flag = False
for alph in alphs:
    S2 = S
    indlist = []
    while alph in S2:
        i = S.index(alph)
        indlist.append(i)
        S2 = S2[i+1:]
    if indlist != []:
        T2 = T[indlist[0]]
    for ind in indlist:
        if T[ind] != T2:
            print("No")
            flag = True
            break
    if flag:
        break
else:
    for alph in alphs:
        T3 = T
        indlist = []
        while alph in T3:
            i = T.index(alph)
            indlist.append(i)
            T3 = T3[i+1:]
        if indlist != []:
            S3 = S[indlist[0]]
        for ind in indlist:
            if S[ind] != T3:
                print("No")
                flag = True
                break
        if flag:
            break
    else:
        print("Yes")
Problem p02572 (python)

Fixed submission:
n = int(input())
li = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(1, n):
    ans += li[0]*li[i]

check = ans
for i in range(1, n):
    if li[i-1] == 0:
        continue
    check -= li[i] * li[i-1]
    check //= li[i-1]
    check *= li[i]
    ans += check
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(1, n):
    ans += li[0]*li[i]

check = ans%mod
for i in range(1, n):
    check -= li[i] * li[i-1]
    if check < 0:
        check += 10**9 + 7
    check //= li[i-1]
    check *= li[i]
    ans += check
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(1, n):
    ans += li[0]*li[i]

check = ans
for i in range(1, n):
    check -= li[i] * li[i-1]
    if check < 0:
        check += 10**9 + 7
    check //= li[i-1]
    check *= li[i]
    ans += check
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(1, n):
    ans += li[0]*li[i]
    check = ans

check = ans
for i in range(1, n):
    check -= li[i] * li[i-1]
    check /= li[i-1]
    check *= li[i]
    ans += check
    ans %= mod

print(int(ans))
Problem p02580 (python)

Fixed submission:
import collections

h, w, m = map(int, input().split())
h_li = []
w_li = []

for i in range(m):
    _h, _w = map(int,input().split())
    h_li.append(_h)
    w_li.append(_w)

h_bomb = [0] * (h+1)
w_bomb = [0] * (w+1)

h_counter = collections.Counter(h_li)
w_counter = collections.Counter(w_li)

for i in range(1, h+1):
    h_bomb[i] = h_counter.get(i, 0)

for i in range(1, w+1):
    w_bomb[i] = w_counter.get(i, 0)
    
ans = max(h_bomb) + max(w_bomb)
allow_count = h_bomb.count(max(h_bomb)) * w_bomb.count(max(w_bomb))

s = 0
cnt = 0
for i in range(m):
    _h, _w = h_li[i], w_li[i]
    if h_bomb[_h] + w_bomb[_w] == ans:
        cnt += 1
    
if cnt < allow_count:
    print(ans)
else:
    print(ans-1)

Buggy submission (verdict: Runtime Error):
import numpy as np

h, w, m = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(m)]

check = np.zeros((h, w)).astype(np.uint16)

for i,j in li:
    check[i-1, :] += 1
    check[:, j-1] += 1
    check[i-1, j-1] -= 1

print(int(np.max(check)))

Buggy submission (verdict: Runtime Error):
import numpy as np

h, w, m = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(m)]

check = np.zeros((h, w))

for i,j in li:
    check[i-1, :] += 1
    check[:, j-1] += 1
    check[i-1, j-1] -= 1

print(int(np.max(check)))

Buggy submission (verdict: Runtime Error):
import numpy as np

h, w, m = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(m)]

check = np.zeros((h, w))

for i,j in li:
    check[i-1, :] += 1
    check[:, j-1] += 1
    check[i-1, j-1] -= 1

idx = np.unravel_index(np.argmax(check), check.shape)
print(int(check[idx[0]][idx[1]]))
Problem p02623 (python)

Fixed submission:
n,m,k = map(int, input().split())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))

a_li = [0] + a_li
b_li = [0] + b_li

time = 0
ans = 0
a = 0
temp = 0

a_wa = [0] * (n+10)
b_wa = [0] * (m+10)

s = 0
for i in range(n+1):
    s += a_li[i]
    a_wa[i] = s

s = 0
for i in range(m+1):
    s += b_li[i]
    b_wa[i] = s
    

for i in range(n+1):
    for j in range(max(min(temp-i, m), 0), m+1):
        time = a_wa[i] + b_wa[j]
        if time <= k:
            ans = max(ans, i+j)
            temp = ans
        else:
            break
            
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int, input().split())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))

a_li = [0] + a_li
b_li = [0] + b_li

time = 0
ans = 0
a = 0
temp = 0

a_wa = [0] * (n+10)
b_wa = [0] * (m+10)

s = 0
for i in range(n+1):
    s += a_li[i]
    a_wa[i] = s

s = 0
for i in range(m+1):
    s += b_li[i]
    b_wa[i] = s
    

for i in range(n+1):
    for j in range(min(temp-i, m), m+1):
        time = a_wa[i] + b_wa[j]
        if time <= k:
            ans = max(ans, i+j)
            temp = ans
        else:
            break
            
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int, input().split())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))

a_li = [0] + a_li
b_li = [0] + b_li

time = 0
ans = 0
a = 0
temp = 0

a_wa = [0] * (n+10)
b_wa = [0] * (m+10)

s = 0
for i in range(n+1):
    s += a_li[i]
    a_wa[i] = s

s = 0
for i in range(m+1):
    s += b_li[i]
    b_wa[i] = s
    

for i in range(n+1):
    for j in range(min(ans-i-1, m), m+1):
        time = a_wa[i] + b_wa[j]
        if time <= k:
            ans = max(ans, i+j)
        else:
            break
            
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int, input().split())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))

a_li = [0] + a_li
b_li = [0] + b_li

time = 0
ans = 0
a = 0
temp = 0

a_wa = [0] * (n+10)
b_wa = [0] * (m+10)

s = 0
for i in range(n+1):
    s += a_li[i]
    a_wa[i] = s

s = 0
for i in range(m+1):
    s += b_li[i]
    b_wa[i] = s
    

for i in range(n+1):
    for j in range(min(ans-i, m), m+1):
        time = a_wa[i] + b_wa[j]
        if time <= k:
            ans = max(ans, i+j)
        else:
            break
            
print(ans)
Problem p02831 (python)

Fixed submission:
a, b = map(int,input().split())

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
    
print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int,input().split())

def lcm(a,b):
    return (a*b) // math.gcd(a, b)
    
print(lcm(a,b))
Problem p02862 (python)

Fixed submission:
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
    
x,y = map(int,input().split())


if (x+y)%3 != 0 or not(x <= 2*y and y <= 2*x):
    print(0)
    exit()
else:
    s = (x+y)//3
 
t = min((x-s),(y-s))

print(combination(s,t))

Buggy submission (verdict: Runtime Error):
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
    
x,y = map(int,input().split())


if (x+y)%3 != 0 or not(X <= 2*Y and Y <= 2*X):
    print(0)
    exit()
else:
    s = (x+y)//3
 
t = min((x-s),(y-s))

print(combination(s,t))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

x,y = map(int,input().split())
mod = 10**9 + 7

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return (over // under)

if (x+y)%3 != 0:
    print(0)
    exit()
else:
    s = (x+y)//3

t = min((x-s),(y-s))


print(cmb(s,t)%mod)
Problem p02897 (python)

Fixed submission:
n = int(input())

if n%2 == 0:
    print(0.5)
else:
    print(1-(n-1)/2/n)

Buggy submission (verdict: Runtime Error):
n = int(input())
 
if n%2 == 0:
    print(0.5)    #整数Nが偶数のとき
else:
    s = (n-1)/2    #偶数の数を確認
    s /= n　　　#nで割って偶数の確率を求める
    print(1-s)    #全体から偶数の確率を引いて奇数の確率を求める

Buggy submission (verdict: Runtime Error):
n = int(input())
 
if n%2 == 0:
    print(0.5)   
else:
    s = (n-1)/2   
    s /= n　　　
print(1-s)

Buggy submission (verdict: Runtime Error):
n = int(input())
 
if n%2 == 0:
    print(0.5)   
else:
    s = (n-1)/2   
    s /= n　　　
    print(1-s)
Problem p02925 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
N = int(input())
A = [[-1] + [int(x)-1 for x in row.split()][::-1] for row in sys.stdin.readlines()]
 
A.append([-1])

def f(cand):
    cand1 = set()
    can_use = []
    for n in cand:
        if A[A[n][-1]][-1] == n:
            can_use.append(n)
    for n in can_use:
        A[n].pop()
        cand1.add(n)
        if A[n][-1] != -1:
            cand1.add(A[n][-1])
    return len(can_use), cand1
    
answer = 0
rest = N*(N-1)
cand = set(range(N))
while True:
    answer += 1
    x,cand = f(cand)
    if x == 0:
        answer = -1
        break
    rest -= x
    if rest == 0:
        break
    
print(answer)

Buggy submission (verdict: Runtime Error):
n = int(input())
li =[list(map(int,input().split())) for i in range(1,n+1)]

cnt = 0
check = []
kouho = [i for i in range(1,n+1)]
play = 0

while play < n*(n-1) // 2:
    s = play
    for i in kouho:
        if i in check or len(li[i-1]) == 0:
            continue
        temp = li[i-1][0]
        if li[temp-1][0] == i and temp not in check:
            del li[i-1][0]
            del li[temp-1][0]
            play += 1
            check.append(i)
            check.append(temp)
    cnt += 1
    kouho = check.copy()
    check = []
    
    if s == play:
        print(-1)
        exit()

print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
li =[list(map(int,input().split())) for i in range(1,n+1)]

cnt = 0
check = []
kouho = list(range(1,n+1))
play = 0

while play < n*(n-1) // 2:
    s = play
    for i in kouho:
        if i in check or len(li[i-1]) == 0:
            continue
        temp = li[i-1][0]
        if li[temp-1][0] == i and temp not in check:
            del li[i-1][0]
            del li[temp-1][0]
            play += 1
            check.append(i)
            check.append(temp)
    cnt += 1
    kouho = check.copy()
    check = []
    
    if s == play:
        print(-1)
        exit()

print(cnt)
Problem p02990 (python)

Fixed submission:
import math

def combination_count(n,k):
    if k < 0 or k > n:
        return 0
    if n == 0 or k == 0:
        return 1
    
    s = math.factorial(n)
    t = math.factorial(k)
    u = math.factorial(n-k)
    
    return s//(t*u) 
    
n,k = map(int,input().split())
mod = 10**9 + 7

for i in range(1,k+1):
    x = combination_count(n-k+1, i) 
    y = combination_count(k-1, i-1)
    z = (x*y) % mod
    print(z)

Buggy submission (verdict: Runtime Error):
import math

def combination_count(n,k):
    s = math.factorial(n)
    t = math.factorial(k)
    u = math.factorial(n-k)
    
    return s//(t*u)
    
n,k = map(int,input().split())
mod = 10**9 + 7

for i in range(1,k+1):
    x = combination_count(n-k+1, i) 
    y = combination_count(k-1, i-1)
    z = (x*y) % mod
    print(z)

Buggy submission (verdict: Runtime Error):
import math

def combination_count(n,k):
    s = math.factorial(n)
    t = math.factorial(k)
    u = math.factorial(n-k)
    
    return s//(t*u)
    
n,k = map(int,input().split())

for i in range(1,k+1):
    print(combination_count(n-k+1, i) * combination_count(k-1, i-1) % (10**9 +7))
Problem p03042 (python)

Fixed submission:
s = input()

x = int(s[0:2])
y = int(s[2:])

if x > 12:
    if y > 12:
        print("NA")
    elif y >= 1:
        print("YYMM")
    else:
        print("NA")
elif x >= 1:
    if y > 12:
        print("MMYY")
    elif y >= 1:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if y > 12:
        print("NA")
    if y >= 1:
        print("YYMM")
    else:
        print("NA")

Buggy submission (verdict: Runtime Error):
s = input()

x = int(s[0:2])
y = int(s[3:])

if x > 12:
    if y > 12:
        print("NA")
    elif y >= 1:
        print("YYMM")
    else:
        print("NA")
elif x >= 1
    if y > 12:
        print("MMYY")
    elif y >= 1:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if y > 12:
        print("NA")
    if y >= 1:
        print("YYMM")
    else:
        print("NA")
Problem p03127 (python)

Fixed submission:
n = int(input())
li = list(map(int,input().split()))
ans = li[0]

def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

for i in range(1,n):
    ans = gcd(ans,li[i])

print(ans)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
li = list(map(int,input().split()))
ans = li[0]

for i in range(1,n):
    ans = math.gcd(ans,li[i])

print(ans)
Problem p03785 (python)

Fixed submission:
n, c, k = map(int, input().split())
from collections import deque

t = [int(input()) for _ in range(n)]
t.sort()
t=deque(t)

ans = 1
bus=t[0]+k
cnt = 0

while t:
    i=t.popleft()
    if i>bus:
        bus=i+k
        ans+=1
        cnt=1
    elif cnt==c:
        bus=i+k
        ans+=1
        cnt=1
    else:
        cnt+=1

print(ans)

Buggy submission (verdict: Runtime Error):
n, c, k = map(int, input().split())

check = [0] * (n+10)

for i in range(n):
    check[int(input())] += 1

wait = False
time_cnt = 0
people_cnt = 0
ans = 0

for i in range(len(check)):
    if wait == False:
        if check[i] > 0:
            wait = True
            people_cnt += check[i]
            time_cnt = 1
            continue
        else:
            continue
        
    if people_cnt > c:
        ans += people_cnt//c
        people_cnt = people_cnt%c
        time_cnt = 1
        
    
    if time_cnt > k:
        ans += 1
        people_cnt = 0
        time_cnt = 0
        wait = False
    
    people_cnt += check[i]
    time_cnt += 1
else:
    if people_cnt > 0:
        ans += people_cnt//c
    if people_cnt%c > 0:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]

check = [0] * (n+10)

for i in t:
    check[i] += 1

wait = False
time_cnt = 0
people_cnt = 0
ans = 0

for i in range(len(check)):
    if wait == False:
        if check[i] > 0:
            wait = True
            people_cnt += check[i]
            time_cnt = 1
            continue
        else:
            continue
        
    if people_cnt > c:
        ans += people_cnt//c
        people_cnt = people_cnt%c
        time_cnt = 1
        
    
    if time_cnt > k:
        ans += 1
        people_cnt = 0
        time_cnt = 0
        wait = False
    
    people_cnt += check[i]
    time_cnt += 1
else:
    if people_cnt > 0:
        ans += people_cnt//c
    if people_cnt%c > 0:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]

check = [0] * (n+10)

for i in t:
    check[i] += 1

wait = False
time_cnt = 0
people_cnt = 0
ans = 0

for i in range(len(check)):
    if wait == False:
        if check[i] > 0:
            wait = True
            people_cnt += check[i]
            time_cnt = 1
            continue
        else:
            continue
        
    if people_cnt > c:
        ans += people_cnt//c
        people_cnt = people_cnt%c
        time_cnt = 1
        
    
    if time_cnt > k:
        ans += 1
        people_cnt = 0
        time_cnt = 0
        wait = False
    
    people_cnt += check[i]
    time_cnt += 1
else:
    if people_cnt > 0:
        ans += people_cnt//c
    if people_cnt%c > 0:
        ans += 1

print(ans)
Problem p03804 (python)

Fixed submission:
n,m = map(int,input().split())
li_a = [list(input()) for _ in range(n)]
li_b = [list(input()) for _ in range(m)]


for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if li_a[i+k][j:j+m] != li_b[k][:]:
                break
        else:
            print("Yes")
            exit()
            
print("No")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
li_a = [list(input()) for _ in range(n)]
li_b = [list(input()) for _ in range(m)]


for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if li_a[i+x][j:j+m] != li_b[x][:]:
                break
        else:
            print("Yes")
            exit()
            
print("No")
Problem p02623 (python)

Fixed submission:

import bisect
import numpy

n, m, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

cost_a = numpy.insert(numpy.cumsum(a), 0, 0)
cost_b = numpy.insert(numpy.cumsum(b), 0, 0)

ans = 0
j =  len(cost_b) -1
for i in range(len(cost_a)):
    for j in range(j, -1, -1):
        if cost_a[i] + cost_b[j] <= k:
            ans  = i + j if ans < i + j else ans
            break
print(ans)

Buggy submission (verdict: Runtime Error):

import bisect
import numpy

n, m, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

cost_a = numpy.insert(numpy.cumsum(a), 0, 0)
cost_b = numpy.insert(numpy.cumsum(b), 0, 0)

ans = 0
j =  len(cost_b) -1
for i in range(len(cost_a)):
    for j in range( j, 0, -1):
        if cost_a[i] + cost_b[j] <= k:
            ans  = i + j if ans < i + j else ans
            break
print(ans)
[root@local

Buggy submission (verdict: Runtime Error):

import bisect
import numpy

n, m, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

cost_a = numpy.insert(numpy.cumsum(a), 0, 0)
cost_b = numpy.insert(numpy.cumsum(b), 0, 0)

ans = 0
j =  len(cost_b)
for i in range(len(cost_a)):
    for j in range( j, 0, -1):
        if cost_a[i] + cost_b[j] <= k:
            ans  = i + j if ans < i + j else ans
            break
print(ans)

Buggy submission (verdict: Runtime Error):

import bisect
import numpy

n, m, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

cost_a = numpy.insert(numpy.cumsum(a), 0, 0)
cost_b = numpy.insert(numpy.cumsum(b), 0, 0)

left_max = bisect.bisect_left(cost_a, k)
right_max = bisect.bisect_left(cost_b, k)

ans = 0
j = right_max
for i in range(left_max):
    for j in range(j , -1, -1):
        if cost_a[i] + cost_b[j] <= k:
            ans  = i + j if ans < i + j else ans
            break
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
import numpy

n, m, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

cost_a = numpy.insert(numpy.cumsum(a), 0, 0)
cost_b = numpy.insert(numpy.cumsum(b), 0, 0)

left_max = bisect.bisect_left(cost_a, k) + 1
right_max = bisect.bisect_left(cost_b, k) + 1

ans = 0
j = right_max - 1
for i in range(left_max):
    for j in range(j , -1, -1):
        if cost_a[i] + cost_b[j] <= k:
            ans  = i + j if ans < i + j else ans
            break
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
import numpy

n, m, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

cost_a = numpy.insert(numpy.cumsum(a), 0, 0)
cost_b = numpy.insert(numpy.cumsum(b), 0, 0)

left_max = bisect.bisect_left(cost_a, k)
right_max = bisect.bisect_left(cost_b, k)

ans = 0
for i in range(left_max):
    for j in range(right_max):
        if cost_a[i] + cost_b[j] <= k:
            ans  = i + j if ans < i + j else ans
print(ans)