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):
a,b,import numpy as np
import itertools
n, m, x = map(int, input().split())
a = np.dot([i for i in itertools.product([0, 1], repeat = n)],
           [list(map(int, input().split())) for _ in range(n)])
b = np.prod(a[:, 1:(m + 1)] >= x, axis = 1, dtype = bool)
print(min(a[:, 0][b]) if b.sum() else '-1')

a,b,import numpy as np
import itertools
n, m, x = map(int, input().split())
a = np.dot([i for i in itertools.product([0, 1], repeat = n)],
           [list(map(int, input().split())) for _ in range(n)])
b = np.prod(a[:, 1:(m + 1)] >= x, axis = 1, dtype = bool)
print(min(a[:, 0][b]) if b.sum() else '-1')


import numpy as np
import itertools
n, m, x = map(int, input().split())
a = np.dot([i for i in itertools.product([0, 1], repeat = n)],
           [list(map(int, input().split())) for _ in range(n)])
b = np.prod(a[:, 1:(m + 1)] >= x, axis = 1, dtype = bool)
print(min(a[:, 0][b]) if b.sum() else '-1')


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):
import itertools
n, m, x = map(int, input().split())
ca = [list(int(i) for i in input().split()) for i in range(n)]

cost_list = []
for choice in range(n+1):
  for v in itertools.combinations(ca, choice):
    cost = 0
    us = [0] * m
    for t in v:
      cost += t[0]
      for i in range(m):
        us[i] += t[i+1]
    flag = True
    for check in range(m):
      if us[check] < x:
        flag = False
    if flag == True:
      cost_list.append(cost)
    print(cost, us, cost_list)

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


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

cost_list = []
for choice in range(n+1):
  for v in itertools.combinations(ca, choice):
    cost = 0
    us = [0] * m
    for t in v:
      cost += t[0]
      for i in range(m):
        us[i] += t[i+1]
    flag = True
    for check in range(m):
      if us[check] < x:
        flag = False
    if flag == True:
      cost_list.append(cost)

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


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, k = map(int, input().split())
li = []
for t in range(n):
    li.append(list(map(int, input().split())))
price_list = []
for bit in range(1, 2**n):
    index_list = []
    for i in range(n):
        if bit & 1<<i:
            index_list.append(i)

    s = 0
    c = 0
    for t in range(1,m+1):
        for i in index_list:
            s += li[i][t]
        if s >= k:
            c += 1
        else:
            continue

    if c == m:
        p = 0
        for i in index_list:
            p += li[i][0]
        price_list.append(p)

if len(price_list):
    print(price_list)
else:
    print('-1')
        


n, m, k = map(int, input().split())
li = []
for t in range(n):
    li.append(list(map(int, input().split())))
price_list = []
for bit in range(1, 2**n):
    index_list = []
    for i in range(n):
        if bit & 1<<i:
            index_list.append(i)

    s = 0
    c = 0
    for t in range(1,m+1):
        for i in index_list:
            s += li[i][t]
        if s >= k:
            c += 1
        else:
            break
    else:
        if c == m:
            p = 0
            for i in index_list:
                p += li[i][0]
            price_list.append(p)

if len(price_list):
    print(price_list)
else:
    print('-1')

n, m, k = map(int, input().split())
li = []
for t in range(n):
    li.append(list(map(int, input().split())))
price_list = []
for bit in range(1, 2**n):
    index_list = []
    for i in range(n):
        if bit & 1<<i:
            index_list.append(i)

    c = 0
    for t in range(1,m+1):
        s = 0
        for i in index_list:
            s += li[i][t]
        if s >= k:
            c += 1
        else:
            break

    if c == m:
        p = 0
        for i in index_list:
            p += li[i][0]
        price_list.append(p)

if len(price_list):
    print(min(price_list))
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 = map(int,input().split())
C = []
for i in range(N):
    C.append(list(map(int,input().split())))

cost = 100000000000000000000000
l = list(range(1,N+1))
import itertools
for i in range(1,N+1):
    check_l = list(itertools.combinations(l,i))
    for a in check_l:
        sub_list = [0] * (M + 1)
        for j in range(i):
            for k in range(M+1):
                sub_list[k] += C[a[i-1]-1][k]
        flag = True
        for p in range(M):
            if sub_list[p+1] < X:
                flag = False
        if flag == True:
            if cost > sub_list[0]:
                cost = sub_list[0]

if cost == 100000000000000000000000:
    print(-1)
else:
    print(cost)

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

cost = 100000000000000000000000
l = list(range(1,N+1))
import itertools
for i in range(1,N+1):
    check_l = list(itertools.combinations(l,i))
    for a in check_l:
        sub_list = [0] * (M + 1)
        for j in range(i):
            for k in range(M+1):
                sub_list[k] += C[a[i]-1][k]
        flag = True
        for p in range(M):
            if sub_list[p+1] < X:
                flag = False
        if flag == True:
            if cost > sub_list[0]:
                cost = sub_list[0]

if cost == 100000000000000000000000:
    print(-1)
else:
    print(cost)

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

cost = 100000000000000000000000
l = list(range(1,N+1))
for i in range(2**N):
    check = [0]*N
    sub_list = [0]*(M+1)
    for j in range(N):
        if (i >> j) & 1 == 1:
            check[j] = 1
    for k in range(N):
        if check[k] == 1:
            for p in range(M+1):
                sub_list[p] += C[k][p]
    flag = True
    for q in range(M):
        if sub_list[q+1] < X:
            flag = False
    if flag == True:
        cost = min(sub_list[0],cost)

if cost == 100000000000000000000000:
    print(-1)
else:
    print(cost)

Verdicts: Wrong Answer

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())
ALL=[]
cost=0
for i in range(N):
  listA=list(map(int,input().split()))
  ALL+=[listA]
  cost+=listA[0]
for i in range(1,M+1):
  SUM=0
  for k in range(N):
    SUM+=ALL[k][i]
  if SUM<X:
    print(-1)
    sys.exit()
ALL.sort(reverse=True)
cost2=0
for start in range(1,N):
  for i in range(M+1):
    SUM=0
    for k in range(start,N):
      SUM+=ALL[k][i]
    if SUM<X:
      print(cost-cost2)
      sys.exit()
  cost2+=ALL[start-1][0]  

import sys,itertools
N,M,X=map(int,input().split())
ALL=[]
cost=0
for i in range(N):
  listA=list(map(int,input().split()))
  ALL+=[listA]
  cost+=listA[0]
for i in range(1,M+1):
  SUM=0
  for k in range(N):
    SUM+=ALL[k][i]
  if SUM<X:
    print(-1)
    sys.exit()
cost2=10**9    
for take in range(1,N+1):
  takeL=list(itertools.combinations(list(range(N)),take))
  for t in takeL:
    for i in range(1,M+1):
      SUM=0
      cost3=0
      for k in range(take):
        SUM+=ALL[t[k]][i]
        cost3+=ALL[t[k]][0]
      if SUM<X:
        break
      if i==M:
        cost2=min(cost2,cost3)
print(cost2)      

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 copy

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

res = 10**8

C = [0] * N
A = [0] * N

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

def sum_l(a,b):
    for i in range(len(a)):
        a[i] += b[i]
    return a

def check_x(a):
    for i in range(len(a)):
        if a[i] < X:
            return False
    return True


def calc_money_under(n):
    understand = [0] * M
    money = 0
    for s in range(N):
        if (n >> s) == 1:
            money += C[s]
            
            understand = copy.copy([x + y for (x,y) in zip(understand, A[s])])
            print(understand)
    
    if check_x(understand):
        res = min(sum(money), res)
    return

for n in range(2**N):
    calc_money_under(n)

if res == 10**8:
    print(-1)
else:
    print(res)



import copy
 
N,M,X = map(int,input().split())
 
res = 10**8
 
C = [0] * N
A = [0] * N
 
for i in range(N):
    L = list(map(int,input().split()))
    C[i] = L[0]
    A[i] = L[1:]
 
def check_x(a):
    for i in range(len(a)):
        if a[i] < X:
            return False
    return True
 

def calc_money_under(n):
    global res

    understand = [0] * M
    money = 0
    for s in range(N):
        if (n >> s) & 1:
            money += C[s]
            for j in range(M):
                understand[j] += A[s][j]
            
    
    if check_x(understand):
        res = min(money, res)
    return
 
for n in range(2**N):
    calc_money_under(n)
 
if res == 10**8:
    print(-1)
else:
    print(res)

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):
# -*- coding: utf-8 -*-

###
# main
if(__name__ == '__main__'):
    # input
    n, m, x = map(int, input().split(" "))

    book = []
    c_sum = 0
    sum_li = [0 for _ in range(m)]
    cp_dict = [{} for _ in range(m)]
    for i in range(n):
        b = list(map(int, input().split(" ")))
        book.append(b)
        c = b[0]
        c_sum += c
        for al in range(m):
            a = b[al+1]
            cp = a/c
            cp_dict[al][cp] = c
            sum_li[al] += a

    ans = -1
    for al in range(m):
        if sum_li[al] < x:
            break
    else:
        ans = c_sum

    print(ans)

# else:
    # do nothing

# -*- coding: utf-8 -*-

###
# main
if(__name__ == '__main__'):
    # input
    n, m, x = map(int, input().split(" "))

    book = []
    c_sum = 0
    sum_li = [0 for _ in range(m)]
    for i in range(n):
        b = list(map(int, input().split(" ")))
        book.append(b)
        c = b[0]
        c_sum += c
        for al in range(m):
            a = b[al+1]
            sum_li[al] += a

    ans = -1
    for al in range(m):
        if sum_li[al] < x:
            break
    else:
        q = []
        cost_list = [c_sum]
        init_list = [c_sum]
        for al in range(m):
            init_list.append(sum_li[al])
        q.append(init_list)

        for i in range(n):
            for tgt_cnt in range(len(q)):
                tgt = q[tgt_cnt]
                cost = tgt[0] - book[i][0]
                tgt_list = [cost]
                for al in range(m):
                    cp = tgt[al+1] - book[i][al+1]
                    if cp < x:
                        break
                    else:
                        tgt_list.append(cp)
                else:
                    cost_list.append(cost)
                    q.append(tgt_list)

        cost_list.sort()
        ans = cost_list[0]

    print(ans)

# else:
    # do nothing

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())

a = [[0 for i in range(m)] for _ in range(n)]
c = [0] * n
for sankousyo in range(n):
    c_and_a = list(map(int,input().split()))
    c[sankousyo] = c_and_a[0]
    a[sankousyo] = c_and_a[1:]
    
cost = [0] * (2**n)
INF = 10**12
res_cost = INF
for i in range(2**n):
    understandings = [0] * m
    cost_sum = 0
    for j in range(n):
        if (i >> j) & 1:

            cost_sum += c[j]
            
            for k in range(m):
                understandings[k] = understandings[k] + a[j][k]

    res = True
    for j in range(n):
        if understandings[j] < x:
            res = False 

    if res:
        if res_cost > cost_sum:
            res_cost = cost_sum

if res_cost == INF:
    print(-1)
else:
    print(f"お会計は{res_cost}円です")


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

a = [[0 for i in range(m)] for _ in range(n)]
c = [0] * n
for sankousyo in range(n):
    c_and_a = list(map(int,input().split()))
    c[sankousyo] = c_and_a[0]
    a[sankousyo] = c_and_a[1:]
    
cost = [0] * (2**n)
INF = 10**12
res_cost = INF
for i in range(2**n):
    understandings = [0] * m
    cost_sum = 0
    for j in range(n):
        if (i >> j) & 1:

            cost_sum += c[j]
            
            for k in range(m):
                understandings[k] = understandings[k] + a[j][k]

    res = True
    for j in range(m):
        if understandings[j] < x:
            res = False 

    if res:
        if res_cost > cost_sum:
            res_cost = cost_sum

if res_cost == INF:
    print(-1)
else:
    print(f"お会計は{res_cost}円です")

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

a = [[0 for i in range(m)] for _ in range(n)]
c = [0] * n
for sankousyo in range(n):
    c_and_a = list(map(int,input().split()))
    c[sankousyo] = c_and_a[0]
    a[sankousyo] = c_and_a[1:]
    
cost = [0] * (2**n)
INF = 10**12
res_cost = INF
for i in range(2**n):
    understandings = [0] * m
    cost_sum = 0
    for j in range(n):
        if (i >> j) & 1:

            cost_sum += c[j]
            
            for k in range(m):
                understandings[k] = understandings[k] + a[j][k]

    res = True
    for j in range(m):
        if understandings[j] < x:
            res = False 

    if res:
        if res_cost > cost_sum:
            res_cost = cost_sum

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


Verdicts: Runtime Error

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

N, M, X = map(int, input().split())
C = []
A = [[] for i in range(M)]
resC = []
resA = list(A)

NEW = 0

def update(base):
  #print(NEW,base)
  if base==None:
    return NEW
  return base + NEW

def check(num):
  return num>=X

def check2(*args):
  res = True
  for val in args:
    buf = (val >= X)
    res = res and buf
  return res

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

for i in range(N):
  if i == 0:
    NEW = C[i]
    resC = [0, NEW]
    resA = [[0, A[j][i]] for j in range(M)]
  else:
    NEW = C[i]
    resC = resC + list(map(update, resC))
    for j in range(M):
      NEW = A[j][i]
      resA[j] = resA[j] + list(map(update, resA[j]))

res = list(map(check2, *resA))
print(np.asarray(resC)[res]) 
if sum(res)==0:
  print(-1)
else:
  print(min(np.asarray(resC)[res]))

import numpy as np

N, M, X = map(int, input().split())
C = []
A = [[] for i in range(M)]
resC = []
resA = list(A)

NEW = 0

def update(base):
  #print(NEW,base)
  if base==None:
    return NEW
  return base + NEW

def check(num):
  return num>=X

def check2(*args):
  res = True
  for val in args:
    buf = (val >= X)
    res = res and buf
  return res

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

for i in range(N):
  if i == 0:
    NEW = C[i]
    resC = [0, NEW]
    resA = [[0, A[j][i]] for j in range(M)]
  else:
    NEW = C[i]
    resC = resC + list(map(update, resC))
    for j in range(M):
      NEW = A[j][i]
      resA[j] = resA[j] + list(map(update, resA[j]))

res = list(map(check2, *resA))
#print(np.asarray(resC)[res]) 
if sum(res)==0:
  print(-1)
else:
  print(min(np.asarray(resC)[res]))

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 sys
import numpy as np

read = sys.stdin.read

n, m, k = map(int, input().split())
ca = np.array(read().split(), dtype=np.int64).reshape([n,m+1])

ans = 10**8

for i in range(2**n):
    b = np.array(list(format(i,'0'+str(n)+'b')), dtype=np.int64)
    print(b)
    d = ca[b == 1].sum(axis=0)
    print(d)
    if np.all(d[1:] >= k):
        ans = min(ans, d[0])

if ans == 10**8:
    print("-1")
else:
    print(ans)

import sys
import numpy as np

read = sys.stdin.read

n, m, k = map(int, input().split())
ca = np.array(read().split(), dtype=np.int64).reshape([n,m+1])

ans = 10**8

for i in range(2**n):
    b = np.array(list(format(i,'0'+str(n)+'b')), dtype=np.int64)
    d = ca[b == 1].sum(axis=0)
    if np.all(d[1:] >= k):
        ans = min(ans, d[0])

if ans == 10**8:
    print("-1")
else:
    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())
L=[list(map(int,input().split())) for i in range(N)]
S=[]
for i in range(2**N):
  A=[]
  b=0
  for j in range(M):
    a=0
    for k in range(N):
      if (i>>j & 1):
        a+=L[k][j+1]
        b+=L[k][0]
    A.append(a)
  T=True
  for l in A:
    if l<X:
      T=False
  if T==True:
    S.append(b//M)
  #print(A)
S=sorted(S)
if len(S)==0:
  print(-1)
else:
  print(S[0])

      

N,M,X=map(int,input().split())
L=[list(map(int,input().split())) for i in range(N)]
a=2**N
J=[]
for i in range(a):
    T=True
    K=[0]*(M+1)
    for j in range(N):
        if (i>>j)&1:
            for k in range(M+1):
                K[k]+=L[j][k]
    for j in range(1,M+1):
        if K[j]<X:
            T=False
    if T:
        J.append(K[0])
if len(J)==0:
    print(-1)
else:
    J.sort()
    print(J[0])

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 check(understanding,X):
    for individual in understanding:
        if individual<X:
            return False
    return True

cost=0
inputs1 =list(map(int, input().split()[:3]))
N=inputs1[0]
M=inputs1[1]
X=inputs1[2]

matrix=[]
understanding= []
for i in range(N):
    inputs =list(map(int, input().split()[:M+1]))
    matrix.append(inputs)

for i in range(N):
    cost+=matrix[i][0]
    for j in range(1,M+1):
        understanding[j]+=matrix[i][j]
    if check(understanding,X):
        print(cost)
        break

if not check(understanding,X):
    print(-1)

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

a = []
c = []

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

INF = 100000000

ans = INF

for i in range(1 << n):
    cost = 0
    d = [0] * m
    for j in range(n):
        if i >> j & 1:
            cost += c[j]
            for k in range(m):
                d[k] += a[j][k]
    ok = True
    for j in range(m):
        if d[j] < x:
            ok = False
    if ok:
        ans = min(ans, cost)
if ans == 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):
from itertools import combinations
n, m, x = map(int, input().split())
ca = list(map(int, input().split()))

ans = 10**9
for i in range(1,n+1):
  for j in combinations(ca, i):
    s = [0]*(m+1)
    for k in j:
      for l in range(m+1):
        s[l] += k[l]
    if min(s[1:]) <= x:
      ans += min(ans, s[0])
if ans == 10**9:
  print(-1)
else:
  print(ans)
    

from itertools import combinations
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

ans = 10**9
for i in range(1,n+1):
  for j in combinations(ca, i):
    s = [0]*(m+1)
    for k in j:
      for l in range(m+1):
        s[l] += k[l]
    if min(s[1:]) >= x:
      ans = min(ans, s[0])
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):
n,m,x = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = [sum([i/j[0] for i in j[1:]]) for k,j in enumerate(a)]
c = sorted(b,reverse=True)
l = [0]*m
p = 0
for i in c:
    if all([i>=x for i in l]):
        break
    f = a[b.index(i)]
    print(f,i)
    p+=f[0]
    for k,j in enumerate(f[1:]):
        l[k]+=j
if all([i>=x for i in l]):
    print(p)
else:
    print(-1)

n, m, x = map(int, input().split())
ans = 10000000
bs = []
for i in range(n):
    bs.append(tuple(map(int, input().split())))

for i in range(2**n):
    a = [0]*m
    c = 0
    for j in range(n):
        if (i>>j)&1:
            c += bs[j][0]
            for k in range(m):
                a[k]+=bs[j][k+1]
    if all([ai >= x for ai in a]):
        ans = min(ans,c)
if ans == 10000000:
    print(-1)
else:
    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 = [0] * N
A = []

for __ in range(N):
    nums = list(map(int, input().split()))
    C[__] = nums[0]
    A.append(nums[1:])
mincost = 10e9
ok = False
for i in range(1 << N):
    cost = 0
    skill = [0] * M

    for u in range(N):
        if i & (1<<u):
            cost += C[u]
            for si, s in enumerate(A[u]):
                skill[si] += s
    
    
    if all([s >= X for s in skill]):
        ok = True
        if mincost > cost:
            mincost = cost

print(mincost if ok else -1)
 dp


N, M, X = map(int, input().split())
C = [0] * N
A = []

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

mincost = 10e9
ok = False
for i in range(1 << N):
    cost = 0
    skill = [0] * M

    for u in range(N):
        if i & (1<<u):
            cost += C[u]
            for si, s in enumerate(A[u]):
                skill[si] += s
    
    
    if all([s >= X for s in skill]):
        ok = True
        if mincost > cost:
            mincost = cost

print(mincost if ok 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 itertools
import numpy as np

N, M, X = map(int, input().split())
items = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)

out = 10**18
for c in itertools.product([False, True], repeat=M):
    tmp = np.sum(items[[np.where(c)]], axis=0)
    if np.any(tmp):
      if M == np.count_nonzero(tmp[1:] >= X):
        out = min(out, tmp[0])
if out == 10**18:
  print(-1)
else:
  print(out) 

import itertools
import numpy as np

N, M, X = map(int, input().split())
items = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)

out = 10**18
for c in itertools.product([False, True], repeat=M):
    tmp = np.sum(items[[np.where(c)]], axis=0)
    if np.any(tmp):
      if M == np.count_nonzero(tmp[1:] >= X):
        out = min(out, tmp[0])
if out == 10**18:
  print(-1)
else:
  print(out) 

import itertools
import numpy as np

N, M, X = map(int, input().split())
items = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)

out = 10**18
for c in itertools.product([False, True], repeat=N):
    tmp = np.sum(items[np.where(c)], axis=0)
    if M == np.count_nonzero(tmp[1:] >= X):
      out = min(out, tmp[0])

if out == 10**18:
  print(-1)
else:
  print(out) 

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):
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, m, x = MI()
    li = [LI() for _ in range(n)]

    min = float(inf)
    for i in range(2 ** n):
        flag = True
        total = [0] * (m + 1)
        for j in range(n):
            if (i >> j) & 1:
                total = [x + y for (x, y) in zip(total, li[j])]

        print(total)
        for t in total[1:]:
            if t < x:
                flag = False

        if flag:
            if total[0] < min:
                min = total[0]

    if isinstance(min, float):
        print(-1)
    else:
        print(min)


if __name__ == "__main__":
    main()


import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, m, x = MI()
    li = [LI() for _ in range(n)]

    min = float(inf)
    for i in range(2 ** n):
        flag = True
        total = [0] * (m + 1)
        for j in range(n):
            if (i >> j) & 1:
                total = [x + y for (x, y) in zip(total, li[j])]

        for t in total[1:]:
            if t < x:
                flag = False

        if flag:
            if total[0] < min:
                min = total[0]

    if isinstance(min, float):
        print(-1)
    else:
        print(min)


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):
import itertools

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

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

min_cost = 10 ** 7
flag_i = False
for i in range(1, N+1):
    comb_list = list(itertools.combinations(range(N), i))
    

    for comb in comb_list:
        know = [0] * M
        cost = 0
        for book in comb:

            for i in range(M):
                know[i] += A[book][i]
            cost += C[book]
        
        
        flag = True
        for i in range(M):
            if (know[i] < X):
                flag = False
              
        
        if (flag):
            flag_i = True
            
            if (min_cost > cost):
                min_cost = cost
if (flag_i):
    print(min_cost)
        

print(-1)

        


import itertools

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

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

flag_i = False
min_cost = 10**7

for i in range(1, N+1):
    comb_list = list(itertools.combinations(range(N), i))
    
    for comb in comb_list:
        know = [0] * M
        cost = 0
        for book in comb:

            for i in range(M):
                know[i] += A[book][i]
            cost += C[book]
        
        
        flag = True
        for i in range(M):
            if (know[i] < X):
                flag = False
              
        
        if (flag):
            flag_i = True
            
            if (min_cost > cost):
                min_cost = cost
if (flag_i):
    print(min_cost)
    exit(0)

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):
ef can_reach_the_goal(u, x):
    return min(u) >= x

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

c = []
a = []
for i in range(n):
    ca = [int(row) for row in input().split()]
    c.append(ca[0])
    a.append(ca[1:])

INF = 10**7
min_cost = INF
for k in range(2**n):
    purchase = [True if c == '1' else False for c in list(format(k, '0{}b'.format(n)))]
    cost = 0
    u = [0]*m
    for i in range(n):
        cost += c[i] if purchase[i] else 0
        for j in range(m):
            u[j] += a[i][j] if purchase[i] else 0

    if can_reach_the_goal(u, x) and cost < min_cost:
        min_cost = cost

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

import sys
import numpy as np

def can_reach_the_goal(u, x):
    return min(u) >= x

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

c = []
a = []
u = [0]*m
u_sum = [0]*n
for i in range(n):
    ca = [int(row) for row in input().split()]
    c.append(ca[0])
    a.append(ca[1:])
    u_sum[i] += sum(a[i])
    for j in range(m):
        u[j] += a[i][j]

if not can_reach_the_goal(u, x):
    print(-1)
    sys.exit(-1)

idx_c = list(np.argsort(-1 * np.array(c)))
c_sum = sum(c)
for i in idx_c:
    print(c[i])
    u_tmp = [u[j] - a[i][j] for j in range(m)]
    if can_reach_the_goal(u_tmp, x):
        c_sum -= c[i]
        u = u_tmp

print(c_sum)

def can_reach_the_goal(u, x):
    return min(u) >= x

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

c = []
a = []
for i in range(n):
    ca = [int(row) for row in input().split()]
    c.append(ca[0])
    a.append(ca[1:])

INF = 10**7
min_cost = INF
for k in range(2**n):
    purchase = [True if c == '1' else False for c in list(format(k, '0{}b'.format(n)))]
    cost = 0
    u = [0]*m
    for i in range(n):
        cost += c[i] if purchase[i] else 0
        for j in range(m):
            u[j] += a[i][j] if purchase[i] else 0

    if can_reach_the_goal(u, x) and cost < min_cost:
        min_cost = cost

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


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):
import numpy as np
import itertools

Cmin = 10**10
N, M, X = map(int, input().split())
L = np.array([[int(j) for j in input().split()] for i in range(N)])
for i in range(N):
  for idx in itertools.combinations(list(range(N)), i+1):
    A = np.zeros(M+1, dtype=int)
    for j in idx:
      A = A + L[j]
    print(A)
    if A[0] < Cmin and (A[1:] >= X).all() == True:
      Cmin = A[0]
if Cmin == 10**10:
  print(-1)
  exit()
print(Cmin)

import numpy as np
import itertools

Cmin = 10**10
N, M, X = map(int, input().split())
L = np.array([[int(j) for j in input().split()] for i in range(N)])
for i in range(N):
  for idx in itertools.combinations(list(range(N)), i+1):
    A = np.zeros(M+1, dtype=int)
    A = A + np.sum(L[list(idx)], axis=0)
    if A[0] < Cmin and (A[1:] >= X).all() == True:
      Cmin = A[0]
if Cmin == 10**10:
  print(-1)
  exit()
print(Cmin)

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

data = input().split()
n = int(data[0])
m = int(data[1])
x = int(data[2])
data = []
for _ in range(n):
    data.append(np.array(list(map(int,input().split()))))

ans = 10000000
for b in range(2**n):
    value = np.array([0 for _ in range(m+1)])
    b = bin(b)[2:]
    for zero in range(n-len(b)):
        b = "0" + b
    for i in range(n):
        if b[i] == 1:
            value += data[i]
    ok = True
    for i in range(1,m+1):
        if value[i] < x:
            ok = False
    if ok == True and value[0] <= ans:
        ans = value[0]

print(ans)
            

import numpy as np

data = input().split()
n = int(data[0])
m = int(data[1])
x = int(data[2])
data = []
for _ in range(n):
    data.append(np.array(list(map(int,input().split()))))

INF = 10000000
ans = INF
for b in range(2**n):
    value = np.array([0 for _ in range(m+1)])
    b = bin(b)[2:]
    for zero in range(n-len(b)):
        b = "0" + b
    for i in range(n):
        if b[i] == "1":
            value += data[i]
    ok = True
    for i in range(1,m+1):
        if value[i] < x:
            ok = False
    if ok == True and value[0] <= ans:
        ans = value[0]
if ans == INF:
    print(-1)
else:
    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):
#!/usr/bin/env python3
import itertools

def main():
    N, M, X = map(int, input().split())
    C = [0] * N
    A = []
    for n in range(0, N):
        l = input().split()
        C[n] = int(l[0])
        A.append([int(i) for i in l[1:]])
        print(C[n], A[n])

    min_cost = sum(C) + 1
    for i in range(N):
        for comb in itertools.combinations(range(N), i):
            canAchive = True
            for m in range(M):
                r = 0
                for n in comb:
                    r += A[n][m]
                if (r < X):
                    canAchive = False
                    break
            if (canAchive):
                cost = sum([C[n] for n in comb])
                min_cost = min(min_cost, cost)

    if (min_cost <= sum(C)):
        print(min_cost)
    else:
        print(-1)


if __name__ == '__main__':
    main()


#!/usr/bin/env python3
import itertools

def main():
    N, M, X = map(int, input().split())
    C = [0] * N
    A = []
    for n in range(0, N):
        l = input().split()
        C[n] = int(l[0])
        A.append([int(i) for i in l[1:]])

    min_cost = sum(C) + 1
    globalCanAchive = False
    for i in range(1,N+1):
        for comb in itertools.combinations(range(N), i):
            canAchive = True
            for m in range(M):
                r = sum([A[n][m] for n in comb])
                if (r < X):
                    canAchive = False
                    break
            if (canAchive):
                globalCanAchive = True
                cost = sum([C[n] for n in comb])
                min_cost = min(min_cost, cost)

    if (globalCanAchive):
        print(min_cost)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted