Help in question MLCHEF on segment tree on rooted trees

can someone help me debug my code.
i have already tried for past one day continuously but couldn’t found the logical error even when why whole approach is similar t the editoriallist.
link to question MLCHEF-medium
link to my submission my_submission

the code i wrote:

#include<iostream>
#include<cstdio>
#include<cstring>
#include <climits>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
using namespace std;
#define LL long long
#define LD long double
#define DB double
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
int read(){
	char ch=getchar();int x=0,fl=1;
	for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
	for(;isdigit(ch);ch=getchar())x=(x<<3)+(x<<1)+(ch-'0');
	return x*fl;
}
const int NN=500000+17;
 
int n,q;
int HHH[NN];
vector<int> e[NN];
struct Tree{
	int fa[NN],ll[NN],rr[NN],rev[NN];
	int tim;
	
	struct node{
		int health_least, alive_count, lazy_dec;
	}t[NN<<2]; 
	node merge(node a,node b){
		node c;
		c.health_least=min(a.health_least,b.health_least);
                c.alive_count=a.alive_count+b.alive_count;
                c.lazy_dec=0;
                
		return c;
	}
	void push(int v){ 
	                t[(v<<1)].health_least-=t[v].lazy_dec;  t[(v<<1)].lazy_dec+=t[v].lazy_dec;
			t[(v<<1|1)].health_least-=t[v].lazy_dec;  t[(v<<1|1)].lazy_dec+=t[v].lazy_dec;
                       t[v].lazy_dec=0;
	} 
 

	void build(int rt,int l,int r){  
		if(l==r){
			t[rt].health_least=HHH[rev[l]];
                       if(HHH[rev[l]]>0){ t[rt].alive_count=1;} t[rt].lazy_dec=0;
                       if(l==1){t[rt].alive_count=0;}                                            
			return;
		}
		int mid=(l+r)>>1;
		build(rt<<1,l,mid);
		build(rt<<1|1,mid+1,r);
		t[rt]=merge(t[rt<<1],t[rt<<1|1]);       
	}

        void remove_dead(int rt,int l,int r){
		 int mid=(l+r)>>1;
		if(t[rt].health_least>0){return;}
		else if(l==r){t[rt].alive_count=0; t[rt].health_least=INT_MAX;
                 }
		else{
		push(rt);
		remove_dead(2*rt,l,mid);
		remove_dead(2*rt+1,mid+1,r);
		t[rt]=merge( t[(rt<<1)], t[(rt<<1|1)]);
		}
	}
	void update(int rt,int l,int r,int ll,int rr,int lazy){ 
		if(ll<=l&&r<=rr){  
			t[rt].health_least-=lazy;
                        t[rt].lazy_dec+=lazy;                       
                        if(t[rt].health_least<=0){remove_dead(rt,l,r);}
			return;
		}
		push(rt);
		int mid=(l+r)>>1;
		if(ll<=mid){update(rt<<1,l,mid,ll,rr,lazy);  }
		if(rr>mid){update(rt<<1|1,mid+1,r,ll,rr,lazy); }
		t[rt]=merge(t[rt<<1],t[rt<<1|1]);
	}
        
        int query(int rt,int l,int r,int ll,int rr){ 
                
		if(ll<=l&&r<=rr){
			return t[rt].alive_count; 
		}
		push(rt);
		int mid=(l+r)>>1;
                int ans=0;
		if(ll<=mid){ans+=query(rt<<1,l,mid,ll,rr);} 
		if(rr>mid){ans+=query(rt<<1|1,mid+1,r,ll,rr);}    
		return ans;
	}

	void dfs(int x,int ff){   
		fa[x]=ff;
		ll[x]=++tim;       
		rev[tim]=x;        
		for(int i=0,top=e[x].size();i<top;i++){
			int y=e[x][i];
			if(y!=ff){
			
				dfs(y,x);
			}
		}
		rr[x]=tim;     
	}
	void work(int root){
		dfs(root,-1);
		build(1,1,n+1);
                
		
	}
}tx; 

void get_path(){
	tx.tim=0;
	tx.work(0);
}
 
int main(){	
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n; HHH[0]=INT_MAX;
	for(int i=1;i<=n;i++){
		int x,y; cin>>x>>y;
                HHH[i]=x;
		e[i].push_back(y);
		e[y].push_back(i);		
	}
        get_path();
	cin>>q;
        int a,b,c;
	for(int i=1;i<=q;i++){
        	cin>>a;
        	 if(a==1){
		 cin>>b>>c;
		 tx.update(1,1,n+1,tx.ll[b]+1,tx.rr[b],c);
		 }
		else{
		 cin>>b;
 		 cout<<tx.query(1,1,n+1,tx.ll[b]+1,tx.rr[b])<<"\n"; //<<"\nQUERYEND============\n";
		}

	}
	return 0;
}