Language: C++

//good luck
# include <iostream>
# include <cstdio>
# include <cmath>
# include <cstdlib>
# include <cstring>
# include <string>
# include <algorithm>
# include <vector>
# include <queue>
# include <ctime>
# include <map>

#define LL long long
#define maxn (int)4e5+5
#define inf  (int)2147483640
#define is(a) (a>='0'&&a<='9')
#define iabs(a) ((a)>0?(a):(-a))
#define imax(a,b) ((a)>(b)?(a):(b))
#define imin(a,b) ((a)<(b)?(a):(b))
 
using namespace std;

int N,Q,a,b,tot,head[maxn],next[maxn],ver[maxn],val[maxn],fa[maxn];

inline void read(int &x)
{
  x=0;bool f=0;char ch=getchar();
  for (;!is(ch);ch=getchar()) f|=ch=='-';
  for (;is(ch);ch=getchar()) x=(x<<3)+(x<<1)+(ch^48);
  x=f?-x:x;
}

void addedge(int x,int y)
{
	++tot; next[tot] = head[x]; head[x] = tot; ver[tot] = y; 
	++tot; next[tot] = head[y]; head[y] = tot; ver[tot] = x; 
}

void Dfs(int x)
{
	for (int i = head[x];i ;i = next[i])
	{
		int y = ver[i];
		if (fa[x] == y) continue;
		fa[y] = x;
		Dfs(y);
	}
}

void Debug(int x)
{
	for (int i = head[x];i ;i = next[i])
	{
		int y = ver[i];
		if (fa[x] == y) continue;
		val[y] += val[x];
		Debug(y);
	}
}

int main()
{
	read(N); read(Q);
	for (int i = 1; i < N; ++i) 
	{
		read(a),read(b);
		addedge (a,b);
	}
	Dfs(1);
	for (int i = 1; i <= Q; ++i) 
	{
		read(a),read(b);
		val[a]+=b;
	}
	Debug(1);
	for (int i = 1; i <= N; ++i)  printf("%d%c",val[i],(i == N)?'\n':' ');
	return 0;
}

Compiler output:
a.cc: In function 'void addedge(int, int)':
a.cc:36:16: error: reference to 'next' is ambiguous
   36 |         ++tot; next[tot] = head[x]; head[x] = tot; ver[tot] = y;
      |                ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:28: note:                 'int next [400005]'
   24 | int N,Q,a,b,tot,head[maxn],next[maxn],ver[maxn],val[maxn],fa[maxn];
      |                            ^~~~
a.cc:37:16: error: reference to 'next' is ambiguous
   37 |         ++tot; next[tot] = head[y]; head[y] = tot; ver[tot] = x;
      |                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:28: note:                 'int next [400005]'
   24 | int N,Q,a,b,tot,head[maxn],next[maxn],ver[maxn],val[maxn],fa[maxn];
      |                            ^~~~
a.cc: In function 'void Dfs(int)':
a.cc:42:37: error: reference to 'next' is ambiguous
   42 |         for (int i = head[x];i ;i = next[i])
      |                                     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:28: note:                 'int next [400005]'
   24 | int N,Q,a,b,tot,head[maxn],next[maxn],ver[maxn],val[maxn],fa[maxn];
      |                            ^~~~
a.cc: In function 'void Debug(int)':
a.cc:53:37: error: reference to 'next' is ambiguous
   53 |         for (int i = head[x];i ;i = next[i])
      |                                     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:28: note:                 'int next [400005]'
   24 | int N,Q,a,b,tot,head[maxn],next[maxn],ver[maxn],val[maxn],fa[maxn];
      |                            ^~~~