criyle/codenet-compile-errors huggingface dataset:
Language: C++

/*editorialからのコピペ*/

#include <vector>
#include <iostream>
#include <algorithm>
std::vector<long long> solve(int N, std::vector<int> X, std::vector<int> Y, std::vector<int> P) {
	const long long inf = 1LL << 62;
	int mul = 1;
	for (int i = 0; i < N; ++i) {
		mul *= 3;
	}
	std::vector<std::vector<int> > xsel(1 << N, std::vector<int>(N));
	std::vector<std::vector<int> > ysel(1 << N, std::vector<int>(N));
	for (int i = 0; i < 1 << N; ++i) {　
		for (int j = 0; j < N; ++j) {
			xsel[i][j] = std::abs(X[j]);
			ysel[i][j] = std::abs(Y[j]);
			for (int k = 0; k < N; ++k) {
				if ((i >> k) & 1) {
					xsel[i][j] = std::min(xsel[i][j], std::abs(X[j] - X[k]));
					ysel[i][j] = std::min(ysel[i][j], std::abs(Y[j] - Y[k]));
				}
			}
		}
	}
	std::vector<long long> ans(N + 1, inf);
	for (int i = 0; i < 1 << N; ++i) {
		int cnt = 0;
		for (int j = 0; j < N; ++j) {
			if ((i >> j) & 1) ++cnt;
		}
		for (int j = i; j >= 0; --j) {
			j &= i;
			long long cost = 0;
			for (int k = 0; k < N; ++k) {
				if (!((i >> k) & 1)) {
					cost += 1LL * std::min({ xsel[j][k], ysel[i - j][k] }) * P[k];
				}
			}
			ans[cnt] = std::min(ans[cnt], cost);
		}
	}
	return ans;
}
int main() {
	int N;
	std::cin >> N;
	std::vector<int> X(N), Y(N), P(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> X[i] >> Y[i] >> P[i];
	}
	std::vector<long long> ans = solve(N, X, Y, P);
	for (int i = 0; i <= N; ++i) {
		std::cout << ans[i] << std::endl;
	}
	return 0;
}


Compiler output:
a.cc:14:43: error: extended character 　 is not valid in an identifier
   14 |         for (int i = 0; i < 1 << N; ++i) {　
      |                                           ^
a.cc: In function 'std::vector<long long int> solve(int, std::vector<int>, std::vector<int>, std::vector<int>)':
a.cc:14:43: error: '\U00003000' was not declared in this scope
   14 |         for (int i = 0; i < 1 << N; ++i) {　
      |                                           ^~
a.cc:15:33: error: 'j' was not declared in this scope
   15 |                 for (int j = 0; j < N; ++j) {
      |                                 ^
Language: C++

/*editorialからのコピペ*/

#include <vector>
#include <iostream>
#include <algorithm>
std::vector<long long> solve(int N, std::vector<int> X, std::vector<int> Y, std::vector<int> P) {
	const long long inf = 1LL << 62;
	int mul = 1;
	for (int i = 0; i < N; ++i) {
		mul *= 3;
	}
	std::vector<std::vector<int> > xsel(1 << N, std::vector<int>(N));
	std::vector<std::vector<int> > ysel(1 << N, std::vector<int>(N));
	for (int i = 0; i < 1 << N; ++i) {　/* 1<<Nは、N**2を表す */
		for (int j = 0; j < N; ++j) {
			xsel[i][j] = std::abs(X[j]);
			ysel[i][j] = std::abs(Y[j]);
			for (int k = 0; k < N; ++k) {
				if ((i >> k) & 1) {
					xsel[i][j] = std::min(xsel[i][j], std::abs(X[j] - X[k]));
					ysel[i][j] = std::min(ysel[i][j], std::abs(Y[j] - Y[k]));
				}
			}
		}
	}
	std::vector<long long> ans(N + 1, inf);
	for (int i = 0; i < 1 << N; ++i) {
		int cnt = 0;
		for (int j = 0; j < N; ++j) {
			if ((i >> j) & 1) ++cnt;
		}
		for (int j = i; j >= 0; --j) {
			j &= i;
			long long cost = 0;
			for (int k = 0; k < N; ++k) {
				if (!((i >> k) & 1)) {
					cost += 1LL * std::min({ xsel[j][k], ysel[i - j][k] }) * P[k];
				}
			}
			ans[cnt] = std::min(ans[cnt], cost);
		}
	}
	return ans;
}
int main() {
	int N;
	std::cin >> N;
	std::vector<int> X(N), Y(N), P(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> X[i] >> Y[i] >> P[i];
	}
	std::vector<long long> ans = solve(N, X, Y, P);
	for (int i = 0; i <= N; ++i) {
		std::cout << ans[i] << std::endl;
	}
	return 0;
}


Compiler output:
a.cc:14:43: error: extended character 　 is not valid in an identifier
   14 |         for (int i = 0; i < 1 << N; ++i) {　/* 1<<Nは、N**2を表す */
      |                                           ^
a.cc: In function 'std::vector<long long int> solve(int, std::vector<int>, std::vector<int>, std::vector<int>)':
a.cc:14:43: error: '\U00003000' was not declared in this scope
   14 |         for (int i = 0; i < 1 << N; ++i) {　/* 1<<Nは、N**2を表す */
      |                                           ^~
a.cc:15:33: error: 'j' was not declared in this scope
   15 |                 for (int j = 0; j < N; ++j) {
      |                                 ^
Language: C++

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

#define int ll

int n;
vector<int> x(20), y(20), p(20), ans(20, mod);

vector<vector<int>> s1(1<<20), s2(1<<20);
void calc_score(){
    for(int bit = 0; bit < (1<<n); bit++){
        vector<int> dis(n, mod);
        rep(i, n){
            chmin(dis[i], abs(x[i]) * p[i]);
            rep(j, n)if(bit & (1<<j))chmin(dis[i], abs(x[i]-x[j]) * p[i]);
        }
        s1[bit] = dis;
    }
    for(int bit = 0; bit < (1<<n); bit++){
        vector<int> dis(n, mod);
        rep(i, n){
            chmin(dis[i], abs(y[i]) * p[i]);
            rep(j, n)if(bit & (1<<j))chmin(dis[i], abs(y[i]-y[j]) * p[i]);
        }
        s2[bit] = dis;
    }
}

void dfs(vector<int> &bit){
    if(bit.size() == n){
        int h = 0, w = 0;
        rep(i, n){
            if(bit[i] == 0)h |= (1<<i);
            if(bit[i] == 1)w |= (1<<i);
        }
        int now_score = 0;
        rep(i, n){
            now_score += min(s1[h][i], s2[w][i]);
        }
        int c = n - count(all(bit), 2);
        chmin(ans[c], now_score);
    }else{
        rep(i, 3){
            bit.push_back(i);
            dfs(bit);
            bit.pop_back();
        }
    }
}

int main() {
    cin >> n;
    vector<int> a;
    rep(i, n){
        cin >> x[i] >> y[i] >> p[i];
    }
    calc_score();
    dfs(a);
    rep(i, n+1)cout << ans[i] << endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#解法１

#入力
N = int(input())
town = [list(map(int,input().split())) for i in range(N)]

#縦と横のリストを作る
vert = [town[i][0] for i in range(N)]
hori = [town[i][1] for i in range(N)]

#bit全探索
dX = [[] for m in range(N+1)]
for i in range(2**N):
    m = 0
    vertsel = []
    dXconst = [abs(town[l][0])*town[l][2] for l in range(N)]
    for j in range(N):
        if ((i >> j) & 1):
            vertsel.append(town[j][0])
            m += 1
    for k in vertsel:
        dXconst = [min(dXconst[l],abs(town[l][0]-k)*town[l][2]) for l in range(N)]
    dX[m].append(dXconst)

dY = [[] for n in range(N+1)]
for i in range(2**N):
    n = 0
    horisel = []
    dYconst = [abs(town[l][1])*town[l][2] for l in range(N)]
    for j in range(N):
        if ((i >> j) & 1):
            horisel.append(town[j][1])
            n += 1
    for k in horisel:
        dYconst = [min(dYconst[l],abs(town[l][1]-k)*town[l][2]) for l in range(N)]
    dY[n].append(dYconst)



Compiler output:
a.cc:1:2: error: invalid preprocessing directive #\U000089e3\U00006cd5\U0000ff11
    1 | #解法１
      |  ^~~~~~
a.cc:3:2: error: invalid preprocessing directive #\U00005165\U0000529b
    3 | #入力
      |  ^~~~
a.cc:7:2: error: invalid preprocessing directive #\U00007e26\U00003068\U00006a2a\U0000306e\U000030ea\U000030b9\U000030c8\U00003092\U00004f5c\U0000308b
    7 | #縦と横のリストを作る
      |  ^~~~~~~~~~~~~~~~~~~~
a.cc:11:2: error: invalid preprocessing directive #bit\U00005168\U000063a2\U00007d22
   11 | #bit全探索
      |  ^~~~~~~~~
a.cc:4:1: error: 'N' does not name a type
    4 | N = int(input())
      | ^
Language: C++

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
const ll INF = 1145141919810364;
using P = pair<ll,ll>;
#define chmin(x,y) x = min(x,y)
ll dp[20][20];
vector<ll> calc(vector<P> &a){
    ll n = a.size();
    sort(a.begin(),a.end());
    rep(i,n + 1){
        rep(j,n + 1){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    rep(l,n){
        for(int r = l + 1; r <= n; r++){
            {
                ll now = INF;
                for(int k = l; k < r; k++){
                    ll s = 0;
                    for(int i = l; i < r; i++){
                        s += abs(a[i].first - a[k].first) * s[i].second;
                    }
                    chmin(now,s);
                }
                rep(j,n) chmin(dp[r][j + 1],dp[l][j] + now);
            }
            {
                ll now = 0;
                    for(int i = l; i < r; i++) {
                        now += abs(a[i].first) * (a[i].second);
                    }
                rep(j,n + 1) chmin(dp[r][j],dp[l][j] + now);
            }
        }
    }
    vector<ll> res(n + 1,INF);
    return res;
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
vector<ll> x(n),y(n),p(n);
rep(i,n) cin >> x[i] >> y[i] >> p[i];
rep(s,1 << n){ //x,yでの全探索決め打ちはビット演算を使う
    vector<P> ax,ay;
    vector<ll> ans(n + 1,INF);
    rep(i,n){
    if(i & 1 << s) {
        ax.emplace_back(x[i],p[i]);
    }else{
        ay.emplace_back(y[i],p[i]);
    }
    }
    vector<ll> dx = calc(ax);
    vector<ll> dy = calc(ay);
    rep(i,dx.size()){
        rep(j,dy.size()){
            ans[i + j] = min(ans[i + j], dx[i] + dy[j]);
        }
    }
    rep(i,n + 1){
        cout << ans[i] << endl;
    }
}
}

Compiler output:
a.cc: In function 'std::vector<long long int> calc(std::vector<std::pair<long long int, long long int> >&)':
a.cc:28:62: error: invalid types 'll {aka long long int}[int]' for array subscript
   28 |                         s += abs(a[i].first - a[k].first) * s[i].second;
      |                                                              ^
Language: C++

#include<stdio.h>
struct node{
	short x=0,y=0;
	int p=0;
}a[20]; 
long long ans[20];
short mi[20],m1[20];
short px[20][20],py[20][20];
int ppk,st;
short cnt,now;
int main(void)
{
#pragma GCC optimize(2)
	char n;
	scanf("%hd",&n);
	for(char i=0;i<n;i++) scanf("%hd%hd%d",&a[i].x,&a[i].y,&a[i].p);
	int ma=1;
	for(char i=0;i<=n;++i) ans[i]=1000000000000000;
	for(char i=0;i<n;++i) ma*=3;
	for(char i=0;i<n;++i)
	{
		short x=a[i].x>0?a[i].x:-a[i].x,y=a[i].y>0?a[i].y:-a[i].y;
		m1[i]=x>y?y:x;
	}
	for(char i=0;i<n;++i)
	{
		for(char j=0;j<n;++j)
		{
			px[i][j]=a[i].x-a[j].x;
			py[i][j]=a[i].y-a[j].y;
			if(px[i][j]<0) px[i][j]=-px[i][j];
			if(py[i][j]<0) py[i][j]=-py[i][j];
		}
	}
	for(int zhu=0;zhu<ma;++zhu)
	{
		ppk=zhu,cnt=0,st=ma/3;
		for(char i=0;i<n;i++) mi[i]=m1[i];
		for(char i=0;i<n;i++,st/=3)
		{
			now=ppk/st;
			switch(now)
			{
				case 1:cnt++;for(char j=0;j<n;++j) if(mi[j]>px[i][j]) mi[j]=px[i][j];break;
				case 2:cnt++;for(char j=0;j<n;++j) if(mi[j]>py[i][j]) mi[j]=py[i][j];
			}
			ppk-=st*now;
		}
		long long sum=0;
		for(char i=0;i<n;++i) sum+=(long long)mi[i]*a[i].p;
		if(ans[cnt]>sum) ans[cnt]=sum;
	}
	for(char i=0;i<=n;i++) printf("%lld\n",ans[i]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: '#pragma GCC optimize' is not allowed inside functions
   13 | #pragma GCC optimize(2)
      |         ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

int x[20],y[20],p[20];
ll ans[20];

void solve()
{
	IOS
	memset(ans,infi,sizeof ans);
	int n,i;
	cin>>n;
	ans[n]=ans[0]=0;
	for(i=0;i<n;i++)
	{
		cin>>x[i]>>y[i]>>p[i];
		ans[0]+=1LL*p[i]*min(abs(x[i]),abs(y[i]));
	}
	
	for(i=1;i<(1<<n);i++)
	{
		for(int s=i;;s=(s-1)&i)
		{
			if(s==0)
			{
				ll temp=0;
				for(int j=0;j<n;j++)
				{
					int closest=min(abs(x[j]),abs(y[j]));
					for(int k=0;k<n;k++)
					if(i&(1<<k))
					{
						closest=min(closest,abs(x[j]-x[k]));
					}
					temp+=1LL*p[j]*closest;
				}
				int sb=__builtin_popcount(i);
				ans[sb]=min(ans[sb],temp);
				break;
			}
			
			ll temp=0;
			for(int j=0;j<n;j++)
			{
				int closest=min(abs(x[j]),abs(y[j]));
				for(int k=0;k<n;k++)
				if(i&(1<<k))
				{
					if(s&(1<<k))
					closest=min(closest,abs(y[j]-y[k]));
					else
					closest=min(closest,abs(x[j]-x[k]));
				}
				temp+=1LL*p[j]*closest;
			}
			int sb=__builtin_popcount(i);
			ans[sb]=min(ans[sb],temp);
		}
	}
	for(i=0;i<=n;i++)
	cout<<ans[i]<<'\n';
}


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
 
int pow3(int index)
{
	int base = 3, ret = 1;
	while(index)
	{
		if(index & 1) ret *= base;
		index /= 2;
		base *= base;
	}
	return ret;
}
 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin >> n;
	vector<ll> x(n);
	vector<ll> y(n);
	vector<ll> p(n);
	vector<ll> ans(n + 1, INF64);
	for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> p[i];
    int temp = pow3(n);
	for(int i = 0; i < temp; i++)
	{
		ll d = 0;
		int ii = i;
		vector<pair<bool, ll>> r(2);
		r[0] = make_pair(0, 0);
		r[1] = make_pair(1, 0);
		for(int j = 0; j < n; j++)
		{
			if(ii % 3 == 1) r.push_back(make_pair(0, x[j]));
			else if(ii % 3 == 2) r.push_back(make_pair(1, y[j]));
			ii /= 3;
		}
		if(r.size() - 2 > n) continue;
		for(int j = 0; j < n; j++)
		{
			ll mini = abs(max(x[j], y[j]));
            int rr = r.size()
			for(int k = 0; k < rr; k++)
			{
				if(r[k].first) mini = min(mini, abs(y[j] - r[k].second));
				else mini = min(mini, abs(x[j] - r[k].second));
			}
			d += mini * p[j];
		}
		ans[r.size() - 2] = min(ans[r.size() - 2], d);
	}
	for(int i = 0; i < n + 1; i++) cout << ans[i] << endl;
 
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:25: error: expected ',' or ';' before 'for'
   61 |                         for(int k = 0; k < rr; k++)
      |                         ^~~
a.cc:61:40: error: 'k' was not declared in this scope
   61 |                         for(int k = 0; k < rr; k++)
      |                                        ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const ll INF = 1e18;

vector<ll> calc(vector<P>& a) {
  int n = a.size();
  sort(a.begin(), a.end());
  vector<ll> res(n+1, INF);
  vector<int> p;
  p.reserve(n);
  rep(s,1<<n) {
    rep(i,n) if (s>>i&1) p.push_back(a[i].first);
    ll now = 0;
    int pi = 0;
    rep(i,n) {
      int x = a[i].first;
      while (pi+1 < p.size() && p[pi+1] < x) pi++;
      int m = abs(x);
      if (pi < p.size()) m = min(m, abs(x-p[pi]));
      if (pi+1 < p.size()) m = min(m, abs(x-p[pi+1]));
      now += ll(m)*a[i].second;
    }
    int b = p.size();
    res[b] = min(res[b], now);
    p.clean();
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n), p(n);
  rep(i,n) cin >> x[i] >> y[i] >> p[i];
  vector<ll> ans(n+1,INF);
  rep(s,1<<n) {
    vector<P> ax, ay;
    rep(i,n) {
      if (s>>i&1) ax.emplace_back(x[i],p[i]);
      else ay.emplace_back(y[i],p[i]);
    }
    vector<ll> dx = calc(ax);
    vector<ll> dy = calc(ay);
    rep(i,dx.size())rep(j,dy.size()) {
      ans[i+j] = min(ans[i+j], dx[i]+dy[j]);
    }
  }

  rep(i,n+1) {
    cout << ans[i] << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'std::vector<long long int> calc(std::vector<std::pair<int, int> >&)':
a.cc:29:7: error: 'class std::vector<int>' has no member named 'clean'; did you mean 'clear'?
   29 |     p.clean();
      |       ^~~~~
      |       clear
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll INF = (ll)(1e18);

struct ST {
  int x, y;
  int p;
};
vector<pair<int,int>> px, py;
vector<int> xx(N), yy(N);

ll calc(const vector<ST>& v, int T, int R){
  int N = v.size();
  vector<int> candx, candy;
  rep(i,N){
    {
      int idx = px[i].second;
      if((T>>idx)&1) candx.push_back(px[i].first);
    }
    {
      int idx = py[i].second;
      if((R>>idx)&1) candy.push_back(py[i].first);
    }
  }
/*
  rep(i,N) if((T>>i)&1) cout << 1; else cout << 0;
  cout << "\t";
  rep(i,N) if((R>>i)&1) cout << 1; else cout << 0;
  cout << endl;
 */

  rep(i,N){
    xx[i] = abs(v[i].x);
    yy[i] = abs(v[i].y);
  }

  {
    int j=0, k=0;
    while(j<px.size()){
      while(k < candx.size() && px[j].first >= candx[k]){
        int idx = px[j].second;
        xx[idx] = min(xx[idx], abs(v[idx].x - candx[k]));
        k++;
      }
      if(k == candx.size()) break;
      int idx = px[j].second;
      if(k>0) xx[idx] = min(xx[idx], abs(v[idx].x - candx[k-1]));
      xx[idx] = min(xx[idx], abs(v[idx].x - candx[k]));
      j++;
    }
    if(candx.size() > 0){
      while(j<px.size()){
        int idx = px[j].second;
        xx[idx] = min(xx[idx], abs(v[idx].x - candx[candx.size()-1]));
        j++;
      }
    }
  }
  {
    int j=0, k=0;
    while(j<py.size()){
      while(k < candy.size() && py[j].first >= candy[k]){
        int idx = py[j].second;
        yy[idx] = min(yy[idx], abs(v[idx].y - candy[k]));
        k++;
      }
      if(k == candy.size()) break;
      int idx = py[j].second;
      if(k>0) yy[idx] = min(yy[idx], abs(v[idx].y - candy[k-1]));
      yy[idx] = min(yy[idx], abs(v[idx].y - candy[k]));
      j++;
    }
    if(candy.size() > 0){
      while(j<py.size()){
        int idx = py[j].second;
        yy[idx] = min(yy[idx], abs(v[idx].y - candy[candy.size()-1]));
        j++;
      }
    }
  }
  ll ret = 0;
  rep(i,N){
    ret += min(xx[i], yy[i]) * (ll)v[i].p;
  }
  return ret;
}


int main(){
  int N;
  cin >> N;

  vector<ST> v;
  rep(i,N){
    ST st;
    cin >> st.x >> st.y >> st.p;
    v.push_back(st);
  }

  rep(i,N){
    px.emplace_back(v[i].x, i);
    py.emplace_back(v[i].y, i);
  }
  sort(ALLOF(px));
  sort(ALLOF(py));
  
  vector<ll> ret(N+1, INF);

  for(int S=0; S<(1<<N); S++){
    int cnt = 0;
    rep(i,N) if((S>>i)&1) cnt++;
    for(int T=S; T>=0; T--){
      T &= S;
      int R = S^T;
      ret[cnt] = min(ret[cnt], calc(v, T, R));
    }
  }

  rep(i,ret.size()){
    cout << ret[i] << endl;
  }

  return 0;
}



Compiler output:
a.cc:17:16: error: 'N' was not declared in this scope
   17 | vector<int> xx(N), yy(N);
      |                ^
a.cc:17:23: error: 'N' was not declared in this scope
   17 | vector<int> xx(N), yy(N);
      |                       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  vector<lint> X(N);
  vector<lint> Y(N);
  vector<lint> P(N);
  REP(i, N) cin >> X[i] >> Y[i] >> P[i];
  vector<lint> ans(N+1, 1e18);
  REP(bit, pow(3LL, N)) {
    lint cnt = 0;
    set<lint> x;
    set<lint> y;
    x.insert(0);
    y.insert(0);
    REP(i, N) {
      if(((lint)bit / (lint)pow(3, i)) % 3 == 1) {
        x.insert(X[i]);
        cnt++;
      }
      else if(((lint)bit / (lint)pow(3, i)) % 3 == 2) {
        y.insert(Y[i]);
        cnt++;
      }
    }
    vector<lint> S(N, 1e18);
    REP(i, N) {
      auto itr = x.lower_bound(X[i]);
      if(itr != x.end()) S[i] = min(S[i], abs(X[i]-*itr)*P[i]);
      if(itr != x.begin()) {
        itr = prev(itr);
        S[i] = min(S[i], abs(X[i]-*itr)*P[i]);
      }
      auto itr = y.lower_bound(Y[i]);
      if(itr != y.end()) S[i] = min(S[i], abs(Y[i]-*itr)*P[i]);
      if(itr != y.begin()) {
        itr = prev(itr);
        S[i] = min(S[i], abs(Y[i]-*itr)*P[i]);
      }
    }
    lint sum = 0;
    REP(i, N) sum += S[i];
    ans[cnt] = min(ans[cnt], sum);
  }
  REP(i, N+1) cout << ans[i] << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:12: error: conflicting declaration 'auto itr'
   50 |       auto itr = y.lower_bound(Y[i]);
      |            ^~~
a.cc:44:12: note: previous declaration as 'std::_Rb_tree_const_iterator<long long int> itr'
   44 |       auto itr = x.lower_bound(X[i]);
      |            ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll INF = 1e17;

int n;
ll x[15], y[15], p[15];

set<ll> sx, sy;
vector<ll> ans(20,INF);

ll dfs(int id) {
  ll dis = INF;
  if(id == n) {
    dis = 0;
    rep(i,n) {
      ll res = INF;
      auto itr = sx.lower_bound(x[i]);
      if(itr != sx.end()) res = min(res,abs(x[i]-(*itr)));
      if(itr != sx.begin()) {
        itr--;
        res = min(res,abs(x[i]-(*itr)));
      }
      itr = sy.lower_bound(y[i]);
      if(itr != sy.end()) res = min(res,abs(y[i]-(*itr)));
      if(itr != sy.begin()) {
        itr--;
        res = min(res,abs(y[i]-(*itr)));
      }
      dis += p[i]*res;
    }
    int l = sx.size() + sy.size() - 2;
    ans[l] = min(ans[l],dis);
  } else {
    dis = min(dis,dfs(id+1));
    if(sx.find(x[id]) == sx.end()) {
      sx.insert(x[id]);
      dis = min(dis,dfs(id+1));
      sx.erase(x[id]);
    }a
    if(sy.find(y[id]) == sy.end()) {
      sy.insert(y[id]);
      dis = min(dis,dfs(id+1));
      sy.erase(y[id]);
    }
  }
  return dis;
}

int main(){
  cin >> n;
  rep(i,n) cin >> x[i] >> y[i] >> p[i];
  sx.insert(0);
  sy.insert(0);
  dfs(0);
  rep(i,n+1) {
    if(i > 0) ans[i] = min(ans[i],ans[i-1]);
    cout << ans[i] << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'll dfs(int)':
a.cc:41:6: error: 'a' was not declared in this scope
   41 |     }a
      |      ^
Language: C++

/*
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
*/
#include <iostream>
#include <vector>
using namespace std;
long long INF = 1000000000000;
int pow3(int x){
  int ans = 1;
  for (int i = 0; i < x; i++){
    ans *= 3;
  }
  return ans;
}
int main(){
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  vector<long long> P(N);
  for (int i = 0; i < N; i++){
    cin >> X[i] >> Y[i] >> P[i];
  }
  vector<pair<int, int>> xs;
  xs.reserve(N + 1);
  for (int i = 0; i < N; i++){
    xs.emplace_back(X[i], i);
  }
  xs.emplace_back(0, N);
  sort(xs.begin(), xs.end());
  vector<pair<int, int>> ys;
  ys.reserve(N + 1);
  for (int i = 0; i < N; i++){
    ys.emplace_back(Y[i], i);
  }
  ys.emplace_back(0, N);
  sort(ys.begin(), ys.end());
  vector<long long> ans(N + 1, INF);
  vector<int> H, V;
  H.reserve(N + 2);
  V.reserve(N + 2);
  vector<int> a(N + 1, 0);
  vector<int> d(N, 1000000);
  int u = pow3(N);
  int cnt, tmp, A, B;
  for (int i = 0; i < u; i++){
    cnt = 0;
    tmp = i;
    for (int j = 0; j < N; j++){
      a[j] = tmp % 3;
      tmp /= 3;
      if (a[j] > 0){
        cnt++;
      }
    }
    a[N] = 1;
    H.clear();
    H.emplace_back(-1000000);
    for (auto P : ys){
      if (a[P.second] == 1){
        H.emplace_back(P.first);
      }
    }
    H.emplace_back(1000000);
    a[N] = 2;
    V.clear();
    V.emplace_back(-1000000);
    for (auto P : xs){
      if (a[P.second] == 2){
        V.emplace_back(P.first);
      }
    }
    V.emplace_back(1000000);
    A = 0;
    int tmp1 = H.size() - 1;
    for (auto p : ys){
      if (p.second == N){
        continue;
      }
      while (A < tmp1){
        if (H[A + 1] < p.first){
          A++;
        } else {
          break;
        }
      }
      d[p.second] = min(p.first - H[A], H[A + 1] - p.first);
    }
    B = 0;
    int tmp2 = V.size() - 1;
    for (auto p : xs){
      if (p.second == N){
        continue;
      }
      while (B < tmp2){
        if (V[B + 1] < p.first){
          B++;
        } else {
          break;
        }
      }
      d[p.second] = min(d[p.second], min(p.first - V[B], V[B + 1] - p.first));
    }
    long long S = 0;
    for (int i = 0; i < N; i++){
      S += d[i] * P[i];
    }
    ans[cnt] = min(ans[cnt], S);
  }
  for (int i = 0; i <= N; i++){
    cout << ans[i] << "\n";
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   32 |   sort(xs.begin(), xs.end());
      |   ^~~~
      |   short
Language: C++

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
int n,cnt=0;
ll ret;
ll ans[20];
ll x[20],y[20],p[20],dist[20];
int train[20];//0:なし 1:東西 2:南北
/*
集落を貫通する鉄道のみを考えれば良い→2^(N*2)本
縦横両方を通す必要はないので3^N本
O(N*3^N)やってみる
*/
void solve(){
    ret=0;
    For(i,0,n) dist[i]=min(abs(x[i]),abs(y[i]));
    int left=-1e8;
    For(i,0,n){
        if(train[i]==2){
            left=x[i];
        }
        dist[i]=min(dist[i],x[i]-left);
        For(j,i,n){
            if(train[i]==1){//東西にあるとき
                dist[j]=min(dist[j],abs(y[i]-y[j]));
            }
            /*if(train[i]==2){//南北にあるとき
                dist[j]=min(dist[j],abs(x[i]-x[j]));
            }*/
            if(train[j]==1){//東西にあるとき
                dist[i]=min(dist[i],abs(y[i]-y[j]));
            }
            /*if(train[j]==2){//南北にあるとき
                dist[i]=min(dist[i],abs(x[i]-x[j]));
            }*/
        }
    }
    int right=1e8;
    for(int i=n-1;i>-1;i--){
        if(train[i]==2){
            right=x[i];
        }
        dist[i]=min(dist[i],right-x[i]);
        ret += dist[i] * p[i];
    }
    ans[cnt] = min(ans[cnt],ret);
    return;
}
void Main(){
    cin >> n;
    vector<pair<int,pair<int,int>>> vec(n);
    For(i,0,n){
        cin >> vec[i].first >> vec[i].second.first >> vec[i].second.second;
    }
    sort(ALL(vec));
    For(i,0,n){
        x[i]=vec[i].first;
        y[i]=vec[i].second.first;
        p[i]=vec[i].second.second;
    }
    int p3=1;
    fill(ans,ans+n+1,1e18);
    For(i,0,n)p3*=3;
    For(i,0,p3){
        int x=i;
        cnt=0;
        For(j,0,n){
            train[j]=x%3;
            x/=3;
            if(train[j]>0) cnt++;
        }
        solve();
    }
    For(i,0,n+1) cout << ans[i] << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:4:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<std::pair<int, std::pair<int, int> >, std::allocator<std::pair<int, std::pair<int, int> > > >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::pair<int, std::pair<int, int> >]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const ll INF = 1e18+3;
const ll mod = 1e9 + 7; //998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;

ll ans[20];
bool flag[20];
ll x[20], y[20];
int N;

ll X[20], Y[20], Q[20];
search(int depth, int xnum, int ynum){
    ll pop = 0;
    int final_i = -1;
    if (depth > N)return 0;
    rep(i, N){
        ll dist = 20000;
        rep(j, xnum) chmin(dist, abs(x[j] - X[i]));
        rep(j, ynum) chmin(dist, abs(y[j] - Y[i]));
     
        
        pop += dist * Q[i];
        if (final_i == -1 && dist > 0){
            final_i = i;
        }
        //if (depth <= 1)
        //    fprintf(stderr, "depth = %d, i = %d, dist = %d, final_i = %d\n", depth, i, dist, final_i);
    }
    chmin(ans[xnum + ynum - 2], pop);
    
    if (final_i >= 0 && pop > 0){
        x[xnum] = X[final_i];
        search(depth + 1, xnum + 1, ynum);
        y[ynum] = Y[final_i];
        search(depth + 1, xnum, ynum + 1);
    } else {
        for (int i = xnum + ynum; i - 2 <= N; i++){
            ans[i - 2] = 0;
        }
    }
    return 0;
}

int main() {
    cin >> N;
    vector<ll> XX(N), YY(N), PP(N); //, X(N), Y(N), Q(N);
    vector<P> PPP;
    rep(i, N){
        cin >> XX[i] >> YY[i] >> PP[i];
        PPP.push_back(make_pair(PP[i], i));
    }
    sort(ALL(PPP), greater<P>());
    rep(i, N){
        X[i] = XX[PPP[i].second];
        Y[i] = YY[PPP[i].second];
        Q[i] = PP[PPP[i].second];
        //fprintf(stderr, "%d, %d, %d\n", X[i], Y[i], Q[i]);
    }
    x[0] = y[0] = 0;
    rep(i, N){
        flag[i] = false;
        ans[i] = 1e15;
        x[i + 1] = y[i + 1] = -20000;
    }
    search(0, 1, 1);
    rep(i, N + 1){
        cout << ans[i] << endl;
    }
    
    return 0;
}
   

Compiler output:
a.cc:25:1: error: ISO C++ forbids declaration of 'search' with no type [-fpermissive]
   25 | search(int depth, int xnum, int ynum){
      | ^~~~~~
Language: C++

#include<bits/stdc++.h>
#define int long long
using namespace std;
struct T{int X,Y,P;};
T A[20];
stack<pair<int,int>> S;
stack<int> V;
int N,ans[100];
void a(int n){
  if(n==N){
    /*set<pair<int,int>> T;
    stack<pair<int,int>> U=S;
    stack<int> W=V;
    while(!U.empty()){
      T.insert(U.top());
      U.pop();
    }
    int cnt=0;
    while(!W.empty()){
      int i=W.top();
      W.pop();
      int mn=1000000000000;
      for(pair<int,int> p:T){
        if(p.first==0)
          mn=min(mn,abs(p.second-A[i].X));
        else
          mn=min(mn,abs(p.second-A[i].Y));
      }
      cnt+=mn*A[i].P;*/
    }
    ans[T.size()-2]=min(ans[T.size()-2],cnt);
    return;
  }
  S.push({0,A[n].X});
  a(n+1);
  S.pop();
  S.push({1,A[n].Y});
  a(n+1);
  S.pop();
  V.push(n);
  a(n+1);
  V.pop();
}
signed main(){
  cin>>N;
  S.push(make_pair(0,0));
  S.push(make_pair(1,0));
  for(int i=0;i<N;i++)
    cin>>A[i].X>>A[i].Y>>A[i].P;
  for(int i=0;i<N;i++)
    ans[i]=1000000000000;
  a(0);
  for(int i=0;i<=N;i++)cout<<ans[i]<<endl;
}

Compiler output:
a.cc: In function 'void a(long long int)':
a.cc:31:10: error: expected primary-expression before '.' token
   31 |     ans[T.size()-2]=min(ans[T.size()-2],cnt);
      |          ^
a.cc:31:30: error: expected primary-expression before '.' token
   31 |     ans[T.size()-2]=min(ans[T.size()-2],cnt);
      |                              ^
a.cc:31:41: error: 'cnt' was not declared in this scope; did you mean 'int'?
   31 |     ans[T.size()-2]=min(ans[T.size()-2],cnt);
      |                                         ^~~
      |                                         int
a.cc: At global scope:
a.cc:34:3: error: 'S' does not name a type
   34 |   S.push({0,A[n].X});
      |   ^
a.cc:34:20: error: expected unqualified-id before ')' token
   34 |   S.push({0,A[n].X});
      |                    ^
a.cc:35:4: error: expected constructor, destructor, or type conversion before '(' token
   35 |   a(n+1);
      |    ^
a.cc:36:3: error: 'S' does not name a type
   36 |   S.pop();
      |   ^
a.cc:37:3: error: 'S' does not name a type
   37 |   S.push({1,A[n].Y});
      |   ^
a.cc:37:20: error: expected unqualified-id before ')' token
   37 |   S.push({1,A[n].Y});
      |                    ^
a.cc:38:4: error: expected constructor, destructor, or type conversion before '(' token
   38 |   a(n+1);
      |    ^
a.cc:39:3: error: 'S' does not name a type
   39 |   S.pop();
      |   ^
a.cc:40:3: error: 'V' does not name a type
   40 |   V.push(n);
      |   ^
a.cc:41:4: error: expected constructor, destructor, or type conversion before '(' token
   41 |   a(n+1);
      |    ^
a.cc:42:3: error: 'V' does not name a type
   42 |   V.pop();
      |   ^
a.cc:43:1: error: expected declaration before '}' token
   43 | }
      | ^
Language: C++

風呂入りたいのでもうやめます 競プロ引退

Compiler output:
a.cc:1:1: error: '\U000098a8\U00005442\U00005165\U0000308a\U0000305f\U00003044\U0000306e\U00003067\U00003082\U00003046\U00003084\U00003081\U0000307e\U00003059' does not name a type
    1 | 風呂入りたいのでもうやめます 競プロ引退
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll n;
ll x[20],y[20],p[20];
ll ret[20];
ll D[20];

int a[20];
int cnt;
void solve(int k){
	if(k==0){
		for(int i=0;i<n;i++)D[i]=10000000000;
	}
	if(k==n-2){
		for(int i=0;i<n;i++){
			if(i<k&&a[i]!=0){
				D[i]=0;
			}
			else {
				D[i]=min(abs(x[i]),abs(y[i]));
				for(int j=0;j<k;j++){
					if(a[j]==1)D[i]=min(D[i],abs(x[i]-x[j]));
					if(a[j]==2)D[i]=min(D[i],abs(y[i]-y[j]));
				}
			}
		}
	}
	if(k==n){
		ll sum=0;
		for(int i=0;i<n;i++){
			if(a[i]!=0)continue;
			ll d=D[i];
			for(int j=max(n-2,0);j<n;j++){
				if(a[j]==1)d=min(d,abs(x[i]-x[j]));
				if(a[j]==2)d=min(d,abs(y[i]-y[j]));
			}
			sum+=d*p[i];
		}
		ret[cnt]=min(ret[cnt],sum);
		return;
	}
	for(int j=0;j<3;j++){
		a[k]=j;
		if(j>0)cnt++;
		solve(k+1);
		if(j>0)cnt--;
	}
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>p[i];
	}
	for(int k=0;k<=n;k++){
		ret[k]=1000000000000000000;
	}
	solve(0);
	for(int k=0;k<=n;k++){
		cout<<ret[k]<<endl;
	}
}

Compiler output:
a.cc: In function 'void solve(int)':
a.cc:35:38: error: no matching function for call to 'max(ll, int)'
   35 |                         for(int j=max(n-2,0);j<n;j++){
      |                                   ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:35:38: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   35 |                         for(int j=max(n-2,0);j<n;j++){
      |                                   ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:35:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   35 |                         for(int j=max(n-2,0);j<n;j++){
      |                                   ~~~^~~~~~~
Language: C++

#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
#define pb push_back
#define IT iterator
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=17,size=1<<20,mod=998244353,inf=2e9;

/ar buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

//math
ll mult(ll a,ll b,ll p) {
	a=(a%p+p)%p; b=(b%p+p)%p;
	ll c=(ld)a*b/p;
	return a*b-c*p;
}
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}
ll Power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=mult(c,a,mod);
		b /= 2; a=mult(a,a,mod);
	}
	return c;
}

ll n,x[N],y[N],p[N],w[1<<N],f[1<<N][N],lg[1<<N];

struct rec {
	ll x,y;
	bool operator <(rec b) const {
		return x<b.x;
	}
} a[N];

ll calc(int now) {
	ll tot,s,ans=1e18,tmp,mid;
	
	tot=s=0;
	for(int i=0;i<n;i++)
		if(now>>i&1) a[++tot]=(rec){x[i],p[i]},s+=p[i];
	sort(a+1,a+tot+1);
	mid=s+1>>1;
	for(int i=1;i<=tot;i++)
		if(mid<=a[i].y) {
			tmp=0;
			for(int j=1;j<=tot;j++) tmp+=a[j].y*abs(a[i].x-a[j].x);
			ans=min(ans,tmp); break;
		}
		else mid-=a[i].y;
	
	tot=s=0;
	for(int i=0;i<n;i++)
		if(now>>i&1) a[++tot]=(rec){y[i],p[i]},s+=p[i];
	sort(a+1,a+tot+1);
	mid=s+1>>1;
	for(int i=1;i<=tot;i++)
		if(mid<=a[i].y) {
			tmp=0;
			for(int j=1;j<=tot;j++) tmp+=a[j].y*abs(a[i].x-a[j].x);
			ans=min(ans,tmp); break;
		}
		else mid-=a[i].y;
	
	return ans;
}

int main() {
	qr(n);
	for(int i=0;i<=n;i++) lg[1<<i]=i;
	for(int i=0;i<n;i++)
		qr(x[i]),qr(y[i]),qr(p[i]);
	int s=(1<<n)-1;
	memset(f,63,sizeof f);
	f[0][0]=0;
	for(int i=1;i<=s;i++) {
		f[i][0]=f[i&(i-1)][0];
		int j=lg[i&-i];
		f[i][0] += min(abs(x[j]),abs(y[j]))*p[j];
	}
	pr2(f[s][0]);
	for(int i=1;i<(1<<n);i++) w[i]=calc(i);
	for(int t=1;t<=n;t++) {
 		for(int i=1;i<=s;i++)
			for(int j=i;	;j=(j-1)&i) {
				f[i][t]=min(f[i][t],f[j][t-1]+w[i^j]);
				if(!j) break;
			}
		pr2(f[s][t]);
	}
	return 0;
}

Compiler output:
a.cc:19:1: error: expected unqualified-id before '/' token
   19 | /ar buf[size],*p1=buf,*p2=buf;
      | ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> X(N), Y(N), P(N);
  for(int i = 0; i < N; ++i){
    cin >> X[i] >> Y[i] >> P[i];
  }
  const int INF = 1e9+1;
  vector<long long> ans(N+1,1e18);
  for(int i = 0; i < (1<<N); ++i){
    for(int j = i; ; --j, j &= i){
      int k = i^j;
      vector<long long> XX = {-INF,0,INF}, YY = {-INF,0,INF};
      for(int l = 0; l < N; ++l){
        if(j>>l&1){
          XX.emplace_back(X[l]);
        }
        if(k>>l&1){
          YY.emplace_back(Y[l]);
        }
      }
      sort(XX.begin(), XX.end());
      sort(YY.begin(), YY.end());
      long long s = 0;
      for(int l = 0; l < N; ++l){
        auto xlb = lower_bound(XX.begin(), XX.end(), X[l]);
        long long dx = *xlb-X[l];
        dx = min(dx,X[l]-*prev(xlb));
        auto ylb = lower_bound(YY.begin(), YY.end(), Y[l]);
        long long dy = *ylb-Y[l];
        dy = min(dy,Y[l]-*prev(ylb));
        s += min(dx,dy)*P[l];
      }
      int p = __builtin_popcount(i);
      ans[p] = min(ans[p],s);
      if(!j) break;
    }
  }
  for(auto e : ans)
    cout << e << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:7: error: 'sort' was not declared in this scope; did you mean 'short'?
   26 |       sort(XX.begin(), XX.end());
      |       ^~~~
      |       short
Language: C++

#include <iostream>
#include <vector>
using namespace std;

const int INF = 100000000;
const int M = 200000;

vector<int> v1[4][400002];
vector<int> v2[2][200002];

int main()
{
    int n;
    cin >> n;
    int x[200002], y[200002];
    char u[200002];
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> u[i];
        if(u[i] == 'U'){
            v1[0][x[i] + y[i]].push_back(x[i]);
            v1[1][y[i] - x[i] + M].push_back(x[i]);
            v2[0][x[i]].push_back(y[i]);
        }
        if(u[i] == 'D'){
            v1[2][x[i] + y[i]].push_back(x[i]);
            v1[3][y[i] - x[i] + M].push_back(x[i]);
        }
        if(u[i] == 'R'){
            v2[1][y[i]].push_back(x[i]);
        }
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j <= 400000; j++) sort(v1[i][j].begin(), v1[i][j].end());
    }
    for(int i = 0; i < 2; i++){
        for(int j = 0; j <= 200000; j++) sort(v2[i][j].begin(), v2[i][j].end());
    }
    int ans = INF;
    for(int i = 0; i < n; i++){
        if(u[i] == 'D'){
            auto itr = lower_bound(v2[0][x[i]].begin(), v2[0][x[i]].end(), y[i]);
            if(itr != v2[0][x[i]].begin()){
                ans = min(ans, (y[i] - *--itr) * 5);
            }
        }
        if(u[i] == 'R'){
            auto itr1 = lower_bound(v1[0][x[i] + y[i]].begin(), v1[0][x[i] + y[i]].end(), x[i]);
            if(itr1 != v1[0][x[i] + y[i]].end()){
                ans = min(ans, (*itr1 - x[i]) * 10);
            }
            auto itr2 = lower_bound(v1[3][y[i] - x[i] + M].begin(), v1[3][y[i] - x[i] + M].end(), x[i]);
            if(itr2 != v1[3][y[i] - x[i] + M].end()){
                ans = min(ans, (*itr2 - x[i]) * 10);
            }
        }
        if(u[i] == 'L'){
            auto itr1 = lower_bound(v2[1][y[i]].begin(), v2[1][y[i]].end(), x[i]);
            if(itr1 != v2[1][y[i]].begin()){
                ans = min(ans, (x[i] - *--itr1) * 5);
            }
            auto itr2 = lower_bound(v1[2][x[i] + y[i]].begin(), v1[2][x[i] + y[i]].end(), x[i]);
            if(itr2 != v1[2][x[i] + y[i]].begin()){
                ans = min(ans, (x[i] - *--itr2) * 10);
            }
            auto itr3 = lower_bound(v1[1][y[i] - x[i] + M].begin(), v1[1][y[i] - x[i] + M].end(), x[i]);
            if(itr3 != v1[1][y[i] - x[i] + M].begin()){
                ans = min(ans, (x[i] - *--itr3) * 10);
            }
        }
    }
    if(ans == INF) cout << "SAFE" << endl;
    else cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:42: error: 'sort' was not declared in this scope; did you mean 'short'?
   33 |         for(int j = 0; j <= 400000; j++) sort(v1[i][j].begin(), v1[i][j].end());
      |                                          ^~~~
      |                                          short
a.cc:36:42: error: 'sort' was not declared in this scope; did you mean 'short'?
   36 |         for(int j = 0; j <= 200000; j++) sort(v2[i][j].begin(), v2[i][j].end());
      |                                          ^~~~
      |                                          short
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

/*
正面衝突の場合 U-D, L-R
斜め衝突の場合 U-L, L-D, D-R, R-U





*/


int X[1<<18], Y[1<<18];
char D[1<<18];
vector<pair<int, char>> V1[1<<19];
vector<pair<int, char>> V2[1<<19];

int n;

int solve_UR(){
	int Answer = (1 << 24);
	for (int i = 0; i <= 500000; i++) V1[i].clear();
	for (int i = 1; i <= n; i++) {
		if (!(D[i] == 'R' || D[i] == 'U')) continue;
		V1[X[i] + Y[i]].push_back(make_pair(X[i], D[i]));
	}
	for (int i = 0; i <= 500000; i++) {
		sort(V1[i].begin(), V1[i].end());
		for (int j = 0; j < (int)V1[i].size() - 1; j++) {
			if (!(V1[i][j].second == 'R' && V1[i][j + 1].second == 'U')) continue;
			Answer = min(Answer, V1[i][j + 1].first - V1[i][j].first);
		}
	}
	return Answer * 10;
}



int solve_UD(){
	int Answer = (1 << 24);
	for (int i = 0; i <= 500000; i++) V2[i].clear();
	for (int i = 1; i <= N; i++) {
		if (!(D[i] == 'L' || D[i] == 'R')) continue;
		V2[Y[i]].push_back(make_pair(X[i], D[i]));
	}
	for (int i = 0; i <= 500000; i++) {
		sort(V2[i].begin(), V2[i].end());
		for (int j = 0; j < (int)V2[i].size() - 1; j++) {
			if (!(V2[i][j].second == 'R' && V2[i][j + 1].second == 'L')) continue;
			Answer = min(Answer, V2[i][j + 1].first - V2[i][j].first);
		}
	}
	return Answer * 5;
}


void rotate(){
    int tmp;
    rep(i, n){
        tmp = X[i];
        X[i] = 200000-Y[i];
        Y[i] = tmp;
        if (D[i] == 'U') D[i] = 'L';
        else if (D[i] == 'L') D[i] = 'D';
        else if (D[i] == 'D') D[i] = 'R';
        else D[i] = 'U';
    }
    
}


int main()
{
    cin >> n;
    rep(i, n){
        cin >> X[i] >> Y[i] >> D[i];
    }

    int t_time = 2000001;    
    rep(t, 4){
        t_time = min(t_time, solve_UD());
        t_time = min(t_time, solve_UR());
        rotate();
    }

    if (t_time == 2000001) cout << "SAFE" << endl;
    else cout << t_time << endl;

}



Compiler output:
a.cc: In function 'int solve_UD()':
a.cc:55:30: error: 'N' was not declared in this scope
   55 |         for (int i = 1; i <= N; i++) {
      |                              ^