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

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

struct Node {
    int parent;
    vector<int> child;
    int value;
}

int main(){
    int n, q, a, b, p, x;
    cin >> n >> q;
    Node node[n];
    for(int i = 0; i < n; i++){
        node[i].value = 0;
    }
    for(int i = 1; i < n; i++){
        cin >> a >> b;
        node[a-1].child.push_back(b-1);
    }
    for(int i = 0; i < q; i++){
        cin >> p >> x;
        queue<int> tmp;
        tmp.push(p-1);
        while(!tmp.empty()){
            int r = tmp.front();
            node[r].value += x;
            tmp.pop();
            if(!node[r].child.empty()) {
                for(int j = 0; j < node[r].child.size(); j++)tmp.push(node[r].child[j]);
            }
        }
    }
    for(int i = 0; i < n; i++){
        cout << i + 1 << " " << node[i].value << endl;
    }
    return 0;
}

Compiler output:
a.cc:8:2: error: expected ';' after struct definition
    8 | }
      |  ^
      |  ;
Language: C++

N,Q = map(int,input().split())

for i in range (N-1):
  a,b = map(int,input().split())
  flag = 0
  for j1, j2 in l:
    if (j1 == a) :
      flag = 1
      j2.append(b)
      '''
      j3 = j2
      print(j3)
      j3 = j3.append(b)
      l.append((j1,j3))
      '''
  if flag == 0:
    l.append((a,[b]))


ans = [0 for i in range(500000)]

for i in range(Q-1):
  p,q = map(int,input().split())
  flag = 0
  search = [p]
  while(flag != 1):
    for j1,j2 in l:
      if j1 == p:
        tmp = copy.copy(search)
        search = search + list(set(j2)-set(search))
        if(tmp == search) :
          flag = 1
  for k in search:
    ans[k] = ans[k] + q

for i in range(N+1):
  if i != 0:
    print (ans[i])

Compiler output:
a.cc:10:7: error: empty character constant
   10 |       '''
      |       ^~
a.cc:10:9: warning: missing terminating ' character
   10 |       '''
      |         ^
a.cc:10:9: error: missing terminating ' character
a.cc:15:7: error: empty character constant
   15 |       '''
      |       ^~
a.cc:15:9: warning: missing terminating ' character
   15 |       '''
      |         ^
a.cc:15:9: error: missing terminating ' character
a.cc:1:1: error: 'N' does not name a type
    1 | N,Q = map(int,input().split())
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Q,a,b;
  double sum;
  cin >> N>> Q;
  vector<vector<int>> vec(N, vector<int>());
  
  for(int i=0;i<N-1;i++){
    cin >>a>>b;    
    vec.at(a).push_buck(b);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'class std::vector<int>'} has no member named 'push_buck'; did you mean 'push_back'?
   12 |     vec.at(a).push_buck(b);
      |               ^~~~~~~~~
      |               push_back
Language: C++

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

int main() {
  int n,q;
  cin >> n >> q;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n, 0);
  vector<int> p(q);
  vector<int> x(q);
  rep(i,n) {
    cin >> a(i) >> b(i);
  }
  
  rep(i, q) {
    cin >> p(i) >>x(i);
  }
  int count = 0;
  rep(j, q) {
    rep(k, n) {
      if (p.at(j) == a.at(k)){
        c.at(b.at(k)) += x.at(j);
        count++;
        if (count == 1){
          c.at(a.at(k)) += x.at(j);
        }
      }
    }
  }
  rep(i,n) {
    cout << c(i) << " ";
  }
  endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: no match for call to '(std::vector<int>) (int&)'
   17 |     cin >> a(i) >> b(i);
      |            ~^~~
a.cc:17:21: error: no match for call to '(std::vector<int>) (int&)'
   17 |     cin >> a(i) >> b(i);
      |                    ~^~~
a.cc:21:13: error: no match for call to '(std::vector<int>) (int&)'
   21 |     cin >> p(i) >>x(i);
      |            ~^~~
a.cc:21:20: error: no match for call to '(std::vector<int>) (int&)'
   21 |     cin >> p(i) >>x(i);
      |                   ~^~~
a.cc:36:14: error: no match for call to '(std::vector<int>) (int&)'
   36 |     cout << c(i) << " ";
      |             ~^~~
a.cc:38:7: error: statement cannot resolve address of overloaded function
   38 |   endl;
      |       ^
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <iomanip>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
#define MOD 1000000007
using namespace std;
 
int main(){
  int N, Q;
  cin >> N >> Q;
  int a[N-1], b[N-1], p[Q], x[Q], bubs[N], bub[N][N];
  long long c[N] = {};
  REP(i,N-1){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    bub[a[i]][bubs[a[i]]] = b[i];
    bubs[a[i]]++;
  }
  REP(i,Q){
    cin >> p[i] >> x[i];
    p[i]--;
  }
  REP(j,Q){
    int i = bubs[p[j]];
    REP(k,i)
      c[bub[i][k]] += bubs[i] * x[i];
    }
  }
  REP(i,N-1){
    cout << c[i] << " ";
  }
  cout << c[N-1] << endl;
}
  
  
  
  

Compiler output:
a.cc:9:19: error: expected unqualified-id before 'for'
    9 | #define REP(i, n) for(int i = 0; (i) < (n); (i)++)
      |                   ^~~
a.cc:35:3: note: in expansion of macro 'REP'
   35 |   REP(i,N-1){
      |   ^~~
a.cc:9:38: error: expected constructor, destructor, or type conversion before '<' token
    9 | #define REP(i, n) for(int i = 0; (i) < (n); (i)++)
      |                                      ^
a.cc:35:3: note: in expansion of macro 'REP'
   35 |   REP(i,N-1){
      |   ^~~
a.cc:9:48: error: expected constructor, destructor, or type conversion before '++' token
    9 | #define REP(i, n) for(int i = 0; (i) < (n); (i)++)
      |                                                ^~
a.cc:35:3: note: in expansion of macro 'REP'
   35 |   REP(i,N-1){
      |   ^~~
a.cc:38:3: error: 'cout' does not name a type
   38 |   cout << c[N-1] << endl;
      |   ^~~~
a.cc:39:1: error: expected declaration before '}' token
   39 | }
      | ^
Language: C++

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

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first) {
        return a.first < a.first;
    }else
    {
        return a.second < a.second;
    }
}

int main(){

    int N, Q;
    scanf("%d %d", &N, &Q);
    
    int parent[N] = {};
    int a, b;
    for (int i = 0; i < N - 1;i++) {
        scanf("%d %d", &a, &b);
        parent[b-1] = a-1;
    }
    
    int counter[N] = {};
    int p, x;
    rep(i, Q) {
        scanf("%d %d", &p, &x);
        counter[p-1] += x;
    }

    // int n, ret;
    // for (int i = 0; i < N ; i++) {
        // n = i; //node
        // ret = counter[0];
        // while(n != 0) {
        //     ret += counter[n];
        //     n = parent[n];
        // }
        // printf("%d ", ret);
    // }
    vector<pair<int, int> > input(Q);
    int x, p;
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &p, &x);
        input[i] = make_pair(p, x);
    }
    sort(input.begin(), input.end(), compare);

    int ret;
    for (int i = 0; i<N; i++){
        ret = input[0].second;

        ret += input[i].second + input[ parent[i] ].second;
        printf("%d ", ret);
    }
        
         return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:9: error: redeclaration of 'int x'
   45 |     int x, p;
      |         ^
a.cc:28:12: note: 'int x' previously declared here
   28 |     int p, x;
      |            ^
a.cc:45:12: error: redeclaration of 'int p'
   45 |     int x, p;
      |            ^
a.cc:28:9: note: 'int p' previously declared here
   28 |     int p, x;
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)

//-----------------------------------------------
// 深さ優先探索
vector<bool> seen;
vector<int> ans;
void dfs(const vector<vector<int>> &g,int v,int k) {
  
    seen[v] = true; // v を訪問済にする
    ans[v] += k;//countor
    // v から行ける各頂点 next_v について
    for (auto next_v : g[v]) {
      if(k==0) break;
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(g, next_v,k); // 再帰的に探索
    }
}
//------------------------------------------------
int main(){
  int n,q;
  cin>>n>>q;
  vector<vector<int>> g(n);
  rep(i,0,n-1){
    int a,b;
    cin>>a>>b;
    g.at(a-1).push_back(b-1);
    //g.at(b-1).push_back(a-1);
  }
  int p[n];
  int x[n];
  int h,r
  rep(i,0,q){

    cin>>h>>r;
    p[h-1]+=r;
    //dfs(g,p-1,x);
  }
  ans.assign(n, 0);
  rep(i,0,n){
    seen.assign(n, false);
    dfs(g,i,p[h-1]);
  }
rep(i,0,n) cout<<ans[i]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:20: error: expected initializer before 'for'
    4 | #define rep(i,a,b) for(ll i=a;i<b;i++)
      |                    ^~~
a.cc:36:3: note: in expansion of macro 'rep'
   36 |   rep(i,0,q){
      |   ^~~
a.cc:36:7: error: 'i' was not declared in this scope
   36 |   rep(i,0,q){
      |       ^
a.cc:4:31: note: in definition of macro 'rep'
    4 | #define rep(i,a,b) for(ll i=a;i<b;i++)
      |                               ^
Language: C++

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

struct Node {
    int parent;
    vector<int> child;
    int value;
}

int main(){
    int n, q, a, b, p, x;
    cin >> n >> q;
    Node node[n];
    for(int i = 0; i < n; i++){
        node[i].value = 0;
    }
    for(int i = 1; i < n; i++){
        cin >> a >> b;
        node[a-1].child.push_back(b-1);
    }
    for(int i = 0; i < q; i++){
        cin >> p >> x;
        queue<int> tmp;
        tmp.push_back(p-1);
        while(!tmp.empty()){
            int r = tmp.top();
            node[r].value += x;
            tmp.pop();
            if(!node[r].child.empty()) {
                for(int j = 0; j < node[r].child.size(); j++)tmp.push_back(node[r].child[j]);
            }
        }
    }
    for(int i = 0; i < n; i++){
        cout << i + 1 << " " << node[i].value << endl;
    }
    return 0;
}

Compiler output:
a.cc:8:2: error: expected ';' after struct definition
    8 | }
      |  ^
      |  ;
a.cc: In function 'int main()':
a.cc:24:13: error: 'class std::queue<int>' has no member named 'push_back'
   24 |         tmp.push_back(p-1);
      |             ^~~~~~~~~
a.cc:26:25: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   26 |             int r = tmp.top();
      |                         ^~~
      |                         pop
a.cc:30:66: error: 'class std::queue<int>' has no member named 'push_back'
   30 |                 for(int j = 0; j < node[r].child.size(); j++)tmp.push_back(node[r].child[j]);
      |                                                                  ^~~~~~~~~
Language: Java

import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int Q = scanner.nextInt();
        Map<Integer, List<Integer>> adja = new HashMap<>();
        Set<Integer> tree = new HashSet<>();
        for(int i=1; i<=N; i++){
            adja.put(i, new ArrayList<>());
            tree.add(i);
        }
        for(int i=0; i<N-1; i++){
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            adja.get(a).add(b);
            tree.remove(b);
        }
        int root = (int)tree.toArray()[0];
        Map<Integer, Integer> oper = new HashMap<>();
        for(Integer node:adja.keySet()){
            oper.put(node, 0);
        }
        for(int i=0; i<Q; i++){
            int p = scanner.nextInt();
            int x = scanner.nextInt();
            oper.put(p, oper.get(p) + x);
        }

        LinkedList<Integer> nodes = new LinkedList<>();
        nodes.add(root);
        while(nodes.size()>0){
            int node = nodes.poll();
            for(Integer nextnode: adja.get(node)){
                oper.put(nextnode, oper.get(nextnode) + oper.get(node))
                nodes.add(nextnode);
            }            
        }

        for(int i=1; i<=N; i++){
            System.out.println(oper.get(i));
        }
    }
}

Compiler output:
Main.java:35: error: ';' expected
                oper.put(nextnode, oper.get(nextnode) + oper.get(node))
                                                                       ^
1 error
Language: C++

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

int main() {
  int n,q;
  cin >> n >> q;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n, 0);
  rep(i,n) {
    cin >> a(i) >> b(i);
  }
  vector<int> p(q);
  vector<int> x(q);
  rep(i, q) {
    cin >>p(i) >>x(i);
  }
  int count = 0;
  rep(j, q) {
    rep(k, n) {
      if (p.at(j) == a.at(k)){
        c.at(b.at(k)) += x.at(j)
        count++;
        if (count == 1){
          c.at(a.at(k)) += x.at(j)
        }
      }
    }
  }
  rep(i,n) {
    cout << c(i) << " ";
  }
  endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:13: error: no match for call to '(std::vector<int>) (int&)'
   15 |     cin >> a(i) >> b(i);
      |            ~^~~
a.cc:15:21: error: no match for call to '(std::vector<int>) (int&)'
   15 |     cin >> a(i) >> b(i);
      |                    ~^~~
a.cc:20:12: error: no match for call to '(std::vector<int>) (int&)'
   20 |     cin >>p(i) >>x(i);
      |           ~^~~
a.cc:20:19: error: no match for call to '(std::vector<int>) (int&)'
   20 |     cin >>p(i) >>x(i);
      |                  ~^~~
a.cc:26:33: error: expected ';' before 'count'
   26 |         c.at(b.at(k)) += x.at(j)
      |                                 ^
      |                                 ;
   27 |         count++;
      |         ~~~~~                    
a.cc:29:35: error: expected ';' before '}' token
   29 |           c.at(a.at(k)) += x.at(j)
      |                                   ^
      |                                   ;
   30 |         }
      |         ~                          
a.cc:35:14: error: no match for call to '(std::vector<int>) (int&)'
   35 |     cout << c(i) << " ";
      |             ~^~~
a.cc:37:7: error: statement cannot resolve address of overloaded function
   37 |   endl;
      |       ^
Language: C++

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

int main() {
  int n,q;
  cin >> n >> q;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n, 0);
  rep(i,n) {
    cin >> a(i) >> b(i);
  }
  vector<int> p(q);
  vector<int> x(q);
  rep(i, q) {
    cin >>p(i) >>x(i);
  }
  int count = 0;
  rep(j, q) {
    rep(k. n) {
      if (p.at(j) == a.at(k)){
        c.at(b.at(k)) += x.at(j)
        count++;
        if (count == 1){
          c.at(a.at(k)) += x.at(j)
        }
      }
    }
  }
  rep(i,n) {
    cout << c(i) << " ";
  }
  endl;
}


Compiler output:
a.cc:24:13: error: macro "rep" requires 2 arguments, but only 1 given
   24 |     rep(k. n) {
      |             ^
a.cc:6:9: note: macro "rep" defined here
    6 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:15:13: error: no match for call to '(std::vector<int>) (int&)'
   15 |     cin >> a(i) >> b(i);
      |            ~^~~
a.cc:15:21: error: no match for call to '(std::vector<int>) (int&)'
   15 |     cin >> a(i) >> b(i);
      |                    ~^~~
a.cc:20:12: error: no match for call to '(std::vector<int>) (int&)'
   20 |     cin >>p(i) >>x(i);
      |           ~^~~
a.cc:20:19: error: no match for call to '(std::vector<int>) (int&)'
   20 |     cin >>p(i) >>x(i);
      |                  ~^~~
a.cc:24:5: error: 'rep' was not declared in this scope
   24 |     rep(k. n) {
      |     ^~~
a.cc:35:14: error: no match for call to '(std::vector<int>) (int&)'
   35 |     cout << c(i) << " ";
      |             ~^~~
a.cc:37:7: error: statement cannot resolve address of overloaded function
   37 |   endl;
      |       ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int N, Q;
int adj[200001][200001] = {{0}};
vector<int> v;
vector<bool> f;

void rec (int node) {
	if (node>N)
		return;
	f.at(node) = true;
	for (int i=2; i<=N; i++) {
		if (adj[node][i]==1 && !f.at(i)) {
			v.at(i)	+= v.at(node);
			rec (i);
		}
	}
}

int main () {
	cin >> N >> Q;
	for (int i=1; i<N; i++) {
		int a, b;
		cin >> a >> b;
		adj[a][b] = adj[b][a] = 1;
	}
	for (int i=0; i<Q; i++) {
		int p, x;
		cin >> p >> x;
		v.at(p) += x;
	}
	rec (1);

	for (int i=1; i<=N; i++)
		cout << v.at(i) << " ";
	cout << endl;
	return 0;
}

Compiler output:
/tmp/ccVzGoNF.o: in function `rec(int)':
a.cc:(.text+0x26): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccVzGoNF.o
a.cc:(.text+0x8e): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccVzGoNF.o
a.cc:(.text+0xd0): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccVzGoNF.o
a.cc:(.text+0xe9): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccVzGoNF.o
/tmp/ccVzGoNF.o: in function `main':
a.cc:(.text+0x24f): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccVzGoNF.o
a.cc:(.text+0x291): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccVzGoNF.o
/tmp/ccVzGoNF.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2fb): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccVzGoNF.o
a.cc:(.text+0x314): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccVzGoNF.o
a.cc:(.text+0x32d): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccVzGoNF.o
a.cc:(.text+0x346): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccVzGoNF.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,q;
	cin>>n>>q;
	int a[n],num[n]={0};
	a[1]=1;
	for (int i=2;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		a[y]=x;
	}
	for (int i=1;i<=q;i++)
	{
		int x,y;
		cin>>x>>y;
		num[x]+=y;
	}
	for (int i=2;i<=n;i++)
	{
		for (int j=2;j<=n;j++)
		{
			if (a[j]==k)
			{
				num[j]+=num[k];
			}
		}
	}
	for (int i=1;i<=n;i++)
	{
		cout<<num[i]<<' ';
	}
	cout<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:35: error: 'k' was not declared in this scope
   25 |                         if (a[j]==k)
      |                                   ^
Language: C

#include <stdio.h>
void add(int*);
int main(void){
    // Your code here!
   
        
            
int n,q;
scanf("%d %d",&n,&q);
int r[n][2];
int ans[n];
int root[n][n];
int i;
for(i=0;i<n-1;i++){
    scanf("%d %d",&r[i][0],&r[i][1]);
    root[r[i][0]][r[i][1]]=1;
    ans[i]=0;
}
ans[i+1]=0;
for(i=0;i<n;i++){
    add(root[i]);
}

int b[q][2];
for(i=0;i<q;i++){
    scanf("%d %d",&b[i][0],&b[i][1]);
    ans[b[i][0]]+=b[i][1];
}
for (i=0;i<n;i++){
    printf("%d ",ans[i]);
}     

return 0;

}
void add(int* n){
    int g;
    //int *w = ans;
    for (g=0;g< sizeof(n)/sizeof(int);g++){
        ans[g]=ans[g]+ b[i][1]
        if (sizeof(root[g])/sizeof(int)==1){
            return 0;}
        else{
            return(add(root[g]));
}
    } 
    }

Compiler output:
main.c: In function 'add':
main.c:40:9: error: 'ans' undeclared (first use in this function)
   40 |         ans[g]=ans[g]+ b[i][1]
      |         ^~~
main.c:40:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:40:24: error: 'b' undeclared (first use in this function)
   40 |         ans[g]=ans[g]+ b[i][1]
      |                        ^
main.c:40:26: error: 'i' undeclared (first use in this function)
   40 |         ans[g]=ans[g]+ b[i][1]
      |                          ^
main.c:40:31: error: expected ';' before 'if'
   40 |         ans[g]=ans[g]+ b[i][1]
      |                               ^
      |                               ;
   41 |         if (sizeof(root[g])/sizeof(int)==1){
      |         ~~
Language: C++

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

using namespace std;
typedef vector<vector<int>> Graph;

int main() {
  int N, Q;
  cin >> N >> Q;
  Graph G(N + 1);  // 1-origin
  vector<P> px;
  for (int i = 0; i < N - 1; ++i) {
    // edge
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  // ノード1からの距離（BFSで求める）
  vector<int> depth_v(N + 1, -1);  // i-origin
  queue<int> que;

  depth_v[1] = 0;
  que.push(1);

  while (!que.empty()) {
    int v = que.front();
    que.pop();

    for (int next_v : G[v]) {
      if (depth_v[next_v] != -1) continue;

      depth_v[next_v] = depth_v[v] + 1;
      que.push(next_v);
    }
  }

  // ノード1からの距離に従い、有向グラフで考える
  for (int i = 1; i < N + 1; ++i) {
    for (int j = 0; j < G[i].size(); ++j) {
      if (depth_v[i] > depth_v[G[i][j]]) {
        // 有向な辺はなしとする
        G[i].erase(G[i].begin() + j);
      }
    }
  }

  vector<int> counter(N + 1, 0);  // 1-origin

  for (int i = 0; i < Q; ++i) {
    int p, x;
    cin >> p >> x;
    counter[p] += x;

    // BFS的に探索
    queue<int> que_v;
    que_v.push(p);
    while (!que_v.empty()) {
      int v = que_v.front();
      que_v.pop();
      for (int j = 0; j < G[v].size(); ++j) {
        counter[G[v][j]] += x;
        que_v.push(G[v][j]);
      }
    }
  }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'P' was not declared in this scope
   14 |   vector<P> px;
      |          ^
a.cc:14:11: error: template argument 1 is invalid
   14 |   vector<P> px;
      |           ^
a.cc:14:11: error: template argument 2 is invalid
Language: C

#include<stdio.h>
#define rep(i,n) for(i=0;i<n;i++)
int i,j,k;
int main(){
  int n,q;
  scanf("%d%d",&n,&q);
  int a[n-1],b[n-1],c[n],p[q],x[q];
  rep(i,n){c[i]=0;}
  rep(i,n-1){ scanf("%d%d",&a[i],&b[i]);}
  rep(i,q){
    scanf("%d%d",&p[i],&x[i])
      if(p[i]==1)
	req(k,n){
	  c[k]=c[k]+x[i];}}
  rep(i,q){
    rep(j,n-1){
      if(a[j]==p[i]&&p[i]!=1){
	c[b[j]-1]=c[b[j]-1]+x[i];}}}
  rep(i,q){
    if(p[i]!=1){
      c[p[i]-1]=c[p[i]-1]+x[i];}}
  rep(i,q){
    if(p[i]==1){
      rep(k,n){
	c[k]=c[k]+x[i];}}}
  rep(i,n){printf("%d ",c[i]);}
  printf("\n");
  return 0;}

  



Compiler output:
main.c: In function 'main':
main.c:11:30: error: expected ';' before 'if'
   11 |     scanf("%d%d",&p[i],&x[i])
      |                              ^
      |                              ;
   12 |       if(p[i]==1)
      |       ~~
Language: C

#include <stdio.h>

bool adjm[2001][2001];
int  adjl[2001][2001];
bool visited[2001];
int counter[2001];
int n;

void mtol(int v) {
	int k;
	visited[v] = true;
	for (int i = 0; i <= n; i++) {
		if (adjm[v][i] && !visited[i]) {
			k = 0;
			while (adjl[v][k] > 0) k++;
			adjl[v][k] = i;
			mtol(i);
		}
	}
	return;
}

void addsubtree(int p, int x) {
	counter[p] += x;
	int k=0;
	while (adjl[p][k] > 0){
		addsubtree(adjl[p][k], x);
		k++;
	}
	return;
}

int main()
{
	int i, j;
	int q;
	scanf("%d%d", &n, &q);
	for (i = 0; i <= n; i++) {
		visited[i] = false;
		counter[i] = 0;
		for (j = 0; j <= n; j++) {
			adjm[i][j] = false;
			adjl[i][j] = 0;
		}
	}
	int e1, e2;
	for (i = 0; i < n-1; i++) {
		scanf("%d%d", &e1, &e2);
		adjm[e1][e2] = true;
		adjm[e2][e1] = true;
	}
	mtol(1);
	int p, x;
	for (i = 0; i < q; i++) {
		scanf("%d%d", &p, &x);
		addsubtree(p, x);
	}
	for (i = 1; i <= n; i++) {
		printf("%d ", counter[i]);
	}
	printf("\n");
	return 0;
}

Compiler output:
main.c:3:1: error: unknown type name 'bool'
    3 | bool adjm[2001][2001];
      | ^~~~
main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    1 | #include <stdio.h>
  +++ |+#include <stdbool.h>
    2 | 
main.c:5:1: error: unknown type name 'bool'
    5 | bool visited[2001];
      | ^~~~
main.c:5:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c: In function 'mtol':
main.c:11:22: error: 'true' undeclared (first use in this function)
   11 |         visited[v] = true;
      |                      ^~~~
main.c:11:22: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:11:22: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:39:30: error: 'false' undeclared (first use in this function)
   39 |                 visited[i] = false;
      |                              ^~~~~
main.c:39:30: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:49:32: error: 'true' undeclared (first use in this function)
   49 |                 adjm[e1][e2] = true;
      |                                ^~~~
main.c:49:32: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
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];
      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:47: error: cannot find symbol
        for(int j=1;j<numNo0[p[i]];j++){
                      ^
  symbol:   variable numNo0
  location: class Main
Main.java:48: error: cannot find symbol
          counter[partTree[p[i]][j]]+=x[i];
          ^
  symbol:   variable counter
  location: class Main
Main.java:48: error: cannot find symbol
          counter[partTree[p[i]][j]]+=x[i];
                  ^
  symbol:   variable partTree
  location: class Main
Main.java:64: error: cannot find symbol
      System.out.print(counter[i]+" ");
                       ^
  symbol:   variable counter
  location: class Main
4 errors
Language: C++

#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main (){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	 
	int n,q;
	cin >> n >> q;

	int  c[n+1];
	rep(i,n+1){
		c[i] = 0;
	}

	int  a,b,d[n+1][n+1]={0},pp,xx;
	vint p;
	vint x;
	rep(i,n-1){
		cin >> a >> b;
		d[a][b]++;
	}
	rep(i,q){
		cin >> pp >> xx;
		p.push_back(pp);
		x.push_back(xx);
		c[p[i]] += x[i];
	}

	rep(i,q){
		rep(j,n+1){


Compiler output:
a.cc: In function 'int main()':
a.cc:65:28: error: expected '}' at end of input
   65 |                 rep(j,n+1){
      |                           ~^
a.cc:65:28: error: expected '}' at end of input
a.cc:64:17: note: to match this '{'
   64 |         rep(i,q){
      |                 ^
a.cc:65:28: error: expected '}' at end of input
   65 |                 rep(j,n+1){
      |                            ^
a.cc:38:12: note: to match this '{'
   38 | int main (){
      |            ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int N, Q;
int adj[200001][200001] = {{0}};
int v[200001] = {0};
bool f[200001] = {false};

void rec (int node) {
	if (node>N)
		return;
	f[node] = true;
	for (int i=2; i<=N; i++) {
		if (adj[node][i]==1 && !f[i]) {
			v[i] += v[node];
			rec (i);
		}
	}
}

int main () {
	cin >> N >> Q;
	for (int i=1; i<N; i++) {
		int a, b;
		cin >> a >> b;
		adj[a][b] = adj[b][a] = 1;
	}
	for (int i=0; i<Q; i++) {
		int p, x;
		cin >> p >> x;
		v[p] += x;
	}
	rec (1);

	for (int i=1; i<=N; i++)
		cout << v[i] << " ";
	cout << endl;
	return 0;
}

Compiler output:
/tmp/ccT6F5xS.o: in function `rec(int)':
a.cc:(.text+0x22): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccT6F5xS.o
a.cc:(.text+0x6a): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccT6F5xS.o
a.cc:(.text+0x89): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccT6F5xS.o
a.cc:(.text+0xa0): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccT6F5xS.o
a.cc:(.text+0xba): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccT6F5xS.o
/tmp/ccT6F5xS.o: in function `main':
a.cc:(.text+0x216): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccT6F5xS.o
a.cc:(.text+0x232): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccT6F5xS.o
a.cc:(.text+0x26b): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccT6F5xS.o
collect2: error: ld returned 1 exit status
Language: C++

#import pysnooper
import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy

setrecursionlimit(10**6)

def rec(pp,xx):
    for i in range(n):
        if gragh[pp][i]:
            cnt[i]+=xx
            if tree[i]:
                continue
            rec(i,xx)
    return
n,q=map(int,stdin.readline().rstrip().split())
gragh=[[0]*n for _ in range(n)]
cnt=[0]*n
tree=[0]*n
for i in range(n-1):
    a,b=map(int,stdin.readline().rstrip().split())
    tree[a-1],tree[b-1]=0,1
    gragh[a-1][b-1]=1
for i in range(q):
    p,x=map(int,stdin.readline().rstrip().split())
    cnt[p-1]+=x
    rec(p-1,x)
print(*cnt)

Compiler output:
a.cc:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
    1 | #import pysnooper
      |  ^~~~~~
a.cc:1:9: error: #import expects "FILENAME" or <FILENAME>
    1 | #import pysnooper
      |         ^~~~~~~~~
a.cc:2:1: error: 'import' does not name a type
    2 | import os,re,sys,operator,math,heapq,string
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,q;
vector<int> a[200005];
int cnt[200005];
int ans[200005];
void dfs(int a,int b,int c)
{
	c+=cnt[a];
	ans[a]=c;
	for (int i=0;i<a[a].size();i++)
	{
		int v=a[a][i];
		if(v!=b)
		{
			dfs(v,a,c);			
		}
	}
}
int main()
{
	cin>>n>>q;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for(int i=1;i<=q;i++)
	{
		int x,y;
		cin>>x>>y;
		cnt[x]+=y;
	}
	dfs(1,0,0);
	for(int i=1;i<=n;i++)
	{
		cout<<ans[i]<<" ";		
	}
	cout<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:11:25: error: invalid types 'int[int]' for array subscript
   11 |         for (int i=0;i<a[a].size();i++)
      |                         ^
a.cc:13:24: error: invalid types 'int[int]' for array subscript
   13 |                 int v=a[a][i];
      |                        ^
Language: C++

#include<iostream>#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
vector<ll> G[200001];
bool used[200001]={};
void search(ll d[],ll x,ll sum){
  if(used[x])return;
  used[x]=true;
  d[x]+=sum;
  for(int i=0;i<G[x].size();i++){
    search(d,G[x][i],d[x]);
  }
}
int main(){
  ll n,q,a,b,p,x,mrank=0;
  cin >> n >> q;
  ll rank[n],rsum[n];
  ll d[n];
  bool en[n];
  ll vad[n];
  fill(vad,vad+n,0);
  fill(rank,rank+n,-1);
  fill(en,en+n,false);
  fill(rsum,rsum+n,0);
  fill(d,d+n,0);
  rank[0]=0;
  for(ll i=0;i<n-1;i++){
    cin >> a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(ll i=0;i<q;i++){
    cin >> p >> x;
    p--;
    d[p]+=x;
  }
  search(d,0,0);
  for(ll i=0;i<n;i++){
    cout << d[i]<<" ";
  }
  cout << endl;
}
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll n,q,a,b,p,x,mrank=0;
  cin >> n >> q;
  ll rank[n],rsum[n];
  bool en[n];
  vector<ll> G[n];
  ll vad[n];
  fill(vad,vad+n,0);
  fill(rank,rank+n,-1);
  fill(en,en+n,false);
  fill(rsum,rsum+n,0);
  rank[0]=0;
  for(ll i=0;i<n-1;i++){
    cin >> a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  bool no_c=true;
  while(no_c){
    no_c=false;
    for(ll i=0;i<n;i++){
      if(rank[i]!=-1&&!en[i]){
        en[i]=true;
        for(ll j=0;j<G[i].size();j++){
          if(rank[G[i][j]]==-1){
            rank[G[i][j]]=rank[i]+1;
            mrank = max(rank[i]+1,mrank);
            no_c=false;
          }
        }
      }
    }
  }
  for(ll i=0;i<q;i++){
    cin >> p >> x;
    p--;
    rsum[rank[p]]+=x;
    vad[p]+=x;
  }
  for(ll i=1;i<=mrank;i++){
    rsum[i]+=rsum[i-1];
  }
  ll tmp;
  for(ll i=0;i<n;i++){
    if(rank[i]==0)tmp=0;
    else tmp = rsum[rank[i]-1];
    tmp += vad[i];
    cout << tmp<<" ";
  }
  cout << endl;
}


Compiler output:
a.cc:1:19: warning: extra tokens at end of #include directive
    1 | #include<iostream>#include<iostream>
      |                   ^
a.cc:50:5: error: redefinition of 'int main()'
   50 | int main(){
      |     ^~~~
a.cc:16:5: note: 'int main()' previously defined here
   16 | int main(){
      |     ^~~~
Language: C++


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

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> edges(N, vector<int>(0));
  vector<int> px(N, 0);
  for (int i = 0; i < N-1; i++) {
    int a, b;
    cin >> a >> b;
    edges[a-1].push_back(b-1);

  }
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    px[a-1] += b;
  }
  vector<int> ans(N, 0);
  function<void(int, int)> dfs = [&](int i, int v) {
    ans[i] += v;
    edges[i].size();
    for (int j : edges[i]) {
      dfs(j, v + px[j]);
    }
  };
  dfs(0, px[0]);
  for (int i = 0; i < N; i++) {
    cout << ans[i] << " ";
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:3: error: 'function' was not declared in this scope
   23 |   function<void(int, int)> dfs = [&](int i, int v) {
      |   ^~~~~~~~
a.cc:4:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>'
    3 | #include <vector>
  +++ |+#include <functional>
    4 | using namespace std;
a.cc:23:25: error: expression list treated as compound expression in functional cast [-fpermissive]
   23 |   function<void(int, int)> dfs = [&](int i, int v) {
      |                         ^
a.cc:23:12: error: expected primary-expression before 'void'
   23 |   function<void(int, int)> dfs = [&](int i, int v) {
      |            ^~~~
a.cc:30:3: error: 'dfs' was not declared in this scope
   30 |   dfs(0, px[0]);
      |   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int>v[200005];
int arr[200005], ans[200005];
void solve();
int main(void) 
{
	int n, q;
	cin >> n >> q;
	int a, b;
	int t = n;
	while (t > 1) 
	{
		cin >> a >> b;
		v[b].push_back(a);
		t--;
	}
	for (int i = 0; i < q; i++) 
	{
		int a, b;
		cin >> a >> b;
		arr[a] += b;
	}
	return 0;
}
void solve()
{
	ans[1] = arr[1];
	printf("%d", ans[1]);
	for (int i = 2; i <= n; i++)
	{
		if (v[i].size() != 0)
		{
			int sum = 0;
			for (int j = 0; j < v[i].size(); j++)
			{
				int k = v[i][j];
				sum += ans[k];
			}
			ans[i] = sum + arr[i];
			printf(" %d", ans[i]);
		}
	}
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:30:30: error: 'n' was not declared in this scope
   30 |         for (int i = 2; i <= n; i++)
      |                              ^
Language: C++

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

vector <int> g[200005];

int st[200005], ed[200005], dfs_time;

int bit[200005];
inline void add(int x, int val) {
  while (x < 200005)
    bit[x] += val, x += x & -x;
}
inline int query(int x) {
  int res = 0;
  while (x)
    res += bit[x], x &= x - 1;
  return res;
}

void dfs(int u, int par) {
  st[u] = ++dfs_time;
  for (int i = 0; i < (int)g[u].size(); ++i)
    if (g[u][i] != par)
      dfs(g[u][i], u);
  ed[u] = dfs_time;
}

int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u)
  }
  dfs(1, -1);
  while (q--) {
    int u, val;
    cin >> u >> val;
    add(st[u], val);
    add(ed[u] + 1, -val);
  }
  for (int i = 1; i <= n; ++i)
    printf("%d%c", query(st[i]), " \n"[i == n]);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:22: error: expected ';' before '}' token
   35 |     g[v].push_back(u)
      |                      ^
      |                      ;
   36 |   }
      |   ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;
map<int, vector<int>> mp;
map<int, ll> mp_val;
vector<ll> vout;


void dfs(int node, ll val){
  vout[node-1] += val;
  visited[node-1] = true;
  auto nodes = mp[node];
  for(int i=0;i<nodes.size();++i){
    dfs(nodes[i],val);
  }
  return;
}

int main() {
  int n,q;cin >>n >>q;
  for(int i=0;i<n-1;++i){
    int a,b;cin>> a>>b;
    if(mp.find(a) ==mp.end()){
      vector<int> tmp;
      tmp.push_back(b);
      mp[a] = tmp;
    } else {
      vector<int> tmp = mp[a];
      tmp.push_back(b);
      mp[a] = tmp;
    }
    vout.push_back(0);
    visited.push_back(false);
  }
  //vector<pair<int, int>> vq(q);
  for(int i=0;i<q;++i){
    int p,x;cin>> p>>x;
    if(mp_val.find(p) ==mp_val.end()){
      mp_val[p] = x;
    } else {
      mp_val[p] += x;
    }
  }

  for(auto itr = mp_val.begin();itr != mp_val.end()++itr){
    dfs(itr->first, itr->second);
  }

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

  return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, ll)':
a.cc:13:3: error: 'visited' was not declared in this scope
   13 |   visited[node-1] = true;
      |   ^~~~~~~
a.cc: In function 'int main()':
a.cc:35:5: error: 'visited' was not declared in this scope
   35 |     visited.push_back(false);
      |     ^~~~~~~
a.cc:47:54: error: expected ';' before 'itr'
   47 |   for(auto itr = mp_val.begin();itr != mp_val.end()++itr){
      |                                                      ^~~
      |                                                      ;
Language: C++

#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
using namespace std;

vector<ll> v[250000];
int c[250000]={0};


void nuru(ll pre,ll now,ll x){
  c[now]+=x;
  for(ll i=0;i<v[now].size();i++){
    if(v[now][i]!=pre){
      nuru(now,v[now][i],x);
    }
  }

}

void ser(ll pre,ll now,ll q,ll x){

int kkk=-100;
  for(ll i=0;i<v[now].size();i++){
    if(v[now][i]!=pre){
      if(v[now][i]==q){
        kkk=i;
        break;
      }
      ser(now,v[now][i],x);
    }
  }

if(kkk>=0)
  nuru(now,v[now][i],x);

}


}







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


ll tmp,tmp1,tmp2,tmp3;
for(ll i=0;i<n-1;i++){
  cin>>tmp>>tmp1;
  v[tmp-1].push_back(tmp1-1);
  v[tmp1-1].push_back(tmp-1);
}

vector<ll> p(q);
vector<ll> x(q);

for(ll i=0;i<q;i++){
  cin>>p[i]>>x[i];
  p[i]--;
}



for(ll i=0;i<q;i++){

if(p[i]==0){
nuru(-1,0,p[i],x[i]);
}
else
ser(-1,0,p[i],x[i]);
}

ll ans=0;
for(ll i=0;i<n;i++){
  cout<<c[i]<<" ";
}

}


Compiler output:
a.cc: In function 'void ser(long long int, long long int, long long int, long long int)':
a.cc:29:10: error: too few arguments to function 'void ser(long long int, long long int, long long int, long long int)'
   29 |       ser(now,v[now][i],x);
      |       ~~~^~~~~~~~~~~~~~~~~
a.cc:20:6: note: declared here
   20 | void ser(ll pre,ll now,ll q,ll x){
      |      ^~~
a.cc:34:19: error: 'i' was not declared in this scope
   34 |   nuru(now,v[now][i],x);
      |                   ^
a.cc: At global scope:
a.cc:39:1: error: expected declaration before '}' token
   39 | }
      | ^
a.cc: In function 'int main()':
a.cc:72:5: error: too many arguments to function 'void nuru(long long int, long long int, long long int)'
   72 | nuru(-1,0,p[i],x[i]);
      | ~~~~^~~~~~~~~~~~~~~~
a.cc:10:6: note: declared here
   10 | void nuru(ll pre,ll now,ll x){
      |      ^~~~
Language: C++

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

vector<int> WOODP(int x, vector<vector<int> > &wood, vector<int> &woodp) {
    vector<int> list;
    for (auto &y: wood.at(x)) {
        woodp.at(x).push_back(y);
        list.push_back(y);
        for (auto &z: WOODP(y, wood, woodp)) {
            woodp.at(x).push_back(y);
            list.push_back(y);
        }
    }
    return list;
}

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    vector<int> counter(n, 0);
    vector<vector<int> > wood(n);
    vector<vector<int> > woodp(n);
    rep(i,n-1) {
        int c, cc;
        scanf("%d %d", &c, &cc);
        wood.at(c-1).push_back(cc-1);
    }
    woodp = WOODP(0, wood, woodp);
    rep(i,q) {
        int c, v;
        scanf("%d %d", &c, &v);
        c--;
        for (auto &x: woodp.at(c)) {
            x += v;
        }
    }
    rep(i,n-1) printf("%d ", counter.at(i));
    printf("%d\n", counter.at(n-1));
}


Compiler output:
a.cc: In function 'std::vector<int> WOODP(int, std::vector<std::vector<int> >&, std::vector<int>&)':
a.cc:9:21: error: request for member 'push_back' in '(& woodp)->std::vector<int>::at(((std::vector<int>::size_type)x))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    9 |         woodp.at(x).push_back(y);
      |                     ^~~~~~~~~
a.cc:12:25: error: request for member 'push_back' in '(& woodp)->std::vector<int>::at(((std::vector<int>::size_type)x))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   12 |             woodp.at(x).push_back(y);
      |                         ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:30:28: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<std::vector<int> >'
   30 |     woodp = WOODP(0, wood, woodp);
      |                            ^~~~~
a.cc:6:67: note: in passing argument 3 of 'std::vector<int> WOODP(int, std::vector<std::vector<int> >&, std::vector<int>&)'
    6 | vector<int> WOODP(int x, vector<vector<int> > &wood, vector<int> &woodp) {
      |                                                      ~~~~~~~~~~~~~^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 200005;
vector<int>arr[MAX_N];
long long hs[MAX_N];
long long hst[MAX_N];
int n, q;
long long a, b;
void solve(long long a);
int main(void)
{
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++)
	{
		scanf_s("%lld%lld", &a, &b);
		arr[a].push_back(b);
	}
	for (int i = 0; i < q; i++)
	{
		scanf_s("%lld%lld", &a, &b);
		hst[a] += b;
	}
	for (int i = 1; i < n; i++)
	{
		b = hst[i];
		hs[i] += b;
		solve(i);
	}
	for (int i = 1; i <= n; i++)
	{
		printf("%lld ", hs[i]);
	}
	printf("\n");
	return 0;
}
void solve(long long a)
{
	for (int i = 0; i < arr[a].size(); i++)
	{
		hs[arr[a][i]] += b;
		solve(arr[a][i]);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   15 |                 scanf_s("%lld%lld", &a, &b);
      |                 ^~~~~~~
      |                 scanf
a.cc:20:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   20 |                 scanf_s("%lld%lld", &a, &b);
      |                 ^~~~~~~
      |                 scanf
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 200005;
vector<int>arr[MAX_N];
long long hs[MAX_N];
long long hst[MAX_N];
int n, q;
long long a, b;
void solve(long long a);
int main(void)
{
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++)
	{
		scanf_s("%d%d", &a, &b);
		arr[a].push_back(b);
	}
	for (int i = 0; i < q; i++)
	{
		scanf_s("%d%d", &a, &b);
		hst[a] += b;
	}
	for (int i = 1; i < n; i++)
	{
		b = hst[i];
		hs[i] += b;
		solve(i);
	}
	for (int i = 1; i <= n; i++)
	{
		printf("%lld ", hs[i]);
	}
	printf("\n");
	return 0;
}
void solve(long long a)
{
	for (int i = 0; i < arr[a].size(); i++)
	{
		hs[arr[a][i]] += b;
		solve(arr[a][i]);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   15 |                 scanf_s("%d%d", &a, &b);
      |                 ^~~~~~~
      |                 scanf
a.cc:20:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   20 |                 scanf_s("%d%d", &a, &b);
      |                 ^~~~~~~
      |                 scanf
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 200005;
vector<int>arr[MAX_N];
long long hs[MAX_N];
long long hst[MAX_N];
int n, q, a, b;
void solve(int a);
int main(void)
{
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++)
	{
		scanf_s("%d%d", &a, &b);
		arr[a].push_back(b);
	}
	for (int i = 0; i < q; i++)
	{
		scanf_s("%d%d", &a, &b);
		hst[a] += b;
	}
	for (int i = 1; i < n; i++)
	{
		b = hst[i];
		hs[i] += b;
		solve(i);
	}
	for (int i = 1; i <= n; i++)
	{
		printf("%lld ", hs[i]);
	}
	printf("\n");
	return 0;
}
void solve(int a)
{
	for (int i = 0; i < arr[a].size(); i++)
	{
		hs[arr[a][i]] += b;
		solve(arr[a][i]);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   14 |                 scanf_s("%d%d", &a, &b);
      |                 ^~~~~~~
      |                 scanf
a.cc:19:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   19 |                 scanf_s("%d%d", &a, &b);
      |                 ^~~~~~~
      |                 scanf