criyle/codenet-compile-errors huggingface dataset:
Language: C++

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static List<Integer>[] adj;
	static List<Integer>[] used;
	static int[] root;
	static int[] color;
	static int cMax = 1;

	static void dfs(int v, int prev) {
		int c = 1;
		for (int next : adj[v]) {
			if (next == prev)
				continue;
			root[next] = v;
			while (used[v].contains(c))
				c++;
			color[next] = c;
			used[v].add(c);
			used[next].add(c);
			if (c > cMax)
				cMax = c;
			dfs(next, v);
		}
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		adj = new List[n];
		used = new List[n];
		root = new int[n];
		color = new int[n];
		for (int i = 0; i < n; i++) {
			adj[i] = new ArrayList<Integer>();
			used[i] = new ArrayList<Integer>();
		}

		int[][] edges = new int[n - 1][2];
		for (int i = 0, a, b; i < n - 1; i++) {
			a = scanner.nextInt() - 1;
			b = scanner.nextInt() - 1;
			edges[i][0] = a;
			edges[i][0] = b;
			adj[a].add(b);
			adj[b].add(a);
		}

		dfs(0, -1);
		System.out.println(cMax);
		for (int i = 0, a, b; i < n - 1; i++) {
			a = edges[i][0];
			b = edges[i][1];
			System.out.println(root[b] == a ? color[b] : color[a]);
		}

	}

}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.ArrayList;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.List;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main {
      | ^~~~~~
Language: C++

#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int getmin(bitset<100001>& a) {
	for (int i = 1;; i++) {
		if (!a[i])return i;
	}
}
void dfs(int pos, int prev, vector<vector<pair<int, int>>>& T, vector<int>& col) {
	bitset<100001> *e_ = new bitset<100001>();
        auto e = *e_;
	for (int i = 0; i < T[pos].size(); i++) {
		if (col[T[pos][i].second] != INF)e[col[T[pos][i].second]] = true;
	}
	for (int i = 0; i < T[pos].size(); i++) {
		if (T[pos][i].first == prev)continue;
		int c;
		for (int i = 1;; i++) {
			if (e[i] != true) {
				c = i;
				break;
			}
		}
		col[T[pos][i].second] = c;
		e->set(c);
		dfs(T[pos][i].first, pos, T, col);
	}
        delete e_;
}
int main() {
	int N;
	cin >> N;
	vector<vector<pair<int, int>>> T(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		T[a].push_back({ b,i });
		T[b].push_back({ a,i });
	}
	vector<int> col(N - 1, INF);
	dfs(0, -1, T, col);
	cout << *max_element(col.begin(), col.end()) << endl;
	for (int i = 0; i < N - 1; i++) {
		cout << col[i] << endl;
	}
}


Compiler output:
a.cc: In function 'void dfs(int, int, std::vector<std::vector<std::pair<int, int> > >&, std::vector<int>&)':
a.cc:34:18: error: base operand of '->' has non-pointer type 'std::bitset<100001>'
   34 |                 e->set(c);
      |                  ^~
Language: C++

#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
int getmin(bitset<200001>& a) {
	for (int i = 1;; i++) {
		if (!a[i])return i;
	}
}
void dfs(int pos, int prev, vector<vector<pair<int,int>>>& T, vector<int>& col) {
	bitset<200001> e;
	for (int i = 0; i < T[pos].size(); i++) {
		if (col[T[pos][i].second] != INF)e[col[T[pos][i].second]] = true;
	}
	for (int i = 0; i < T[pos].size(); i++) {
		if (T[pos][i].first == prev)continue;
		int c;
      	for (int i = 1;; i++) {
			if (!a[i]){
              c = i;
              break;
            }
		}
		col[T[pos][i].second] = c;
		e.set(c);
		dfs(T[pos][i].first, pos, T, col);
	}
}
int main() {
	int N;
	cin >> N;
	vector<vector<pair<int,int>>> T(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		T[a].push_back({ b,i });
		T[b].push_back({ a,i });
	}
	vector<int> col(N-1,INF);
	dfs(0, -1, T, col);
	cout << *max_element(col.begin(), col.end()) << endl;
	for (int i = 0; i < N-1; i++) {
		cout << col[i] << endl;
	}
}

Compiler output:
a.cc: In function 'void dfs(int, int, std::vector<std::vector<std::pair<int, int> > >&, std::vector<int>&)':
a.cc:24:30: error: 'a' was not declared in this scope
   24 |                         if (!a[i]){
      |                              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int edge[100010][100010];
vector<bool> seen;  // 訪問済みの点

// BFSのための再帰関数
void bfs(const Graph &G, int v, int color, int k) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        color = (color + 1) % k;
        if (seen[next_v]) continue;
        edge[v][next_v] = color;
        bfs(G, next_v, color, k);
    }
}

int main()
{
    int N;
    cin >> N;

    // グラフ
    Graph G(N);

    vector<int> A(N-1);
    vector<int> B(N-1);

    seen.assign(N, false);
    
    REP(i, N-1){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
        A[i] = a-1;
        B[i] = b-1;
    }
    int K = 0;
    int index = 0;

    // 次数が最も高い頂点を探索
    REP(i, N){
        int size;
        size = G[i].size();
        if(size >= K){
            K = size;
            index = i;
        }
    }

    bfs(G, index, 0, K);

    cout << K << endl;
    REP(i, N-1){
        cout << edge[A[i]][B[i]] + 1 << endl;
    }
    return 0;
}

Compiler output:
/tmp/ccSeae71.o: in function `bfs(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, int, int, int)':
a.cc:(.text+0x20): relocation truncated to fit: R_X86_64_PC32 against symbol `seen' defined in .bss section in /tmp/ccSeae71.o
a.cc:(.text+0xac): relocation truncated to fit: R_X86_64_PC32 against symbol `seen' defined in .bss section in /tmp/ccSeae71.o
/tmp/ccSeae71.o: in function `main':
a.cc:(.text+0x20e): relocation truncated to fit: R_X86_64_PC32 against symbol `seen' defined in .bss section in /tmp/ccSeae71.o
/tmp/ccSeae71.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x509): relocation truncated to fit: R_X86_64_PC32 against symbol `seen' defined in .bss section in /tmp/ccSeae71.o
a.cc:(.text+0x522): relocation truncated to fit: R_X86_64_PC32 against symbol `seen' defined in .bss section in /tmp/ccSeae71.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define ins insert
#define ft front()
#define bk back()
#define f first
#define s second
#define trav(a,x) for(auto& a : x)
#define ALL(x) (x).begin(), (x).end()

const int MOD = 1000000007;
const int MX = 2e5+2;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);
const pi dir[4] = {{1,0}, {0,1}, {-1,0}, {0,-1}};

// -----------

int n, a, b, k;
vi adj[100001];
set<int> colors[100001];
int ans[100001];
int k;

int main(){
    IOS;
    cin >> n;
    k = 0;
    F0R(i,n-1){
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
        int currColor = 1;
        while (true){
            k = max(k, currColor);
            if(!(colors[a].count(currColor)) && !(colors[b].count(currColor))){
                ans[i] = currColor;
                colors[a].ins(currColor);
                colors[b].ins(currColor);
                break;
            }
            currColor++;
        }
    }
    cout << k << endl;
    F0R(i,n-1){
        cout << ans[i] << endl;
    }
    
    return 0;
    // You should actually read the notes to self.
}

/* NOTES TO SELF:
    Int overflow? Array bounds?
    Edge cases? (n = 1, n = 0)
    Don't be dumbosity please pace yourself.
*/

Compiler output:
a.cc:44:5: error: redefinition of 'int k'
   44 | int k;
      |     ^
a.cc:40:14: note: 'int k' previously declared here
   40 | int n, a, b, k;
      |              ^
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vvll t(n,vll(0));
  vector<pll> pp(n-1);
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    t[a].pb(b);
    t[b].pb(a);
    pp[i]=mp(a,b);
  }
  map<pll,ll> m;
  queue<ll> que;
  vll cs(n,-1);
  que.pu(0);
  ll k=0;
  while(sz(que)){
    ll v=que.front();
    que.pop();
    k=max(sz(t[v]),k);
    ll cu=1;
    for(ll p:t[v]){
      if(cs[p]!=-1)continue;
      if(cs[v]==cu) cu++;
      cs[p]=m[pll(v,p)]=m[pll(p,v)]=cu;
      cu++;
      queue.pu(p);
    }
  }
  COUT(k);
  rep(i,n-1){
    COUT(m[pp[i]]);
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:12: error: expected unqualified-id before '.' token
   71 |       queue.pu(p);
      |            ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;

int main() {
  int n, m = 0, r;
  cin >> n;
  v2i v(n);
  vector<pii> s;
  vector<unordered_set<int>> u(n);
  map<pii, int> c;
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    s.push_back({min(a-1, b-1), max(a-1, b-1)});
    v[a-1].push_back(b-1);
    v[b-1].push_back(a-1);
  }
  rep(i, n){
    if(m < v[i].size()){
      m = v[i].size();
      r = i;
    }
  }
  deque<int> d;
  d.push_back(r);
  int tmp = r, tc = 1;
  v1b ch(n, 1); ch[r] = 0;
  while(!d.empty()){
    d.pop_front();
    for(int b: v[tmp]){
      if(ch[b]){
        ch[b] = 0;
        d.push_back(b);
        while(!u[i].count(tc)){
          ++tc;
          tc = (tc-1) % m + 1;
        }
        c[{min(tmp, b), max(tmp, b)}] = tc;
      }
    }
    tmp = d.front();
    tc = 1;
  }
  cout << m << endl;
  rep(i, s.size()) cout << c[s[i]] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:18: error: 'i' was not declared in this scope
   59 |         while(!u[i].count(tc)){
      |                  ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using Graph = vector<vector<int>>;
ll k = -1;
map<P, int> ans;

void dfs(const Graph &G, int v, int p, int e){
    ll now = 1;
    for(auto nv : G[v]){
        if(nv == p)continue;
        if(now == e)now++;
        P p = make_pair(min(v, nv), max(v, nv));
      　ans[p] = now;
        k = max(k, now);
        dfs(G, nv, v, now);
        now++;
    }
}

int main() {
    int n;
    cin >> n;
    Graph G(n);
    vector<int> a(n-1), b(n-1);
    rep(i, n-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    dfs(G, 0, -1, -1);
    cout << k << endl;
    rep(i, n-1){
        cout << ans[make_pair(a[i], b[i])] << endl;
    }
}


Compiler output:
a.cc:25:7: error: extended character 　 is not valid in an identifier
   25 |       　ans[p] = now;
      |       ^
a.cc: In function 'void dfs(const Graph&, int, int, int)':
a.cc:25:7: error: '\U00003000ans' was not declared in this scope
   25 |       　ans[p] = now;
      |       ^~~~~
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vector<set<ll>> t(n+1,set<ll> );
  vector<pll> p(n-1);
  vll a(n+1);
  rep(i,n-1){
    ll c,b;
    cin>>c>>b;
    a[c]++;
    a[b]++;
    p[i]=mp(c,b);
  }
  ll ans=0;
  rep(i,n+1){
    ans=max(ans,a[i]);
  }
  COUT(ans);
  rep(i,n-1){
     for(int u=1;u<=ans;u++){
       if(!t[p[i].F].count(u)&&!t[p[i].S].count(u)){
         COUT(u);
         t[p[i].F].insert(u);
         t[p[i].S].insert(u);
       }
     }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:33: error: expected primary-expression before ')' token
   45 |   vector<set<ll>> t(n+1,set<ll> );
      |                                 ^
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vector<set<ll>> t(n+1,set<ll>));
  vector<pll> p(n-1);
  vll a(n+1);
  rep(i,n-1){
    ll c,b;
    cin>>c>>b;
    a[c]++;
    a[b]++;
    p[i]=mp(c,b);
  }
  ll ans=0;
  rep(i,n+1){
    ans=max(ans,a[i]);
  }
  COUT(ans);
  rep(i,n-1){
     for(int u=1;u<=ans;u++){
       if(!t[p[i].F].count(u)&&!t[p[i].S].count(u)){
         COUT(u);
         t[p[i].F].insert(u);
         t[p[i].S].insert(u);
       }
     }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:32: error: expected primary-expression before ')' token
   45 |   vector<set<ll>> t(n+1,set<ll>));
      |                                ^
a.cc:45:33: error: expected ',' or ';' before ')' token
   45 |   vector<set<ll>> t(n+1,set<ll>));
      |                                 ^
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vector<set<ll>> t(n+1,set<ll>);
  vector<pll> p(n-1);
  vll a(n+1);
  rep(i,n-1){
    ll c,b;
    cin>>c>>b;
    a[c]++;
    a[b]++;
    p[i]=mp(c,b);
  }
  ll ans=0;
  rep(i,n+1){
    ans=max(ans,a[i]);
  }
  COUT(ans);
  rep(i,n-1){
     for(int u=1;u<=ans;u++){
       if(!t[p[i].F].count(u)&&!t[p[i].S].count(u)){
         COUT(u);
         t[p[i].F].insert(u);
         t[p[i].S].insert(u);
       }
     }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:32: error: expected primary-expression before ')' token
   45 |   vector<set<ll>> t(n+1,set<ll>);
      |                                ^
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vector<set<ll>> t(n+1,set<ll>);
  vector<pll> p(n-1);
  vll a(n+1);
  rep(i,n-1){
    ll c,b;
    cin>>c>>b;
    a[c]++;
    a[b]++;
    p[i]=mp(c,b);
  }
  ll ans=0;
  rep(i,n+1){
    ans=max(ans,a[i]);
  }
  COUT(ans);
  rep(i,n-1){
     for(int u=1;u<=ans;u++){
       if(!t[p.F].count(u)&&!t[p.S].count(u)){
         COUT(u);
         t[p.F].insert(u);
         t[p.S].insert(u);
       }
     }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:32: error: expected primary-expression before ')' token
   45 |   vector<set<ll>> t(n+1,set<ll>);
      |                                ^
a.cc:15:11: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'first'
   15 | #define F first
      |           ^~~~~
a.cc:62:16: note: in expansion of macro 'F'
   62 |        if(!t[p.F].count(u)&&!t[p.S].count(u)){
      |                ^
a.cc:16:11: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'second'
   16 | #define S second
      |           ^~~~~~
a.cc:62:34: note: in expansion of macro 'S'
   62 |        if(!t[p.F].count(u)&&!t[p.S].count(u)){
      |                                  ^
a.cc:15:11: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'first'
   15 | #define F first
      |           ^~~~~
a.cc:64:14: note: in expansion of macro 'F'
   64 |          t[p.F].insert(u);
      |              ^
a.cc:16:11: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'second'
   16 | #define S second
      |           ^~~~~~
a.cc:65:14: note: in expansion of macro 'S'
   65 |          t[p.S].insert(u);
      |              ^
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vector<set<ll>> t(n+1,set<ll>);
  vector<pll> p(n-1);
  vll a(n+1);
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    a[a]++;
    a[b]++;
    p[i]=mp(a,b);
  }
  ll ans=0;
  rep(i,n+1){
    ans=max(ans,a[i]);
  }
  COUT(ans);
  rep(i,n-1){
     for(int u=1;u<=ans;u++){
       if(!t[p.F].count(u)&&!t[p.S].count(u)){
         COUT(u);
         t[p.F].insert(u);
         t[p.S].insert(u);
       }
     }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:32: error: expected primary-expression before ')' token
   45 |   vector<set<ll>> t(n+1,set<ll>);
      |                                ^
a.cc:51:6: error: invalid types 'long long int[long long int]' for array subscript
   51 |     a[a]++;
      |      ^
a.cc:52:6: error: invalid types 'long long int[long long int]' for array subscript
   52 |     a[b]++;
      |      ^
a.cc:15:11: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'first'
   15 | #define F first
      |           ^~~~~
a.cc:62:16: note: in expansion of macro 'F'
   62 |        if(!t[p.F].count(u)&&!t[p.S].count(u)){
      |                ^
a.cc:16:11: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'second'
   16 | #define S second
      |           ^~~~~~
a.cc:62:34: note: in expansion of macro 'S'
   62 |        if(!t[p.F].count(u)&&!t[p.S].count(u)){
      |                                  ^
a.cc:15:11: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'first'
   15 | #define F first
      |           ^~~~~
a.cc:64:14: note: in expansion of macro 'F'
   64 |          t[p.F].insert(u);
      |              ^
a.cc:16:11: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'second'
   16 | #define S second
      |           ^~~~~~
a.cc:65:14: note: in expansion of macro 'S'
   65 |          t[p.S].insert(u);
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("in.txt","r",stdin);
    map< int,map< int,int > > vertex;
    map< int,map< int,int > >::iterator it;
    map< int,int >::iterator ptr;
    int n,x,y;
    cin >> n;
    vector< int > edge(n,0);
    map< int,map< int,bool > > color;
    for(int i=0;i<n-1;i++){
        cin >> x >> y;
        x--,y--;
        edge[x]++;
        edge[y]++;a
        vertex[x][y] = 0;
    }
    sort(edge.begin(),edge.end());
    int m = edge[n-1];
    for(it = vertex.begin();it != vertex.end();it++){
        int first = it->first;
        for(ptr = it->second.begin();ptr != it->second.end();ptr++){
            int second = ptr->first;
            for(int i=1;i<=m;i++){
                if(color[first][i]==false && color[second][i]==false){
                    color[first][i]=true;
                    color[second][i]=true;
                    vertex[first][second] = i;
                    break;
                }
            }
        }
    }
    cout << m << endl;
    for(it = vertex.begin();it != vertex.end();it++){
        int first = it->first;
        for(ptr = it->second.begin();ptr != it->second.end();ptr++){
            int second = ptr->first;
            cout << vertex[first][second] << endl;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:19: error: 'a' was not declared in this scope
   17 |         edge[y]++;a
      |                   ^
Language: Java

import java.io.*;
import java.util.*;

public class Main {

	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	public static List<Integer>[] edges;
	public static long[] fac,inv;
	public static int mod = (int) (1e9+7),MAX = (int) (1e5+1);
	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc = new FastReader();
	
	
		int n = sc.nextInt();
		edges = new ArrayList[n+1];
		for(int i=0;i<=n;++i) edges[i] = new ArrayList<>();
		int k = 0;
		List<Pair> list = new ArrayList<>();
		for(int i=1;i<n;++i) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			edges[u].add(v);
			edges[v].add(u);
			list.add(new Pair(u,v));
			k = Math.max(k, Math.max(edges[u].size(), edges[v].size()));
		}
	
		int[] col = bfs(n);
		out.println(k);
		for(int i=0;i<list.size();++i) out.println(col[list.get(i).v]);
		
        out.close();
		
	}
	
	private static int[] bfs(int n) {
		int[] col = new int[n+1];
		Queue<Integer> q = new ArrayDeque<>();
		q.add(1);
		boolean[] vis = new boolean[col.length];
		vis[1] = true;
		while(q.size() > 0) {
			int node = q.poll();
			int c = 1;
			for(int v : edges[node]) {
				if(!vis[v]) {
					if(c == col[node]) ++c;
					col[v] = c++;
					vis[v] = true;
					q.add(v);
					set.add(new Pair(node,v));
				}
			}
		}
		
		return col;
	}
	
	static class Pair implements Comparable<Pair>{
		int u;
		int v;
		int c;
		Pair(int u,int v){
			this.u = u;
			this.v = v;
		}
		@Override
		public int compareTo(Pair arg0) {
			// TODO Auto-generated method stub
			return this.u - arg0.u;
		}
	}
	
}


Compiler output:
Main.java:107: error: cannot find symbol
					set.add(new Pair(node,v));
					^
  symbol:   variable set
  location: class Main
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define MAX_N 1000010
using namespace std;

//辺の塗り分けの最小値 = 出次数の最大値 = max(k,G[u].size())

// 節点uに対し時節点vの色は 1,2,~,G[u].size()
//ただし、節点uの色以外 if(c[u] == cur(=c[v])) cur++;
//組み合わせ(辺) (u,v)の色(cur)を保存 map<P,int> ec
//c[v = 0~G[u].size()] = cur++;
//ただし(c[u] == c[v](=cur) ) cur++;
//e_c[u,v] = ec[v,c] = cur;

int main(){
    int n;
    cin>>n;
    vector<vector<int>> G(n);
    bool visited[n-1];
    vector<int> c(n,0);
    vector<P> e;
    map<P,int> ec;
    
    for(int i=0; i<(n-1); i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        e.push_back(a,b);
    }

    int k = 0;
    visited[0] = true;
    queue<int> que;
    que.push(0);

    while(!que.empty()){
        int u = que.front(); que.pop();

        if( k< (int)G[u].size() ) k = G[u].size();
        int cur =1;

        for(int j = 0;j<G[u].size();j++){
            int v =G[u][j];
            if(visited[v]) continue;
            if(c[u] == cur) cur++;
            c[v] = ec[make_pair(u,v)] = ec[make_pair(v,u)] = cur++;
            que.push(v);
            visited[v] = true;
        }
    }

    cout<< k <<endl;
    for(int i = 0; i<e.size(); i++){
        int ans = ec[e[i]];
        cout<< ans <<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:20: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&, int&)'
   31 |         e.push_back(a,b);
      |         ~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note:   candidate expects 1 argument, 2 provided
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define MAX_N 1000010
#define push emplace
using namespace std;

//辺の塗り分けの最小値 = 出次数の最大値 = max(k,G[u].size())

// 節点uに対し時節点vの色は 1,2,~,G[u].size()
//ただし、節点uの色以外 if(c[u] == cur(=c[v])) cur++;
//組み合わせ(辺) (u,v)の色(cur)を保存 map<P,int> ec
//c[v = 0~G[u].size()] = cur++;
//ただし(c[u] == c[v](=cur) ) cur++;
//e_c[u,v] = ec[v,c] = cur;

int main(){
    int n;
    cin>>n;
    vector<vector<int>> G(n);
    bool visited[n-1];
    vector<int> c(n,0);
    vector<P> e;
    map<P,int> ec;
    
    for(int i=0; i<(n-1); i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        e.push_back(a,b);
    }

    int k = 0;
    visited[0] = true;
    queue<int> que;
    que.push(0);

    while(!que.empty()){
        int u = que.front(); que.pop();

        if( k< (int)G[u].size() ) k = G[u].size();
        int cur =1;

        for(int j = 0;j<G[u].size();j++){
            int v =G[u][j];
            if(visited[v]) continue;
            if(c[u] == cur) cur++;
            c[v] = ec[make_pair(u,v)] = ec[make_pair(v,u)] = cur++;
            que.push(v);
            visited[v] = true;
        }
    }

    cout<< k <<endl;
    for(int i = 0; i<e.size(); i++){
        int ans = ec[e[i]];
        cout<< ans <<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:20: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&, int&)'
   32 |         e.push_back(a,b);
      |         ~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note:   candidate expects 1 argument, 2 provided
Language: C++

N=int(input())
ab=[list(map(int, input().split())) for _ in range(N-1)]
ans=[0 for _ in range(N-1)]

def dfs(v, c=-1, p=-1):
  k=1
  for i in range(len(to[v])):
    u, id=to[v][i]
    if u==p:
      continue
    if k==c:
      k+=1
    ans[id]=k
    k+=1
    dfs(u, ans[id], v)

to=[[] for _ in range(N)]
for i in range(N-1):
  a, b=ab[i][0]-1, ab[i][1]-1
  to[a].append([b, i])
  to[b].append([a, i])

dfs(0)
print(max(ans))
for a in ans:
  print(a)
               

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N=int(input())
      | ^
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1001001001;
using namespace std;
vector<int> g[100005];
int c[100005][100005];
int cc = 0;
void dfs(int n, int p, int pc) {
    int ref = 1;
    for(auto i: g[n]) {
        if (i == p) continue;
        if (ref == pc) ref++;
        c[n][i] = ref;
        c[i][n] = ref;
        dfs(i, n, ref);
        ref++;
    }
    chmax(cc, ref-1);
}

int main(){
    int N;
    cin >> N;
    int a[N], b[N];
    rep(i, N-1) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }

    dfs(0, -1, 0);
    cout << cc << endl;
    rep(i, N-1){
        cout << c[a[i]][b[i]] << endl;
    }

}

Compiler output:
/tmp/cckRshgE.o: in function `dfs(int, int, int)':
a.cc:(.text+0x122): relocation truncated to fit: R_X86_64_PC32 against symbol `cc' defined in .bss section in /tmp/cckRshgE.o
/tmp/cckRshgE.o: in function `main':
a.cc:(.text+0x331): relocation truncated to fit: R_X86_64_PC32 against symbol `cc' defined in .bss section in /tmp/cckRshgE.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1001001001;
using namespace std;
vector<int> G[100005];
int c[100005][100005];
int cc = 0;
void dfs(int n, int p, int pc) {
    int ref = 1;
    for(auto i: G[n]) {
        if (i == p) continue;
        if (ref == pc) ref++;
        c[n][i] = ref;
        c[i][n] = ref;
        dfs(i, n, ref);
        ref++;
    }
    chmax(cc, ref-1);
}

int main(){
    int N;
    cin >> N;
    int a[N], b[N];
    rep(i, N-1) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }

    dfs(0, -1, 0);
    cout << cc << endl;
    rep(i, N-1){
        cout << c[a[i]][b[i]] << endl;
    }

}


Compiler output:
/tmp/cc47K3zv.o: in function `dfs(int, int, int)':
a.cc:(.text+0x122): relocation truncated to fit: R_X86_64_PC32 against symbol `cc' defined in .bss section in /tmp/cc47K3zv.o
/tmp/cc47K3zv.o: in function `main':
a.cc:(.text+0x331): relocation truncated to fit: R_X86_64_PC32 against symbol `cc' defined in .bss section in /tmp/cc47K3zv.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1001001001;
using namespace std;
vector<int> G[100005];
int c[100005][100005];
int cc = 0;
void dfs(int n, int p, int pc) {
    int ref = 1;
    for(auto i: G[n]) {
        if (i == p) continue;
        if (ref == pc) ref++;
        c[n][i] = ref;
        c[i][n] = ref;
        dfs(i, n, ref);
        ref++;
    }
    chmax(cc, ref-1);
}

int main(){
    int N;
    cin >> N;
    int a[N], b[N];
    rep(i, N-1) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }

    dfs(0, -1, 0);
    cout << cc << endl;
    rep(i, N-1){
        cout << c[a[i]][b[i]] << endl;
    }

}

Compiler output:
/tmp/ccsAwUbK.o: in function `dfs(int, int, int)':
a.cc:(.text+0x122): relocation truncated to fit: R_X86_64_PC32 against symbol `cc' defined in .bss section in /tmp/ccsAwUbK.o
/tmp/ccsAwUbK.o: in function `main':
a.cc:(.text+0x331): relocation truncated to fit: R_X86_64_PC32 against symbol `cc' defined in .bss section in /tmp/ccsAwUbK.o
collect2: error: ld returned 1 exit status
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,(int)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: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,
                 from a.cc:1:
/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)
      |            ~~~~~~~~~~~~~^~~
Language: C

#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define N 100000
#define max(a, b) (a > b ? a : b)

typedef struct queue
{
  int a;
  int b;
  struct queue *next;
} queue;

//first element
queue *queue_init()
{
  queue *q = malloc(sizeof(queue));
  q->next = NULL;
  return q;
}

queue *queue_create(int a, int b)
{
  queue *q = malloc(sizeof(queue));
  q->a = a;
  q->b = b;
  q->next = NULL;
  return q;
}

void queue_free(queue *q)
{
  if (q != NULL)
    free(q);
}

bool queue_empty(queue *q)
{
  if (q->next == NULL)
    return true;
  return false;
}

queue *queue_back(queue *q)
{
  if (queue_empty(q))
    return q;
  return queue_back(q->next);
}

queue *queue_front(queue *q)
{
  if (queue_empty(q))
    return NULL;
  return q->next;
}

void queue_pop(queue *q)
{
  if (queue_empty(q))
    return;
  queue *qnext = q->next;
  q->next = qnext->next;
  queue_free(qnext);
}

void queue_push(queue *q, int a, int b) { queue_back(q)->next = queue_create(a, b); }

int queue_size(queue *q)
{
  if (queue_empty(q))
    return 0;
  return queue_size(q->next) + 1;
}

typedef struct node{
  int value;
  queue *edge;
}node;

node t[N];
int color[N], pc[N];

void _init(int n) {
  for (int i = 0; i < n; i++)
  {
    t[i].value = i + 1;
    t[i].edge = queue_init();
  }
  for (int i=0; i<n-1; i++) {
    color[i] = 0;
    pc[i] = 0;
  }
  return ;
}

void _free(int n) {
  for (int i = 0; i < n; i++)
    free(t[i].edge);
  return ;
}

void dfs(int a) {
  int c = 1;
  while (!queue_empty(t[a].edge))
  {
    queue *front = queue_front(t[a].edge);
    if (color[front->b] == 0)
    {
      if (pc[a] == c)
        c++;
      color[front->b] = c;
      pc[front->a] = c;
      c++;
      dfs(front->a);
    }
    queue_pop(t[a].edge);
  }
}

int main() {
  int n;
  scanf("%d", &n);
  _init(n);
  int a, b, ans = 0;
  for (int i=0; i<n-1; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    queue_push(t[a].edge, b, i);
    queue_push(t[b].edge, a, i);
  }
  for (int i=0; i<n; i++)
    ans = max(ans, queue_size(t[i].edge));
  dfs(0);
  _free(n);
  printf("%d\n", ans);
  for (int i=0; i<n-1; i++)
    printf("%d\n", color[i]);
  return 0;
}


Compiler output:
/usr/bin/ld: /tmp/ccdKtKta.o: in function `_init':
main.c:(.text+0x1cc): multiple definition of `_init'; /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>

using namespace std;

int n, a[100005], b[100005], col[100005][100005], vis[100005], ans;
vector <int> G[100005];

void colo(int id, int deco) {
	vis[id] = 1;
	int k = 1;
	for (int u : G[id]) {
		if (vis[u]) continue;
		if (k == deco) k++;
		col[id][u] = k;
		col[u][id] = k;
		ans = max(k, ans);
	}
	for (int u : G[id]) {
		if (vis[u]) continue;
		colo(u, col[id][u]);
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i=0; i<n - 1; i++) {
		cin >> a[i] >> b[i];
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	colo(a[0], 0);
	cout << ans << endl;
	for (int i=0; i<n-1; i++) {
		cout << col[a[i]][b[i]] << endl;
	}
}

Compiler output:
/tmp/cccv9qOB.o: in function `colo(int, int)':
a.cc:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/cccv9qOB.o
a.cc:(.text+0x46): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cccv9qOB.o
a.cc:(.text+0x97): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/cccv9qOB.o
a.cc:(.text+0x114): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cccv9qOB.o
a.cc:(.text+0x127): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cccv9qOB.o
a.cc:(.text+0x16b): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cccv9qOB.o
a.cc:(.text+0x1b9): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/cccv9qOB.o
/tmp/cccv9qOB.o: in function `main':
a.cc:(.text+0x2fc): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cccv9qOB.o
a.cc:(.text+0x350): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cccv9qOB.o
a.cc:(.text+0x3a4): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cccv9qOB.o
/tmp/cccv9qOB.o: in function `__tcf_0':
a.cc:(.text+0x473): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status