Language: C++

#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);
int n,q;
vi adj[mxN];
int val[mxN];
void DFS(int node,int par,int sum){
    val[node]+=sum;
    for(auto child:adj[node]){
        if(child==par)continue;
        DFS(child,node,val[node]);
    }
}
void solve(){
    cin>>n>>q;
    loop(n-1,i,0){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    while(q--){
        int p,x;
        cin>>p>>x;
        val[p]+=x;
    }
    DFS(1,0,0);
    loop(n+1,i,1)
        cout<<val[i]<<' ';
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);
int n,q;
vi adj[mxN];
int val[mxN];
void DFS(int node,int par,int sum){
    val[node]+=sum;
    for(auto child:adj[node]){
        if(child==par)continue;
        DFS(child,node,val[node]);
    }
}
void solve(){
    cin>>n>>q;
    loop(n-1,i,0){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    while(q--){
        int p,x;
        cin>>p>>x;
        val[p]+=x;
    }
    DFS(1,0,0);
    loop(n+1,i,1)
        cout<<val[i]<<' ';
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Compiler output:
a.cc:163:5: error: redefinition of 'int dx []'
  163 | int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
      |     ^~
a.cc:44:5: note: 'int dx [8]' previously defined here
   44 | int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
      |     ^~
a.cc:164:5: error: redefinition of 'int dy []'
  164 | int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
      |     ^~
a.cc:45:5: note: 'int dy [8]' previously defined here
   45 | int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
      |     ^~
a.cc:165:5: error: redefinition of 'int KnightI []'
  165 | int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
      |     ^~~~~~~
a.cc:46:5: note: 'int KnightI [8]' previously defined here
   46 | int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
      |     ^~~~~~~
a.cc:166:5: error: redefinition of 'int KnightJ []'
  166 | int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
      |     ^~~~~~~
a.cc:47:5: note: 'int KnightJ [8]' previously defined here
   47 | int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
      |     ^~~~~~~
a.cc:168:6: error: redefinition of 'template<class T> void max_self(T&, T)'
  168 | void max_self(T &a,T b){
      |      ^~~~~~~~
a.cc:49:6: note: 'template<class T> void max_self(T&, T)' previously declared here
   49 | void max_self(T &a,T b){
      |      ^~~~~~~~
a.cc:172:6: error: redefinition of 'template<class T> void min_self(T&, T)'
  172 | void min_self(T &a,T b){
      |      ^~~~~~~~
a.cc:53:6: note: 'template<class T> void min_self(T&, T)' previously declared here
   53 | void min_self(T &a,T b){
      |      ^~~~~~~~
a.cc:175:6: error: redefinition of 'void fast()'
  175 | void fast(){
      |      ^~~~
a.cc:56:6: note: 'void fast()' previously defined here
   56 | void fast(){
      |      ^~~~
a.cc:180:16: error: redefinition of 'std::vector<std::__cxx11::basic_string<char> > vec_splitter(std::string)'
  180 | vector<string> vec_splitter(string s) {
      |                ^~~~~~~~~~~~
a.cc:61:16: note: 'std::vector<std::__cxx11::basic_string<char> > vec_splitter(std::string)' previously defined here
   61 | vector<string> vec_splitter(string s) {
      |                ^~~~~~~~~~~~
a.cc:189:6: error: redefinition of 'void debug_out(std::vector<std::__cxx11::basic_string<char> >, int, int)'
  189 | void debug_out(
      |      ^~~~~~~~~
a.cc:70:6: note: 'void debug_out(std::vector<std::__cxx11::basic_string<char> >, int, int)' previously defined here
   70 | void debug_out(
      |      ^~~~~~~~~
a.cc:194:6: error: redefinition of 'template<class Head, class ... Tail> void debug_out(std::vector<std::__cxx11::basic_string<char> >, int, int, Head, Tail ...)'
  194 | void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
      |      ^~~~~~~~~
a.cc:75:6: note: 'template<class Head, class ... Tail> void debug_out(std::vector<std::__cxx11::basic_string<char> >, int, int, Head, Tail ...)' previously declared here
   75 | void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
      |      ^~~~~~~~~
a.cc:201:10: error: redefinition of 'const long long int mxN'
  201 | const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
      |          ^~~
a.cc:82:10: note: 'const long long int mxN' previously defined here
   82 | const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
      |          ^~~
a.cc:201:21: error: redefinition of 'const long long int oo'
  201 | const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
      |                     ^~
a.cc:82:21: note: 'const long long int oo' previously defined here
   82 | const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
      |                     ^~
a.cc:201:35: error: redefinition of 'const long long int MOD'
  201 | const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
      |                                   ^~~
a.cc:82:35: note: 'const long long int MOD' previously defined here
   82 | const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
      |                                   ^~~
a.cc:202:14: error: redefinition of 'const double PI'
  202 | const double PI = acos(-1);
      |              ^~
a.cc:83:14: note: 'const double PI' previously defined here
   83 | const double PI = acos(-1);
      |              ^~
a.cc:203:5: error: redefinition of 'int n'
  203 | int n,q;
      |     ^
a.cc:84:5: note: 'int n' previously declared here
   84 | int n,q;
      |     ^
a.cc:203:7: error: redefinition of 'int q'
  203 | int n,q;
      |       ^
a.cc:84:7: note: 'int q' previously declared here
   84 | int n,q;
      |       ^
a.cc:204:4: error: redefinition of 'std::vector<int> adj [500010]'
  204 | vi adj[mxN];
      |    ^~~
a.cc:85:4: note: 'std::vector<int> adj [500010]' previously declared here
   85 | vi adj[mxN];
      |    ^~~
a.cc:205:5: error: redefinition of 'int val [500010]'
  205 | int val[mxN];
      |     ^~~
a.cc:86:5: note: 'int val [500010]' previously declared here
   86 | int val[mxN];
      |     ^~~
a.cc:206:6: error: redefinition of 'void DFS(int, int, int)'
  206 | void DFS(int node,int par,int sum){
      |      ^~~
a.cc:87:6: note: 'void DFS(int, int, int)' previously defined here
   87 | void DFS(int node,int par,int sum){
      |      ^~~
a.cc:213:6: error: redefinition of 'void solve()'
  213 | void solve(){
      |      ^~~~~
a.cc:94:6: note: 'void solve()' previously defined here
   94 | void solve(){
      |      ^~~~~
a.cc:230:5: error: redefinition of 'int main()'
  230 | int main() {
      |     ^~~~
a.cc:111:5: note: 'int main()' previously defined here
  111 | int main() {
      |     ^~~~