Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
 
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define gap cout<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
int total;
const int N=100005;
int visited[N];
int coount[N];
vector<int> adj[N];
std::vector<ii> edges; 
map<ii,int> colors;

void dfs(int node,int color){
    visited[node]=1;
    for(auto j:adj[node]){
        if(visited[j]) continue;
        colors[{node,j}]=(color)%total;
        dfs(j,(color+1)%total);
        color++;
        color=(color)%total;
    }
}
 
int main(){
    int n;
    cin>>n;
    int maax=0;
    int a,b;
    fo(i,n+1){
        visited[i]=0;
        coount[i]=0;

    }
    fo(i,n-1){
        cin>>a>>b;
        coount[a]++;
        coount[b]++;
        maax=max(coount[a],maax);
        maax=max(coount[b],maax);
        edges.pb({a,b});
        adj[a].pb(b);
        adj[b].pb(a);

    }
    total=maax;
    dfs(1,0);
    cout<<total<<endl;
    for(auto j:edges){
        if(colors.count(j)) cout<<colors[j]+1<<endl;
        else cout<<colors[j.second,j.first]+1<<endl;
    }
   
 
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:26: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'int')
   71 |         else cout<<colors[j.second,j.first]+1<<endl;
      |                          ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'int' to 'const std::map<std::pair<int, int>, int>::key_type&' {aka 'const std::pair<int, int>&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~