Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    xyp = [list(map(int, input().split())) for _ in [0]*n]
    d = []

    def calc(seq):
        m = len(seq)
        dp = [[10**15]*(m+1) for _ in [0]*(m+1)]
        dp[0][0] = 0
        for i in range(m):
            s = seq[i][0]
            for j in range(i+1):
                temp = dp[j][0]
                for a, b in seq[:i+1]:
                    temp += min(abs(a), s-a)*b
                dp[j+1][i+1] = min(dp[j+1][i+1], temp)
                temp2 = 10**15
                for k in range(1, i+1):
                    temp = dp[j][k]
                    t = seq[k-1][0]
                    for a, b in seq[k:i+1]:
                        temp += min(abs(a), a-t, s-a)*b
                    temp2 = min(temp2, temp)
                dp[j+1][i+1] = min(dp[j+1][i+1], temp2)
        for i in range(m+1):
            for a, b in seq[:m]:
                dp[i][0] += abs(a)*b
            for k in range(1, m+1):
                t = seq[k-1][0]
                temp = 0
                for a, b in seq[k:m]:
                    temp += min(abs(a), a-t)*b
                dp[i][k] += temp
        for i in range(m+1):
            dp[i] = min(dp[i])
        dp += [0]*(n-m)
        return dp

    xyp.sort()
    for i in range(2**n):
        x_list, y_list = [], []
        for j in range(n):
            x, y, p = xyp[j]
            if i & 1:
                x_list.append([x, p])
            else:
                y_list.append([y, p])
            i >>= 1
        y_list.sort()
        d.append([calc(x_list), calc(y_list)])

    ans = [10**15]*(n+1)
    for x, y in d:
        for i in range(n+1):
            for j in range(n-i+1):
                ans[i+j] = min(ans[i+j], x[i]+y[j])
    for i in ans:
        print(i)


main()


Fixed submission:
def main():
    n = int(input())
    xyp = [list(map(int, input().split())) for _ in [0]*n]
    d = []

    def calc(seq):
        m = len(seq)
        dp = [[0] for _ in [0]*1]  # 使った回数、前のやつ
        for i in range(m):
            dp2 = [[10**15]*(i+2) for _ in [0]*(i+2)]
            for j in range(i+1):
                for k in range(i+1):
                    dp2[j][k] = min(dp2[j][k], dp[j][k])
                    temp = dp[j][k]
                    if k == 0:
                        for l in range(k, i+1):
                            temp += min(abs(seq[l][0]), seq[i]
                                        [0]-seq[l][0])*seq[l][1]
                    else:
                        for l in range(k, i+1):
                            temp += min(abs(seq[l][0]), seq[l]
                                        [0]-seq[k-1][0], seq[i][0]-seq[l][0])*seq[l][1]
                    dp2[j+1][i+1] = min(dp2[j+1][i+1], temp)
            dp = dp2
        for i in range(m+1):
            for l in range(m):
                dp[i][0] += abs(seq[l][0])*seq[l][1]
            for k in range(1, m+1):
                for l in range(k, m):
                    dp[i][k] += min(abs(seq[l][0]), seq[l]
                                    [0]-seq[k-1][0])*seq[l][1]
        for i in range(m+1):
            dp[i] = min(dp[i])
        dp += [0]*(n-m)
        return dp

    xyp.sort()
    for i in range(2**n):
        x_list, y_list = [], []
        for j in range(n):
            x, y, p = xyp[j]
            if i & 1:
                x_list.append([x, p])
            else:
                y_list.append([y, p])
            i >>= 1
        y_list.sort()
        d.append([calc(x_list), calc(y_list)])

    ans = [10**15]*(n+1)
    for x, y in d:
        for i in range(n+1):
            for j in range(n-i+1):
                ans[i+j] = min(ans[i+j], x[i]+y[j])
    for i in ans:
        print(i)


main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    xyp = [list(map(int, input().split())) for _ in [0]*n]
    d = []

    def calc(seq):
        m = len(seq)
        dp = [[0]]
        for i in range(m):
            dp2 = [[10**15]*(i+2) for _ in [0]*(i+2)]
            for j in range(i+1):
                dp2[j][0] = min(dp2[j][0], dp[j][0])
                temp = dp[j][0]
                for a, b in seq[:i+1]:
                    temp += min(abs(a), seq[i][0]-a)*b
                dp2[j+1][i+1] = min(dp2[j+1][i+1], temp)
                for k in range(1, i+1):
                    dp2[j][k] = min(dp2[j][k], dp[j][k])
                    temp = dp[j][k]
                    for a, b in seq[k:i+1]:
                        temp += min(abs(a), a-seq[k-1][0], seq[i][0]-a)*b
                    dp2[j+1][i+1] = min(dp2[j+1][i+1], temp)
            dp = dp2
        for i in range(m+1):
            for a, b in seq[:m]:
                dp[i][0] += abs(a)*b
            for k in range(1, m+1):
                for a, b in seq[k:m]:
                    dp[i][k] += min(abs(a), a-seq[k-1][0])*b
        for i in range(m+1):
            dp[i] = min(dp[i])
        dp += [0]*(n-m)
        return dp

    xyp.sort()
    for i in range(2**n):
        x_list, y_list = [], []
        for j in range(n):
            x, y, p = xyp[j]
            if i & 1:
                x_list.append([x, p])
            else:
                y_list.append([y, p])
            i >>= 1
        y_list.sort()
        d.append([calc(x_list), calc(y_list)])

    ans = [10**15]*(n+1)
    for x, y in d:
        for i in range(n+1):
            for j in range(n-i+1):
                ans[i+j] = min(ans[i+j], x[i]+y[j])
    for i in ans:
        print(i)


main()


Fixed submission:
def main():
    n = int(input())
    xyp = [list(map(int, input().split())) for _ in [0]*n]
    d = []

    def calc(seq):
        m = len(seq)
        dp = [[0] for _ in [0]*1]  # 使った回数、前のやつ
        for i in range(m):
            dp2 = [[10**15]*(i+2) for _ in [0]*(i+2)]
            for j in range(i+1):
                for k in range(i+1):
                    dp2[j][k] = min(dp2[j][k], dp[j][k])
                    temp = dp[j][k]
                    if k == 0:
                        for l in range(k, i+1):
                            temp += min(abs(seq[l][0]), seq[i]
                                        [0]-seq[l][0])*seq[l][1]
                    else:
                        for l in range(k, i+1):
                            temp += min(abs(seq[l][0]), seq[l]
                                        [0]-seq[k-1][0], seq[i][0]-seq[l][0])*seq[l][1]
                    dp2[j+1][i+1] = min(dp2[j+1][i+1], temp)
            dp = dp2
        for i in range(m+1):
            for l in range(m):
                dp[i][0] += abs(seq[l][0])*seq[l][1]
            for k in range(1, m+1):
                for l in range(k, m):
                    dp[i][k] += min(abs(seq[l][0]), seq[l]
                                    [0]-seq[k-1][0])*seq[l][1]
        for i in range(m+1):
            dp[i] = min(dp[i])
        dp += [0]*(n-m)
        return dp

    xyp.sort()
    for i in range(2**n):
        x_list, y_list = [], []
        for j in range(n):
            x, y, p = xyp[j]
            if i & 1:
                x_list.append([x, p])
            else:
                y_list.append([y, p])
            i >>= 1
        y_list.sort()
        d.append([calc(x_list), calc(y_list)])

    ans = [10**15]*(n+1)
    for x, y in d:
        for i in range(n+1):
            for j in range(n-i+1):
                ans[i+j] = min(ans[i+j], x[i]+y[j])
    for i in ans:
        print(i)


main()