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

Fixed submission:
import itertools
import math
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = 0
count = 0
i = 1
while d <= x and i <= n:
    d = d + l[i - 1]
    count += 1
    i += 1
if d <= x:
    count += 1

print(count)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = 0
count = 0
i = 1
while d <= x:
    d = d + l[i - 1]
    count += 1
    if i <= n - 1
        i += 1

print(count)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = 0
count = 0
i = 1
while d <= x:
    d = d + l[i - 1]
    count += 1
    i += 1

print(count)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = 0
count = 0
i = 2
while d <= x:
    d = d + l[i - 2]
    count += 1
    i += 1

print(count)
Problem p03085 (python)

Fixed submission:
b = input()
if b =='A': print('T')
if b == 'T': print('A')
if b == 'C': print('G')
if b == 'G': print('C')

Buggy submission (verdict: Runtime Error):
b = input()
if b ='A': print('T')
if b = 'T': print('A')
if b = 'C': print('G')
if b = 'G': print('C')
Problem p03086 (python)

Fixed submission:
s = input()
temp = []
maximum = 0
count =0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
            count +=1
            maximum = max(maximum,count)
    else:
        count = 0

print(maximum)

Buggy submission (verdict: Runtime Error):
s = input()
temp = []
count = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        count += 1
    else:
        temp.append(count)
        count = 0
print(max(temp))
Problem p03244 (python)

Fixed submission:
import itertools
import math
import fractions
import functools
l = [0]*(10**5+10)
r = [0]*(10**5+10)

n = int(input())
v = list(map(int, input().split()))

for i in range(n):
    if i % 2 == 0:
        l[v[i]] += 1
    else:
        r[v[i]] += 1

max_l = l.index(max(l))
max_r = r.index(max(r))
count = 0

if max_l == max_r:
    for i in range(len(r)):
        if r[i] == r[max_r]:
            r[i] = 0
        if l[i] == l[max_l]:
            l[i] = 0
if max(l) > max(r):
    max_l = l.index(max(l))
else:
    max_r = r.index(max(r))

for i in range(n):
    if i % 2 == 0 and v[i] != max_l:
        count += 1
    if i % 2 != 0 and v[i] != max_r:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    # n, k = map(int, input().split())
    v = list(map(int, input().split()))
    # s = input()

    even = [0] * (10 ** 5)
    odd = [0] * (10 ** 5)

    for i in range(n):
        if i % 2 == 0:
            even[v[i]] += 1
        else:
            odd[v[i]] += 1

    max_even = even.index(max(even))
    max_odd = odd.index(max(odd))

    if max_even == max_odd:
        even[max_even] = 0
        odd[max_odd] = 0
        if max(even) < max(odd):
            max_odd = odd.index(max(odd))
        else:
            max_even = even.index(max(even))
    ans = 0
    for i in range(n):
        if i % 2 == 0 and max_even != v[i]:
            ans += 1
        if i % 2 != 0 and max_odd != v[i]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    # n, k = map(int, input().split())
    v = list(map(int, input().split()))
    # s = input()

    even = [0] * (10 ** 5)
    odd = [0] * (10 ** 5)

    for i in range(n):
        if i % 2 == 0:
            even[v[i]] += 1
        else:
            odd[v[i]] += 1

    max_even = even.index(max(even))
    max_odd = odd.index(max(odd))

    ans = 0
    if max_even != max_odd:
        ans = n - even[max_even] - odd[max_odd]
    else:
        temp_even = even[max_even]
        temp_odd = odd[max_odd]
        even[max_even] = 0
        odd[max_odd] = 0
        max_even2 = even.index(max(even))
        max_odd2 = odd.index(max(odd))
        if even[max_even2] > odd[max_odd2]:
            ans = n - even[max_even2] - temp_odd
        else:
            ans = n - temp_even - odd[max_odd2]

    print(ans)


if __name__ == '__main__':
    main()
Problem p02641 (python)

Fixed submission:
x,n = map(int,input().split())

p_list = list(map(int,input().split()))

import sys
if n == 0:
    print(x)
else:
    sa_min = 1000000
    for i in range(-110, 210):
        if i not in p_list:
            if sa_min > abs(i - x):
                sa_min = abs(i - x)
                ans = i
    print(ans)

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

p_list = list(map(int,input().split()))
p_list = sorted(p_list)

import sys
if n == 0:
    print(x)
    sys.exit()

sa_min = 1000000
for i in range(1, 101):
    if i not in p_list:
        if sa_min > abs(i - x):
            sa_min = abs(i - x)
            ans = i
print(ans)

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

import sys
if n == 0:
    print(x)
    sys.exit()

p_list = list(map(int,input().split()))

sa_min = 1000000
for i in range(1, 101):
    if i not in p_list:
        if sa_min > abs(i - x):
            sa_min = abs(i - x)
            ans = i
print(ans)
Problem p02720 (python)

Fixed submission:
# solution
k=int(input())

from collections import deque
todo = deque([i for i in range(1, 10)])
count = 0

while len(todo) > 0:
    value = todo.popleft()
    value_digit1 = value % 10
    count += 1
    if count == k:
        print(value)
        break
    if value_digit1==0:
        todo.append(10*value)
        todo.append(10*value+1)
    elif value_digit1==9:
        todo.append(10*value+8)
        todo.append(10*value+9)
    else:
        todo.append(10*value+value_digit1-1)
        todo.append(10*value+value_digit1)
        todo.append(10*value+value_digit1+1)

Buggy submission (verdict: Runtime Error):
# solution
k=int(input())

from collections import deque
todo = deque([i for i in range(1, 10)])
count = 0

while len(todo) > 0:
    value = todo.popleft()
    seen.append(value)
    value_digit1 = value % 10
    count += 1
    if count == k:
        print(value)
        break
    if value_digit1==0:
        todo.append(10*value)
        todo.append(10*value+1)
    elif value_digit1==9:
        todo.append(10*value+8)
        todo.append(10*value+9)
    else:
        todo.append(10*value+value_digit1-1)
        todo.append(10*value+value_digit1)
        todo.append(10*value+value_digit1+1)
Problem p02768 (python)

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

MOD=10**9+7
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

nCa = comb(n,a)
nCb = comb(n,b)

ans = (pow(2,n,MOD) - 1) - nCa - nCb
 
if ans < 0:
    print((ans+MOD)%MOD)
else:
    print(ans%MOD)

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

class ModComb:
    def __init__(self, MAX, mod=10 ** 9 + 7):
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, MAX):
            fac.append(fac[i - 1] * i % mod)
            inv.append(mod - inv[mod % i] * (mod // i) % mod)
            finv.append(finv[i - 1] * inv[i] % mod)
        self.fac, self.finv, self.mod = fac, finv, mod

    def nCk(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        fac, finv, mod = self.fac, self.finv, self.mod
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod


mod = 10 ** 9 + 7
mc = ModComb(1000000, mod=mod) 

minus = (mc.nCk(n, a) % mod) + (mc.nCk(n, b) % mod)

print(((2 ** (n) - 1) - minus) % mod)

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

class ModComb:
    def __init__(self, MAX, mod=10 ** 9 + 7):
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, MAX):
            fac.append(fac[i - 1] * i % mod)
            inv.append(mod - inv[mod % i] * (mod // i) % mod)
            finv.append(finv[i - 1] * inv[i] % mod)
        self.fac, self.finv, self.mod = fac, finv, mod

    def nCk(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        fac, finv, mod = self.fac, self.finv, self.mod
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod


mod = 10 ** 9 + 7
mc = ModComb(1000000, mod=mod) 

minus = (mc.nCk(n, a) % mod) + (mc.nCk(n, b) % mod)

print((2 ** (n) - 1) - minus)
Problem p02786 (python)

Fixed submission:
n=int(input())

def count_attack(hp):
    count = 0        
    if hp == 2 or hp == 3:
        return 3
    else:
        # calculate new hp
        count += 1
        hp_child = hp //2
        count += 2 * count_attack(hp_child)
        return count

if n == 1:
    print(1)
else:
    print(count_attack(n))

Buggy submission (verdict: Runtime Error):
n=int(input())

def count_attack(hp):
    count = 0
    if hp == 2 or hp == 3:
        return 3
    else:
        # calculate new hp
        count += 1
        hp_child = hp //2
        count += 2 * count_attack(hp_child)
        return count

print(count_attack(n))
Problem p02936 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import collections
n,q = map(int,input().split())
a_b_list = [list(map(int,input().split())) for i in range(n-1)]
p_x_list = [list(map(int,input().split())) for i in range(q)]

graph_direct_list = [[] for _ in range(n+1)]
for i in range(n-1):
    a_i = a_b_list[i][0]
    b_i = a_b_list[i][1]
    graph_direct_list[a_i].append(b_i)
    graph_direct_list[b_i].append(a_i)

counter_init_list = [0 for _ in range(n+1)]


for j in range(q):
    p_j = p_x_list[j][0]
    x_j = p_x_list[j][1]
    counter_init_list[p_j] += x_j

counter_list = [0 for _ in range(n+1)]
graph_vertex_checked_list = [0 for _ in range(n+1)]


graph_vertex_stack_que=collections.deque()
graph_vertex_stack_que.append(1) # start
while graph_vertex_stack_que:
    v = graph_vertex_stack_que.pop()
    graph_vertex_checked_list[v] = 1
    counter_list[v] += counter_init_list[v]
    for u in graph_direct_list[v]:
        if graph_vertex_checked_list[u] == 1:
            continue
        counter_list[u] += counter_list[v]
        graph_vertex_stack_que.append(u)
print(*counter_list[1:])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n,q = map(int,input().split())
a_b_list = [list(map(int,input().split())) for i in range(n-1)]
p_x_list = [list(map(int,input().split())) for i in range(q)]

graph_direct_list = [[] for _ in range(n+1)]
for i in range(n-1):
    a_i = a_b_list[i][0]
    b_i = a_b_list[i][1]
    graph_direct_list[a_i].append(b_i)
    graph_direct_list[b_i].append(a_i)

counter_init_list = [0 for _ in range(n+1)]


for j in range(q):
    p_j = p_x_list[j][0]
    x_j = p_x_list[j][1]
    counter_init_list[p_j] += x_j

counter_list = [0 for _ in range(n+1)]
graph_vertex_checked_list = [0 for _ in range(n+1)]


graph_vertex_stack_que=collections.deque()
graph_vertex_stack_que.append(1) # start
while graph_vertex_stack_que:
    v = graph_vertex_stack_que.pop()
    graph_vertex_checked_list[v] = 1
    counter_list[v] += counter_init_list[v]
    for u in graph_direct_list[v]:
        if graph_vertex_checked_list[u] == 1:
            continue
        counter_list[u] += counter_list[v]
        graph_vertex_stack_que.append(u)
print(*counter_list[1:])
Problem p03160 (python)

Fixed submission:
n = int(input())
h_list = list(map(int,input().split()))
cost_min_list = [0] * n
cost_min_list[0] = 0
cost_min_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, n):
    cost_min_list[i] = min(cost_min_list[i - 1] + abs(h_list[i] - h_list[i - 1]),
                           cost_min_list[i - 2] + abs(h_list[i] - h_list[i - 2]))
print(cost_min_list[n - 1])

Buggy submission (verdict: Runtime Error):
n = int(input())
h_list = list(map(int,input().split()))
cost_min_list = [0] * n
cost_min_list[0] = 0
cost_min_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, n):
    cost_min_list[i] = min(cost_min_list[i - 1] + abs(h_list[i] - h_list[i - 1]),
                           cost_min_list[i - 2] + abs(h_list[i] - h_list[i - 2]))
print(cost_min_list[n])

Buggy submission (verdict: Runtime Error):
n = int(input())
h_list = list(map(int,input().split()))
cost_min_list = [0] * n
cost_min_list[0] = 0
cost_min_list[1] = h_list[0]
for i in range(2, n):
    cost_min_list[i] = min(cost_min_list[i - 1] + abs(h_list[i] - h_list[i - 1]),
                           cost_min_list[i - 2] + abs(h_list[i] - h_list[i - 2]))
print(cost_min_list[n])
Problem p03246 (python)

Fixed submission:
n=int(input())
v_list = list(map(int,input().split()))
odd_list = []
even_list = []

for i in range(n):
    if i % 2 == 0:
        odd_list.append(v_list[i]) 
    else:
        even_list.append(v_list[i])

import collections

odd_list_c = collections.Counter(odd_list)
even_list_c = collections.Counter(even_list)

if odd_list_c.most_common()[0][0] != even_list_c.most_common()[0][0]:
    ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[0][1]
else:
    if len(even_list_c) == 1 and len(odd_list_c) == 1:
        ans = n // 2
    else: 
        ans1 = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[1][1]
        ans2 = n - odd_list_c.most_common()[1][1] - even_list_c.most_common()[0][1]
        ans = min(ans1, ans2)

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
v_list = list(map(int,input().split()))
odd_list = []
even_list = []

for i in range(n):
    if i % 2 == 0:
        odd_list.append(v_list[i]) 
    else:
        even_list.append(v_list[i])

import collections

odd_list_c = collections.Counter(odd_list)
even_list_c = collections.Counter(even_list)

if odd_list_c.most_common()[0][0] != even_list_c.most_common()[0][0]:
    ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[0][1]
else:
    if len(even_list_c) == 1 && len(odd_list_c) == 1:
        ans = n // 2
    else: 
        if odd_list_c.most_common()[0][1] >= even_list_c.most_common()[0][1]:
            ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[1][1]
        elif odd_list_c.most_common()[0][1] < even_list_c.most_common()[0][1]:
            ans = n - odd_list_c.most_common()[1][1] - even_list_c.most_common()[0][1]

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
v_list = list(map(int,input().split()))
odd_list = []
even_list = []

for i in range(n):
    if i % 2 == 0:
        odd_list.append(v_list[i]) 
    else:
        even_list.append(v_list[i])

import collections

odd_list_c = collections.Counter(odd_list)
even_list_c = collections.Counter(even_list)

if odd_list_c.most_common()[0][0] != even_list_c.most_common()[0][0]:
    ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[0][1]
else:
    if odd_list_c.most_common()[0][1] >= even_list_c.most_common()[0][1]:
        ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[1][1]
    else:
        ans = n - odd_list_c.most_common()[1][1] - even_list_c.most_common()[0][1]

print(ans)
Problem p03471 (python)

Fixed submission:
n,y = map(int,input().split())
import sys
for a in range(n+1):
    for b in range(n-a+1):
        c=n-a-b
        if 10000*a+5000*b+1000*c==y:
            print(a, b, c)
            sys.exit()
print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
n,y = map(int,input().split())
for a in range(n+1):
    for b in range(n-b+1):
        c=n-a-b
        if 10000*a+5000*b+1000*c==y:
            print(a, b, c)
            exit()
print("-1 -1 -1")
Problem p03494 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
# スペース区切りの整数の入力
a_list = list(input().split())

count = 10000000

for i in range(len(a_list)):
    a_tmp = int(a_list[i])
    count_tmp = 0
    while int(a_tmp) % 2 == 0:
        a_tmp /= 2
        count_tmp += 1
    if count > count_tmp:
        count = count_tmp
print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
# スペース区切りの整数の入力
a_list = list(input())

count = 10000000

for i in range(len(a_list)):
    a_tmp = int(a_list[i])
    count_tmp = 0
    while int(a_tmp) % 2 == 0:
        a_tmp /= 2
        count_tmp += 1
    if count > count_tmp:
        count = count_tmp
print(count)
Problem p03545 (python)

Fixed submission:
n_str = input()

op_count = len(n_str) - 1  # すき間の個数
for i in range(2 ** op_count):
    op_list = ["-"] * op_count    # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_count):    # iの右からj+1番目のbitが1かどうかを確認
        if ((i >> j) & 1):
            op_list[len(op_list) - 1 -j] = "+"

    op_list.append("")
    formula = ""
    for i in range(len(n_str)):
        formula += (n_str[i] + op_list[i])
    if eval(formula) == 7:
        print(formula + "=7")
        break

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

op_count = len(n) - 1  # すき間の個数
for i in range(2 ** op_count):
    op_list = ["-"] * op_count    # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_count):    # iの右からj+1番目のbitが1かどうかを確認
        if ((i >> j) & 1):
            op_list[len(op_list) - 1 -j] = "+"

    op_list.append("")
    formula = ""
    for i in range(len(n_str)):
        formula += (n_str[i] + op_list[i])
    if eval(formula) == 7:
        print(formula + "=7")
        break
Problem p02553 (python)

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

print(max(a * c, a * d, b * c, b * d))

Buggy submission (verdict: Runtime Error):
N = int(input())
INF = 10 ** 9
y_min_pos = [INF, []]
x_min_pos = [INF, []]
y_max_pos = [0, []]
x_max_pos = [0, []]
for _ in range(N):
    # print(x_min_pos, y_min_pos, y_max_pos, x_max_pos)
    x, y = map(int, input().split())
    if y <= y_min_pos[0]:
        if y == y_min_pos[0]:
            y_min_pos[1].append(x)
        else:
            y_min_pos = [y, [x]]
    if y >= y_max_pos[0]:
        if y == y_max_pos[0]:
            y_max_pos[1].append(x)
        else:
            y_max_pos = [y, [x]]

    if x <= x_min_pos[0]:
        if x == x_min_pos[0]:
            x_min_pos[1].append(y)
        else:
            x_min_pos = [x, [y]]
    if x >= x_max_pos[0]:
        if x == x_max_pos[0]:
            x_max_pos[1].append(y)
        else:
            x_max_pos = [x, [y]]
# print(x_max_pos[1])
x_min_ymax = max(x_min_pos[1])
x_max_ymax = max(x_max_pos[1])
y_min_xmax = max(y_min_pos[1])
y_max_xmax = max(y_max_pos[1])
x_min_ymin = min(x_min_pos[1])
x_max_ymin = min(x_max_pos[1])
y_min_xmin = min(y_min_pos[1])
y_max_xmin = min(y_max_pos[1])

y_min_max = max(
    abs(y_min_xmax - x_min_pos[0]) + abs(y_min_pos[0] - x_min_ymax),
    abs(y_min_xmax - y_max_xmin) + abs(y_min_pos[0] - y_max_pos[0]),
    abs(y_min_xmin - x_max_pos[0]) + abs(y_min_pos[0] - x_max_ymax),
    abs(y_min_xmin - y_max_xmax) + abs(y_min_pos[0] - y_max_pos[0]),
)
y_max_max = max(
    abs(y_max_xmax - x_min_pos[0]) + abs(y_max_pos[0] - x_min_ymin),
    abs(y_max_xmax - y_min_xmin) + abs(y_max_pos[0] - y_min_pos[0]),
    abs(y_max_xmin - x_max_pos[0]) + abs(y_max_pos[0] - x_max_ymin),
    abs(y_max_xmin - y_max_xmax) + abs(y_max_pos[0] - y_min_pos[0]),
)
x_min_max = max(
    abs(x_min_ymax - y_min_pos[0]) + abs(x_min_pos[0] - y_min_xmax),
    abs(x_min_ymax - x_max_ymin) + abs(x_min_pos[0] - x_max_pos[0]),
    abs(x_min_ymin - y_max_pos[0]) + abs(x_min_pos[0] - y_max_xmax),
    abs(x_min_ymin - x_max_ymax) + abs(x_min_pos[0] - x_max_pos[0]),
)
x_max_max = max(
    abs(x_max_ymax - y_min_pos[0]) + abs(x_max_pos[0] - y_min_xmin),
    abs(x_max_ymax - x_min_ymin) + abs(x_max_pos[0] - x_min_pos[0]),
    abs(x_max_ymin - y_max_pos[0]) + abs(x_max_pos[0] - y_max_xmin),
    abs(x_max_ymin - x_min_ymax) + abs(x_max_pos[0] - x_min_pos[0]),
)
print(max(y_min_max, y_max_max, x_min_max, x_max_max))
Problem p02683 (python)

Fixed submission:
def list_add(li1, li2):
    return list(map(sum, zip(li1, li2)))


def dfs(price, knowledge, depth):
    if (min(knowledge) >= X):
        ansList.append(price)
    if depth == N:
        return
    dfs(price, knowledge, depth + 1)
    dfs(price+priceList[depth], list_add(KnowList[depth], knowledge), depth+1)


N, M, X = map(int, input().split(" "))
KnowList = [[] for i in range(N)]
priceList = [0] * N
for i in range(N):
    tmp = [int(i) for i in input().split(" ")]
    priceList[i] = tmp[0]
    KnowList[i] = tmp[1:]
price = 0
ansList = []
knowledge = [0] * M
dfs(price, knowledge, 0)
if (len(ansList) == 0):
    ansList.append(-1)
print(min(ansList))

Buggy submission (verdict: Runtime Error):
def list_add(li1, li2):
    return list(map(sum,zip(li1,li2)))
N, M, X = map(int, input().split(" "))
list = []
for i in range(N):
    list.append([int(i) for i in input().split(" ")])
list.sort()
price = 0
knowledge = []
priceList = []
for i in range(N):
    price = price + list[i][0]
    if i == 0:
        knowledge = list[0][1: M + 1]
    else:
        tmp2 = [x + y for (x, y) in zip(knowledge, list[i][1:M+1])]
        knowledge = tmp2
    # 全部足しても足りないとき
    if i == N - 1 and min(knowledge) < X:
        print(-1)
        exit()
    # 目標を超えたとき
    if min(knowledge) >= X:
        for j in range(i, -1, -1):
            searchList = [x - y for (x, y) in zip(knowledge, list[j][1: M + 1])]
            if min(searchList) >= X:
                knowledge = searchList
                price = price - list[j][0]
        break
for i in range(N):
    if min(list[i][1: M + 1]) >= X and min(priceList) > list[i][0]:
        print(list[i][0])
        exit()
print(price)

Buggy submission (verdict: Runtime Error):
def list_add(li1, li2):
    return list(map(sum,zip(li1,li2)))
N, M, X = map(int, input().split(" "))
list = []
for i in range(N):
    list.append([int(i) for i in input().split(" ")])
list.sort()
price = 0
knowledge = []
priceList = []
flag = True
for i in range(N):
    if flag:
        price = price + list[i][0]
        if i == 0:
            knowledge = list[0][1: M + 1]
        else:
            tmp2 = [x + y for (x, y) in zip(knowledge, list[i][1:M+1])]
            knowledge = tmp2
        # 全部足しても足りないとき
        if i == N - 1 and min(knowledge) < X:
            print(-1)
            exit()
        # 目標を超えたとき
        if min(knowledge) >= X and flag:
            for j in range(i, -1, -1):
                searchList = [x - y for (x, y) in zip(knowledge, list[j][1: M + 1])]
                if min(searchList) >= X:
                    knowledge = searchList
                    price = price - list[j][0]
            flag = False
for i in range(N):
    if min(list[i][1: M + 1]) >= X and min(priceList) > list[i][0]:
        print(list[i][0])
        exit()
print(price)