Language: C++

#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  4000006

ll n;
vi w(N),ans11(N,0),vis(N,0);
vi v[N];
ll l,r;
vi a(N),seg(4*N);
void build(ll cur,ll st,ll end)
{
    if(st==end)
    {
        seg[cur]=a[st];
        return;
    }
    ll mid=(st+end)>>1;
    build(2*cur,st,mid);
    build(2*cur+1,mid+1,end);
    seg[cur]=max(seg[2*cur],seg[2*cur+1]);    /*  1-change here  */
}
ll query(ll cur,ll st,ll end,ll l,ll r)
{
    if(l<=st&&r>=end)
    return seg[cur];
    if(r<st||l>end)
    return 0;                           /*  2-change here  */
    ll mid=(st+end)>>1;
    ll ans1=query(2*cur,st,mid,l,r);
    ll ans2=query(2*cur+1,mid+1,end,l,r);
    return max(ans1,ans2);                 /*  3-change here  */
}
void update(ll cur,ll st,ll end,ll pos,ll upd)
{
    if(st==end)
    {
        a[pos]=upd;                    /*  4-change here  */
        seg[cur]=upd;                    /*  5-change here  */
        return;
    }
    ll mid=(st+end)>>1;
    if(st<=pos&&pos<=mid)
        update(2*cur,st,mid,pos,upd);
    else
        update(2*cur+1,mid+1,end,pos,upd);
    seg[cur]=max(seg[2*cur],seg[2*cur+1]);    /*  6-change here  */
}

void dfs(ll x)
{
    // cout<<x<<endl;

    vis[x]=1;
    ll y=query(1,0,n,0,w[x]);
    // cout<<x<<" "<<w[x]-1<<endl;
    ll yy=query(1,0,n,w[x],w[x]);
    // cout<<yy<<endl;
    // cout<<a<<y<<endl<<endl;
    y=max(y+1,yy)
    ans11[x]=y;
    update(1,0,n,w[x],y);
    for(auto i:v[x])
    {
        if(vis[i]==1)continue;
        dfs(i);
    }
    update(1,0,n,w[x],yy);
}

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m;
        cin>>n;
        map<ll,ll> ma;
        for(i=1;i<=n;i++)
        {   
            cin>>w[i];
            ma[w[i]]=1;
        }
        for(i=0;i<n-1;i++)
        {
            cin>>l>>m;
            v[l].pb(m);
            v[m].pb(l);
        }
        j=1;
        for(auto i:ma)
        {
            ma[i.F]=j;
            j++;
        }
        for(i=1;i<=n;i++)
        {
            w[i]=ma[w[i]];
        }
        // cout<<w;
        for(i=0;i<=n;i++)a[i]=0;
        build(1,0,n);
        dfs(1);
        for(i=1;i<=n;i++)
            cout<<ans11[i]<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'void dfs(long long int)':
a.cc:111:18: error: expected ';' before 'ans11'
  111 |     y=max(y+1,yy)
      |                  ^
      |                  ;
  112 |     ans11[x]=y;
      |     ~~~~~