Language: C++

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

vector<vector<ll>> v(222222);
ll ma[222222];
ll ans[222222];

int seica(int num, int lim, int pre){
	int ret = 0;
	REP(i,v[num].size()){
		if(v[num][i] != pre && v[num][i] < lim){
			ret += seica(v[num][i],lim,num);
		}
	}
	return ret + 1;
}

void dfs(int num, int pre) {
	int ret = ans[pre];
	ma[num] = max(ma[pre], pre);
	if(num > ma[pre]){
		ret += seica(num,ma[num],pre);
	}
	ans[num] = ret;
	REP(i,v[num].size()){
		if(v[num][i] != pre){
			dfs(v[num][i], num);
		}
	}
}

int main(){
	
	int n;cin >> n;
	REP(i,n-1){
		int a,b;cin >> a >> b;
		a--;b--;
		v[a].EB(b);
		v[b].EB(a);
	}
	
	REP(i,v[0].size()){
		dfs(v[0][i], 0);
	}
	
	REP(i,n-1)cout << ans[i+1] << " ";cout << endl;
	
	return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:39:22: error: no matching function for call to 'max(ll&, int&)'
   39 |         ma[num] = max(ma[pre], pre);
      |                   ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:39:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   39 |         ma[num] = max(ma[pre], pre);
      |                   ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:39:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   39 |         ma[num] = max(ma[pre], pre);
      |                   ~~~^~~~~~~~~~~~~~