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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

int check(set<int> a, set<int> b)
{
    int i = 1;
    while (a.count(i) || b.count(i))
    {
        i++;
    }
    return i;
}

signed main()
{
    int N;
    cin >> N;
    vector<unordered_set<int>> ab(N);
    vi ans(N - 1);

    int maxans = 0;

    REP(i, N - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        int color = check(ab.at(a), ab.at(b));
        maxans = max(color, maxans);
        ab.at(a).insert(color);
        ab.at(b).insert(color);
        ans.at(i) = color;
    }

    cout << maxans << endl;
    REP(i, N - 1)
    {
        cout << ans.at(i) << endl;
    }
    return 0;
    // system("pause");
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:32: error: could not convert 'ab.std::vector<std::unordered_set<long long int> >::at(((std::vector<std::unordered_set<long long int> >::size_type)a))' from '__gnu_cxx::__alloc_traits<std::allocator<std::unordered_set<long long int> >, std::unordered_set<long long int> >::value_type' {aka 'std::unordered_set<long long int>'} to 'std::set<long long int>'
   65 |         int color = check(ab.at(a), ab.at(b));
      |                           ~~~~~^~~
      |                                |
      |                                __gnu_cxx::__alloc_traits<std::allocator<std::unordered_set<long long int> >, std::unordered_set<long long int> >::value_type {aka std::unordered_set<long long int>}
Language: C++

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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> G(n);
    vector<pii> vp;

    rep(i,n){
        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;

    vector<int> cs(n,0);
    vector<int> used(n,0);
    used[0]=1;

    map<pii,int> I;
    queue<int> que;
    que.emplace(0);
    while(!que.empty()){
        int v=que.first();que.pop();
        if(K<(int)G[v].size()) K = G[v].size();
        
        int cur=1;
        for(int u:G[v]){
            if(used[u]) continue;
            if(cs[v]==cur) cur++;
            cs[u]=I[make_pair(u,v)]=I[make_pair(v,u)]=cur;
            cur++;
            que.emplace(u);
        }
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:33:19: error: 'class std::queue<int>' has no member named 'first'
   33 |         int v=que.first();que.pop();
      |                   ^~~~~
Language: C++

//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
using namespace std;

int N;

int K = 0;

void solve(map<pair<int,int>,int> color,vector<vector<int>> list){
	vector<int> used(N);
	vector<int> col(N);
	used[1] = 1;
	queue<int> q;
	q.push(1);
	while(!q.empty()){
		int point = q.front();
		q.pop();
		used[point] = 1;
		int color = 1;
		for(int i=0;i<list[point].size();i++){
			if(!used[list[point][i]]){
				q.push(list[point][i]);
				if(point==col[point]) color++;
				col[list[point][i]] = color;
				color[make_pair(list[point][i],point)] = color;
				color[make_pair(point,list[point][i])] = color;
				if(K<color) K=color;
				color++;
			}
		}
	}
}

int main(){
	vector<pair<int,int>> edge; 
	vector<vector<int>> list(N);
	map<pair<int,int>,int> color;

	cin >> N;
	for(int i=1;i<N;i++){
		int a,b;
		cin >> a >> b;
		edge.push_back(make_pair(a,b));
		list[a].push_back(b);
		list[b].push_back(a);
	}

	solve(color,list);

	cout << K << endl;
	for(int i=1;i<N;i++){
		cout << color[edge[i]] << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'void solve(std::map<std::pair<int, int>, int>, std::vector<std::vector<int> >)':
a.cc:35:38: error: no match for 'operator[]' (operand types are 'int' and 'std::pair<int, int>')
   35 |                                 color[make_pair(list[point][i],point)] = color;
      |                                      ^
a.cc:36:38: error: no match for 'operator[]' (operand types are 'int' and 'std::pair<int, int>')
   36 |                                 color[make_pair(point,list[point][i])] = color;
      |                                      ^
Language: C++

//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
using namespace std;

int N;
int a[100000];
int b[100000];

int K = 0;
int col[100000][100000];//i~j間の色をcol[i][j]とおく

vector<bool> visited(100000);//点iが訪問済みかどうかをvisted[i]で表す
vector<vector <int>> edge(100000);//点iから行ける点をedge[i]にまとめる 

void search(int point,int prev_color){
	visited[point] = true;
	int color = 1;
	for(int i=0;i<edge[point].size();i++){
		if(!visited[edge[point][i]]){
			if(color==prev_color) color++;
			int new_color = color;
			color++;
			col[point][edge[point][i]] = new_color;
			col[edge[point][i]][point] = new_color;
			if(new_color>K) K = new_color;
			//cout << "i:" << i << " prev_color:" << prev_color << " new_color:" << new_color <<" point:" << point << " next_point:" << edge[point][i] << endl;
			search(edge[point][i],new_color);
		}
	}
}

void solve(){
	for(int i=1;i<N;i++){
		edge[a[i]].push_back(b[i]);
		edge[b[i]].push_back(a[i]);
	}
	search(a[1],-1);
}

int main(){
	cin >> N;
	for(int i=1;i<N;i++) cin >> a[i] >> b[i];

	solve();

	cout << K << endl;
	for(int i=1;i<N;i++) cout <<  col[a[i]][b[i]] << endl;
	return 0;
}


Compiler output:
/tmp/ccJJ6AY2.o: in function `search(int, int)':
a.cc:(.text+0x1a): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccJJ6AY2.o
a.cc:(.text+0x5d): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccJJ6AY2.o
a.cc:(.text+0x86): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccJJ6AY2.o
a.cc:(.text+0xd5): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccJJ6AY2.o
a.cc:(.text+0x128): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccJJ6AY2.o
a.cc:(.text+0x18c): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccJJ6AY2.o
a.cc:(.text+0x1ce): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccJJ6AY2.o
/tmp/ccJJ6AY2.o: in function `solve()':
a.cc:(.text+0x22b): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccJJ6AY2.o
a.cc:(.text+0x27b): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccJJ6AY2.o
/tmp/ccJJ6AY2.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x440): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccJJ6AY2.o
a.cc:(.text+0x466): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
using namespace std;

int N;
int a[100000];
int b[100000];

int K = 0;
int col[100000][100000];//i~j間の色をcol[i][j]とおく

vector<bool> visited(100000);//点iが訪問済みかどうかをvisted[i]で表す
vector<vector <int>> edge(100000);//点iから行ける点をedge[i]にまとめる 

void search(int point,int prev_color){
	visited[point] = true;
	int color = 1;
	for(int i=0;i<edge[point].size();i++){
		if(!visited[edge[point][i]]){
			if(color==prev_color) color++;
			int new_color = color;
			color++;
			col[point][edge[point][i]] = new_color;
			col[edge[point][i]][point] = new_color;
			if(new_color>K) K = new_color;
			//cout << "i:" << i << " prev_color:" << prev_color << " new_color:" << new_color <<" point:" << point << " next_point:" << edge[point][i] << endl;
			search(edge[point][i],new_color);
		}
	}
}

void solve(){
	for(int i=1;i<N;i++){
		edge[a[i]].push_back(b[i]);
		edge[b[i]].push_back(a[i]);
	}
	search(a[1],-1);
}

int main(){
	cin >> N;
	for(int i=1;i<N;i++) cin >> a[i] >> b[i];

	solve();

	cout << K << endl;
	for(int i=1;i<N;i++) cout <<  col[a[i]][b[i]] << endl;
	return 0;
}


Compiler output:
/tmp/ccCBGRGC.o: in function `search(int, int)':
a.cc:(.text+0x1a): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccCBGRGC.o
a.cc:(.text+0x5d): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccCBGRGC.o
a.cc:(.text+0x86): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccCBGRGC.o
a.cc:(.text+0xd5): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccCBGRGC.o
a.cc:(.text+0x128): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccCBGRGC.o
a.cc:(.text+0x18c): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccCBGRGC.o
a.cc:(.text+0x1ce): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccCBGRGC.o
/tmp/ccCBGRGC.o: in function `solve()':
a.cc:(.text+0x22b): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccCBGRGC.o
a.cc:(.text+0x27b): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccCBGRGC.o
/tmp/ccCBGRGC.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x440): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccCBGRGC.o
a.cc:(.text+0x466): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
int mincol = 0;

map <pair<int,int>, int > edge;

void color_edges(vector<vector<int> > arr)
{
    queue <int> q;
    q.push(1);
    while(!q.empty()){
        unordered_set <int> col;
        for(int i=1;i<=mincol;i++){
            col.insert(i);
        }

        int v = q.front();
        q.pop();

        for(int i=0;i<arr[v].size();i++){
            int ecol = edge[{v, arr[v][i]}]
            if(ecol == -1){
                q.push(arr[v][i]);
                auto it = col.begin();
                edge[{v, arr[v][i]}] = *it;
                edge[{arr[v][i], v}] = *it;
                col.erase(it);
            }
            else{
                col.erase(col.find(ecol));
            }
        }
    }
}

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

    int n;
    cin >> n;
    vector<vector<int>> arr(n+1);
    vector<pair<int,int> > input;

    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        input.push_back({a, b});
        edge[{a,b}] = -1;
        edge[{b,a}] = -1;
        arr[a].push_back(b);
        arr[b].push_back(a);

        mincol = max(mincol, (int)arr[a].size());
        mincol = max(mincol, (int)arr[b].size());
    }

    cout << mincol << '\n';
    color_edges(arr);
    for(int i=0;i<input.size();i++){
       cout <<  edge[{input[i].first, input[i].second}] << '\n';
    }
    return 0;
}


Compiler output:
a.cc: In function 'void color_edges(std::vector<std::vector<int> >)':
a.cc:22:13: error: expected ',' or ';' before 'if'
   22 |             if(ecol == -1){
      |             ^~
a.cc:29:13: error: 'else' without a previous 'if'
   29 |             else{
      |             ^~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#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, 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);
    for(int i=0;i<-1;++i) {
        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;
    for (int i=0;i<n;++i) {
        mx = max(mx, int(g[i].size()));
        cout << mx << endl;
        for(int i =0;i<n-1;++i) {
            cout << ans[i] << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:10:37: error: expected ';' before '<' token
   10 | #define rep(i, n) for (int i = 0, i < (n); ++i)
      |                                     ^
a.cc:21:5: note: in expansion of macro 'rep'
   21 |     rep(i, g[v].size()) {
      |     ^~~
a.cc:10:37: error: expected primary-expression before '<' token
   10 | #define rep(i, n) for (int i = 0, i < (n); ++i)
      |                                     ^
a.cc:21:5: note: in expansion of macro 'rep'
   21 |     rep(i, g[v].size()) {
      |     ^~~
Language: C++

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

vector<P> edge[200000]
int tyo[200000];
P ans[200000];
int depth[200000];

void dfs(int i){
  int now_v = i;
  REP(j,edge[now_v].size()){
    int next_v = edge[now_v].[i];

  }
}


signed main(){
  int n;
  cin >> n;
  REP(i,n){
    int a1,b1;
    cin >> a1 >> b1;
    a1--;b1--;
    edge[a1].pb(P(b1,i));
    edge[b1].pb(P(a1,i));
    tyo[a1] ++;
    tyo[b1] ++;
  }
  int ma = 0;
  REP(i,n){
    ma = max(ma,tyo[i]);
  }
  depth[0]=1;
  dfs(0);

  return 0;
}


Compiler output:
a.cc:17:13: error: expected initializer before 'long'
   17 | #define int long long
      |             ^~~~
a.cc:31:1: note: in expansion of macro 'int'
   31 | int tyo[200000];
      | ^~~
a.cc: In function 'void dfs(long long int)':
a.cc:37:9: error: 'edge' was not declared in this scope
   37 |   REP(j,edge[now_v].size()){
      |         ^~~~
a.cc:13:41: note: in definition of macro 'REP'
   13 | #define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
      |                                         ^
a.cc:38:30: error: expected unqualified-id before '[' token
   38 |     int next_v = edge[now_v].[i];
      |                              ^
a.cc: In function 'int main()':
a.cc:51:5: error: 'edge' was not declared in this scope
   51 |     edge[a1].pb(P(b1,i));
      |     ^~~~
a.cc:53:5: error: 'tyo' was not declared in this scope
   53 |     tyo[a1] ++;
      |     ^~~
a.cc:58:17: error: 'tyo' was not declared in this scope
   58 |     ma = max(ma,tyo[i]);
      |                 ^~~
Language: C++

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

int main(){
  long long n; cin >> n;
  vector<vector<long long>> e(n), c(n);
  vector<pair<long long, long long> per(n - 1);
  for(int i = 0; i < n - 1; i++){
    long long a, b; cin >> a >> b;
    a--; b--;
    e.at(a).push_back(b);
    e.at(b).push_back(a);
    c.at(a).push_back(0);
    c.at(b).push_back(0);
    per.at(i).first = a;
    per.at(i).second = b;
  }
  vector<long long> col(n - 1);
  queue<long long> que;
  que.push(0);
  while(!que.empty()){
    long long u = que.front();
    que.pop();
    for(int i : e.at(u)){
      if(c.at(u).at(i) != 0){
        col.at(c.at(u).at(i)) = 1;
        continue;
      }
      for(int j = 0; j < n - 1; j++){
        if(col.at(j) == 0){
          c.at(u).at(i) = col.at(j);
          c.at(i).at(u) = col.at(j);
          col.at(j) = 1;
        }
        que.push(i);
      }
    }
    for(int i = 0; i < n - 1; i++){
      if(col.at(i) == 1) col.at(i) = 0;
    }
  }
  for(int i = 0; i < n; i++){
    cout << c.at(per.at(i).first).at(per.at(i).second) << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:46: error: template argument 1 is invalid
    7 |   vector<pair<long long, long long> per(n - 1);
      |                                              ^
a.cc:7:46: error: template argument 2 is invalid
a.cc:15:5: error: 'per' was not declared in this scope
   15 |     per.at(i).first = a;
      |     ^~~
a.cc:43:18: error: 'per' was not declared in this scope
   43 |     cout << c.at(per.at(i).first).at(per.at(i).second) << endl;
      |                  ^~~
Language: C++

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

int main(){
  long long n; cin >> n;
  vector<vector<long long>> e(n), c(n);
  vector<pair<long long, long long> per(n - 1);
  for(int i = 0; i < n - 1; i++){
    long long a, b; cin >> a >> b;
    a--; b--;
    e.at(a).push_back(b);
    e.at(b).push_back(a);
    c.at(a).push_back(0);
    c.at(b).push_back(0);
    per.at(i).first = a;
    per.at(i).second = b;
  }
  vector<long long> col(n - 1);
  queue<long long> que;
  que.push(0);
  while(!que.empty()){
    long long u = que.front();
    que.pop();
    for(int i : e.at(u)){
      if(c.at(u).at(i) != 0){
        col.at(c.at(u).at(i)) = 1;
        continue;
      }
      for(int j = 0; j < n - 1; j++){
        if(col.at(j) == 0){
          c.at(u).at(i) = col.at(j);
          c.at(i).at(u) = col.at(j);
          col.at(j) = 1;
        }
        que.push(i);
      }
    }
    for(int i = 0; i < n - 1; i++){
      if(col.at(i) == 1) col.at(i) = 0;
    }
  }
  for(int i = 0; i < n; i++){
    cout << c.at(per.at(i)).at(per.at(b)) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:46: error: template argument 1 is invalid
    7 |   vector<pair<long long, long long> per(n - 1);
      |                                              ^
a.cc:7:46: error: template argument 2 is invalid
a.cc:15:5: error: 'per' was not declared in this scope
   15 |     per.at(i).first = a;
      |     ^~~
a.cc:43:18: error: 'per' was not declared in this scope
   43 |     cout << c.at(per.at(i)).at(per.at(b)) << endl;
      |                  ^~~
a.cc:43:39: error: 'b' was not declared in this scope
   43 |     cout << c.at(per.at(i)).at(per.at(b)) << endl;
      |                                       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(ll i = 0; i < N; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
vector<pair<int,int>> edge[1e5+5]
int ans[1e5+5]={};

void dfs(int from,int pre,int precolor){
    int color=1;
    for(auto e:edge[from]){
        int to,id;
        tie(to,id)=e;
        if(to==pre) continue;
        if(color==precolor) color++;
        ans[id]=color;
        dfs(to,from,color);
        color++;
    }
}
signed main(){
    int n;cin>>n;
    rep(i,n-1){
        int a,b;cin>>a>>b;
        edge[a-1].emplace_back(b-1,i);
        edge[b-1].emplace_back(a-1,i);
    }
    rep(i,n-1) ans[i]=-1;
    dfs(0,-1,-1);

    int ansnum=0;
    rep(i,n-1){
        ansnum=max(ansnum,ans[i]);
    }
    cout<<ansnum<<endl;
    rep(i,n-1) cout<<ans[i]<<endl;
    return 0;
}

Compiler output:
a.cc:13:1: error: expected initializer before 'int'
   13 | int ans[1e5+5]={};
      | ^~~
a.cc: In function 'void dfs(int, int, int)':
a.cc:17:16: error: 'edge' was not declared in this scope
   17 |     for(auto e:edge[from]){
      |                ^~~~
a.cc:22:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |         ans[id]=color;
      |         ^~~
      |         abs
a.cc: In function 'int main()':
a.cc:31:9: error: 'edge' was not declared in this scope
   31 |         edge[a-1].emplace_back(b-1,i);
      |         ^~~~
a.cc:34:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |     rep(i,n-1) ans[i]=-1;
      |                ^~~
      |                abs
a.cc:39:27: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |         ansnum=max(ansnum,ans[i]);
      |                           ^~~
      |                           abs
a.cc:42:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |     rep(i,n-1) cout<<ans[i]<<endl;
      |                      ^~~
      |                      abs
Language: C

N = int(input())
graph = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append((b-1,i))
    graph[b-1].append((a-1,i))
ans = 0
print(graph)
pos = 0
for i in range(N-1):
    if ans < len(graph[i]):
        ans = len(graph[i])
        pos = i
print(ans)

color = [-1 for i in range(N-1)]
def dps(now,pare,par_col=-1):
    col = 1
    for u,idx in graph[now]:
        if u != pare :
            if col == par_col :
                col += 1
            color[idx] = col
            dps(u,now,col)
            col += 1

dps(0,-1,-1)
print("\n".join(map(str,color)))

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | N = int(input())
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'N' [-Wimplicit-int]
main.c:1:5: error: expected expression before 'int'
    1 | N = int(input())
      |     ^~~
Language: C++

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

queue<int> todo;
vector<bool> seen(n, false);

void bfs(const vector<vector<int>> &vertex, vector<vector<int>> &order, int v, int prevcolor){
  seen.at(v) = true;
  todo.push(v);
  while(!todo.empty()){
    int vfromtodo = todo.pop();
    for(int next_v : vertex.at(vfromtodo)){
      if(seen.at(next_v) == true) continue;
      bfs(vertex, next_v);
    }
  }
}

int main(){
  int n; cin >> n;
  vector<vector<int>> vertex(n);
  vector<vector<int>> order(n-1);
  for(int i=0; i<n; ++i){
    int a, b; cin >> a >> b;
    vertex.at(a-1).push_back(b-1);
    vertex.at(b-1).push_back(a-1);
    order.at(i).push_back(i);
    order.at(i).push_back(a-1);
    order.at(i).push_back(b-1);
  }
  
  sort(order.begin(), order.end(), );
}

Compiler output:
a.cc:5:19: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 | vector<bool> seen(n, false);
      |                   ^
      |                   yn
a.cc: In function 'void bfs(const std::vector<std::vector<int> >&, std::vector<std::vector<int> >&, int, int)':
a.cc:11:29: error: void value not ignored as it ought to be
   11 |     int vfromtodo = todo.pop();
      |                     ~~~~~~~~^~
a.cc:14:19: error: invalid initialization of reference of type 'std::vector<std::vector<int> >&' from expression of type 'int'
   14 |       bfs(vertex, next_v);
      |                   ^~~~~~
a.cc:7:66: note: in passing argument 2 of 'void bfs(const std::vector<std::vector<int> >&, std::vector<std::vector<int> >&, int, int)'
    7 | void bfs(const vector<vector<int>> &vertex, vector<vector<int>> &order, int v, int prevcolor){
      |                                             ~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc: In function 'int main()':
a.cc:32:36: error: expected primary-expression before ')' token
   32 |   sort(order.begin(), order.end(), );
      |                                    ^
Language: C++

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define vrep(vec, vecs) for(auto& vec : vecs)
#define all(x) (x).begin(), (x).end()

struct e { int v, id; };

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

	vector<vector<e>> G(n);
	vector<int> ans(n-1);

	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;		

		G[a].push_back(e{ b, i });
		G[b].push_back(e{ a, i });		
	}

	queue<e>q;
	q.push(e{ 0,-1 });
	vector<int> visited(n, false);
	int cur = 0;

	while (!q.empty() && cur < n) {
		e t = q.front();
		q.pop();
		
		if (visited[t.v]) continue;
		visited[t.v] = true;

		cur++;
		int k = 0;

		vrep(u, G[t.v]) {
			if (visited[u.v]) continue;
			if (t.id == k) k++;

			ans[u.id] = k;
			q.push(e{ u.v, k });
			k++;
		}
	}

	cout << *max_element(all(ans))+1 << endl;
	vrep(a, ans) cout << a+1 << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:18: error: 'max_element' was not declared in this scope
   54 |         cout << *max_element(all(ans))+1 << endl;
      |                  ^~~~~~~~~~~
Language: C++

# -*- coding: utf-8 -*

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    
    G = [[] for i in range(N)]
    ans = [None] * (N-1)
    
    for i in range(N-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        
        G[a].append((b, i))
        G[b].append((a, i))
        
    q = [(0, -1)]
    
    visited = [False] * N
    cur = 0
    
    while q and cur < N:
        v, c = q.pop(0)
    
        if visited[v]: continue
        visited[v] = True
        cur += 1
        
        k = 0
        for u, idx in G[v]:
            if visited[u]: continue
            if c == k: k += 1
            
            ans[idx] = k
            q.append((u, k))
            k += 1
            
    print(max(ans)+1)
    for a in ans: print(a+1)
     
if __name__ == '__main__':
    main()        


Compiler output:
a.cc:1:3: error: invalid preprocessing directive #-
    1 | # -*- coding: utf-8 -*
      |   ^
a.cc:44:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   44 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:3:1: error: 'import' does not name a type
    3 | import sys
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

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

int main()
{
    int N;
    cin >> N;
    vector< vector<int> > V(N);
    vector< pair<int, int> > a(N-1);

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        V[a].emplace_back(b);
        V[b].emplace_back(a);
        a.emplace_back(make_pair(a, b));
    }

    int K = 0;            /* 塗り分ける色の数 */
    map< pair<int, int>, int > I; /* どの辺が何色になったか */

    queue<int> q;         /* 幅優先探索 */
    vector<int> cs(N, 0);
    vector<int> used(N, 0);  /* 一度でも通ったことがあるか */

    used[0] = 1;
    q.emplace(0);
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        if (K < (int)V[v].size())
            K = V[v].size();
        int cur = 1;
        for (int u: V[v]) {
            if (used[u])   /* 一度でも通った頂点はもう計算しない */
                continue;
            if (cur == cs[v])
                cur++;
            cs[u] = I[make_pair(u, v)] =
                    I[make_pair(v, u)] = cur++;
            used[u] = 1;
            q.emplace(u);
        }
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:17:11: error: request for member 'emplace_back' in 'a', which is of non-class type 'int'
   17 |         a.emplace_back(make_pair(a, b));
      |           ^~~~~~~~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    vvl G(n);
    vector<pair<ll, ll>> vp;
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
        vp.pb(a, b);
    } 
    
    vl cs(n);  // cs[i] : 頂点iとiの親を結ぶ辺の色
    vl used(n);  // used[i] : 頂点iを訪れたら1
    map<pair<ll, ll>, ll> mp;
    queue<ll> Q;

    Q.push(0);
    used[0] = 1;
    while(!Q.empty()) {
        ll v = Q.front();
        Q.pop();
        ll color = 1;
        for(auto u : G[v]) {
            if(used[u]) {
                continue;
            }
            if(color == cs[v]) {
                color++;
            }
            cs[u] = mp[make_pair(u, v)] = mp[make_pair(v, u)] = color;
            color++;
            used[u] = 1;
            Q.push(u);
        }
    }

    ll K = 0;
    rep(i, n) {
        chmax(K, (ll)G[i].size());
    }
    out(K);

    for(auto p : vp) {
        out(mp[p]);
    }

    re0;
}

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

#include <bits/stdc++.h>

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

typedef pair<int, int> P;

// const int INF = 1001001001;
// long long max => LLONG_MAX

vector<int> graph[100005];
int color[100005][100005];
int k;

void dfs(int _v, int _pr, int _c){
    queue<int> cl;
    for(int i = 0; i < k; i++){
        if(i+1 != _c) cl.push(i+1);
    }
    for(int nv : graph[_v]){
        if(nv == _pr) continue;
        int cc = cl.front();
        color[nv][_v] = cc;
        color[_v][nv] = cc;
        cl.pop();
        dfs(nv, _v, cc);
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<P> tor(n-1);
    vector<int> p(n);

    for(int i = 0; i < n-1; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
        tor[i].first = a;
        tor[i].second = b;
        p[a]++;
        p[b]++;
    }
    sort(p.rbegin(), p.rend());
    k = p[0];

    dfs(0, -1, -1);

    cout << k << endl;
    for(int i = 0; i < n-1; i++){
        int a = tor[i].first;
        int b = tor[i].second;
        cout << color[a][b] << endl;
    }

    return 0;
}


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

#include <bits/stdc++.h>

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

typedef pair<int, int> P;

// const int INF = 1001001001;
// long long max => LLONG_MAX

vector<int> graph[100005];
int color[1000005][100005];
int k;

void dfs(int _v, int _pr, int _c){
    queue<int> cl;
    for(int i = 0; i < k; i++){
        if(i+1 != _c) cl.push(i+1);
    }
    for(int nv : graph[_v]){
        if(nv == _pr) continue;
        int cc = cl.front();
        color[nv][_v] = cc;
        color[_v][nv] = cc;
        cl.pop();
        dfs(nv, _v, cc);
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<P> tor(n-1);
    vector<int> p(n);

    for(int i = 0; i < n-1; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
        tor[i].first = a;
        tor[i].second = b;
        p[a]++;
        p[b]++;
    }
    sort(p.rbegin(), p.rend());
    k = p[0];

    dfs(0, -1, -1);

    cout << k << endl;
    for(int i = 0; i < n-1; i++){
        int a = tor[i].first;
        int b = tor[i].second;
        cout << color[a][b] << endl;
    }

    return 0;
}


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

#include <bits/stdc++.h>

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

typedef pair<int, int> P;

// const int INF = 1001001001;
// long long max => LLONG_MAX

vector<vector<int>> g;
int color[1000005][100005];
int k;

void dfs(int _v, int _pr, int _c){
    queue<int> cl;
    for(int i = 0; i < k; i++){
        if(i+1 != _c) cl.push(i+1);
    }
    for(int nv : g[_v]){
        if(nv == _pr) continue;
        int cc = cl.front();
        color[nv][_v] = cc;
        color[_v][nv] = cc;
        cl.pop();
        dfs(nv, _v, cc);
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<P> tor(n-1);
    vector<int> p(n);
    g.resize(n);

    for(int i = 0; i < n-1; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        tor[i].first = a;
        tor[i].second = b;
        p[a]++;
        p[b]++;
    }
    sort(p.rbegin(), p.rend());
    k = p[0];

    dfs(0, -1, -1);

    cout << k << endl;
    for(int i = 0; i < n-1; i++){
        int a = tor[i].first;
        int b = tor[i].second;
        cout << color[a][b] << endl;
    }

    return 0;
}


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

#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

ll col[100010][100010] = {};
vector<vector<ll>> g(100010);
bool visited[100010] = {};
ll mx = 0;

void dfs(ll self, ll c){
    visited[self] = true;
    ll chil_col = 1;
    rep(i, g[self].size())if(!visited[g[self][i]]){
        if(chil_col == c)chil_col++;
        col[self][g[self][i]] = chil_col;
        dfs(g[self][i], chil_col);
        mx = max(mx, chil_col);
        chil_col++;
    }
}
 
int main(){
    ll n;
    cin >> n;
    rep(i, n-1){
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1, 0);

    cout << mx << endl;
    rep(i, n)rep(j, g[i+1].size()){
        if(col[i+1][g[i+1][j]]>0)cout << col[i+1][g[i+1][j]] << endl;
    }
}

Compiler output:
/tmp/ccNtk70B.o: in function `dfs(long long, long long)':
a.cc:(.text+0x14): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccNtk70B.o
a.cc:(.text+0x41): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccNtk70B.o
a.cc:(.text+0x65): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccNtk70B.o
a.cc:(.text+0x9c): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccNtk70B.o
a.cc:(.text+0xec): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccNtk70B.o
a.cc:(.text+0x122): relocation truncated to fit: R_X86_64_PC32 against symbol `mx' defined in .bss section in /tmp/ccNtk70B.o
a.cc:(.text+0x134): relocation truncated to fit: R_X86_64_PC32 against symbol `mx' defined in .bss section in /tmp/ccNtk70B.o
a.cc:(.text+0x153): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccNtk70B.o
/tmp/ccNtk70B.o: in function `main':
a.cc:(.text+0x1dc): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccNtk70B.o
a.cc:(.text+0x204): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccNtk70B.o
a.cc:(.text+0x24b): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

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

struct Edge {
  int to;
  int id;
  Edge(int t, int i) : to(t), id(i) {}
};

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

void dfs(const vector<vector<Edge>> &g, int vertex, int c = -1) {
  seen.at(vertex) = true;
  int color = 1;

  for (int i = 0; i < g.at(vertex).size(); i++) {
    int next_v = g.at(vertex).at(i).to, edge_id = g.at(vertex).at(i).id;

    if (seen.at(next_v)) continue;
    if (color == c) color++; // avoid color duplication
    ans.at(ei) = color;
    color++;
    dfs(g, next_v, ans.at(ei));
  }
}

int main() {
  int N;
  cin >> N;
  int edge_num = N - 1;
  int from, to;
  g.resize(N);
  seen.assign(N, false);
  ans.resize(edge_num);
  for (int i = 0; i < edge_num; i++) {
    cin >> from >> to;
    from--; to--;
    g.at(from).push_back(Edge(to, i));
    g.at(to).push_back(Edge(from, i));
  }
  dfs(g, 0);

  int color_max = 0;
  for (int i = 0; i < N; i++) {
    color_max = max(color_max, static_cast<int>(g.at(i).size()));
  }
  cout << color_max << endl;
  for (int i = 0; i < edge_num; i++) {
    cout << ans.at(i) << endl;
  }
}


Compiler output:
a.cc: In function 'void dfs(const std::vector<std::vector<Edge> >&, int, int)':
a.cc:23:12: error: 'ei' was not declared in this scope; did you mean 'i'?
   23 |     ans.at(ei) = color;
      |            ^~
      |            i
Language: C++

#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int n;
vector<pair<int,int>> *adj;
int *color,*color_v;//color_vに探索履歴を残す.

void init(){
    cin>>n;
    //例のごとく、index 0は使わない方針で。
    adj = new vector<pair<int,int>>[n+1];
    for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;
        adj[u].push_back(make_pair(v,i));
        adj[v].push_back(make_pair(u,i));
    }
    color = new int[n];for(int i=0;i<n;i++)color[i]=0;
    color_v = new int[n+1];for(int i=0;i<n+1;i++)color_v[i]=0;
    //初期化とても大事....。
}
//必要色数は最大次数と同じ。だからあとは作られた色を割り当てるのみ!!

void solve(){
    int degree_M=0,max_v;
    for(int i=1;i<n+1;i++){
        if(degree_M < adj[i].size()){
            degree_M = adj[i].size();
            max_v = i;
        }
    }
    queue<int> Q;
    Q.push(max_v);
    while(!Q.empty){
        int target = Q.front();Q.pop();
        color_v[target] = 1;//訪問.
        int NG_colors[degree_M+1]={};
        int now_color=1;

        for(int j=0;j<adj[target].size();j++){
            NG_colors[color[adj[target][j].second]] = 1;
        }

        for(int j=0;j<adj[target].size();j++){
            if(color_v[adj[target][j].first] == 0)Q.push(adj[target][j].first);
            if(color[adj[target][j].second] == 0){
                while(NG_colors[now_color] == 1){
                    now_color++;
                }
                color[adj[target][j].second] = now_color++;
            }
        }
    }
    cout<<degree_M<<endl;
    for(int i=1;i<n;i++){
        cout<<color[i]<<endl;
    }
}

int main(){
    init();
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:34:14: error: cannot convert 'std::queue<int>::empty' from type 'bool (std::queue<int>::)() const' to type 'bool'
   34 |     while(!Q.empty){
      |              ^~~~~
a.cc:34:14: error: in argument to unary !
   34 |     while(!Q.empty){
      |            ~~^~~~~
Language: C

#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <vector>

using std::pair;
typedef std::vector<std::pair<int, int>> vec;
using std::make_pair;

int n, i;
vec es[100000];
int color[100000];
int max;

void co(int v, int p, int c){
	int l= es[v].size(), i;
	if(l>max) max=l;
	int j=0;
	for(i=0; i<l; i++){
		if(j==c) j++;
		int r = es[v][i].second;
		if(r!=p){
			color[es[v][i].first]=j;
			co(r, v, j);
			j++;
		}
	}
}

int main(void){
	scanf("%d", &n);
	int a, b;
	for(i=0; i<n-1; i++){
		scanf("%d%d", &a, &b);
		es[a-1].emplace_back(make_pair(i, b-1));
		es[b-1].emplace_back(make_pair(i, a-1));
	}
	max=0;
	co(0, -1, -1);
	printf("%d\n", max);
	for(i=0; i<n-1; i++){
		printf("%d\n", color[i]+1);
	}
}


Compiler output:
main.c:4:10: fatal error: vector: No such file or directory
    4 | #include <vector>
      |          ^~~~~~~~
compilation terminated.
Language: Java


import java.util.*;

public class Main extends Tree{
		public static void main(String[] args){
			
			Scanner sc=new Scanner(System.in);

			int n=sc.nextInt();
			
			LinkedList <Integer>[] tree=new LinkedList [n+1];
			for(int i=0;i<n+1;i++){
				tree[i]=new LinkedList();
			}
			
			for(int i=0;i<n-1;i++){
				int a=sc.nextInt();
				int b=sc.nextInt();
				
				tree[a].add(b);
				tree[b].add(a);
				
			}
			/*for(int i=0;i<n+1;i++){
				for (int a : tree[i]) {
		            System.out.println(i+" "+a);//test
		        }
			}*/
			
			int deg=0;
			
			HashMap<Integer, Integer> visited=new HashMap<Integer, Integer>();
			
			LinkedList<Integer> que=new LinkedList<Integer>();
			que.add(1);
			
			int[] anscolor=new int[n+1];
			int[] parcolor=new int[n+1];
			
			int index=1;
			
			while(!que.isEmpty()){
				int v=que.pop();
				  //System.out.println("v is: "+v+" v size is:  "+tree[v].size());//test
				if(deg<tree[v].size())deg=tree[v].size();//最大次数の更新
				  //System.out.println("deg is: "+deg);
				int curcolor=1;
				for(int u:tree[v]){
					//System.out.println("now u is: "+u);//test
					if(visited.containsKey(u))continue;
					
					que.add(u);
					visited.put(v,u);
					
					if(curcolor==parcolor[v])curcolor++;
					
					anscolor[index]=curcolor;index++;
					parcolor[v]=curcolor;
					parcolor[u]=curcolor;
					
				}
			}
			
			System.out.println(deg);
			for(int i=1;i<n;i++){
				System.out.println(anscolor[i]);
			}
		
		}

  }




Compiler output:
Main.java:4: error: cannot find symbol
public class Main extends Tree{
                          ^
  symbol: class Tree
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: Java

package ABC146D;

import java.util.*;

public class Main extends Tree{
		public static void main(String[] args){
			
			Scanner sc=new Scanner(System.in);

			int n=sc.nextInt();
			
			LinkedList <Integer>[] tree=new LinkedList [n+1];
			for(int i=0;i<n+1;i++){
				tree[i]=new LinkedList();
			}
			
			for(int i=0;i<n-1;i++){
				int a=sc.nextInt();
				int b=sc.nextInt();
				
				tree[a].add(b);
				tree[b].add(a);
				
			}
			/*for(int i=0;i<n+1;i++){
				for (int a : tree[i]) {
		            System.out.println(i+" "+a);//test
		        }
			}*/
			
			int deg=0;
			
			HashMap<Integer, Integer> visited=new HashMap<Integer, Integer>();
			
			LinkedList<Integer> que=new LinkedList<Integer>();
			que.add(1);
			
			int[] anscolor=new int[n+1];
			int[] parcolor=new int[n+1];
			
			int index=1;
			
			while(!que.isEmpty()){
				int v=que.pop();
				  //System.out.println("v is: "+v+" v size is:  "+tree[v].size());//test
				if(deg<tree[v].size())deg=tree[v].size();//最大次数の更新
				  //System.out.println("deg is: "+deg);
				int curcolor=1;
				for(int u:tree[v]){
					//System.out.println("now u is: "+u);//test
					if(visited.containsKey(u))continue;
					
					que.add(u);
					visited.put(v,u);
					
					if(curcolor==parcolor[v])curcolor++;
					
					anscolor[index]=curcolor;index++;
					parcolor[v]=curcolor;
					parcolor[u]=curcolor;
					
				}
			}
			
			System.out.println(deg);
			for(int i=1;i<n;i++){
				System.out.println(anscolor[i]);
			}
		
		}

  }




Compiler output:
Main.java:5: error: cannot find symbol
public class Main extends Tree{
                          ^
  symbol: class Tree
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error