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

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

vector< vector<int> > G(200005);
vector< int64_t > cnt(200005, 0);
vector< bool > visit(200005, false);

void BFS( int v, int64_t pval ) {
  cnt[v] = px[v] + pval;
  visit[v] = true;
  for( auto a : G[v] ) {
    if ( visit[a] ) continue;
    BFS( a, cnt[v] );
  }
}

int main() {
  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) {
    int64_t p,x;
    cin >> p >> x;
    cnt[--p] += x;
  }

  BFS(0,0);

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

}


Compiler output:
a.cc: In function 'void BFS(int, int64_t)':
a.cc:9:12: error: 'px' was not declared in this scope
    9 |   cnt[v] = px[v] + pval;
      |            ^~
a.cc:10:3: error: reference to 'visit' is ambiguous
   10 |   visit[v] = 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:6:16: note:                 'std::vector<bool> visit'
    6 | vector< bool > visit(200005, false);
      |                ^~~~~
a.cc:12:10: error: reference to 'visit' is ambiguous
   12 |     if ( visit[a] ) 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:6:16: note:                 'std::vector<bool> visit'
    6 | vector< bool > visit(200005, false);
      |                ^~~~~
Language: C++

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


int main() {
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> g(N, vector<int>(N, 0));
  vector<ll> cnt(N, 0);
  for (int i = 0; i < N - 1; ++i) {
    int ai, bi;
    cin >> ai >> bi;
    ++g[ai - 1][bi - 1];
  }
  
  for (int i = 0; i < Q; ++i) {
    ll pi, xi;
    cin >> pi >> xi;
    cnt[pi - 1] += xi;
  }
    
  for (int i = 0; i < N; ++i) {
    if (accumulate(g[i].begin(), g[i].end(), 0) == 0) {
      continue;
    }
    for (int j = i + 1; j < N; ++j) {
      if (1 <= g[i][j]) {
        cnt[j] += cnt[i];
      }
    }
  }
  
  for (int i = 0; i < N; ++i) {
    cout << cnt[i]　<< " ";
  }
}

Compiler output:
a.cc:35:19: error: extended character 　 is not valid in an identifier
   35 |     cout << cnt[i]　<< " ";
      |                   ^
a.cc: In function 'int main()':
a.cc:35:19: error: expected ';' before '\U00003000'
   35 |     cout << cnt[i]　<< " ";
      |                   ^~
      |                   ;
Language: Java

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

vector<int> to[200005];
vector<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 - 1) {
        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;
    }
    /*
    cout << "test" << endl;
    for (int u : to[0]) {
        cout << u << endl;
    }
    */
    dfs(0);
    REP(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:2: error: illegal character: '#'
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
^
Main.java:2: error: class, interface, enum, or record expected
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
                                 ^
Main.java:2: error: class, interface, enum, or record expected
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
                                       ^
Main.java:3: error: illegal character: '#'
#define REP(i,n)  FOR(i,0,n)
^
Main.java:6: error: class, interface, enum, or record expected
vector<int> to[200005];
^
Main.java:7: error: unnamed classes are a preview feature and are disabled by default.
vector<int> ans;
^
  (use --enable-preview to enable unnamed classes)
Main.java:8: error: ',', ')', or '[' expected
void dfs(int v, int p = -1) {
                     ^
Main.java:18: error: not a statement
    cin >> n >> q;
             ^
Main.java:21: error: not a statement
        cin >> a >> b;
                 ^
Main.java:29: error: not a statement
        cin >> p >> x;
                 ^
Main.java:41: error: not a statement
        cout << ans[i] << endl;
                       ^
Main.java:19: error: ';' expected
    REP(i, n - 1) {
                 ^
Main.java:27: error: ';' expected
    REP(i, q) {
             ^
Main.java:40: error: ';' expected
    REP(i, n) {
             ^
16 errors
Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/bellman_ford_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;

int main() {
	int N, Q;

	cin >> N >> Q;
    multimap<int, int> adj;
  
    REP(i, N-1) {
      int a, b;
      
      cin >> a >> b;
      adj.emplace(a, b);
      adj.emplace(b, a);
    }
  
    vector<long long> count(N+1, 0);
  
    REP(i, Q) {
      long long p, x;
      cin >> p >> x;
      
      count[p] += x;
    }
  
    auto dfs = [&](auto f, int n, int v, int p) -> void{
      visited.insert(n);
      auto it = adj.lower_bound(n), eit = adj.upper_bound(n);

      for (; it != eit; ++it) {
        if (it->second != p)
          f(f, it->second, v + count[n], n);
      }
      count[n] += v;
    };

    dfs(dfs, 1, 0, -1);
	cout << count[1];
    for (auto i : boost::irange(2, N+1))
      cout << " " << count[i];
  cout << endl;
 
	return 0;
}


Compiler output:
a.cc:12:10: fatal error: boost/range/irange.hpp: No such file or directory
   12 | #include <boost/range/irange.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
        #define ll    long long
        #define lld long double
        #define hell  998244353 
         
        using namespace std;
       
  
  ll hello(vector < vector <ll> > &v,ll x,vector <ll> &a)
  {
  	ll c=1;
  	for(ll i=0;i<v[x].size();i++)
  	{
  		c+=hello(v,v[x][i],a);
	  }
	  
	  a[x]=c;
  	return c;
	 }
	 
	hi(vector < vector <ll> > &v,ll x,vector <ll> &ans,vector <ll> &a,vector <ll> &b)
	{
		ll y=b[x]/a[x];
		ans[x]+=y;
		for(ll i=0;i<v[x].size();i++)
		{
		     ans[v[x][i]]+=ans[x];
			hi(v,v[x][i],ans,a,b);
			
		}
		
		}
		    
        int main()
        {
        	ios::sync_with_stdio(0);
        	cin.tie(0);
        	cout.tie(0);
 
 ll n,q;
 cin>>n>>q;
 vector < vector <ll>  > v(n+1);
 for(ll i=1;i<=n-1;i++)
 {
 	ll x,y;
 	cin>>x>>y;
 	v[x].push_back(y);
 }
 vector <ll> a(n+1,0);
 vector <ll> b(n+1,0);
 ll s=hello(v,1,a);
 

 while(q--)
 {
 	ll x,y;
 	cin>>x>>y;
 	b[x]+=a[x]*y;
 }

 vector <ll> ans(n+1,0);
 hi(v,1,ans,a,b);
 for(ll i=1;i<=n;i++)
 cout<<ans[i]<<" ";
 cout<<endl;
	    }
	    

Compiler output:
a.cc:21:9: error: ISO C++ forbids declaration of 'hi' with no type [-fpermissive]
   21 |         hi(vector < vector <ll> > &v,ll x,vector <ll> &ans,vector <ll> &a,vector <ll> &b)
      |         ^~
a.cc: In function 'int hi(std::vector<std::vector<long long int> >&, long long int, std::vector<long long int>&, std::vector<long long int>&, std::vector<long long int>&)':
a.cc:32:17: warning: no return statement in function returning non-void [-Wreturn-type]
   32 |                 }
      |                 ^
Language: C++

#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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;}

//vi to[200005];
vi to[200000000000000005];
vi ans;

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

int main () {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N, Q; cin >> N >> Q;
  REP(i,N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    to[a].PB(b);
    to[b].PB(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] << "\n";
  }
  
  return 0;
}

Compiler output:
/tmp/ccUG0Leo.o: in function `dfs(int, int)':
a.cc:(.text+0xe4): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccUG0Leo.o
a.cc:(.text+0xfd): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccUG0Leo.o
/tmp/ccUG0Leo.o: in function `main':
a.cc:(.text+0x259): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccUG0Leo.o
a.cc:(.text+0x2aa): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccUG0Leo.o
a.cc:(.text+0x2ee): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccUG0Leo.o
/tmp/ccUG0Leo.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x3ca): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccUG0Leo.o
a.cc:(.text+0x3e3): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccUG0Leo.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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;}

int main () {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  //vi to[200005];

  int N, Q; cin >> N >> Q;
  vvi to(N,vi());
  REP(i,N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    to[a].PB(b);
    to[b].PB(a);
  }

  vi ans(N);
  //ans.resize(N);
  REP(i,Q) {
    int p, x; cin >> p >> x;
    --p;
    ans[p] += x;
  }

  vector<bool> checked(N,false);
  queue<int> que;
  que.push(0);
  checked[0] = true;

  while (!que.empty()) {
    int node = que.front();
    que.pop();
    int point = ans[node];
    for (auto &next : to[node]) {
      if (!checked[next]) {
        ans[next] += point;
        que.push(next);
        checked[next] = true;
      }
    }
  }

  /*REP(i,N) {
    cout << ans[i] << endl;
  }*/

  for (auto &a : ans) {
    cout << ans[i] << endl;
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:85:17: error: 'i' was not declared in this scope
   85 |     cout << ans[i] << endl;
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll a[maxn];
ll ans[maxn];
int ru[maxn];
int tot=0,head[maxn],next[maxn],to[maxn];
vector<int>s[maxn];
void add(int x,int y)
{
    tot++;
    to[tot]=y;
  next[tot]=head[x];
  head[x]=tot;
}
void dfs(int x,int pre)
{
      a[x]+=a[pre];
    for(int i=head[x];i;i=next[i])
    {
        if(to[i]!=pre)
        {
            dfs(to[i],x);
        }
    }
}
int  main()
 {
     int n,q;
     scanf("%d%d",&n,&q);
     for(int i=0;i<n-1;i++)
     {
         int x,y;
         scanf("%d%d",&x,&y);
         add(x,y);
         add(y,x);
     }
     for(int i=0;i<q;i++)
     {
         int x,y;
         scanf("%d%d",&x,&y);
         a[x]+=y;
     }
     int pos=1;
     dfs(pos,0);
     for(int i=1;i<=n;i++)
        printf("%lld%c",a[i],i==n? '\n':' ');
     return 0;
 }


Compiler output:
a.cc: In function 'void add(int, int)':
a.cc:14:3: error: reference to 'next' is ambiguous
   14 |   next[tot]=head[x];
      |   ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:8:22: note:                 'int next [200010]'
    8 | int tot=0,head[maxn],next[maxn],to[maxn];
      |                      ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:20:27: error: reference to 'next' is ambiguous
   20 |     for(int i=head[x];i;i=next[i])
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:8:22: note:                 'int next [200010]'
    8 | int tot=0,head[maxn],next[maxn],to[maxn];
      |                      ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll a[maxn];
ll ans[maxn];
int ru[maxn];
vector<int>s[maxn];
void dfs(int x,int pre,ll sum)
{
    ans[x]+=sum;
    for(int i=0;i<s[x].size();i++)
    {
        if(s[x][i]!=pre)
        {
            dfs(s[x][i],x,sum+a[s[x][i]]);
        }
    }
}
int  main()
 {
     int n,q;
     scanf("%d%d",&n,&q);
     for(int i=0;i<n-1;i++)
     {
         int x,y;
         scanf("%d%d",&x,&y);
         s[x].push_back(y);
         s[y].push_back(y);
         ru[y]++;
         r[x]++;
     }
     for(int i=0;i<q;i++)
     {
         int x,y;
         scanf("%d%d",&x,&y);
         a[x]+=y;
     }
     int pos=1;
     for(int i=1;i<=n;i++)
     {
          if(ru[i]==1)
            pos=i;
     }
     dfs(pos,-1,a[pos]);
     for(int i=1;i<=n;i++)
        printf("%lld%c",ans[i],i==n? '\n':' ');
     return 0;
 }


Compiler output:
a.cc: In function 'int main()':
a.cc:31:10: error: 'r' was not declared in this scope
   31 |          r[x]++;
      |          ^
Language: C++

from collections import deque
import sys
input = sys.stdin.readline

def solve():
  n,q = (int(i) for i in input().split())
  graph = [[] for _ in range(n)]

  for i in range(n-1):
    a,b = (int(i) for i in input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
  ans = [0]*n
  
  for i in range(q):
    p,x = (int(i) for i in input().split())
    ans[p-1] += x

  query = deque([(0,-1)])
  while query:
    nowplace,parent = query.popleft()
    nowvalue = ans[nowplace]   
    for node in graph[nowplace]:
      if node == parent:
        continue
      else:
        ans[node] += nowvalue
        query.append([node,nowplace])
      
  print(*ans)
  
solve()

Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
Language: Java

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main4 {

    public static boolean debug = true;

    public static class Node {
    	Node parent = null;
    	List<Node> children = new LinkedList<Node>();
    	boolean visited = false;
    	long v = 0;

    	public boolean hasParent() {
    		return !(parent == null);
    	}

    	public void setParent(Node p) {
    		this.parent = p;
    	}

    	public void addChild(Node n) {
    		this.children.add(n);
    		n.setParent(this);
    	}

    	public void addValue(long v) {
    		this.v += v;
    	}

    	public long getValue() {
    		return this.v;
    	}

    	public void calc(long parentValue) {
    		if (visited) {
    			return;

    		} else {
	    		this.v += parentValue;

	    		for(Node child : children) {
	    			child.calc(this.v);
	    		}

	    		visited = true;
    		}
    	}

    }
	static String input = "4 3\r\n" +
			"1 4\r\n" +
			"1 3\r\n" +
			"2 3\r\n" +
			"2 10\r\n" +
			"1 100\r\n" +
			"3 1";
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
//    	Scanner sc = new Scanner(new ByteArrayInputStream(input.getBytes("utf-8")));

       	int n = sc.nextInt();
        int q = sc.nextInt();

        // Node番号から直接Nodeを取れるインデックスを生成しとく
        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 p = sc.nextInt();
            int c = sc.nextInt();

            Node n1 = nodes[p - 1];
            Node n2 = nodes[c - 1];

            if (n1.hasParent()) {
            	 if (n2.hasParent()) {
            		 // 取り合えず左辺を親にしてみる（）
            		 n1.addChild(n2);
//            		 throw new RuntimeException("両方親もってるとかエラー");
            	 } else {
            		 n1.addChild(n2);
            	 }
            } else {
            	if (n2.hasParent()){
            		n2.addChild(n1);
            	} else {
            		// どっちも親持ってなかったら取り合えず左側を親とするにゃ
            		n1.addChild(n2);
            	}
            }
        }

        // 一旦全ての操作の値を各Nodeに保存（子に対する計算はしない）
        for(int i = 0; i < q; i++){
            int key = sc.nextInt();
            long value = sc.nextLong();

            nodes[key - 1].addValue(value);
        }

        // グラフをたどって部分木の値を計算
        nodes[0].calc(0);

        StringBuilder sb = new StringBuilder();

        // 出力してみる
        for(Node node : nodes){
            sb.append(node.getValue());
            sb.append(' ');
        }

        System.out.println(sb.toString());
    }

    public static void d(String message){
        if(debug){
            System.out.println(message);
        }
    }
}

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

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

const int MAXN = 1e5 + 5;

vector<int> edges[MAXN];
long long a[MAXN], add[MAXN];
bool vis[MAXN];

void dfs(int u, ll qtt) {
	vis[u] = true;
  	a[u] = add[u] + qtt;
  	
  	for (int v : edges[u]) {
     	if (!vis[v]) dfs(v, qtt + add[u]); 
    }
}

int main() {
 	ios::sync_with_stdio(false); cin.tie(NULL);
  
  	int n, q; cin >> n >> q;
  
  	for (int i = 1; i <= n-1; i++) {
     	int u, v;  cin >> u >> v;
      	edges[u].push_back(v);
      	edges[v].push_back(u);
    }
  
  	while(q--) {
     	int u, x; cin >> u >> x;
      	add[u] += x;
    }
  	
  	dfs(1, 0);
  	for (int i = 1; i <= n; i++) cout << a[i] << ' ';
  	cout << endl;
  
  
}

Compiler output:
a.cc:10:17: error: 'll' has not been declared
   10 | void dfs(int u, ll qtt) {
      |                 ^~
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<int> v[200010];
ll ans[200010];
int sum[200010];
int n,q;
bool seen[200020];

void dfs(int now,int from){
  seen[now]=true;
  if(from>=0)ans[now]=ans[from];
  ans[now]+=sum[now];
  rep(i,v[now].size()){
    if(!seen[v[now][i]])dfs(v[now][i],now);
  }
}



int main(){
  cin >> n >> q;
  rep(i,n-1){
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  rep(i,q){
    int x,y;
    cin >> x >> y;
    x--;
    sum[x]+=y;
  }
  dfs(0,-1);
  rep(i,n)cout << ans[i] << ' ';
  cout << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:60:16: error: expected '}' at end of input
   60 |   cout << endl;
      |                ^
a.cc:43:11: note: to match this '{'
   43 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

typedef boost::multiprecision::cpp_int 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 int e5 = (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 ------------- */
/* ---------------------------------- */
vector<ll> G[2 * e5];
vector<ll> ans(2 * e5);
unordered_map<int, ll> pl;
vector<bool> seen(2 * e5);

void dfs(int now, ll value) {
    seen[now] = true;
    ans[now] = value;
    each(e, G[now]) {
        if (!seen[int(e)]) {
            dfs(int(e), value + pl[int(e)]);
        }
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n, q;
        cin >> n >> q;
        rep(i, n - 1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].eb(b);
            G[b].eb(a);
        }

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

        rep(i, n) cout << ans[int(i)] << " ";

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Compiler output:
a.cc:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

typedef boost::multiprecision::cpp_int 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 int e5 = (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 ------------- */
/* ---------------------------------- */
vector<ll> G[2 * e5];
vector<ll> ans(2 * e5);
unordered_map<ll, ll> pl;
vector<bool> seen(2 * e5);

void dfs(int now, ll value) {
    seen[now] = true;
    ans[now] = value;
    each(e, G[now]) {
        if (!seen[int(e)]) {
            dfs(int(e), value + pl[e]);
        }
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n, q;
        cin >> n >> q;
        rep(i, n - 1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].eb(b);
            G[b].eb(a);
        }

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

        rep(i, n) cout << ans[int(i)] << " ";

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Compiler output:
a.cc:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define HpOut(S) cout << setprecision(20) << S << endl;
#define print(x) cout << (x) << endl;
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

// 入力
ll N;
 
// res は答え
vector<ll> ans;
vector<vector<ll>> G(N);

void dfs(ll v, ll p=-1) {
    for (auto e : G[v]) {
        if (e == p) continue;
        ans[e] += ans[v];
        dfs(e, v);
    }
}

int main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N,Q;
    cin >> N >> Q;
    G.assign(N, vector<ll>());
    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);
    }
    ans.assign(N, 0);
    for (int q = 0; q < Q; ++q) {
        int p, x; cin >> p >> x; --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i,N) cout << res[i] << " ";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:22: error: 'res' was not declared in this scope; did you mean 'rep'?
   60 |     rep(i,N) cout << res[i] << " ";
      |                      ^~~
      |                      rep
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int n,q,a,b,x,y;
vector<vector<int>> d(200010);
vector<int> t(200010,0),v(200010);
map<pair<int,int>,bool> m
int c=0;
void dfs(int p){
  c+=t[p];
  v[p]=c;
  for(auto au:d[p]){
    if(!m[pair<int,int>(min(au,p),max(au,p))]){
      m[pair<int,int>(min(au,p),max(au,p))]=true;
      dfs(au);
    }
  }
  c-=t[p];
}
int main(){
  cin>>n>>q;
  for(int i=0;i<n-1;i++){
    cin>>a>>b;
    d[a].push_back(b);
    d[b].push_back(a);
  }
  for(int i=0;i<q;i++){
    cin>>x>>y;
    t[x]+=y;
  }
  dfs(1);
  for(int i=1;i<=n;i++){
    cout<<v[i]<<" ";
  }
}


Compiler output:
a.cc:10:1: error: expected initializer before 'int'
   10 | int c=0;
      | ^~~
a.cc: In function 'void dfs(int)':
a.cc:12:3: error: 'c' was not declared in this scope
   12 |   c+=t[p];
      |   ^
a.cc:15:9: error: 'm' was not declared in this scope
   15 |     if(!m[pair<int,int>(min(au,p),max(au,p))]){
      |         ^
Language: C++

// AtCoderCPP.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
map<int, vector<int>> dix;
void get(int, int, int*);
int main()
{
	string NStr, QStr;
	cin >> NStr >> QStr;
	int n = stoi(NStr);
	int q = stoi(QStr);
	for (int i = 0; i < n - 1; i++) {
		string astr, bstr;
		cin >> astr >> bstr;
		int a = stoi(astr);
		int b = stoi(bstr);
		dix[a].push_back(b);
	}
	int* co = new int[n] {0};
	for (int i = 0; i < q; i++)
	{
		string pstr, xstr;
		cin >> pstr >> xstr;
		int p = stoi(pstr);
		int x = stoi(xstr);
		get(p, x, co);
		co[p - 1] += x;
	}
	for (int i = 0; i < n; i++) {
		cout << co[i] << " ";
	}

}

void get(int p, int x, int *c) {
	if (dix[p].size() == 0) { return; }
	else {
		for each (int n in dix[p])
		{
			c[n - 1] += x;
			get(n, x, c);
		}
	}
}

Compiler output:
a.cc: In function 'void get(int, int, int*)':
a.cc:43:21: error: expected '(' before 'each'
   43 |                 for each (int n in dix[p])
      |                     ^~~~
      |                     (
a.cc:43:27: error: expected primary-expression before 'int'
   43 |                 for each (int n in dix[p])
      |                           ^~~
a.cc:43:21: error: 'each' was not declared in this scope
   43 |                 for each (int n in dix[p])
      |                     ^~~~
a.cc:48:9: error: expected primary-expression before '}' token
   48 |         }
      |         ^
a.cc:47:18: error: expected ';' before '}' token
   47 |                 }
      |                  ^
      |                  ;
   48 |         }
      |         ~         
a.cc:48:9: error: expected primary-expression before '}' token
   48 |         }
      |         ^
a.cc:47:18: error: expected ')' before '}' token
   47 |                 }
      |                  ^
      |                  )
   48 |         }
      |         ~         
a.cc:43:21: note: to match this '('
   43 |                 for each (int n in dix[p])
      |                     ^~~~
a.cc:48:9: error: expected primary-expression before '}' token
   48 |         }
      |         ^
Language: C++

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

typedef long long LL;
const int SIZE = 100005;

void dfs( int pos, LL sum );

vector< int > tree[SIZE];
LL node_sum[SIZE];
LL res;

int main() {
  int n, q;
  cin >> n >> q;
  
  for( int i = 0; i < n; ++i ) {
    int a, b;
    cin >> a >> b;
    tree[a].push_back( b );
    
  }
  
  for( int i = 0; i < q; ++i ) {
    LL add;
    int pos;
    cin >> pos >> add;
    node_sum[pos] += sum;
    
  }
  
  dfs( 1, 0 );
  cout << res << endl;
  
  return 0;
}

void dfs( int pos, LL sum ) {
  sum += node_sum[pos];
  
  for( int i = 0; i < tree[pos].size(); ++i ) {
    dfs( tree[pos][i], sum );
    
  }
  
  node_sum[pos] = sum;
  return;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:22: error: 'sum' was not declared in this scope
   28 |     node_sum[pos] += sum;
      |                      ^~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define lli long long int
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,q,i,j;
	cin>>n>>q;
	vector<vector<int> > adj;
	adj.resize(n);
	lli a,b;
	for(i=0;i<n-1;i++)
	{
		cin>>a>>b;
		adj[a-1].push_back(b-1);
		adj[b-1].push_back(a-1);
	}
	vector<lli> val;
	val.resize(n);
	for(i=0;i<q;i++)
	{
		cin>>a>>b;
		val[a-1] += b; 
	}
	vector<int> par;
	for(i=0;i<n;i++)
		par[i] = -1;
	par[0] = 0;
	queue<int> q;
	q.push(0);
	while(!q.empty())
	{
		int x = q.front();
		q.pop();
		for(i=0;i<adj[x].size();i++)
		{
			int y = adj[x][i];
			if(par[y]==-1)
			{
				par[y] = x;
				val[y] += val[x];
				q.push(y);
			}
		}
	}
	for(i=0;i<n;i++)
		cout<<val[i]<<" ";
	cout<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:20: error: conflicting declaration 'std::queue<int> q'
   32 |         queue<int> q;
      |                    ^
a.cc:10:15: note: previous declaration as 'int q'
   10 |         int n,q,i,j;
      |               ^
a.cc:33:11: error: request for member 'push' in 'q', which is of non-class type 'int'
   33 |         q.push(0);
      |           ^~~~
a.cc:34:18: error: request for member 'empty' in 'q', which is of non-class type 'int'
   34 |         while(!q.empty())
      |                  ^~~~~
a.cc:36:27: error: request for member 'front' in 'q', which is of non-class type 'int'
   36 |                 int x = q.front();
      |                           ^~~~~
a.cc:37:19: error: request for member 'pop' in 'q', which is of non-class type 'int'
   37 |                 q.pop();
      |                   ^~~
a.cc:45:35: error: request for member 'push' in 'q', which is of non-class type 'int'
   45 |                                 q.push(y);
      |                                   ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> e;
vector<int> v;

void dfs(int x, int r = -1, int s = 0) {
  v[x] += s;
  for (auto& a: e[x]) {
    if (a == r) continue;
    dfs(a, x, v[x]);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  v.resize(n, 0);
  e.resize(n);
  
  for (int i = 0; i < n-1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    v[a] += b;
  }
  dfs(0);
  for (auto& a: v) {
    cout << a << endl;
  }
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:27:10: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   27 |     v[a].push_back(b);
      |          ^~~~~~~~~
a.cc:28:10: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   28 |     v[b].push_back(a);
      |          ^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
struct node{
	int date;
	int shang;
};
node a[200000+5];
int main(){
	int n,q;
	cin>>n>>q;
	a[1].shang=0;
	for(int i=1;i<=n-1;i++){
		int x,y;
		cin>>x>>y;
		a[i].date=0;
		a[y].shang=x;
	}
	for(int i=1;i<=q;i++){
		int x,y;
		cin>>x>>y;
		a[x].date=a[x].date+y;
	}
	for(int i=2;i<=n;i++){
		a[i].date=a[i].date+a[a[i].shang].date;	
	}
	for(int i=1;i<=n;i++)
		cout<<a[i].date; if(i!=n) cout<<" ";
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:27:37: error: 'i' was not declared in this scope
   27 |                 cout<<a[i].date; if(i!=n) cout<<" ";
      |                                     ^
Language: C++

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

int n, q;
vector<int> nodes;
vector<vector<int>> edges;

void dfs(int root, vector<int>& ans, vector<int>& vi, int extra) {
 	vi[root] = 1;
	ans[root] += (nodes[root] + extra);
  	vector<int>& es = edges[root];
  	for (int e : es) {
    	if (vi[e] == 0) {
         	dfs(e, ans, vi, extra + nodes[root]); 
        }
    }
}

int main() {
 	cin >> n >> q;
  	nodes.resize(n + 1, 0);
  	edges.resize(n + 1, vector<int>());
  	for (int i = 1; i < n; i++) {
    	int x, y;
    	cin >> x >> y;
      	edges[x].push_back(y);
      	edges[y].push_back(x);
    }
  	for (int i = 1; i <= q; i++) {
     	int x, y;
      	cin >> x >> y;
      	nodes[x] += y;
    }
  	vector<int> vi(n + 1, 0);
  	vector<int> ans(n + 1, 0);
    dfs(1, ans, vi, 0);
  	for (int i = 1; i <= b; i++) cout << ans[i] << " ";
  	cout << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:30: error: 'b' was not declared in this scope
   39 |         for (int i = 1; i <= b; i++) cout << ans[i] << " ";
      |                              ^
Language: Java

import java.util.*;
import java.lang.*;

public class Main{
	static Tree tree;
	static boolean[] visited;
	public static void main(String[] args) {
		int n = nextInt();
		int q = nextInt();
		tree = new Tree(n);
		for (int i = 0; i < n - 1; i++) {
			tree.union(nextInt() - 1, nextInt() - 1);
		}
		for (int i = 0; i < q; i++) {
			tree.node[nextInt() - 1].value += nextInt();
		}
		visited = new boolean[n];
		visited[0] = true;
		dfs(0);
		for (int i = 0; i < n - 1; i++) {
			System.out.print(tree.node[i].value + " ");
		}
		System.out.println(tree.node[n - 1].value);
	}
	static void dfs(int n) {
		visited[n] = true;
		for (int key : tree.node[n].list) {
			if (!visited[key]) {
				visited[key] = true;
				tree.node[key].value += tree.node[n].value;
				dfs(key);
			}
		}
	}
  
    static int nextInt() {
        int c;
        try {
            c = System.in.read();
            while(c != '-' && (c < '0' || c > '9')) c = System.in.read();
            if(c == '-') return -nextInt();
            int res = 0;
            while(c >= '0' && c <= '9') {
                res = res * 10 + c - '0';
                c = System.in.read();
            }
            return res;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return -1;
    }
}

class Node {
	ArrayList<Integer> list;
	int value;
	Node() {
		list = new ArrayList<>();
		value = 0;
	}
}

class Tree {
	Node[] node;
	Tree(int n) {
		node = new Node[n];
		for (int i = 0; i < n; i++) {
			node[i] = new Node();
		}
	}
	void union(int n, int m) {
		node[n].list.add(m);
		node[m].list.add(n);
	}
}


Compiler output:
Main.java:48: error: cannot find symbol
        } catch (IOException e) {
                 ^
  symbol:   class IOException
  location: class Main
1 error
Language: C++

import sys
sys.setrecursionlimit(1000000000)
 
n,q=input().split()
n=int(n)
q=int(q)
l=[[] for i in range(n)]
def count(p,x,l,counter):
    counter[p-1]+=x
    for i in l[p-1]:
        counter[i-1]+=x
        if l[i-1]:
            count2(i,x,l,counter)
def count2(p,x,l,counter):
    for i in l[p-1]:
        counter[i-1]+=x
        if l[i-1]:
            count2(i,x,l,counter)
for i in range(n-1):
    a,b=input().split()
    a=int(a)
    b=int(b)
    l[a-1].append(b)
counter=[0 for i in range(n)]
lis=[0 for i in  range(n)]
for i in range(q):
    p,x=input().split()
    p=int(p)
    x=int(x)
    lis[p-1]+=x
of=0
for i in lis:
    of+=1
    count(of,i,l,counter)
for i in counter:
    print(i,end=" ")
print()


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>
 
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
 
using namespace std;
using ll = long long;
 
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, Q; cin >> N >> Q;
  vector<vector<int>> G(N);
  rep(i, N-1) {
    int a, b; cin >> a >> b; a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<ll> val(N);
  rep(i, Q) {
    int p, x; cin >> p >> x; p--;
    val[p] += x;
  }
  auto dfs = [&](auto dfs, int u, int p) -> void {
    for (int v : G[u]) if (v != p) {
      val[v] += val[u];
      dfs(dfs, v, u);
    }
  };
  dfs(dfs, 0, -1);
  rep(i, N) cout << val[i] << (i == N - 1 ? '\n' : ' ');


Compiler output:
a.cc: In function 'int main()':
a.cc:30:57: error: expected '}' at end of input
   30 |   rep(i, N) cout << val[i] << (i == N - 1 ? '\n' : ' ');
      |                                                         ^
a.cc:9:12: note: to match this '{'
    9 | int main() {
      |            ^
Language: C++

    #include <bits/stdc++.h>
    using namespace std;
    int main(){
    int n,q,a,b,p,x;
    cin>>n>>q;
    vector<int> g[n+1];
    for(int i=0;i<n-1;i++){
    cin>>a>>b;
    g[a].push_back(b);
    }
    vector<int> inc(n+1,0);
    while(q--){
        cin>>p>>x;
        inc[p]+=x;
    }
    queue<int> qq;

    for(int i=0;i<g.size();i++){
        if(g[i].size()>0){
            qq.push(i);
            break;
        }
    }

    // qq.push(1);
    while(!qq.empty()){
        int t=qq.front();
        qq.pop();
        for(int i=0;i<g[t].size();i++){
            int u=g[t][i];
            qq.push(u);
        }
        if(inc[t]==0){
            continue;
        }
        int ct=inc[t];
        for(int i=0;i<g[t].size();i++){
            int u=g[t][i];
            inc[u]+=ct;
        }
    }
    for(int i=1;i<=n;i++){
        cout<<inc[i]<<" ";
    }
    cout<<endl;
    return 0;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:18:21: error: request for member 'size' in 'g', which is of non-class type 'std::vector<int> [(n + 1)]'
   18 |     for(int i=0;i<g.size();i++){
      |                     ^~~~
Language: Java

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main4 {

    public static boolean debug = true;

    public static class Node {
    	List<Node> children = new LinkedList<Node>();
    	long v = 0;

    	public void addChild(Node n) {
    		this.children.add(n);
    	}

    	public void addValue(long v) {
    		this.v += v;
    	}

    	public long getValue() {
    		return this.v;
    	}

    	public void calc(long parentValue) {
    		this.v += parentValue;

    		for(Node child : children) {
    			child.calc(this.v);
    		}
    	}

    }
	static String input = "4 3\r\n" +
			"1 2\r\n" +
			"2 3\r\n" +
			"2 4\r\n" +
			"2 10\r\n" +
			"1 100\r\n" +
			"3 1";
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
//    	Scanner sc = new Scanner(new ByteArrayInputStream(input.getBytes("utf-8")));

       	int n = sc.nextInt();
        int q = sc.nextInt();

        // Node番号から直接Nodeを取れるインデックスを生成しとく
        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 p = sc.nextInt();
            int c = sc.nextInt();

            if (p > c) {
            	int t = c;
            	c = p;
            	p = t;
            }

            nodes[p - 1].addChild(nodes[c - 1]);
        }

        // 一旦全ての操作の値を各Nodeに保存（子に対する計算はしない）
        for(int i = 0; i < q; i++){
            int key = sc.nextInt();
            long value = sc.nextLong();

            nodes[key - 1].addValue(value);
        }

        // グラフをたどって部分木の値を計算
        nodes[0].calc(0);

        // 出力してみる
        for(Node node : nodes){
            System.out.print(node.getValue() + " ");
        }
    }

    public static void d(String message){
        if(debug){
            System.out.println(message);
        }
    }
}

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

import java.util.*;

public class Main {
    int[] ans;
    List<Integer>[] tree;

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int q = sc.nextInt();

        ans = new int[n];
        tree = new List[n];
        for (int i = 0; i < n; i++) {
            tree[i] = new ArrayList<>();
        }

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

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

        dfs(0);
//        debug(ans);

        PrintWriter out = new PrintWriter(System.out);
        out.print(ans[0]);
        for (int i = 1; i < n; i++) {
            out.print(" ");
            out.print(ans[i]);
        }
        out.println();
        out.flush();
        // write your code
//        System.out.println(ans);
    }

    void dfs(int parent) {
        List<Integer> nextNodes = tree[parent];
        for (int nodeIdx : nextNodes) {
            ans[nodeIdx] += ans[parent];
            dfs(nodeIdx);
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Compiler output:
Main.java:34: error: cannot find symbol
        PrintWriter out = new PrintWriter(System.out);
        ^
  symbol:   class PrintWriter
  location: class Main
Main.java:34: error: cannot find symbol
        PrintWriter out = new PrintWriter(System.out);
                              ^
  symbol:   class PrintWriter
  location: class Main
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,q;
vector<vector<int>> a(200005,vector<int>(0));
int score[200005],p[200005];
int solve(int l){
    if(l==0)return p[0];
    int ans = 0;
    int y;
    
    for(int i=0;i<a.at(l).size();i++){
        y=a.at(l).at(i);
        ans+=solve(y);
    }
    
    return ans + p[l];
}

int main(){
    cin>>n>>q;
    int j,k;
    for(int i=0;i<n-1;i++){
        cin>>j>>k;
        a.at(k-1).push_back(j-1);
        a.at(j-1).push_back(k-1);
    }
    
    for(int i=0;i<q;i++){
        cin>>j>>k;
        p[j-1]+=k;
    }
    
    for(int i=0;i<n;i++){
        int t = solve(i);
        cout << t <<" ";
    }
    cout <<endl;
}
cin.tie(nullptr);
ios::sync_with_stdio(false);

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