Language: Java

#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e16;

int n;
Graph G;
set<ll>s;
ll ans[200010];
vector<ll>a;

void dfs(int v,int p,set<ll> &s){
    ll now = a[v];
    auto itr = s.lower_bound(now);
    if(itr==s.end()){
        s.emplace(now);
    }
    else{
        s.erase(itr);
        s.emplace(now);
    }
    ans[v]=s.size();
    for(ll x : G[v]){
        if(x==p)continue;
        dfs(x,v,s);
    }
}

int main(){
    cin >> n;
    a.resize(n);
    rep(i,n)cin>>a[i];
    G.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0,-1,s);
    rep(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:2: error: illegal character: '#'
#define rep(i,n) for (ll i = 0; i < (n); ++i)
^
Main.java:2: error: class, interface, enum, or record expected
#define rep(i,n) for (ll i = 0; i < (n); ++i)
                                ^
Main.java:2: error: class, interface, enum, or record expected
#define rep(i,n) for (ll i = 0; i < (n); ++i)
                                         ^
Main.java:4: error: class, interface, enum, or record expected
typedef long long ll;
^
Main.java:5: error: class, interface, enum, or record expected
typedef pair<ll,ll> P;
^
Main.java:6: error: class, interface, enum, or record expected
typedef vector<vector<ll> > Graph;
^
Main.java:7: error: class, interface, enum, or record expected
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
^
Main.java:7: error: '{' expected
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
                ^
Main.java:7: error: illegal start of type
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
                                                 ^
Main.java:7: error: > or ',' expected
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
                                                          ^
Main.java:7: error: illegal start of type
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
                                                                                 ^
Main.java:8: error: class, interface, enum, or record expected
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
^
Main.java:8: error: '{' expected
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
                ^
Main.java:8: error: illegal start of type
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
                                                 ^
Main.java:8: error: <identifier> expected
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
                                                      ^
Main.java:8: error: <identifier> expected
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
                                                          ^
Main.java:8: error: illegal start of type
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
                                                                                 ^
Main.java:9: error: class, interface, enum, or record expected
const ll INF = 1e16;
^
Main.java:11: error: unnamed classes are a preview feature and are disabled by default.
int n;
^
  (use --enable-preview to enable unnamed classes)
Main.java:14: error: class, interface, enum, or record expected
ll ans[200010];
^
Main.java:17: error: <identifier> expected
void dfs(int v,int p,set<ll> &s){
                            ^
Main.java:35: error: not a statement
    cin >> n;
        ^
Main.java:37: error: not a statement
    rep(i,n)cin>>a[i];
               ^
Main.java:41: error: not a statement
        cin >> a >> b;
                 ^
Main.java:48: error: not a statement
        cout << ans[i] << endl;
                       ^
Main.java:37: error: ';' expected
    rep(i,n)cin>>a[i];
            ^
Main.java:39: error: ';' expected
    rep(i,n-1){
              ^
Main.java:47: error: ';' expected
    rep(i,n){
            ^
30 errors