Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
int n, q;
vector<vector<int>> graph;
vector<ll> ans;
 
struct leaf {
    int p;
    ll x;
};
 
int main() {
    cin >> n >> q;
    graph = vector<vector<int>>(n);
    ans = vector<int>(n, 0);
    for(int i = 0; i < n-1; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph.at(a).push_back(b);
    }
 
    queue<leaf> que;
 
    for(int i = 0; i < q; ++i) {
        leaf first;
        cin >> first.p >> first.x;
        first.p--;
        que.push(first);
    }
 
    while(!que.empty()) {
        leaf excute;
        excute = que.front();
        que.pop();
        ans.at(excute.p) += excute.x;
        if(graph.at(excute.p).size() != 0) {
            int len = graph.at(excute.p).size();
            for(int i = 0; i < len; ++i) {
                leaf next;
                next.p = graph.at(excute.p).at(i);
                next.x = excute.x;
                que.push(next);
            }
        }
    }
 
    for(int i = 0; i < n; ++i) {
        cout << ans.at(i) << " ";
    }
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:27: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   24 |     ans = vector<int>(n, 0);
      |                           ^
In file included from /usr/include/c++/14/vector:72,
                 from a.cc:3:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~