Language: C++

#include <algorithm>
using namespace std;
 
int main() {
  int N, Q;
  cin >> N >> Q;
  vector<int> edgestart(N-1);
  vector<int> edgeend(N-1);
  vector<int> vertex(Q);
  vector<int> plus(Q);
  vector<int> ans(N);
  for (int i = 0; i < N-1; i++) {
    cin >> edgestart[i];
    cin >> edgeend[i];
    ans[i] = 0; 
  }
  ans[N-1] = 0;
  for (int j = 0; j < Q; j++) {
    cin >> vertex[j];
    cin >> plus[j];
  }
  
void play(int, int, int, vector<int>, vector<int>, vector<int>);
  
  for(int p = 0; p < Q; p++){
    play(vertex[p],plus[p],N,ans,edgestart,edgeend);
  }  
  
  for(int k = 0; k < N; k++){
  cout << ans[k] << " ";
  }  
  cout << endl;
  
  return 0;
}

void play(int v, int x, int N, vector<int> a, vector<int> b, vector<int> c)
{
  a[v] += x;
  for(int l = 0;l < N-1;l++){
    if(b[l] == v){
      play(c[l], x, N, a, b, c);
    }  
  }  
  return;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin >> N >> Q;
      |   ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <algorithm>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> edgestart(N-1);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <algorithm>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> edgestart(N-1);
      |          ^~~
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> edgeend(N-1);
      |          ^~~
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> vertex(Q);
      |          ^~~
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vector<int> plus(Q);
      |          ^~~
a.cc:11:10: error: expected primary-expression before 'int'
   11 |   vector<int> ans(N);
      |          ^~~
a.cc:13:12: error: 'edgestart' was not declared in this scope
   13 |     cin >> edgestart[i];
      |            ^~~~~~~~~
a.cc:14:12: error: 'edgeend' was not declared in this scope
   14 |     cin >> edgeend[i];
      |            ^~~~~~~
a.cc:15:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   15 |     ans[i] = 0;
      |     ^~~
      |     abs
a.cc:17:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |   ans[N-1] = 0;
      |   ^~~
      |   abs
a.cc:19:12: error: 'vertex' was not declared in this scope
   19 |     cin >> vertex[j];
      |            ^~~~~~
a.cc:20:12: error: 'plus' was not declared in this scope
   20 |     cin >> plus[j];
      |            ^~~~
a.cc:23:26: error: 'vector' is not a type
   23 | void play(int, int, int, vector<int>, vector<int>, vector<int>);
      |                          ^~~~~~
a.cc:23:32: error: expected ',' or '...' before '<' token
   23 | void play(int, int, int, vector<int>, vector<int>, vector<int>);
      |                                ^
a.cc:26:10: error: 'vertex' was not declared in this scope
   26 |     play(vertex[p],plus[p],N,ans,edgestart,edgeend);
      |          ^~~~~~
a.cc:26:20: error: 'plus' was not declared in this scope
   26 |     play(vertex[p],plus[p],N,ans,edgestart,edgeend);
      |                    ^~~~
a.cc:26:34: error: 'edgestart' was not declared in this scope
   26 |     play(vertex[p],plus[p],N,ans,edgestart,edgeend);
      |                                  ^~~~~~~~~
a.cc:26:44: error: 'edgeend' was not declared in this scope
   26 |     play(vertex[p],plus[p],N,ans,edgestart,edgeend);
      |                                            ^~~~~~~
a.cc:30:3: error: 'cout' was not declared in this scope
   30 |   cout << ans[k] << " ";
      |   ^~~~
a.cc:30:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:32:3: error: 'cout' was not declared in this scope
   32 |   cout << endl;
      |   ^~~~
a.cc:32:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:32:11: error: 'endl' was not declared in this scope
   32 |   cout << endl;
      |           ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <algorithm>
  +++ |+#include <ostream>
    2 | using namespace std;
a.cc: At global scope:
a.cc:37:32: error: 'vector' has not been declared
   37 | void play(int v, int x, int N, vector<int> a, vector<int> b, vector<int> c)
      |                                ^~~~~~
a.cc:37:38: error: expected ',' or '...' before '<' token
   37 | void play(int v, int x, int N, vector<int> a, vector<int> b, vector<int> c)
      |                                      ^
a.cc: In function 'void play(int, int, int, int)':
a.cc:39:3: error: 'a' was not declared in this scope
   39 |   a[v] += x;
      |   ^
a.cc:41:8: error: 'b' was not declared in this scope
   41 |     if(b[l] == v){
      |        ^
a.cc:42:12: error: 'c' was not declared in this scope
   42 |       play(c[l], x, N, a, b, c);
      |            ^