Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XYP = [list(map(int, readline().split())) for _ in range(N)]

x_cost = [0] * ((1 << N) * N)
y_cost = [0] * ((1 << N) * N)

for bit in range(1 << N):
    for i, (xi, yi, _) in enumerate(XYP):
        x_cost[bit * N + i] = abs(xi)
        y_cost[bit * N + i] = abs(yi)

        for k, (xk, yk, _) in enumerate(XYP):
            if bit & (1 << k):
                x_cost[bit * N + i] = min(x_cost[bit * N + i], abs(xi - xk))
                y_cost[bit * N + i] = min(y_cost[bit * N + i], abs(yi - yk))

ans = [sys.maxsize for _ in range(N + 1)]

for bit in range(1 << N):
    cnt = bin(bit).count('1')
    bit_ = bit
    while bit_ >= 0:
        bit_ &= bit
        cost = 0
        for k in range(N):
            cost += 1 * XYP[k][2] * min(x_cost[bit_ * N + k],
                                        y_cost[(bit - bit_) * N + k])
        ans[cnt] = min(ans[cnt], cost)

        bit_ -= 1
for i in range(N + 1):
    print(ans[i])

Fixed submission:
#! /usr/bin/env python3

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XYP = [list(map(int, readline().split())) for _ in range(N)]

costs = [sys.maxsize] * N
for i, (x, y, c) in enumerate(XYP):
    costs[i] = c * min(abs(x), abs(y))

x_cost = [sys.maxsize] * ((1 << N) * N)
y_cost = [sys.maxsize] * ((1 << N) * N)

for bit in range(1 << N):
    for i, (xi, yi, _) in enumerate(XYP):
        x_cost[bit * N + i] = min(costs[i], x_cost[bit * N + i])
        y_cost[bit * N + i] = min(costs[i], y_cost[bit * N + i])
        if not (bit & (1 << i)):
            continue
        for k, (xk, yk, c) in enumerate(XYP):
            x_cost[bit * N + k] = min(x_cost[bit * N + k], abs(xi - xk) * c)
            y_cost[bit * N + k] = min(y_cost[bit * N + k], abs(yi - yk) * c)

ans = [sys.maxsize] * (N + 1)

for bit in range(1 << N):
    cnt = bin(bit).count('1')
    bit_ = bit
    while bit_ >= 0:
        bit_ &= bit
        cost = 0
        y_bit = bit - bit_
        for k in range(N):
            cost += min(x_cost[bit_ * N + k], y_cost[(y_bit) * N + k])
        ans[cnt] = min(ans[cnt], cost)

        bit_ -= 1
for i in range(N + 1):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XYP = [list(map(int, readline().split())) for _ in range(N)]

x_cost = [0] * ((1 << N) * N)
y_cost = [0] * ((1 << N) * N)

for bit in range(1 << N):
    for i, (xi, yi, _) in enumerate(XYP):
        x_cost[bit * N + i] = abs(xi)
        y_cost[bit * N + i] = abs(yi)

        for k, (xk, yk, _) in enumerate(XYP):
            if bit & (1 << k):
                x_cost[bit * N + i] = min(x_cost[bit * N + i], abs(xi - xk))
                y_cost[bit * N + i] = min(y_cost[bit * N + i], abs(yi - yk))

ans = [sys.maxsize for _ in range(N + 1)]

for bit in range(1 << N):
    cnt = bin(bit).count('1')
    bit_ = bit
    while bit_ >= 0:
        bit_ &= bit
        cost = 0
        for k in range(N):
            cost += 1 * XYP[k][2] * min(x_cost[bit_ * N + k],
                                        y_cost[(bit - bit_) * N + k])
        ans[cnt] = min(ans[cnt], cost)

        bit_ -= 1
for i in range(N + 1):
    print(ans[i])

Fixed submission:
#! /usr/bin/env python3

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XYP = [list(map(int, readline().split())) for _ in range(N)]

costs = [sys.maxsize] * N
for i, (x, y, c) in enumerate(XYP):
    costs[i] = c * min(abs(x), abs(y))

x_cost = [sys.maxsize] * ((1 << N) * N)
y_cost = [sys.maxsize] * ((1 << N) * N)

for bit in range(1 << N):
    for i, (xi, yi, _) in enumerate(XYP):
        x_cost[bit * N + i] = min(costs[i], x_cost[bit * N + i])
        y_cost[bit * N + i] = min(costs[i], y_cost[bit * N + i])
        if not (bit & (1 << i)):
            continue
        for k, (xk, yk, c) in enumerate(XYP):
            x_cost[bit * N + k] = min(x_cost[bit * N + k], abs(xi - xk) * c)
            y_cost[bit * N + k] = min(y_cost[bit * N + k], abs(yi - yk) * c)

ans = [sys.maxsize] * (N + 1)

for bit in range(1 << N):
    cnt = bin(bit).count('1')
    bit_ = bit
    while bit_ >= 0:
        bit_ &= bit
        cost = 0
        y_bit = bit - bit_
        for k in range(N):
            cost += min(x_cost[bit_ * N + k], y_cost[(y_bit) * N + k])
        ans[cnt] = min(ans[cnt], cost)

        bit_ -= 1
for i in range(N + 1):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XYP = [list(map(int, readline().split())) for _ in range(N)]

x_cost = [[0 for _ in range(N)] for _ in range(1 << N)]
y_cost = [[0 for _ in range(N)] for _ in range(1 << N)]

for bit in range(1 << N):
    for i in range(N):
        x_cost[bit][i] = abs(XYP[i][0])
        y_cost[bit][i] = abs(XYP[i][1])

        for k in range(N):
            if bit & (1 << k):
                x_cost[bit][i] = min(x_cost[bit][i], abs(XYP[i][0] - XYP[k][0]))
                y_cost[bit][i] = min(y_cost[bit][i], abs(XYP[i][1] - XYP[k][1]))

ans = [sys.maxsize for _ in range(N + 1)]

for bit in range(1 << N):
    cnt = bin(bit).count('1')
    bit_ = bit
    while bit_ >= 0:
        bit_ &= bit
        cost = 0
        for k in range(N):
            cost += 1 * XYP[k][2] * min(x_cost[bit_][k], y_cost[bit - bit_][k])
        ans[cnt] = min(ans[cnt], cost)

        bit_ -= 1
for i in range(N + 1):
    print(ans[i])

Fixed submission:
#! /usr/bin/env python3

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XYP = [list(map(int, readline().split())) for _ in range(N)]

costs = [sys.maxsize] * N
for i, (x, y, c) in enumerate(XYP):
    costs[i] = c * min(abs(x), abs(y))

x_cost = [sys.maxsize] * ((1 << N) * N)
y_cost = [sys.maxsize] * ((1 << N) * N)

for bit in range(1 << N):
    for i, (xi, yi, _) in enumerate(XYP):
        x_cost[bit * N + i] = min(costs[i], x_cost[bit * N + i])
        y_cost[bit * N + i] = min(costs[i], y_cost[bit * N + i])
        if not (bit & (1 << i)):
            continue
        for k, (xk, yk, c) in enumerate(XYP):
            x_cost[bit * N + k] = min(x_cost[bit * N + k], abs(xi - xk) * c)
            y_cost[bit * N + k] = min(y_cost[bit * N + k], abs(yi - yk) * c)

ans = [sys.maxsize] * (N + 1)

for bit in range(1 << N):
    cnt = bin(bit).count('1')
    bit_ = bit
    while bit_ >= 0:
        bit_ &= bit
        cost = 0
        y_bit = bit - bit_
        for k in range(N):
            cost += min(x_cost[bit_ * N + k], y_cost[(y_bit) * N + k])
        ans[cnt] = min(ans[cnt], cost)

        bit_ -= 1
for i in range(N + 1):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XYP = [list(map(int, readline().split())) for _ in range(N)]

x_cost = [[0 for _ in range(N)] for _ in range(1 << N)]
y_cost = [[0 for _ in range(N)] for _ in range(1 << N)]

for bit in range(1 << N):
    for i in range(N):
        x_cost[bit][i] = abs(XYP[i][0])
        y_cost[bit][i] = abs(XYP[i][1])

        for k in range(N):
            if bit & (1 << k):
                x_cost[bit][i] = min(x_cost[bit][i], abs(XYP[i][0] - XYP[k][0]))
                y_cost[bit][i] = min(y_cost[bit][i], abs(XYP[i][1] - XYP[k][1]))

ans = [sys.maxsize for _ in range(N + 1)]

for bit in range(1 << N):
    cnt = bin(bit).count('1')
    bit_ = bit
    while bit_ >= 0:
        bit_ &= bit
        cost = 0
        for k in range(N):
            cost += 1 * XYP[k][2] * min(x_cost[bit_][k], y_cost[bit - bit_][k])
        ans[cnt] = min(ans[cnt], cost)

        bit_ -= 1
for i in range(N + 1):
    print(ans[i])

Fixed submission:
#! /usr/bin/env python3

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XYP = [list(map(int, readline().split())) for _ in range(N)]

costs = [sys.maxsize] * N
for i, (x, y, c) in enumerate(XYP):
    costs[i] = c * min(abs(x), abs(y))

x_cost = [sys.maxsize] * ((1 << N) * N)
y_cost = [sys.maxsize] * ((1 << N) * N)

for bit in range(1 << N):
    for i, (xi, yi, _) in enumerate(XYP):
        x_cost[bit * N + i] = min(costs[i], x_cost[bit * N + i])
        y_cost[bit * N + i] = min(costs[i], y_cost[bit * N + i])
        if not (bit & (1 << i)):
            continue
        for k, (xk, yk, c) in enumerate(XYP):
            x_cost[bit * N + k] = min(x_cost[bit * N + k], abs(xi - xk) * c)
            y_cost[bit * N + k] = min(y_cost[bit * N + k], abs(yi - yk) * c)

ans = [sys.maxsize] * (N + 1)

for bit in range(1 << N):
    cnt = bin(bit).count('1')
    bit_ = bit
    while bit_ >= 0:
        bit_ &= bit
        cost = 0
        y_bit = bit - bit_
        for k in range(N):
            cost += min(x_cost[bit_ * N + k], y_cost[(y_bit) * N + k])
        ans[cnt] = min(ans[cnt], cost)

        bit_ -= 1
for i in range(N + 1):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3

import sys
import numpy as np
from itertools import combinations
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XYP = [list(map(int, readline().split())) for _ in range(N)]

x_cost = [[0 for _ in range(N)] for _ in range(1 << N)]
y_cost = [[0 for _ in range(N)] for _ in range(1 << N)]

for bit in range(1 << N):
    for i in range(N):
        x_cost[bit][i] = abs(XYP[i][0])
        y_cost[bit][i] = abs(XYP[i][1])

        for k in range(N):
            if bit & (1 << k):
                x_cost[bit][i] = min(x_cost[bit][i], abs(XYP[i][0] - XYP[k][0]))
                y_cost[bit][i] = min(y_cost[bit][i], abs(XYP[i][1] - XYP[k][1]))

ans = [sys.maxsize for _ in range(N + 1)]

for bit in range(1 << N):
    cnt = bin(bit).count('1')
    for i in range(bit, -1, -1):
        i &= bit
        cost = 0
        for k in range(N):
            if ~(bit & (1 << k)):
                cost += 1 * XYP[k][2] * min(x_cost[i][k], y_cost[bit - i][k])
        ans[cnt] = min(ans[cnt], cost)

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

Fixed submission:
#! /usr/bin/env python3

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XYP = [list(map(int, readline().split())) for _ in range(N)]

costs = [sys.maxsize] * N
for i, (x, y, c) in enumerate(XYP):
    costs[i] = c * min(abs(x), abs(y))

x_cost = [sys.maxsize] * ((1 << N) * N)
y_cost = [sys.maxsize] * ((1 << N) * N)

for bit in range(1 << N):
    for i, (xi, yi, _) in enumerate(XYP):
        x_cost[bit * N + i] = min(costs[i], x_cost[bit * N + i])
        y_cost[bit * N + i] = min(costs[i], y_cost[bit * N + i])
        if not (bit & (1 << i)):
            continue
        for k, (xk, yk, c) in enumerate(XYP):
            x_cost[bit * N + k] = min(x_cost[bit * N + k], abs(xi - xk) * c)
            y_cost[bit * N + k] = min(y_cost[bit * N + k], abs(yi - yk) * c)

ans = [sys.maxsize] * (N + 1)

for bit in range(1 << N):
    cnt = bin(bit).count('1')
    bit_ = bit
    while bit_ >= 0:
        bit_ &= bit
        cost = 0
        y_bit = bit - bit_
        for k in range(N):
            cost += min(x_cost[bit_ * N + k], y_cost[(y_bit) * N + k])
        ans[cnt] = min(ans[cnt], cost)

        bit_ -= 1
for i in range(N + 1):
    print(ans[i])