Language: C++

#include <iostream>
using namespace std;
 
#define MAX 200010
#define NIL -1
 
struct Node{
    int parent;
    int left;
    int right;
    int counter;
    //bool fixed;
};
 
Node T[MAX];
 
int set_counter(int point){
  if(T[point].parent!=NIL){
    T[point].counter += T[T[point].parent].counter;
  }  
  if(T[point].left==NIL && T[point].right==NIL){
    return 0;
  }
  if(T[point].left!=NIL){
    set_counter(T[point].left);
  }
  if(T[point].right!=NIL){
    set_counter(T[point].right);
  }
}
 
int main(){
  int N;
  int Q;
  
  cin >> N;
  cin >> Q;
  
  for(int i=0; i<N; i++){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
    T[i].counter = 0;
    //T[i].fixed = false;
  }
  
  for(int i=0; i<N-1; i++){
    int tmp_parent;
    int tmp_children;
    cin >> tmp_parent >> tmp_children;
    tmp_parent--;
    tmp_children--;
    if(T[tmp_parent].left == NIL){
      T[tmp_parent].left = tmp_children;
    }else{
      T[T[tmp_parent].left].right = tmp_children;
    }
    T[tmp_children].parent = tmp_parent;
  }
  
  for(int i=0; i<Q; i++){
    int tmp_point;
    int tmp_counter;
    cin >> tmp_point >> tmp_counter;
    tmp_point--;
    T[tmp_point].counter += tmp_counter;
  }
  
  set_counter(0);
  
  for(int i=0; i<N; i++){
    cout << T[i].counter << endl;
  }
}
#include <iostream>
using namespace std;

#define MAX 100010
#define NIL -1

struct Node{
    int parent;
    int left;
    int right;
    int counter;
    //bool fixed;
};

Node T[MAX];

int set_counter(int point){
  if(T[point].parent!=NIL){
    T[point].counter += T[T[point].parent].counter;
  }  
  if(T[point].left==NIL && T[point].right==NIL){
    return 0;
  }
  if(T[point].left!=NIL){
    set_counter(T[point].left);
  }
  if(T[point].right!=NIL){
    set_counter(T[point].right);
  }
}

int main(){
  int N;
  int Q;
  
  cin >> N;
  cin >> Q;
  
  for(int i=0; i<N; i++){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
    T[i].counter = 0;
    //T[i].fixed = false;
  }
  
  for(int i=0; i<N-1; i++){
    int tmp_parent;
    int tmp_children;
    cin >> tmp_parent >> tmp_children;
    tmp_parent--;
    tmp_children--;
    if(T[tmp_parent].left == NIL){
      T[tmp_parent].left = tmp_children;
    }else{
      T[T[tmp_parent].left].right = tmp_children;
    }
    T[tmp_children].parent = tmp_parent;
  }
  
  for(int i=0; i<Q; i++){
    int tmp_point;
    int tmp_counter;
    cin >> tmp_point >> tmp_counter;
    tmp_point--;
    T[tmp_point].counter += tmp_counter;
  }
  
  set_counter(0);
  
  for(int i=0; i<N; i++){
    cout << T[i].counter << endl;
  }
}

Compiler output:
a.cc:78:9: warning: "MAX" redefined
   78 | #define MAX 100010
      |         ^~~
a.cc:4:9: note: this is the location of the previous definition
    4 | #define MAX 200010
      |         ^~~
a.cc:81:8: error: redefinition of 'struct Node'
   81 | struct Node{
      |        ^~~~
a.cc:7:8: note: previous definition of 'struct Node'
    7 | struct Node{
      |        ^~~~
a.cc:89:6: error: conflicting declaration 'Node T [100010]'
   89 | Node T[MAX];
      |      ^
a.cc:15:6: note: previous declaration as 'Node T [200010]'
   15 | Node T[MAX];
      |      ^
a.cc:91:5: error: redefinition of 'int set_counter(int)'
   91 | int set_counter(int point){
      |     ^~~~~~~~~~~
a.cc:17:5: note: 'int set_counter(int)' previously defined here
   17 | int set_counter(int point){
      |     ^~~~~~~~~~~
a.cc:106:5: error: redefinition of 'int main()'
  106 | int main(){
      |     ^~~~
a.cc:32:5: note: 'int main()' previously defined here
   32 | int main(){
      |     ^~~~
a.cc: In function 'int set_counter(int)':
a.cc:30:1: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      | ^
a.cc: In function 'int set_counter(int)':
a.cc:104:1: warning: control reaches end of non-void function [-Wreturn-type]
  104 | }
      | ^