Language: C++

#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1,mod=1e9+7;
const int inf=(1ull<<31)-1;
vector<vector<int>> g(100000);
map<pair<int,int>,int> mp;
vector<pair<int,int>> v(100000);
int n,s=0;
bool vis[100000];

void dfs(int a,int b){
	vis[a]=true;
	for (int j=0;j<g[a].size();j++)
		if (!vis[g[a][j]]){
			mp[{a,g[a][j]}]=b++;
			dfs(g[a][j],b%s);
		}
}

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	n--;
	for (int i=0,f,t;i<n;i++){
		cin>>f>>t;
		f--,t--;
		v[i]={f,t};
		mp[{f,t}]=0;
		g[f].push_back(t);
		g[t].push_back(f);
	}
	s=0;
	for (int i=0;i<n+1;i++)
		s=max((ui)s,g[i].size());
	cout<<s<<"\n";
	fill(vis,vis+100000,false);
	dfs(0,0);
	for (int i=0;i<n;i++)
		cout<<mp[{v[i].first,v[i].second}]+1<<"\n";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:22: error: no matching function for call to 'max(ui, std::vector<int>::size_type)'
   44 |                 s=max((ui)s,g[i].size());
      |                   ~~~^~~~~~~~~~~~~~~~~~~
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:44:22: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   44 |                 s=max((ui)s,g[i].size());
      |                   ~~~^~~~~~~~~~~~~~~~~~~
/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:44:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
   44 |                 s=max((ui)s,g[i].size());
      |                   ~~~^~~~~~~~~~~~~~~~~~~