Language: C++

#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int used[200100];
int main()
{
    int n, Q;
    cin >> n >> Q;
    vector<vector<int>> tree(n);
    vector<ll> count(n);
    rep(i, n) count[i] = 0;
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tree[a].push_back(b);
    }
    rep(i, Q)
    {
        int p, x;
        cin >> p >> x;
        p--;
        count[p] += x;
    }
    vector<vector<int>> newtree(n);
    queue<int> q;
    for (int a : tree[0])
    {
        q.push(a);
        used[a] = 1;
        newtree[0].push_back(a);
    }
    used[0] = 1;
    while (!q.empty())
    {
        int idx = q.front();
        q.pop();
        for (int a : tree[idx])
        {
            q.push(a);
            used[a] = 1;
            newtree[idx].push_back(a);
        }
    }
    rep(i,n){
        if(used[i])
            continue;
        if(tree[i].size()==0)
            continue;
        newtree.push_back(tree[i][0]);
    }
    queue<int> nq;
    for (int a : newtree[0])
    {
        nq.push(a);
        count[a] += count[0];
    }
    while (!nq.empty())
    {
        int idx = nq.front();
        nq.pop();
        for (int a : newtree[idx])
        {
            nq.push(a);
            count[a] += count[idx];
        }
    }
    rep(i, n)
    {
        cout << count[i] << (i < n ? " " : "");
    }
    cout << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:26: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   64 |         newtree.push_back(tree[i][0]);
      |         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
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:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; value_type = std::vector<int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'const std::vector<std::vector<int> >::value_type&' {aka 'const std::vector<int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; value_type = std::vector<int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<std::vector<int> >::value_type&&' {aka 'std::vector<int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~