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

#include<iostream>
#include<vector>
#include<queue>
#include<set>

using namespace std;

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

    vector< pair<int, int> > G[N];
    int num[N-1]; fill(num, num + N-1, 0);

    int k=0;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back({b, i});
        G[b].push_back({a, i});
        num[a]++;
        num[b]++;
    }
    int max_v = *max_element(num, num + N-1);

    queue< int > que;
    que.push(0);

    set<int> clr_set;
    for(int i=1; i<=max_v; i++){
        clr_set.insert(i);
    }

    set<int> clr[N];
    int ans[N-1]; fill(ans, ans + N-1, -1);
    ans[0] = 1;
    fill(clr, clr + N, clr_set);

    while(!que.empty()){
        int v = que.front(); que.pop();
        for(auto e : G[v]){
            if(ans[e.second] == -1){
                que.push(e.first);
                int use = *clr[v].begin();
                ans[e.second] =  use;
                clr[v].erase(use);
                clr[e.first].erase(use);
            }
        }
    }
    cout << max_v << endl;

    for(int i=0; i<N-1; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:18: error: 'max_element' was not declared in this scope
   25 |     int max_v = *max_element(num, num + N-1);
      |                  ^~~~~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<queue>
#include<set>

using namespace std;

typedef struct{
    int from;
    int to;
    int color;
} edge;

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

    vector< pair<int, int> > G[N];
    int num[N-1]; fill(num, num + N-1, 0);

    int k=0;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back({b, i});
        G[b].push_back({a, i});
        num[a]++;
        num[b]++;
    }
    int max_v = *max_element(num, num + N-1);

    queue< int > que;
    que.push(0);

    set<int> clr_set;
    for(int i=1; i<=max_v; i++){
        clr_set.insert(i);
    }

    set<int> clr[N];
    int ans[N-1]; fill(ans, ans + N-1, -1);
    fill(clr, clr + N, clr_set);

    while(!que.empty()){
        int v = que.front(); que.pop();
        for(auto e : G[v]){
            if(ans[e.second] == -1){
                que.push(e.first);
                int use = *clr[v].begin();
                ans[e.second] =  use;
                clr[v].erase(use);
                clr[e.first].erase(use);
            }
        }
    }
    cout << max_v << endl;

    for(int i=0; i<N-1; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:18: error: 'max_element' was not declared in this scope
   31 |     int max_v = *max_element(num, num + N-1);
      |                  ^~~~~~~~~~~
Language: C

#include <stdio.h>
#include <stdlib.h>

typedef struct list {
	int val;
	struct list *next;
} *list;

list cons (int car, list cdr) {
	list lst = (list)malloc(sizeof(struct list));
	lst->val = car;
	lst->next = cdr;
	return lst;
}

list insert (int val, list lst) {
	if (lst && lst->val < val) {
		lst->next = insert(val, lst->next);
		return lst;
	} else {
		return cons(val, lst);
	}
}

// ----

list used_colors[100001];
int color[100001];
int max_color;

int main (void) {
	int a, b, i;
	
	scanf("%*d\n");
	
	for (i = 1; ~scanf("%d %d\n", &a, &b); i++) {
		list l1 = used_colors[a];
		list l2 = used_colors[b];
		int j = 1;
		
		while (true) {
			if ((!l1 || l1->val > j) && (!l2 || l2->val > j)) {
				break;
			}
			if (l1 && l1->val == j) l1 = l1->next;
			if (l2 && l2->val == j) l2 = l2->next;
			j++;
		}
		
		if (max_color < j) max_color = j;
		color[i] = j;
		used_colors[a] = insert(j, used_colors[a]);
		used_colors[b] = insert(j, used_colors[b]);
	}
	
	printf("%d\n", max_color);
	
	for (i = 1; color[i]; i++) {
		printf("%d\n", color[i]);
	}
}


Compiler output:
main.c: In function 'main':
main.c:41:24: error: 'true' undeclared (first use in this function)
   41 |                 while (true) {
      |                        ^~~~
main.c:3:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    2 | #include <stdlib.h>
  +++ |+#include <stdbool.h>
    3 | 
main.c:41:24: note: each undeclared identifier is reported only once for each function it appears in
   41 |                 while (true) {
      |                        ^~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
const int maxn=1000005;
vector<int>G[maxn];
int in[maxn]={0};
int u1[maxn]={0};
int v1[maxn]={0};
map<pair<int,int>,int>mm;
int ans=0;
void dfs(int u,int color){
    int col=0;
    for(auto v:G[u]){
        col++;
        if(col==color)
            col++;
        mm[make_pair(u,v)]=col;
        dfs(v,col);
    }
    ans=max(ans,col);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int u,v;
    for(int i=0;i<n-1;i++){
        cin >> u1[i] >> v1[i];
        G[u1[i]].push_back(v1[i]);
        in[u1[i]]++;
        in[v1[i]]++;
    }
    //int ans=*max_element(in+1,in+n+1);
    dfs(1,0);
    cout << ans << endl;
    for(int i=0;i<n-1;i++){
        cout << mm[make_pair(u1[i],v1[i])] <<endl;
    }
    return 0;
}


Compiler output:
a.cc:7:1: error: 'vector' does not name a type
    7 | vector<int>G[maxn];
      | ^~~~~~
a.cc: In function 'void dfs(int, int)':
a.cc:15:16: error: 'G' was not declared in this scope
   15 |     for(auto v:G[u]){
      |                ^
a.cc: In function 'int main()':
a.cc:33:9: error: 'G' was not declared in this scope
   33 |         G[u1[i]].push_back(v1[i]);
      |         ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i<(int)n; ++i)
using namespace std;

vector<bool> seen;
vector<vector<int>> color;
int color_num = 1;

void dfs(const vector<vector<int>> &graph, vector<vector<int>> color, int v){
  seen[v] = true;
  for(auto next_v : graph[v]){
    if(seen[next_v] == true) continue;
    else{
      color.at(v).push_back(color_num);
      color.at(next_v).push_back(color_num);
      dfs(graph, next_v)
    }//todo
  }
}

int main(){
  int n; cin >> n;
  vector<vector<int>> graph(n);
  rep(i, n-1){
    int a, b; cin >> a >> b;
    graph.at(a-1).push_back(b-1);
    graph.at(b-1).push_back(a-1);
  }
  
  seen.assign(n, false);
  dfs(graph, color, 0);
  
  
}

Compiler output:
a.cc: In function 'void dfs(const std::vector<std::vector<int> >&, std::vector<std::vector<int> >, int)':
a.cc:16:18: error: could not convert 'next_v' from 'int' to 'std::vector<std::vector<int> >'
   16 |       dfs(graph, next_v)
      |                  ^~~~~~
      |                  |
      |                  int
a.cc: In function 'int main()':
a.cc:2:32: error: expected ';' before '<' token
    2 | #define rep(i,n) for(int i=0, i<(int)n; ++i)
      |                                ^
a.cc:24:3: note: in expansion of macro 'rep'
   24 |   rep(i, n-1){
      |   ^~~
a.cc:2:32: error: expected primary-expression before '<' token
    2 | #define rep(i,n) for(int i=0, i<(int)n; ++i)
      |                                ^
a.cc:24:3: note: in expansion of macro 'rep'
   24 |   rep(i, n-1){
      |   ^~~
Language: C++

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

int main(){
  int N;
  cin >> N;
  
  int k = 0;
  deque<int> Q;
  vector<vector<int>> v(N);
  vector<int> p(N);
  vecor<pair<int, int>> I;
  
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    v.at(a).emplace_back(b);
    v.at(b).emplace_back(a);
    p.at(b) = a;
    I.emplace_back((a, b));
    //T.at(a).c.push_back(b);
    //T.at(b).p = a;
    //y.at(i).first = a;
    //y.at(i).second = b;
  }
  
  for (int i = 0; i < N; i++) {
    int t = 0;
    for (int j : v.at(i)) {
      t++;
      k = max(k, t);
    }
  }
  
  map<pair<int, int>, int> M;
  
  Q.emplace_back(0);
  while(!Q.empty()) {
    
    
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'vecor' was not declared in this scope
   12 |   vecor<pair<int, int>> I;
      |   ^~~~~
a.cc:12:22: error: expected primary-expression before '>' token
   12 |   vecor<pair<int, int>> I;
      |                      ^~
a.cc:12:25: error: 'I' was not declared in this scope
   12 |   vecor<pair<int, int>> I;
      |                         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int edge[n+1][n+1];
  for(int i=0; i<n-1; i++){
    int a,b;
    cin >> a >> b;
    edge[a][b] = 1;
    edge[b][a] = 1;
  }
  int color[n+1];
  color[1] = 1;
  for(int i=2; i<=n; i++){
    target_color = 1;
    while(true){
      bool success = true;
      for(int j=1; j<=n; j++){
        if(edge[i][j] == 1 && target_color == color[j]){
          success = false;
        }
      }
      if(success){
        color[i] = target_color;
        break;
      }
      else{
        target_color++;
      }
    }
  }
  ans = 1;
  for(int i=2; i<=n; i++){
    ans = max(ans,color[i]);
  }
  cout << ans << endl;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: 'target_color' was not declared in this scope
   16 |     target_color = 1;
      |     ^~~~~~~~~~~~
a.cc:33:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |   ans = 1;
      |   ^~~
      |   abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int edge[n+1][n+1];
  for(int i=0; i<n-1; i++){
    int a,b;
    cin >> a >> b;
    edge[a][b] = 1;
    edge[b][a] = 1;
  }
  int color[n+1];
  color[1] = 1;
  for(int i=2; i<=n; i++){
    target_color = 1;
    while(true){
      bool success = true;
      for(int j=1; j<=n; j++){
        if(edge[i][j] == 1 && target_color == color[j]){
          success = false;
        }
      }
      if(success){
        color[i] = target_color;
        break;
      }
      else{
        target_color++;
      }
    }
  }
  ans = 1;
  for(int i=2; i<=n; i++){
    ans = max(ans,color[i]);
  }
  cout << ans << endl;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:4:12: error: 'n' was not declared in this scope; did you mean 'yn'?
    4 |   int edge[n+1][n+1];
      |            ^
      |            yn
a.cc:8:5: error: 'edge' was not declared in this scope
    8 |     edge[a][b] = 1;
      |     ^~~~
a.cc:12:3: error: 'color' was not declared in this scope
   12 |   color[1] = 1;
      |   ^~~~~
a.cc:14:5: error: 'target_color' was not declared in this scope
   14 |     target_color = 1;
      |     ^~~~~~~~~~~~
a.cc:18:12: error: 'edge' was not declared in this scope
   18 |         if(edge[i][j] == 1 && target_color == color[j]){
      |            ^~~~
a.cc:31:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |   ans = 1;
      |   ^~~
      |   abs
Language: C++

include<bits/stdc++.h>
using namespace std;
int main(){
  int edge[n+1][n+1];
  for(int i=0; i<n-1; i++){
    int a,b;
    cin >> a >> b;
    edge[a][b] = 1;
    edge[b][a] = 1;
  }
  int color[n+1];
  color[1] = 1;
  for(int i=2; i<=n; i++){
    target_color = 1;
    while(true){
      bool success = true;
      for(int j=1; j<=n; j++){
        if(edge[i][j] == 1 && target_color == color[j]){
          success = false;
        }
      }
      if(success){
        color[i] = target_color;
        break;
      }
      else{
        target_color++;
      }
    }
  }
  ans = 1;
  for(int i=2; i<=n; i++){
    ans = max(ans,color[i]);
  }
  cout << ans << endl;
}
    

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:4:12: error: 'n' was not declared in this scope
    4 |   int edge[n+1][n+1];
      |            ^
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin >> a >> b;
      |     ^~~
a.cc:8:5: error: 'edge' was not declared in this scope
    8 |     edge[a][b] = 1;
      |     ^~~~
a.cc:12:3: error: 'color' was not declared in this scope
   12 |   color[1] = 1;
      |   ^~~~~
a.cc:14:5: error: 'target_color' was not declared in this scope
   14 |     target_color = 1;
      |     ^~~~~~~~~~~~
a.cc:18:12: error: 'edge' was not declared in this scope
   18 |         if(edge[i][j] == 1 && target_color == color[j]){
      |            ^~~~
a.cc:31:3: error: 'ans' was not declared in this scope
   31 |   ans = 1;
      |   ^~~
a.cc:33:11: error: 'max' was not declared in this scope
   33 |     ans = max(ans,color[i]);
      |           ^~~
a.cc:35:3: error: 'cout' was not declared in this scope
   35 |   cout << ans << endl;
      |   ^~~~
a.cc:35:18: error: 'endl' was not declared in this scope
   35 |   cout << ans << endl;
      |                  ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<vector<int>> G(N);
  vector<pair<int,int>> vp;
  for(int i=1;i<N;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    vp.emplace_back(a,b);
  }
 
  int K=0;
  map<pair<int,int>,int> I;
  vector<int> cs(N,0); // color of edge between its parent
 
  vector<int> used(N,0);
  queue<int> que;
  used[0]=1;
  que.emplace(0);
  while(!que.empty()){
    int v=que.front();que.pop();
    if(K<(int)G[v].size()) K=G[v].size();
    int cur=1;
    for(int u:G[v]){
      if(used[u]) continue;
      if(cur==cs[v]) cur++;
      cs[u]=I[make_pair(u,v)]=I[make_pair(v,u)]=cur++;
      used[u]=1;
      que.emplace(u);
    }
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:37:4: error: expected '}' at end of input
   37 |   }
      |    ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

import java.util.*;

public class Main{
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static List<Integer>[] edge = new ArrayList[n];
    static int[] arr = new int[n];
    static boolean[] visit = new boolean[n];


    public static void main(String[] args){
//        Scanner sc = new Scanner(System.in);
//
//        int n = sc.nextInt();
//
//        List<Integer>[] edge = new ArrayList[n];

        if (n==2){
            System.out.println(1);
            System.out.println(1);
            return;
        }

        for (int i=0; i<n; i++){
            edge[i] = new ArrayList<>();
        }

        for (int i=0; i<n-1; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            edge[a].add(b);
            edge[b].add(a);
        }

        int k = 1;

        for (int i=0; i<n; i++){
            k = Math.max(k, edge[i].size());
        }

        System.out.println(k);
        arr[0] = 1;
        bfs();

        System.out.println(arr[0]);
        for (int i=1; i<n-1; i++){
            System.out.println(arr[i]);
        }
//        int[] arr = new int[n-1];
    }

    public static void bfs(){
        Queue<Integer> q = new ArrayDeque<>();
        ((ArrayDeque<Integer>) q).push(0);
        visit[0] = true;
        int tmp = 1;
        while (!q.isEmpty()){
            tmp = 1;
            int u = q.poll();
            for (int i=0; i<edge[u].size(); i++){
                int v = edge[u].get(i);
                if (visit[v]) continue;
                arr[v] = ++tmp;
                visit[v] = true;
                ((ArrayDeque<Integer>) q).push(v);
            }
        }
    }

}

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

#include <iostream>

using namespace std;

int main() {
    int n;
  	int a, b;
  	int g[n][n];
  	for(int i=0; i<n; ++i){
    	cin>>a>>b;
      	g[a-1][b-1]=1;
        g[b-1][a-1]=1;
    }
  	int tmp;
  	for(int i=0; i<n; ++i){
    	for(int j=0;j<n;++j)tmp += a[i][j];
      	cout<<n-tmp+1<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:37: error: invalid types 'int[int]' for array subscript
   16 |         for(int j=0;j<n;++j)tmp += a[i][j];
      |                                     ^
Language: C++

// #include <bits/stdc++.h>
#include </Users/rsuazo/bits/stdc++.h>

using namespace std;
using Long = long long;
typedef vector<int> VI;
typedef vector<VI> VII;

VII adj;
VI vis;
int numberOfColors = 0;
int currentNumberColor = 0;
vector<set<int>> colorsForNode;

void DFS(int u) {
  vis[u] = true;
  for(auto v: adj[u]) {
    if (vis[v]) continue;
    int colorForthisNode = (currentNumberColor % numberOfColors) + 1;
    if (colorsForNode[u].count(colorForthisNode) || colorsForNode[v].count(colorForthisNode)) {
      cout << colorForthisNode + 1 << endl;
      colorsForNode[u].insert(colorForthisNode + 1);
      colorsForNode[v].insert(colorForthisNode + 1);
    } else {
      colorsForNode[u].insert(colorForthisNode);
      colorsForNode[v].insert(colorForthisNode);
      cout << colorForthisNode << endl;
    }
    currentNumberColor++;
    DFS(v);
  }
}

int main (){
  int N;
  cin >> N;
  adj = VII(N);
  vis = VI(N, 0);
  colorsForNode = vector<set<int>>(N);
  for(int i = 0; i < N - 1; i++) {
    int u,v;
    cin >> u >> v;
    u--; v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  for (int i = 0; i < adj.size(); i++){
    numberOfColors = max(numberOfColors, (int)adj[i].size());
  }

  cout << numberOfColors << endl;
  DFS(0);

  return 0;
}


Compiler output:
a.cc:2:10: fatal error: /Users/rsuazo/bits/stdc++.h: No such file or directory
    2 | #include </Users/rsuazo/bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353 
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
int ans[100005];
map<P,int>id;
vector<int>edge[100005];
set<int>S[100005];
int mx;
void dfs(int v,int u){
    //cout << v << u << endl;
    int id = 0;;
	rep(i,edge[v].size()){
		if(edge[v][i] == u) continue;
		id++;
		int to = edge[v][i];
		for(int ii=id;ii<2000005;ii++) if(S[v].find(ii) == S[v].end()){
			int vv = id[P(min(to,v),max(to,v))]; //cout << v << to <<  endl;
			ans[vv] = ii;
			mx = max(mx,ii);
			S[v].insert(ii);
			S[to].insert(ii);
			break;
		}
		dfs(to,v);
	}
}
int main(){
	cin >> n;
	rep(i,n-1){
		int a,b; cin >> a >> b;
		if(a > b) swap(a,b);
		id[P(a,b)] = i+1;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	dfs(1,-1);
	cout << mx << endl;
	repn(i,n-1) printf("%d\n",ans[i]);
}


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:40:36: error: no match for 'operator[]' (operand types are 'int' and 'P' {aka 'std::pair<int, int>'})
   40 |                         int vv = id[P(min(to,v),max(to,v))]; //cout << v << to <<  endl;
      |                                    ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define N 1000010
#define LL long long
map<LL,int> p;
LL vis[N],res[N];
LL check(LL x)
{
    LL d;
    while(1)
    {
        d=x*N+vis[x];
        if(!p[d])
            return vis[x];
        ++vis[x];
    }
}
int main()
{
    int i,n;
    LL ans,x,y,k1,k2,d1,d2;
    scanf("%d",&n);
    ans=0;
    p.clear();
    for(i=1;i<=n;i++)
        vis[i]=1;
    for(i=1;i<n;i++)
    {
        scanf("%lld%lld",&x,&y);
        k1=check(x);
        k2=check(y);
        if(k1==k2)
        {
            vis[x]=k1+1;
            vis[y]=k1+1;
            res[i]=k1;
        }
        else
        if(k1<k2)
        {
            d1=x*N+k2;
            d2=y*N+k2;
            while(p[d1]||p[d2])
            {
                k2++;
                d1=x*N+k2;
                d2=y*N+k2;
            }
            p[d1]=1;
            p[d2]=1;
            vis[y]=k2+1;
            res[i]=k2;
        }
        else
        if(k1>k2)
        {
            d1=x*N+k1;
            d2=y*N+k1;
            while(p[d1]||p[d2])
            {
                k1++;
                d1=x*N+k1
                d2=y*N+k1;
            }
            p[d1]=1;
          	p[d2]=1;
            vis[x]=k1+1;
            res[i]=k1;
        }
        ans=max(ans,res[i]);
    }
    printf("%lld\n",ans);
    for(i=1;i<n;i++)
        printf("%lld\n",res[i]);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:26: error: expected ';' before 'd2'
   62 |                 d1=x*N+k1
      |                          ^
      |                          ;
   63 |                 d2=y*N+k1;
      |                 ~~
Language: Java


import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	class Pair{
		int s;
		int t;
		Pair(int s, int t){
			this.s=s;
			this.t=t;
		}
		@Override
		public String toString() {
			return "Pair [s=" + s + ", t=" + t + "]";
		}
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + s;
			result = prime * result + t;
			return result;
		}
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (s != other.s)
				return false;
			if (t != other.t)
				return false;
			return true;
		}
		private Main2 getOuterType() {
			return Main2.this;
		}

	}

	HashMap<Pair, Integer>I = new HashMap<>();
	int color[][];
	boolean used[];
	boolean next[][];
	int N;
	int K = 0;
	int cs[];
	public void run() {
		Scanner sc = new Scanner(System.in);
		N=sc.nextInt();
		ArrayList<ArrayList<Integer>> G = new ArrayList<ArrayList<Integer>>();
		ArrayList<Pair> vp = new ArrayList<Pair>();
		color=new int[N][N];
		used=new boolean[N];
		cs = new int[N];
		for(int i=0; i<N; i++) {
			G.add(new ArrayList<Integer>());
		}
		for(int i=0; i<N; i++) {
			for(int j=0; j<N; j++) {
				color[i][j]=0;
			}
			used[i]=false;
			cs[i]=0;
		}
		for(int i=0; i<N-1; i++) {
			int a = sc.nextInt();
			a--;
			int b = sc.nextInt();
			b--;
			G.get(a).add(b);
			G.get(b).add(a);
			vp.add(new Pair(a,b));
		}
		ArrayDeque<Integer> que = new ArrayDeque<Integer>();

		used[0]=true;
		que.add(0);
		while(!que.isEmpty()) {
			int v = que.poll();
			if(K < G.get(v).size()) {
				K = G.get(v).size();
			}
			int cur=1;
			for(int u : G.get(v)) {
				if(used[u]) {
					continue;
				}
				if(cur == cs[v]) {
					cur++;
				}
				cs[u] = cur;
				I.put(new Pair(u,v), cur);
				I.put(new Pair(v,u), cur);
				cur++;
				used[u]=true;
				que.add(u);
			}
		}
		System.out.println(K);
		for(Pair p : vp) {
			System.out.println(I.get(p));
		}
		sc.close();
	}


}

Compiler output:
Main.java:50: error: cannot find symbol
		private Main2 getOuterType() {
		        ^
  symbol:   class Main2
  location: class Main.Pair
Main.java:51: error: cannot find symbol
			return Main2.this;
			       ^
  symbol:   class Main2
  location: class Main.Pair
2 errors
Language: C++

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<int> graph[100010];
map<P, int> mp;
void dfs(int prev, int now, int color){
    /string to_str(ll A){
        stringstream ss;
        ss << A;
        return ss.str();
    }cout << "prev:" << prev << endl;
    int nextc = 1;
    for(auto next:graph[now]){
        if(next == prev)continue;
        if(nextc == color)nextc++;
        int a = now, b = next;
        if(a > b)swap(a,b);
        mp[P(a,b)] = nextc;
        dfs(now, next, nextc);
        nextc++;
    }
}
main(){
    int N;
    cin >> N;
    vector<P> E(N-1);
    rep(i,0,N-1)cin >> E[i].first >> E[i].second;
    rep(i,0,N-1){
        
        E[i].first--;
        E[i].second--;
        graph[E[i].first].push_back(E[i].second);
        graph[E[i].second].push_back(E[i].first);
    }
    
    dfs(-1, 0, -1);
    int maxi = 0;
    vector<int> ans(N-1);
    rep(i, 0, N - 1){
        ans[i] = mp[P(E[i].first, E[i].second)];
        maxi = max(maxi, ans[i]);
    }
    cout << maxi << endl;
    rep(i, 0, N - 1){
        cout << ans[i] << endl;
    }
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:11:5: error: expected primary-expression before '/' token
   11 |     /string to_str(ll A){
      |     ^
a.cc:11:13: error: expected primary-expression before 'to_str'
   11 |     /string to_str(ll A){
      |             ^~~~~~
a.cc: At global scope:
a.cc:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main(){
      | ^~~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;

typedef pair<int, int> Pa;
typedef long long ll;

set<int> used[100001];
int ans[100001];

int main() {
    vector<pair<ll, ll>> edge;
    cin >> N;
    rep(i, N-1){
        cin >> A >> B;
        edge.push_back(make_pair(A, B));
    }
    rep(i, N-1){
        int a = edge[i].first, b = edge[i].second;
        ll index = 1;
        while(true){
            if((used[a].find(index) == used[a].end()) && (used[b].find(index) == used[b].end())) break;
            index++;
        }
        max_value = max(max_value, index);
        used[a].insert(index);
        used[b].insert(index);
        ans[i] = index;
    }
    cout << max_value << endl;
    rep(i, N-1){
        cout << a[i] << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:17: error: 'a' was not declared in this scope
   36 |         cout << a[i] << endl;
      |                 ^
Language: C++

from collections import deque

n = int(input())
nodes = [[] for _ in range(n)]
edges = dict()
for _ in range(n - 1):
	a, b = map(int, input().split())
	nodes[a - 1].append(b - 1)
	nodes[b - 1].append(a - 1)
	edges[(a - 1, b - 1)] = 0

used = [False] * n
que = deque()
que.append(0)
while len(que) > 0:
	ni = que.pop()
	if used[ni]:
		continue
	used_colors = [edges[tuple(sorted((ni, e)))] for e in nodes[ni]]
	unused = [c for c in range(1, n + 1) if not c in used_colors]
	for node in nodes[ni]:
		[a, b] = sorted([ni, node])
		if edges[(a, b)] == 0:
			# print((a, b), unused)
			edges[(a, b)] = unused[0]
			unused = unused[1:]
			que.append(node)

	used[ni] = True

print(max(edges.values()))
print(*edges.values(), sep='\n')


Compiler output:
a.cc:24:27: error: invalid preprocessing directive #print
   24 |                         # print((a, b), unused)
      |                           ^~~~~
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int head[100010],Next[200010],tot,to[200010];
void ADD(int a,int b){
	tot++;
	Next[tot]=head[a];
	to[tot]=b;
	head[a]=tot;
}
void dfs(int now,int faco,int fa){
	int tmp=1;
	for(int i=head[now];)
}
int main(){
	int n;
	cin>>n;
	int a,b;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		ADD(a,b);
		ADD(b,a);
	}
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:12:29: error: expected primary-expression before ')' token
   12 |         for(int i=head[now];)
      |                             ^
a.cc:12:29: error: expected ';' before ')' token
   12 |         for(int i=head[now];)
      |                             ^
      |                             ;
a.cc:13:1: error: expected primary-expression before '}' token
   13 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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 = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N;
vector<vector<pair<int,int>>> G;
vector<int> color;

void dfs(int i, int pre, int pre_c){
    int cnt = 1;
    for(auto ni: G[i]){
        if(ni.first == pre)continue;
        if(cnt == pre_c){
            cnt++;
        }
        color[ni.second] = cnt;
        dfs(ni.first, i, color[ni.second]);
        cnt++;
    }
}

int main() {
    cin>>N;
    G.resize(N);
    color.resize(N-1);
    rep(i,N-1){
        int a,b; cin>>a>>b;
        a--;b--;
        G[a].push_back({b,i});
        G[b].push_back({a,i});
    }
    int maxc = 0;
    int start = 0;
    rep(i,N){
        if(maxc < (ll)G[i].size()){
            chmax(maxc, (ll)G[i].size());
            start = i;
        }
    }
    cout<<maxc<<endl;

    dfs(0, -1, -1);
    rep(i,N-1){
        cout<<color[i]<<endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:18: error: no matching function for call to 'chmax(int&, ll)'
   52 |             chmax(maxc, (ll)G[i].size());
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:31: note: candidate: 'template<class T> bool chmax(T&, T)'
   11 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
      |                               ^~~~~
a.cc:11:31: note:   template argument deduction/substitution failed:
a.cc:52:18: note:   deduced conflicting types for parameter 'T' ('int' and 'long long int')
   52 |             chmax(maxc, (ll)G[i].size());
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<algorithm>
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<bitset>
using namespace std;
int head[100010],Next[200010],tot,to[200010];
int ans[100010],maxans=0;
bool vis[100010];
void ADD(int a,int b){
	tot++;
	Next[tot]=head[a];
	to[tot]=b;
	head[a]=tot;
}
int main(){
	int n;
	cin>>n;
	int a,b;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		ADD(a,b);
		ADD(b,a);
	}
	dfs();
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   26 |         dfs();
      |         ^~~
      |         ffs
Language: C++

int main()
{
	cout << setprecision(10);
	cin >> N ;
	g.resize(N);//to , id(辺の番号)
	ans.resize(N-1);
	rep(i,N-1){	
		int a , b ;
		cin >> a >> b;
		a--;b--;

		g[a].push_back((Edge){b,i});
		g[b].push_back((Edge){a,i});
	}
	dfs(0);

	//最大字数を取得したい。
	int mx = 0;
	rep(i,N-1){
		mx = max((int)mx,(int)g[i].size());
	}
	cout << mx << endl;
	rep(i,N-1){
		cout << ans[i] << endl;
	}

}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:9: error: 'cout' was not declared in this scope
    3 |         cout << setprecision(10);
      |         ^~~~
a.cc:3:17: error: 'setprecision' was not declared in this scope
    3 |         cout << setprecision(10);
      |                 ^~~~~~~~~~~~
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin >> N ;
      |         ^~~
a.cc:4:16: error: 'N' was not declared in this scope
    4 |         cin >> N ;
      |                ^
a.cc:5:9: error: 'g' was not declared in this scope
    5 |         g.resize(N);//to , id(辺の番号)
      |         ^
a.cc:6:9: error: 'ans' was not declared in this scope
    6 |         ans.resize(N-1);
      |         ^~~
a.cc:7:13: error: 'i' was not declared in this scope
    7 |         rep(i,N-1){
      |             ^
a.cc:7:9: error: 'rep' was not declared in this scope
    7 |         rep(i,N-1){
      |         ^~~
a.cc:15:9: error: 'dfs' was not declared in this scope
   15 |         dfs(0);
      |         ^~~
a.cc:22:23: error: 'endl' was not declared in this scope
   22 |         cout << mx << endl;
      |                       ^~~~
Language: C++

N = int(input())
num = [[]for _ in range(N)]
for i in (range(N-1)):
  a, b = map(int, input().split())
  num[a-1].append([i, b-1])
answer = [0] * (N-1)
color = [-1] * (N)
max_num = 0
for i in range(len(num)):
  if max_num <= len(num[i]):
    if i == 0:
      max_num = len(num[i])
    else:
      max_num = len(num[i]) + 1
  c = 1
  for j in range(len(num[i])):
    if c == color[i]:
      c += 1
    answer[num[i][j][0]] = c
    color[num[i][j][1]] = c
    c += 1
print(max_num)
for i in answer:
  print(i)
  

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

#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

struct Edge {
    int to, id
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1) {
    int k = 1;
    rep(i, g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if (u == p) continue; // 親との辺の場合
        if (k == c) k++; // 親で使用した色の場合
        ans[ei] = k;
        k++;
        dfs(u, ans[ei], v);
    }
}

int main() {
    int N;
    cin >> N;
    g.resize(N);
    ans = vector<int>(N - 1);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back((Edge) {b, i});
        g[b].push_back((Edge) {a, i});
    }

    dfs(0);
    int mx = 0;
    rep(i, N) mx = max(mx, int(g[i].size()));

    cout << mx << endl;
    rep(i, N - 1) {
        cout << ans[i] << endl;
    }
}


Compiler output:
a.cc:12:13: error: expected ';' at end of member declaration
   12 |     int to, id
      |             ^~
      |               ;
Language: C++

import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      int[][] arr=new int[n+1][n+1];
      int[][] arr1=new int[n+1][2];
      Map<Integer,Set<Integer>>map=new HashMap<>();
      int[] in=new int[n+1];
      int max=0;
      for(int i=1;i<n;i++){
        int x=s.nextInt(),y=s.nextInt();
        arr1[i][0]=x;arr1[i][1]=y;
        in[y]++;
        if(map.get(x)==null){
          map.put(x,new HashSet<>());
          map.get(x).add(y);
        }
        else{map.get(x).add(y);}

        if(map.get(y)==null){
          map.put(y,new HashSet<>());
          map.get(y).add(x);
        }
        else{map.get(y).add(x);}
        max=Math.max(max,Math.max(map.get(x).size(),map.get(y).size()));
      }
      int root=0;
      for(int z=1;z<n;z++){
        if(in[z]==0){root=z;}
      }
      int k=1;
      Queue<Integer> q=new LinkedList<>();
      q.add(root);
      while(!q.isEmpty()){
        int curr=q.poll(),tmp=0; 
        for(int xx:map.get(curr)){
          if(arr[curr][xx]!=0){
            tmp=arr[curr][xx];continue;
          }
          if(k==tmp){k++;}
          arr[xx][curr]=k;arr[curr][xx]=k;
          k++;
          q.add(xx);
        }
        k=1;
      }
      BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
      System.out.println(max);
      for(int i=1;i<n;i++){
        out.write(arr[arr1[i][0]][arr1[i][1]]+" ");
        out.write("\n");
        out.flush();
      }
        }
      }
      
      
      
    


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
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.io.*;
      | ^~~~~~
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.lang.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class Main{
      | ^~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stack>
#include<queue>
#include<limits>

using namespace std;


int main(){
    int n;
    int a,b;
    cin>> n;
    vector< unordered_map<int,bool> > vcolor(n+1) ;
    int col;
    int maxcol=INT_MIN;
    vector<int> ans;
    n--;
    while( n-- ){
        cin >> a >> b;
        col = 1;
        /* cout <<  vcolor[a][col] << " " << vcolor[b][col] << endl; */
        while( vcolor[a][col] == true || vcolor[b][col] == true ){
            col++;
        }
        vcolor[a][col] = vcolor[b][col] = true;
        maxcol = max( maxcol , col );
        ans.push_back( col );
    }
    cout << maxcol << endl;
    for( auto c : ans ) cout << c << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:16: error: 'INT_MIN' was not declared in this scope
   18 |     int maxcol=INT_MIN;
      |                ^~~~~~~
a.cc:8:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include<limits>
  +++ |+#include <climits>
    8 |
Language: C++

#include <cstdio>
#include <algorithm>
using namespace std;
int n;
vector<int> al[100005];
int c[100005];
void dfs(int i,int p){
    int col=1;
    for (auto it:al[i]){
        if (it==p) continue;
        if (c[p]==col) col++;
        c[it]=col++;
        dfs(it,i);
    }
}
int main(){
    scanf("%d",&n);
    int a,b;
    for (int x=1;x<n;x++){
        scanf("%d%d",&a,&b);
        al[a].push_back(b);
        al[b].push_back(a);
    }
    
    c[1]=1;
    dfs(1,0);
    
    for (int x=1;x<=n;x++) printf("%d\n",c[x]);
}

Compiler output:
a.cc:5:1: error: 'vector' does not name a type
    5 | vector<int> al[100005];
      | ^~~~~~
a.cc: In function 'void dfs(int, int)':
a.cc:9:18: error: 'al' was not declared in this scope
    9 |     for (auto it:al[i]){
      |                  ^~
a.cc: In function 'int main()':
a.cc:21:9: error: 'al' was not declared in this scope; did you mean 'a'?
   21 |         al[a].push_back(b);
      |         ^~
      |         a
Language: C++

#include <iostream>
#include <algorithm>
#include <math.h>
#include <iomanip>

using namespace std;


const int MAX_N = 100000;

struct edge { int from, to; };
char color[MAX_N + 1][MAX_N + 1];

edge es[MAX_N];
int N;
int K = 0;

void dfs(int v, int c) {
  int _c = 1;
  int k = 1;
  for (int i = 1; i <= N; ++i) {
    if (color[v][i] != -1) continue;
    if (_c == c) _c++;

    color[v][i] = _c;
    color[i][v] = _c;

    dfs(i, _c);

    _c++;
    k++;
  }

  K = max(K, k);
}

void Main() {
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    edge e = {0, 0};
    cin >> e.from >> e.to;
    color[e.from][e.to] = -1;
    color[e.to][e.from] = -1;
    es[i] = e;
  }

  dfs(1, 0);

  cout << K << endl;
  for (int i = 0; i < N - 1; ++i) {
    cout << int(color[es[i].to][es[i].from]) << endl;
  }
}

int main() {
  Main();
  return 0;
}

Compiler output:
/tmp/ccty0Cyp.o: in function `dfs(int, int)':
a.cc:(.text+0xcb): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccty0Cyp.o
a.cc:(.text+0xe2): relocation truncated to fit: R_X86_64_PC32 against symbol `K' defined in .bss section in /tmp/ccty0Cyp.o
a.cc:(.text+0xf2): relocation truncated to fit: R_X86_64_PC32 against symbol `K' defined in .bss section in /tmp/ccty0Cyp.o
/tmp/ccty0Cyp.o: in function `Main()':
a.cc:(.text+0x104): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccty0Cyp.o
a.cc:(.text+0x1b4): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccty0Cyp.o
a.cc:(.text+0x1c6): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccty0Cyp.o
a.cc:(.text+0x1e7): relocation truncated to fit: R_X86_64_PC32 against symbol `K' defined in .bss section in /tmp/ccty0Cyp.o
a.cc:(.text+0x227): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccty0Cyp.o
a.cc:(.text+0x23e): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccty0Cyp.o
a.cc:(.text+0x28d): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccty0Cyp.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <algorithm>
#include <math.h>
#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;


const int MAX_N = 100000;

struct edge { int from, to; };
int color[MAX_N + 1][MAX_N + 1];

edge es[MAX_N];
int N;
int K = 0;

void dfs(int v, int c) {
  int _c = 1;
  int k = 1;
  for (int i = 1; i <= N; ++i) {
    if (color[v][i] != -1) continue;
    if (_c == c) _c++;

//    cout << v << " " << i << " " << _c << endl;

    color[v][i] = _c;
    color[i][v] = _c;

    dfs(i, _c);

    _c++;
    k++;
  }

  K = max(K, k);
}

void Main() {
//  fill(color[0], color[MAX_N], );

  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    edge e = {0, 0};
    cin >> e.from >> e.to;
    color[e.from][e.to] = -1;
    color[e.to][e.from] = -1;
    es[i] = e;
//    cout << e.from << " " << e.to << endl;
  }

  dfs(1, 0);

  cout << K << endl;
  for (int i = 0; i < N - 1; ++i) {
    cout << color[es[i].to][es[i].from] << endl;
  }
}

int main() {
  Main();
  return 0;
}

Compiler output:
/tmp/ccJC5xVZ.o: in function `dfs(int, int)':
a.cc:(.text+0xd9): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccJC5xVZ.o
a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `K' defined in .bss section in /tmp/ccJC5xVZ.o
a.cc:(.text+0x100): relocation truncated to fit: R_X86_64_PC32 against symbol `K' defined in .bss section in /tmp/ccJC5xVZ.o
/tmp/ccJC5xVZ.o: in function `Main()':
a.cc:(.text+0x112): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccJC5xVZ.o
a.cc:(.text+0x1d4): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccJC5xVZ.o
a.cc:(.text+0x1e6): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccJC5xVZ.o
a.cc:(.text+0x207): relocation truncated to fit: R_X86_64_PC32 against symbol `K' defined in .bss section in /tmp/ccJC5xVZ.o
a.cc:(.text+0x247): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccJC5xVZ.o
a.cc:(.text+0x25e): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccJC5xVZ.o
a.cc:(.text+0x2af): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccJC5xVZ.o
collect2: error: ld returned 1 exit status
Language: C++

//#include <iostream>
//#include <algorithm>
//#include <math.h>
//#include <iomanip>
#include <bits/stdc++.h>

using namespace std;


const int MAX_N = 100000;

struct edge { int from, to; };
int color[MAX_N + 1][MAX_N + 1];

edge es[MAX_N];
int N;
int K = 0;

void dfs(int v, int c) {
  int _c = 1;
  int k = 1;
  for (int i = 1; i <= N; ++i) {
    if (color[v][i] != -1) continue;
    if (_c == c) _c++;

//    cout << v << " " << i << " " << _c << endl;

    color[v][i] = _c;
    color[i][v] = _c;

    dfs(i, _c);

    _c++;
    k++;
  }

  K = max(K, k);
}

void Main() {
//  fill(color[0], color[MAX_N], );

  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    edge e = {0, 0};
    cin >> e.from >> e.to;
    color[e.from][e.to] = -1;
    color[e.to][e.from] = -1;
    es[i] = e;
//    cout << e.from << " " << e.to << endl;
  }

  dfs(1, 0);

  cout << K << endl;
  for (int i = 0; i < N - 1; ++i) {
    cout << color[es[i].to][es[i].from] << endl;
  }
}

int main() {
  Main();
  return 0;
}

Compiler output:
/tmp/ccjISg06.o: in function `dfs(int, int)':
a.cc:(.text+0xd9): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccjISg06.o
a.cc:(.text+0xf0): relocation truncated to fit: R_X86_64_PC32 against symbol `K' defined in .bss section in /tmp/ccjISg06.o
a.cc:(.text+0x100): relocation truncated to fit: R_X86_64_PC32 against symbol `K' defined in .bss section in /tmp/ccjISg06.o
/tmp/ccjISg06.o: in function `Main()':
a.cc:(.text+0x112): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccjISg06.o
a.cc:(.text+0x1d4): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccjISg06.o
a.cc:(.text+0x1e6): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccjISg06.o
a.cc:(.text+0x207): relocation truncated to fit: R_X86_64_PC32 against symbol `K' defined in .bss section in /tmp/ccjISg06.o
a.cc:(.text+0x247): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccjISg06.o
a.cc:(.text+0x25e): relocation truncated to fit: R_X86_64_PC32 against symbol `es' defined in .bss section in /tmp/ccjISg06.o
a.cc:(.text+0x2af): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccjISg06.o
collect2: error: ld returned 1 exit status
Language: C++

N = input()
N = int(N)
scount = 0 #出力した回数

peg = [[]]*3

def output():
  global scount
  global peg
  scount+=1
  print("[", scount, "]\n")
  for i in range(N):
    if(len(peg[0]) > i):
      print(peg[0][i], " ")
    else:
      print("  ")
    if(len(peg[1]) > i):
      print(peg[1][i], " ")
    else:
      print("  ")
    #if(len(peg[2]) > i):
    #  print(peg[2][i], " \n")
    #else:
    #  print("  \n")

def hanoi(i,j,k,t):
  global peg
  if(i != 1):
    hanoi(i-1,j,t,k)
  
  peg[k].insert(0,peg[j][0])
  peg[j].pop(0)
  output()

  if(i == 1):
    return
  
  hanoi(i-1,t,k,j)
  return

for i in range(N):
  peg[0].extend(i+1)
print(peg)  
output()
#hanoi(N,0,2,1)






Compiler output:
a.cc:3:12: error: stray '#' in program
    3 | scount = 0 #出力した回数
      |            ^
a.cc:21:12: error: missing binary operator before token "("
   21 |     #if(len(peg[2]) > i):
      |            ^
a.cc:23:10: warning: extra tokens at end of #else directive [-Wendif-labels]
   23 |     #else:
      |          ^
a.cc:24:8: error: invalid preprocessing directive #print
   24 |     #  print("  \n")
      |        ^~~~~
a.cc:45:2: error: invalid preprocessing directive #hanoi
   45 | #hanoi(N,0,2,1)
      |  ^~~~~
a.cc:21: error: unterminated #else
   21 |     #if(len(peg[2]) > i):
a.cc:1:1: error: 'N' does not name a type
    1 | N = input()
      | ^
Language: C++

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

vector<ll> G[100000];
vector<P> vp;

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

	ll K = 0;
	map<P, ll> I;
	vector<ll> cs(N, 0); // color of edge between its parent
	vector<ll> used(N, 0);
	queue<ll> que;

	used[0] = 1;
	que.emplace_back(0);
	while(!que.empty()) {
		ll v = que.front();que.pop();
		if (K < G[v].size()) K = G[v].size();
		ll cur = 1;
		for (auto u: G[v]) {
			if (used[v]) continue;
			if (cur == cs[v]) cur++;
			cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
			used[u] = 1;
			que.emplace(u);
		}
	}
	
	cout << K << endl;
	for (auto p: vp) cout << I[p] << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:13: error: 'class std::queue<long long int>' has no member named 'emplace_back'
   36 |         que.emplace_back(0);
      |             ^~~~~~~~~~~~