TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
blist = []
def createBitline(N, p, bl):
	if(N == p):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")



def checkClear(X, M, list):
	for i in range(1, M):
		if X > int(list[i]):
			return False
	return True

listCA = []
def main3():
	N,M,X = map(int, input().split())
	for i in range(N):
		listCA.append(input().split())
	createBitline(N, 0, "")
	max = 1000000000
	flg = False
	
	for x in range(len(blist)):
		sumCA = [0] * M
		
		for i in range(N):
			if blist[x][i] == "1":
				for j in range(M):
					sumCA[j] += int(listCA[i][j])
		
		if checkClear(X, M, sumCA) and sumCA[0] < max:
			max = sumCA[0]
			flg = True
	if flg:
		print(max)
	else:
		print("-1")

blist = []
def createBitline(N, p, bl):
	if(N == p and len(bl) == N):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")

def checkClear(X, list):
	for i in range(1, len(list)):
		if int(list[i]) < X:
			return False
	return True

listCA = []
N,M,X = map(int, input().split())
for i in range(N):
	listCA.append(input().split())
for i in listCA:
	print(i)
createBitline(N, 0, "")
cost = []
for x in range(len(blist)):
	sumCA = [0] * (M + 1)
	for i in range(N):
		if blist[x][i] == "1":
			for j in range(len(listCA[i])):
				sumCA[j] += int(listCA[i][j])
	if checkClear(X, sumCA):
		cost.append(sumCA[0])
if cost:
	print(min(cost))
else:
	print('-1')

blist = []
def createBitline(N, p, bl):
	if(N == p and len(bl) == N):
		blist.append(bl)
	else:
		createBitline(N, p + 1, bl + "0")
		createBitline(N, p + 1, bl + "1")
 
def checkClear(X, list):
	for i in range(1, len(list)):
		if int(list[i]) < X:
			return False
	return True
 
listCA = []
N,M,X = map(int, input().split())
for i in range(N):
	listCA.append(input().split())
createBitline(N, 0, "")
cost = []
for x in range(len(blist)):
	sumCA = [0] * (M + 1)
	for i in range(N):
		if blist[x][i] == "1":
			for j in range(len(listCA[i])):
				sumCA[j] += int(listCA[i][j])
	if checkClear(X, sumCA):
		cost.append(sumCA[0])
if cost:
	print(min(cost))
else:
	print('-1')

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
from operator import sub, add
import sys
N, M, X = map(int, input().split())
AC = []
for _ in range(N):
    AC.append(list(map(int, input().split())))

S = [sum(x) for x in zip(*AC)]
s = [sum(x) for x in zip(*AC)]
for m in range(1, M+1):
    if s[m] < X:
        print(-1)
        sys.exit(0)
        
AC.sort(reverse=True)        
for n in range(N):
    ac = AC[n]
    s = list(map(sub, s, ac))
    for m in range(1, M+1):
        if s[m] < X:
            s = list(map(add, s, ac))
            break
            
print(min(S, s[0]))

import itertools as it

N,M,X=map(int,input().split())
book = [[int(_) for _ in input().split()] for i in range(N)]

combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
	bag = [0] * (M+1)
	for i in range(N):
		if comb[i] == 0:
			continue
		else:
			for j in range(M+1):
				bag[j]+=book[i][j]
	if min(bag[1:]) < X:
		continue
	else:
		prices.append(bag[0])

if len(prices) == 0:
	print(-1)
else:
	print(min(prices))


Verdicts: Runtime Error

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
n,m,x = map(int, input().split())

N=[]
NI=[]
for i in range(n) :
    N = list(map(str, input().split()))
    NI.append(N)

ans=-1

for i in range(1<<n) :
    A=[0]*(m+1)
    for j in range(n) :
        # print(NI[j])
        if (1<<j)&i :
            A=[x+int(y) for(x,y)in zip(A,NI[j])]
    print(A)
    a = A[0]
    del A[0]
    if min(A)<x :
        a=-1
    elif ans==-1:
        ans = a
    elif ans>a :
        ans = a
print(ans)


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

N=[]
NI=[]
for i in range(n) :
    N = list(map(str, input().split()))
    NI.append(N)

ans=-1

for i in range(1<<n) :
    A=[0]*(m+1)
    for j in range(n) :
        # print(NI[j])
        if (1<<j)&i :
            A=[x+int(y) for(x,y)in zip(A,NI[j])]
    # print(A)
    a = A[0]
    del A[0]
    if min(A)<x :
        a=-1
    elif ans==-1:
        ans = a
    elif ans>a :
        ans = a
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
n, m, x = map(int, input().split())
sL = [0]*m
bL = []
for i in range(n):
    book = list(map(int, input().split()))
    bL.append(book)


def fullS(currentL, index, allP):
    if index > len(currentL):
        if min(currentL) >= x:
            return allP
        else:
            return -1
    else:
        if min(currentL) >= x:
            return allP
        else:
            op1 = fullS(currentL, index+1, allP)
            newP = 0
            newL = []
            for i in range(len(bL[index])):
                if i == 0:
                    newP = allP+bL[index][i]
                else:
                    newL.append(currentL[i-1]+bL[index][i])
            op2 = fullS(newL, index+1, newP)
            if op1 == -1 and op2 == -1:
                return -1
            elif op1 == -1:
                return op2
            elif op2 == -1:
                return op1
            else:
                return min(op1, op2)
                


print(fullS(sL, 0, 0))

n, m, x = map(int, input().split())
sL = [0]*m
bL = []
for i in range(n):
    book = list(map(int, input().split()))
    bL.append(book)


def fullS(currentL, index, allP):
    if index >= len(bL):
        if min(currentL) >= x:
            return allP
        else:
            return -1
    else:
        if min(currentL) >= x:
            return allP
        else:
            op1 = fullS(currentL, index+1, allP)
            newP = 0
            newL = []
            for i in range(len(bL[index])):
                if i == 0:
                    newP = allP+bL[index][i]
                else:
                    newL.append(currentL[i-1]+bL[index][i])
            op2 = fullS(newL, index+1, newP)
            if op1 == -1 and op2 == -1:
                return -1
            elif op1 == -1:
                return op2
            elif op2 == -1:
                return op1
            else:
                return min(op1, op2)
                


print(fullS(sL, 0, 0))

Verdicts: Runtime Error

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
N, M, X = input().split()
C, A = [], []
for _ in range(N):
    tmp = [int(a) for a in input().split()]
    C.append(tmp[0])
    A.append(tmp[1:])

mi = 1 << 100
for binary in range(1 << N):
    B = [0] * M
    c = 0
    for i in range(N):
        if binary >> N & 1:
            c += C[i]
            for j in range(M):
                B[j] += A[i][j]
    if min(B) >= X:
        mi = min(c, mi)
print(mi if mi < 1 << 99 else -1)


N, M, X = map(int, input().split())
C, A = [], []
for _ in range(N):
    tmp = [int(a) for a in input().split()]
    C.append(tmp[0])
    A.append(tmp[1:])

mi = 1 << 100
for binary in range(1 << N):
    B = [0] * M
    c = 0
    for i in range(N):
        if binary >> i & 1:
            c += C[i]
            for j in range(M):
                B[j] += A[i][j]
    if min(B) >= X:
        mi = min(c, mi)
print(mi if mi < 1 << 99 else -1)


Verdicts: Runtime Error

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
import sys
n,m,x=map(int,input().split())
A=[]
for i in range(n):
    ca=list(map(int,input().split()))
    A.append(ca)
ans=10**7

for i in range(2**n):
    tmp=[0]*m
    cost=0
    for j in range(n):
        if (1<<j)&i:
            cost+=A[j][0]
            for k in range(m):
                tmp[k]+=A[j][k+1]
    for l in range(m):
        if tmp[l]<x:
            break
    ans=min(ans,cost)
if ans==10**7:
    ans=-1
print(ans)




import sys
n,m,x=map(int,input().split())
A=[]
for i in range(n):
    ca=list(map(int,input().split()))
    A.append(ca)
ans=10**7

for i in range(2**n):
    tmp=[0]*m
    cost=0
    for j in range(n):
        if (1<<j)&i:
            cost+=A[j][0]
            for k in range(m):
                tmp[k]+=A[j][k+1]
    check=True
    for l in range(m):
        if tmp[l]<x:
            check=False
            break
    #else:
    if check:
        ans=min(ans,cost)
                        
if ans==10**7:
    ans=-1
print(ans)




Verdicts: Wrong Answer

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
n,m,x = map(int,input().split())
c = [list(map(int,input().split())) for i in range(n)]

ans = float('inf')

print(c)

for i in range(2**n):
    hold = [0] * (m+1)
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m+1):
                hold[k] += c[j][k]
    if min(hold[1:]) >= x : 
        ans = min(ans,hold[0])

if ans != float('inf'):
    print(ans)
else:
    print("-1")



n,m,x = map(int,input().split())
c = [list(map(int,input().split())) for i in range(n)]

ans = float('inf')

print(c)

for i in range(2**n):
    hold = [0] * (m+1)
    for j in range(n):
        if(i >> j) and 1:
            for k in range(m+1):
                hold[k] += c[j][k]
    if min(hold[1:]) >= x : 
        ans = min(ans,hold[0])

if ans != float('inf'):
    print(ans)
else:
    print("-1")

n,m,x = map(int,input().split())
c = [list(map(int,input().split())) for i in range(n)]

ans = float('inf')

for i in range(2**n):
    hold = [0] * (m+1)
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m+1):
                hold[k] += c[j][k]
    if min(hold[1:]) >= x : 
        ans = min(ans,hold[0])

if ans != float('inf'):
    print(ans)
else:
    print("-1")



Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
N,M,X=list(map(int,input().split()))
AC=[]
C=[]
A=[]
for n in range(N):
  AC.append(list(map(int,input().split())))
  C.append(AC[0])
  A.append(AC[1:])
ans=0
for n in range(2**N):
  total=0
  und=[0]*M
  for j in range(N):
    if n >> j & 1:
      total+=C[j]
      for m in range(M):
        und[m]+=A[j][m]
  if X <= min(und):
    ans=total
if ans==0:
  print(-1)
else:
  print(ans)
    

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

C=[]
A=[]
for n in range(N):
  AC=list(map(int,input().split()))
  C.append(AC[0])
  A.append(AC[1:])
ans=10**9

for n in range(2**N):
  total=0
  und=[0]*M
  for j in range(N):
    if n >> j & 1:
      total+=C[j]
      for m in range(M):
        und[m]+=A[j][m]
  if X <= min(und):
    ans=min(total,ans)
if ans==10**9:
  print(-1)
else:
  print(ans)

Verdicts: Runtime Error

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
from itertools import combinations
import numpy as np
n,m,x = map(int, input().split())
costs = []
understnding = []
ans = 10 ** 20

for _ in range(n):
    tmp = list(map(int, input().split()))
    costs.append(tmp[0])
    understnding.append(tmp[1:])
    
costs = np.array(costs)
understnding = np.array(understnding)

for i in range(2**n):
    row = str(bin(i)).split("0b")[1]
    row = '0'*(n - len(row_tmp))+row_tmp
    one_index = [j for j in range(len(row)) if row[j] =="1"]
    cost_sum = np.sum(costs[one_index])
    under_sum = np.sum(understnding[one_index], axis=0)
    if np.all(under_sum >= x) and cost_sum < ans:
        ans = cost_sum
    
if ans = 10 ** 20:
    print(-1)
else
    print(ans)

from itertools import combinations
import numpy as np
n,m,x = map(int, input().split())
costs = []
understnding = []
ans = 10 ** 20

for _ in range(n):
    tmp = list(map(int, input().split()))
    costs.append(tmp[0])
    understnding.append(tmp[1:])
    
costs = np.array(costs)
understnding = np.array(understnding)

for i in range(2**n):
    row = str(bin(i)).split("0b")[1]
    row = '0'*(n - len(row_tmp))+row_tmp
    one_index = [j for j in range(len(row)) if row[j] =="1"]
    cost_sum = np.sum(costs[one_index])
    under_sum = np.sum(understnding[one_index], axis=0)
    if np.all(under_sum >= x) and cost_sum < ans:
        ans = cost_sum
    
if ans == 10 ** 20:
    print(-1)
else:
    print(ans)

import numpy as np
n,m,x = map(int, input().split())
costs = []
understnding = []
ans = 10 ** 20

for _ in range(n):
    tmp = list(map(int, input().split()))
    costs.append(tmp[0])
    understnding.append(tmp[1:])
    
costs = np.array(costs)
understnding = np.array(understnding)

for i in range(1, 2**n):
    row = str(bin(i)).split("0b")[1]
    row = '0'*(n - len(row))+row
    one_index = [j for j in range(len(row)) if row[j] =="1"]
    cost_sum = np.sum(costs[one_index])
    under_sum = np.sum(understnding[one_index], axis=0)
    if np.all(under_sum >= x) and cost_sum < ans:
        ans = cost_sum
    
if ans == 10 ** 20:
    print(-1)
else:
    print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
n, m, x = list(map(int, input().split()))
lists = []
result_price = 0
existed = False

for i in range(n):
  lists.append(list(map(int, input().split())))

for i in range(n):
  result_price += lists[i][0]
for i in range(1 << n):
  flag = True
  scores = [0] * m
  tmp_price = 0
  for j in range(n):
    if i & (1 << j):
      for k in range(m):
        scores[k] += lists[j][k+1]
      tmp_price += lists[j][0]
  for l in range(m):
    if scores[l] < x:
      flag = False
      break
  if flag and (result_price > tmp_price):
    print(i)
    existed = True
    result_price = tmp_price
if existed:
  print(result_price)
else:
  print(-1)

n, m, x = list(map(int, input().split()))
lists = []
result_price = 0
existed = False

for i in range(n):
  lists.append(list(map(int, input().split())))

for i in range(1 << n):
  flag = True
  scores = [0] * m
  tmp_price = 0
  for j in range(n):
    if i & (1 << j):
      for k in range(m):
        scores[k] += lists[j][k+1]
      tmp_price += lists[j][0]
  for l in range(m):
    if scores[l] < x:
      flag = False
      break
  if flag and (result_price > tmp_price or result_price == 0):
    existed = True
    result_price = tmp_price
if existed:
  print(result_price)
else:
  print(-1)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
n, m, x = list(map(int, input().split()))

c_list = []
a_matrix = []

for i in range(n):
    items = list(map(int, input().split()))
    c_list.append(items[0])
    a_matrix.append(items[1:])

min_cost = 1000000 * (n+1)

for i in range(2^n):
    cost = 0
    skill_sum = [0 for _ in range(m)]
    bit_pattern = format(i, '0' + str(n) + 'b')[::-1]
    for i, a_line in enumerate(a_matrix):
        if bit_pattern[i] == "1":
            cost += c_list[i]
            for j, a in enumerate(a_line):
                skill_sum[j] += a
    
    if all(map(lambda skill_s: skill_s >= x, skill_sum)) and cost < min_cost:
        min_cost = cost

if min_cost >= 1000000 * (n+1):
    print(-1)
else:
    print(min_cost)

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

c_list = []
a_matrix = []

for i in range(n):
    items = list(map(int, input().split()))
    c_list.append(items[0])
    a_matrix.append(items[1:])

min_cost = 1000000 * (n+1)

for i in range(2**n):
    cost = 0
    skill_sum = [0 for _ in range(m)]
    bit_pattern = format(i, '0' + str(n) + 'b')[::-1]
    for i, a_line in enumerate(a_matrix):
        if bit_pattern[i] == "1":
            cost += c_list[i]
            for j, a in enumerate(a_line):
                skill_sum[j] += a
    
    if all(map(lambda skill_s: skill_s >= x, skill_sum)) and cost < min_cost:
        min_cost = cost

if min_cost >= 1000000 * (n+1):
    print(-1)
else:
    print(min_cost)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):


def main():
    N, M, X = map(int, input().split())
    Cs = [list(map(int, input().split())) for _ in range(N)]
    mi = 100000000000000000000 #->float("inf")
    for i in range(1<<N):
        lis = [0] * (M+1)
        for j in range(N):
            if i & (1<<j) == 0:
                continue
            for k in range(M):
                lis[k] += Cs[j][k]
        if all(v>=X for v in lis[1:]):
            mi = min(lis[0], mi)

    return -1 if mi == 100000000000000000000 else mi

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    



def main():
    N, M, X = map(int, input().split())
    Cs = [list(map(int, input().split())) for _ in range(N)]
    mi = 100000000000000000000 #->float("inf")
    for i in range(1<<N):
        lis = [0] * (M+1)
        for j in range(N):
            if i & (1<<j) == 0:
                continue
            for k in range(M+1):
                lis[k] += Cs[j][k]
        if all(v>=X for v in lis[1:]):
            mi = min(lis[0], mi)

    return -1 if mi == 100000000000000000000 else mi

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    

Verdicts: Wrong Answer

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
import itertools
n,m,x=map(int,input().split())
c=[0]*n
a=[[0 for i in range(m)] for j in range(n)]
print(a)
current_skill=[0]*m
INF=9999999
min_money=INF


for  i in range(n):
    tmp=list(map(int,input().split()))
    c[i]=tmp[0]
    a[i]=tmp[1:]

current_money=0

for i in range(1 << n):
    bug=[]
    #print('current_money=',current_money)
    #print('current_skill=',current_skill)
    for j in range(n):
        if (i>>j) &1:
            bug.append(j)
    current_skill=[0]*m
    current_money=0
    for chosen_set_num in bug:
        current_money+=c[chosen_set_num]
        for each_book_num in range(m):
            current_skill[each_book_num]+=a[chosen_set_num][each_book_num]
            

        if all(status >=x for status in current_skill ):
            min_money=min(min_money,current_money)
            continue
if min_money==INF:
    min_money=-1
print(min_money)


import itertools
n,m,x=map(int,input().split())
c=[0]*n
a=[[0 for i in range(m)] for j in range(n)]
current_skill=[0]*m
INF=9999999
min_money=INF


for  i in range(n):
    tmp=list(map(int,input().split()))
    c[i]=tmp[0]
    a[i]=tmp[1:]

current_money=0

for i in range(1 << n):
    bug=[]
    for j in range(n):
        if (i>>j) &1:
            bug.append(j)
    current_skill=[0]*m
    current_money=0
    for chosen_set_num in bug:
        current_money+=c[chosen_set_num]
        for each_book_num in range(m):
            current_skill[each_book_num]+=a[chosen_set_num][each_book_num]
            

        if all(status >=x for status in current_skill ):
            min_money=min(min_money,current_money)
            continue
if min_money==INF:
    min_money=-1
print(min_money)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
import numpy as np
import itertools

n, m, x = map(int, input().split())
calist = []
for i in range(n):
    ca = list(map(int, input().split()))
    calist.append(ca)

# print(n, m, x, calist)


for j in range(m):
    sum = 0
    for i in range(n):
        sum += calist[i][j + 1]
    if sum < x:
        print(-1)
        exit()

calist = np.array(calist)
dp = float('inf')

for comb in range(1, m + 1):
    sc = itertools.combinations(calist, comb)
    sum = 0
    a = np.array([0 for _ in range(m)])
    for ca in sc:
        sum += ca[0]
        a += ca[1:]
    if False not in (a > x) and sum < dp:
        dp = sum

print(dp)


import unittest
from io import StringIO
import sys


def resolve():
    n, m, x = [int(i) for i in input().split()]
    cc = []
    aa = []
    for comb in range(n):
        c, *a = [int(comb) for comb in input().split()]
        cc.append(c)
        aa.append(a)

    ans = float('inf')
    for comb in range(2**n):
        sum = 0
        xx = [0] * m
        for i in range(n):
            if (comb >> i) & 1:
                sum += cc[i]
                for j in range(m):
                    xx[j] += aa[i][j]
        for tx in xx:
            if tx < x:
                break
        else:
            ans = min(ans, sum)

    if ans == float('inf'):
        print(-1)
    else:
        print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3 10
60 2 2 4
70 8 7 9
50 2 3 9"""
        output = """120"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 3 10
100 3 1 4
100 1 5 9
100 2 6 5"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2"""
        output = """1067"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Verdicts: Runtime Error

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
import numpy as np


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

    books = np.array([list(map(int, input().split())) for _ in range(N)])

    min_total_cost = 10**9

    for i in range(2**N):
        to_read_indexes = np.array(list(str(i)), dtype=int)
        to_read_books = books[to_read_indexes, :]
        total_cost = to_read_books[:, 0].sum()
        increased_levels = to_read_books[:, 1:].sum(axis=0)

        if min(increased_levels) >= X:
            min_total_cost = min(min_total_cost, total_cost)

    if min_total_cost == 10**9:
        print('-1')
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()


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

    books = [list(map(int, input().split())) for _ in range(N)]

    min_total_cost = 10**9

    for i in range(2**N):
        total_cost = 0
        learned = [0] * M

        for j in range(N):
            if (i >> j) & 1:
                cost, points = books[j]
                total_cost += cost
                
                learned = [x + y for x, y in zip(learned, points)]

        if min(learned) >= X:
            min_total_cost = min(min_total_cost, total_cost)

    if min_total_cost == 10**9:
        print('-1')
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()


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

    books = [list(map(int, input().split())) for _ in range(N)]

    min_total_cost = 10**9

    for i in range(2**N):
        total_cost = 0
        learned = [0] * M

        for j in range(N):
            if (i >> j) & 1:
                cost, *points = books[j]
                total_cost += cost

                learned = [x + y for x, y in zip(learned, points)]

        if min(learned) >= X:
            min_total_cost = min(min_total_cost, total_cost)

    if min_total_cost == 10**9:
        print('-1')
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
from itertools import product

N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = float("inf")

for now in product(range(2), N):
    res = 0
    An = [0 for _ in range(M)]
    for n in range(N):
        if now[n] == 1:
            res += A[n][0]
            An = [An[j] + A[n][j+1] for j in range(M)]
    if min(An) >= X:
        ans = min(ans, res)

if ans == float("inf"):
    print(-1)
else:
    print(ans)


from itertools import product

N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = float("inf")

for now in product(range(2), repeat=N):
    res = 0
    An = [0 for _ in range(M)]
    for n in range(N):
        if now[n] == 1:
            res += A[n][0]
            An = [An[j] + A[n][j+1] for j in range(M)]
    if min(An) >= X:
        ans = min(ans, res)

if ans == float("inf"):
    print(-1)
else:
    print(ans)


Verdicts: Runtime Error

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
N, M, X = map(int, input().split())

# input
A = [[] for _ in range(N)]
C = [0] * N

for i in range(N):
    C_as = list(map(int, input().split()))
    C[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)


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

A = [[] for _ in range(N)]
c = [0] * N

for i in range(N):
    c_as = list(map(int, input().split()))
    c[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)




Verdicts: Wrong Answer

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
N, M, X = map(int, input().split())
C = []
A = []
result = -1

for i in range(N):
    tmp = list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

for n in range(1 << N-1):
    Cn = 0
    skill = [0] * M
    for i in range(N):
        if (n >> i) & 1 == 1:
            Cn += C[i]
            for j in range(M):
                skill[j] += A[i][j]

    if all(x >= X for x in skill):
        if result == -1:
            result = Cn
        else:
            result = min(result, Cn)

print(result)


N, M, X = map(int, input().split())
C = []
A = []
result = -1

for i in range(N):
    tmp = list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

for n in range(1 << N):
    Cn = 0
    skill = [0] * M
    for i in range(N):
        if (n >> i) & 1 == 1:
            Cn += C[i]
            for j in range(M):
                skill[j] += A[i][j]

    if all(x >= X for x in skill):
        if result == -1:
            result = Cn
        else:
            result = min(result, Cn)

print(result)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
N,M,X = map(int,input().split())
books = [list(map(int,input().split())) for i in range(N)]
bag = []

for i in range(2**N):
  temp = []
  job = [0] * M
  for s in range(N):
    if (i>>s)&1:
      temp.append(s)
      for j in range(M):
        job[j] += item[s][j+1]
  for s in range(len(job)):
    if job[s]<X:
      break
  else:
    ans = 0
    for s in temp:
      ans += item[s][0]
    bag.append(ans)
print(min(bag) if len(bag)>=1 else -1)  

# coding: utf-8
N,M,X = map(int,input().split())
item = [list(map(int,input().split())) for i in range(N)]
bag = []

for i in range(2**N):
  temp = []
  job = [0] * M
  for s in range(N):
    if (i>>s)&1:
      temp.append(s)
      for j in range(M):
        job[j] += item[s][j+1]
  for s in range(len(job)):
    if job[s]<X:
      break
  else:
    ans = 0
    for s in temp:
      ans += item[s][0]
    bag.append(ans)
print(min(bag) if len(bag)>=1 else -1)  


Verdicts: Runtime Error

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
big_int = 10 ** 9

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

L = []
for i in range(N):
  L.insert( tuple(map(int, input().split())) )

def foo(i):
  T = [0 for j in range(M+1)]
  for j in range(N):
    for k in range(M+1):
      T[k] += L[j][k] * (i%2)
      i //= 2
  for k in range(1,M+1):
    if T[k] < X:
      return big_int
  return T[0]
  
ans = big_int

for i in range(2**N):
  ans = min(ans, foo(i))
  
if ans == big_int:
  print(-1)
else:
  print(ans)

big_int = 10 ** 9

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

L = [0 for i in range(N)]
for i in range(N):
  L[i] = tuple(map(int, input().split()))

def foo(i):
  t = i
  T = [0 for j in range(M+1)]
  for j in range(N):
    for k in range(M+1):
      T[k] += L[j][k] * (t%2)
    t //= 2
  for k in range(1,M+1):
    if T[k] < X:
      return big_int
  return T[0]
  
ans = big_int

for i in range(2**N):
  ans = min(ans, foo(i))
  
if ans == big_int:
  print(-1)
else:
  print(ans)

Verdicts: Runtime Error

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
n, m, x = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]

def generate_n_bit(n):
    bins= []
    for i in range(2**n):
        bins.append(list(str(format(i,'b').zfill(n))))
    
    return bins

min_price = 10**9
bins = generate_n_bit(10)
del bins[0]

for bin in bins:
    a = [0 for k in range(m)]
    price = 0
    for i in range(n):
        if bin[i] == '1':
            for j in range(m):
                a[j] += l[i][j+1]
            
            price += l[i][0]
    
   
    
    if min(a) >= x:
        min_price = min(price, min_price)
        print(min_price)


print(min_price)



n, m, x = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]

def generate_n_bit(n):
    bins= []
    for i in range(2**n):
        bins.append(list(str(format(i,'b').zfill(n))))
    
    return bins

min_price = 10**9
bins = generate_n_bit(n)
bins = bins[1:]

for bin in bins:
    a = [0 for k in range(m)]
    price = 0
    for i in range(n):
        if bin[i] == '1':
            for j in range(m):
                a[j] += l[i][j+1]
            
            price += l[i][0]
    
   
    
    if min(a) >= x:
        min_price = min(price, min_price)
        

if min_price == 10**9:
    print(-1)
    exit()
    
print(min_price)

Verdicts: Runtime Error

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
print(-1)

#from collections import defaultdict, deque
import itertools
import numpy as np

def main():
    N, M, X = tuple(int(c) for c in input().split(' '))
    C = []
    A = []
    for _ in range(N):
        tmp = tuple(int(c) for c in input().split(' '))
        C.append(tmp[0])
        A.append(np.array(tmp[1:]))

    
    
    
    
    
    #     print(-1)
    #     exit()

    
    cmin = -1
    for n in range(1, N+1):
        for t in itertools.combinations(range(N), n):
            ri = np.zeros(M)
            ctmp = 0
            for i in t:
                ri += A[i]
                ctmp += C[i]
            if min(ri) >= X:  
                if cmin == -1:
                    cmin = ctmp
                elif ctmp < cmin:
                    cmin = ctmp
    print(cmin)

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: Takahashi, who is a novice in competitive programming, wants to learn M algorithms. Initially, his _understanding level_ of each of the M algorithms is 0.  Takahashi is visiting a bookstore, where he finds N books on algorithms. The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M). There is no other way to increase the understanding levels of the algorithms.  Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

Submission attempts (in order):
N, M, X = map(int,input().split())
C = [list(map(int,input().split())) for x in range(N)] 

skill = [0]*M
flag = [0]*M    
saisyou = 10**7
for p in range(2**N):
    for q in range(N):
        if p >> q & 1:      
            money += C[q][0]
            for r in range(M):  
                skill[r] += C[q][r+1]
    print(skill)
    for s in range(M):
        if skill[s] >= X:
            flag[s] = 1
    if 0 not in flag and money < saisyou:
        saisyou = money
    money = 0
    skill = [0]*M
    flag = [0]*M
if saisyou == 10**7:
    saisyou = -1
print(saisyou)





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

skill = [0]*M
flag = [0]*M    
saisyou = 10**7
for p in range(2**N):
    for q in range(N):
        if p >> q & 1:      
            money += C[q][0]
            for r in range(M):  
                skill[r] += C[q][r+1]
    for s in range(M):
        if skill[s] >= X:
            flag[s] = 1
    if 0 not in flag and money < saisyou:
        saisyou = money
    money = 0
    skill = [0]*M
    flag = [0]*M
if saisyou == 10**7:
    saisyou = -1
print(saisyou)





Verdicts: Wrong Answer

Accepted