Language: C++

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

#define ll long long

using Graph = vector<vector<int>>;

ll count[200010];
Graph G;

void DFS(ll v, ll p, vector<ll> &res) {
  if (p! = -1) res[v] += res[p];
  for (auto e : G[v]) {
    if (e == p) continue;
    dfs(e, v, res);
  }
}


int main() {
  ll N, Q;
  cin >> N >> Q;
  
  
  G.assign(N, vector<int>());
  
  // 木を作る
  for (int i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  
  // DFS
  for (int i = 0; i < Q; i++) {
    int p, x;
    cin >> p >> x;
    count[p] += x;
  }
  dfs(0, -1, count);
  
  
  // output
  for (int i = 1; i <= N; i++) {
    cout << count[i] << " ";
  }
  cout << endl;
  
}

Compiler output:
a.cc: In function 'void DFS(long long int, long long int, std::vector<long long int>&)':
a.cc:12:8: error: expected ')' before '!' token
   12 |   if (p! = -1) res[v] += res[p];
      |      ~ ^
      |        )
a.cc:15:5: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   15 |     dfs(e, v, res);
      |     ^~~
      |     ffs
a.cc: In function 'int main()':
a.cc:41:5: error: reference to 'count' is ambiguous
   41 |     count[p] += x;
      |     ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:8:4: note:                 'long long int count [200010]'
    8 | ll count[200010];
      |    ^~~~~
a.cc:43:14: error: reference to 'count' is ambiguous
   43 |   dfs(0, -1, count);
      |              ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:8:4: note:                 'long long int count [200010]'
    8 | ll count[200010];
      |    ^~~~~
a.cc:43:3: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   43 |   dfs(0, -1, count);
      |   ^~~
      |   ffs
a.cc:48:13: error: reference to 'count' is ambiguous
   48 |     cout << count[i] << " ";
      |             ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:8:4: note:                 'long long int count [200010]'
    8 | ll count[200010];
      |    ^~~~~