Buggy python submission (verdict: Runtime Error):
import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64, int64[:], int64[:], ), cache=True)
def pre_calc(n, pos, coef):
    ret = np.empty((1 << n, n), np.int64)
    ret[0] = np.abs(pos) * coef

    for i in range(n):
        bt = 1 << i
        ret[bt:2 * bt] = np.minimum(ret[:bt], np.abs(pos - pos[i]) * coef)

    return ret


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = pre_calc(n, x, p)
    hor = pre_calc(n, y, p)

    states = np.zeros((2, pow(3, n)), np.int16)
    cnts = np.zeros(pow(3, n), np.int8)
    for i in range(pow(3, n)):
        pw2 = 1
        now = i
        for j in range(n):
            r = now % 3
            if r != 0:
                states[r - 1, i] += pw2
                cnts[i] += 1
            pw2 *= 2
            now //= 3

    vals = np.minimum(ver[states[0]], hor[states[1]]).sum(axis=1)
    ans = [INF] * (n + 1)
    for ev, ec in zip(vals, cnts):
        ans[ec] = min(ans[ec], ev)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")


Fixed submission:
import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = np.empty((1 << n, n), np.int64)
    ver[0] = np.abs(x) * p

    for i in range(n):
        bt = 1 << i
        ver[bt:2 * bt] = np.minimum(ver[:bt], np.abs(x - x[i]) * p)

    hor = np.empty((1 << n, n), np.int64)
    hor[0] = np.abs(y) * p

    for i in range(n):
        bt = 1 << i
        hor[bt:2 * bt] = np.minimum(hor[:bt], np.abs(y - y[i]) * p)

    ans = [INF] * (n + 1)
    for i in range(pow(3, n)):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            pow3, r = divmod(pow3, 3)
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")

Buggy python submission (verdict: Runtime Error):
import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64, int64[:], int64[:], ), cache=True)
def pre_calc(n, pos, coef):
    ret = np.empty((1 << n, n), np.int64)
    ret[0] = np.abs(pos) * coef

    for i in range(n):
        bt = 1 << i
        ret[bt:2 * bt] = np.minimum(ret[:bt], np.abs(pos - pos[i]) * coef)

    return ret


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = pre_calc(n, x, p)
    hor = pre_calc(n, y, p)

    states = np.zeros((2, pow(3, n)), np.int64)
    cnts = np.zeros(pow(3, n), np.int64)
    for i in range(pow(3, n)):
        pw2 = 1
        now = i
        for j in range(n):
            r = now % 3
            if r != 0:
                states[r - 1, i] += pw2
                cnts[i] += 1
            pw2 *= 2
            now //= 3

    vi, hi = states[0], states[1]
    vals = np.minimum(ver[vi], hor[hi]).sum(axis=1)
    ans = [INF] * (n + 1)
    for ev, ec in zip(vals, cnts):
        ans[ec] = min(ans[ec], ev)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")


Fixed submission:
import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = np.empty((1 << n, n), np.int64)
    ver[0] = np.abs(x) * p

    for i in range(n):
        bt = 1 << i
        ver[bt:2 * bt] = np.minimum(ver[:bt], np.abs(x - x[i]) * p)

    hor = np.empty((1 << n, n), np.int64)
    hor[0] = np.abs(y) * p

    for i in range(n):
        bt = 1 << i
        hor[bt:2 * bt] = np.minimum(hor[:bt], np.abs(y - y[i]) * p)

    ans = [INF] * (n + 1)
    for i in range(pow(3, n)):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            pow3, r = divmod(pow3, 3)
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from numba import njit
import sys

read = sys.stdin.buffer.read


@njit
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = np.empty((1 << n, n), np.int64)
    ver[0] = np.abs(x) * p

    for i in range(n):
        bt = 1 << i
        ver[bt:2 * bt] = np.minimum(ver[:bt], np.abs(x - x[i]) * p)

    hor = np.empty((1 << n, n), np.int64)
    hor[0] = np.abs(y) * p

    for i in range(n):
        bt = 1 << i
        hor[bt:2 * bt] = np.minimum(hor[:bt], np.abs(y - y[i]) * p)

    ans = [INF] * (n + 1)
    for i in range(3 ** n):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            r = pow3 % 3
            pow3 //= 3
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")


Fixed submission:
import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = np.empty((1 << n, n), np.int64)
    ver[0] = np.abs(x) * p

    for i in range(n):
        bt = 1 << i
        ver[bt:2 * bt] = np.minimum(ver[:bt], np.abs(x - x[i]) * p)

    hor = np.empty((1 << n, n), np.int64)
    hor[0] = np.abs(y) * p

    for i in range(n):
        bt = 1 << i
        hor[bt:2 * bt] = np.minimum(hor[:bt], np.abs(y - y[i]) * p)

    ans = [INF] * (n + 1)
    for i in range(pow(3, n)):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            pow3, r = divmod(pow3, 3)
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import numpy as np


def f(idx):
    ret = np.zeros((1 << n, n), np.int64)

    for i in range(1 << n):
        lines = [0]
        now = i
        for j in range(n):
            if now & 1:
                lines.append(xyp[j][idx])
            now >>= 1

        for j, (e, p) in enumerate(map(itemgetter(idx, 2), xyp)):
            dist = INF
            for el in lines:
                dist = min(dist, abs(e - el))

            ret[i, j] = dist * p

    return ret


def pow3topow2(pow3):
    v = 0
    h = 0
    cnt = 0
    pow2 = 1
    while pow3:
        pow3, r = divmod(pow3, 3)
        if r == 1:
            v += pow2
            cnt += 1
        elif r == 2:
            h += pow2
            cnt += 1

        pow2 *= 2

    return v, h, cnt


n = int(input())
xyp = [list(map(int, input().split())) for _ in range(n)]
INF = 10 ** 18

ver = f(0)
hor = f(1)

ans = [INF] * (n + 1)
powers = [pow3topow2(i) for i in range(3 ** n)]
for i in range(3 ** n):
    vi, hi, cnt = powers[i]
    score = np.minimum(ver[vi], hor[hi]).sum()
    ans[cnt] = min(ans[cnt], score)

print(*ans, sep="\n")


Fixed submission:
import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = np.empty((1 << n, n), np.int64)
    ver[0] = np.abs(x) * p

    for i in range(n):
        bt = 1 << i
        ver[bt:2 * bt] = np.minimum(ver[:bt], np.abs(x - x[i]) * p)

    hor = np.empty((1 << n, n), np.int64)
    hor[0] = np.abs(y) * p

    for i in range(n):
        bt = 1 << i
        hor[bt:2 * bt] = np.minimum(hor[:bt], np.abs(y - y[i]) * p)

    ans = [INF] * (n + 1)
    for i in range(pow(3, n)):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            pow3, r = divmod(pow3, 3)
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
import numpy as np
from numba import njit


def f(idx):
    ret = np.zeros((1 << n, n), np.int64)

    for i in range(1 << n):
        lines = [0]
        now = i
        for j in range(n):
            if now & 1:
                lines.append(xyp[j][idx])
            now >>= 1

        for j, (e, p) in enumerate(map(itemgetter(idx, 2), xyp)):
            dist = INF
            for el in lines:
                dist = min(dist, abs(e - el))

            ret[i, j] = dist * p

    return ret


@njit
def pow3topow2(pow3):
    v = 0
    h = 0
    cnt = 0
    pow2 = 1
    while pow3:
        pow3, r = divmod(pow3, 3)
        if r == 1:
            v += pow2
            cnt += 1
        elif r == 2:
            h += pow2
            cnt += 1

        pow2 *= 2

    return v, h, cnt


n = int(input())
xyp = [list(map(int, input().split())) for _ in range(n)]
INF = 10 ** 18

ver = f(0)
hor = f(1)

ans = [INF] * (n + 1)
for i in range(3 ** n):
    vi, hi, cnt = pow3topow2(i)

    score = np.minimum(ver[vi], hor[hi]).sum()

    ans[cnt] = min(ans[cnt], score)

print(*ans, sep="\n")


Fixed submission:
import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = np.empty((1 << n, n), np.int64)
    ver[0] = np.abs(x) * p

    for i in range(n):
        bt = 1 << i
        ver[bt:2 * bt] = np.minimum(ver[:bt], np.abs(x - x[i]) * p)

    hor = np.empty((1 << n, n), np.int64)
    hor[0] = np.abs(y) * p

    for i in range(n):
        bt = 1 << i
        hor[bt:2 * bt] = np.minimum(hor[:bt], np.abs(y - y[i]) * p)

    ans = [INF] * (n + 1)
    for i in range(pow(3, n)):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            pow3, r = divmod(pow3, 3)
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter


def f(idx):
    ret = []
    for i in range(1 << n):
        lines = [0]
        for j in range(n):
            if i & 1:
                lines.append(xyp[j][idx])
            i >>= 1

        costs = []
        for e, p in map(itemgetter(idx, 2), xyp):
            dist = INF
            for el in lines:
                dist = min(dist, abs(e - el))
            costs.append(dist * p)

        ret.append(costs)

    return ret


n = int(input())
xyp = [list(map(int, input().split())) for _ in range(n)]
INF = 10 ** 18

ver = f(0)
hor = f(1)

ans = [INF] * (n + 1)
for i in range(3 ** n):
    now = i
    vi = 0
    hi = 0
    power = 1
    cnt = n
    for j in range(n):
        q, r = divmod(now, 3)
        if r == 1:
            vi += power
        elif r == 2:
            hi += power
        else:
            cnt -= 1
        now = q
        power *= 2

    score = 0
    for ev, eh in zip(ver[vi], hor[hi]):
        score += min(ev, eh)

    ans[cnt] = min(ans[cnt], score)

print(*ans, sep="\n")


Fixed submission:
import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = np.empty((1 << n, n), np.int64)
    ver[0] = np.abs(x) * p

    for i in range(n):
        bt = 1 << i
        ver[bt:2 * bt] = np.minimum(ver[:bt], np.abs(x - x[i]) * p)

    hor = np.empty((1 << n, n), np.int64)
    hor[0] = np.abs(y) * p

    for i in range(n):
        bt = 1 << i
        hor[bt:2 * bt] = np.minimum(hor[:bt], np.abs(y - y[i]) * p)

    ans = [INF] * (n + 1)
    for i in range(pow(3, n)):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            pow3, r = divmod(pow3, 3)
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n = int(input())
xyp = [list(map(int, input().split())) for _ in range(n)]
INF = 10 ** 18

ver = dict()
ver[()] = [abs(x) * p for x, _, p in xyp]
for cnt in range(1, n + 1):
    for pat in combinations(range(n), cnt):
        lines = [0]
        for i in pat:
            lines.append(xyp[i][0])

        costs = []
        for x, _, p in xyp:
            dist = INF
            for e in lines:
                dist = min(dist, abs(x - e))
            costs.append(dist * p)

        ver[pat] = costs

hor = dict()
hor[()] = [abs(y) * p for _, y, p in xyp]
for cnt in range(1, n + 1):
    for pat in combinations(range(n), cnt):
        lines = [0]
        for i in pat:
            lines.append(xyp[i][1])

        costs = []
        for _, y, p in xyp:
            dist = INF
            for e in lines:
                dist = min(dist, abs(y - e))
            costs.append(dist * p)

        hor[pat] = costs

ans = [INF] * (n + 1)
for i in range(3 ** n):
    now = i
    v = []
    h = []
    cnt = n
    for j in range(n):
        q, r = divmod(now, 3)
        if r == 1:
            v.append(j)
        elif r == 2:
            h.append(j)
        else:
            cnt -= 1
        now = q

    v = tuple(v)
    h = tuple(h)

    score = 0
    for ev, eh in zip(ver[v], hor[h]):
        score += min(ev, eh)

    ans[cnt] = min(ans[cnt], score)

print(*ans, sep="\n")


Fixed submission:
import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = np.empty((1 << n, n), np.int64)
    ver[0] = np.abs(x) * p

    for i in range(n):
        bt = 1 << i
        ver[bt:2 * bt] = np.minimum(ver[:bt], np.abs(x - x[i]) * p)

    hor = np.empty((1 << n, n), np.int64)
    hor[0] = np.abs(y) * p

    for i in range(n):
        bt = 1 << i
        hor[bt:2 * bt] = np.minimum(hor[:bt], np.abs(y - y[i]) * p)

    ans = [INF] * (n + 1)
    for i in range(pow(3, n)):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            pow3, r = divmod(pow3, 3)
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n = int(input())
xyp = [list(map(int, input().split())) for _ in range(n)]
INF = 10 ** 18

ver = dict()
ver[()] = [abs(x) * p for x, _, p in xyp]
for cnt in range(1, n + 1):
    for pat in combinations(range(n), cnt):
        lines = [0]
        for i in pat:
            lines.append(xyp[i][0])

        costs = []
        for x, _, p in xyp:
            dist = INF
            for e in lines:
                dist = min(dist, abs(x - e))
            costs.append(dist * p)

        ver[pat] = costs

hor = dict()
hor[()] = [abs(y) * p for _, y, p in xyp]
for cnt in range(1, n + 1):
    for pat in combinations(range(n), cnt):
        lines = [0]
        for i in pat:
            lines.append(xyp[i][1])

        costs = []
        for _, y, p in xyp:
            dist = INF
            for e in lines:
                dist = min(dist, abs(y - e))
            costs.append(dist * p)

        hor[pat] = costs

ans = [INF] * (n + 1)
for i in range(3 ** n):
    now = i
    v = []
    h = []
    cnt = n
    for j in range(n):
        q, r = divmod(now, 3)
        if r == 1:
            v.append(j)
        elif r == 2:
            h.append(j)
        else:
            cnt -= 1
        now = q

    v = tuple(v)
    h = tuple(h)

    score = 0
    for ev, eh in zip(ver[v], hor[h]):
        score += min(ev, eh)

    ans[cnt] = min(ans[cnt], score)

print(*ans, sep="\n")


Fixed submission:
import numpy as np
from numba import njit, int64
import sys

read = sys.stdin.buffer.read


@njit((int64[:], ), cache=True)
def solve(inp):
    INF = 10 ** 18

    n = inp[0]
    x = inp[1::3]
    y = inp[2::3]
    p = inp[3::3]

    ver = np.empty((1 << n, n), np.int64)
    ver[0] = np.abs(x) * p

    for i in range(n):
        bt = 1 << i
        ver[bt:2 * bt] = np.minimum(ver[:bt], np.abs(x - x[i]) * p)

    hor = np.empty((1 << n, n), np.int64)
    hor[0] = np.abs(y) * p

    for i in range(n):
        bt = 1 << i
        hor[bt:2 * bt] = np.minimum(hor[:bt], np.abs(y - y[i]) * p)

    ans = [INF] * (n + 1)
    for i in range(pow(3, n)):
        vi = 0
        hi = 0
        cnt = 0
        pow2 = 1
        pow3 = i
        while pow3:
            pow3, r = divmod(pow3, 3)
            if r == 1:
                vi += pow2
                cnt += 1
            elif r == 2:
                hi += pow2
                cnt += 1

            pow2 *= 2

        score = np.minimum(ver[vi], hor[hi]).sum()
        ans[cnt] = min(ans[cnt], score)

    return ans


inp = np.array(read().split(), np.int64)
ans = solve(inp)
print(*ans, sep="\n")