Language: C++

//Ki

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,q;cin>>n>>q;
    vector<queue<int>>g(n+1);
    rep(i,0,n-1){
        int a,b;cin>>a>>b;
        g[a].push(b);
        g[b].push(a);
    }
    map<int,int>m{};
    rep(i,0,q){
        int a,b;cin>>a>>b;
        m[a]+=b;
    }
    stack<p>s;
    s.push(1);
    vector<int>d(n+1);
    while(!s.empty()){
        int c = s.front();
        s.pop();
        int t = g[c].front();
        g[c].pop();
        d[c]=m[c]+d[t];
        while(!g[c].empty()){
            s.push(g[c].front());
            g[c].pop();
        }
    }
    rep(i,1,n+1){
        cout<<d[i]<<nnn;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:11: error: no matching function for call to 'std::stack<std::pair<long long int, long long int> >::push(int)'
   36 |     s.push(1);
      |     ~~~~~~^~~
In file included from /usr/include/c++/14/stack:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:160,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_stack.h:258:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; value_type = std::pair<long long int, long long int>]'
  258 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_stack.h:258:30: note:   no known conversion for argument 1 from 'int' to 'const std::stack<std::pair<long long int, long long int> >::value_type&' {aka 'const std::pair<long long int, long long int>&'}
  258 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:263:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; value_type = std::pair<long long int, long long int>]'
  263 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_stack.h:263:25: note:   no known conversion for argument 1 from 'int' to 'std::stack<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  263 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
a.cc:39:19: error: 'class std::stack<std::pair<long long int, long long int> >' has no member named 'front'
   39 |         int c = s.front();
      |                   ^~~~~
a.cc:45:19: error: no matching function for call to 'std::stack<std::pair<long long int, long long int> >::push(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   45 |             s.push(g[c].front());
      |             ~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_stack.h:258:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; value_type = std::pair<long long int, long long int>]'
  258 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_stack.h:258:30: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'const std::stack<std::pair<long long int, long long int> >::value_type&' {aka 'const std::pair<long long int, long long int>&'}
  258 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:263:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; value_type = std::pair<long long int, long long int>]'
  263 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_stack.h:263:25: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'std::stack<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  263 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~