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


bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')


REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn


TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def rec(self, N, M, X, now_index, now_knowledge, now_price, books):

        if now_index > N:
            return 12 * 10**5 +1

        next_knowledge = now_knowledge + books[now_index][1:]
        if np.min(next_knowledge) >= X:
            result1 = now_price + books[now_index][0]
        else:
            result1 = self.rec(N, M, X, now_index+1, next_knowledge,  now_price + books[now_index][0], books)

        result2 = self.rec(N, M, X, now_index+1, now_knowledge,  now_price, books)

        if result1 < result2:
            return result1
        else:
            return result2

    def resolve(self):

        N, M, X = map(int, self.input_data().split())

        books = [None]*(N+1)
        for i in range(N):
            books[i+1] = np.array(list(map(int, self.input_data().split())))

        print(books)
        print( np.zeros(M))

        result = self.rec(N, M, X, 1, np.zeros(M), 0, books)
        if result == 12 * 10**5 +1:
            print('-1')
        else:
            print(str(result))


solver = Solver(REL_PATH)
solver.exec_resolve()


import glob
import os
import numpy as np


bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')


REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn


TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def rec(self, N, M, X, now_index, now_knowledge, now_price, books):

        if now_index > N:
            return 12 * 10**5 +1

        next_knowledge = now_knowledge + books[now_index][1:]
        if np.min(next_knowledge) >= X:
            result1 = now_price + books[now_index][0]
        else:
            result1 = self.rec(N, M, X, now_index+1, next_knowledge,  now_price + books[now_index][0], books)

        result2 = self.rec(N, M, X, now_index+1, now_knowledge,  now_price, books)

        if result1 < result2:
            return result1
        else:
            return result2

    def resolve(self):

        N, M, X = map(int, self.input_data().split())

        books = [None]*(N+1)
        for i in range(N):
            books[i+1] = np.array(list(map(int, self.input_data().split())))

        result = self.rec(N, M, X, 1, np.zeros(M), 0, books)
        if result == 12 * 10**5 +1:
            print('-1')
        else:
            print(str(result))


solver = Solver(REL_PATH)
solver.exec_resolve()


Verdicts: Wrong Answer

Accepted