Language: C++

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

using Graph = vector<vector<int>>;
Graph G;

vector<int> count;

void dfs(int par, int now, int val){
	count.at(now) += val;
	for(auto child : G.at(now)){
		if(child == par) continue;
		dfs(now, chlid, count.at(now));
	}
}



int main() {
  int N, Q;
  int a,b,p,x;

  cin >> N >> Q;
  G.resize(N);
  count.resize(N);

  for(int i=0; i<N-1; i++){
  	cin >> p >> x; p--; x--;
  	G.at(p).push_back(x);
  	G.at(x).push_back(p);
  }

  for(int i=0; i<Q; i++){
  	cin >> a >> b; a--;
  	count.at(a) += b;
  }

  dfs(-1,0,0);
  for(int i=0; i<Q; i++){ cout << count.at(i) << " "; }
  cout << endl;

  return 0;
}  


Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:10:9: error: reference to 'count' is ambiguous
   10 |         count.at(now) += val;
      |         ^~~~~
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:7:13: note:                 'std::vector<int> count'
    7 | vector<int> count;
      |             ^~~~~
a.cc:13:26: error: 'chlid' was not declared in this scope; did you mean 'child'?
   13 |                 dfs(now, chlid, count.at(now));
      |                          ^~~~~
      |                          child
a.cc:13:33: error: reference to 'count' is ambiguous
   13 |                 dfs(now, chlid, count.at(now));
      |                                 ^~~~~
/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:7:13: note:                 'std::vector<int> count'
    7 | vector<int> count;
      |             ^~~~~
a.cc: In function 'int main()':
a.cc:25:3: error: reference to 'count' is ambiguous
   25 |   count.resize(N);
      |   ^~~~~
/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:7:13: note:                 'std::vector<int> count'
    7 | vector<int> count;
      |             ^~~~~
a.cc:35:9: error: reference to 'count' is ambiguous
   35 |         count.at(a) += b;
      |         ^~~~~
/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:7:13: note:                 'std::vector<int> count'
    7 | vector<int> count;
      |             ^~~~~
a.cc:39:35: error: reference to 'count' is ambiguous
   39 |   for(int i=0; i<Q; i++){ cout << count.at(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:7:13: note:                 'std::vector<int> count'
    7 | vector<int> count;
      |             ^~~~~