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

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;

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:14:22: error: invalid declarator before 'g'
   14 | vector<vector<Edge>> g;
      |                      ^
a.cc: In function 'void dfs(int, int, int)':
a.cc:19:11: error: 'g' was not declared in this scope
   19 |     rep(i,g[v].size()){
      |           ^
a.cc:2:36: note: in definition of macro 'rep'
    2 | #define rep(i,n) for (int i=0;i < (n); ++i)
      |                                    ^
a.cc:23:13: error: 'ei' was not declared in this scope; did you mean 'i'?
   23 |         ans[ei] = k; k++;
      |             ^~
      |             i
a.cc: In function 'int main()':
a.cc:31:5: error: 'g' was not declared in this scope
   31 |     g.resize(n)
      |     ^
Language: C++

#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

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);

    vector<bool> used(N, false);
    queue<int > que;
    used[0]=true;
    que.emplace(0);
    while(!que.empty()){
        int v=que.front(); que.pop();
        if(K<(int) G[v].size()) K=(int) 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++;
            que.emplace(u);
            used[u]=true;
        }
    }

    cout << K << endl;
    for(auto p: vp){
        cout << I[p] << endl;
    }
    return 0;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:22: error: no match for call to '(std::map<std::pair<int, int>, int>) (std::pair<int, int>)'
   43 |             cs[u] = I(make_pair(u,v))=I(make_pair(v,u)) = cur++;
      |                     ~^~~~~~~~~~~~~~~~
a.cc:43:40: error: no match for call to '(std::map<std::pair<int, int>, int>) (std::pair<int, int>)'
   43 |             cs[u] = I(make_pair(u,v))=I(make_pair(v,u)) = cur++;
      |                                       ~^~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#include<queue>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<vector<int>>tree(N);
  for (int i = 0; i < N - 1; i ++) {
    int a, b;
    cin >> a >> b;
    a --;
    b --;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  vector<int>cl(N, 0);
  vector<int>par(N);
  cl[0] = 1;
  par[0] = -1;
  queue<int>que;
  que.push(0);
  int K = 0;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    int c = 1:
    for (int i = 0; i < (int)tree[i].size(); i ++) {
      int v = tree[u][i];
      if (cl[v] == 0) {
        while (c == cl[u] || c == par[u]) c ++;
        cl[v] = c;
        c ++;
        que.push(v);
      }
    }
    if (K < c - 1) K = c - 1;
  }
  cout << K << endl;
  for (int i = 0; i < N; i ++) cout << cl[i] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:14: error: expected ',' or ';' before ':' token
   26 |     int c = 1:
      |              ^
a.cc:27:21: error: 'i' was not declared in this scope
   27 |     for (int i = 0; i < (int)tree[i].size(); i ++) {
      |                     ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

using Edge = pair<int,int>;
using Graphy = vector<vector<Edge> >;

int n;
Graphy g;

void dfs(int v, int p, int pc, vector<int> &res) {
  int c = 1;
  if (c == pc) c++;
  for (auto e : g[v]) {
    if (e.first == p) continue;
    res[e.second] = c;
    dfs(e.first, v, c, res);
    c++;
    if (c == pc) c++;
  }
}

int main() {
  cin >> n;
  g.assign(n, vector<Edge>());
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b,i);
    g[b].emplace_back(a,i);
  }
  int mc = 0;
  rep(i,n) {
    mc = max(mc,g[i].size());
  }
  vector<int> res(n-1,-1);

  dfs(0,-1,-1,res);

  cout << mc << endl;
  for (auto u : res) cout << u << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:13: error: no matching function for call to 'max(int&, std::vector<std::pair<int, int> >::size_type)'
   40 |     mc = max(mc,g[i].size());
      |          ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:40:13: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'})
   40 |     mc = max(mc,g[i].size());
      |          ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:40:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |     mc = max(mc,g[i].size());
      |          ~~~^~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

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

  int ans = 0;
  rep(i,n) {
    ans = max(ans, (int)g[i].size());
  }
  vector<int> res(n-1, -1);
  vector<int> dist(n, -1);

  queue<P> q;
  q.push({0,1});
  dist[0] = 0;

  while (!q.empty()) {
    auto p = q.front(); q.pop();
    int v = p.first, c = p.second;
    int col = 1;
    if (col == c) col++;
    for (auto e : g[v]) {
      if (dist[e.first] == -1) {
        dist[e.first] = dist[v.first] + 1;
        q.push({e.first, col});
        res[e.second] = col;
        col++;
        if (col == c) col++;
      }
    }
  }

  cout << ans << endl;
  for (auto v : res) cout << v << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:10: error: expected initializer before '.' token
   15 |     int a. b;
      |          ^
a.cc:16:12: error: 'a' was not declared in this scope
   16 |     cin >> a >> b;
      |            ^
a.cc:16:17: error: 'b' was not declared in this scope
   16 |     cin >> a >> b;
      |                 ^
a.cc:40:32: error: request for member 'first' in 'v', which is of non-class type 'int'
   40 |         dist[e.first] = dist[v.first] + 1;
      |                                ^~~~~
Language: Java

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n - 1];
        int[] b = new int[n - 1];
        List<Integer>[] list = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            list[i] = new ArrayList<>();
        }
        for (int i = 0; i < n - 1; i++) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
            list[a[i]].add(b[i]);
            list[b[i]].add(a[i]);
        }
        int k = 0;
        for (int i = 0; i < n; i++) {
            k = Math.max(k, list[i].size());
        }
        Map<Map<Integer, Integer>, Integer> map = new HashMap<>();
        Queue<Integer> queue = new ArrayDeque<>();
        queue.add(0);
        Set<Integer> seen = new HashSet<>();
        seen.add(0);
        while (queue.size() != 0) {
            int now = queue.poll();
            int color[] = new int[k];
            for (Integer x : list[now]) {
                Map<Integer, Integer> map2 = new HashMap<>();
                map2.put(Math.min(x, now), Math.max(x, now));
                if (map.containsKey(map2)) {
                    color[map.get(map2)]++;
                }
            }
            for (Integer x : list[now]) {
                if (!seen.contains(x)) {
                    Map<Integer, Integer> map2 = new HashMap<>();
                    map2.put(Math.min(x, now), Math.max(x, now));
                    for (int i = 0 ; i < k ; i++) {
                        if (color[i] == 0) {
                            map.put(map2, i);
                            color[i]++;
                            break;
                        }
                    }
                    queue.add(x);
                    seen.add(x);
                }
            }
        }

        System.out.println(k);
        for (int i = 0; i < n - 1; i++) {
            Map<Integer, Integer> map2 = new HashMap<>();
            map2.put(a[i], b[i]);
            System.out.print(map.get(map2) + 1);
            System.out.print("\n");
        }

    }


Compiler output:
Main.java:73: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int Max_Num=1e5+10;

vector<P> G(Max_Num);
int ans[Max_Num];
int K;
void dfs(int n, int col=0, int par=-1){
	rep(i,G[n].size()){
		int next=G[n][i].first;
		int num=G[n][i].second;
		if(next==par) continue;
		int c;
		if(i+1!=col) c=i+1;
		else c=i+2;
		ans[num]=c;
		K=max(K,c);
		dfs(next, c, n);
	}
}

int main(){
	int N;
	cin >> N;
	K=0;
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].emplace_back(P(b,i));
		G[b].emplace_back(P(a,i));
	}
	dfs(0);
	cout << K << 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:20: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'size'
   13 |         rep(i,G[n].size()){
      |                    ^~~~
a.cc:2:39: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
      |                                       ^
a.cc:14:30: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   14 |                 int next=G[n][i].first;
      |                              ^
a.cc:15:29: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int')
   15 |                 int num=G[n][i].second;
      |                             ^
a.cc: In function 'int main()':
a.cc:34:22: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'emplace_back'
   34 |                 G[a].emplace_back(P(b,i));
      |                      ^~~~~~~~~~~~
a.cc:35:22: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'emplace_back'
   35 |                 G[b].emplace_back(P(a,i));
      |                      ^~~~~~~~~~~~
Language: C++

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

map<<int,int>,int> m;
vector<int> g[100005];
int c[100005];
int N;
void dfs(int now,int pre,int num){
    if(num==N-1)return;
    else{
        int K=0;
        int count=num;
        for(int u:g[now]){
            K++;
            if(c[m[make_pair(min(pre,now),max(pre,now))]]==K)K++;
            if(u!=pre){
                if(c[m[make_pair(min(u,now),max(u,now))]]==0){
                    c[m[make_pair(min(u,now),max(u,now))]]=K;
                    count++;
                }
            }
        }
        for(int u:g[now]){
            if(u!=pre)dfs(u,now,count);
        }
    }}


int main(){
    int a,b;
    cin >> N;
    for(int i=1;i<N;i++){
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
        m[make_pair(a,b)]=i;
    }
    dfs(1,-1,0);
    int ans=0;
    for(int i=1;i<N;i++)ans=max(ans,c[i]);
    cout << ans << endl;
    for(int i=1;i<N;i++)cout << c[i] << endl;
}

Compiler output:
a.cc:4:4: error: expected unqualified-id before '<<' token
    4 | map<<int,int>,int> m;
      |    ^~
a.cc: In function 'void dfs(int, int, int)':
a.cc:15:18: error: 'm' was not declared in this scope
   15 |             if(c[m[make_pair(min(pre,now),max(pre,now))]]==K)K++;
      |                  ^
a.cc:17:22: error: 'm' was not declared in this scope
   17 |                 if(c[m[make_pair(min(u,now),max(u,now))]]==0){
      |                      ^
a.cc: In function 'int main()':
a.cc:36:9: error: 'm' was not declared in this scope
   36 |         m[make_pair(a,b)]=i;
      |         ^
Language: C++

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

map<<<int,int>,int>> m;
vector<int> g[100005];
int c[100005];
int N;
void dfs(int now,int pre,int num){
    if(num==N-1)return;
    else{
        int K=0;
        int count=num;
        for(int u:g[now]){
            K++;
            if(c[m[make_pair(min(pre,now),max(pre,now))]]==K)K++;
            if(u!=pre){
                if(c[m[make_pair(min(u,now),max(u,now))]]==0){
                    c[m[make_pair(min(u,now),max(u,now))]]=K;
                    count++;
                }
            }
        }
        for(int u:g[now]){
            if(u!=pre)dfs(u,now,count);
        }
    }}


int main(){
    int a,b;
    cin >> N;
    for(int i=1;i<N;i++){
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
        m[make_pair(a,b)]=i;
    }
    dfs(1,-1,0);
    int ans=0;
    for(int i=1;i<N;i++)ans=max(ans,c[i]);
    cout << ans << endl;
    for(int i=1;i<N;i++)cout << c[i] << endl;
}

Compiler output:
a.cc:4:4: error: expected unqualified-id before '<<' token
    4 | map<<<int,int>,int>> m;
      |    ^~
a.cc: In function 'void dfs(int, int, int)':
a.cc:15:18: error: 'm' was not declared in this scope
   15 |             if(c[m[make_pair(min(pre,now),max(pre,now))]]==K)K++;
      |                  ^
a.cc:17:22: error: 'm' was not declared in this scope
   17 |                 if(c[m[make_pair(min(u,now),max(u,now))]]==0){
      |                      ^
a.cc: In function 'int main()':
a.cc:36:9: error: 'm' was not declared in this scope
   36 |         m[make_pair(a,b)]=i;
      |         ^
Language: C++

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

map<<int,int>,int> m;
vector<int> g[100005];
int c[100005];
int N;
void dfs(int now,int pre,int num){
    if(num==N-1)return -1;
    else{
        int K=0;
        int count=num;
        for(int u:g[now]){
            K++;
            if(c[m[make_pair(min(pre,now),max(pre,now))]]==K)K++;
            if(u!=pre){
                if(c[m[make_pair(min(u,now),max(u,now))]]==0){
                    c[m[make_pair(min(u,now),max(u,now))]]=K;
                    count++;
                }
            }
        }
        for(int u:g[now]){
            if(u!=pre)dfs(u,now,count);
        }
    }}


int main(){
    int a,b;
    cin >> N;
    for(int i=1;i<N;i++){
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
        m[make_pair(a,b)]=i;
    }
    dfs(1,-1,0);
    int ans=0;
    for(int i=1;i<N;i++)ans=max(ans,c[i]);
    cout << ans << endl;
    for(int i=1;i<N;i++)cout << c[i] << endl;
}

Compiler output:
a.cc:4:4: error: expected unqualified-id before '<<' token
    4 | map<<int,int>,int> m;
      |    ^~
a.cc: In function 'void dfs(int, int, int)':
a.cc:9:24: error: return-statement with a value, in function returning 'void' [-fpermissive]
    9 |     if(num==N-1)return -1;
      |                        ^~
a.cc:15:18: error: 'm' was not declared in this scope
   15 |             if(c[m[make_pair(min(pre,now),max(pre,now))]]==K)K++;
      |                  ^
a.cc:17:22: error: 'm' was not declared in this scope
   17 |                 if(c[m[make_pair(min(u,now),max(u,now))]]==0){
      |                      ^
a.cc: In function 'int main()':
a.cc:36:9: error: 'm' was not declared in this scope
   36 |         m[make_pair(a,b)]=i;
      |         ^
Language: C++

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

using Edge = pair<int,int>; // (隣接頂点, 辺番号)
using Graph = vector<Edge>;
int N;


int main() {
    cin >> N;
    Graph G[N];
        G.assign(N, vector<Edge>());
    for (int i = 0; i < N-1; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].emplace_back(b, i); 
        G[b].emplace_back(a, i);
    }
    int max_color = 0;
    for (int i = 0; i < N; ++i) chmax(max_color, (int)G[i].size());
    vector<int> res(N-1, -1);

    vector<int> dist(N, -1);
    queue<pair<int,int>> que; // (頂点, 前回の色)
    que.push({0, -1});
    dist[0] = 0;
    while (!que.empty()) {
        auto p = que.front(); que.pop();
        int v = p.first, c = p.second;
        int color = 1;
        if (color == c) ++color;
        for (auto e : G[v]) {
            if (dist[e.first] == -1) {
                dist[e.first] = dist[v] + 1;
                que.push({e.first, color});
                res[e.second] = color;
                ++color;
                if (color == c) ++color;
            }
        }
    }
    cout << max_color << endl;
    for (auto v : res) cout << v << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: request for member 'assign' in 'G', which is of non-class type 'Graph [N]' {aka 'std::vector<std::pair<int, int> > [N]'}
   14 |         G.assign(N, vector<Edge>());
      |           ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> v(n-1);
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v[i] = make_pair(a, b);
	}
	vector<vector<int>> m(n);
	vector<int> ans(n-1);
	int mans = 0;
	rep(i, n - 1)
	{
		int a = v[i].first;
		int b = v[i].second;
		for (int k = 1; k <＝ n; k++){
			bool ab = binary_search(m[a].begin(), m[a].end(), k);
			bool bb = binary_search(m[b].begin(), m[b].end(), k);
			if (!ab && !bb)
			{
				m[a].push_back(k);
				m[b].push_back(k);
				sort(all(m[a]));
				sort(all(m[b]));
				mans = max(mans, k);
				ans[i] = k;
				break;
			}
		}
	}
	cout << mans << endl;
	rep(i, n - 1)
	{
		cout << ans[i] << endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:36: error: '\U0000ff1d' was not declared in this scope
   36 |                 for (int k = 1; k <＝ n; k++){
      |                                    ^~
a.cc:36:38: error: expected ';' before 'n'
   36 |                 for (int k = 1; k <＝ n; k++){
      |                                      ^~
      |                                      ;
a.cc:36:40: error: expected ')' before ';' token
   36 |                 for (int k = 1; k <＝ n; k++){
      |                     ~                  ^
      |                                        )
a.cc:36:42: error: 'k' was not declared in this scope
   36 |                 for (int k = 1; k <＝ n; k++){
      |                                          ^
Language: C++

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int m = 0;
int n;vector<P> g[110000];
int ans[110000];
dfs(int x, int p, int c){
  int color = 1;
  rep(i,g[x].size()){
    int to = g[x][i].first, ind = g[x][i].second;
    if(to == p)continue;
    if(color == c)color++;
    ans[ind] = color;
    chmax(m, color);
    dfs(to, x, color);
    color++;
  }
}
signed main(){
  cin>>n;
  rep(i,n-1){
    int a, b;cin>>a>>b;a--;b--;
    g[a].push_back(P(b,i));
    g[b].push_back(P(a,i));
  }
  dfs(0,-1,-1);
  cout << m << endl;
  rep(i,n-1){
    cout << ans[i] << endl;
  }
}


Compiler output:
a.cc:42:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
   42 | dfs(int x, int p, int c){
      | ^~~
a.cc: In function 'int dfs(long long int, long long int, long long int)':
a.cc:53:1: warning: no return statement in function returning non-void [-Wreturn-type]
   53 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;


vector<vector<P>> G;
vl ans;

void dfs(int p=-1, int v, int c=-1){
    int k=1;
    for(auto nv:G[v]){
        int next=nv.first,id=nv.second;
        if(next==p)continue;
        if(k==c)k++;
        ans[id]=k;
        k++;
        dfs(v,next,ans[id]);
    }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 

  int n;
  cin >> n;
  G.resize(n);

  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(P(b,i));
    G[b].push_back(P(a,i));
  }
  dfs(0);
  int m=0;
  rep(i,n)m=max(m,(int)G[i].size());
  rep(i,n-1) cout<<ans[i] << endl;
  return 0;
  
}


Compiler output:
a.cc:18:24: error: default argument missing for parameter 2 of 'void dfs(int, int, int)'
   18 | void dfs(int p=-1, int v, int c=-1){
      |                    ~~~~^
a.cc:18:14: note: ...following parameter 1 which has a default argument
   18 | void dfs(int p=-1, int v, int c=-1){
      |          ~~~~^~~~
Language: C++

#キューとdictionaryを利用したBFS
from collections import deque

n = int(input())

ab = [list(map(int,input().split())) for i in range(n-1)]

ver = [[] for i in range(n)]

for i in range(n-1):
    a,b = ab[i][0],ab[i][1]
    ver[a-1].append(b-1)
    ver[b-1].append(a-1)

#print(ver)

color = [dict() for i in range(n)]
q = deque()
i = 1
for v in ver[0]:
    color[0][v] = i
    color[v][0] = i
    q.append((0,v))
    i += 1

#print(q)

while q:
    f,t = q.popleft()
    i = 1
    for v in ver[t]:
        if v == f:
            continue
        if i == color[f][t]:
            i += 1
        color[t][v] = i
        color[v][t] = i
        q.append((t,v))
        i += 1

#print(color)
#辞書のリストで辺の色を管理している
k = 0
for i in range(n):
    k = max(k,len(ver[i]))
print(k)
for i in range(n-1):
    a,b = ab[i][0],ab[i][1]
    print(color[a-1][b-1])


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #\U000030ad\U000030e5\U000030fc\U00003068dictionary\U00003092\U00005229\U00007528\U00003057\U0000305fBFS
    1 | #キューとdictionaryを利用したBFS
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:15:2: error: invalid preprocessing directive #print
   15 | #print(ver)
      |  ^~~~~
a.cc:26:2: error: invalid preprocessing directive #print
   26 | #print(q)
      |  ^~~~~
a.cc:41:2: error: invalid preprocessing directive #print
   41 | #print(color)
      |  ^~~~~
a.cc:42:2: error: invalid preprocessing directive #\U00008f9e\U000066f8\U0000306e\U000030ea\U000030b9\U000030c8\U00003067\U00008fba\U0000306e\U00008272\U00003092\U00007ba1\U00007406\U00003057\U00003066\U00003044\U0000308b
   42 | #辞書のリストで辺の色を管理している
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:2:1: error: 'from' does not name a type
    2 | from collections import deque
      | ^~~~
Language: C++

//============================================================================
// Name        : d.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;

int main() {
	int n;cin>>n;
	vector<int> a(n),b(n);
	vector<vector<pair<int,int>>> e(n);
	for(int i=0;i<n-1;i++){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
		e[a[i]].push_back(make_pair(b[i],i));
		e[b[i]].push_back(make_pair(a[i],i));
	}
	int ansnum=0;
	for(int i=0;i<n;i++){
		ansnum=max(ansnum,int(e[i].size()));
	}
	vector<int> anse(n-1,-1);
	vector<int> c(n);

	vector<int> stack;
	stack.push_back(0);
	while(stack.size()){
		int tempnode=stack.back();
		stack.pop_back();
		int color=1;
		for(int i=0;i<e[tempnode].size();i++){
			int tempe=e[tempnode][i].second;
			if(anse[tempe]==-1){
				if(color==c[tempnode])color++;
				anse[tempe]=color;
				c[e[tempnode][i].first]=color;
				stack.push_back(e[tempnode][i].first);
				color++;
			}
		}
	}
	cout<<ansnum<<endl;
	for(int i=0;i<n-1;i++){
		cout<<anse[i]<<endl;
	}


	return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:53:18: error: expected '}' at end of input
   53 |         return 0;
      |                  ^
a.cc:13:12: note: to match this '{'
   13 | int main() {
      |            ^
Language: C++

import sys
sys.setrecursionlimit(10**6)
def dfs(G,v,p,color):
    cnt=1
    for nv in G[v]:
        if(nv==p):
            continue
        if cnt in liset[v]:
            while(cnt in liset[v]):
                cnt+=1
        liset[v].add(cnt)
        liset[nv].add(cnt)
        dic[str(v)+'t'+str(nv)]=cnt
        dfs(G,nv,v,cnt)
N=int(input())
G=[[] for i in range(N)]
e=[]
for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
    e.append([a,b])
l=0
for i in range(N):
    l=max(l,len(G[i]))
liset=[set() for i in range(N)]
dic={}
dfs(G,0,-1,0)
print(l)
for i in range(N-1):
    if str(e[i][0])+'t'+str(e[i][1]) in dic:
        print(dic[str(e[i][0])+'t'+str(e[i][1])])
    else:
        print(dic[str(e[i][1])+'t'+str(e[i][0])])

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:28:4: error: expected constructor, destructor, or type conversion before '(' token
   28 | dfs(G,0,-1,0)
      |    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

//dfsで探索してく
struct Edge {int to; int id;};
vector<vector<Edge>> tree;
vector<int> color;

void dfs(int v, int c = -1, int p=-1) {
    int cnt = 1;
    rep(i,tree[v].size) {
        int next = tree[v][i].to;
        int hen = tree[v][i].id;
        if(next==p) continue;
        if(cnt==c) cnt++;
        color[hen] = cnt; cnt++;
        dfs(next, color[hen], v);
    }
}
int main() {
    int n; 
    cin >> n;
    tree.resize(n);
    color.resize(n-1);
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back((Edge){a, i});
        tree[b].push_back((Edge){b, i});
    }
    dfs(0);
    //使った色の数
    int mx = 0;
    rep(i,n) mx = max(mx, int(tree[i].size()));
    cout << mx << endl;

    //使った色列挙
    rep(i,n-1) {
        cout << color[i] << endl;
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:16:19: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = Edge; _Alloc = std::allocator<Edge>; size_type = long unsigned int]' (did you forget the '()' ?)
   16 |     rep(i,tree[v].size) {
      |                   ^
a.cc:4:34: note: in definition of macro 'rep'
    4 | #define rep(i,n) for(int i=0; i<(n); i++)
      |                                  ^
Language: C++



#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <set>

using namespace std;

void A();
void B();
void C();
void D();
void E();
void F();

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	D();

}

void A() {

	string day;
	cin >> day;

	int daysAways = 0;
	
	if (day == "SUN") daysAways = 7;
	if (day == "MON") daysAways = 6;
	if (day == "TUE") daysAways = 5;
	if (day == "WED") daysAways = 4;
	if (day == "THU") daysAways = 3;
	if (day == "FRI") daysAways = 2;
	if (day == "SAT") daysAways = 1;


	int result = 0;


	cout << daysAways << endl;

	
}

void B() {

	int N;
	string S;
	cin >> N >> S;

	for (int i = 0; i < S.length(); i++) {

		int ch = (int)(S[i]-'A');

		S[i] = (ch + N) % 26 + 'A';


	}




	cout << S << endl;

	
}

void C() {
	long long A, B, X;
	cin >> A >> B >> X;

	int result = 0;

  	for (int d = 9; d >= 0; d--) {

		long long dif = X - (B * d);
		int n = (int)(dif / A);

		if (log10(n) > d-1 && log10(n) <= d + 1) {

			result = n;
			break;
		}
	}

	cout << result << endl;
}

void D() {

	int N;
	cin >> N;

	vector<vector<int>> edges(N-1, { 0, 0 });

	for (auto& edge : edges) {
		cin >> edge[0];
		cin >> edge[1];
	}

	int maxColors = 1;

	vector<int> colors(N-1, 0);

	vector<vector<int>> queue;

	queue.push_back({ 1, 0 });
	
	while ((int)queue.size() > 0) {

		vector<int> vertex = queue[0];
		queue.erase(queue.begin(), queue.begin() + 1);

		int color = 1;

		for (int n = 0; n < N-1; n++) {

			if (edges[n][0] == vertex[0] || edges[n][1] == vertex[0]) {
				//is an edge that contains vertex
				if (colors[n] == 0) {
					if (color == vertex[1]) color++;
					colors[n] = color;

					if (edges[n][0] == vertex[0]) {
						queue.push_back({ edges[n][1], color });
					}
					else {

						queue.push_back({ edges[n][0], color });
					}

					color++;

				}
			}

			maxColors = max(maxColors, color-1);
		}
	}

	cout << maxColors << endl;

	for (int i = 0; i < N-1; i++) cout << colors[i] << endl;

	
}

void E() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void F() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {



	}
}



Compiler output:
a.cc: In function 'void C()':
a.cc:87:21: error: 'log10' was not declared in this scope
   87 |                 if (log10(n) > d-1 && log10(n) <= d + 1) {
      |                     ^~~~~
Language: C++

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

int main(){
    int64_t      a,b,x;
    cin >> a >> b >> x;
    int64_t l  = 0,r = pow(10,9) + 1;
    auto keta = [&](int64_t c){
        int res = 0;
        while(c){
            c /= 10;
            res++;
        }
    }
    auto f = [&](int64_t c){
        return a * c + b * keta(c);
    }
    while(r-l > 1){
        int64_t c = (l+r)/2;
        if(f(c) <= x) l = c;
        else r = c; 
    }
    cout << l << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: expected ',' or ';' before 'auto'
   16 |     auto f = [&](int64_t c){
      |     ^~~~
a.cc:21:12: error: 'f' was not declared in this scope
   21 |         if(f(c) <= x) l = c;
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
vector<int> c[100002];
vector<int> G[100002];
int visited[100002]={};
int ans[100002][100002]={};
set<pair<int,int>> s;
int Max=0;
void dfs(int now){
    visited[now]=1;
    int i = 1;
    //c[now].push_back(i);
    //cout<<now<<"から出る辺を"
    //s.insert(make_pair(now,i));
    for(int j=0;j<G[now].size();j++){
        int child = G[now][j];
        if(!visited[child]){
            while(s.count(make_pair(now,i))){
                i++;
            }
            c[now].push_back(i);
            c[child].push_back(i);
            s.insert(make_pair(now,i));
            s.insert(make_pair(child,i));
            ans[now][child] = i;
            if(Max<i){
                Max = i;
            }
            dfs(child);
        }
    }

}
//無向グラフの作り方
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n-1){
        cin >> a[i]>>b[i];
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    dfs(1);
    /*
    for(int i=1;i<=n;i++){
        cout << "G[" <<i <<"]={";
        for(unsigned int j=0;j<G[i].size();j++){
            cout<<G[i][j]<<" ";
        }
        cout<<"}"<<endl;
    }
    for(int i=1;i<=n;i++){
        cout << "C[" <<i <<"]={";
        for(unsigned int j=0;j<c[i].size();j++){
            cout<<c[i][j]<<" ";
        }
        cout<<"}"<<endl;
    }
    */
   cout<<Max<<endl;
    rep(i,n-1){
        cout<<ans[a[i]][b[i]]<<endl;
    }
}

Compiler output:
/tmp/cc3eAjAK.o: in function `dfs(int)':
a.cc:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/cc3eAjAK.o
a.cc:(.text+0x146): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/cc3eAjAK.o
a.cc:(.text+0x173): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/cc3eAjAK.o
a.cc:(.text+0x1ac): relocation truncated to fit: R_X86_64_PC32 against symbol `Max' defined in .bss section in /tmp/cc3eAjAK.o
a.cc:(.text+0x1bc): relocation truncated to fit: R_X86_64_PC32 against symbol `Max' defined in .bss section in /tmp/cc3eAjAK.o
/tmp/cc3eAjAK.o: in function `main':
a.cc:(.text+0x3a7): relocation truncated to fit: R_X86_64_PC32 against symbol `Max' defined in .bss section in /tmp/cc3eAjAK.o
/tmp/cc3eAjAK.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x5ce): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/cc3eAjAK.o
a.cc:(.text+0x5e7): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/cc3eAjAK.o
collect2: error: ld returned 1 exit status
Language: C++

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    rep(i,n-1) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        c[a[i]]++; c[b[i]]++;
    }
    int mx = 0;
    rep(i,n) mx = max(mx,c[i]);
    cout << mx << endl;
    vector<vector<int>> d(n,vector<int>); 
    rep(i,n-1){
        bool ok = true;
        for(int j=1;j<=mx;j++){
            if(d[a[i]][j]!=0||d[b[i]][j]!=0) continue;
            if(ok){
                cout << j << endl;
                d[a[i]][j]++; d[b[i]][j]++;
                ok = false;
                break;
            }
        }
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:40: error: expected primary-expression before ')' token
   19 |     vector<vector<int>> d(n,vector<int>);
      |                                        ^
Language: Java

import java.util.*;

public class Main {
  public static int C;
  public static ArrayList[] edge;
  public static HashMap[] map;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    edge = new ArrayList[n];
    map = new HashMap[n];
    for(int i = 0; i < n; i++) {
      edge[i] = new ArrayList<Integer>();
      map[i] = new HashMap<Integer, Integer>();
    }
    int[] a = new int[n - 1];
    int[] b = new int[n - 1];
    for(int i = 0; i < n - 1; i++) {
      a[i] = sc.nextInt() - 1;
      b[i] = sc.nextInt() - 1;
      edge[a[i]].add(b[i]);
      edge[b[i]].add(a[i]);
    }
    for(int i = 0; i < n; i++) {
      C = Math.max(C, edge[i].size());
    }
    Queue queue = new PriorityQueue<Integer>();
    queue.add(0);
    int[] seen = new int[n];
    seen[0] = 1;
    int[] co = new int[n];
    while(queue.size() > 0) {
      int v = queue.poll();
      seen[v] = 1;
      ArrayList<Integer> e = edge[v];
      int pp = 1;
      for(int i = 0; i < e.size(); i++) {
        int u = e.get(i);
        if(seen[u] == 0) {
          if(pp == co[v]) pp++;
          map[v].put(u, pp);
          co[u] = pp;
          pp++;
          queue.add(u);
        }
      }
    }
    System.out.println(C);
    for(int i = 0; i < n - 1; i++) {
      System.out.println(map[a[i]].get(b[i]));
    }
  }
}

Compiler output:
Main.java:33: error: incompatible types: Object cannot be converted to int
      int v = queue.poll();
                        ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: Java

import java.util.*;

public class Main {
  public static int C;
  public static ArrayList[] edge;
  public static HashMap[] map;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    edge = new ArrayList[n];
    map = new HashMap[n];
    for(int i = 0; i < n; i++) {
      edge[i] = new ArrayList<Integer>();
      map[i] = new HashMap<Integer, Integer>();
    }
    int[] a = new int[n - 1];
    int[] b = new int[n - 1];
    for(int i = 0; i < n - 1; i++) {
      int a[i] = sc.nextInt() - 1;
      int b[i] = sc.nextInt() - 1;
      edge[a[i]].add(b[i]);
      edge[b[i]].add(a[i]);
    }
    for(int i = 0; i < n; i++) {
      C = Math.max(C, edge[i].size());
    }
    Queue queue = new PriorityQueue<Integer>();
    queue.add(0);
    int[] seen = new int[n];
    seen[0] = 1;
    int[] co = new int[n];
    while(queue.size() > 0) {
      int v = queue.poll();
      seen[v] = 1;
      ArrayList<Integer> e = edge[v];
      int pp = 1;
      for(int i = 0; i < e.size(); i++) {
        int u = e.get(i);
        if(seen[u] == 0) {
          if(pp == co[v]) pp++;
          map[v].put(u, pp);
          co[u] = pp;
          pp++;
          queue.add(u);
        }
      }
    }
    System.out.println(C);
    for(int i = 0; i < n - 1; i++) {
      System.out.println(map[a[i]].get(b[i]));
    }
  }
}

Compiler output:
Main.java:19: error: ']' expected
      int a[i] = sc.nextInt() - 1;
            ^
Main.java:19: error: ';' expected
      int a[i] = sc.nextInt() - 1;
             ^
Main.java:19: error: not a statement
      int a[i] = sc.nextInt() - 1;
                              ^
Main.java:20: error: ']' expected
      int b[i] = sc.nextInt() - 1;
            ^
Main.java:20: error: ';' expected
      int b[i] = sc.nextInt() - 1;
             ^
Main.java:20: error: not a statement
      int b[i] = sc.nextInt() - 1;
                              ^
6 errors
Language: Java

import java.util.*;

public class ABC146D_Coloring_Edges_on_Tree {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N - 1];
		int[] B = new int[N - 1];
		int[] degree = new int[N];
		Arrays.fill(degree, 0);
		
		for(int i = 0; i < N - 1; i++){
			A[i] = sc.nextInt() - 1;
			B[i] = sc.nextInt() - 1;
			degree[A[i]]++;
			degree[B[i]]++;
		}
		
		int max = -1;
		for(int i = 0; i < N - 1; i++){
			max = Math.max(degree[i], max);
		}
		System.out.println(max);

		ArrayList<ArrayList<Integer>> vertexes = new ArrayList<ArrayList<Integer>>();
		for(int i = 0; i < N; i++){
			ArrayList<Integer> v = new ArrayList<Integer>();
			vertexes.add(v);
		}
		
		for(int i = 0; i < N - 1; i++){
			vertexes.get(A[i]).add(B[i]);
			vertexes.get(B[i]).add(A[i]);
		}

		boolean[] seen = new boolean[N];
		Arrays.fill(seen, false);
		ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
		int[] color = new int[N];
		Arrays.fill(color, 0);
		
		Map<Integer, Map<Integer,Integer>> map = new HashMap<Integer, Map<Integer,Integer>>();
		
		queue.add(0);
		seen[0] = true;
		while(!queue.isEmpty()){
			int x = queue.poll();
			int c = color[x];
			map.put(x , new HashMap<Integer,Integer>());
			ArrayList<Integer> v = vertexes.get(x);
			for(int i = 0; i < v.size(); i++){
				if(!seen[v.get(i)]){
					queue.add(v.get(i));
					seen[v.get(i)] = true;
					c = (c + 1) % max;
					map.get(x).put(v.get(i), c);
					color[v.get(i)] = c;
				}
			}
		}
		for(int i = 0; i < N - 1; i++){
			System.out.println(map.get(A[i]).get(B[i]) + 1);
		}
	}
}

Compiler output:
Main.java:3: error: class ABC146D_Coloring_Edges_on_Tree is public, should be declared in a file named ABC146D_Coloring_Edges_on_Tree.java
public class ABC146D_Coloring_Edges_on_Tree {
       ^
1 error
Language: Java

import java.util.*;

public class ABC146C_Buy_an_Integer {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N - 1];
		int[] B = new int[N - 1];
		int[] vertex = new int[N];
		Arrays.fill(vertex, 0);
		for(int i = 0; i < N - 1; i++){
			A[i] = sc.nextInt() - 1;
			B[i] = sc.nextInt() - 1;
			vertex[A[i]]++; 
			vertex[B[i]]++; 
		}
		int max = -1;
		for(int i = 0; i < N - 1; i++){
			max = Math.max(vertex[i], max);
		}
		System.out.println(max);
		int[] color = new int[N];
		boolean[] seen = new boolean[N];
		Arrays.fill(seen, false);
		color[0] = -1;
		int x = 0;
		for(int i = 0; i < N - 1; i++){
			
			if(!seen[A[i]]){
				seen[A[i]] = true;
				x = color[i];
			}
			x++;
			int next = (x % max);
			System.out.println(next + 1);
			color[B[i]] = next;
		}
	}
}

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

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

int main() {
    int N; cin >> N;
    vector< vector<int> > G(N);
    vector< pair<int, int> > v;
    int a, b;
    for (int i = 1; i < N; i++) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        v.push_back(make_pair(a, b));
    }
    int K = 0;
    map< pair<int, int>, int> I;
    vector<int> color(N);
    vector<int> check(N); check[0] = 1
    queue<int> q;
    q.push(0);
    int tmp;
    while(!q.empty()) {
        tmp = q.front(); q.pop();
        if (K < G[tmp].size()) K = G[tmp].size();
        int cur = 1;
        for (int u:G[tmp]){
            if (check[u]) continue;
            if (cur == color[tmp]) cur++;
            color[u] = I[make_pair(u, tmp)] = I[make_pair(tmp, u)] = cur++;
            check[u]++;
            q.push(u);
        }
    }
    cout << K << endl;
    for (auto p:v) cout << I[p] << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:39: error: expected ';' before 'queue'
   22 |     vector<int> check(N); check[0] = 1
      |                                       ^
      |                                       ;
   23 |     queue<int> q;
      |     ~~~~~                              
a.cc:24:5: error: 'q' was not declared in this scope
   24 |     q.push(0);
      |     ^
Language: C++

#include#include<iostream>
#include<vector>
using namespace std;

const int sz=1e5+10;
vector<int> ans(sz,0);
vector<vector<pair<int,int> > > roads;

void dfs(int now, int back, int back_color)
{
    int cnt=1;
    for(pair<int,int> i : roads[now])
    {
        if(i.first==back)continue;
        if(cnt==back_color)cnt++;
        ans[i.second]=cnt;
        dfs(i.first,now,cnt);
        cnt++;
    }
}

main()
{
    int a;
    scanf("%d",&a);
    roads.resize(a);
    for(int i=0;i<a-1;i++)
    {
        int b,c;
        scanf("%d%d",&b,&c);
        b--,c--;
        roads[b].push_back({c,i});
        roads[c].push_back({b,i});

    }

    int k=0;
    for(int i=0;i<a;i++)k=max(k,(int)roads[i].size());

    dfs(0,-1,-1);

    printf("%d\n",k);
    for(int i=0;i<a-1;i++)printf("%d\n",ans[i]);

    return 0;
}

Compiler output:
a.cc:1:9: error: #include expects "FILENAME" or <FILENAME>
    1 | #include#include<iostream>
      |         ^
a.cc:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:25:5: error: 'scanf' was not declared in this scope
   25 |     scanf("%d",&a);
      |     ^~~~~
a.cc:42:5: error: 'printf' was not declared in this scope
   42 |     printf("%d\n",k);
      |     ^~~~~~
a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    2 | #include<vector>
  +++ |+#include <cstdio>
    3 | using namespace std;