qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n, m, x = map(int, input().split())
A = [[] for _ in range(n)]
cost = [0] * n
for i in range(n):
  c_as = list(map(int, input().split()))
  cost[i], A[i] = c_as[0], c_as[1:]
INF = 10**9
ans = INF
for s in range(0, 1 << n):
  smart = [0] * m
  cost_sum = 0
  for i in range(n):
    if (s >> i) % 2 == 0:
      continue
    cost_sum += c[i]
    for j in range(m):
      smart[j] += A[i][j]
  ok = True
  for j in range(m):
    if smart[j] < x:
      ok = False
  if ok:
    ans = min(ans, cost_sum)
if ans == INF:
  ans = -1
print(ans)
    

Fixed code:
n, m, x = map(int, input().split())
A = [[] for _ in range(n)]
cost = [0] * n
for i in range(n):
  c_as = list(map(int, input().split()))
  cost[i], A[i] = c_as[0], c_as[1:]
INF = 10**9
ans = INF
for s in range(0, 1 << n):
  smart = [0] * m
  cost_sum = 0
  for i in range(n):
    if (s >> i) % 2 == 0:
      continue
    cost_sum += cost[i]
    for j in range(m):
      smart[j] += A[i][j]
  ok = True
  for j in range(m):
    if smart[j] < x:
      ok = False
  if ok:
    ans = min(ans, cost_sum)
if ans == INF:
  ans = -1
print(ans)
Buggy code:
from itertools import combinations

def main():
    N, M, X = list(map(int, input().split()))

    row = []

    ans = 10 ** 10

    for i in range(N):
        row.append(list(map(int, input().split())))

    for k in range(1, N+1):
        co = list(combinations(row, k))

        for t in co:
            cost = 0
            skill = [0] * M
            for v in t:
                cost += v[0]
                for s in range(M):
                    skill[s] += v[s+1]

            if(min(skill) >= X):
                ans = min(ans, cost)

    if(ans == 10 ** 6):
        ans = -1

    print(ans)


if __name__ == "__main__":
    main()

Fixed code:
from itertools import combinations

def main():
    N, M, X = list(map(int, input().split()))

    row = []

    ans = 10 ** 10

    for i in range(N):
        row.append(list(map(int, input().split())))

    for k in range(1, N+1):
        co = list(combinations(row, k))

        for t in co:
            cost = 0
            skill = [0] * M
            for v in t:
                cost += v[0]
                for s in range(M):
                    skill[s] += v[s+1]

            if(min(skill) >= X):
                ans = min(ans, cost)

    if(ans == 10 ** 10):
        ans = -1

    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
def main()
    n, m, x = map(int, input().split())
    ca = []
    for _ in range(n):
        ca.append(list(map(int, input().split())))
    result = 10**9
    for i in range(1, 2**n+1):
        work = 0
        j = 0
        temp = [0] * m
        for flag in bin(i)[2:].zfill(n):
            if flag == "1":
                work += ca[j][0]
                for k in range(1, m+1):
                    temp[k-1] += ca[j][k]
            j += 1
        flag = True
        for t in temp:
            if t < x:
                flag = False
                break
        if flag:
            result = min(result, work)
    if result == 10**9:
        print(-1)
    else:
        print(result)
main()

Fixed code:
def main():
    n, m, x = map(int, input().split())
    ca = []
    for _ in range(n):
        ca.append(list(map(int, input().split())))
    result = 10**9
    for i in range(1, 2**n+1):
        work = 0
        j = 0
        temp = [0] * m
        for flag in bin(i)[2:].zfill(n):
            if flag == "1":
                work += ca[j][0]
                for k in range(1, m+1):
                    temp[k-1] += ca[j][k]
            j += 1
        flag = True
        for t in temp:
            if t < x:
                flag = False
                break
        if flag:
            result = min(result, work)
    if result == 10**9:
        print(-1)
    else:
        print(result)
main()
Buggy code:
CA = [list(map(int,input().split())) for _ in range(n)]

ans = 10**9

for i in range(2**n):
    ls = [0] * m
    tmp = 0
    for j in range(n):
        if (i >> j) & 1:
            ls = [l + a for l, a in zip(ls, CA[j][1:])]
            tmp += CA[j][0]
    if all(i >= x for i in ls):
        ans = min(ans, tmp)
print(ans if ans != 10**9 else -1)

Fixed code:
n, m, x = map(int,input().split())
CA = [list(map(int,input().split())) for _ in range(n)]

ans = 10**9

for i in range(2**n):
    ls = [0] * m
    tmp = 0
    for j in range(n):
        if (i >> j) & 1:
            ls = [l + a for l, a in zip(ls, CA[j][1:])]
            tmp += CA[j][0]
    if all(i >= x for i in ls):
        ans = min(ans, tmp)
print(ans if ans != 10**9 else -1)
Buggy code:
N,M,X=map(int,input().split())
l=[]
for i in range (N):
  l.append(list(map(int,input().split())))
ans=0
for i in range(2**N):
  score=[0]*M
  coin=0
  for j in range(N):
    if i>=2**(N-1-j):
      for p in range(M):
        score[p]+=l[j][p+1]
        coin+=l[j][0]
      i-=2**(N-1-j)
  flag=0
  for q in range(M):
    if score(q)<X:
      flag=1
  if flag==0:
    if ans<coin:
      ans=coin
print(coin)

Fixed code:
N,M,X=map(int,input().split())
l=[]
for i in range (N):
  l.append(list(map(int,input().split())))
ans=10000000
for i in range(2**N):
  score=[0]*M
  coin=0
  for j in range(N):
    if i>=2**(N-1-j):
      for p in range(M):
        score[p]+=l[j][p+1]
      coin+=l[j][0]
      i-=2**(N-1-j)
  flag=0
  for q in range(M):
    if score[q]<X:
      flag=1
  if flag==0:
    if ans>coin:
      ans=coin
if ans==10000000:
  print("-1")
else:
  print(ans)
Buggy code:
import itertools

N,M,X=map(int,input().split(' '))

book=[]
skil=[0]*M
for i in range(N):
    line=list(map(int,input().split(' ')))
    book.append(line)
    skil=list(map(lambda x,y:x+y,skil,line[1:]))

min_p=1200000
for n in range(1,N+1):
    for conbo in itertools.combinations(book,n):
        conbo_book=[0]*(1+M)
        for b in list(conbo):
            conbo_book=list(map(lambda x,y:x+y,conbo_book,b))
        if len([m for m in conbo_book[1:] if m>=X])==M:
            print(conbo_book)
            if min_p>conbo_book[0]:
                min_p=conbo_book[0]

print(min_p) if min_p<1200000 else print("-1")

Fixed code:
import itertools

N,M,X=map(int,input().split(' '))

book=[]
skil=[0]*M
for i in range(N):
    line=list(map(int,input().split(' ')))
    book.append(line)
    skil=list(map(lambda x,y:x+y,skil,line[1:]))

min_p=12000000
for n in range(1,N+1):
    for conbo in itertools.combinations(book,n):
        conbo_book=[0]*(1+M)
        for b in list(conbo):
            conbo_book=list(map(lambda x,y:x+y,conbo_book,b))
        if len([m for m in conbo_book[1:] if m>=X])==M:
            if min_p>conbo_book[0]:
                min_p=conbo_book[0]

print(min_p) if min_p<12000000 else print("-1")
Buggy code:
import numpy as np
N,M,X = map(int, input().split())
nd_list = np.ones(M)*X

next_list = []
for i in range(0,N):
    next_list.append(list(map(int, input().split())))
next_list = np.array(next_list)
min_tot = 10000000

def dfs(i,ab_list):
    global min_tot
    if i==N and np.all(ab_list[1:]>=nd_list):
        if min_tot > ab_list[0]:
            min_tot = ab_list[0]
        return True
    elif i ==N:
        return True

    dfs(i+1,ab_list)
    dfs(i+1,ab_list+next_list[i,:])


if min_tot ==10000000:
    print(-1)
else:
    print(min_tot)

Fixed code:
import numpy as np
N,M,X = map(int, input().split())
nd_list = np.ones(M)*X

next_list = []
for i in range(0,N):
    next_list.append(list(map(int, input().split())))
next_list = np.array(next_list)
min_tot = 10000000

def dfs(i,ab_list):
    global min_tot
    if i==N and np.all(ab_list[1:]>=nd_list):
        if min_tot > ab_list[0]:
            min_tot = ab_list[0]
        return True
    elif i ==N:
        return True

    dfs(i+1,ab_list)
    dfs(i+1,ab_list+next_list[i,:])


dfs(0,np.zeros(1+M))
if min_tot ==10000000:
    print(-1)
else:
    print(int(min_tot))
Buggy code:
from itertools import product
[N, M, X] = [int(i) for i in input().split()]
bk = [[int(i) for i in input().split()] for _ in range(N)]

ans = 12*10**5
for seq in product(range(2), repeat=N):
    S = [0]*(M+1)
    for i in range(N):
       for j in range(M+1):
           S[j] += seq[i]*bk[i][j]
    print(S, seq)       
    if min(S[1:M+1]) >= X:
        ans = min(ans, S[0]) 

print(ans)

Fixed code:
from itertools import product
[N, M, X] = [int(i) for i in input().split()]
bk = [[int(i) for i in input().split()] for _ in range(N)]

ans = 12*10**5 + 1
for seq in product(range(2), repeat=N):
    S = [0]*(M+1)
    for i in range(N):
       for j in range(M+1):
           S[j] += seq[i]*bk[i][j]     
    if min(S[1:M+1]) >= X:
        ans = min(ans, S[0])

if ans == 12*10**5 + 1:
    print(-1)
else:
    print(ans)
Buggy code:
def resolve():

    n, m,x = map(int, input().split())
    c=[]
    a=[]
    ans=10**13
    nedan=0
    rikai=[0]*m
    for i in range(n):
        A = list(map(int, input().split()))
        c.append(A[0])
        a.append(A[1:])
        for j in range(m):
            rikai[j]+=a[i][j]
    if min(rikai)>=x:
        for Bin in range(2**n):
            N = [str(x) for x in list(str(bin(Bin+2**13)))]
            N.pop(0)
            N.pop(0)
            for hon in range(n):
                if N[hon + 1] == 1:
                    for aru in range(m):
                        rikai[aru]+=a[hon][aru]
                    nedan+=c[hon]
            if min(rikai)>=x:
                ans=min(ans,nedan)
            rikai=[]
            nedan=0
        print(ans)

    else:
        print(-1)
resolve()

Fixed code:
def resolve():

    n, m,x = map(int, input().split())
    c=[]
    a=[]
    ans=10**13
    nedan=0
    rikai=[0]*m
    for i in range(n):
        A = list(map(int, input().split()))
        c.append(A[0])
        a.append(A[1:])
        for j in range(m):
            rikai[j]+=a[i][j]

    if min(rikai)>=x:
        for Bin in range(1,2**n):
            rikai = [0] * m
            nedan = 0
            for hon in range(n):
                if (Bin>>hon) & 1:
                    for aru in range(m):
                        rikai[aru]+=a[hon][aru]
                    nedan+=c[hon]
            if min(rikai)>=x:
                ans=min(ans,nedan)
        print(ans)

    else:
        print(-1)
resolve()
Buggy code:
import itertools
import math
import fractions
import functools

n, m, x = map(int, input().split())


a_do = []
for i in range(n):
    a = list(map(int, input().split()))
    a_do.append(a)


nums = []
for i in range(n):
    nums.append(i)

temp = []
for i in range(1, n+1):
    for v in itertools.combinations(nums, i):
        rikaido = [0] * (m+1)
        for j in range(len(v)):
            for k in range(m+1):
                rikaido[k] += a_do[v[j]][k]

        temp.append(rikaido)

minimum = 10**20
for i in range(len(temp)):
    for j in range(1, m+1):
        if temp[i][j] < x:
            break
        minimum = min(minimum, temp[i][0])

# if(minimum == 10**20):
#     print(-1)
# else:
#     print(minimum)

print(-1)

Fixed code:
import itertools
import math
import fractions
import functools

n, m, x = map(int, input().split())

a_do = []
for i in range(n):
    a = list(map(int, input().split()))
    a_do.append(a)


nums = []
for i in range(n):
    nums.append(i)

temp = []
for i in range(1, n+1):
    for v in itertools.combinations(nums, i):
        rikaido = [0] * (m+1)
        for j in range(len(v)):
            for k in range(m+1):
                rikaido[k] += a_do[v[j]][k]

        temp.append(rikaido)

minimum = 10**20
for i in range(len(temp)):
    ok = True
    for j in range(1, m+1):
        if temp[i][j] < x:
            ok = False
    if(ok):
        minimum = min(minimum, temp[i][0])

if(minimum == 10**20):
    print(-1)
else:
    print(minimum)
Buggy code:
import itertools
n,m,x = map(int, input().split())
book = []
for i in range(n):
  b = list(map(int, input().split()))
  book.append(b)
book = sorted(book, key=lambda x:x[0])
junretu = itertools.permutations(range(n))
max_ = 2**n
min_nedan = 10**9
for j in range(max_):
  bit = format(j, "0"+str(n)+"b")
  count_list = [0]*m
  nedan = 0
  for b in range(n):
    if bit[b] == "1":
      naiyou = book[b]
      nedan += naiyou[0]
      for i in range(1, m+1):
        count_list[i-1] += naiyou[i]
  if min(count_list)>=x:
    if nedan a< min_nedan:
      min_nedan = nedan
if min_nedan == 10**9:
  print(-1)
else:
  print(min_nedan)
  


Fixed code:
import itertools
n,m,x = map(int, input().split())
book = []
for i in range(n):
  b = list(map(int, input().split()))
  book.append(b)
book = sorted(book, key=lambda x:x[0])
junretu = itertools.permutations(range(n))
max_ = 2**n
min_nedan = 10**9
for j in range(max_):
  bit = format(j, "0"+str(n)+"b")
  count_list = [0]*m
  nedan = 0
  for b in range(n):
    if bit[b] == "1":
      naiyou = book[b]
      nedan += naiyou[0]
      for i in range(1, m+1):
        count_list[i-1] += naiyou[i]
  if min(count_list)>=x:
    if nedan < min_nedan:
      min_nedan = nedan
if min_nedan == 10**9:
  print(-1)
else:
  print(min_nedan)
Buggy code:
import numpy as np
n,m,x=map(int,input().split())
P = [list( map( int, input().split() ) ) for i in range(n)]
ca=np.array(P).reshape((n,m+1))
value= 10000000
for i in range(2**n+1):
  sum=np.empty(m+1)
  for y in range(n):
    if (i >> y & 1) == 1:
      sum= sum + ca[-y,:]
  summ=sum[1:]
  if all(elm >= x for elm in summ) == True:
    value= min(int(sum[0]), value)
if value==10000000:
  print('-1')
else:
  print(value)

Fixed code:
import numpy as np
n,m,x=map(int,input().split())
P = [list( map( int, input().split() ) ) for i in range(n)]
ca=np.array(P).reshape((n,m+1))
value= 10000000
for i in range(2**n):
  sum=np.zeros(m+1)
  for y in range(n):
    if list(bin(i >> y))[-1] == '1':
      sum += ca[-y-1,:]
    else:
      pass
  summ=sum[1:]
  if all(elm >= x for elm in summ) == True:
    if value==int(sum[0]):
      value=int(sum[0])
    else:
      value= min(int(sum[0]), value)
if value==10000000:
  print('-1')
else:
  print(value)
Buggy code:
import numpy as np

N, M, X = map(int, input().split())

ca = []
for _ in range(N):
  ca.append( list(map(int, input().split())))
ca.sort(key=lambda x:-x[0])
ca = np.array(ca)
#
ans = 10000000
skill = [0]*(M+1)


def DFS(n,skill):
  global ans
  if skill[0] >= ans:
    return
  if min(skill[1:]) >= X:
    ans = min(ans, skill[0])
    return
  if n >= N:
    return
  DFS(n+1,skill)
  skill = skill + ca[n]
  DFS(n+1,s)
  skill = skill - ca[n]
  return
#

DFS(0,skill)
if ans == 10000000:
  print(-1)
else:
  print(ans)
#

Fixed code:
import numpy as np

N, M, X = map(int, input().split())

ca = []
for _ in range(N):
  ca.append( list(map(int, input().split())))
ca.sort(key=lambda x:-x[0])
ca = np.array(ca)
#
ans = 10000000
skill = [0]*(M+1)


def DFS(n,skill):
  global ans
  if skill[0] >= ans:
    return
  if min(skill[1:]) >= X:
    ans = min(ans, skill[0])
  if n >= N:
    return
  s = skill.copy()
  DFS(n+1,s)
  s = s + ca[n]
  DFS(n+1,s)
  return
#

DFS(0,skill)
if ans == 10000000:
  print(-1)
else:
  print(ans)
#
Buggy code:
import itertools
import sys
import numpy as np

N, M, X = map(int, input().split())
C = []
for n in range(N):
    C.append(list(map(int, input().split())))

result = []
for n in range(2 ** N):
    ii = [0] * N
    for i in range(N):
        if (n >> i) & 1:
            ii[i] = 1
    # print(ii)
    tmp = [0] * (M + 1)
    for j in range(len(ii)):
        if ii[j] == 1:
            tmp = (np.array(tmp) + np.array(C[j])).tolist()
    result.append(tmp)


def ex(array):
    for i in array:
        if i < X:
            return False
    return True


min_value = sys.maxsize
for r in result:
    print(r)
    if ex(r):
        min_value = min(min_value, r[0])
print(min_value) if min_value != sys.maxsize else print(-1)


Fixed code:
import itertools
import sys
import numpy as np

N, M, X = map(int, input().split())
C = []
for n in range(N):
    C.append(list(map(int, input().split())))

result = []
for n in range(2 ** N):
    ii = [0] * N
    for i in range(N):
        if (n >> i) & 1:
            ii[i] = 1
    # print(ii)
    tmp = [0] * (M + 1)
    for j in range(len(ii)):
        if ii[j] == 1:
            tmp = (np.array(tmp) + np.array(C[j])).tolist()
    result.append(tmp)


def ex(array):
    for i in array[1:]:
        if i < X:
            return False
    return True


min_value = sys.maxsize
result.sort()
for r in result:
    if ex(r):
        print(r[0])
        exit()

print(-1)
Buggy code:
import sys
sys.setrecursionlimit(10000000)
INF = 10 ** 10
ans = INF


def rec(A, C, X, idx, ability, sum_):
    if idx == len(A):
        for i in range(len(ability)):
            if ability[i] < X:
                break
        else:
            global ans
            ans = min(sum_, ans)
    else:
        # not buy
        rec(A, C, X, idx+1, ability, sum_)
        M = len(A[0])
        import copy 
        for i in range(M):
            ability[i] += A[idx][i]
        rec(A, C, X, idx+1, copy.copy(ability), sum_+C[idx])


def main():
    N, M, X = map(int, input().split())
    C = []
    A = []
    for i in range(N):
        lists = [int(c) for c in input().split()]
        ci = lists[0]
        ai = lists[1:]
        C.append(ci)
        A.append(ai)

    ability = [0] * M
    rec(A, C, X, 0, ability, 0)

    if ans == INF:
        print(-1)
    else:
        print(ans)
    

    
    



if __name__ == '__main__':
    main()


Fixed code:
import sys
sys.setrecursionlimit(10000000)
INF = 10 ** 10
ans = INF


def rec(A, C, X, idx, ability, sum_):
    if idx == len(A):
        for i in range(len(ability)):
            if ability[i] < X:
                break
        else:
            global ans
            ans = min(sum_, ans)
    else:
        # not buy
        rec(A, C, X, idx+1, ability, sum_)
        M = len(A[0])
        import copy 
        new_ability = copy.copy(ability)
        for i in range(M):
            new_ability[i] += A[idx][i]
        rec(A, C, X, idx+1, new_ability, sum_+C[idx])


def main():
    N, M, X = map(int, input().split())
    C = []
    A = []
    for i in range(N):
        lists = [int(c) for c in input().split()]
        ci = lists[0]
        ai = lists[1:]
        C.append(ci)
        A.append(ai)

    ability = [0] * M
    rec(A, C, X, 0, ability, 0)

    if ans == INF:
        print(-1)
    else:
        print(ans)
    

    
    



if __name__ == '__main__':
    main()
Buggy code:
N, M, X = map(int, input().split())
book = [[map(int, input().split())] for i in range(N)]

min_value = -1
for i in range(2**N):
  sum = [0 for k in range(M+1)]
  for j in range(N):
    if (i >> j) & 1:
      sum = [x+y for x, y in zip(sum, book[N+1])]
  if min(sum[1:]) >= X and min_value > sum[0]:
    min_value = sum[0]

print(min_value)

Fixed code:
N, M, X = map(int, input().split())
book = [list(map(int, input().split())) for i in range(N)]

min_value = -1
for i in range(2**N):
    sum = [0 for k in range(M+1)]
    for j in range(N):
        if (i >> j) & 1:
            sum = [x+y for x, y in zip(sum, book[j])]
    if min(sum[1:]) >= X and (min_value > sum[0] or min_value == -1):
        min_value = sum[0]

print(min_value)
Buggy code:
N, M, X = map(int, input().split())
C = [0] * N
AA = [list(map(int, input().split())) for i in range(N)]
for i in range(len(AA)):
    C[i] = AA[i][0]
    A[i] = AA[i][1:]
ans = sum(C) + 1
for p in range(2 ** N):
    Y = [0] * M
    cnt = 0
    for i, c in enumerate(C):
        if p % 2 == 1:
            cnt += c
            for j, a in enumerate(A[i]):
                Y[j] += a
        p //= 2
    ans = min(ans, cnt) if min(Y) >= X else ans
print(ans if ans <= sum(C) else -1)

Fixed code:
N, M, X = map(int, input().split())
C = [0] * N
A = [0] * N
AA = [list(map(int, input().split())) for i in range(N)]
for i in range(len(AA)):
    C[i] = AA[i][0]
    A[i] = AA[i][1:]
ans = sum(C) + 1
for p in range(2 ** N):
    Y = [0] * M
    cnt = 0
    for i, c in enumerate(C):
        if p % 2 == 1:
            cnt += c
            for j, a in enumerate(A[i]):
                Y[j] += a
        p //= 2
    ans = min(ans, cnt) if min(Y) >= X else ans
print(ans if ans <= sum(C) else -1)
Buggy code:
n,m,x=map(int,input().split())
c=list(map(int,input().split()))
l=[]
for i in range(2**n):
    l.append(format(i,'b').zfill(n))
l1=[]
for i in range(len(l)):
    s=[0]*(m+1)
    for j in range(n):
        if l[i][j]=='1':
            for k in range(m+1):
                s[k]+=c[j][k]

    for o in range(1,m+1):
        if s[o]<x:break
        if o==m:l1.append(s[0])
if len(l1)==0:print(-1) 
else:print(min(l1))

Fixed code:
n,m,x=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(n)]
l=[]
for i in range(2**n):
    l.append(format(i,'b').zfill(n))
l1=[]
for i in range(len(l)):
    s=[0]*(m+1)
    for j in range(n):
        if l[i][j]=='1':
            for k in range(m+1):
                s[k]+=c[j][k]

    for o in range(1,m+1):
        if s[o]<x:break
        if o==m:l1.append(s[0])
if len(l1)==0:print(-1) 
else:print(min(l1))
Buggy code:

#!/usr/bin/env python3

import sys
import pprint
import itertools

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n, m, x = map(int, sys.stdin.readline().split())
	c = []
	a = []
	for i in range(n):
		ci, *ai = map(int, sys.stdin.readline().split())
		c.append(ci)
		a.append(ai)
	ans = 10**9
	log.print(a)
	for i in range(2**n):
		cost = 0
		rikai = [0]*m
		case = []
		for j in range(n):
			case.append(i>>j & 1)
		for j in range(n):
			if not case[j]:
				continue
			cost += c[j]
			for k in range(m):
				rikai[k] += a[j][k]
		# log.print(case, rikai, len(list(filter(lambda z:z>=x, rikai))))
		if len(list(filter(lambda z:z>=x, rikai))) == m:
			ans = min(cost, ans)
	if ans == 10**9:
		print(-1)
		exit()
	print(ans)





main()

Fixed code:

#!/usr/bin/env python3

import sys
import pprint
import itertools

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n, m, x = map(int, sys.stdin.readline().split())
	c = []
	a = []
	for i in range(n):
		ci, *ai = map(int, sys.stdin.readline().split())
		c.append(ci)
		a.append(ai)
	ans = 10**9
	log.print(a)
	for i in range(2**n):
		cost = 0
		rikai = [0]*m
		case = []
		for j in range(n):
			case.append(i>>j & 1)
		for j in range(n):
			if not case[j]:
				continue
			cost += c[j]
			for k in range(m):
				rikai[k] += a[j][k]
		# log.print(case, rikai, len(list(filter(lambda z:z>=x, rikai))))
		if len(list(filter(lambda z:z>=x, rikai))) == m:
			ans = min(cost, ans)
	if ans == 10**9:
		print(-1)
		exit()
	print(ans)





main()
Buggy code:
import itertools
n, m, x = list(map(int,input().split()))
c = []
for i in range(n):
    c.append(list(map(int,input().split())))
mn = 0
for bn in itertools.product([0,1], repeat=n):
    money = 0
    skills = [0]*m
    for j in range(n):
        if bn[j] == 1:
            money += c[j][0]
            for k in range(m):
                skills[k] += c[j][k+1]
    if all([y > x for y in skills]):
        if mn == -1:
            mn = money
        elif money < mn:
            mn = money
print(mn)

Fixed code:
import itertools
n, m, x = list(map(int,input().split()))
c = []
for i in range(n):
    c.append(list(map(int,input().split())))
mn = -1
for bn in itertools.product([0,1], repeat=n):
    money = 0
    skills = [0]*m
    for j in range(n):
        if bn[j] == 1:
            money += c[j][0]
            for k in range(m):
                skills[k] += c[j][k+1]
    if all([y >= x for y in skills]):
        if mn == -1:
            mn = money
        elif money < mn:
            mn = money
print(mn)