Problem p02683 (python)

Fixed submission:
# -*- coding: utf-8 -*-

import itertools
import numpy as np


def main():

    n, m, x= map(int, input().split())
    matrix = np.array([list(map(int, input().split())) for _ in range(n)], dtype=np.int32)

    out = 10**18
    for i in itertools.product([False,True], repeat=n):
        row_sum = np.sum(matrix[np.where(i)], axis=0)
        if m == np.count_nonzero(row_sum[1:] >= x):
            out = min(out, row_sum[0])

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


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import numpy as np

def combinations(iterable, r):
    # combinations('ABCD', 2) --> AB AC AD BC BD CD
    # combinations(range(4), 3) --> 012 013 023 123
    pool = tuple(iterable)
    n = len(pool)
    if r > n:
        return
    indices = list(range(r))
    yield tuple(pool[i] for i in indices)
    while True:
        for i in reversed(range(r)):
            if indices[i] != i + n - r:
                break
        else:
            return
        indices[i] += 1
        for j in range(i+1, r):
            indices[j] = indices[j-1] + 1
        yield tuple(pool[i] for i in indices)

def main():

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

    l= []

    for i in range(n):
        for pair in combinations(matrix, i+1):
            row_sum = np.sum(pair, axis=0)
            for j in range(len(row_sum)):
                if j == 0:
                    continue
                if row_sum[j] < x:
                    break
                l.append(row_sum[0])
    if len(l) == 0:
        print('-1')
    else:
        print(min(l))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import numpy as np

def combinations(iterable, r):
    # combinations('ABCD', 2) --> AB AC AD BC BD CD
    # combinations(range(4), 3) --> 012 013 023 123
    pool = tuple(iterable)
    n = len(pool)
    if r > n:
        return
    indices = list(range(r))
    yield tuple(pool[i] for i in indices)
    while True:
        for i in reversed(range(r)):
            if indices[i] != i + n - r:
                break
        else:
            return
        indices[i] += 1
        for j in range(i+1, r):
            indices[j] = indices[j-1] + 1
        yield tuple(pool[i] for i in indices)

def main():

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

    l= []

    for i in range(n):
        for pair in combinations(matrix, i+1):
            row_sum = np.sum(pair, axis=0)
            for j in range(len(row_sum)):
                if j == 0:
                    continue
                if row_sum[j] < x:
                    break
                l.append(row_sum[0])
    if len(l) == 0:
        print('-1')
    else:
        print(min(l))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import numpy as np

def combinations(iterable, r):
    # combinations('ABCD', 2) --> AB AC AD BC BD CD
    # combinations(range(4), 3) --> 012 013 023 123
    pool = tuple(iterable)
    n = len(pool)
    if r > n:
        return
    indices = list(range(r))
    yield tuple(pool[i] for i in indices)
    while True:
        for i in reversed(range(r)):
            if indices[i] != i + n - r:
                break
        else:
            return
        indices[i] += 1
        for j in range(i+1, r):
            indices[j] = indices[j-1] + 1
        yield tuple(pool[i] for i in indices)

def main():

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

    l= []

    for i in range(N):
        for pair in combinations(matrix, i+1):
            row_sum = np.sum(pair, axis=0)
            for j in range(len(row_sum)):
                if j == 0:
                    continue
                if row_sum[j] < X:
                    break
                l.append(row_sum[0])
    if len(l) == 0:
        print('-1')
    else:
        print(min(l))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import itertools
import numpy as np

def main():

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

    l= []

    for i in range(N):
        for pair in itertools.combinations(matrix, i+1):
            row_sum = np.sum(pair, axis=0)
            for j in range(len(row_sum)):
                if j == 0:
                    continue
                if row_sum[j] < X:
                    break
                l.append(row_sum[0])


    if len(l) == 0:
        print('-1')
    else:
        print(min(l))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import itertools
import numpy as np

def main():

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

    l= []

    for i in range(N):
        for pair in itertools.combinations(matrix, i+1):
            row_sum = np.sum(pair, axis=0)
            for j in range(len(row_sum)):
                if j == 0:
                    continue
                if row_sum[j] < X:
                    break
                l.append(row_sum[0])


    if len(l) == 0:
        print('-1')
    else:
        print(min(l))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import itertools
import numpy as np

def main():

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

    l= []

    for i in range(N):
        for pair in itertools.combinations(matrix, i+1):
            row_sum = np.sum(pair, axis=0)
            print(row_sum)
            for j in range(len(row_sum)):
                if j == 0:
                    continue
                if row_sum[j] < X:
                    break
                l.append(row_sum[0])


    if len(l) == 0:
        print('-1')
    else:
        print(min(l))
if __name__ == '__main__':
    main()