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

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int Vmax = 200000;

vector<int> to(Vmax);
vector<int> ans;

void dfs(int v, int parent = -1) {
    rep(u, to[v].size()) {
        if(u == parent) {
            continue;
        }
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    ans.resize(n);

    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    dfs(0);

    rep(i, n) {
        cout << ans[i] << "\n";
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:20:18: error: request for member 'size' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)v))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   20 |     rep(u, to[v].size()) {
      |                  ^~~~
a.cc:10:38: note: in definition of macro 'rep'
   10 | #define rep(i, n) for(int i = 0; i < n; i++)
      |                                      ^
a.cc: In function 'int main()':
a.cc:38:15: error: request for member 'push_back' in 'to.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'}
   38 |         to[a].push_back(b);
      |               ^~~~~~~~~
a.cc:39:15: error: request for member 'push_back' in 'to.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'}
   39 |         to[b].push_back(a);
      |               ^~~~~~~~~
Language: Java


import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class D_Ki {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int q=scn.nextInt();
		int []arr=new int[n+1];
		HashMap<Integer, ArrayList<Integer>> hmap=new HashMap<>();
		//HashMap<Integer,Integer> sum =new HashMap<>();
		for(int i=0;i<n-1;i++) {
			int x=scn.nextInt();
			int y=scn.nextInt();
			if(hmap.containsKey(x)) {
				ArrayList<Integer> a=hmap.get(x);
				a.add(y);
				hmap.put(x,a);
			}else{
				ArrayList<Integer> a=new ArrayList<>();
				a.add(y);
				hmap.put(x,a);

			}
			if(hmap.containsKey(y)) {
				ArrayList<Integer> a=hmap.get(y);
				a.add(x);
				hmap.put(y,a);

			}else{
				ArrayList<Integer> a=new ArrayList<>();
				a.add(x);
				hmap.put(y,a);

			}
		}
		for(int i=0;i<q;i++) {
			int x=scn.nextInt();
			arr[x]+=scn.nextInt();
		}
		solve(hmap,arr,n);
		for(int i=1;i<=n;i++) {
			System.out.print(arr[i]+" ");
		}
	}
	public static void solve(HashMap<Integer, ArrayList<Integer>> hmap,int []arr,int n) {
		HashSet<Integer> set =new HashSet<>();
		for(int i=1;i<=n;i++) {
			if(!set.contains(i)) {
				recurse(hmap,arr,set,i,0);
			}
		}
	}
	public static void recurse(HashMap<Integer, ArrayList<Integer>> hmap,int []arr,HashSet<Integer> set,int x,int move) {
		ArrayList<Integer> a=hmap.get(x);
		set.add(x);
		arr[x]+=move;
		move=arr[x];
		for(int i=0;i<a.size();i++) {
			if(!set.contains(a.get(i))) {
				recurse(hmap,arr,set,a.get(i),move);
			}
		}
	}
}


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

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
const int  nmax = 200001;
bool graph[nmax][nmax];
bool visited[nmax];
vector <ll>v(nmax,0);

int dfs(int i,int n,int num){
    v[i]+=num;
    visited[i]=true;
    FOR(j,1,n+1){
        if(visited[j])continue;
        if(graph[i][j]){
            //cout << j << endl;
            dfs(j,n,v[i]);
        }
    }
    return 0;
}

int main(){
    int n,q;
    cin >> n >> q;
    ll a[n],b[n];
    ll p[q],x[q];
    
    REP(i,n-1){
        cin >> a[i] >> b[i];
        graph[a[i]][b[i]]=true;
        graph[b[i]][a[i]]=true;
    }
    REP(i,q){
        cin >> p[i] >> x[i];
        v[p[i]]+=x[i];
    }
    
    dfs(1,n,0);
    FOR(i,1,n+1){
        cout << v[i] << " ";
    }
    cout << endl;
    return 0;
}

Compiler output:
/tmp/ccrPW9Ki.o: in function `dfs(int, int, int)':
a.cc:(.text+0x1c): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccrPW9Ki.o
a.cc:(.text+0x3f): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccrPW9Ki.o
a.cc:(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccrPW9Ki.o
a.cc:(.text+0x95): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccrPW9Ki.o
/tmp/ccrPW9Ki.o: in function `main':
a.cc:(.text+0x363): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccrPW9Ki.o
a.cc:(.text+0x3be): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccrPW9Ki.o
/tmp/ccrPW9Ki.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x458): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccrPW9Ki.o
a.cc:(.text+0x47e): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccrPW9Ki.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;

int n,q;
const int  nmax = 200001;
bool graph[nmax][nmax];
bool visited[nmax];
vector <ll>v(nmax,0);

int dfs(int i,int n,int num){
    v[i]+=num;
    visited[i]=true;
    FOR(j,1,n+1){
        if(visited[j])continue;
        if(graph[i][j]){
            //cout << j << endl;
            dfs(j,n,v[i]);
        }
    }
    return 0;
}

int main(){
    
    cin >> n >> q;
    ll a[n],b[n];
    ll p[q],x[q];
    
    REP(i,n-1){
        cin >> a[i] >> b[i];
        graph[a[i]][b[i]]=true;
        graph[b[i]][a[i]]=true;
    }
    REP(i,q){
        cin >> p[i] >> x[i];
        v[p[i]]+=x[i];
    }
    
    dfs(1,n,0);
    FOR(i,1,n+1){
        cout << v[i] << " ";
    }
    cout << endl;
    return 0;
}

Compiler output:
/tmp/ccTdHC54.o: in function `dfs(int, int, int)':
a.cc:(.text+0x1c): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccTdHC54.o
a.cc:(.text+0x3f): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccTdHC54.o
a.cc:(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccTdHC54.o
a.cc:(.text+0x95): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccTdHC54.o
/tmp/ccTdHC54.o: in function `main':
a.cc:(.text+0x378): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccTdHC54.o
a.cc:(.text+0x3d9): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccTdHC54.o
/tmp/ccTdHC54.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x476): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccTdHC54.o
a.cc:(.text+0x49c): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccTdHC54.o
collect2: error: ld returned 1 exit status
Language: C

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int char_acs(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int str_acs(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int N;
int graph[200001][200001] = {0}, counter[200001] = {0};

void dfs(int node, int parent)
{
  int child, edge;
  for (child = 2; child <= N; child++)
  {
    edge = graph[node][child];
    if (edge == 1 && child != parent) // 辺があり、その頂点が子である
    {
      counter[child] += counter[node];
      dfs(child, node);
    }
  }
  return;
}

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

  int i;
  int node1, node2, init;
  for (i = 0; i < N - 1; i++)
  {
    scanf("%d %d", &node1, &node2);
    graph[node1][node2] = graph[node2][node1] = 1;
  }

  for (i = 0; i < Q; i++)
  {
    scanf("%d %d", &node1, &init);
    counter[node1] += init;
  }

  dfs(1, 0);

  for (node1 = 1; node1 <= N; node1++)
    printf("%d ", counter[node1]);
  printf("\n");

  return 0;
}


Compiler output:
/tmp/ccOqoIgM.o: in function `dfs':
main.c:(.text+0xef): relocation truncated to fit: R_X86_64_PC32 against symbol `counter' defined in .bss section in /tmp/ccOqoIgM.o
main.c:(.text+0x106): relocation truncated to fit: R_X86_64_PC32 against symbol `counter' defined in .bss section in /tmp/ccOqoIgM.o
main.c:(.text+0x120): relocation truncated to fit: R_X86_64_PC32 against symbol `counter' defined in .bss section in /tmp/ccOqoIgM.o
/tmp/ccOqoIgM.o: in function `main':
main.c:(.text+0x267): relocation truncated to fit: R_X86_64_PC32 against symbol `counter' defined in .bss section in /tmp/ccOqoIgM.o
main.c:(.text+0x283): relocation truncated to fit: R_X86_64_PC32 against symbol `counter' defined in .bss section in /tmp/ccOqoIgM.o
main.c:(.text+0x2be): relocation truncated to fit: R_X86_64_PC32 against symbol `counter' defined in .bss section in /tmp/ccOqoIgM.o
collect2: error: ld returned 1 exit status
Language: C

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; } /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; } /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{
  return *(char *)a - *(char *)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)

int main(void)
{
  int parent[200001] = {-1}, counter[200001] = {0};
  int N, Q;
  scanf("%d %d", &N, &Q);

  int i;
  int node, tmp;
  parent[1] = 0;
  for (i = 0; i < N - 1; i++) {
    scanf("%d %d", &tmp, &node);
    if (parant[node] == -1) parent[node] = tmp; // 頂点nodeに親がいない
    else parent[tmp] = node;
  }

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

  for (node = 2; node <= N; node++) {
    counter[node] += counter[parent[node]];
  }

  for (node = 1; node <= N; node++) {
    printf("%d ", counter[node]);
  }
  printf("\n");

  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:33:9: error: 'parant' undeclared (first use in this function); did you mean 'parent'?
   33 |     if (parant[node] == -1) parent[node] = tmp; // 頂点nodeに親がいない
      |         ^~~~~~
      |         parent
main.c:33:9: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

https://atcoder.jp/contests/abc138/custom_test#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep for(int i = 0;i<n;i++)
const long long MOD = 1000000007;
 
vector<vector<int>> graph(100001,vector<int>());
 
int main(){
  int n;cin >>n;
  int q;cin >> q;
  int a[n-1],b[n-1];
  for(int i = 0;i<n-1;i++){
    cin >> a[i] >> b[i];
  }
  long long c[n] = {};
  for(int i = 0;i<q;i++){
    int ai,bi;cin >> ai >> bi;
    c[ai-1] += bi;
  }
  for(int i = 0;i<n-1;i++){
    c[b[i]-1] += c[a[i]-1];
  }
  rep{
    cout << c[i] << " ";
  }cout << endl;
}

Compiler output:
a.cc:1:1: error: 'https' does not name a type
    1 | https://atcoder.jp/contests/abc138/custom_test#include <bits/stdc++.h>
      | ^~~~~
a.cc:8:1: error: 'vector' does not name a type
    8 | vector<vector<int>> graph(100001,vector<int>());
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:11:9: error: 'cin' was not declared in this scope
   11 |   int n;cin >>n;
      |         ^~~
a.cc:26:5: error: 'cout' was not declared in this scope
   26 |     cout << c[i] << " ";
      |     ^~~~
a.cc:27:4: error: 'cout' was not declared in this scope
   27 |   }cout << endl;
      |    ^~~~
a.cc:27:12: error: 'endl' was not declared in this scope
   27 |   }cout << endl;
      |            ^~~~
Language: C++

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

int ans[200005]={},memo[200005]={};
vector<int> ab[200005];

void my(int now, int carry)
{
	ans[now]+=carry;
	for (auto i = ab[now].begin(); i != ab[now].end(); ++i)
	{
		if (memo[*i]==0)
		{
			memo[*i]=1;
			my(*i,ans[now]);
		}
	}
}

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a,b;
	for (int i = 0; i < n-1; ++i)
	{
		cin>>a>>b;
		--a,--b;
		ab[a].emplace_back(b);
		ab[b].emplace_back(a);
	}
	int p,x;
	for (int i = 0; i < q; ++i)
	{
		cin>>p>>x;
		--p;
		ans[p]+=x;
	}
	memo[0]=1;
	my(0,0);
	cout<<ans[0];
	for (int i = 0; i < n; ++i)
	{
		cout<<" "<<ans[i];
	}
	cout<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:33:29: error: 'q' was not declared in this scope
   33 |         for (int i = 0; i < q; ++i)
      |                             ^
Language: C++

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

int ans[200005]={},memo[200005]={};
vector<int> ab[200005];

void my(int now, int carry)
{
	ans[now]+=carry;
	for (auto i = ab[now].begin(); i != ab[now].end(); ++i)
	{
		if (memo[*i]==0)
		{
			memo[*i]=1;
			my(*i,ans[now]);
		}
	}
}

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	for (int i = 0; i < n-1; ++i)
	{
		cin>>a>>b;
		--a,--b;
		v[a].emplace_back(b);
		v[b].emplace_back(a);
	}
	int p,x;
	for (int i = 0; i < q; ++i)
	{
		cin>>p>>x;
		--p;
		ans[p]+=x;
	}
	memo[0]=1;
	my(0,0);
	cout<<ans[0];
	for (int i = 0; i < n; ++i)
	{
		cout<<" "<<ans[i];
	}
	cout<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:26:22: error: 'a' was not declared in this scope
   26 |                 cin>>a>>b;
      |                      ^
a.cc:26:25: error: 'b' was not declared in this scope
   26 |                 cin>>a>>b;
      |                         ^
a.cc:28:17: error: 'v' was not declared in this scope
   28 |                 v[a].emplace_back(b);
      |                 ^
a.cc:32:29: error: 'q' was not declared in this scope
   32 |         for (int i = 0; i < q; ++i)
      |                             ^
Language: C++

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

int main(void){
    int n,q;
    cin >> n;
    cin >> q;
    vector <int> a;
    vector <int> b;
    vector <int> p;
    vector <int> x;
    int count[n+1];
    int prev[n+1];
    int next[n+1];
    int check[n+1];
    
    rep(i,n-1){
        int x,y;
        cin >> x;
        cin >> y;
        a.push_back(x);
        b.push_back(y);
    }
    rep(i,q){
        int c,d;
        cin >> c;
        cin >> d;
        p.push_back(c);
        x.push_back(d);
    }
    for(int i=1;i<n+1;i++){
        count[i] = 0;
        next[i] = 0;
      	prev[i] = 0;
        check[i] = 0;
    }
    
    rep(i,n-1){
        prev[b[i]]=a[i];
        next[a[i]]=b[i];
    }
    rep(i,q){
        for(int j=1;j<n+1;j++){
            if(next[j] == 0){
                int num=j;
                while(1){
                    if(num==1 && p[i] != 1){
                          while(1){
                              if(num == 1){
                                num = next[num];
                              }
                              else{
                                check[num] -= 1;
                                num = next[num];
                                if(next[num] == 0){
                                    break;
                                }
                              }
                          }
                          break;
                    }
                  
                    if(num != p[i]){
                        check[num]+=1;
                      	next[prev[num]]=num;
                        num = prev[num];
                    }
                 
                    else{
                        check[num]+=1;
                        num = prev[num];
                        break;
                    }
               	  }
                }
            }
        }
        for(int j=1;j<n+1;j++){
            if(check[j] >= 1){
            
                count[j] += x[i];
            }
            check[j] = 0;
        }
    }
   
    for(int i=1;i<n+1;i++){
        cout << count[i] << " ";
    }
    
    
    return 0;
}







Compiler output:
a.cc: In function 'int main()':
a.cc:82:31: error: 'i' was not declared in this scope
   82 |                 count[j] += x[i];
      |                               ^
a.cc: At global scope:
a.cc:88:5: error: expected unqualified-id before 'for'
   88 |     for(int i=1;i<n+1;i++){
      |     ^~~
a.cc:88:17: error: 'i' does not name a type
   88 |     for(int i=1;i<n+1;i++){
      |                 ^
a.cc:88:23: error: 'i' does not name a type
   88 |     for(int i=1;i<n+1;i++){
      |                       ^
a.cc:93:5: error: expected unqualified-id before 'return'
   93 |     return 0;
      |     ^~~~~~
a.cc:94:1: error: expected declaration before '}' token
   94 | }
      | ^
Language: C++

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

int main() {
  int n,q;
  cin >> n >> q;
  <vector<int> a(n),b(n),c(n);
  for(int i=0;i<n-1;i++){
    cin >> a.at(i) >> b.at(i);
  }
  vector<int> p(q),x(q);
  for(int i=0;i<q;i++){
    cin >> p.at(i) >> x.at(i);
    c.at(p.at(i)) += x.at(i);
  }
  for(int i=0;i<n-1;i++){
    c.at(b.at(i)) += c.at(a.at(i));
  }
  
  for(int i=0;i<n;i++){
    cout << c.at(i) << endl;
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: expected primary-expression before '<' token
    7 |   <vector<int> a(n),b(n),c(n);
      |   ^
a.cc:7:16: error: expected primary-expression before 'a'
    7 |   <vector<int> a(n),b(n),c(n);
      |                ^
a.cc:9:12: error: 'a' was not declared in this scope
    9 |     cin >> a.at(i) >> b.at(i);
      |            ^
a.cc:9:23: error: 'b' was not declared in this scope
    9 |     cin >> a.at(i) >> b.at(i);
      |                       ^
a.cc:14:5: error: 'c' was not declared in this scope
   14 |     c.at(p.at(i)) += x.at(i);
      |     ^
a.cc:17:5: error: 'c' was not declared in this scope
   17 |     c.at(b.at(i)) += c.at(a.at(i));
      |     ^
a.cc:17:10: error: 'b' was not declared in this scope
   17 |     c.at(b.at(i)) += c.at(a.at(i));
      |          ^
a.cc:17:27: error: 'a' was not declared in this scope
   17 |     c.at(b.at(i)) += c.at(a.at(i));
      |                           ^
a.cc:21:13: error: 'c' was not declared in this scope
   21 |     cout << c.at(i) << endl;
      |             ^
Language: C++

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

int main() {
  int n,q;
  cin >> n >> q;
  <vector<int> a(n),b(n),c(n);
  for(int i=0;i<n-1;i++){
    cin >> a.at(i) >> b.at(i);
  }
  vector<int> p(q),x(q);
  for(int i=0;i<q;i++){
    cin >> p.at(i) >> x.at(i);
    c.at(p.at(i)) += x.at(i);
  }
  for(int i=0;i<n-1;i++){
    c.at(b.at(i)) += c.at(a.at(i));
  }
  
  for(int i=0;i<n;i++){
    cout << c.at(i) << endl;
  }
  
  return 0;
}

Compiler output:
a.cc:1:10: fatal error: bits/sdtc++.h: No such file or directory
    1 | #include <bits/sdtc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

clock_t present = clock();
void complexiti(){
	present = clock() - present;
	cerr << "TIME : " << float(present)/CLOCKS_PER_SEC << '\n';
}

vector<ll> child[200010] , value(200010,0) , Ans(200010,0);
visit<int> visit(200010);

void dfs(int x){
	visit[x] = 1;
	Ans[x] = value[x];
	for(auto &i:child[x]){
		value[i] += value[x];
		if(!visit[i])dfs(i);
	}
	return;
}

void solver(){
	//~ type your code here
	int n , q;
	cin >> n >> q;
	for(int i = 0 ; i < n-1 ; ++i){
		int par , chi;
		cin >> par >> chi;
		child[par].push_back(chi);
	}
	for(int i = 0 ; i < q ; ++i){
		ll ver , val;
		cin >> ver >> val;
		value[ver] += val;
	}
	dfs(1);
	for(int i = 1 ; i <= n ; ++i){
		cout << Ans[i] << " ";
	}
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int queries = 1;
	//~ cin >> queries;
	for(int i = 0 ; i < queries ; ++i){
		solver();
	}
	complexiti();
	return 0;
}


Compiler output:
a.cc:12:1: error: 'visit<int>' does not name a type
   12 | visit<int> visit(200010);
      | ^~~~~~~~~~
a.cc: In function 'void dfs(int)':
a.cc:15:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   15 |         visit[x] = 1;
      |              ^
a.cc:19:26: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   19 |                 if(!visit[i])dfs(i);
      |                          ^
Language: C++

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

void dfs(int v) {
  vis[v] = 1;
  for(int u : adj[v]) {
    if(!vis[u]) {
      d[u] += d[v];
      dfs(u);
    }
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  for(int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  while(q--) {
    int a, x;
    cin >> a >> x;
    d[a] += x;
  }
  dfs(1);
  for(int i = 1; i <= n; i++)
    cout << d[i] << ' ';
  return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:5:3: error: 'vis' was not declared in this scope
    5 |   vis[v] = 1;
      |   ^~~
a.cc:6:15: error: 'adj' was not declared in this scope
    6 |   for(int u : adj[v]) {
      |               ^~~
a.cc:8:7: error: 'd' was not declared in this scope
    8 |       d[u] += d[v];
      |       ^
a.cc: In function 'int main()':
a.cc:20:5: error: 'adj' was not declared in this scope
   20 |     adj[a].push_back(b);
      |     ^~~
a.cc:26:5: error: 'd' was not declared in this scope
   26 |     d[a] += x;
      |     ^
a.cc:30:13: error: 'd' was not declared in this scope
   30 |     cout << d[i] << ' ';
      |             ^
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll N, Q;
    cin >> N >> Q;
    vector<vector<ll>> tree(N);
    rep(i, N-1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vector<ll> val(N);
    rep(i, Q) {
        ll p, x;
        cin >> p >> x; p--;
        val[p] += x;
    }
    dfs(dfs, 0, -1);

    cout << val << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:9: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   48 |     dfs(dfs, 0, -1);
      |         ^~~
      |         ffs
a.cc:48:5: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   48 |     dfs(dfs, 0, -1);
      |     ^~~
      |     ffs
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;


int main(void){
    int N, Q; cin >> N >> Q;
    vector<ll> point(N);
    for (int i = 0; i < N-1; i++)
    {
        cin >> a[i] >> b[i];
    }
    
    for (int i = 0; i < Q; i++)
    {
        int p, x;
        cin >> p >> x;
        point[p-1] += x;
    }
    for (int i = 0; i < N-1; i++)
    {
        point[b[i]-1] += point[a[i]-1];
    }
    cout << point[0];
    for (int i = 1; i < N; i++)
    {
        cout << ' ' << point[i];
    }
    cout << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: 'a' was not declared in this scope
   13 |         cin >> a[i] >> b[i];
      |                ^
a.cc:13:24: error: 'b' was not declared in this scope
   13 |         cin >> a[i] >> b[i];
      |                        ^
a.cc:24:15: error: 'b' was not declared in this scope
   24 |         point[b[i]-1] += point[a[i]-1];
      |               ^
a.cc:24:32: error: 'a' was not declared in this scope
   24 |         point[b[i]-1] += point[a[i]-1];
      |                                ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N,Q;
bool graph[200010][200010];
bool visited[200010];
int ans[200010];



void dfs(int v) {
  visited[v] = true;
  for (int v2 = 1; v2 < N+1; ++v2) {
   if (graph[v][v2] == false) continue;
   if (visited[v2] == true) continue;
   ans[v2] += ans[v];
   dfs(v2);
  }
 }

int main() {
  cin >> N >> Q;
  int a[N-1],b[N-1];
  FOR(i,0,N-2){
      cin >> a[i] >> b[i];
      graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  int p[Q],x[Q];
  FOR(i,0,Q-1){
      cin >> p[i] >> x[i];
      ans[p[i]] += x[i];
  }

  dfs(1);

  FOR(i,1,N) cout << ans[i] << " ";
  cout << endl;





}



Compiler output:
/tmp/ccaSiXkl.o: in function `dfs(int)':
a.cc:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccaSiXkl.o
a.cc:(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccaSiXkl.o
a.cc:(.text+0x78): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccaSiXkl.o
a.cc:(.text+0x8f): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccaSiXkl.o
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccaSiXkl.o
/tmp/ccaSiXkl.o: in function `main':
a.cc:(.text+0x3b3): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccaSiXkl.o
a.cc:(.text+0x3e3): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccaSiXkl.o
a.cc:(.text+0x420): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccaSiXkl.o
collect2: error: ld returned 1 exit status
Language: Java

import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

//////////////////////////////////////////////////////
      int n = sc.nextInt();
      int q = sc.nextInt();
      int[] a = new int[n];
      int[] b = new int[n];
      for(int i=1;i<n;i++){
        a[i] = sc.nextInt();
        b[i] = sc.nextInt();
      }
      int[] p = new int[q+1];
      int[] x = new int[q+1];
      for(int i=1;i<q+1;i++){
        p[i] = sc.nextInt();
        x[i] = sc.nextInt();
      }
//////////////////////////////////////////////////////

      long[] counter = new long[n+1];
      long[][] partTree = new long[n+1][n+1]; //this RE

      int[] numNo0 = new int[n+1];


      for(int i=1;i<n+1;i++){
        partTree[i][1] = i;
        numNo0[i] = 1 + 1;
      }

      for(int i=1;i<n;i++){
        for(int j=1;j<n+1;j++){
          for(int k=1;k<numNo0[j];k++){
            if(partTree[j][k]==a[i]){
              partTree[j][numNo0[j]] = b[i];
              numNo0[j]++;
            }
          }
        }
      }

///////////////////////////////////////////////////////

      for(int i=1;i<q+1;i++){
        for(int j=1;j<numNo0[p[i]];j++){
          counter[partTree[p[i]][j]]+=x[i];
        }
      }



    for(int i=1;i<n+1;i++){
      for(int j=1;j<n+1;j++){
        System.out.print(partTree[i][j]+" ");
      }
      System.out.println("");
    }



    for(int i=1;i<n+1;i++){
      System.out.print(counter[i]+" ");
    }


    }
}


Compiler output:
Main.java:50: error: incompatible types: possible lossy conversion from long to int
          counter[partTree[p[i]][j]]+=x[i];
                                ^
1 error
Language: Java

import java.util.*;

public class D138{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

//////////////////////////////////////////////////////
      int n = sc.nextInt();
      int q = sc.nextInt();
      int[] a = new int[n];
      int[] b = new int[n];
      for(int i=1;i<n;i++){
        a[i] = sc.nextInt();
        b[i] = sc.nextInt();
      }
      int[] p = new int[q+1];
      int[] x = new int[q+1];
      for(int i=1;i<q+1;i++){
        p[i] = sc.nextInt();
        x[i] = sc.nextInt();
      }
//////////////////////////////////////////////////////

      //long[] counter = new long[n+1];
      //int[][] partTree = new int[n+1][n+1];
/*
      int[] numNo0 = new int[n+1];


      for(int i=1;i<n+1;i++){
        partTree[i][1] = i;
        numNo0[i] = 1 + 1;
      }

      for(int i=1;i<n;i++){
        for(int j=1;j<n+1;j++){
          for(int k=1;k<numNo0[j];k++){
            if(partTree[j][k]==a[i]){
              partTree[j][numNo0[j]] = b[i];
              numNo0[j]++;
            }
          }
        }
      }

///////////////////////////////////////////////////////

      for(int i=1;i<q+1;i++){
        for(int j=1;j<numNo0[p[i]];j++){
          counter[partTree[p[i]][j]]+=x[i];
        }
      }


/*
    for(int i=1;i<n+1;i++){
      for(int j=1;j<n+1;j++){
        System.out.print(partTree[i][j]+" ");
      }
      System.out.println("");
    }



    for(int i=1;i<n+1;i++){
      System.out.print(counter[i]+" ");
    }
*/

    }
}


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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

vector<vector<int>> dfs(vector<vector<int>> v,int i){
  int n = v.sizeof();
  fr(j,n){
    if(v[i][j]==1){
      v=dfs(v,j);
      fr(k,n){
        if(v[j][k]==1)v[i][k]=1;
      }
    }
  }
  return v;
}

int main() {
    int n,q,a,b;
    cin >> n>>q;
    int ans[n];
    fr(i,n){
      ans[i]=0;
    }
	vector<vector<int>> v(n,vector<int>(n,0));
    fr(i,n-1){
      cin >> a>>b;
      v[a-1][b-1]=1;
    }
    v=dfs(v,0);
    fr(i,n){
      v[i][i]=1;
    }
    fr(i,q){
      int p,x;
      cin >>p>>x;
      fr(j,n){
        if(v[p-1][j]==1)ans[j]+=x;
      }
    }
    fr(i,n){
       cout << ans[i] <<" " ;
    }
   
}


Compiler output:
a.cc: In function 'std::vector<std::vector<int> > dfs(std::vector<std::vector<int> >, int)':
a.cc:9:13: error: expected unqualified-id before 'sizeof'
    9 |   int n = v.sizeof();
      |             ^~~~~~
Language: C++

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

const int N = 1e5 + 10;
bool mark[N];
int ans[N], sum[N];
vector<int> adj[N];

void dfs(int root, int extra) {
  	ans[root] = sum[root] + extra;
  	for (int i = 0; i < adj[root].size(); i++) {
      	int u = adj[root][i];
      	if(!mark[u])
			dfs(u, extra + sum[root]);
    }
}
int main() {
  	int n, u, v;
  	cin >> n;
  	for (int i = 1; i < n; i++) {
      	cin >> u >> v;
      	u--;
      	v--;
      	adj[u].push_back(v);
      	adj[v].push_back(u);
    }
  	int q, x, p;
  	cin >> q;
  	for (int i = 0; i < q; i++) {
    	cin >> x >> p;
      	sum[x - 1] += p;
	dfs(0, 0);
    for (int i = 0; i < n; i++)
      	cout << ans[i] << " ";
    cout << endl;
    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    int n,q;cin>>n>>q;
    vector<int>V[n];
    int f,t;
    rep(i,n){
        cin>>f>>t;
        f--;t--;
        V[f].push_back(t);
        V[f].push_back(t);
    }
    vector<int>C(n,0);
    rep(i,q){
        cin>>f>>t;
        f--;
        C[f]+=t;
    }
    vector<bool>judge(n,true);
    queue<int>Q;Q.push(0);
    judge[0]=false;
    while(!empty()){
        f=Q.front();Q.pop();
        rep(i,V[f].size()){
            t=V[f][i];
            judge[t]=false;
            C[t]+=C[f];
            Q.push(t);
        }
    }
    rep(i,n){
        cout<<C[i]<<' ';
    }
        
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:17: error: no matching function for call to 'empty()'
   30 |     while(!empty()){
      |            ~~~~~^~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:282:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.empty()) std::empty(const _Container&)'
  282 |     empty(const _Container& __cont) noexcept(noexcept(__cont.empty()))
      |     ^~~~~
/usr/include/c++/14/bits/range_access.h:282:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:292:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr bool std::empty(const _Tp (&)[_Nm])'
  292 |     empty(const _Tp (&)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/14/bits/range_access.h:292:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:302:5: note: candidate: 'template<class _Tp> constexpr bool std::empty(initializer_list<_Tp>)'
  302 |     empty(initializer_list<_Tp> __il) noexcept
      |     ^~~~~
/usr/include/c++/14/bits/range_access.h:302:5: note:   candidate expects 1 argument, 0 provided
Language: C++

#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7; 

fn dfs(p: usize, g: &Vec<Vec<usize>>, c: &mut Vec<usize>, used: &mut Vec<bool>){
    used[p] = true;
    for i in &g[p]{
        if used[*i]{
            continue;
        }
        c[*i] += c[p];
        dfs(*i, g, c, used);
    }
}

fn main(){
    let n: usize = read();
    let q: usize = read();
    let mut g: Vec<Vec<usize>> = vec![vec![]; n];
    let mut c: Vec<usize> = vec![0; n];
    let mut used: Vec<bool> = vec![false; n];
    for _ in 0..n-1{
        let mut a: usize = read();
        let mut b: usize = read();
        a -= 1;
        b -= 1;
        g[a].push(b);
        g[b].push(a);
    }
    for _ in 0..q {
        let mut p: usize = read();
        let x: usize = read();
        p -= 1;
        c[p] += x;
    }
    dfs(0, &g, &mut c, &mut used);
    print!("{}", c[0]);
    for i in 1..n {
        print!(" {}", c[i]);
    }
    println!();
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #![allow(unused_imports)]
      |  ^
a.cc:2:2: error: invalid preprocessing directive #!
    2 | #![allow(dead_code)]
      |  ^
a.cc:26:14: error: too many decimal points in number
   26 |     for _ in 0..n-1{
      |              ^~~~
a.cc:34:14: error: too many decimal points in number
   34 |     for _ in 0..q {
      |              ^~~~
a.cc:42:14: error: too many decimal points in number
   42 |     for i in 1..n {
      |              ^~~~
a.cc:3:1: error: 'use' does not name a type
    3 | use std::io::prelude::*;
      | ^~~
a.cc:4:1: error: 'use' does not name a type
    4 | use std::cmp::{max, min};
      | ^~~
a.cc:5:1: error: 'use' does not name a type
    5 | use std::collections::BinaryHeap;
      | ^~~
a.cc:7:10: error: found ':' in nested-name-specifier, expected '::'
    7 | const MOD: i64 = 1e9 as i64 + 7;
      |          ^
      |          ::
a.cc:7:7: error: 'MOD' does not name a type
    7 | const MOD: i64 = 1e9 as i64 + 7;
      |       ^~~
a.cc:9:1: error: 'fn' does not name a type
    9 | fn dfs(p: usize, g: &Vec<Vec<usize>>, c: &mut Vec<usize>, used: &mut Vec<bool>){
      | ^~
a.cc:20:1: error: 'fn' does not name a type
   20 | fn main(){
      | ^~
a.cc:48:1: error: 'fn' does not name a type
   48 | fn read<T>() -> T
      | ^~
Language: C++

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

int main(){
  int n,q;cin>>n>>q;
  vector<vector<int>> v(n);
  vector<int> x(n,0),ans(n,0);
  rep(i,n-1){
    int a,b;cin>>a>>b;
    v.at(b-1).push_back(a);
    rep(j,v.at(a-1).size())v.at(b-1).push_back(v.at(a-1).at(j));
  }
  rep(i,q){
    int c,d;
    cin>>c>>d;
    x.at(c-1)+=d;
  }
  rep(i,n){
    int ans=0;
    rep(j,v.at(i).size()){
      ans+=v.at(i).at(j);
      if(i)cout<<" ";
      cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:2: error: expected '}' at end of input
   25 | }
      |  ^
a.cc:19:11: note: to match this '{'
   19 |   rep(i,n){
      |           ^
a.cc:25:2: error: expected '}' at end of input
   25 | }
      |  ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

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

void dfs(int curnode, int ans[], vector<int> tr[], int parentVal) {
	ans[curnode] += parentVal;
	
	if(tr[curnode].size() == 0) return;
	
	for(int i = 0; i<tr[curnode].size(); i++) {
		dfs(tr[curnode][i], ans, tr, ans[curnode]);
	}
}

void solve() {
	int n, q;
	cin>>n>>q;
	
	vector<int> tr[n];
	
	int u, v;
	for(int i = 0; i<n-1; i++) {
		cin>>u>>v;
		u--, v--;
		tr[u].push_back(v);
	}
	
	int ans[n];
	memset(ans, 0, n*sizeof(int));
	
	while(q--) {
		cin>>u>>v;
		u--;
		ans[u] += v;
	}
	
	dfs(0, ans, tr, 0);
	
	for(int i = 0; i<n; i++) cout<<ans[i]<<" ";
	cout<<endl;
}

int main() {
	solve();
	return 0;
}

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

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

class Tree{
private:
	int id_;
	int val_;
	Tree* next_;
	vector<Tree*> next_list_;
public:
	Tree() : id_(0), val_(0), next_(NULL){}
	Tree(int id, int val) : id_(id), val_(val), next_(NULL){}
	int getId(){return id_;}
	int getValue(){return val_;}
	Tree* getNext(){return next_;}
	vector<Tree*> getNextList(){return next_list_;}
	void addNode(int id, int val){
		Tree* new_node = new Tree(id,val);
		next_list_.push_back(new_node);
	}
	void addNode(Tree* node){next_list_.push_back(node);}
	void addValue(int add_val){val_+=add_val;}
};

void addToSubTree(Tree* cur_node, int target_id, int value_to_add, bool start_to_add, unordered_map<int,bool>& visited){
	int cur_id = cur_node->getId();
	if(visited[cur_id]) return;
	visited[cur_id]=true;
	if(cur_id==target_id) start_to_add=true;
	if(start_to_add) cur_node->addValue(value_to_add);
	vector<Tree*> next_list = cur_node->getNextList();
	for(int i=0; i<next_list.size(); i++) addToSubTree(next_list[i], target_id, value_to_add, start_to_add, visited);
}

int main(){
    int n, q;
	cin >> n >> q;
	vector<Tree*> node_list;
	for(int i=0; i<=n; i++){
		Node* new_node = new Tree(i,0);
		node_list.push_back(new_node);
	}
	for(int i=1; i<=n-1; i++){
		int id_1, id_2;
		cin >> id_1 >> id_2;
		node_list[id_1]->addNode(node_list[id_2]);
		node_list[id_2]->addNode(node_list[id_1]);
	}
	unordered_map<int,bool> visited;
	for(int i=1; i<=q; i++){
		int target_id, value_to_add;
		cin >> target_id >> value_to_add;
		addToSubTree(node_list[1], target_id, value_to_add, false, visited);
	}
	for(int i=1; i<=n; i++) cout << node_list[i]->getValue() << " ";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:17: error: 'Node' was not declared in this scope
   40 |                 Node* new_node = new Tree(i,0);
      |                 ^~~~
a.cc:40:23: error: 'new_node' was not declared in this scope
   40 |                 Node* new_node = new Tree(i,0);
      |                       ^~~~~~~~
Language: C++

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

class Tree{
private:
	int id_;
	int val_;
	Tree* next_;
	vector<Tree*> next_list_;
public:
	Tree() : id_(0), val_(0), next_(NULL){}
	Tree(int id, int val) : id_(id), val_(val), next_(NULL){}
	int getId(){return id_;}
	int getValue(){return val_;}
	Tree* getNext(){return next_;}
	vector<Tree*> getNextList(){return next_list_;}
	void addNode(int id, int val){
		Tree* new_node = new Tree(id,val);
		next_list_.push_back(new_node);
	}
	void addNode(Tree* node) next_list_.push_back(node);
	void addValue(int add_val){val_+=add_val;}
};

void addToSubTree(Tree* cur_node, int target_id, int value_to_add, bool start_to_add, unordered_map<int,bool>& visited){
	int cur_id = cur_node->getId();
	if(visited[cur_id]) return;
	visited[cur_id]=true;
	if(cur_id==target_id) start_to_add=true;
	if(start_to_add) cur_node->addValue(value_to_add);
	vector<Tree*> next_list = cur_node->getNextList();
	for(int i=0; i<next_list.size(); i++) addToSubTree(next_list[i], target_id, value_to_add, start_to_add, visited);
}

int main(){
    int n, q;
	cin >> n >> q;
	vector<Tree*> node_list;
	for(int i=0; i<=n; i++){
		Node* new_node = new Tree(i,0);
		node_list.push_back(new_node);
	}
	for(int i=1; i<=n-1; i++){
		int id_1, id_2;
		cin >> id_1 >> id_2;
		node_list[id_1]->addNode(node_list[id_2]);
		node_list[id_2]->addNode(node_list[id_1]);
	}
	unordered_map<int,bool> visited;
	for(int i=1; i<=q; i++){
		int target_id, value_to_add;
		cin >> target_id >> value_to_add;
		addToSubTree(node_list[1], target_id, value_to_add, false, visited);
	}
	for(int i=1; i<=n; i++) cout << node_list[i]->getValue() << " ";
    return 0;
}

Compiler output:
a.cc:21:32: error: expected ';' at end of member declaration
   21 |         void addNode(Tree* node) next_list_.push_back(node);
      |                                ^
      |                                 ;
a.cc:21:34: error: 'next_list_' does not name a type
   21 |         void addNode(Tree* node) next_list_.push_back(node);
      |                                  ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:40:17: error: 'Node' was not declared in this scope
   40 |                 Node* new_node = new Tree(i,0);
      |                 ^~~~
a.cc:40:23: error: 'new_node' was not declared in this scope
   40 |                 Node* new_node = new Tree(i,0);
      |                       ^~~~~~~~
Language: C++

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

vector<int> to[200005];
void<int> ans[];

void dfs(int v,int p=-1){
    for(int u : to[v]{
        if(u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    })
}

int main(){
    int n,q;
    cin >> n >> q;
    rep(i,n-i){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc:7:1: error: 'void' is not a template
    7 | void<int> ans[];
      | ^~~~
a.cc:7:11: error: declaration of 'ans' as array of void
    7 | void<int> ans[];
      |           ^~~
a.cc: In function 'void dfs(int, int)':
a.cc:10:22: error: expected ')' before '{' token
   10 |     for(int u : to[v]{
      |        ~             ^
      |                      )
a.cc:12:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |         ans[u] += ans[v];
      |         ^~~
      |         abs
a.cc:14:6: error: expected primary-expression before ')' token
   14 |     })
      |      ^
a.cc: In function 'int main()':
a.cc:28:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |     ans.resize(n);
      |     ^~~
      |     abs
Language: C++

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

class Tree{
private:
	int id_;
	int val_;
	Tree* next_;
	vector<Tree*> next_list_;
public:
	Tree() : id_(0), val_(0), next_(NULL){}
	Tree(int id, int val) : id_(id), val_(val), next_(NULL){}
	int getId(){return id_;}
	int getValue(){return val_;}
	Tree* getNext(){return next_;}
	vector<Tree*> getNextList(){return next_list_;}
	void addNode(int id, int val){
		Tree* new_node = new Tree(id,val);
		next_list_.push_back(new_node);
	}
	void addValue(int add_val){val_+=add_val;}
};

Tree* goToTarget(Tree* cur, int target_id){
	if(cur->getId()==target_id) return cur;
	for(int i=0; i<next_list_.size(); i++){
		Tree* target = goToTarget(next_list_[i], target_id);
		if(target!=NULL) return target;
	}
	return NULL;
}
void addToSubTree(Tree* cur, int add_val){
	cur->addValue(add_val);
	vector<Tree*> next_list = cur->getNextList();
	for(int i=0; i<next_list.size(); i++) addToSubTree(next_list[i], add_val);
}

int main(){
    int n, q;
	cin >> n >> q;
	vector<int> a, b;
	vector<int> p, x;
	for(int i=1; i<n; i++){
		int num1, num2;
		cin >> num1 >> num2;
		a.push_back(num1);
		b.push_back(num2);
	}
	for(int i=1; i<n; i++){
		int num1, num2;
		cin >> num1 >> num2;
		a.push_back(num1);
		b.push_back(num2);
	}
	for(int i=0; i<q; i++){
		int num1, num2;
		cin >> num1 >> num2;
		p.push_back(num1);
		x.push_back(num2);
	}
	
	Tree* root = new Tree(1,0);
	for(int i=0; i<n-1; i++){
		Tree* target = goToTarget(root, a[i]);
		target->addNode(b[i],0);
	}
	for(int i=0; i<q; i++){
		Tree* target = goToTarget(root, p[i]);
		addToSubTree(target, x[i]);
	}
	for(int i=1; i<=n; i++){
		Tree* target = goToTarget(root, i);
		cout << target->getValue() << " ";
	}
		
    return 0;
}


Compiler output:
a.cc: In function 'Tree* goToTarget(Tree*, int)':
a.cc:26:24: error: 'next_list_' was not declared in this scope
   26 |         for(int i=0; i<next_list_.size(); i++){
      |                        ^~~~~~~~~~