Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
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)

Buggy python submission (verdict: Runtime Error):
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:
    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)

Fixed submission:
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)

Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
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)