Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def solve():
    xc = [[0] * n for _ in range(1 << n)]
    yc = [[0] * n for _ in range(1 << n)]
    for s in range(1 << n):
        for i,(x, y, p) in enumerate(xyp):
            xcost = abs(x)
            ycost = abs(y)
            for j, (lx, ly, _) in enumerate(xyp):
                if s >> j & 1 == 0: continue
                xcost = min(xcost, abs(x - lx))
                ycost = min(ycost, abs(y - ly))
            xc[s][i] = xcost * p
            yc[s][i] = ycost * p

    ans = [inf] * (n + 1)
    for s in range(1 << n):
        k = bin(s).count("1")
        xs = (1 << n) - 1
        while xs > 0:
            xs &= s
            xcs=xc[xs]
            ycs=yc[s-xs]
            ans[k]=min(ans[k], sum(min(xcs[i], ycs[i]) for i in range(n)))
            xs -= 1

    for a in ans: print(a)

inf = 10 ** 16
n = II()
xyp = LLI(n)

solve()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def solve():
    xc = [[0] * n for _ in range(1 << n)]
    yc = [[0] * n for _ in range(1 << n)]
    for s in range(1 << n):
        xcs = xc[s]
        ycs = yc[s]
        for i, (x, y, p) in enumerate(xyp):
            xcost = abs(x)
            ycost = abs(y)
            for j, (lx, ly, _) in enumerate(xyp):
                if s >> j & 1 == 0: continue
                if abs(x - lx) < xcost: xcost = abs(x - lx)
                if abs(y - ly) < ycost: ycost = abs(y - ly)
            xcs[i] = xcost * p
            ycs[i] = ycost * p
    # print(xc)

    ans = [inf] * (n + 1)
    for s in range(1 << n):
        k = bin(s).count("1")
        xs = (1 << n) - 1
        while xs > 0:
            xs &= s
            xcs = xc[xs]
            ycs = yc[s - xs]
            cur = 0
            for i in range(n): cur += min(xcs[i], ycs[i])
            if cur < ans[k]: ans[k] = cur
            xs -= 1

    for a in ans: print(a)

inf = 10 ** 16
n = II()
xyp = LLI(n)

solve()

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

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def solve():
    xc = [[0] * n for _ in range(1 << n)]
    yc = [[0] * n for _ in range(1 << n)]
    for s in range(1 << n):
        for i,(x, y, p) in enumerate(xyp):
            xcost = abs(x)
            ycost = abs(y)
            for j, (lx, ly, _) in enumerate(xyp):
                if s >> j & 1 == 0: continue
                xcost = min(xcost, abs(x - lx))
                ycost = min(ycost, abs(y - ly))
            xc[s][i] = xcost * p
            yc[s][i] = ycost * p

    def chmin(i, val):
        if ans[i] > val: ans[i] = val

    ans = [inf] * (n + 1)
    for s in range(1 << n):
        k = bin(s).count("1")
        xs = (1 << n) - 1
        while xs > 0:
            xs &= s
            chmin(k, sum(min(xc[xs][i], yc[s - xs][i]) for i in range(n)))
            xs -= 1

    for a in ans: print(a)

inf = 10 ** 16
n = II()
xyp = LLI(n)

solve()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def solve():
    xc = [[0] * n for _ in range(1 << n)]
    yc = [[0] * n for _ in range(1 << n)]
    for s in range(1 << n):
        xcs = xc[s]
        ycs = yc[s]
        for i, (x, y, p) in enumerate(xyp):
            xcost = abs(x)
            ycost = abs(y)
            for j, (lx, ly, _) in enumerate(xyp):
                if s >> j & 1 == 0: continue
                if abs(x - lx) < xcost: xcost = abs(x - lx)
                if abs(y - ly) < ycost: ycost = abs(y - ly)
            xcs[i] = xcost * p
            ycs[i] = ycost * p
    # print(xc)

    ans = [inf] * (n + 1)
    for s in range(1 << n):
        k = bin(s).count("1")
        xs = (1 << n) - 1
        while xs > 0:
            xs &= s
            xcs = xc[xs]
            ycs = yc[s - xs]
            cur = 0
            for i in range(n): cur += min(xcs[i], ycs[i])
            if cur < ans[k]: ans[k] = cur
            xs -= 1

    for a in ans: print(a)

inf = 10 ** 16
n = II()
xyp = LLI(n)

solve()

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

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def solve():
    itox = list(sorted(set([x for x, y, p in xyp])))
    xtoi = {x: i for i, x in enumerate(itox)}
    xc = [[0] * (1 << len(itox)) for _ in range(n)]
    for bit in range(1 << len(itox)):
        xx = [-inf]
        for i in range(len(itox)):
            if bit >> i & 1: xx.append(itox[i])
        xx.append(inf)
        for i, (x, y, p) in enumerate(xyp):
            j = bisect(xx, x)
            xc[i][bit] = min(x - xx[j - 1], xx[j] - x, abs(x)) * p
    # print(itox)
    # p2D(xc)

    itoy = list(sorted(set([y for x, y, p in xyp])))
    ytoi = {y: i for i, y in enumerate(itoy)}
    yc = [[0] * (1 << len(itoy)) for _ in range(n)]
    for bit in range(1 << len(itoy)):
        yy = [-inf]
        for i in range(len(itoy)):
            if bit >> i & 1: yy.append(itoy[i])
        yy.append(inf)
        for i, (x, y, p) in enumerate(xyp):
            j = bisect(yy, y)
            yc[i][bit] = min(y - yy[j - 1], yy[j] - y, abs(y)) * p

    # print(itoy)
    # p2D(yc)

    def chmin(i, val): ans[i] = min(ans[i], val)

    ans = [inf] * (n + 1)
    for aa in product(range(3), repeat=n):
        xb = yb = 0
        cl = 0
        for a, (x, y, p) in zip(aa, xyp):
            if a == 1: xb |= 1 << xtoi[x]
            if a == 2: yb |= 1 << ytoi[y]
            if a: cl += 1
        chmin(cl, sum(min(xc[i][xb], yc[i][yb]) for i in range(n)))

    for i in range(n):
        if ans[i] == inf: ans[i] = 0

    for a in ans: print(a)

inf=10**16
n=II()
xyp=[]
for _ in range(n):
    x,y,p=MI()
    if x*y==0:continue
    xyp.append((x,y,p))

solve()

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def solve():
    xc = [[0] * n for _ in range(1 << n)]
    yc = [[0] * n for _ in range(1 << n)]
    for s in range(1 << n):
        xcs = xc[s]
        ycs = yc[s]
        for i, (x, y, p) in enumerate(xyp):
            xcost = abs(x)
            ycost = abs(y)
            for j, (lx, ly, _) in enumerate(xyp):
                if s >> j & 1 == 0: continue
                if abs(x - lx) < xcost: xcost = abs(x - lx)
                if abs(y - ly) < ycost: ycost = abs(y - ly)
            xcs[i] = xcost * p
            ycs[i] = ycost * p
    # print(xc)

    ans = [inf] * (n + 1)
    for s in range(1 << n):
        k = bin(s).count("1")
        xs = (1 << n) - 1
        while xs > 0:
            xs &= s
            xcs = xc[xs]
            ycs = yc[s - xs]
            cur = 0
            for i in range(n): cur += min(xcs[i], ycs[i])
            if cur < ans[k]: ans[k] = cur
            xs -= 1

    for a in ans: print(a)

inf = 10 ** 16
n = II()
xyp = LLI(n)

solve()

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

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def solve():
    itox = list(sorted(set([x for x, y, p in xyp])))
    xtoi = {x: i for i, x in enumerate(itox)}
    xc = [[0] * (1 << len(itox)) for _ in range(n)]
    for bit in range(1 << len(itox)):
        xx = [-inf]
        for i in range(len(itox)):
            if bit >> i & 1: xx.append(itox[i])
        xx.append(inf)
        for i, (x, y, p) in enumerate(xyp):
            j = bisect(xx, x)
            xc[i][bit] = min(x - xx[j - 1], xx[j] - x, abs(x)) * p
    # print(itox)
    # p2D(xc)

    itoy = list(sorted(set([y for x, y, p in xyp])))
    ytoi = {y: i for i, y in enumerate(itoy)}
    yc = [[0] * (1 << len(itoy)) for _ in range(n)]
    for bit in range(1 << len(itoy)):
        yy = [-inf]
        for i in range(len(itoy)):
            if bit >> i & 1: yy.append(itoy[i])
        yy.append(inf)
        for i, (x, y, p) in enumerate(xyp):
            j = bisect(yy, y)
            yc[i][bit] = min(y - yy[j - 1], yy[j] - y, abs(y)) * p

    # print(itoy)
    # p2D(yc)

    def chmin(i, val): ans[i] = min(ans[i], val)

    ans = [inf] * (n + 1)
    for aa in product(range(3), repeat=n):
        xb = yb = 0
        cl = 0
        for a, (x, y, p) in zip(aa, xyp):
            if a == 1: xb |= 1 << xtoi[x]
            if a == 2: yb |= 1 << ytoi[y]
            if a: cl += 1
        chmin(cl, sum(min(xc[i][xb], yc[i][yb]) for i in range(n)))

    for i in range(n):
        if ans[i] == inf: ans[i] = 0

    for a in ans: print(a)

inf=10**16
n=II()
xyp=[]
for _ in range(n):
    x,y,p=MI()
    if x*y==0:continue
    xyp.append((x,y,p))

solve()

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def solve():
    xc = [[0] * n for _ in range(1 << n)]
    yc = [[0] * n for _ in range(1 << n)]
    for s in range(1 << n):
        xcs = xc[s]
        ycs = yc[s]
        for i, (x, y, p) in enumerate(xyp):
            xcost = abs(x)
            ycost = abs(y)
            for j, (lx, ly, _) in enumerate(xyp):
                if s >> j & 1 == 0: continue
                if abs(x - lx) < xcost: xcost = abs(x - lx)
                if abs(y - ly) < ycost: ycost = abs(y - ly)
            xcs[i] = xcost * p
            ycs[i] = ycost * p
    # print(xc)

    ans = [inf] * (n + 1)
    for s in range(1 << n):
        k = bin(s).count("1")
        xs = (1 << n) - 1
        while xs > 0:
            xs &= s
            xcs = xc[xs]
            ycs = yc[s - xs]
            cur = 0
            for i in range(n): cur += min(xcs[i], ycs[i])
            if cur < ans[k]: ans[k] = cur
            xs -= 1

    for a in ans: print(a)

inf = 10 ** 16
n = II()
xyp = LLI(n)

solve()