Language: C++

using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int n;
vvin edge(100050);
map<pair<int,int>,int> e;

void bfs(){
    queue<pair<int,int>> q;
    q.push(mp(1,0));
    vbo arrived(n+1,false);arrived[1]=true;
    int j;
    while(q.size()){
        auto p=q.front();q.pop();
        if(edge[p.first].size()==0)continue;
        j=1;
        for(auto hen:edge[p.first]){
            if(j==p.second)j++;
            if(!arrived[hen]){
                if(p.first<hen)e[mp(p.first,hen)]=j;
                else e[mp(hen,p.first)]=j;
                q.push(mp(hen,j));
                arrived[hen]=true;
                j++;
            }
        }
    }
}

int main(){
    cin>>n;
    vector<set<int>> used(n+1);
    vin a(n-1),b(n-1);
    rep(i,n-1){
        cin>>a[i]>>b[i];
        edge[a[i]].push_back(b[i]);
        edge[b[i]].push_back(a[i]);
    }
    int M=0;int tmp;
    rep(i,n){
        tmp=edge[i+1].size();
        M=max(M,tmp);
    }
    bfs();
    cout<<M<<endl;
    rep(i,n-1){
        if(a[i]<b[i])cout<<e[mp(a[i],b[i])]<<endl;
        else cout<<e[mp(b[i],a[i])]<<endl;
    }
}

Compiler output:
a.cc:3:11: error: 'vector' does not name a type
    3 | using vin=vector<int>;
      |           ^~~~~~
a.cc:4:11: error: 'vector' does not name a type
    4 | using vll=vector<long long>;
      |           ^~~~~~
a.cc:5:12: error: 'vector' does not name a type
    5 | using vvin=vector<vector<int>>;
      |            ^~~~~~
a.cc:6:12: error: 'vector' does not name a type
    6 | using vvll=vector<vector<long long>>;
      |            ^~~~~~
a.cc:7:12: error: 'vector' does not name a type
    7 | using vstr=vector<string>;
      |            ^~~~~~
a.cc:8:13: error: 'vector' does not name a type
    8 | using vvstr=vector<vector<string>>;
      |             ^~~~~~
a.cc:9:11: error: 'vector' does not name a type
    9 | using vch=vector<char>;
      |           ^~~~~~
a.cc:10:12: error: 'vector' does not name a type
   10 | using vvch=vector<vector<char>>;
      |            ^~~~~~
a.cc:11:11: error: 'vector' does not name a type
   11 | using vbo=vector<bool>;
      |           ^~~~~~
a.cc:12:12: error: 'vector' does not name a type
   12 | using vvbo=vector<vector<bool>>;
      |            ^~~~~~
a.cc:13:12: error: 'vector' does not name a type
   13 | using vpii=vector<pair<int,int>>;
      |            ^~~~~~
a.cc:14:13: error: 'priority_queue' does not name a type
   14 | using pqsin=priority_queue<int,vector<int>,greater<int>>;
      |             ^~~~~~~~~~~~~~
a.cc:24:1: error: 'vvin' does not name a type
   24 | vvin edge(100050);
      | ^~~~
a.cc:25:1: error: 'map' does not name a type; did you mean 'mp'?
   25 | map<pair<int,int>,int> e;
      | ^~~
      | mp
a.cc: In function 'void bfs()':
a.cc:28:5: error: 'queue' was not declared in this scope
   28 |     queue<pair<int,int>> q;
      |     ^~~~~
a.cc:1:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
  +++ |+#include <queue>
    1 | using namespace std;
a.cc:28:11: error: 'pair' was not declared in this scope
   28 |     queue<pair<int,int>> q;
      |           ^~~~
a.cc:1:1: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
  +++ |+#include <utility>
    1 | using namespace std;
a.cc:28:16: error: expected primary-expression before 'int'
   28 |     queue<pair<int,int>> q;
      |                ^~~
a.cc:29:5: error: 'q' was not declared in this scope
   29 |     q.push(mp(1,0));
      |     ^
a.cc:15:12: error: 'make_pair' was not declared in this scope
   15 | #define mp make_pair
      |            ^~~~~~~~~
a.cc:29:12: note: in expansion of macro 'mp'
   29 |     q.push(mp(1,0));
      |            ^~
a.cc:15:12: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
   15 | #define mp make_pair
      |            ^~~~~~~~~
a.cc:29:12: note: in expansion of macro 'mp'
   29 |     q.push(mp(1,0));
      |            ^~
a.cc:30:5: error: 'vbo' was not declared in this scope
   30 |     vbo arrived(n+1,false);arrived[1]=true;
      |     ^~~
a.cc:30:28: error: 'arrived' was not declared in this scope
   30 |     vbo arrived(n+1,false);arrived[1]=true;
      |                            ^~~~~~~
a.cc:34:12: error: 'edge' was not declared in this scope
   34 |         if(edge[p.first].size()==0)continue;
      |            ^~~~
a.cc:36:22: error: 'edge' was not declared in this scope
   36 |         for(auto hen:edge[p.first]){
      |                      ^~~~
a.cc:39:32: error: 'e' was not declared in this scope
   39 |                 if(p.first<hen)e[mp(p.first,hen)]=j;
      |                                ^
a.cc:40:22: error: 'e' was not declared in this scope
   40 |                 else e[mp(hen,p.first)]=j;
      |                      ^
a.cc: In function 'int main()':
a.cc:50:5: error: 'cin' was not declared in this scope
   50 |     cin>>n;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:51:5: error: 'vector' was not declared in this scope
   51 |     vector<set<int>> used(n+1);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:51:12: error: 'set' was not declared in this scope
   51 |     vector<set<int>> used(n+1);
      |            ^~~
a.cc:1:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
  +++ |+#include <set>
    1 | using namespace std;
a.cc:51:16: error: expected primary-expression before 'int'
   51 |     vector<set<int>> used(n+1);
      |                ^~~
a.cc:52:5: error: 'vin' was not declared in this scope
   52 |     vin a(n-1),b(n-1);
      |     ^~~
a.cc:54:14: error: 'a' was not declared in this scope
   54 |         cin>>a[i]>>b[i];
      |              ^
a.cc:54:20: error: 'b' was not declared in this scope
   54 |         cin>>a[i]>>b[i];
      |                    ^
a.cc:55:9: error: 'edge' was not declared in this scope
   55 |         edge[a[i]].push_back(b[i]);
      |         ^~~~
a.cc:60:13: error: 'edge' was not declared in this scope
   60 |         tmp=edge[i+1].size();
      |             ^~~~
a.cc:61:11: error: 'max' was not declared in this scope
   61 |         M=max(M,tmp);
      |           ^~~
a.cc:64:5: error: 'cout' was not declared in this scope
   64 |     cout<<M<<endl;
      |     ^~~~
a.cc:64:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:64:14: error: 'endl' was not declared in this scope
   64 |     cout<<M<<endl;
      |              ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
a.cc:66:12: error: 'a' was not declared in this scope
   66 |         if(a[i]<b[i])cout<<e[mp(a[i],b[i])]<<endl;
      |            ^
a.cc:66:17: error: 'b' was not declared in this scope
   66 |         if(a[i]<b[i])cout<<e[mp(a[i],b[i])]<<endl;
      |                 ^
a.cc:66:28: error: 'e' was not declared in this scope
   66 |         if(a[i]<b[i])cout<<e[mp(a[i],b[i])]<<endl;
      |                            ^
a.cc:15:12: error: 'make_pair' was not declared in this scope
   15 | #define mp make_pair
      |            ^~~~~~~~~
a.cc:66:30: note: in expansion of macro 'mp'
   66 |         if(a[i]<b[i])cout<<e[mp(a[i],b[i])]<<endl;
      |                              ^~
a.cc:15:12: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
   15 | #define mp make_pair
      |            ^~~~~~~~~
a.cc:66:30: note: in expansion of macro 'mp'
   66 |         if(a[i]<b[i])cout<<e[mp(a[i],b[i])]<<endl;
      |                              ^~
a.cc:67:20: error: 'e' was not declared in this scope
   67 |         else cout<<e[mp(b[i],a[i])]<<endl;
      |                    ^
a.cc:15:12: error: 'make_pair' was not declared in this scope
   15 | #define mp make_pair
      |            ^~~~~~~~~
a.cc:67:22: note: in expansion of macro 'mp'
   67 |         else cout<<e[mp(b[i],a[i])]<<endl;
      |                      ^~
a.cc:15:12: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
   15 | #define mp make_pair
      |            ^~~~~~~~~
a.cc:67:22: note: in expansion of macro 'mp'
   67 |         else cout<<e[mp(b[i],a[i])]<<endl;
      |                      ^~