Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    N = int(input().strip())
    XYP = np.empty((N, 3), dtype=np.int32)
    for i in range(N):
        XYP[i] = np.fromstring(input().strip(), sep=" ")
    return N, XYP


@njit
def solve(N, XYP, INF=10**18):
    ans = np.full(N+1, INF, dtype=np.int64)
    vcost = np.zeros((N, 2**N), dtype=np.int32)
    hcost = np.zeros((N, 2**N), dtype=np.int32)

    # check 2**N pairs
    for intptn in range(2**N):
        for i in range(N):
            xi, yi, pi = XYP[i]
            v = abs(xi)
            h = abs(yi)
            for j in range(N):
                xj, yj, pj = XYP[j]
                if (intptn >> j) & 1 == 1:
                    v = min(v, abs(xj-xi))
                    h = min(h, abs(yj-yi))
            vcost[i, intptn] += v
            hcost[i, intptn] += h

    # check 3**N pairs
    for intptn in range(3**N):
        # split into two 2**N pairs
        p, intvptn, inthptn = intptn, 0, 0
        u = 0
        for i in range(N):
            if p % 3 == 1:
                intvptn += 1 << (N-i-1)
                u += 1
            elif p % 3 == 2:
                inthptn += 1 << (N-i-1)
                u += 1
            p //= 3
        s = 0
        for i in range(N):
            s += min(vcost[i, intvptn], hcost[i, inthptn]) * XYP[i, 2]
        ans[u] = min(ans[u], s)
    
    return ans


if __name__ == '__main__':
    inputs = read()
    ans = solve(*inputs)
    for a in ans:
        print(a)


Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    N = int(input().strip())
    XYP = np.empty((N, 3), dtype=np.int32)
    for i in range(N):
        XYP[i] = np.fromstring(input().strip(), sep=" ")
    return N, XYP


@njit
def solve(N, XYP, INF=10**18):
    ans = np.full(N+1, INF, dtype=np.int64)
    vcost = np.zeros((2**N, N), dtype=np.int32)
    hcost = np.zeros((2**N, N), dtype=np.int32)

    # check 2**N pairs
    for intptn in range(2**N):
        for i in range(N):
            xi, yi, pi = XYP[i]
            v = abs(xi)
            h = abs(yi)
            for j in range(N):
                xj, yj, pj = XYP[j]
                if (intptn >> j) & 1 == 1:
                    v = min(v, abs(xj-xi))
                    h = min(h, abs(yj-yi))
            vcost[intptn, i] += v
            hcost[intptn, i] += h

    # check 3**N pairs
    for intptn in range(3**N):
        # split into two 2**N pairs
        p, intvptn, inthptn = intptn, 0, 0
        u = 0
        for i in range(N):
            if p % 3 == 1:
                intvptn += 1 << (N-i-1)
                u += 1
            elif p % 3 == 2:
                inthptn += 1 << (N-i-1)
                u += 1
            p //= 3
        s = 0
        for i in range(N):
            s += min(vcost[intvptn, i], hcost[inthptn, i]) * XYP[i, 2]
        ans[u] = min(ans[u], s)
    
    return ans


if __name__ == '__main__':
    inputs = read()
    ans = solve(*inputs)
    for a in ans:
        print(a)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from itertools import product


def read():
    N = int(input().strip())
    XYP = []
    for i in range(N):
        x, y, p = map(int, input().strip().split())
        XYP.append((x, y, p))
    return N, XYP


def solve(N, XYP, INF=10**18):
    ans = [INF for i in range(N+1)]
    vcost = [[0 for j in range(2**N)] for i in range(N)]
    hcost = [[0 for j in range(2**N)] for i in range(N)]

    # check 2**N pairs
    for intptn in range(2**N):
        for i, (xi, yi, pi) in enumerate(XYP):
            v = abs(xi)
            h = abs(yi)
            for j, (xj, yj, pj) in enumerate(XYP):
                if (intptn >> j) & 1 == 1:
                    v = min(v, abs(xj-xi))
                    h = min(h, abs(yj-yi))
            vcost[i][intptn] += v * pi
            hcost[i][intptn] += h * pi

    # check 3**N pairs
    for ptn in product(range(3), repeat=N):
        # split into two 2**N pairs
        intvptn = sum([1<<(N-i-1) for i in range(N) if ptn[i]==1])
        inthptn = sum([1<<(N-i-1) for i in range(N) if ptn[i]==2])
        s = 0
        for i in range(N):
            s += min(vcost[i][intvptn], hcost[i][inthptn])
        u = sum([t>0 for t in ptn])
        ans[u] = min(ans[u], s)

    for u in range(N+1):
        print(ans[u])


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)


Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    N = int(input().strip())
    XYP = np.empty((N, 3), dtype=np.int32)
    for i in range(N):
        XYP[i] = np.fromstring(input().strip(), sep=" ")
    return N, XYP


@njit
def solve(N, XYP, INF=10**18):
    ans = np.full(N+1, INF, dtype=np.int64)
    vcost = np.zeros((2**N, N), dtype=np.int32)
    hcost = np.zeros((2**N, N), dtype=np.int32)

    # check 2**N pairs
    for intptn in range(2**N):
        for i in range(N):
            xi, yi, pi = XYP[i]
            v = abs(xi)
            h = abs(yi)
            for j in range(N):
                xj, yj, pj = XYP[j]
                if (intptn >> j) & 1 == 1:
                    v = min(v, abs(xj-xi))
                    h = min(h, abs(yj-yi))
            vcost[intptn, i] += v
            hcost[intptn, i] += h

    # check 3**N pairs
    for intptn in range(3**N):
        # split into two 2**N pairs
        p, intvptn, inthptn = intptn, 0, 0
        u = 0
        for i in range(N):
            if p % 3 == 1:
                intvptn += 1 << (N-i-1)
                u += 1
            elif p % 3 == 2:
                inthptn += 1 << (N-i-1)
                u += 1
            p //= 3
        s = 0
        for i in range(N):
            s += min(vcost[intvptn, i], hcost[inthptn, i]) * XYP[i, 2]
        ans[u] = min(ans[u], s)
    
    return ans


if __name__ == '__main__':
    inputs = read()
    ans = solve(*inputs)
    for a in ans:
        print(a)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
from bisect import bisect_left


def read():
    N = int(input())
    XYP = []
    for i in range(N):
        x, y, p = map(int, input().split())
        XYP.append((x, y, p))
    return N, XYP



def solve(N, XYP, INF=1<<61):
    # 3^N通り全て試す
    # 東西、左右、道なしの3通り
    minK = [INF for i in range(N+1)]

    for ptn in product(range(3), repeat=N):
        nh = ptn.count(1)
        nv = ptn.count(2)
        k = nh + nv
        # calculate score
        score = 0
        nearest_x = [abs(x)*p for x, y, p in XYP]
        nearest_y = [abs(y)*p for x, y, p in XYP]
        for i in range(N):
            x, y, p = XYP[i]
            for j in range(N):
                x1, y1, p1 = XYP[j]
                if ptn[j] == 1:
                    nearest_x[i] = min(nearest_x[i], abs(x - x1)*p)
                elif ptn[j] == 2:
                    nearest_y[i] = min(nearest_y[i], abs(y -y1) * p)
                
        for i in range(N):
            score += min(nearest_x[i], nearest_y[i])
        minK[k] = min(minK[k], score)
    
    for k in range(0, N+1):
        print(minK[k])
    


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)


Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    N = int(input().strip())
    XYP = np.empty((N, 3), dtype=np.int32)
    for i in range(N):
        XYP[i] = np.fromstring(input().strip(), sep=" ")
    return N, XYP


@njit
def solve(N, XYP, INF=10**18):
    ans = np.full(N+1, INF, dtype=np.int64)
    vcost = np.zeros((2**N, N), dtype=np.int32)
    hcost = np.zeros((2**N, N), dtype=np.int32)

    # check 2**N pairs
    for intptn in range(2**N):
        for i in range(N):
            xi, yi, pi = XYP[i]
            v = abs(xi)
            h = abs(yi)
            for j in range(N):
                xj, yj, pj = XYP[j]
                if (intptn >> j) & 1 == 1:
                    v = min(v, abs(xj-xi))
                    h = min(h, abs(yj-yi))
            vcost[intptn, i] += v
            hcost[intptn, i] += h

    # check 3**N pairs
    for intptn in range(3**N):
        # split into two 2**N pairs
        p, intvptn, inthptn = intptn, 0, 0
        u = 0
        for i in range(N):
            if p % 3 == 1:
                intvptn += 1 << (N-i-1)
                u += 1
            elif p % 3 == 2:
                inthptn += 1 << (N-i-1)
                u += 1
            p //= 3
        s = 0
        for i in range(N):
            s += min(vcost[intvptn, i], hcost[inthptn, i]) * XYP[i, 2]
        ans[u] = min(ans[u], s)
    
    return ans


if __name__ == '__main__':
    inputs = read()
    ans = solve(*inputs)
    for a in ans:
        print(a)