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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll powmod(ll x, ll y = P - 2, ll p = P) {
	ll ans = 1;
  	while(y) {
		if(y & 1) ans = ans * x % p;
    	x = x * x % p;
      	y >>= 1;
    }
  	return ans;
}

ll Fac[200010], Rev[200010];

int main() {
	int n, a, b, c;
  	scanf("%d%d%d%d", &n, &a, &b, &c);
  	if(c == 100) {puts("RuYaSuiHe"); assert(0);}
  a = a * powmod(100) % P, b = b * powmod(100) % P, c = c * powmod(100) % P;
  	for(int i = 0; i <= 2 * n; i++) Fac[i] = !i ? 1 : Fac[i - 1] * i % P;
  	Rev[2 * n] = powmod(Fac[2 * n]);
  for(int i = 2 * n; i >= 1; i--) Rev[i - 1] = Rev[i] * i % P;
  ll ans = 0;
  	for(int i = 1; i < n; i++) {
      	ans = (ans + Fac[n + i] * Rev[i] % P * Rev[n] % P * powmod(a, n) % P * powmod(b, i)) % P;
    	ans = (ans + Fac[n + i] * Rev[i] % P * Rev[n] % P * powmod(b, n) % P * powmod(a, i)) % P;
    }
  printf("%lld\n", (ans * powmod(1 - c) % P + P) % P);
	return 0;
}

Compiler output:
a.cc:7:24: error: 'P' was not declared in this scope
    7 | ll powmod(ll x, ll y = P - 2, ll p = P) {
      |                        ^
a.cc:7:38: error: 'P' was not declared in this scope
    7 | ll powmod(ll x, ll y = P - 2, ll p = P) {
      |                                      ^
a.cc: In function 'int main()':
a.cc:23:25: error: 'P' was not declared in this scope
   23 |   a = a * powmod(100) % P, b = b * powmod(100) % P, c = c * powmod(100) % P;
      |                         ^
Language: C++

//最大化する時を考える
//bfs

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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
using ll = long long;
using ld = long double;
const int root = 0;
 
int main() {
  int n;
  cin >> n;
  vector<vector<int>> inp(n);
  for (int i = 0, a, b; i + 1 < n; ++i) {
    cin >> a >> b;
    inp[a - 1].push_back(b - 1);
    inp[b - 1].push_back(a - 1);
  }
 
  vector<int> c(n);
  for (auto &c_i : c) cin >> c_i;
  sort(c.begin(), c.end(), greater<int>());
 
  int max_sum = 0, idx = 0;
  vector<int> max_w(n, -1);
  queue<int> que;
  que.push(root);
  max_w[root] = c[idx++];
 
  while (!que.empty()) {
    int cur = que.front(); que.pop();
    for (auto u : inp[cur]) {
      if (max_w[u] != -1) continue;
      max_w[u] = c[idx++];
      max_sum += min(max_w[cur], max_w[u]);
      que.push(u);
    }
  }
 
  cout << max_sum << endl;
  for (int v = 0; v < n; ++v) {
    cout << max_w[v] << " \n"[v == n - 1];
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:3: error: 'queue' was not declared in this scope
   26 |   queue<int> que;
      |   ^~~~~
a.cc:4:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    3 | #include <algorithm>
  +++ |+#include <queue>
    4 | using namespace std;
a.cc:26:9: error: expected primary-expression before 'int'
   26 |   queue<int> que;
      |         ^~~
a.cc:27:3: error: 'que' was not declared in this scope
   27 |   que.push(root);
      |   ^~~
Language: C++

#include <iostream>
using namespace std;

using ll = long long;
using ld = long double;
const int root = 0;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> inp(n);
  for (int i = 0, a, b; i + 1 < n; ++i) {
    cin >> a >> b;
    inp[a - 1].push_back(b - 1);
    inp[b - 1].push_back(a - 1);
  }

  vector<int> c(n);
  for (auto &c_i : c) cin >> c_i;
  sort(c.begin(), c.end(), greater<int>());

  int max_sum = 0, idx = 0;
  vector<int> max_w(n, -1);
  queue<int> que;
  que.push(root);
  max_w[root] = c[idx++];

  while (!que.empty()) {
    int cur = que.front(); que.pop();
    for (auto u : inp[cur]) {
      if (max_w[u] != -1) continue;
      max_w[u] = c[idx++];
      max_sum += min(max_w[cur], max_w[u]);
      que.push(u);
    }
  }

  cout << max_sum << endl;
  for (int v = 0; v < n; ++v) {
    cout << max_w[v] << " \n"[v == n - 1];
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'vector' was not declared in this scope
   11 |   vector<vector<int>> inp(n);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:11:17: error: expected primary-expression before 'int'
   11 |   vector<vector<int>> inp(n);
      |                 ^~~
a.cc:14:5: error: 'inp' was not declared in this scope; did you mean 'int'?
   14 |     inp[a - 1].push_back(b - 1);
      |     ^~~
      |     int
a.cc:18:10: error: expected primary-expression before 'int'
   18 |   vector<int> c(n);
      |          ^~~
a.cc:19:20: error: 'c' was not declared in this scope
   19 |   for (auto &c_i : c) cin >> c_i;
      |                    ^
a.cc:20:8: error: 'c' was not declared in this scope
   20 |   sort(c.begin(), c.end(), greater<int>());
      |        ^
a.cc:20:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |   sort(c.begin(), c.end(), greater<int>());
      |   ^~~~
      |   short
a.cc:23:10: error: expected primary-expression before 'int'
   23 |   vector<int> max_w(n, -1);
      |          ^~~
a.cc:24:3: error: 'queue' was not declared in this scope
   24 |   queue<int> que;
      |   ^~~~~
a.cc:2:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    1 | #include <iostream>
  +++ |+#include <queue>
    2 | using namespace std;
a.cc:24:9: error: expected primary-expression before 'int'
   24 |   queue<int> que;
      |         ^~~
a.cc:25:3: error: 'que' was not declared in this scope
   25 |   que.push(root);
      |   ^~~
a.cc:26:3: error: 'max_w' was not declared in this scope; did you mean 'max_sum'?
   26 |   max_w[root] = c[idx++];
      |   ^~~~~
      |   max_sum
a.cc:30:19: error: 'inp' was not declared in this scope; did you mean 'int'?
   30 |     for (auto u : inp[cur]) {
      |                   ^~~
      |                   int
Language: C++

#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint 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)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7;

lint N, A, B, index = 0;
lint arr[10000];
lint val[10000];
vector<lint> to[10000];

void dfs(lint curr, lint prev) {
	val[curr] = arr[index];
	index++;
	REP(i, to[curr].size()) {
		lint next = to[curr][i];
		if (next == prev) continue;
		dfs(next, curr);
	}
}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	fill((long long*)val, (long long*)val + sizeof(val) / sizeof(long long), 0);
	REP(i, N - 1) {
		cin >> A >> B; A--; B--;
		to[A].push_back(B);
		to[B].push_back(A);
	}
	REP(i, N) {
		cin >> arr[i];
	}
	sort(arr, arr + N, greater<lint>());
	lint sum = 0;
	REP(i, N - 1) {
		sum += arr[i + 1];
	}
	val[0] = arr[index];
	index++;
	REP(i, to[0].size()) {
		dfs(to[0][i], 0);
	}
	cout << sum << endl;
	REP(i, N) {
		cout << val[i] << " ";
	}
}


Compiler output:
a.cc:19:15: error: 'lint index' redeclared as different kind of entity
   19 | lint N, A, B, index = 0;
      |               ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'void dfs(lint, lint)':
a.cc:25:24: error: invalid types 'lint [10000] {aka long long int [10000]}[<unresolved overloaded function type>]' for array subscript
   25 |         val[curr] = arr[index];
      |                        ^
a.cc:26:14: error: no post-increment operator for type
   26 |         index++;
      |              ^~
a.cc: In function 'int main()':
a.cc:51:21: error: invalid types 'lint [10000] {aka long long int [10000]}[<unresolved overloaded function type>]' for array subscript
   51 |         val[0] = arr[index];
      |                     ^
a.cc:52:14: error: no post-increment operator for type
   52 |         index++;
      |              ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

vector<int> edge[d5],num,res;
int cnt=0;
void dfs(int x,int p){
    for(auto it:edge[x]){
        if(res[it]!=-1||p==it)continue;
        dfs(it,x);
    }
    res[x]=num[cnt];
    cnt++;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    num.resize(n);
    res.resize(n,-1);
    for(int i=0;i<n;i++)cin>>num[i];
    sort(All(num));
    res[0]=num[n-1];
    dfs(0,0);
    int ans=0;
    for(int i=0;i<n-1;i++)ans+=num[i];
    cout<<ans<<endl;
    for(int i=0;i<n;i++)cout<<res[i]<<' ';
    cout<<endl;
}

Compiler output:
a.cc:6:18: error: 'd5' was not declared in this scope
    6 | vector<int> edge[d5],num,res;
      |                  ^~
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:9:17: error: 'edge' was not declared in this scope
    9 |     for(auto it:edge[x]){
      |                 ^~~~
a.cc: In function 'int main()':
a.cc:25:9: error: 'edge' was not declared in this scope
   25 |         edge[a].push_back(b);
      |         ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pb push_back
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N; cin>>N;
  vii A(N);
  rep(i,1,N){
    int X,Y; cin>>X>>Y;
    A[X-1].pb(Y-1);
    A[Y-1].pb(X-1);
    }
  vi C(N);
  rep(i,0,N) cin>>C[i];
  sort(ALL(C),greater<int>());
  int sum=0;
  rep(i,1,N) sum+=C[i];
  cout<<sum<<endl;
  vi F(N,-1);
  F[0]=0;
  int count=1;
  queue<int> Q;
  A.push(0);
  while(Q.size()>0){
    int X=Q.front(); Q.pop();
    rep(i,0,A[X].size()){
      int Y=A[X][i];
      if(F[Y]==-1){
        F[Y]=count++;
        Q.push(Y);
        }
      }
    }
  rep(i,0,N) cout<<C[F[i]]<<" ";
  cout<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:33:5: error: 'class std::vector<std::vector<long long int> >' has no member named 'push'
   33 |   A.push(0);
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pb push_back
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N; cin>>N;
  vii A(N);
  rep(i,1,N){
    int X,Y; cin>>X>>Y;
    A[X-1].pb(Y-1);
    A[Y-1].pb(X-1);
    }
  vi C(N);
  rep(i,0,N) cin>>C[i];
  sort(ALL(C),greater<int>());
  int sum=0;
  rep(i,1,N) sum+=C[i];
  cout<<sum<<endl;
  int count=0;
  vi F(N,-1);
  F[0]=0;
  int count=1;
  queue<int> Q;
  A.push(0);
  while(Q.size()>0){
    int X=Q.front(); Q.pop();
    rep(i,0,A[X].size()){
      int Y=A[X][i];
      if(F[Y]==-1){
        F[Y]=count++;
        Q.push(Y);
        }
      }
    }
  rep(i,0,N) cout<<C[F[i]]<<" ";
  cout<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:32:7: error: redeclaration of 'long long int count'
   32 |   int count=1;
      |       ^~~~~
a.cc:29:7: note: 'long long int count' previously declared here
   29 |   int count=0;
      |       ^~~~~
a.cc:34:5: error: 'class std::vector<std::vector<long long int> >' has no member named 'push'
   34 |   A.push(0);
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N; cin>>N;
  vii A(N);
  rep(i,1,N){
    int X,Y; cin>>X>>Y;
    A[X-1].pb(Y-1);
    A[Y-1].pb(X-1);
    }
  vi C(N);
  rep(i,0,N) cin>>C[i];
  sort(ALL(C),greater<int>());
  int sum=0;
  rep(i,1,N) sum+=C[i];
  cout<<sum<<endl;
  int count=0;
  vi F(N,-1);
  F[0]=0;
  int count=1;
  queue<int> Q;
  A.push(0);
  while(Q.size()>0){
    int X=Q.front(); Q.pop();
    rep(i,0,A[X].size()){
      int Y=A[X][i];
      if(F[Y]==-1){
        F[Y]=count++;
        Q.push(Y);
        }
      }
    }
  rep(i,0,N) cout<<C[F[i]]<<" ";
  cout<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:19:12: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'class std::vector<long long int>'} has no member named 'pb'
   19 |     A[X-1].pb(Y-1);
      |            ^~
a.cc:20:12: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'class std::vector<long long int>'} has no member named 'pb'
   20 |     A[Y-1].pb(X-1);
      |            ^~
a.cc:31:7: error: redeclaration of 'long long int count'
   31 |   int count=1;
      |       ^~~~~
a.cc:28:7: note: 'long long int count' previously declared here
   28 |   int count=0;
      |       ^~~~~
a.cc:33:5: error: 'class std::vector<std::vector<long long int> >' has no member named 'push'
   33 |   A.push(0);
      |     ^~~~
Language: Java

import java.util.*;
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    List<List<Integer>> from = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      from.add(new ArrayList<>());
    }
    
    for (int i = 0; i < N-1; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      from.get(a-1).add(b-1);
      from.get(b-1).add(a-1);
    }
    int[] c = new int[N];
    for (int i = 0; i < N; i++) {
      c[i] = sc.nextInt();
    }
    Arrays.sort(c);
    
    int idx = N-1;
    int[] d = new int[N];
    boolean[] visit = new boolean[N];
    long M = 0;
    Queue<Integer> q = new LinkedList<>();
    d[0] = c[idx--];
    q.offer(0);
    visit[0] = true;
    while (!q.isEmpty()) {
      int now = q.poll();
      for (int next : from.get(now.a)) {
        if (!visit[next]) {
          d[next] = c[idx--];
          M += Math.min(d[now], d[next]);
          q.offer(next);
          visit[next] = true;
        }
      }
    }
      
    StringBuilder ans = new StringBuilder();
    ans.append(M+"\n");
    for (int i = 0; i < N; i++) {
      ans.append(d[i]);
      if (i < N-1) {
        ans.append(' ');
      } else {
        ans.append('\n');
      }
    }
    System.out.print(ans.toString());
  }
}

Compiler output:
Main.java:34: error: int cannot be dereferenced
      for (int next : from.get(now.a)) {
                                  ^
1 error
Language: Java

import java.util.*;
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    List<List<Integer>> from = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      from.add(new ArrayList<>());
    }
    
    for (int i = 0; i < N-1; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      from.get(a-1).add(b-1);
      from.get(b-1).add(a-1);
    }
    int[] c = new int[N];
    for (int i = 0; i < N; i++) {
      c[i] = sc.nextInt();
    }
    Arrays.sort(c);
    
    int idx = N-1;
    int[] d = new int[N];
    boolean[] visit = new boolean[N];
    long M = 0;
    Queue<Integer> q = new LinkedList<>();
    d[0] = c[idx--];
    q.offer(new Pair(0, d[0]));
    visit[0] = true;
    while (!q.isEmpty()) {
      int now = q.poll();
      for (int next : from.get(now.a)) {
        if (!visit[next]) {
          d[next] = c[idx--];
          M += Math.min(d[now], d[next]);
          q.offer(next);
          visit[next] = true;
        }
      }
    }
      
    StringBuilder ans = new StringBuilder();
    ans.append(M+"\n");
    for (int i = 0; i < N; i++) {
      ans.append(d[i]);
      if (i < N-1) {
        ans.append(' ');
      } else {
        ans.append('\n');
      }
    }
    System.out.print(ans.toString());
  }
}

Compiler output:
Main.java:30: error: cannot find symbol
    q.offer(new Pair(0, d[0]));
                ^
  symbol:   class Pair
  location: class Main
Main.java:34: error: int cannot be dereferenced
      for (int next : from.get(now.a)) {
                                  ^
2 errors
Language: C++

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int N;
vector<int> graph[10010];
vector<int> C,ans;
int idx = 0;
void dfs(int from, int now){
    //cout << from << " " << now << " " << idx << endl;
    ans[now] = C[idx];
    for(auto next: graph[now]){
        if(next == from)continue;
        index++;
        dfs(now, next);
    }
}
main(){
    cin >> N;
    vector<int> A(N-1), B(N-1);
    rep(i,0,N-1){
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
        graph[A[i]].push_back(B[i]);
        graph[B[i]].push_back(A[i]);
    }
    C.resize(N);
    ans.resize(N);
    rep(i,0,N)cin >> C[i];
    sort(C.rbegin(), C.rend());
    
    dfs(-1, 0);

    ll sum = 0;
    rep(i,0,N-1){
        sum += min(ans[A[i]], ans[B[i]]);
    }
    cout << sum << endl;
    rep(i,0,N){
        cout << ans[i] << " \n"[i==N-1];
    }

}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:17:14: error: no post-increment operator for type
   17 |         index++;
      |              ^~
a.cc: At global scope:
a.cc:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main(){
      | ^~~~
Language: C++

1.	ll ex_gcd(ll a,ll b,ll &x,ll &y){  
2.	    if(a==0 && b==0)return -1;  
3.	    if(b == 0){  
4.	        x = 1;y = 0;return a;  
5.	    }  
6.	    ll d = ex_gcd(b,a%b,y,x);  
7.	    y -= a/b*x;   
8.	    return d;  
9.	}  
10.	//解ax = c (mod b)，相当于ax + by = c (mod b)
11.	bool liEu(ll a, ll b, ll c, ll& x, ll& y) {  
12.	  ll d = ex_gcd(a, b, x, y);  
13.	  if (c % d != 0) return 0;  
14.	  ll k = c / d;  
15.	  x *= k;  
16.	  y *= k;  
17.	  return 1;  
18.	}  


Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 1.      ll ex_gcd(ll a,ll b,ll &x,ll &y){
      | ^~
a.cc:10:1: error: expected unqualified-id before numeric constant
   10 | 10.     //解ax = c (mod b)，相当于ax + by = c (mod b)
      | ^~~
Language: C++

/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#define min(a, b) a < b? a: b

int computeMaxOfMin(int edges[][2], int values[], int n, int *vertices){
	int k = 0;
	int maximumSum = 0;
	for (int i = 0; i < n - 1; i++){
		if (vertices[edges[i][0]] == -1){
			vertices[edges[i][0]] = values[k++];
		}
		if (vertices[edges[i][1]] == -1){
			vertices[edges[i][1]] = values[k++];
		}
		maximumSum += min(vertices[edges[i][0]], vertices[edges[i][1]]);
	}
	return maximumSum;
}
void initialize(int *vertices, int n){
	for (int i = 1; i < n; i++){
		vertices[i] = -1;
	}
}

int comparator(const void *a, const void *b){
	return *((int*)b) - *((int*)a);
}

void display(int *vertices, int n){
	for (int i = 1; i < n; i++){
		cout << vertices[i];
	}
}

int main(){
	int n;
	scanf("%d", &n);
	int values[n];
	int edges[n - 1][2];
	int *vertices = (int*)malloc((n + 1) * sizeof(int));
	initialize(vertices, n + 1);
	for (int i = 0; i < n - 1; i++){
		cin >> edges[i][0] >> &edges[i][1]);
	}
	for (int i = 0; i < n; i++){
		cin >> values[i]);
	}
	
	qsort((void*)values, n, sizeof(int), comparator);
	cout << computeMaxOfMin(edges, values, n, vertices);
	display(vertices, n + 1);
	return 0;
}


Compiler output:
a.cc: In function 'void display(int*, int)':
a.cc:39:17: error: 'cout' was not declared in this scope
   39 |                 cout << vertices[i];
      |                 ^~~~
a.cc: In function 'int main()':
a.cc:51:17: error: 'cin' was not declared in this scope; did you mean 'min'?
   51 |                 cin >> edges[i][0] >> &edges[i][1]);
      |                 ^~~
      |                 min
a.cc:54:17: error: 'cin' was not declared in this scope; did you mean 'min'?
   54 |                 cin >> values[i]);
      |                 ^~~
      |                 min
a.cc:58:9: error: 'cout' was not declared in this scope
   58 |         cout << computeMaxOfMin(edges, values, n, vertices);
      |         ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int n;
cin>>n;
vector<int>a(n),b(n);
for(int i=0;i<n-1;i++){
    cin>>a.at(i)>>b.at(i);
    a.at(i)--;
    b.at(i)--;
}
vector<int> score(n);
for(int i=0;i<n;i++)cin>>score.at(i);
sort(score.begin(),score.end(),greater<int>());
vector<vector<int>> graph(n);
for(int i=0;i<n-1;i++){
    int c=a.at(i),d=b.at(i);
    graph.at(c).push_back(d);
    graph.at(d).push_back(c);
}
vector<int> ans(n,0);
queue<int> Q;
Q.push(0);
int idx=0;
while(!Q.enpty()){
    int now=Q.front();
    Q.pop();
    ans.at(now)=score.at(idx);
    idx++;
    for(int i=0;i<graph.at(now).size();i++){
        if(ans.at(gragh.at(now).at(i)==0))Q.push(gragh.at(now).at(i));
    }
}
ll total=0;
for(int i=1;i<n;i++){
    total+=score.at(i);
}
cout<<total<<endl;
for(int i=0;i<n;i++){
    cout<<ans.at(i)<<endl;
}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:10: error: 'class std::queue<int>' has no member named 'enpty'; did you mean 'empty'?
   26 | while(!Q.enpty()){
      |          ^~~~~
      |          empty
a.cc:32:19: error: 'gragh' was not declared in this scope; did you mean 'graph'?
   32 |         if(ans.at(gragh.at(now).at(i)==0))Q.push(gragh.at(now).at(i));
      |                   ^~~~~
      |                   graph
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


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

    if(n==1){
        int c;
        cin >> c;
        cout << '0' << endl;
        return 0;
    }

    vector<int> v[n];
    /*
    int f[n][n];
    rep(i,n){
        rep(j,n){
            f[i][j] = 0;
        }
    }
    */

    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        /*
        f[a][b] = 1;
        f[b][a] = 1;
        */
        v[a].push_back(b);
        v[b].push_back(a);
    }

    int c[n];
    rep(i,n){
        cin >> c[i];
    }
    sort(c,c+n);

    int r[200005] = {};
    queue<int> que;
    int d[n] = {};
    int count = n-1;

    int now = 0;
    int ma = 0;

    r[ma] = 1;
    ma++;

    que.push(0);

    

    while(!que.empty()){
        int x = que.front();
        que.pop();
        d[x] = c[count];
        count--;
        rep(i.v[x].size()){
            if(d[v[x][i]]==0){
                d[v[x][i]] = c[count];
                count--;
                que.push(v[x][i]);
            }
        }
    }

    ll ans = 0;
    rep(i,n-1){
        ans += c[i];
    }
    cout << ans << endl;
    rep(i,n){
        cout << d[i] << ' ';
    }
    cout << endl;

    return 0;
}
 
 


Compiler output:
a.cc:71:26: error: macro "rep" requires 2 arguments, but only 1 given
   71 |         rep(i.v[x].size()){
      |                          ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(i,n) for(int i = 0; i < (n); ++i)
      |         ^~~
a.cc: In function 'int main()':
a.cc:71:9: error: 'rep' was not declared in this scope
   71 |         rep(i.v[x].size()){
      |         ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


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

    if(n==1){
        int c;
        cin >> c;
        cout << '0' << endl;
        return 0;
    }

    vector<int> v;
    /*
    int f[n][n];
    rep(i,n){
        rep(j,n){
            f[i][j] = 0;
        }
    }
    */

    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        /*
        f[a][b] = 1;
        f[b][a] = 1;
        */
        v[a].push_back(b);
        v[b].push_back(a);
    }

    int c[n];
    rep(i,n){
        cin >> c[i];
    }
    sort(c,c+n);

    int r[200005] = {};
    queue<int> que;
    int d[n] = {};
    int count = n-1;

    int now = 0;
    int ma = 0;

    r[ma] = 1;
    ma++;

    que.push(0);

    

    while(!que.empty()){
        int x = que.front();
        que.pop();
        d[x] = c[count];
        count--;
        rep(i.v[x].size()){
            if(d[v[x][i]]==0){
                d[v[x][i]] = c[count];
                count--;
                que.push(v[x][i]);
            }
        }
    }

    ll ans = 0;
    rep(i,n-1){
        ans += c[i];
    }
    cout << ans << endl;
    rep(i,n){
        cout << d[i] << ' ';
    }
    cout << endl;

    return 0;
}
 
 


Compiler output:
a.cc:71:26: error: macro "rep" requires 2 arguments, but only 1 given
   71 |         rep(i.v[x].size()){
      |                          ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(i,n) for(int i = 0; i < (n); ++i)
      |         ^~~
a.cc: In function 'int main()':
a.cc:41:14: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   41 |         v[a].push_back(b);
      |              ^~~~~~~~~
a.cc:42:14: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   42 |         v[b].push_back(a);
      |              ^~~~~~~~~
a.cc:71:9: error: 'rep' was not declared in this scope
   71 |         rep(i.v[x].size()){
      |         ^~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define ll long long

using namespace std;

int main(){

    int n;
    vector<vector<int>> edge;
    vector<int> c;
    vector<int> ansv;

    int sum = 0;
    int maxc = 0;

    cin >> n;

    //1オリジンに対応のようなもの
    for(int i = 0; i <= n; i++){
        vector<int> tmp;
        edge.push_back(tmp);
    }

    for(int i = 0; i < n - 1; i++){
        int tmpa,tmpb;
        cin >> tmpa >> tmpb;

        edge[tmpa].push_back(tmpb);
        edge[tmpb].push_back(tmpa);
    }

    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        sum += tmp;
        maxc = max(maxc,tmp);
        
        c.push_back(tmp);
    }

    sum = sum - maxc;

    sort(c.begin(),c.end());
    int ci = 0;

    for(int i = 0; i <= n; i++){
        ansv.push_back(0);
    }

    while(ci < n - 1){

        vector<int> tmpv;

        for(int i = 1; i <= n; i++){
            if(edge[i].size() == 1){
                cerr << i << endl;
                tmpv.push_back(i);
            }
        }

        queue<int> erases;

        for(int i = 0; i < tmpv.size(); i++){
            int node = tmpv[i];
            ansv[node] = c[ci];
            ci++;
            
            //int to = edge[node][0];

            //cerr << "node:" << node;
            //cerr << " to:" << to << endl;

            /*
            edge[node].erase(edge[node].begin());

            for(int j = 0; j < edge[to].size(); j++){
                if(edge[to][j] == node){
                    edge[to].erase(edge[to].begin() + j);
                }
            }*/

            erases.push(node);
        }

        while(!erases.empty()){
            int node = erases.front();
            int to = edge[node][0];

            if(edge[node].size() != 0){
                edge[node].erase(edge[node].begin());
            }

            for(int i = 0; i < edge[to].size(); i++){
                if(edge[to][i] == node){
                    edge[to].erase(edge[to].begin() + i);
                }
            }

            erases.pop()
        }
    }

    for(int i = 1; i <= n; i++){
        if(ansv[i] == 0){
            ansv[i] = c[ci];
        }
    }
    
    //output
    cout << sum << endl;
    for(int i = 1; i < n; i++){
        cout << ansv[i] << " ";
    }

    cout << ansv[n] << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:103:25: error: expected ';' before '}' token
  103 |             erases.pop()
      |                         ^
      |                         ;
  104 |         }
      |         ~
Language: C++

//mo algo (no square root decomposition)
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define int long long int
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 998244353;
#define int long long int
vector<pii> g;
vector<pii> ed;
int32_t main()
{
    IOS;
    int n;
    cin >> n;
    g.resize(n + 1);
    for (int i = 0; i <= n; i++)
    {
        g[i] = {0, i};
    }
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        ed.pb({a, b});
        g[a].ff = g[a].ff + 1;
        g[b].ff = g[b].ff + 1;
    }
    int c[n + 1];
    for (int i = 1; i <= n; i++)
        cin >> c[i];
    sort(g.begin() + 1, g.end());
    sort(c + 1, c + n + 1);
    int val[n + 1];
    for (int i = 1; i <= n; i++)
    {
        int in = g[i].ss;
        val[in] = c[i];
        ans+=c[i];
    }
    ans-=c[n];
    int ans = 0;
    for (int i = 0; i < ed.size(); i++)
    {
        int a = ed[i].ff, b = ed[i].ss;
       // ans += min(val[a], val[b]);
    }
    cout << ans << endl;
    for (int i = 1; i <= n; i++)
        cout << val[i] << " ";
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:73:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   73 |         ans+=c[i];
      |         ^~~
      |         abs
a.cc:75:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   75 |     ans-=c[n];
      |     ^~~
      |     abs
Language: C++

// https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_d
/*<head>*/
#include "Tree.hpp"
/*</head>*/

/*<body>*/
/*</body>*/
int N;
int c[11234];
int as[11234];
int main() {
    cin >> N;
    Graph<> g(N);

    for (int i : range(N - 1)) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g.add_edge(a, b);
    }
    for (int i : range(N)) {
        cin >> c[i];
    }
    sort(c, c + N);
    reverse(c, c + N);
    cout << accumulate(c + 1, c + N, 0) << endl;
    Tree<> t(g);
    stack<int> st;
    st.push(t.get_root());
    for (int i : range(N)) {
        int v = st.top();
        st.pop();
        as[v] = c[i];
        for (int u : t.Ns(v)) st.push(u);
    }
    string sp(N, ' ');
    sp.back() = '\n';
    for (int i : range(N)) cout << as[i] << sp[i];
    return 0;
}

Compiler output:
a.cc:3:10: fatal error: Tree.hpp: No such file or directory
    3 | #include "Tree.hpp"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<iomanip>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
long long int n,x,y,ans=0;
cin>>n;
long long a[(n-1)*2];
long long b[n];
long long c[n];
for(int i=0;i<(n-1)*2;i+=2){
  cin>>a[i]>>a[i+1];
  a[i]=a[i]-1;
  a[i+1]=a[i+1]-1;
}
for(int i=0;i<n;i++){
  cin>>b[i];
  ans+=b[i];
}
sort(b,b+n);
ans-=b[n-1];
for(int i=0;i<(n-1)*2;i+=2){
  c[a[i]]=b[a[i]];
  c[a[i+1]]=b[a[i+1]]
}
cout<<ans<<endl;
for(int i=0;i<n;i++){
  cout<<c[i]<<" ";
}
cout<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:22: error: expected ';' before '}' token
   33 |   c[a[i+1]]=b[a[i+1]]
      |                      ^
      |                      ;
   34 | }
      | ~
Language: C++


#https://atcoder.jp/contests/m-solutions2019/submissions/5730635



#x = [1,2,3]
#while x:
#    if x : 
#        print(x)
#        x.pop()


n = int(input())

abn = [list(map(int,input().split())) for _ in range(n-1)]

cn = list( map(int, input().split()) )
cn.sort(reverse = True)


links = [set() for _ in range(n)]

for abi in abn:
    a, b = abi

    a -= 1; b-=1
    links[a].add(b)
    links[b].add(a)



# points of vertices
pv = [0]*n
ans = 0


#リンクを嘗めてsizeが1のもののindexだけ選ぶ
leaves = { i for i, l in enumerate(links) if len(l) == 1 }

# print(*abn)
# print(*cn)
# print(*leaves)
while leaves:
    
    index = leaves.pop()
    cmax = cn.pop()#popなので最小値から利用していく=>大きな値が残っていく
    
    pv[index] = cmax

    if not cn: # 最後のcmax (= 与えられた数列cnの最大値 )を加算する前に抜ける
        break

    ans += cmax
    for ci in links[index]:
        lu = links[ci]
        lu.remove(index)
        if len(lu) == 1:
            leaves.add(ci)

print(ans)
print(*pv)


Compiler output:
a.cc:2:2: error: invalid preprocessing directive #https
    2 | #https://atcoder.jp/contests/m-solutions2019/submissions/5730635
      |  ^~~~~
a.cc:6:2: error: invalid preprocessing directive #x
    6 | #x = [1,2,3]
      |  ^
a.cc:7:2: error: invalid preprocessing directive #while
    7 | #while x:
      |  ^~~~~
a.cc:8:11: error:  ':' without preceding '?'
    8 | #    if x :
      |           ^
a.cc:8: error: unterminated #if
    8 | #    if x :
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;

    cin >> N;

    vector<pair<int, int> > E;
    int C[N];

    int a, b;
    for(int i = 0; i < N - 1; i++) {
        cin >> a >> b;
        E.emplace_back(make_pair(a, b));
    }

    int c;
    for(int i = 0; i < N; i++) {
        cin >> c;
        C[i] = c;
    }

    sort(C, C + sizeof(C)/sizeof(C[0]), greater<int>());

    int M = 0;
    int D[N + 1];
    int index = N - 1;
    bool visited[N + 1];

    for(int i = 1; i < N + 1; i++) {
        D[i] = 0;
        visited[i] = false;
    }

    for(int i = 1; i < N; i++) M += C[i];

    auto e = E.front();
    E.erase(E.begin());

    visited[e.first] = true;
    visited[e.second] = true;
    D[e.first] = C[index];
    index--;
    D[e.second] =C[index];
    index--;

    int target;
    while(!E.empty()) {
        for(auto itr = E.begin(); itr != E.end(); ++itr) {
            if(visited[itr->first]) {
                target = itr->second;
                E.erase(itr);
                break;
            } else if(visited[itr->second]) {
                target = itr->first;
                E.erase(itr);
                break;
            }
        }
        visited[target] = true;
        D[target] = C[index];
        index--;
    }

    cout << M << endl;

    for(int i = 1; i < N + 1; i++) {
        if(i != 1) cout << " ";
        cout << D[i];
    }
    cout << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   26 |     sort(C, C + sizeof(C)/sizeof(C[0]), greater<int>());
      |     ^~~~
      |     short
Language: C++

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

#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back

vector< vector<int> > adj(123456);
vector<int> val(123456), res(123456);
vector<bool> visited(123456, false);
int current = 0;

int dfs(int x)
{
    res[x] = val[current++];
    visited[x] = true;
    for(int i = 0; i < adj[x].size(); i++)
    {
        if(!visited[adj[x][i]])
        {
            dfs(adj[x][i]);
        }
    }
}

int main()
{
    int n, sum = 0, maxx = INT_MIN; cin >> n;

    int a, b, c;
    for(int i = 0; i < n - 1; i++)
    {
        cin >> a >> b;
        a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    for(int i = 0; i < n; i++)
    {
        cin >> val[i];
        sum = sum + val[i];
        maxx = max(maxx, val[i]);
    }
    cout << sum - maxx << endl;
    sort(val.begin(), val.end(), greater<int>());
    dfs(0);

    for(int i = 0; i< n; i++)
    {
        cout << res[i] << " ";
    }
    cout << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:28:1: warning: no return statement in function returning non-void [-Wreturn-type]
   28 | }
      | ^
a.cc: In function 'int main()':
a.cc:32:28: error: 'INT_MIN' was not declared in this scope
   32 |     int n, sum = 0, maxx = INT_MIN; cin >> n;
      |                            ^~~~~~~
a.cc:5:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <algorithm>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main()
{
    int N, ans = 0;
    cin >> N;
    vector<int> c(N), deg(N), d(N);
    for (int i = 0; i + 1 < N; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        deg[a]++, deg[b]++;
    }
    for (int i = 0; i < N; i++)
    {
        cin >> c[i];
        ans += c[i];
    }
    sort(c.begin(), c.end());
    ans -= c[N - 1];
    for (int i = 0; i < N; i++)
    {
        int min = (1 << 20), v = 0;
        for (int j = 0; j < N; j++)
        {
            if (deg[j] < min && d[j] == 0)
                min = deg[j], v = j;
        }
        d[v] = c[i];
        for (auto &p : G[v])
        {
            deg[p]--;
        }
    }
    cout << ans << endl;
    for (int i = 0; i < N; i++)
    {
        cout << d[i] << (i == N - 1 ? "\n" : " ");
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:24: error: 'G' was not declared in this scope
   36 |         for (auto &p : G[v])
      |                        ^
Language: C++

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

int N;
const int MAX_N = 10000;

int c[MAX_N];

int is_leaf[MAX_N];

int main() {
    cin >> N;
    memset (is_leaf, 0, MAX_N);
    for (int i = 0; i < N-1; i++) {
        int a_in, b_in;
        cin >> a_in >> b_in;
        is_leaf[a_in - 1]++;
        is_leaf[b_in - 1]++;
    }
    for (int i = 0; i < N; i++) cin >> c[i];

    sort(c, c+N);

    int M = 0;
    for (int i = 0; i < N - 1; i++) {
        M += c[i];
    }
    cout << M << endl;

    int leaf_cnt = 0;
    int not_leaf = N-1;

    for (int i = 0; i < N; i++) {
        if (is_leaf[i] == 1) {
            cout << c[leaf_cnt] << " ";
            leaf_cnt++;
        }
        else {
            cout << c[not_leaf] << " ";
            not_leaf--;
        }
    }

    

Compiler output:
a.cc: In function 'int main()':
a.cc:43:6: error: expected '}' at end of input
   43 |     }
      |      ^
a.cc:12:12: note: to match this '{'
   12 | int main() {
      |            ^
Language: C++

module ddd;import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto G = new int[][](N);
    foreach (i; 0..N-1) {
        auto s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }
    auto A = readln.split.map!(to!long).array;
    A.sort!"a > b";

    auto ans = new long[](N);
    int cnt = 0;

    void dfs(int n, int p) {
        ans[n] = A[cnt++];
        foreach (m; G[n]) {
            if (m != p) {
                dfs(m, n);
            }
        }
    }

    dfs(0, -1);
    A[1..$].sum.writeln;
    ans.map!(to!string).join(" ").writeln;
}

Compiler output:
a.cc:10:17: error: too many decimal points in number
   10 |     foreach (i; 0..N-1) {
      |                 ^~~~
a.cc:31:7: error: too many decimal points in number
   31 |     A[1..$].sum.writeln;
      |       ^~~~
a.cc:1:1: error: 'module' does not name a type
    1 | module ddd;import std.stdio, std.array, std.string, std.conv, std.algorithm;
      | ^~~~~~
a.cc:1:1: note: C++20 'module' only available with '-fmodules-ts'
a.cc:1:12: error: 'import' does not name a type
    1 | module ddd;import std.stdio, std.array, std.string, std.conv, std.algorithm;
      |            ^~~~~~
a.cc:1:12: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import std.typecons, std.range, std.random, std.math, std.container;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import std.numeric, std.bigint, core.bitop, core.stdc.string;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'immutable' does not name a type; did you mean 'mutable'?
    5 | immutable long MOD = 10^^9 + 7;
      | ^~~~~~~~~
      | mutable
a.cc:7:1: error: '::main' must return 'int'
    7 | void main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:14: error: 'readln' was not declared in this scope
    8 |     auto N = readln.chomp.to!int;
      |              ^~~~~~
a.cc:9:24: error: expected primary-expression before ']' token
    9 |     auto G = new int[][](N);
      |                        ^
a.cc:10:14: error: 'i' was not declared in this scope
   10 |     foreach (i; 0..N-1) {
      |              ^
a.cc:18:28: error: parenthesized initializer in array new
   18 |     auto ans = new long[](N);
      |                            ^
a.cc:21:28: error: a function-definition is not allowed here before '{' token
   21 |     void dfs(int n, int p) {
      |                            ^
a.cc:30:5: error: 'dfs' was not declared in this scope
   30 |     dfs(0, -1);
      |     ^~~
Language: C++

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

typedef unsigned long long ull;

struct Node {
  ull value;
  vector<int> connectNodes;
};

Node nodes[10000];

int main()
{
  int N;
  cin >> N;
  
  for (int i=0; i<N-1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    nodes[a].connectNodes.push_back(b);
    nodes[b].connectNodes.push_back(a);
  }
  vector<ull> values;
  vector<int> nodeIndices(N);
  for (int i=0; i<N; i++) {
    ull c;
    cin >> c;
    values.push_back(c);
    nodeIndices[i] = i;
  }
  std::sort(values.begin(), values.end());
  std::sort(nodeIndices.begin(), nodeIndices.end(), [N](int lhs, int rhs) {
    if (nodes[lhs].connectNodes.size() == nodes[rhs].connectNodes.size()) {
        return abs(lhs-N/2) < abs(rhs-N/2);
    }
    return nodes[lhs].connectNodes.size() > nodes[rhs].connectNodes.size();
  });
  
  // Assign middle to the most connected node
  int valuesIdx = values.size()/2;
  for (int nodeIdx : nodeIndices) {
    nodes[nodeIdx].value = values[valuesIdx];
    values.erase(values.begin() + valuesIdx);
    valuesIdx = values.size()/2;
  }

  unordered_map<int, unordered_map<int, ull>> edgeToScore;
  ull totalScore = 0;
  for (int i1=0; i1<N; i1++) {
      for (int i2 : nodes[i1].connectNodes) {
          if (i1 > i2) {
              continue;
          }
          ull score = min(nodes[i1].value, nodes[i2].value);
          edgeToScore[i1][i2] = score;
          totalScore += score;
      }
  }

cout << totalScore << endl; 
for (int i=0; i<N-1; i++) {
    cout << nodes[i].value << " ";
}
cout << nodes[N-1].value << endl;
  
  
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:37:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   37 |   std::sort(values.begin(), values.end());
      |        ^~~~
      |        qsort
a.cc:38:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   38 |   std::sort(nodeIndices.begin(), nodeIndices.end(), [N](int lhs, int rhs) {
      |        ^~~~
      |        qsort
Language: C++

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

int N;
const int MAX_N = 10000;

int c[MAX_N];

int is_leaf[MAX_N];
memset(is_leaf, 0, MAX_N);

int main() {
    cin >> Q;
    for (int i = 0; i < N-1; i++) {
        int a_in, b_in;
        cin >> a_in >> b_in;
        is_leaf[a_in - 1]++;
        is_leaf[b_in - 1]++;
    }
    for (int i = 0; i < N; i++) cin >> c[i];

    sort(c, c+N);

    int M = 0;
    for (int i = 0; i < N - 1; i++) {
        M += c[i];
    }
    cout << M << endl;

    leaf_cnt = 0;

    for (int i = N-1; i >= 0; i++) {
        if (is_leaf[i] == 1) {
            cout << c[i - N-1 + leaf_cnt] << " ";
            leaf_cnt++;
        }
        else cout << c[i - leaf_cnt] << " ";
    }

    
    


    return 0;
}

Compiler output:
a.cc:11:7: error: expected constructor, destructor, or type conversion before '(' token
   11 | memset(is_leaf, 0, MAX_N);
      |       ^
a.cc: In function 'int main()':
a.cc:14:12: error: 'Q' was not declared in this scope
   14 |     cin >> Q;
      |            ^
a.cc:31:5: error: 'leaf_cnt' was not declared in this scope
   31 |     leaf_cnt = 0;
      |     ^~~~~~~~