Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int int ll;
typedef long double ld;

#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
const ll N=2e5+5,inf=1e9;
ll ary[N];
ll ans[N];
vll G[N];
ll n;
ll tree[4*N];
ll build(ll nd,ll st, ll ed)
{
	if(st==ed)
	{
		tree[nd]=0;
	}
	else
	{
		ll mid=(st+ed)/2;
		build(2*nd,st,mid);
		build(2*nd+1,mid+1,ed);
		tree[nd]=0;
	}
}
ll query(ll nd,ll st,ll ed,ll l,ll r)
{
	if(st>r||ed<l||st>ed)return 0;
	if(st>=l&&ed<=r)
	{
		return tree[nd];
	}
	ll mid=(st+ed)/2;
	return max(query(2*nd,st,mid,l,r),query(2*nd+1,mid+1,ed,l,r));
}
ll update(ll nd,ll st,ll ed,ll id,ll val)
{
	if(st>id||ed<id)return tree[nd];
	if(st>=id&&ed<=id)
	{
		tree[nd]=val;
		return tree[nd];
	}
	ll mid=(st+ed)/2;
	tree[nd]= max(update(2*nd,st,mid,id,val),update(2*nd+1,mid+1,ed,id,val));
	return tree[nd];
}

ll dfs(ll a,ll p)
{
	ll x=query(1,0,n-1,0,ary[a-1]-1);
	ll pre=query(1,0,n-1,ary[a-1],ary[a-1]);
	update(1,0,n-1,ary[a-1],x+1);
	ans[a]=x+1;	
	lp(i,0,G[a].size())
	{
		ll x=G[a][i];
		if(x!=p)
			dfs(x,a);
	}
	update(1,0,n-1,ary[a-1],pre);

}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> n;
	vll v;
	lp(i,0,n)
	{
		cin >> ary[i];
		v.pb(ary[i]);
	}	    
	map<ll,ll> M;
	sort(all(v));
	ll c=0;
	lp(i,0,n)
	{
		if(M.count(v[i])==0)
		{
			M[v[i]]=c++;
		}
	}
	// cerr<<1<<endl;
	lp(i,0,n)
	{
		ary[i]=M[ary[i]];
	}
	lp(i,0,n-1)
	{
		ll u,v;
		cin >>u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
	build(1,0,n-1);
	dfs(1,0);
	lp(i,0,n)
	{
		cout<<ans[i+1]<<endl;
	}
	return 0;
}

Compiler output:
a.cc:3:19: error: two or more data types in declaration of 'll'
    3 | typedef long long int int ll;
      |                   ^~~
a.cc:22:7: error: 'll' does not name a type; did you mean 'ld'?
   22 | const ll N=2e5+5,inf=1e9;
      |       ^~
      |       ld
a.cc:23:1: error: 'll' does not name a type; did you mean 'ld'?
   23 | ll ary[N];
      | ^~
      | ld
a.cc:24:1: error: 'll' does not name a type; did you mean 'ld'?
   24 | ll ans[N];
      | ^~
      | ld
a.cc:13:20: error: 'll' was not declared in this scope; did you mean 'ld'?
   13 | #define vll vector<ll>
      |                    ^~
a.cc:25:1: note: in expansion of macro 'vll'
   25 | vll G[N];
      | ^~~
a.cc:13:22: error: template argument 1 is invalid
   13 | #define vll vector<ll>
      |                      ^
a.cc:25:1: note: in expansion of macro 'vll'
   25 | vll G[N];
      | ^~~
a.cc:13:22: error: template argument 2 is invalid
   13 | #define vll vector<ll>
      |                      ^
a.cc:25:1: note: in expansion of macro 'vll'
   25 | vll G[N];
      | ^~~
a.cc:25:7: error: 'N' was not declared in this scope
   25 | vll G[N];
      |       ^
a.cc:26:1: error: 'll' does not name a type; did you mean 'ld'?
   26 | ll n;
      | ^~
      | ld
a.cc:27:1: error: 'll' does not name a type; did you mean 'ld'?
   27 | ll tree[4*N];
      | ^~
      | ld
a.cc:28:1: error: 'll' does not name a type; did you mean 'ld'?
   28 | ll build(ll nd,ll st, ll ed)
      | ^~
      | ld
a.cc:42:1: error: 'll' does not name a type; did you mean 'ld'?
   42 | ll query(ll nd,ll st,ll ed,ll l,ll r)
      | ^~
      | ld
a.cc:52:1: error: 'll' does not name a type; did you mean 'ld'?
   52 | ll update(ll nd,ll st,ll ed,ll id,ll val)
      | ^~
      | ld
a.cc:65:1: error: 'll' does not name a type; did you mean 'ld'?
   65 | ll dfs(ll a,ll p)
      | ^~
      | ld
a.cc: In function 'int main()':
a.cc:83:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   83 |         cin >> n;
      |                ^
      |                yn
a.cc:13:20: error: 'll' was not declared in this scope; did you mean 'ld'?
   13 | #define vll vector<ll>
      |                    ^~
a.cc:84:9: note: in expansion of macro 'vll'
   84 |         vll v;
      |         ^~~
a.cc:13:22: error: template argument 1 is invalid
   13 | #define vll vector<ll>
      |                      ^
a.cc:84:9: note: in expansion of macro 'vll'
   84 |         vll v;
      |         ^~~
a.cc:13:22: error: template argument 2 is invalid
   13 | #define vll vector<ll>
      |                      ^
a.cc:84:9: note: in expansion of macro 'vll'
   84 |         vll v;
      |         ^~~
a.cc:85:12: error: expected ';' before 'i'
   85 |         lp(i,0,n)
      |            ^
a.cc:6:35: note: in definition of macro 'lp'
    6 | #define lp(var,start,end) for (ll var = start; var <end ; ++var)
      |                                   ^~~
a.cc:85:12: error: 'i' was not declared in this scope
   85 |         lp(i,0,n)
      |            ^
a.cc:6:48: note: in definition of macro 'lp'
    6 | #define lp(var,start,end) for (ll var = start; var <end ; ++var)
      |                                                ^~~
a.cc:87:24: error: 'ary' was not declared in this scope
   87 |                 cin >> ary[i];
      |                        ^~~
a.cc:8:12: error: request for member 'push_back' in 'v', which is of non-class type 'int'
    8 | #define pb push_back
      |            ^~~~~~~~~
a.cc:88:19: note: in expansion of macro 'pb'
   88 |                 v.pb(ary[i]);
      |                   ^~
a.cc:90:18: error: template argument 3 is invalid
   90 |         map<ll,ll> M;
      |                  ^
a.cc:90:18: error: template argument 4 is invalid
a.cc:19:18: error: request for member 'begin' in 'v', which is of non-class type 'int'
   19 | #define all(X) X.begin(),X.end()
      |                  ^~~~~
a.cc:91:14: note: in expansion of macro 'all'
   91 |         sort(all(v));
      |              ^~~
a.cc:19:28: error: request for member 'end' in 'v', which is of non-class type 'int'
   19 | #define all(X) X.begin(),X.end()
      |                            ^~~
a.cc:91:14: note: in expansion of macro 'all'
   91 |         sort(all(v));
      |              ^~~
a.cc:92:11: error: expected ';' before 'c'
   92 |         ll c=0;
      |           ^~
      |           ;
a.cc:93:12: error: expected ';' before 'i'
   93 |         lp(i,0,n)
      |            ^
a.cc:6:35: note: in definition of macro 'lp'
    6 | #define lp(var,start,end) for (ll var = start; var <end ; ++var)
      |                                   ^~~
a.cc:93:12: error: 'i' was not declared in this scope
   93 |         lp(i,0,n)
      |            ^
a.cc:6:48: note: in definition of macro 'lp'
    6 | #define lp(var,start,end) for (ll var = start; var <end ; ++var)
      |                                                ^~~
a.cc:95:22: error: request for member 'count' in 'M', which is of non-class type 'int'
   95 |                 if(M.count(v[i])==0)
      |                      ^~~~~
a.cc:97:33: error: 'c' was not declared in this scope
   97 |                         M[v[i]]=c++;
      |                                 ^
a.cc:101:12: error: expected ';' before 'i'
  101 |         lp(i,0,n)
      |            ^
a.cc:6:35: note: in definition of macro 'lp'
    6 | #define lp(var,start,end) for (ll var = start; var <end ; ++var)
      |                                   ^~~
a.cc:101:12: error: 'i' was not declared in this scope
  101 |         lp(i,0,n)
      |            ^
a.cc:6:48: note: in definition of macro 'lp'
    6 | #define lp(var,start,end) for (ll var = start; var <end ; ++var)
      |                                                ^~~
a.cc:103:17: error: 'ary' was not declared in this scope
  103 |                 ary[i]=M[ary[i]];
      |                 ^~~
a.cc:105:12: error: expected ';' before 'i'
  105 |         lp(i,0,n-1)
      |            ^
a.cc:6:35: note: in definition of macro 'lp'
    6 | #define lp(var,start,end) for (ll var = start; var <end ; ++var)
      |                                   ^~~
a.cc:105:12: error: 'i' was not declared in this scope
  105 |         lp(i,0,n-1)
      |            ^
a.cc:6:48: note: in definition of macro 'lp'
    6 | #define lp(var,start,end) for (ll var = start; var <end ; ++var)
      |                                                ^~~
a.cc:107:19: error: expected ';' before 'u'
  107 |                 ll u,v;
      |                   ^~
      |                   ;
a.cc:108:23: error: 'u' was not declared in this scope
  108 |                 cin >>u >> v;
      |                       ^
a.cc:109:17: error: 'G' was not declared in this scope
  109 |                 G[u].pb(v);
      |                 ^
a.cc:112:9: error: 'build' was not declared in this scope
  112 |         build(1,0,n-1);
      |         ^~~~~
a.cc:113:9: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
  113 |         dfs(1,0);
      |         ^~~
      |         ffs
a.cc:114:12: error: expected ';' before 'i'
  114 |         lp(i,0,n)
      |            ^
a.cc:6:35: note: in definition of macro 'lp'
    6 | #define lp(var,start,end) for (ll var = start; var <end ; ++var)
      |                                   ^~~
a.cc:114:12: error: 'i' was not declared in this scope
  114 |         lp(i,0,n)
      |            ^
a.cc:6:48: note: in definition of macro 'lp'
    6 | #define lp(var,start,end) for (ll var = start; var <end ; ++var)
      |                                                ^~~
a.cc:116:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
  116 |                 cout<<ans[i+1]<<endl;
      |                       ^~~
      |                       abs