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

#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 200005;

int n, q, cnt;
ll in[N], re[N], sz[N], a[N];
vector<int> G[N];

void dfs(int u, int p) {
    in[u] = ++cnt;
    re[cnt] = u;
    sz[u] = 1;
    for (int v : G[u]) {
        if (v == p) continue;
        dfs(v, u);
        sz[u] += sz[v];
    }
}

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n >> q;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    dfs(1, 0);
    while (q--) {
        int p, x;
        cin >> p >> x;
        a[in[p]] += x;
        a[in[p] + sz[p]] -= x;
    }
    for (int i = 1; i <= n; ++i)
        a[i] += a[i - 1];
    for (int i = 1; i <= n; ++i)
        cout << a[re[i]] << " \n" [i == n];
}

Compiler output:
a.cc:8:1: error: 'll' does not name a type
    8 | ll in[N], re[N], sz[N], a[N];
      | ^~
a.cc: In function 'void dfs(int, int)':
a.cc:12:5: error: 'in' was not declared in this scope; did you mean 'yn'?
   12 |     in[u] = ++cnt;
      |     ^~
      |     yn
a.cc:13:5: error: 're' was not declared in this scope
   13 |     re[cnt] = u;
      |     ^~
a.cc:14:5: error: 'sz' was not declared in this scope
   14 |     sz[u] = 1;
      |     ^~
a.cc: In function 'int main()':
a.cc:35:9: error: 'a' was not declared in this scope
   35 |         a[in[p]] += x;
      |         ^
a.cc:35:11: error: 'in' was not declared in this scope; did you mean 'yn'?
   35 |         a[in[p]] += x;
      |           ^~
      |           yn
a.cc:36:19: error: 'sz' was not declared in this scope
   36 |         a[in[p] + sz[p]] -= x;
      |                   ^~
a.cc:39:9: error: 'a' was not declared in this scope
   39 |         a[i] += a[i - 1];
      |         ^
a.cc:41:17: error: 'a' was not declared in this scope
   41 |         cout << a[re[i]] << " \n" [i == n];
      |                 ^
a.cc:41:19: error: 're' was not declared in this scope
   41 |         cout << a[re[i]] << " \n" [i == n];
      |                   ^~
Language: C++

class Node:
    def __init__(self, name):
        self.name = name
        self.parent = None
        self.progeny = None
        self.count = 0
        self.children = []
    
    def __str__(self):
        return "{}({}):{}".format(self.name, self.count, len(self.children))
        
    def set_parent(self, parent):
        self.parent = parent
        
    def add_child(self, child):
        self.children.append(child)
        child.set_parent(self)
        
    def num_child(self):
        return len(self.children)
    
    def add_count(self, count):
        self.count += count
    
    def get_progeny(self):
        if self.progeny==None:
            self.progeny = []
            self.progeny.extend(self.children)
            for child in self.children:
                self.progeny.extend(child.get_progeny())
        return self.progeny


def print_tree(node, tab):
    print("{}{}({})".format("\t"*tab, node.name, node.count))
    num = node.num_child()
    if num != 0:
        for i in range(num):
            print_tree(node.children[i], tab+1)

if __name__ == "__main__":
    n, q = map(int, input().split())
    nodes = [0] + [Node(i) for i in range(1,n+1)]
    for i in range(1,n):
        a, b = map(int, input().split())
        nodes[a].add_child(nodes[b])
    for _ in range(q):
        p, x = map(int, input().split())
        nodes[p].add_count(x)
        for node in nodes[p].get_progeny():
            node.add_count(x)
    print(" ".join([str(nodes[i].count) for i in range(1,n+1)]))

Compiler output:
a.cc:2:9: error: expected class-name before '__init__'
    2 |     def __init__(self, name):
      |         ^~~~~~~~
a.cc:2:9: error: expected '{' before '__init__'
a.cc:2:18: error: 'self' was not declared in this scope
    2 |     def __init__(self, name):
      |                  ^~~~
a.cc:2:24: error: 'name' was not declared in this scope
    2 |     def __init__(self, name):
      |                        ^~~~
a.cc:2:28: error: expression list treated as compound expression in initializer [-fpermissive]
    2 |     def __init__(self, name):
      |                            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll int res[200000];
ll int add[200000];
vector<int> edges[200000];
ll bool visit[200000];

int n,q;

void solve(int nownode, int nowcnt){
  visit[nownode] = true;
  res[nownode] = nowcnt + add[nownode];
  nowcnt = res[nownode];
  if(edges[nownode].size() == 0) return;
  for(int i = 0; i < edges[nownode].size(); i++){
    int to = edges[nownode][i];
    if(visit[to]) continue;
    // cout << "nownode : " << nownode << " to: " << to << " nowcnt: " << nowcnt << endl;
    solve(to, nowcnt);
  }
}
int main(){
  cin >> n >> q;
  REP(i, n-1){
    int from, to;
    cin >> from >> to;
    edges[from-1].pb(to-1);
    edges[to-1].pb(from-1);
  }
  REP(i, 200000){
    res[i] = 0;
    add[i] = 0;
  }
  REP(i, q){
    int node, amount;
    cin >> node >> amount;
    add[node-1] += amount;
  }
  solve(0, 0);
  REP(i, n){
    cout << res[i];
    if(i != n-1) cout << " ";
    else cout << endl;
  }
}

Compiler output:
a.cc:4:17: error: 'long long' specified with 'bool'
    4 | #define ll long long
      |                 ^~~~
a.cc:20:1: note: in expansion of macro 'll'
   20 | ll bool visit[200000];
      | ^~
a.cc: In function 'void solve(int, int)':
a.cc:25:3: error: reference to 'visit' is ambiguous
   25 |   visit[nownode] = true;
      |   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:20:9: note:                 'bool visit [200000]'
   20 | ll bool visit[200000];
      |         ^~~~~
a.cc:31:8: error: reference to 'visit' is ambiguous
   31 |     if(visit[to]) continue;
      |        ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:20:9: note:                 'bool visit [200000]'
   20 | ll bool visit[200000];
      |         ^~~~~
Language: C++

#include <stdio.h>

int g[200000], v[200000], res[200000];

int main(void) {
  int n, q;
  scanf("%d %d", &n, &q);

  int a, b;
  for(int i = 1; i < n; i++) {
    scanf("%d %d", &a, &b);

    g[b] = a;
  }

  int p, x;
  for(int i = 0; i < q; i++) {
    scanf("%d %d", &p, &x);

    v[p] += x;
  }

  for(int i = 1; i <= n; i++) {
    int src = g[i];

    res[i] = v[i] + res[src];
  }

  for(int i = 1; i < n; i++) {
    printf("%d ", res[i]);
  }
  printf("%d", res[n]);

  return 0;
}
~/t/at

Compiler output:
a.cc:36:2: error: expected class-name before '/' token
   36 | ~/t/at
      |  ^
Language: C++

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)


vector<int> co(200005, 0);
vector<vector<int>> child(200005);

void dfs(int a, int x)
{
  co[a] += x;
  rep(i, child[d].size())
    dfs(child[a][i], co[a]);
}

int main()
{
  int N, Q;
  int a, b, p, x;
  
  cin >> N >> Q;
  
  rep(i, N - 1)
  {
    cin >> a >> b;
    child[a].push_back(b);
  }
  
  rep(i, Q)
  {
    cin >> p >> x;
    co[p] += x;
  }
  
  countup(1, 0);
  
  for(int i = 1; i <= N; i++)
  {
    cout << co[i];
    if(i != N)
      cout << " ";
    else
      cout << endl;
  }
  
  return 0;
}
  
  




Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:13:16: error: 'd' was not declared in this scope
   13 |   rep(i, child[d].size())
      |                ^
a.cc:4:44: note: in definition of macro 'rep'
    4 | #define rep(i, n) for(int i = 0; i < (int)(n); i++)
      |                                            ^
a.cc: In function 'int main()':
a.cc:36:3: error: 'countup' was not declared in this scope
   36 |   countup(1, 0);
      |   ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

struct connect
{
  int a;
  int b;
};

class node
{
  public:
  int num;
  node* parent;
  int count;
  
  node(int x, node* par=nullptr):num(x),parent(par),count(0){};
};
signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q;
  cin >> N >> Q;
  vector<connect> con(N-1);
  REP(i,N-1) cin >> con[i].a >> con[i].b;
  
  vector<node*> ns;
  ns.push_back(new node(1));
  int order[N];
  order[0] = 0;
  int count=0;
  
  vector<node*> todo;
  todo.push_back(ns[0]);
  
  while(!con.empty())
  {
    vector<node*> tmp;
    for(node* nod:todo)
    {
      int n = nod->num;
      for(int itr=con.size()-1; itr!=-1; --itr)
        if(con[itr].a == n)
        {
          order[con[itr].b-1] = ++count;
          node* t = new node(con[itr].b,nod);
          ns.push_back(t);
          tmp.push_back(t);
          con[itr] = con.back();
          con.pop_back();
        }else if(con[itr].b == n)
        {
          order[con[itr].a-1] = ++count;
          node * t = new node(con[itr].a,nod);
          ns.push_back(t);
          tmp.push_back(t);
          con[itr] = con.back();
          con.pop_back();
        }
      todo.clear();
      for(auto n:tmp) todo.push_back(n);
    }
  }
  /*
  cout << ns.size() << endl;
  
  for(auto n:ns){
    cout << n->num << ":";
    if(n->parent!=nullptr)
    cout << n->parent->num;
    cout << endl;
  }
  */
  
 // int counter[N];
 // REP(i,N) counter[i]=0;
  REP(i,Q){
    int p, x;
    cin >> p >> x;
    ns[order[p-1]]->count += x;
    //counter[p-1] += x;
  }
  /*
  REP(i,N)
    cout << i+1 << ":" << counter[i] << endl;
  */
  
  //for(node* n:ns) n->count = counter[(n->num)-1];
  /*
  for(auto n:ns){
    cout << n->num << ":";
    //if(n->parent!=nullptr)
    cout << n->count;
    cout << endl;
  }*/
  for(auto itr=++(ns.begin()); itr!=ns.end(); ++itr)
    (*itr)->count += (*itr)->parent->count;
  REP(i,N) cout << ns[order[i]]->count << " ";
  cout << endl;
  return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:106:12: error: expected '}' at end of input
  106 |   return 0;
      |            ^
a.cc:25:1: note: to match this '{'
   25 | {
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

struct connect
{
  int a;
  int b;
};

class node
{
  public:
  int num;
  node* parent;
  int count;
  
  node(int x, node* par=nullptr):num(x),parent(par),count(0){};
};
signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q;
  cin >> N >> Q;
  vector<connect> con(N-1);
  REP(i,N-1) cin >> con[i].a >> con[i].b;
  
  vector<node*> ns;
  ns.push_back(new node(1));
  int order[N];
  order[0] = 0;
  int count=0;
  
  vector<node*> todo;
  todo.push_back(ns[0]);
  
  while(!con.empty())
  {
    vector<node*> tmp;
    for(node* nod:todo)
    {
      int n = nod->num;
      for(int itr=con.size()-1; itr!=-1; --itr)
        if(con[itr].a == n)
        {
          order[con[itr].b-1] = ++count;
          node* t = new node(con[itr].b,nod);
          ns.push_back(t);
          tmp.push_back(t);
          con[itr] = con.back();
          con.pop_back();
        }else if(con[itr].b == n)
        {
          order[con[itr].a-1] = ++count;
          node * t = new node(con[itr].a,nod);
          ns.push_back(t);
          tmp.push_back(t);
          con[itr] = con.back();
          con.pop_back();
        }
      todo.clear();
      for(auto n:tmp) todo.push_back(n);
    }
  }
  /*
  cout << ns.size() << endl;
  
  for(auto n:ns){
    cout << n->num << ":";
    if(n->parent!=nullptr)
    cout << n->parent->num;
    cout << endl;
  }
  */
  
 // int counter[N];
 // REP(i,N) counter[i]=0;
  REP(i,Q){
    int p, x;
    cin >> p >> x;
    ns[order[p-1]]->count += x;
    //counter[p-1] += x;
  }
  /*
  REP(i,N)
    cout << i+1 << ":" << counter[i] << endl;
  */
  
  for(node* n:ns) n->count = counter[(n->num)-1];
  /*
  for(auto n:ns){
    cout << n->num << ":";
    //if(n->parent!=nullptr)
    cout << n->count;
    cout << endl;
  }*/
  for(auto itr=++(ns.begin()); itr!=ns.end(); ++itr)
    (*itr)->count += (*itr)->parent->count;
  REP(i,N) cout << ns[order[i]]->count << " ";
  cout << endl;
  return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:94:30: error: 'counter' was not declared in this scope; did you mean 'count'?
   94 |   for(node* n:ns) n->count = counter[(n->num)-1];
      |                              ^~~~~~~
      |                              count
a.cc:106:12: error: expected '}' at end of input
  106 |   return 0;
      |            ^
a.cc:25:1: note: to match this '{'
   25 | {
      | ^
Language: C++

#include "bits/stdc++.h"

using namespace std;

using ll = long long;

int main() {
  int n, q; cin >> n >> q;
  vector<int> adj[n + 1];
  for (int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  
  vector<ll> lazy(n + 1, 0);
  while (q--) {
    int p, x; cin >> p >> x;
    lazy[p] += x;
  }0
  
  vector<ll> val(n + 1, 0);
  function<void(int, int, ll)> dfs = [&](int u, int p, ll v) -> void {
    val[u] = lazy[u] + v;
    for (int x : adj[u]) {
      if (x == p) continue;
      dfs(x, u, v + lazy[u]);
    }
  }
  
  dfs(1, 0, 0);
  
  for (int i = 1; i <= n; i++)
    cout << val[i] << " ";
  cout << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:5: error: expected ';' before 'vector'
   20 |   }0
      |     ^
      |     ;
   21 | 
   22 |   vector<ll> val(n + 1, 0);
      |   ~~~~~~
a.cc: In lambda function:
a.cc:24:5: error: 'val' was not declared in this scope
   24 |     val[u] = lazy[u] + v;
      |     ^~~
a.cc: In function 'int main()':
a.cc:31:3: error: expected ',' or ';' before 'dfs'
   31 |   dfs(1, 0, 0);
      |   ^~~
a.cc:34:13: error: 'val' was not declared in this scope
   34 |     cout << val[i] << " ";
      |             ^~~
Language: Java

import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    private static int[] points;
    private static NeighborList[] neighbors;

    private static class NeighborList {
        ArrayList<Integer> nl;
        public NeighborList() {
            nl = new ArrayList<Integer>();
        }
    }

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String[] mainParams = scanner.nextLine().split(" ");
        int paramN = Integer.parseInt(mainParams[0]);
        int paramQ = Integer.parseInt(mainParams[1]);
        points = new int[paramN];
        neighbors = new NeighborList[paramN + 1];

        for (int i = 0; i < paramN + 1; i++) {
            neighbors[i] = new NeighborList();
        }

        for (int i = 0; i < paramN - 1; i++) {
            String[] data = scanner.nextLine().split(" ");
            neighbors[Integer.parseInt(data[0])].nl.add(Integer.parseInt(data[1]));
            neighbors[Integer.parseInt(data[1])].nl.add(Integer.parseInt(data[0]));
        }

        for (int i = 0; i < paramQ; i++) {
            String[] data = scanner.nextLine().split(" ");
            points[Integer.parseInt(data[0]) - 1] += Integer.parseInt(data[1]);
        }

        scanner.close();

        addCountToPoint(1, 0);

        String[] outs = new String[points.length];
        for (int i = 0; i < points.length; i++) {
            outs[i] = String.valueOf(points[i]);
        }

        System.out.println(String.join(" ", outs));
    }

    private static void addCountToPoint(int pointId, int p) {
        for (int i = 0; i < nei.size(); i++) {
            int neId = neighbors[pointId].nl.get(i);
            if (neId == p) continue;
            points[neId - 1] += points[pointId - 1];
            addCountToPoint(neId, pointId);
        }
    }
}

Compiler output:
Main.java:52: error: cannot find symbol
        for (int i = 0; i < nei.size(); i++) {
                            ^
  symbol:   variable nei
  location: class Main
1 error
Language: C++

typedef long long ll;

vector<int> g[200005];
ll val[200005];

void dfs(int p, int c, ll sum){
  val[c] += sum;
  for(auto v : g[c]){
    if(v!=p){
      dfs(c, v, val[c]);
    }
  }
}

int main(int argc, char *argv[]) {
  int n,q;
  cin>>n>>q;
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(int i=0;i<q;i++){
    int p,x;cin>>p>>x;
    p--;
    val[p] += x;
  }
  dfs(-1, 0, 0);

  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    cout<<val[i];
  }
  cout<<endl;

  return 0;
}

Compiler output:
a.cc:3:1: error: 'vector' does not name a type
    3 | vector<int> g[200005];
      | ^~~~~~
a.cc: In function 'void dfs(int, int, ll)':
a.cc:8:16: error: 'g' was not declared in this scope
    8 |   for(auto v : g[c]){
      |                ^
a.cc: In function 'int main(int, char**)':
a.cc:17:3: error: 'cin' was not declared in this scope
   17 |   cin>>n>>q;
      |   ^~~
a.cc:22:5: error: 'g' was not declared in this scope
   22 |     g[a].push_back(b);
      |     ^
a.cc:33:10: error: 'cout' was not declared in this scope
   33 |     if(i)cout<<' ';
      |          ^~~~
a.cc:34:5: error: 'cout' was not declared in this scope
   34 |     cout<<val[i];
      |     ^~~~
a.cc:36:3: error: 'cout' was not declared in this scope
   36 |   cout<<endl;
      |   ^~~~
a.cc:36:9: error: 'endl' was not declared in this scope
   36 |   cout<<endl;
      |         ^~~~
Language: C++

#include <stdio.h>
#include <iostream>
#include <vector>

int ta[200000];
std::vector<int> ti[200000];
std::vector<int> tb[200000];

void f(int x, int idx)
{
  ta[idx] += x;
  for (auto &&i : ti[idx])
  {
    auto removeIt = std::remove_if(tb[i].begin(), tb[i].end(), [&](int value) {
      return value == idx;
    });
    tb[i].erase(removeIt, tb[i].end());
    f(ta[idx], i);
  }
  for (auto &&i : tb[idx])
  {
    auto removeIt = std::remove_if(ti[i].begin(), ti[i].end(), [&](int value) {
      return value == idx;
    });
    ti[i].erase(removeIt, ti[i].end());
    f(ta[idx], i);
  }
}

int main(int argc, char const *argv[])
{
  int N;
  int Q;

  scanf("%d %d", &N, &Q);

  for (size_t i = 0; i < N; i++)
  {
    ta[i] = 0;
  }


  int a, b;
  for (size_t i = 0; i < N - 1; i++)
  {
    scanf("%d %d", &a, &b);
    ti[a - 1].push_back(b - 1);
    tb[b - 1].push_back(a - 1);
  }

  int p, x;
  for (size_t i = 0; i < Q; i++)
  {
    scanf("%d %d", &p, &x);
    ta[p - 1] += x;
  }

  f(0, 0);

  for (size_t i = 0; i < N; i++)
  {
    printf("%d ", ta[i]);
  }

  return 0;
}


Compiler output:
a.cc: In function 'void f(int, int)':
a.cc:14:26: error: 'remove_if' is not a member of 'std'; did you mean 'remove_cv'?
   14 |     auto removeIt = std::remove_if(tb[i].begin(), tb[i].end(), [&](int value) {
      |                          ^~~~~~~~~
      |                          remove_cv
a.cc:22:26: error: 'remove_if' is not a member of 'std'; did you mean 'remove_cv'?
   22 |     auto removeIt = std::remove_if(ti[i].begin(), ti[i].end(), [&](int value) {
      |                          ^~~~~~~~~
      |                          remove_cv
Language: Java

import java.util.*;

public class Ki{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();

        Node nodes[] = new Node[n];
        for (int i=0; i<n; i++) nodes[i] = new Node();
        for (int i=0; i<n-1; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            nodes[a].neighbors.add(nodes[b]);
            nodes[b].neighbors.add(nodes[a]);
        }

        for (int i=0; i<q; i++){
            int p = sc.nextInt()-1;
            nodes[p].offset += sc.nextInt();
        }

        dfs(null, nodes[0], 0);
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<n; i++){
            sb.append(nodes[i].counter).append(" ");
        }
        System.out.println(sb.toString());


    }

    private static void dfs(Node parent, Node node, int sum){
        sum += node.offset;
        node.counter = sum;
        for (Node n: node.neighbors){
            if (n != parent){
                dfs(node, n, sum);
            }
        }
    }


    private static class Node{
        private List<Node> neighbors = new ArrayList<>();
        private int offset;
        private int counter;
    }
}

Compiler output:
Main.java:3: error: class Ki is public, should be declared in a file named Ki.java
public class Ki{
       ^
1 error
Language: Java

import java.util.*;

public class Ki{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();

        Node nodes[] = new Node[n];
        for (int i=0; i<n; i++) nodes[i] = new Node();
        for (int i=0; i<n-1; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            nodes[a].neighbors.add(nodes[b]);
            nodes[b].neighbors.add(nodes[a]);
        }

        for (int i=0; i<q; i++){
            int p = sc.nextInt()-1;
            nodes[p].offset += sc.nextInt();
        }

        dfs(null, nodes[0], 0);
        for (int i=0; i<n; i++){
            System.out.print(nodes[i].counter+" ");
        }


    }

    private static void dfs(Node parent, Node node, int sum){
        sum += node.offset;
        node.counter = sum;
        for (Node n: node.neighbors){
            if (n != parent){
                dfs(node, n, sum);
            }
        }
    }


    private static class Node{
        private List<Node> neighbors = new ArrayList<>();
        private int offset;
        private int counter;
    }
}

Compiler output:
Main.java:3: error: class Ki is public, should be declared in a file named Ki.java
public class Ki{
       ^
1 error
Language: Java

import java.util.*;

public class Ki{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();

        Node nodes[] = new Node[n];
        for (int i=0; i<n; i++) nodes[i] = new Node();
        for (int i=0; i<n-1; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            nodes[a].neighbors.add(nodes[b]);
            nodes[b].neighbors.add(nodes[a]);
        }

        for (int i=0; i<q; i++){
            int p = sc.nextInt()-1;
            nodes[p].counter += sc.nextInt();
        }

        dfs(null, nodes[0], 0);
        for (int i=0; i<n; i++){
            System.out.print(nodes[i].counter+" ");
        }


    }

    private static void dfs(Node parent, Node node, long sum){
        sum += node.offset;
        node.counter += sum;
        for (Node n: node.neighbors){
            if (n != parent){
                dfs(node, n, node.counter);
            }
        }
    }


    private static class Node{
        List<Node> neighbors = new ArrayList<>();
        long offset;
        long counter;
    }
}

Compiler output:
Main.java:3: error: class Ki is public, should be declared in a file named Ki.java
public class Ki{
       ^
1 error
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;
ll C[300000];


void dfs (int v, int p=-1) { // デフォルト変数？明示的に書かなければ-1が入る
 
    for (int u : to[v]) {
        if (u == p) continue; // 双方向に行けるときは親へ戻らないためにこの処理が必要
        C[u] += C[v];
        dfs(u, v);
    }
}


int main(){
  int N,Q;
  cin>>N>>Q;
  ll A[N],B[N],P[Q],X[Q];
  REP(i,N-1) cin>>A[i]>>B[i];
  REP(i,Q) cin>>P[i]>>X[i];
  
  REP(i,N+1) C[i]=0;
  REP(i,Q) C[P[i]]+=X[i];
  dfs(0);
  
  FOR(i,1,N+1) cout<<C[i]<<" ";
  cout<<endl;
}


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:23:18: error: 'to' was not declared in this scope; did you mean 'tm'?
   23 |     for (int u : to[v]) {
      |                  ^~
      |                  tm
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;
ll C[N+1];


void dfs (int v, int p=-1) { // デフォルト変数？明示的に書かなければ-1が入る
 
    for (int u : to[v]) {
        if (u == p) continue; // 双方向に行けるときは親へ戻らないためにこの処理が必要
        C[u] += C[v];
        dfs(u, v);
    }
}


int main(){
  int N,Q;
  cin>>N>>Q;
  ll A[N],B[N],P[Q],X[Q];
  REP(i,N-1) cin>>A[i]>>B[i];
  REP(i,Q) cin>>P[i]>>X[i];
  
  REP(i,N+1) C[i]=0;
  REP(i,Q) C[P[i]]+=X[i];
  dfs(0);
  
  FOR(i,1,N+1) cout<<C[i]<<" ";
  cout<<endl;
}


Compiler output:
a.cc:18:6: error: 'N' was not declared in this scope
   18 | ll C[N+1];
      |      ^
a.cc: In function 'void dfs(int, int)':
a.cc:23:18: error: 'to' was not declared in this scope; did you mean 'tm'?
   23 |     for (int u : to[v]) {
      |                  ^~
      |                  tm
a.cc:25:9: error: 'C' was not declared in this scope
   25 |         C[u] += C[v];
      |         ^
a.cc: In function 'int main()':
a.cc:38:14: error: 'C' was not declared in this scope
   38 |   REP(i,N+1) C[i]=0;
      |              ^
a.cc:39:12: error: 'C' was not declared in this scope
   39 |   REP(i,Q) C[P[i]]+=X[i];
      |            ^
a.cc:42:22: error: 'C' was not declared in this scope
   42 |   FOR(i,1,N+1) cout<<C[i]<<" ";
      |                      ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

void dfs (int v, int p=-1) { // デフォルト変数？明示的に書かなければ-1が入る
 
    for (int u : to[v]) {
        if (u == p) continue; // 双方向に行けるときは親へ戻らないためにこの処理が必要
        C[u] += C[v];
        dfs(u, v);
    }
}


int main(){
  int N,Q;
  cin>>N>>Q;
  ll A[N],B[N],C[N+1],P[Q],X[Q];
  REP(i,N-1) cin>>A[i]>>B[i];
  REP(i,Q) cin>>P[i]>>X[i];
  
  REP(i,N+1) C[i]=0;
  REP(i,Q) C[P[i]]+=X[i];
  dfs(0);
  
  FOR(i,1,N+1) cout<<C[i]<<" ";
  cout<<endl;
}


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:21:18: error: 'to' was not declared in this scope; did you mean 'tm'?
   21 |     for (int u : to[v]) {
      |                  ^~
      |                  tm
a.cc:23:9: error: 'C' was not declared in this scope
   23 |         C[u] += C[v];
      |         ^
Language: C++

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

vector<int> branch[200000];
int sum[200000];

void ans(int iw,int val){
  sum[iw] += val;
    for(int x: branch[iw])
    {
      ans(x,sum[iw]);
    }
}


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

  for(int i = 0; i < n -1; i++){
    int an,bn;
    cin >> an >> bn;
    branch[an-1].push_back(bn-1);
  }
  
  for(int i = 0;i < q;i++){
    int p,x;
    cin >> p >> x;
    sum[p-1] += x;
    }
  
  ans(0,0);
  
  for(int i = 0; i < n; i++){
    cout << sum[i] << " ";
  }
  
}
cin.tie(0); ios::sync_with_stdio(false);

Compiler output:
a.cc:40:1: error: 'cin' does not name a type
   40 | cin.tie(0); ios::sync_with_stdio(false);
      | ^~~
a.cc:40:13: error: specializing member 'std::basic_ios<char>::sync_with_stdio' requires 'template<>' syntax
   40 | cin.tie(0); ios::sync_with_stdio(false);
      |             ^~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,Q;
  cin>>N>>Q;
  ll A[N],B[N],C[N+1],P[Q],X[Q];
  REP(i,N-1) cin>>A[i]>>B[i];
  REP(i,Q) cin>>P[i]>>X[i];
  
  REP(i,N+1) C[i]=0;
  REP(i,Q) C[P[i]]+=X[i];
  
  int L[N+1]; //L[i]は頂点iの親
  REP(i,N+1) L[i]=i;
  REP(i,N-1) L[B[i]]=A[i];
  
  if(i>=2){
    FOR(i,2,N+1) C[i]+=C[L[i]];
  }
  
  FOR(i,1,N+1) cout<<C[i]<<" ";
  cout<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:6: error: 'i' was not declared in this scope
   33 |   if(i>=2){
      |      ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,Q;
  cin>>N>>Q;
  int A[N],B[N],C[N+1],P[Q],X[Q];
  REP(i,N-1) cin>>A[i]>>B[i];
  REP(i,Q) cin>>P[i]>>X[i];
  
  REP(i,N+1) C[i]=0;
  REP(i,Q) C[P[i]]+=X[i];
  
  REP(i.N-1) C[B[i]]=A[i];
  
  FOR(i,1,N+1) cout<<C[i]<<" ";
  cout<<endl;
}

Compiler output:
a.cc:29:12: error: macro "REP" requires 2 arguments, but only 1 given
   29 |   REP(i.N-1) C[B[i]]=A[i];
      |            ^
a.cc:11:9: note: macro "REP" defined here
   11 | #define REP(i,n)  FOR(i,0,n)
      |         ^~~
a.cc: In function 'int main()':
a.cc:29:3: error: 'REP' was not declared in this scope
   29 |   REP(i.N-1) C[B[i]]=A[i];
      |   ^~~
Language: Java

import java.util.*;
import java.io.*;
 
public class Main {
 
  private static void solve() {
    int n = nextInt();
    int q = nextInt();
    
    Map<Integer, List<Integer>> map = new HashMap<>();
    
    for (int i = 0; i < n; i++) {
      int a = nextInt() - 1;
      int b = nextInt() - 1;
      
      map.computeIfAbsent(a, (k) -> new ArrayList<>()).add(b);
      map.computeIfAbsent(b, (k) -> new ArrayList<>()).add(a);
    }
    
    long[] value = new long[n];
    long[] ans = new long[n];
    
    for (int i = 0; i < n - 1; i++) {
      int p = nextInt() - 1;
      int x = nextInt();
      
      value[p] += x;
    }
    
    
    preOrder(0, -1, map, value, ans, 0);
    
    for (int i = 0; i < q; i++) {
      out.print(ans[i] + " ");
    }
    out.println();
  }
  
  private static void preOrder(int root, 
                               int parent, 
                               Map<Integer, List<Integer>> map, 
                               long[] value,
                               long[] ans, long curValue) {
    ans[root] = curValue + value[root];
    
    List<Integer> ch = map.get(root);
    
    if (ch == null || ch.isEmpty()) return;
    
    for (int chId : ch) {
      if (chId != parent) {
        preOrder(chId, root, map, value, ans, ans[root]);
      }
    }   
  }
                               
  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);
 
    solve();
 
    out.close();
  }
 
  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;
 
  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }
 
  private static int nextInt() {
    return Integer.parseInt(next())a;
  }
 
  private static long nextLong() {
    return Long.parseLong(next());
  }
 
  public static void main(String[] args) {
    run();
  }
}

Compiler output:
Main.java:84: error: ';' expected
    return Integer.parseInt(next())a;
                                   ^
1 error
Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse
#define size(collection) ((ll) (collection).size())						// collection size

#endif

struct Edge
{
	ll vertex;	// 頂点
	Edge(ll v)
	{
		vertex = v;
	}
};

using Graph = vector<vector<Edge>>;

/**
@brief 深さ優先探索
@param v 頂点
@param r 根
@param memo 前処理したメモ(加算するべきカウンタの値)
@param ans 出力する答えを格納する配列
@note
 DFSで全てのノードを処理する。
**/
void DFS(ll v, ll r, vector<ll>& memo, vector<ll>& ans)
{
	if (r != -1)
		ans[v] = ans[r] + memo[v];

	for (const auto& e : g[v])
	{	// 後戻りしないようにする
		if (e.vertex == r)
			continue;

		DFS(e.vertex, v, memo, ans);
	}
}

int main(void)
{
	ll n, q; cin >> n >> q;

	ll u, v;
	Graph g;
	g.resize(n);
	rep(ei, 0, n - 1)
	{
		cin >> u >> v;
		--u; --v;
		g[u].push_back(Edge(v));
		g[v].push_back(Edge(u));
	}

	vector<ll> p(q), x(q);
	rep(i, 0, q)
	{
		cin >> p[i] >> x[i];
		p[i]--;
	}

	// 頂点xで加算するべきカウンタの値をメモしておく。
	vector<ll> memo(n);
	rep(i, 0, q)
		memo[p[i]] += x[i];

	vector<ll> ans(n);
	ans[0] = memo[0];
	DFS(0, -1, memo, ans);

	for(auto& e: ans)
		cout << e << " ";

	return 0;
}


Compiler output:
a.cc: In function 'void DFS(ll, ll, std::vector<long long int>&, std::vector<long long int>&)':
a.cc:42:30: error: 'g' was not declared in this scope
   42 |         for (const auto& e : g[v])
      |                              ^
Language: C++

#include<bits/stdc++.h>

using amespace std;

vector<int> g[20000 + 1];
int a[20000 + 1];

int f(int u, int p, int sum){
    a[u] += sum;

    for(int i = 0; i < g[u].size(); i++){
        int v = g[u][i];
        if(v == p){
            continue;
        }
        f(v, u, a[u]);
    }
}

int main(){
    int n, q;
    cin >> n >> q;
    for(int i = 0; i < n - 1; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    while(q--){
        int x, y;
        cin >> x >> y;
        a[x - 1] += y;
    }

    f(0, -1, 0);
    for(int i = 0; i < n; i++){
        cout << a[i] << " ";
    }

    return 0;
}

Compiler output:
a.cc:3:7: error: expected nested-name-specifier before 'amespace'
    3 | using amespace std;
      |       ^~~~~~~~
a.cc:5:1: error: 'vector' does not name a type
    5 | vector<int> g[20000 + 1];
      | ^~~~~~
a.cc: In function 'int f(int, int, int)':
a.cc:11:24: error: 'g' was not declared in this scope
   11 |     for(int i = 0; i < g[u].size(); i++){
      |                        ^
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
a.cc: In function 'int main()':
a.cc:22:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   22 |     cin >> n >> q;
      |     ^~~
      |     std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:27:9: error: 'g' was not declared in this scope
   27 |         g[u].push_back(v);
      |         ^
a.cc:38:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   38 |         cout << a[i] << " ";
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

vector <int> g[200000 + 5];
int a[200000 + 5];

int f(int u, int p, int sum) {
  a[u] += sum;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == p) continue;
    f(v, a[u]);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  while (q--) {
    int x, y;
    cin >> x >> y;
    a[x-1] += y;
  }
  f(0, -1, 0);
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}

Compiler output:
a.cc: In function 'int f(int, int, int)':
a.cc:13:6: error: too few arguments to function 'int f(int, int, int)'
   13 |     f(v, a[u]);
      |     ~^~~~~~~~~
a.cc:8:5: note: declared here
    8 | int f(int u, int p, int sum) {
      |     ^
a.cc:15:1: warning: no return statement in function returning non-void [-Wreturn-type]
   15 | }
      | ^
Language: C++

import java.util.*;
 
public class Main {
	static int N=26;
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		N = sc.nextInt();
		int kati=sc.nextInt();
		Tree tree[] =new Tree[N+1];
		int data[] =new int[(N-1)*2];
		int kati1[]=new int[N+1];
		int parent[]=new int[N+1];
		for(int i=0;i<(N-1)*2;i++) {
			data[i]=sc.nextInt();
		}
		for(int i=0;i<kati;i++) {
			int j=sc.nextInt();
			kati1[j]+=sc.nextInt();
					
		}
		
		
		
 
		
	
		for(int i=0;i<N-1;i++) {
			int j=data[i*2];
			Tree t =new Tree();
			tree[j]=t;
			if(tree[j].right==0) {
			tree[j].right = data[i*2+1];
			parent[data[i*2+1]]=j;
			}else {
		    tree[j].left = data[i*2+1];
		    parent[data[i*2+1]]=j;
			}
			
			
		}
		for(int i=1;i<tree.length;i++) {
			kati1[i] += kati1[parent[i]];	
			System.out.println(kati1[i]);
		}
		
		
		
		
		
 
	}
	public static class Tree{
		int left=0;
		int right=0;
		int parent=0;
		
	}
 
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int n, q;
vector<int> edge[300004];
long long x3200004];
long long counter[300004];
 
void dfs(int here, long long add){
	counter[here] = add;
	for(int there : edge[here])
		if(!counter[there])
			dfs(there, add + x[there]);
}
 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n>>q;
	for(int i = 0;i<n-1;i++){
		int a, b;
		cin>>a>>b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	memset(x, 0, sizeof(x));
	memset(counter, 0, sizeof(counter));
	for(int i = 0;i<q;i++){
		int p, a;
		cin>>p>>a;
		x[p] += a;
	}
	dfs(1, x[1]);
	for(int i = 1;i<=n;i++)	cout<<counter[i]<<' ';
	return 0;
}

Compiler output:
a.cc:6:19: error: expected initializer before ']' token
    6 | long long x3200004];
      |                   ^
a.cc: In function 'void dfs(int, long long int)':
a.cc:13:42: error: 'x' was not declared in this scope
   13 |                         dfs(there, add + x[there]);
      |                                          ^
a.cc: In function 'int main()':
a.cc:25:16: error: 'x' was not declared in this scope
   25 |         memset(x, 0, sizeof(x));
      |                ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve(istream &in, ostream &out) {

    vector<ll> G[2 * e5];
    vector<ll> ans(2 * e5);
    unordered_map<ll, ll> pl;
    vector<bool> seen(2 * e5);

    auto dfs = [&](auto &&f, ll now, ll value) {
        seen[now] = true;
        ans[now] = value;
        each(e, G[now]) {
            if (!seen[e]) {
                f(f, e, value + pl[e]);
            }
        }
    };
    ll n, q;
    in >> n >> q;
    rep(i, n - 1) {
        ll a, b;
        in >> a >> b;
        a--, b--;
        G[a].eb(b);
        G[b].eb(a);
    }

    rep(i, q) {
        ll p, x;
        in >> p >> x;
        p--;
        pl[p] += x;
    }
    dfs(dfs, 0, pl[0]);

    rep(i, n) out << ans[i] << " ";
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve(cin, cout);
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Compiler output:
a.cc: In instantiation of 'solve(std::istream&, std::ostream&)::<lambda(auto:28&&, ll, ll)> [with auto:28 = solve(std::istream&, std::ostream&)::<lambda(auto:28&&, ll, ll)>&; ll = long long int]':
a.cc:70:8:   required from here
   70 |     dfs(dfs, 0, pl[0]);
      |     ~~~^~~~~~~~~~~~~~~
a.cc:50:18: error: use of 'solve(std::istream&, std::ostream&)::<lambda(auto:28&&, ll, ll)> [with auto:28 = solve(std::istream&, std::ostream&)::<lambda(auto:28&&, ll, ll)>&; ll = long long int]' before deduction of 'auto'
   50 |                 f(f, e, value + pl[e]);
      |                 ~^~~~~~~~~~~~~~~~~~~~~
Language: C++

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

typedef struct node {
    struct node *parent;
    long counter;
} Node;

Node node[200001];

int main()
{
    memset(&node, 0, sizeof(node));

    int N, Q;
    scanf("%d %d", &N, &Q);

    int i;
    int a, b;
    for (i = 0; i < N - 1; i++) {
        scanf("%d %d", &a, &b);
        node[b].parent = &node[a];
    }

    int p, x;
    for (i = 0; i < Q; i++) {
        scanf("%d %d", &p, &x);
        node[p].counter += x;
    }

    printf("%ld\n", node[1].counter);

    for (i = 2; i <= N; i++) {
        if (node[i].parent != 0) {
            node[i].counter += node[i].parent->counter;
        }
        printf("%ld\n", node[i].counter);
    }

    return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:40:14: error: expected '}' at end of input
   40 |     return 0;
      |              ^
a.cc:12:1: note: to match this '{'
   12 | {
      | ^
Language: C++

#include <bits/stdc++.h>
#define push_back pb
using namespace std;
typedef long long ll;
ll ar[100005]={0};//,h[100005];
vector<int> v(100005);
void dfs(int a,int b)
{
    do
    {
        ar[a]+=(ll)b;
        for(int i=0;i<v[a].size();i++)
        dfs(v[a][i],b);
    }while(v[a].size());
}
int main() {
	int n,q;
	cin>>n>>q;
	//ll ar[n+1]={0};
	int a,b;
	for(int i=0;i<n;i++){cin>>a>>b;
	v[a].pb(b);}
	while(q-->0)
	{
	    cin>>a>>b;
	    //ar[a]+=(ll)b;
	    dfs(a,b);
	}
	for(int i=1;i<=n;i++)
	cout<<a[i]<<" ";
	cout<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:12:28: error: request for member 'size' 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'}
   12 |         for(int i=0;i<v[a].size();i++)
      |                            ^~~~
a.cc:13:17: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   13 |         dfs(v[a][i],b);
      |                 ^
a.cc:14:17: error: request for member 'size' 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'}
   14 |     }while(v[a].size());
      |                 ^~~~
a.cc: In function 'int main()':
a.cc:22:14: error: request for member 'pb' 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'}
   22 |         v[a].pb(b);}
      |              ^~
a.cc:30:16: error: invalid types 'int[int]' for array subscript
   30 |         cout<<a[i]<<" ";
      |                ^
Language: C++

#include <bits/stdc++.h>
#define push_back pb
using namespace std;
typedef long long ll;
//ll a[100005],h[100005];
vector<int> v(100005);
void dfs(int a,int b)
{
    do
    {
        ar[a]+=(ll)b;
        for(int i=0;i<v[a].size();i++)
        dfs(v[a][i],b);
    }while(v[a].size());
}
int main() {
	int n,q;
	cin>>n>>q;
	ll ar[n+1]={0};
	int a,b;
	for(int i=0;i<n;i++){cin>>a>>b;
	v[a].pb(b);}
	while(q-->0)
	{
	    cin>>a>>b;
	    //ar[a]+=(ll)b;
	    dfs(a,b);
	}
	for(int i=1;i<=n;i++)
	cout<<a[i]<<" ";
	cout<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:11:9: error: 'ar' was not declared in this scope; did you mean 'a'?
   11 |         ar[a]+=(ll)b;
      |         ^~
      |         a
a.cc:12:28: error: request for member 'size' 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'}
   12 |         for(int i=0;i<v[a].size();i++)
      |                            ^~~~
a.cc:13:17: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   13 |         dfs(v[a][i],b);
      |                 ^
a.cc:14:17: error: request for member 'size' 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'}
   14 |     }while(v[a].size());
      |                 ^~~~
a.cc: In function 'int main()':
a.cc:22:14: error: request for member 'pb' 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'}
   22 |         v[a].pb(b);}
      |              ^~
a.cc:30:16: error: invalid types 'int[int]' for array subscript
   30 |         cout<<a[i]<<" ";
      |                ^