Language: C++

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <stack>
#include <deque>
#include <list>
#include <cassert>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define pb push_back
#define mp make_pair
#ifdef GRAPH
typedef pair <int, int> Edge;
#define v first
#define w second
#endif
#if __cplusplus >= 201103L
using LL = long long;
using ULL = unsigned long long;
#else
#define LL long long
#define ULL unsigned long long
#endif
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define rep(i, n) for (int (i) = 0; (i) < n; (i)++)
#define until(x) while (!x)
#define fail(s) assert(!s)
#define int long long
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
const int MAXN = 50000020;
struct Node
{
    int lc,rc;
    long long s,add;
    #define lc(x) t[x].lc
    #define rc(x) t[x].rc
    #define sum(x) t[x].s
    #define add(x) t[x].add
}t[MAXN*4];
int a[MAXN];
struct Segment_Tree
{
    #define lchild(x) x*2
    #define rchild(x) x*2+1
    void build(int p,int l,int r)
    {
        lc(p)=l,rc(p)=r;
        if (l==r)
        {
            sum(p)=a[l];
            return;
        }
        int mid=(l+r)/2;
        build(lchild(p),l,mid);
        build(rchild(p),mid+1,r);
        sum(p)=sum(lchild(p))+sum(rchild(p));
    }
    void update(int p)
    {
        if (add(p))
        {
            sum(lchild(p))+=add(p)*(rc(lchild(p))-lc(lchild(p))+1);
            sum(rchild(p))+=add(p)*(rc(rchild(p))-lc(rchild(p))+1);
            add(lchild(p))+=add(p);
            add(rchild(p))+=add(p);
            add(p)=0;
        }
    }
    void change(int p,int l,int r,int d)
    {
        if (l<=lc(p)&&r>=rc(p))
        {
            sum(p)+=(long long)d*(rc(p)-lc(p)+1);
            add(p)+=d;
            return;
        }
        update(p);
        int mid=(lc(p)+rc(p))/2;
        if (l<=mid)change(lchild(p),l,r,d);
        if (r>mid)change(rchild(p),l,r,d);
        sum(p)=sum(lchild(p))+sum(rchild(p));
    }
    long long query(int p,int l,int r)
    {
        if (l<=lc(p)&&r>=rc(p)) return sum(p);
        update(p);
        long long res=0;
        int mid=(lc(p)+rc(p))/2;
        if (l<=mid)res+=query(lchild(p),l,r);
        if (r>mid)res+=query(rchild(p),l,r);
        return res;
    }
}tree;
vector <int> G[MAXN];
int L[MAXN], R[MAXN], tot, n, q;
void dfs(int u, int fa) {
	L[u] = ++tot;
	for (auto v:G[u]) {
		if (v == fa)continue;
		dfs(v, u); 
	}
	R[u] = tot;
}
signed main() {
	ios::sync_with_stdio(false);
	cin >> n >> q;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs(1, -1);
	tree.build(1, 1, tot);
	for (int i = 1; i <= q; i++) {
		int u, v;
		cin >> u >> v;
		tree.change(1, L[u], R[u], v);
	} 
	for (int i = 1; i <= n; i++)cout << tree.query(1, i, i) << ' ';
	cout << endl;
	return 0;
}


Compiler output:
/tmp/cc7rh5NQ.o: in function `dfs(long long, long long)':
a.cc:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against symbol `tot' defined in .bss section in /tmp/cc7rh5NQ.o
a.cc:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol `tot' defined in .bss section in /tmp/cc7rh5NQ.o
a.cc:(.text+0x25): relocation truncated to fit: R_X86_64_PC32 against symbol `tot' defined in .bss section in /tmp/cc7rh5NQ.o
a.cc:(.text+0x38): relocation truncated to fit: R_X86_64_PC32 against symbol `L' defined in .bss section in /tmp/cc7rh5NQ.o
a.cc:(.text+0x54): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc7rh5NQ.o
a.cc:(.text+0xda): relocation truncated to fit: R_X86_64_PC32 against symbol `tot' defined in .bss section in /tmp/cc7rh5NQ.o
a.cc:(.text+0xed): relocation truncated to fit: R_X86_64_PC32 against symbol `R' defined in .bss section in /tmp/cc7rh5NQ.o
/tmp/cc7rh5NQ.o: in function `main':
a.cc:(.text+0x10d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc7rh5NQ.o
a.cc:(.text+0x129): relocation truncated to fit: R_X86_64_PC32 against symbol `q' defined in .bss section in /tmp/cc7rh5NQ.o
a.cc:(.text+0x181): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc7rh5NQ.o
a.cc:(.text+0x1ab): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status