Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n, q;
  cin >> n >> q;
  map<ll, ll> parents;
  vector<ll, ll> values(n);

  rep (i, n - 1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    parents[b] = a;
  }

  rep (i, q) {
    int p, x;
    cin >> p >> x;
    --p;
    values[p] += x;
  }

  rep (i, n) {
    if (i == 0) continue;
    values[i] += values[parents[i]];
  }

  rep (i, n) {
    cout << values[i] << endl;
  }
  return 0;
}


Compiler output:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'struct std::_Vector_base<long long int, long long int>':
/usr/include/c++/14/bits/stl_vector.h:428:11:   required from 'class std::vector<long long int, long long int>'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
a.cc:18:26:   required from here
   18 |   vector<ll, ll> values(n);
      |                          ^
/usr/include/c++/14/bits/stl_vector.h:87:28: error: 'long long int' is not a class, struct, or union type
   87 |         rebind<_Tp>::other _Tp_alloc_type;
      |                            ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:89:9: error: 'long long int' is not a class, struct, or union type
   89 |         pointer;
      |         ^~~~~~~
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'class std::vector<long long int, long long int>':
a.cc:18:26:   required from here
   18 |   vector<ll, ll> values(n);
      |                          ^
/usr/include/c++/14/bits/stl_vector.h:518:20: error: '_M_allocate' has not been declared in 'std::vector<long long int, long long int>::_Base'
  518 |       using _Base::_M_allocate;
      |                    ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:519:20: error: '_M_deallocate' has not been declared in 'std::vector<long long int, long long int>::_Base'
  519 |       using _Base::_M_deallocate;
      |                    ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:521:20: error: '_M_get_Tp_allocator' has not been declared in 'std::vector<long long int, long long int>::_Base'
  521 |       using _Base::_M_get_Tp_allocator;
      |                    ^~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:18:26: error: call of overloaded 'vector(int&)' is ambiguous
   18 |   vector<ll, ll> values(n);
      |                          ^
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = long long int]'
  620 |       vector(vector&&) noexcept = default;
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = long long int]'
  601 |       vector(const vector& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = long long int; _Alloc = long long int; size_type = long unsigned int; allocator_type = long long int]'
  556 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = long long int; _Alloc = long long int; allocator_type = long long int]'
  542 |       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~
a.cc:31:11: error: no match for 'operator[]' (operand types are 'std::vector<long long int, long long int>' and 'int')
   31 |     values[p] += x;
      |           ^
a.cc:36:11: error: no match for 'operator[]' (operand types are 'std::vector<long long int, long long int>' and 'int')
   36 |     values[i] += values[parents[i]];
      |           ^
a.cc:36:24: error: no match for 'operator[]' (operand types are 'std::vector<long long int, long long int>' and 'std::map<long long int, long long int>::mapped_type' {aka 'long long int'})
   36 |     values[i] += values[parents[i]];
      |                        ^
a.cc:40:19: error: no match for 'operator[]' (operand types are 'std::vector<long long int, long long int>' and 'int')
   40 |     cout << values[i] << endl;
      |                   ^