Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define mp make_pair
signed main(){
  int N; cin>>N;
  vector<vector<pii>> A(N);
  rep(i,0,N-1){
    int X,Y; cin>>X>>Y;
    A[X-1].push_back(mp(Y-1,i));
    A[Y-1].push_back(mp(X-1,i));
  }
  vi ans(N-1,-1);
  queue<int> Q;
  int Max=0;
  rep(i,0,N) Max=max(Max,A[i].size());
  cout<<Max<<endl;
  Q.push(mp(0,MOD));
  while(Q.size()>0){
    int X=Q.front();
    Q.pop();
    int memo=1;
    rep(i,0,A[X].size()){
      int O=A[X][i].first,P=A[X][i].second;
      if(ans[P]==-1){
        ans[P]=memo;
        Q.push(O);
      }
      else
        memo++;
      memo++;
    }
  }
  rep(i,0,N-1) cout<<ans[i]<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:27:21: error: no matching function for call to 'max(long long int&, std::vector<std::pair<long long int, long long int> >::size_type)'
   27 |   rep(i,0,N) Max=max(Max,A[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:27:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'})
   27 |   rep(i,0,N) Max=max(Max,A[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:27:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   27 |   rep(i,0,N) Max=max(Max,A[i].size());
      |                  ~~~^~~~~~~~~~~~~~~~~
a.cc:29:9: error: no matching function for call to 'std::queue<long long int>::push(std::pair<int, int>)'
   29 |   Q.push(mp(0,MOD));
      |   ~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157:
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >; value_type = long long int]'
  283 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:30: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const std::queue<long long int>::value_type&' {aka 'const long long int&'}
  283 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = long long int; _Sequence = std::deque<long long int, std::allocator<long long int> >; value_type = long long int]'
  288 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:25: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::queue<long long int>::value_type&&' {aka 'long long int&&'}
  288 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~