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

#include<bits/stdc++.h>
#define inf INT_MAX
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("%d %d",&a,&b)
#define sccc(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pff(a,b) printf("%d %d",a,b)
#define pfff(a,b,c) printf("%d %d %d",a,b,c)
#define pb(a) push_back(a)
#define em empty()
#define fr front()
#define cl clear()
#define sz size()
#define mp(a,b) make_pair(a,b)
#define fri(b) freopen(b,"r",stdin)
#define fro(b) freopen(b,"w",stdout)
/*
ID: uslusam1
TASK: test
LANG: C++
*/
using namespace std;

int cnt[100013];
int bas[100013];
int tut[100013];
int maxi;
vector< set<int> > vec;

int main(){
	//	fri(".in");
	//	fro(".out");
	int n;
	cin>>n;
	for(int i=0;i<=n;i++){
		set<int> st;
		vec.pb(st);
	}
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		/*for(int j=1;j<n;j++){
			if(vec[a].count(j)==0 && vec[b].count(j)==0){
				vec[a].insert(j);
				vec[b].insert(j);
				if(j>maxi){
					maxi=j;
				}
				bas[i]=j;
				break;
			}
		}
	}*/
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		cnt[a]++;
		cnt[b]++;
		//bas[i]=max(cnt[a],cnt[b]);
		if(cnt[a]==1 && cnt[b]==1){
			bas[i]=1;
		}
		else if(cnt[a]==1){
			if(tut[b]==0){
				bas[i]=cnt[b];
				tut[a]=bas[i];
			}
			else{
				if(tut[b]!=cnt[b]-1){
					bas[i]=cnt[b]-1;
				}
				else{
					bas[i]=cnt[b];
					tut[b]=0;
				}
			}
		}
		else if(cnt[b]==1){
			if(tut[a]==0){
				bas[i]=max(cnt[a],cnt[b]);
				tut[b]=bas[i];
			}
			else{
				if(tut[a]!=cnt[a]-1){
					bas[i]=cnt[a]-1;
				}
				else{
					bas[i]=cnt[a];
					tut[a]=0;
				}
			}
		}
		else{
			bas[i]=max(cnt[a],cnt[b]);
		}
		if(bas[i]>maxi){
			maxi=bas[i];
		}
	}
	cout<<maxi<<endl;
	for(int i=1;i<n;i++){
		cout<<bas[i]<<endl;
	}
	
	return 0;
}








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

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

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,sz(to[v])) {
    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);
  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(to[i].size()));
  cout << mx << endl;
  rep(i,n-1) {
    cout << ans[i] << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:13:12: error: 'to' was not declared in this scope; did you mean 'tm'?
   13 |   rep(i,sz(to[v])) {
      |            ^~
a.cc:2:39: note: in definition of macro 'rep'
    2 | #define rep(i,n) for (int i = 0; i < (n); ++i)
      |                                       ^
a.cc:13:9: error: 'sz' was not declared in this scope
   13 |   rep(i,sz(to[v])) {
      |         ^~
a.cc:2:39: note: in definition of macro 'rep'
    2 | #define rep(i,n) for (int i = 0; i < (n); ++i)
      |                                       ^
a.cc: In function 'int main()':
a.cc:35:29: error: 'to' was not declared in this scope; did you mean 'tm'?
   35 |   rep(i,n) mx = max(mx, int(to[i].size()));
      |                             ^~
      |                             tm
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } return 0; }

ll k = 0;
vector<vector<pll>> g;
vector<ll> ans;
void dfs(ll from, ll at, ll color){
  for(auto& i : g[at]) if(i.first != from){
    color++;
    if(color >= k) color -= k;
    ans[i.second] = color;
    dfs(at, i, color);
  }
}
int main(){
  ll n;
  cin >> n;
  g.resize(n);
  ans.resize(n - 1);
  for(ll i = 0; i < n - 1; i++){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back({b, i});
    g[b].push_back({a, i});
  }
  for(auto& i : g) chmax<ll>(k, i.size());
  dfs(-1, 0, 0);
  cout << k << endl;
  for(auto& i : ans) cout << i + 1 << endl;
}


Compiler output:
a.cc: In function 'void dfs(ll, ll, ll)':
a.cc:15:13: error: cannot convert 'std::pair<long long int, long long int>' to 'll' {aka 'long long int'}
   15 |     dfs(at, i, color);
      |             ^
      |             |
      |             std::pair<long long int, long long int>
a.cc:10:22: note:   initializing argument 2 of 'void dfs(ll, ll, ll)'
   10 | void dfs(ll from, ll at, ll color){
      |                   ~~~^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } return 0; }

ll k = 0;
vector<vector<pll>> g;
vector<ll> ans;
void dfs(ll from, ll at, ll color){
  for(auto& i : g[at]) if(i.first != from){
    color++;
    if(color >= k) color -= k;
    ans[i.second] = color;
    dfs(at, i, color);
  }
}
int main(){
  ll n;
  cin >> n;
  g.resize(n);
  ans.resize(n - 1);
  for(ll i = 0; i < n - 1; i++){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back({b, i});
    g[b].push_back({a, i});
  }
  for(auto& i : g) chmax(k, i.size());
  dfs(-1, 0, 0);
  cout << k << endl;
  for(auto& i : ans) cout << i + 1 << endl;
}


Compiler output:
a.cc: In function 'void dfs(ll, ll, ll)':
a.cc:15:13: error: cannot convert 'std::pair<long long int, long long int>' to 'll' {aka 'long long int'}
   15 |     dfs(at, i, color);
      |             ^
      |             |
      |             std::pair<long long int, long long int>
a.cc:10:22: note:   initializing argument 2 of 'void dfs(ll, ll, ll)'
   10 | void dfs(ll from, ll at, ll color){
      |                   ~~~^~
a.cc: In function 'int main()':
a.cc:30:25: error: no matching function for call to 'chmax(ll&, std::vector<std::pair<long long int, long long int> >::size_type)'
   30 |   for(auto& i : g) chmax(k, i.size());
      |                    ~~~~~^~~~~~~~~~~~~
a.cc:5:24: note: candidate: 'template<class T> bool chmax(T&, const T&)'
    5 | template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } return 0; }
      |                        ^~~~~
a.cc:5:24: note:   template argument deduction/substitution failed:
a.cc:30:25: note:   deduced conflicting types for parameter 'const T' ('long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'})
   30 |   for(auto& i : g) chmax(k, i.size());
      |                    ~~~~~^~~~~~~~~~~~~
Language: C++

#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi; 

vector<ll > ans;

vector<bool > seen;

void dfs(vector<vector<pi > > G,  ll idx, ll from = -1){
    seen[idx] = true;
    if(from == -1){
        ans[idx] = 1145141919;
    }

    ll cn = 1;
    for(ll i = 0; i < G[idx].size(); i++){
        //次の行き先は？
        ll to = G[idx][i].first;
        //探査済み
        if(seen[to] == true){
            continue;
        }

        if(cn == ans[idx]){
            cn++;
        }
        ans[to] = cn;
 
        dfs(G, seen ,to , idx);
        cn++;
    }
}

int main(){
    ll N;
    cin >> N;
    //初期化
    vector<vector<pi > > G;
    G.assign(N, vector<pi >());
    ans.assign(N, -1);
    vector<bool > seen(N, false);
 
    //グラフ入力
    for(ll i = 0; i < N-1; i++){
        ll u, v, w;
        w = 0;
        cin >> u >> v;
        u--;
        v--;
        //双方向に貼りましょうね
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }

    dfs(G ,seen ,0);

    ll mx = -1;
    for(ll i = 1; i < N; i++){
        mx = max(ans[i], mx);
    }
    cout << mx << endl;
    for(ll i = 1; i < N; i++){
        cout << ans[i] << endl;
    }
}

Compiler output:
a.cc: In function 'void dfs(std::vector<std::vector<std::pair<long long int, long long int> > >, ll, ll)':
a.cc:31:16: error: cannot convert 'std::vector<bool>' to 'll' {aka 'long long int'}
   31 |         dfs(G, seen ,to , idx);
      |                ^~~~
      |                |
      |                std::vector<bool>
a.cc:11:38: note:   initializing argument 2 of 'void dfs(std::vector<std::vector<std::pair<long long int, long long int> > >, ll, ll)'
   11 | void dfs(vector<vector<pi > > G,  ll idx, ll from = -1){
      |                                   ~~~^~~
a.cc: In function 'int main()':
a.cc:57:12: error: cannot convert 'std::vector<bool>' to 'll' {aka 'long long int'}
   57 |     dfs(G ,seen ,0);
      |            ^~~~
      |            |
      |            std::vector<bool>
a.cc:11:38: note:   initializing argument 2 of 'void dfs(std::vector<std::vector<std::pair<long long int, long long int> > >, ll, ll)'
   11 | void dfs(vector<vector<pi > > G,  ll idx, ll from = -1){
      |                                   ~~~^~~
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int a[] = new int[n + 1];
        int b[] = new int[n + 1];
        int color[] = new int[n + 1];
        int num[] = new int[n + 1];
        int numcopy[] = new int[n + 1];
        boolean flag = new boolean[n + 1];
        int index = 1;
        
        for(int i = 1; i < n; i++){
            a[i] = stdIn.nextInt();
            b[i] = stdIn.nextInt();
            color[i] = 0;
            num[a[i]]++;
            num[b[i]]++;
            numcopy[a[i]]++;
            numcopy[b[i]]++;
            flag[i] = true;
        }
        
        Arrays.sort(numcopy);
        
        int maxindex = 0;
        
        for(int i = 0; i < n; i++){
            if(numcopy[n] == num[i]){
                maxindex = i;
                break;
            }
        }
        
        //color[maxindex] = index;
        
        //index++;

        for(int i = 1; i < n; i++){
            if(a[i] == maxindex || b[i] == maxindex){
                color[i] = index;
                index++;
            }
            
        }
        
        
        System.out.println(numcopy[n]);
        
        for(int i = 1; i < n; i++){
            System.out.println(color[i]);
        }
        
    }
}


Compiler output:
Main.java:12: error: incompatible types: boolean[] cannot be converted to boolean
        boolean flag = new boolean[n + 1];
                       ^
Main.java:23: error: array required, but boolean found
            flag[i] = true;
                ^
2 errors
Language: C++

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint getColor(void){
  llint bufc = 1;

  while(1) {

  }

  return bufc;
}

int main (void)
{
  //INPUT
  struct edge{
    llint from;
    llint to;
    llint color=0;
  };

  llint N;
  cin >> N;
  vector<edge> E(N);
  for(llint i=1;i<=N-1;i++) {
    cin >> E[i].from >> E[i].to;
  }

  //SOLVE
  llint ans=0;
  struct ver{
    vector<edge> edge;
  };
  vector<ver> G(N+1);

  for(llint i=1;i<=N-1;i++) {
    //E[i].color
    llint bufc;
    bufc = 1;
    for(llint j=0;j<G[E[i].from].edge.size();j++) {
      if (bufc == G[E[i].from].edge[j].color) {
        bufc++;
      }
    }
    for(llint j=0;j<G[E[i].to].edge.size();j++) {
      if (bufc == G[E[i].to].edge[j].color) {
        bufc++;
      }
    }
    ans = max(ans,bufc);
    E[i].color = bufc;
    G[E[i].from].edge.push_back(E[i]);
    G[E[i].to].edge.push_back(E[i]);
  }



  //OUTPUT
  cout << ans << endl;
  for(llint i=1;i<=N-1;i++) {
    cout << E[i].color << endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:18: error: declaration of 'std::vector<main()::edge> main()::ver::edge' changes meaning of 'edge' [-Wchanges-meaning]
   70 |     vector<edge> edge;
      |                  ^~~~
a.cc:70:12: note: used here to mean 'struct main()::edge'
   70 |     vector<edge> edge;
      |            ^~~~
a.cc:54:10: note: declared here
   54 |   struct edge{
      |          ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
map<pair<int,int> ,int>mp;
int color[100005],mx=0;
vector<int>adj[100005];
void dfs(int u,int par)
{
    int cl=1;
    for(int v:adj[u])
    {
        if(v!=par)
        {
            if(cl==color[mp{par,u}])
                cl++;
            mx=max(cl,mx);
            color[mp[{u,v}]]=cl;
            dfs(v,u);
            cl++;
        }
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        mp[{u,v}]=i;
        mp[{v,u}]=i;
    }
    dfs(1,0);
    cout<<mx<<endl;
    for(int i=1;i<=n-1;i++)
        cout<<color[i]<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:13:28: error: expected ']' before '{' token
   13 |             if(cl==color[mp{par,u}])
      |                            ^
      |                            ]
a.cc:13:25: error: no match for 'operator[]' (operand types are 'int [100005]' and 'std::map<std::pair<int, int>, int>')
   13 |             if(cl==color[mp{par,u}])
      |                         ^
a.cc:13:28: error: expected ')' before '{' token
   13 |             if(cl==color[mp{par,u}])
      |               ~            ^
      |                            )
a.cc:13:35: error: expected primary-expression before ']' token
   13 |             if(cl==color[mp{par,u}])
      |                                   ^
Language: C++

#include <iostream>
using namespace std;
int main(void){
    long long N,i,K,m;
    cin>>N;
    long long a[N-1],b[N-1],c[N],d[N-1],e[N];
    for(i=0;i<N-1;i++){
        cin>>a[i]>>b[i];
        c[a[i]-1]++;c[b[i]-1]++;
    }
    m=0;
    for(i=0;i<N;i++){
        if(c[i]>m){
            m=c[i];
        }
    }
    K=m;
    cout<<K<<endl;
    d[0]=1;e[b[0]-1]=1;
    for(i=1;i<N-1;i++){
        if(a[i]==a[i-1]){
            d[i]=d[i-1]+1;
            e[b[i]-1]=d[i];
            if(e[a[i]-1]==d[i-1]+1){
                d[i]=d[i-1]+2;
            }
        }else{
            d[i]=1;
            if(e[a[i]==1){
                d[i]=2;
            }
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:25: error: expected ']' before ')' token
   29 |             if(e[a[i]==1){
      |                         ^
      |                         ]
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll N, a, b, max;
  cin >> N;
  vector<pair<ll, ll>> sides(N-1);
  vector<pair<ll, vector<bool>>> colors(N);
  map<ll, ll> cnt;
  vll cnt_num(N);
  vll ans(N-1);
  
  for (int i = 0; i < N - 1; i++) {
    cin >> a >> b;
    sides.at(i) = make_pair(a, b);
    if (!cnt.count(a)) cnt[a] = 1;
    else cnt[a]++;
    if (!cnt.count(b)) cnt[b] = 1;
    else cnt[b]++;
  }

  for (int i = 0; i < N; i++) {
    cnt_num.at(i) = cnt[i];
    a = i;
    b = cnt[i];
    vector<bool> tmp(b);
    for (int j = 0; j < b; j++) {
      tmp.at(j) = false;
    }
    colors.at(i) = make_pair(i, tmp);
  }
  
  sort(cnt_num.begin(), cnt_num.end());
  max = cnt_num.at(N-1);

  for (int i = 0; i < N - 1; i++) {
    tie(a, b) = side.at(i);
    for (int j = 0; j < colors.at(a).second.size(); j++) {
      for (int k = 0; k < colors.at(b).second.size(); k++) {
        if (colors.at(a).second.at(j) == false && colors.at(b).second.at(j) == false) {
          ans.at(i) == j;
          colors.at(a).second.at(j) = true;
          colors.at(b).second.at(j) = true;
          break;
        }
        else if (colors.at(a).second.at(k) == false && colors.at(b).second.at(k) == false) {
          ans.at(i) == k;
          colors.at(a).second.at(k) = true;
          colors.at(b).second.at(k) = true;
          break;
        }
      }
      if (ans.at(i) > 0) break;
    }
  }

  cout << max << endl;
  for (int i = 0; i < N - 1; i++) {
    cout << ans.at(i) << endl;
  }
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:17: error: 'side' was not declared in this scope; did you mean 'sides'?
   43 |     tie(a, b) = side.at(i);
      |                 ^~~~
      |                 sides
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


ll digit(ll num){
	ll ret=0;
	string s=to_string(num);
	return s.length();
}
	
class Edge{
public:
	ll num;
	ll a;
	ll b;
	ll color=0;
	Edge(ll _num,ll _a,ll _b){
		num=_num;
		a=_a;
		b=_b;
	}
};
	
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N;
	cin>>N;
	vector<ll>G[N];
	vector<Edge>e;
	for(int i=0;i<N-1;i++){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		Edge _edge=Edge(i,a,b);
		e.push_back(_edge);
		G[a].push_back(i);
		G[b].push_back(i);
	}
	
	queue<ll>que;
	que.push(0);
	e[0].color=0;
	while(!que.empty()){
		ll u=que.front();
		que.pop();
		if(e[u].color!=0)continue;
		ll mycolor=e[u].color;
		ll color=1;
		ll size=G[e[u].a].size();
		if(color==mycolor)color++;
		for(int i=0;i<size;i++){
			ll k=G[e[u].a][i];
			if(e[k].color==0){
				e[k].color=color;
				if(color==mycolor)color++;
				que.push(k);
			}
		}
		
		color=1;
		if(color==mycolor)color++;
		size=G[e[u].b].size();
		for(int i=0;i<size;i++){
			ll k=G[e[u].][i];
			if(e[k].color==0){
				e[k].color=color;
				if(color==mycolor)color++;
				que.push(k);
			}
		}
	}
	ll K=0;
	
	for(int i=0;i<N-1;i++)K=max(e[i].color,K);
	cout<<K<<endl;
	for(int i=0;i<N-1;i++)cout<<e[i].color<<endl;
	
}



Compiler output:
a.cc: In function 'int main()':
a.cc:99:37: error: expected unqualified-id before ']' token
   99 |                         ll k=G[e[u].][i];
      |                                     ^
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int aa[123456], bb[123456], test[123456], uiop[123456][123456];
int main(){
  long long n, a, b, sum = 0; cin>> n;
  for(int h=1;h<n;h++){
    cin>>a>>b; test[a]++; test[b]++; aa[h]=a; bb[h]=b;
  }
  for(int h=1;h<n;h++){
    sum = max(sum,test[h]);
  }
  cout<<sum<<endl;
  for(int h=1;h<n;h++){
    for(int i=0;i<n;i++){
      if(uiop[aa[h]][i]==0&&uiop[bb[h]][i]==0){
        uiop[aa[h]][i]++;uiop[bb[h]][i]++;
        cout<<i<<endl;
      }
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:14: error: no matching function for call to 'max(long long int&, int&)'
   12 |     sum = max(sum,test[h]);
      |           ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:12:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   12 |     sum = max(sum,test[h]);
      |           ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:12:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   12 |     sum = max(sum,test[h]);
      |           ~~~^~~~~~~~~~~~~
Language: C++

#include <algorithm>
#include <bitset>
#include <cstring>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

char t[100010][100010];
char nums[100010];
using P = pair<int, int>;

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

  vector<P> edges;
  int a, b;
  for(int i = 0; i < N - 1; ++i) {
    cin >> a >> b;
    t[a][b] = -1;
    t[b][a] = -1;
    nums[a]++;
    nums[b]++;
    edges.push_back(P(a, b));
  }
  int colorNum = -1;
  int largestIdx = -1;
  for(int i = 1; i <= N; ++i) {
    if(nums[i] > colorNum) {
      colorNum = nums[i];
      largestIdx = i;
    }
  }
  int c = 1;
  for(int i = 1; i <= N; ++i) {
    if(t[largestIdx][i] < 0) {
      t[largestIdx][i] = c;
      t[i][largestIdx] = c;
      c++;
    }
  }

  for(int i = 1; i <= N; ++i) {
    c = 1;
    bitset<100010> f = bitset<100010>(0);
    for(int j = 1; j <= N; ++j) {
      if(t[i][j] > 0) {
        f.set(t[i][j]);
        continue;
      }
      if(t[i][j] < 0) {
        while(!f.test(c)) {
          c++;
        }
        f.set(c);
        t[i][j] = c;
        t[j][i] = c;
        c++;
      }
    }
  }

  cout << colorNum << endl;
  for(int i = 0; i < edges.size(); ++i) {
    auto e = edges[i];
    cout << t[e.first][e.second] << endl;
  }
  return 0;
}

Compiler output:
/tmp/ccrAMI2t.o: in function `main':
a.cc:(.text+0xaf): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/ccrAMI2t.o
a.cc:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/ccrAMI2t.o
a.cc:(.text+0xd1): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/ccrAMI2t.o
a.cc:(.text+0xe3): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/ccrAMI2t.o
a.cc:(.text+0x146): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/ccrAMI2t.o
a.cc:(.text+0x15e): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/ccrAMI2t.o
collect2: error: ld returned 1 exit status
Language: C++

#include <algorithm>
#include <bitset>
#include <cstring>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int t[100010][100010];
int nums[100010];
using P = pair<int, int>;

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

  vector<P> edges;
  int a, b;
  for(int i = 0; i < N - 1; ++i) {
    cin >> a >> b;
    t[a][b] = -1;
    t[b][a] = -1;
    nums[a]++;
    nums[b]++;
    edges.push_back(P(a, b));
  }
  int colorNum = -1;
  int largestIdx = -1;
  for(int i = 1; i <= N; ++i) {
    if(nums[i] > colorNum) {
      colorNum = nums[i];
      largestIdx = i;
    }
  }
  int c = 1;
  for(int i = 1; i <= N; ++i) {
    if(t[largestIdx][i] < 0) {
      t[largestIdx][i] = c;
      t[i][largestIdx] = c;
      c++;
    }
  }

  for(int i = 1; i <= N; ++i) {
    c = 1;
    bitset<100010> f = bitset<100010>(0);
    for(int j = 1; j <= N; ++j) {
      if(t[i][j] > 0) {
        f.set(t[i][j]);
        continue;
      }
      if(t[i][j] < 0) {
        while(!f.test(c)) {
          c++;
        }
        f.set(c);
        t[i][j] = c;
        t[j][i] = c;
        c++;
      }
    }
  }

  cout << colorNum << endl;
  for(int i = 0; i < edges.size(); ++i) {
    auto e = edges[i];
    cout << t[e.first][e.second] << endl;
  }
  return 0;
}

Compiler output:
/tmp/cch0Zr9W.o: in function `main':
a.cc:(.text+0xc9): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/cch0Zr9W.o
a.cc:(.text+0xe0): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/cch0Zr9W.o
a.cc:(.text+0xf8): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/cch0Zr9W.o
a.cc:(.text+0x10f): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/cch0Zr9W.o
a.cc:(.text+0x17a): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/cch0Zr9W.o
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `nums' defined in .bss section in /tmp/cch0Zr9W.o
collect2: error: ld returned 1 exit status
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int N;
    vector<P> ab;
    cin >> N;
    
    vector<vector<int>> g(N);
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
        ab.pb(mp(a,b));
    }
    
    int maxL = 0;
    int maxNode = 0;
    rep(i,N){
        if (maxL < (int) g[i].size()){
            maxL = (int) g[i].size();
            maxNode = i;
        }
        
        
    }
    
    vector<map<int,int>> coloring(N);
    cout << maxL << endl;

    
    rep(j,N-1){
        a = ab[j].fi; b = ab[j].se;

        
        rep(i,maxL){
            if (coloring[a].find(i) == coloring[a].end() && coloring[b].find(i) == coloring[b].end()){
                coloring[a].insert(P(i,0));
                coloring[b].insert(P(i,0));
                cout << i + 1<< endl;
                break;
            }
        }
    }
    
    rn 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:9: error: 'a' was not declared in this scope
   65 |         a = ab[j].fi; b = ab[j].se;
      |         ^
a.cc:65:23: error: 'b' was not declared in this scope
   65 |         a = ab[j].fi; b = ab[j].se;
      |                       ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

#define MAX 100002

vector<int> g[MAX];
vector<int> c[MAX];
int d[MAX][MAX];
int n;
int k = 0;

void BFS(int s){
    queue<P> que;
    que.push(make_pair(s, 0));
    while(!que.empty()){
        int u = que.front().first;
        int pre = que.front().second;
        que.pop();
        int tmp = 0;
        rep(i, g[u].size()){
            int v = g[u][i];
            tmp++;
            if(pre==tmp) tmp++;
            d[u][v] = tmp;
            que.push(make_pair(v, tmp));
        }
        chmax(k, tmp);
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> color[n+1];
    vector<P> hen;

    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        hen.push_back(make_pair(a, b));
        g[a].push_back(b);
    }
    BFS(0);

    cout << k << endl;
    rep(i, n-1){
        int a = hen[i].first, b = hen[i].second;
        cout << d[a][b] << endl;
    }


    return 0;
}


Compiler output:
/tmp/cc4WIPkm.o: in function `BFS(int)':
a.cc:(.text+0x1a5): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc4WIPkm.o
a.cc:(.text+0x1b5): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc4WIPkm.o
/tmp/cc4WIPkm.o: in function `main':
a.cc:(.text+0x3c8): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc4WIPkm.o
collect2: error: ld returned 1 exit status
Language: C++

/***
 **   A S M Atikur Rahman
 **   Update: 14-11-2019
***/

//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<stack>
#include<cstring>
#include<iterator>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<iomanip> ///setprecision


#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sci(x) scanf("%d%*c", &(x))
#define scll(x) scanf("%lld%*c", &(x))
#define scd(x) scanf("%lf%*c", &(x))
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", (x))
#define pfll(x) printf("%lld", (x))
#define pfd(x) printf("%f", (x))
#define pfstr(x) printf("%s", (x))
#define ps printf(" ")
#define pn printf("\n")
#define pfdot printf("..")

#define For(i,a,n) for(int i=(a); i<(n); i++)
#define rFor(i,n,a) for(int i=n-1; i>=0; i--)
#define trav(a,x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define pi  (2*acos(0))


using namespace std;

using ll=long long;
using pii= pair<int,int>;
using pll= pair<long long, long long>;
using pcc= pair<char, char>;
using pdd= pair<double, double>;

#define V(a) vector<a>
using vi= vector<int>;
using vs= vector<string>;
using vll= vector<ll>;
using vpii= vector<pii>;
using vc= vector<char>;
using vd= vector<double>;

//ll POW(ll a,ll b){if(b==0)return 1;ll x=POW(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}




int main( int argc, char *argv[] )
{
//    fropen("input.txt", "r", stdin);
//    fropen("output.txt", "w", stout);

    int n, a, b,i ,j;
    vector<int> vr[100100];
    int prc[100100]={0};
    cin>>n;
    for(i=0; i<n-1; i++)
    {
        sci(a);sci(b);
        vr[a].pb(b);
    }
    int mx=INT_MIN;
    for(i=0; i<n; i++)
    {
        int l=vr[i].size();
        if(i>1) l++;
        mx=max(mx, l);
    }
    cout<<mx<<endl;
    for(i=0; i<n; i++)
    {
        int l=vr[i].size(), x=1;
        for(j=0;j<l; j++)
        {
            if(prc[i]!=x) pfi(x++);
            else pfi(++x);
            prc[vr[i][j]]=x-1;
            pn;
        }
    }

    return 0;
}














Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:87:12: error: 'INT_MIN' was not declared in this scope
   87 |     int mx=INT_MIN;
      |            ^~~~~~~
a.cc:23:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   22 | #include<iomanip> ///setprecision
  +++ |+#include <climits>
   23 |
Language: C++

#include<iostream>
#include<set>
#include<queue>
#include<utility>
using namespace std;
set<long long int> col[100000005];
pair<long long int,long long int> col2[100005];
queue<long long int> ans;
int main()
{
	long long int N;
	cin>>N;
	long long int j=1;
	while(!ans.empty())
	ans.pop();
	for(long long int i=1;i<N;i++)
	{
		int a,b;
		cin>>a>>b;
		int flag=0;
		for(long long int h=1;h<=j;h++)
		{
			if((!col[h].count(a))&&(!col[h].count(b)))
			{
				col[h].insert(a);
				col[h].insert(b);
				flag=1;
				ans.push(h);
				//cout<<"push"<<endl;
				break;
			}
		}
		if(flag==0)
		{
			j++;
			col[j].insert(a);
			col[j].insert(b);
			ans.push(j);
			//cout<<"push!!!"<<endl;
		}
	}
	cout<<j<<endl;
	//cout<<ans.size();
	/*for(int qi=0;qi<=ans.size();qi++)
	 {
	 	int ta=ans.front();
	 	ans.pop();
	 	cout<<ta<<endl;
	 }*/
	 while(!ans.empty())
	 {
	 	long long int ta=ans.front();
	 	
	 	cout<<ta<<endl;
	 	ans.pop();
	 }
	 
	 return 0;
	
}

Compiler output:
/tmp/ccbMOvZJ.o: in function `main':
a.cc:(.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccbMOvZJ.o
a.cc:(.text+0x3a): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccbMOvZJ.o
a.cc:(.text+0x191): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccbMOvZJ.o
a.cc:(.text+0x242): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccbMOvZJ.o
a.cc:(.text+0x28e): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccbMOvZJ.o
a.cc:(.text+0x2cc): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccbMOvZJ.o
a.cc:(.text+0x2db): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccbMOvZJ.o
/tmp/ccbMOvZJ.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x385): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccbMOvZJ.o
a.cc:(.text+0x39e): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccbMOvZJ.o
collect2: error: ld returned 1 exit status
Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < (i##_MACRO); i++)
#define RANGE(i, a, b) for(int i = (a); i < (b); i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

typedef struct {
	int to_node;
	int color;
} edge;

typedef struct {
	vector<edge> next_nodes;
} node;

int color_num;

void color_tree(vector<node>& nodes, int node, int prev_color) {
	int c = 1;
	EACH(e, nodes[node].next_nodes) {
		c = c % color_num + 1;
		if(c == prev_color) {
			c = c % color_num + 1;
		}
		e.color = c;
		color_tree(nodes, e.to_node, e.color);
	}
}

int main() {
	int n;
	scanf("%d", &n);
	VI a(n - 1);
	VI b(n - 1);
	VI edge_num(n - 1, 0);
	vector<node> nodes(n);
	edge tmp;
	REP(i, n - 1) {
		scanf("%d %d", &a[i], &b[i]);
		edge_num[a[i] - 1]++;
		tmp.to_node = b[i] - 1;
		tmp.color = 0;
		nodes[a[i] - 1].next_nodes.push_back(tmp);
	}
	edge_num[0]--;
	color_num = *max_element(ALL(edge_num)) + 1;

	color_tree(nodes, 0, -1);

edge_count[a[i] - 1]++;
}

return 0;
		edge_count[a[i] - 1]++;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:90:1: error: 'edge_count' was not declared in this scope; did you mean 'edge_num'?
   90 | edge_count[a[i] - 1]++;
      | ^~~~~~~~~~
      | edge_num
a.cc:90:14: error: 'i' was not declared in this scope
   90 | edge_count[a[i] - 1]++;
      |              ^
a.cc: At global scope:
a.cc:93:1: error: expected unqualified-id before 'return'
   93 | return 0;
      | ^~~~~~
a.cc:94:17: error: 'edge_count' does not name a type
   94 |                 edge_count[a[i] - 1]++;
      |                 ^~~~~~~~~~
a.cc:95:9: error: expected declaration before '}' token
   95 |         }
      |         ^
a.cc:97:9: error: expected unqualified-id before 'return'
   97 |         return 0;
      |         ^~~~~~
a.cc:98:1: error: expected declaration before '}' token
   98 | }
      | ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  ll N,k=1;
  cin>>N;
  
  ll A[N-1],B[N-1],K[N+1];
  REP(i,N+1) K[i]=0;
  
  REP(i,N-1){
    cin>>A[i]>>B[i];
    K[A[i]]++;
    K[B[i]]++;
  }
  
  REP(i,N+1) chmax(k,K[i]);
  
  bool L[N+1][k+1];
  REP(i,N+1){
    REP(j,k+1){
      L[i][j]=true;
    }
  }
  
  
  co(k);
  bool CAN=false;
  
  
  
  if(k==2){
    
    int P[N-1];
    REP(i,N-1) P[i]=0;
    
    
    ll a=1,ff=1;
    
    
    for(int i=0; i<N-1; ++i){
      for(int j=0; j<N-1; ++j){
        if(A[j]==a || B[j]==a){
          a=A[j]+B[j]-a;
          P[j]=(ff-1)^1+1;
          ff=P[j]
        }
      }
    }
    
    for(int i=0; i<=N-1; ++i){
      co(P[i]);
    }
    
  }
  
  
  REP(i,N-1){
    for(int j=1; j<=k; ++j){
      CAN=false;
      if(L[A[i]][j]==true && L[B[i]][j]==true){
        co(j);
        L[A[i]][j]=false;
        L[B[i]][j]=false;
        CAN=true;
        break;
      }
      if(CAN) break;
    }
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:73:18: error: expected ';' before '}' token
   73 |           ff=P[j]
      |                  ^
      |                  ;
   74 |         }
      |         ~
Language: Java

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

public class D {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		Pair[] P = new Pair[N - 1];

		ArrayList<ArrayList<Integer>> Path = new ArrayList<ArrayList<Integer>>();

		for (int i = 0; i < N; i++) {
			Path.add(new ArrayList<Integer>());
		}

		for (int i = 0; i < N - 1; i++) {
			int a = scn.nextInt() - 1, b = scn.nextInt() - 1;
			P[i] = new Pair(a, b);
			Path.get(a).add(b);
			Path.get(b).add(a);
		}
		int K = 0;
		for (int i = 0; i < N; i++) {
			K = Math.max(K, Path.get(i).size());
		}
		ArrayList<ArrayList<Integer>> num = new ArrayList<ArrayList<Integer>>();
		for (int i = 0; i < N; i++) {
			num.add(new ArrayList<Integer>());
		}

		System.out.println(K);
		for (int i = 0; i < N - 1; i++) {
			Pair p = P[i];
			for (int j = 1; j <= K; j++) {
				if (!num.get(p.first).contains(j) && !num.get(p.second).contains(j)) {
					System.out.println(j);
					num.get(p.first).add(j);
					num.get(p.second).add(j);
					break;
				}
			}
		}
	}

}

class Pair implements Comparable<Pair> {
	int first, second;

	public Pair(int f, int s) {
		this.first = f;
		this.second = s;
	}

	@Override
	public int compareTo(Pair o) {// Comparatorを自由記述せよ(これはfirstが小さい順, secondが小さい順)
		if (this.first < o.first) {
			return -1;
		}
		if (this.first > o.first) {
			return 1;
		}
		if (this.second < o.second) {
			return -1;
		}
		if (this.second > o.second) {
			return 1;
		}

		return 0;
	}
}

Compiler output:
Main.java:4: error: class D is public, should be declared in a file named D.java
public class D {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

#define MAX 100002

vector<int> g[MAX];
vector<int> c[MAX];
int d[MAX][MAX];
int n;
int k = 0;

void BFS(int s){
    queue<P> que;
    que.push(make_pair(s, 0));
    while(!que.empty()){
        int u = que.front().first;
        int pre = que.front().second;
        que.pop();
        int tmp = 0;
        rep(i, g[u].size()){
            int v = g[u][i];
            tmp++;
            if(pre==tmp) tmp++;
            d[u][v] = tmp;
            que.push(make_pair(v, tmp));
        }
        chmax(k, tmp);
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> color[n+1];
    vector<P> hen;

    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        hen.push_back(make_pair(a, b));
        g[a].push_back(b);
    }
    BFS(0);

    cout << k << endl;
    rep(i, n-1){
        int a = hen[i].first, b = hen[i].second;
        cout << d[a][b] << endl;
    }


    return 0;
}

Compiler output:
/tmp/cc3ZBRxj.o: in function `BFS(int)':
a.cc:(.text+0x1a5): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc3ZBRxj.o
a.cc:(.text+0x1b5): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc3ZBRxj.o
/tmp/cc3ZBRxj.o: in function `main':
a.cc:(.text+0x3c8): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc3ZBRxj.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

#define MAX 100002

vector<int> g[MAX];
vector<int> c[MAX];
int d[MAX][MAX];
int n;
int k = 0;

void BFS(int s){
    queue<P> que;
    que.push(make_pair(s, 0));
    while(!que.empty()){
        int u = que.front().first;
        int pre = que.front().second;
        que.pop();
        int tmp = 0;
        rep(i, g[u].size()){
            int v = g[u][i];
            tmp++;
            if(pre==tmp) tmp++;
            d[u][v] = tmp;
            que.push(make_pair(v, tmp));
        }
        chmax(k, tmp);
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> color[n+1];
    vector<P> hen;

    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        hen.push_back(make_pair(a, b));
        g[a].push_back(b);
    }
    BFS(0);

    cout << k << endl;
    rep(i, n-1){
        int a = hen[i].first, b = hen[i].second;
        cout << d[a][b] << endl;
    }


    return 0;
}

Compiler output:
/tmp/ccYoGPlI.o: in function `BFS(int)':
a.cc:(.text+0x1a5): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccYoGPlI.o
a.cc:(.text+0x1b5): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccYoGPlI.o
/tmp/ccYoGPlI.o: in function `main':
a.cc:(.text+0x3c8): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccYoGPlI.o
collect2: error: ld returned 1 exit status
Language: C++

#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int n;
int a[100005];
int next[100005],to[100005],head[100005],w[100005];
int ls=0;
	int mx=0; 
queue<int> l;
void bfs(int x){
	l.push(x);
	int z=0;
	while(!l.empty()){
	int k=l.front();
	l.pop();
	for(int i=head[k];i;i=next[i]){
	w[i]=z+1;
	z++;
	z%=mx;
	l.push(to[i]);
	}
	}
	
}
int main(){
	scanf("%d",&n);
	memset(a,0,sizeof(a));

	int s;
	for(int i=1;i<=n-1;i++){
	int x,y;
	scanf("%d%d",&x,&y);
	if(i==1)s=x;
	next[++ls]=head[x];
	head[x]=ls;
	to[ls]=y;
	a[x]++;
	if(a[x]>mx)mx=a[x];
	a[y]++;
	if(a[y]>mx)mx=a[y];
	}
	printf("%d\n",mx);
	bfs(s);
	for(int i=1;i<=n-1;i++){
	printf("%d\n",w[i]);
	}
}

Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:17:31: error: reference to 'next' is ambiguous
   17 |         for(int i=head[k];i;i=next[i]){
      |                               ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/deque:62,
                 from /usr/include/c++/14/queue:62,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:7:5: note:                 'int next [100005]'
    7 | int next[100005],to[100005],head[100005],w[100005];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:35:9: error: reference to 'next' is ambiguous
   35 |         next[++ls]=head[x];
      |         ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:7:5: note:                 'int next [100005]'
    7 | int next[100005],to[100005],head[100005],w[100005];
      |     ^~~~
Language: Java

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

public class D {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		Pair[] P = new Pair[N-1];

		ArrayList<ArrayList<Integer>> Path = new ArrayList<ArrayList<Integer>>();

		for(int i = 0;i < N;i++) {
			Path.add(new ArrayList<Integer>());
		}

		for(int i = 0;i < N-1;i++) {
			int a = scn.nextInt()-1, b = scn.nextInt()-1;
			P[i] = new Pair(a,b);
			Path.get(a).add(b);
			Path.get(b).add(a);
		}
		int K = 0;
		for(int i = 0;i < N;i++) {
			K = Math.max(K, Path.get(i).size());
		}
		ArrayList<ArrayList<Integer>> num = new ArrayList<ArrayList<Integer>>();
		for(int i = 0;i < N;i++) {
			num.add(new ArrayList<Integer>());
		}

		System.out.println(K);
		for(int i = 0;i < N-1;i++) {
			Pair p = P[i];
			for(int j = 1;j <= K;j++) {
				if(num.get(p.first).contains(j) || num.get(p.second).contains(j)) {
					continue;
				}
				System.out.println(j);
				num.get(p.first).add(j);
				num.get(p.second).add(j);
				break;
			}
		}
	}

}


class Pair implements Comparable<Pair>{
	int first,second;
	public Pair(int f,int s) {
		this.first = f;
		this.second = s;
	}
	@Override
	public int compareTo(Pair o) {//Comparatorを自由記述せよ(これはfirstが小さい順, secondが小さい順)
		if(this.first < o.first) {
			return -1;
		}
		if(this.first > o.first) {
			return 1;
		}
		if(this.second < o.second) {
			return -1;
		}
		if(this.second > o.second) {
			return 1;
		}

		return 0;
	}
}

Compiler output:
Main.java:4: error: class D is public, should be declared in a file named D.java
public class D {
       ^
1 error