Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


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

    MONEY = []
    UNDERSTAND = []
    for i in range(n):
        lst = [int(i) for i in input().split()]
        MONEY.append(lst[0])
        UNDERSTAND.append(lst[1:])

    ans = []
    for i in range(1 << n):
        understand = [0] * m
        money = 0
        for j in range(n):
            if (i >> j) & 1 == 0:
                continue
            money += MONEY[j]
            for k in range(m):
                understand[k] += UNDERSTAND[j][k]
        if all([i >= x for i in understand]):
            ans.append(money)

    print(min(ans))


if __name__ == '__main__':
    main()


Fixed submission:
import itertools
n, m, x = map(int, input().split())
lst = []

for i in range(n):
    lst.append([int(i) for i in input().split()])

ans_list = []

for i in range(1, n + 1):
    for j in itertools.combinations(lst, i):
        under_list = [0] * m
        money = 0
        for k in j:
            money += k[0]
            for i in range(m):
                under_list[i] += k[i + 1]
        if all([i >= x for i in under_list]):
            ans_list.append(money)

if not ans_list:
    ans = -1
else:
    ans = min(ans_list)

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readlinedef


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

    MONEY = []
    UNDERSTAND = []
    for i in range(n):
        lst = [int(i) for i in input().split()]
        MONEY.append(lst[0])
        UNDERSTAND.append(lst[1:])

    ans = []
    for i in range(1 << n):
        understand = [0] * m
        money = 0
        for j in range(n):
            if (i >> j) & 1 == 0:
                continue
            money += MONEY[j]
            for k in range(m):
                understand[k] += UNDERSTAND[j][k]
        if all([i >= x for i in understand]):
            ans.append(money)

    print(min(ans))


if __name__ == '__main__':
    main()

Fixed submission:
import itertools
n, m, x = map(int, input().split())
lst = []

for i in range(n):
    lst.append([int(i) for i in input().split()])

ans_list = []

for i in range(1, n + 1):
    for j in itertools.combinations(lst, i):
        under_list = [0] * m
        money = 0
        for k in j:
            money += k[0]
            for i in range(m):
                under_list[i] += k[i + 1]
        if all([i >= x for i in under_list]):
            ans_list.append(money)

if not ans_list:
    ans = -1
else:
    ans = min(ans_list)

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


def main():
    n, m, x = map(int, input().split())
    lst = [[int(i) for i in input().split()] for _ in range(n)]

    ans = []
    for i in range(1 << n):
        understand = []
        money = 0
        for j in range(n):
            if (i >> j) & 1 == 0:
                continue
            money += lst[0]
            for k in range(m):
                understand[k] += lst[k + 1]
        if all([i >= x for i in understand]):
            ans.append(money)

    print(min(ans))


if __name__ == '__main__':
    main()


Fixed submission:
import itertools
n, m, x = map(int, input().split())
lst = []

for i in range(n):
    lst.append([int(i) for i in input().split()])

ans_list = []

for i in range(1, n + 1):
    for j in itertools.combinations(lst, i):
        under_list = [0] * m
        money = 0
        for k in j:
            money += k[0]
            for i in range(m):
                under_list[i] += k[i + 1]
        if all([i >= x for i in under_list]):
            ans_list.append(money)

if not ans_list:
    ans = -1
else:
    ans = min(ans_list)

print(ans)