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

#include <bits/stdc++.h>

using namespace std;

int N;
vector<int> graph[200005];
int par[200005];
int clr[200005];
vector<int> lst[3];
int ans[200005];
int cnt[2];

void dfs(int n){
	for(int e : graph[n]){
		if(e != par[n]){
			par[e] = n;
			clr[e] = clr[n] ^ 1;
			dfs(e);
			cnt[clr[e]]++;
		}
	}
}

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N;
	for(int i = 1; i<N; i++){
		int a, b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	dfs(1);
	for(int i = 1; i<=N; i++){
		lst[i%3].push_back(i);
	}
	if(cnt[0] <= N/3){
		for(int i = 1; i<=N; i++){
			if(clr[e] == 0){
				ans[i] = lst[0].back();
				lst[0].pop_back();
			}
			else if(lst[1].size()){
				ans[i] = lst[1].back();
				lst[1].pop_back();
			}
			else if(lst[2].size()){
				ans[i] = lst[2].back();
				lst[2].pop_back();
			}
			else{
				ans[i] = lst[0].back();
				lst[0].pop_back());
			}
		}
	}
	else if(cnt[1] <= N/3){
		for(int i = 1; i<=N; i++){
			if(clr[e] == 1){
				ans[i] = lst[0].back();
				lst[0].pop_back();
			}
			else if(lst[1].size()){
				ans[i] = lst[1].back();
				lst[1].pop_back();
			}
			else if(lst[2].size()){
				ans[i] = lst[2].back();
				lst[2].pop_back();
			}
			else{
				ans[i] = lst[0].back();
				lst[0].pop_back());
			}
		}
	}
	else{
		for(int i = 1; i<=N; i++){
			if(clr[i]){
				if(lst[1].size()){
					ans[i] = lst[1].back();
					lst[1].pop_back();
				}
				else if(lst[0].size()){
					ans[i] = lst[0].back();
					lst[0].pop_back();
				}
				else{
					assert(0);
				}
			}
			else{
				if(lst[2].size()){
					ans[i] = lst[2].back();
					lst[2].pop_back();
				}
				else if(lst[0].size()){
					ans[i] = lst[0].back();
					lst[0].pop_back();
				}
				else{
					assert(0);
				}			
			}
		}
	}
	for(int i =1 ; i<=N; i++){
		cout << ans[i] << " ";
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:32: error: 'e' was not declared in this scope
   41 |                         if(clr[e] == 0){
      |                                ^
a.cc:55:50: error: expected ';' before ')' token
   55 |                                 lst[0].pop_back());
      |                                                  ^
      |                                                  ;
a.cc:61:32: error: 'e' was not declared in this scope
   61 |                         if(clr[e] == 1){
      |                                ^
a.cc:75:50: error: expected ';' before ')' token
   75 |                                 lst[0].pop_back());
      |                                                  ^
      |                                                  ;
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#define ll long long
using namespace std;

int n;
vector<int> a;
vector<int> b;

int main()
{
  cin >> n;
  a.resize(n - 1);
  b.resize(n - 1);
  for (int i = 0; i < n - 1; i++)
  {
    cin >> a[i] >> b[i];
  }

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

  do
  {
    bool flag = false;
    for (int i = 0; i < n - 1; i++)
    {
      if (color[a[i]] == 1)
      {
        if (color[b[i]] == 0)
        {
          color[b[i]] = 2;
          flag = true;
        }
      }
      else if (color[a[i]] == 2)
      {
        if (color[b[i]] == 0)
        {
          color[b[i]] = 1;
          flag = true;
        }
      }
    }
  } while (flag);

  int colorOne = 0;
  int colorTwo = 0;
  for (int i = 0; i < n; i++)
  {
    if (color[i] == 1)
    {
      colorOne++;
    }
    else if (color[i] == 2)
    {
      colorTwo++;
    }
    else
    {
      cout << "SWW" << endl;
    }
  }

  vector<int> ans(n);

  int numOfResZero = (n + 2) / 3;
  int numOfResOne = (n + 1) / 3;

  if (colorOne > numOfResZero && colorTwo > numOfResOne)
  {
    int j = 0;
    for (int i = 0; i < numOfResZero; i++)
    {
      while (true)
      {
        if (color[j] == 1)
        {
          ans[j] = 3 * i;
          j++;
          break;
        }
        j++
      }
    }
    int num = 0;
    for (int i = j; i < n; i++)
    {
      if (color[i] == 1)
      {
        ans[j] = 3 * num - 1;
        num++;
      }
    }

    int j = 0;
    for (int i = 0; i < numOfResOne; i++)
    {
      while (true)
      {
        if (color[j] == 2)
        {
          ans[j] = 3 * i + 1;
          j++;
          break;
        }
        j++
      }
    }
    for (int i = j; i < n; i++)
    {
      if (color[i] == 2)
      {
        ans[j] = 3 * num - 1;
        num++;
      }
    }
  }

  for (int i = 0; i < n; i++)
  {
    cout << ans[i] + 1 << " "s;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:12: error: 'flag' was not declared in this scope
   49 |   } while (flag);
      |            ^~~~
a.cc:87:12: error: expected ';' before '}' token
   87 |         j++
      |            ^
      |            ;
   88 |       }
      |       ~     
a.cc:100:9: error: redeclaration of 'int j'
  100 |     int j = 0;
      |         ^
a.cc:76:9: note: 'int j' previously declared here
   76 |     int j = 0;
      |         ^
a.cc:111:12: error: expected ';' before '}' token
  111 |         j++
      |            ^
      |            ;
  112 |       }
      |       ~
Language: C++

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

const int MAX_N=2e5+10;

int N,a,b,u1=1,u2=2,u3=3,c1,c2,c3,l,now=1;
vector<vector<int>> G(MAX_N);
vector<int> dep(MAX_N,0),cnt(2,0),ans(MAX_N,0),used(MAX_N,0);

void dfs(int v,int p){
    ++cnt[dep[v]&1];
    for (int u:G[v]){
        if (u==p) continue;
        dep[u]=dep[v]+1;
        dfs(u,v);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i=0;i<N-1;++i){
        cin >> a >> b; --a,--b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    dfs(0,-1);
    c1=(N+1)/3,c2=(N+2)/2,c3=N/3;
    if (c1<=cnt[0]&&c2<=cnt[1]){
        for (int i=0;i<N;++i){
            if (dep[i]&1){
                if (u2<=N) ans[i]=u2,u2+=3;
                else ans[i]=u3,u3+=3;
            } else {
                if (u1<=N) ans[i]=u1,u1+=3;
                else ans[i]=u3,u3+=3;
            }
        }
    } else if (c1<=cnt[1]&&c2<=cnt[0]{
        for (int i=0;i<N;++i){
            if (dep[i]&1){
                if (u1<=N) ans[i]=u1,u1+=3;
                else ans[i]=u3,u3+=3;
            } else {
                if (u2<=N) ans[i]=u2,u2+=3;
                else ans[i]=u3,u3+=3;
            }
        }
    } else {
        l=cnt[1]<cnt[0];
        for (int i=0;i<N;++i) if (dep[i]&1==l){
            ans[i]=u3,used[u3]=1,u3+=3;
        }
        for (int i=0;i<N;++i) if (!ans[i]){
            while(used[now]) ++now;
            ans[i]=now++;
        }
    }
    for (int i=0;i<N;++i) cout << ans[i] << (i!=N-1?' ':'\n');
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:38: error: expected ')' before '{' token
   40 |     } else if (c1<=cnt[1]&&c2<=cnt[0]{
      |               ~                      ^
      |                                      )
a.cc:60:18: error: 'i' was not declared in this scope
   60 |     for (int i=0;i<N;++i) cout << ans[i] << (i!=N-1?' ':'\n');
      |                  ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
ll n;
vector<ll> g[200010];
vector<ll> v[2];
void dfs(ll x,ll from,ll d){
	v[d%2].push_back(x);
	for(auto y:g[x])if(y!=from){
		dfs(y,x,d+1);
	}
}
vector<ll> ids[3];
bool used[200010];
ll p[200010];
int main(){
	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,0);
	ll r1=n/3+(n%3>=1);
	ll r2=n/3+(n%3>=2);
	//cerr<<r1<<" "<<r2<<" "<<v[0].size()<<" "<<v[1].size()<<endl;
	if(v[0].size()<v[1].size())swap(v[0],v[1]);
	if(v[0].size()>=r1+r2){
		for(int i=0;i<r1;i++)ids[1].push_back(v[0][i]);
		for(int i=r1;i<r1+r2;i++)ids[2].push_back(v[0][i]);
	}
	else{
		if(r1>r2){
			assert(r1<=v[0].size());
			assert(r2<=v[1].size());
			for(int i=0;i<r1;i++)ids[1].push_back(v[0][i]);
			for(int i=0;i<r2;i++)ids[2].push_back(v[1][i]);
		}
		else{
			assert(r1<=v[1].size());
			assert(r2<=v[0].size());
			for(int i=0;i<r1;i++)ids[1].push_back(v[1][i]);
			for(int i=0;i<r2;i++)ids[2].push_back(v[0][i]);
		}
	}
	for(int i=1;i<=n;i++)used[i]=0;
	for(auto t:ids[1])used[t]=1;
	for(auto t:ids[2])used[t]=1;
	for(int i=1;i<=n;i++){
		if(used[i]==0)ids[0].push_back(i);
	}
	rep(k,3){
		ll base=k; if(k==0)base=3;
		//sort(all(ids[k]));
		for(auto t:ids[k]){
			p[t-1]=base;
			//assert(1<=base&&base<=n);
			base+=3;
		}
	}
	rep(i,n)cout<<p[i]<<endl;
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:25: error: 'assert' was not declared in this scope
   45 |                         assert(r1<=v[0].size());
      |                         ^~~~~~
a.cc:8:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    7 | #include<unordered_map>
  +++ |+#include <cassert>
    8 | using namespace std;
a.cc:51:25: error: 'assert' was not declared in this scope
   51 |                         assert(r1<=v[1].size());
      |                         ^~~~~~
a.cc:51:25: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
Language: C

#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
vector<int> g[maxn];
int n;
int c[2],res[maxn];
void dfs(int x,int fa,int dep)
{
	c[dep]++;
	for(int i=0;i<g[x].size();i++)
	{
		if(g[x][i]==fa)continue;
		dfs(g[x][i],x,dep^1);
	}
}
int l1,l2,l3;
void giveval(int x,int fa,int dep)
{
	if(!dep)
	{
		if(l1>0)
		{
			res[x]=l1;
			l1-=3;
		}
		else
		{
			if(l3<=0)
			{
				printf("-1\n");
				exit(0);
			}
			res[x]=l3;
			l3-=3;
		}
	}
	else
	{
		if(l2>0)
		{
			res[x]=l2;
			l2-=3;
		}
		else
		{
			if(l3<=0)
			{
				printf("-1\n");
				exit(0);
			}
			res[x]=l3;
			l3-=3;
		}
	}
	for(int i=0;i<g[x].size();i++)
	{
		if(g[x][i]==fa)continue;
		giveval(g[x][i],x,dep^1);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,0,0);
	
	int c3=n/3;
	int lft=n-c3;
	int c1=(lft+1)/2;
	int c2=lft/2;
	
	if(c[0]<c[1])swap(c[0],c[1]);
	
	if(max(0,c[0]-c1)+max(0,c[1]-c2)>c3)
	{
		printf("-1\n");
		return 0;
	}
	l1=c1*3-2;
	l2=c2*3-1;
	l3=c3*3;
	giveval(1,0,0);
	
	for(int i=1;i<=n;i++)printf("%d ",res[i]);
	return 0;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
vector<int> Tree[200002];
int ans[200002];
queue<int> Q[3];

int dfs(int idx, int mod3, int cnt) { // mod3は1or2
  if (ans[idx] >= 1) return cnt;
  if (Q[mod3%3].empty()) {
    if (Q[0].empty()) {
      a =mod3==1?2:1;
      ans[idx] = Q[a].front();
      Q[a].pop();
    } else {
      ans[idx] = Q[0].front();
      Q[0].pop();
    }
  } else {
    ans[idx] = Q[mod3%3].front();
    Q[mod3%3].pop();
  }
  cnt++;
  mod3=mod3==1?2:1;
  rep (i, Tree[idx].size()) {
    int next = Tree[idx][i];
    dfs(next, mod3, cnt);
  }
  return cnt;
}

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

  cin >> N;
  int a,b;
  rep(i, N-1) {
    cin >> a >> b;
    a--;b--;
    Tree[a].push_back(b);
    Tree[b].push_back(a);
  }
  rep(i, N) Q[(i+1)%3].push(i+1);
  int cnt = dfs(0, 1, 0);
  if (cnt<=1) {
    rep(i, N) {
      cout << ans[i] << ' ';
    }
    cout << endl;
    return 0;
  }
  rep(i, N) {
    if (ans[i]==-1) {
      cout << ans[i] << endl;
      return 0;
    }
  }
  
  rep(i, N) {
    cout << ans[i] << ' ';
  }
  cout << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:31:7: error: 'a' was not declared in this scope
   31 |       a =mod3==1?2:1;
      |       ^
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect 

const int N = 2e5 + 7, INF = 1e9 + 7;

vector <int> g[N], ng[N];
int ans[N], cnt1, cnt2;
short used[N];

void dfs(int v, int c) {
    if (used[v]) return;
    used[v] = c;
    (c == 1 ? ++cnt1 : ++cnt2);
    for (int u : g[v])
        dfs(u, 3 - c);
}

void solve() {
    int n; cin >> n;
    loop(i, n - 1) {
        int u, v; cin >> u >> v;
        g[u].pb(v); g[v].pb(u);
    }
    dfs(i, 1);
    int cg = 1, c = 1;
    if (cnt2 <= n / 3 || cnt1 <= n / 3) {
        loop1(i, n) {
            if ((used[i] == 1 && cnt1 <= n / 3) || (used[i] == 2 && cnt2 <= n / 3)) {
                ans[i] = cg * 3; ++cg;
            }
            else {
                if (c > n) {
                    ans[i] = cg * 3; ++cg;
                }
                else {
                    ans[i] = c; ++c;
                    if (c % 3 == 0) ++c;
                }
            }
        }
    }
    else {
        int c1 = 0, c2 = 0;
        loop1(i, n) {
            if ((used[i] == 1 && cnt1 > cnt2) || (used[i] == 2 && cnt1 <= cnt2)) {
                if (c1 * 3 + 1 > n) {
                    ans[i] = cg * 3; ++cg;
                }
                else {
                    ans[i] = c1 * 3 + 1; ++c1;
                }
            }
            else {
                if (c2 * 3 + 2 > n) {
                    ans[i] = cg * 3; ++cg;
                }
                else {
                    ans[i] = c2 * 3 + 2; ++c2;
                }
            }
        }
    }
    loop1(i, n) cout << ans[i] << " ";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:60:9: error: 'i' was not declared in this scope
   60 |     dfs(i, 1);
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s))
{in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------

int main(){
    init();
    inl(n);
    vl A(n-1),B(n-1);
    // Graph G(n+1);
    // map<ll,ll>T;
    REP(i,n-1){
        inl(A[i],B[i]);
 
    }
    
    // FOR(i,1,n+1){
    //     REP(j,G[i].size()){
    //         REP(k,)
    //     }
    // }
    REP(i,n) cout << "3";
    cout << endl;
}


Compiler output:
a.cc:36:1: error: expected unqualified-id before '{' token
   36 | {in(s[i] , t[i] , u[i]);}
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s))
{in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------

int main(){
    init();
    inl(n);
    vl A(n-1),B(n-1);
    Graph G(n+1);
    map<ll,ll>T;
    REP(i,n-1){
        inl(A[i],B[i]);
        G[A[i]].pb(B[i]);
        G[B[i]].pb(A[i]);
    }
    
    // FOR(i,1,n+1){
    //     REP(j,G[i].size()){
    //         REP(k,)
    //     }
    // }
    REP(i,n) cout << "3";
    cout << endl;
}


Compiler output:
a.cc:36:1: error: expected unqualified-id before '{' token
   36 | {in(s[i] , t[i] , u[i]);}
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n;
  cin >> n;
  vector<int> tree(n,0);
  tree.at(0)=1;
  vector<pair<int,int>> bridge;
  for(int i=0; i<n-1; i++){
    int x,y;
    cin >> x >> y;
    if(x >= y){
      bridge.at(i).first=x;
      bridge.at(i).second=y;
    }
    else{
      bridge.at(i).first=y;
      bridge.at(i).second=x;
    }
  sort(bridge.begin(),bridge.end());
  for(int i=0; i<n-1; i++){
    if(tree.at(bridge.at(i).first)==1) tree.at(bridge.at(i).second)==0;
    else tree.at(bridge.at(i).second)=1;
  }
  int count=0;
  vector<int> zyunretu;
  for(int i=0; i<n; i++){
    if(tree.at(i)==1) count++;
  }
  if(count >= n*2/3){
    int count2=0;
    int count3=0;
    for(int i=0; i<n; i++){
      if(tree.at(i)==0){
      zyunretu.at(3*count2)=i;
      count2++;
      }
    else{
      zyunretu.at(count3+count3/3+1)=i;
      count3++;
    }
   if(count <= n*1/3){
    int count2=0;
    int count3=0;
    for(int i=0; i<n; i++){
      if(tree.at(i)==1){
      zyunretu.at(3*count2)=i;
      count2++;
      }
    else{
      zyunretu.at(count3+count3/3+1)=i;
      count3++;
    }
    }
   }
    }
      
  




Compiler output:
a.cc: In function 'int main()':
a.cc:57:6: error: expected '}' at end of input
   57 |     }
      |      ^
a.cc:31:21: note: to match this '{'
   31 |   if(count >= n*2/3){
      |                     ^
a.cc:57:6: error: expected '}' at end of input
   57 |     }
      |      ^
a.cc:10:27: note: to match this '{'
   10 |   for(int i=0; i<n-1; i++){
      |                           ^
a.cc:57:6: error: expected '}' at end of input
   57 |     }
      |      ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n;
  cin >> n;
  vector<int> tree(n,0);
  tree.at(0)=1;
  vector<pair<int,int>> bridge;
  for(int i=0; i<n-1; i++){
    int x,y;
    cin >> x >> y;
    if(x >= y){
      bridge.at(i).first=x;
      bridge.at(i).second=y;
    }
    else{
      bridge.at(i).first=y;
      bridge.at(i).second=x;
    }
  sort(bridge.begin(),bridge.end());
  for(int i=0; i<n-1; i++){
    if(tree.at(bridge.at(i).first)==1) tree.at(bridge.at(i).second)==0;
    else tree.at(bridge.at(i).second)=1;
  }
  int count=0;
  vector<int> zyunretu;
  for(int i=0; i<n; i++){
    if(tree.at(i)==1) count++;
  }
  if(count >= n*2/3){
    int count2=0;
    int count3=0;
    for(int i=0; i<n; i++){
      if(tree.at(i)==0){
      zyunretu.at(3*count2)=i;
      count2++;
      }
    else{
      zyunretu.at(count3+count3/3+1)=i
      count3++;
    }
   if(count <= n*1/3){
    int count2=0;
    int count3=0;
    for(int i=0; i<n; i++){
      if(tree.at(i)==1){
      zyunretu.at(3*count2)=i;
      count2++;
      }
    else{
      zyunretu.at(count3+count3/3+1)=i
      count3++;
    }
    }
   }
    }
      
  




Compiler output:
a.cc: In function 'int main()':
a.cc:40:39: error: expected ';' before 'count3'
   40 |       zyunretu.at(count3+count3/3+1)=i
      |                                       ^
      |                                       ;
   41 |       count3++;
      |       ~~~~~~                           
a.cc:52:39: error: expected ';' before 'count3'
   52 |       zyunretu.at(count3+count3/3+1)=i
      |                                       ^
      |                                       ;
   53 |       count3++;
      |       ~~~~~~                           
a.cc:57:6: error: expected '}' at end of input
   57 |     }
      |      ^
a.cc:31:21: note: to match this '{'
   31 |   if(count >= n*2/3){
      |                     ^
a.cc:57:6: error: expected '}' at end of input
   57 |     }
      |      ^
a.cc:10:27: note: to match this '{'
   10 |   for(int i=0; i<n-1; i++){
      |                           ^
a.cc:57:6: error: expected '}' at end of input
   57 |     }
      |      ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n;
  cin >> n;
  vector<int> tree(n,0);
  tree.at(0)=1;
  vector<pair<int,int>> bridge;
  for(int i=0; i<n-1; i++){
    int x,y;
    cin >> x >> y;
    if(x >= y){
      bridge.at(i).first=x;
      bridge.at(i).second=y;
    }
    else{
      bridge.at(i).first=y;
      bridge.at(i).second=x;
    }
  sort(bridge.begin(),bridge.end());
  for(int i=0; i<n-1; i++){
    if(tree.at(bridge.at(i).first)==1) tree.at(bridge.at(i).second)==0;
    else tree.at(bridge.second)=1;
  }
  int count=0;
  vector<int> zyunretu;
  for(int i=0; i<n; i++){
    if(tree.at(i)==1) count++;
  }
  if(count >= n*2/3){
    int count2=0;
    int count3=0;
    for(int i=0; i<n; i++){
      if(tree.at(i)==0){
      zyunretu.at(3*count2)=i;
      count2++;
      }
    else{
      zyunretu.at(count3+count3/3+1)=i
      count3++;
    }
   if(count <= n*1/3){
    int count2=0;
    int count3=0;
    for(int i=0; i<n; i++){
      if(tree.at(i)==1){
      zyunretu.at(3*count2)=i;
      count2++;
      }
    else{
      zyunretu.at(count3+count3/3+1)=i
      count3++;
    }
    }
   }
      
  




Compiler output:
a.cc: In function 'int main()':
a.cc:24:25: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   24 |     else tree.at(bridge.second)=1;
      |                         ^~~~~~
a.cc:40:39: error: expected ';' before 'count3'
   40 |       zyunretu.at(count3+count3/3+1)=i
      |                                       ^
      |                                       ;
   41 |       count3++;
      |       ~~~~~~                           
a.cc:52:39: error: expected ';' before 'count3'
   52 |       zyunretu.at(count3+count3/3+1)=i
      |                                       ^
      |                                       ;
   53 |       count3++;
      |       ~~~~~~                           
a.cc:56:5: error: expected '}' at end of input
   56 |    }
      |     ^
a.cc:34:27: note: to match this '{'
   34 |     for(int i=0; i<n; i++){
      |                           ^
a.cc:56:5: error: expected '}' at end of input
   56 |    }
      |     ^
a.cc:31:21: note: to match this '{'
   31 |   if(count >= n*2/3){
      |                     ^
a.cc:56:5: error: expected '}' at end of input
   56 |    }
      |     ^
a.cc:10:27: note: to match this '{'
   10 |   for(int i=0; i<n-1; i++){
      |                           ^
a.cc:56:5: error: expected '}' at end of input
   56 |    }
      |     ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n;
  cin >> n;
  vector<int> tree(n,0);
  tree.at(0)=1;
  vector<pair<int,int>> bridge;
  for(int i=0; i<n-1; i++){
    int x,y;
    cin >> x >> y;
    if(x >= y){
      bridge.at(i).first=x;
      bridge.at(i).second=y;
    }
    else{
      bridge.at(i).first=y;
      bridge.at(i).second=x;
    }
  sort(bridge.begin(),bridge.end());
  for(int i=0; i<n-1; i++){
    if(tree.at(bridge.first)==1) tree.at(bridge.second)==0;
    else tree.at(bridge.second)=1;
  }
  int count=0;
  vector<int> zyunretu;
  for(int i=0; i<n; i++){
    if(tree.at(i)==1) count++;
  }
  if(count >= n*2/3){
    int count2=0;
    int count3=0;
    for(int i=0; i<n; i++){
      if(tree.at(i)==0){
      zyunretu.at(3*count2)=i;
      count2++;
      }
    else{
      zyunretu.at(count3+count3/3+1)=i
      count3++;
    }
   if(count <= n*1/3){
    int count2=0;
    int count3=0;
    for(int i=0; i<n; i++){
      if(tree.at(i)==1){
      zyunretu.at(3*count2)=i;
      count2++;
      }
    else{
      zyunretu.at(count3+count3/3+1)=i
      count3++;
    }
    }
 
      
  




Compiler output:
a.cc: In function 'int main()':
a.cc:23:23: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   23 |     if(tree.at(bridge.first)==1) tree.at(bridge.second)==0;
      |                       ^~~~~
a.cc:23:49: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   23 |     if(tree.at(bridge.first)==1) tree.at(bridge.second)==0;
      |                                                 ^~~~~~
a.cc:24:25: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   24 |     else tree.at(bridge.second)=1;
      |                         ^~~~~~
a.cc:40:39: error: expected ';' before 'count3'
   40 |       zyunretu.at(count3+count3/3+1)=i
      |                                       ^
      |                                       ;
   41 |       count3++;
      |       ~~~~~~                           
a.cc:52:39: error: expected ';' before 'count3'
   52 |       zyunretu.at(count3+count3/3+1)=i
      |                                       ^
      |                                       ;
   53 |       count3++;
      |       ~~~~~~                           
a.cc:55:6: error: expected '}' at end of input
   55 |     }
      |      ^
a.cc:43:22: note: to match this '{'
   43 |    if(count <= n*1/3){
      |                      ^
a.cc:55:6: error: expected '}' at end of input
   55 |     }
      |      ^
a.cc:34:27: note: to match this '{'
   34 |     for(int i=0; i<n; i++){
      |                           ^
a.cc:55:6: error: expected '}' at end of input
   55 |     }
      |      ^
a.cc:31:21: note: to match this '{'
   31 |   if(count >= n*2/3){
      |                     ^
a.cc:55:6: error: expected '}' at end of input
   55 |     }
      |      ^
a.cc:10:27: note: to match this '{'
   10 |   for(int i=0; i<n-1; i++){
      |                           ^
a.cc:55:6: error: expected '}' at end of input
   55 |     }
      |      ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
vector <int> son[maxn];
int cnt[6], dps[maxn];
void dfs(int u, int fath, int tdps) {
    dps[u] = tdps % 6;
    cnt[tdps % 6]++;
    for (int i = 0; i < (int)son[u].size(); i++) {
        int v = son[u][i];
        dfs(v, u, tdps + 1);
    }
}
int lim[4], now[4];
int main() {
    int n;  cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;   cin >> u >> v;
        son[u].push_back(v);
        son[v].push_back(u);
    }
    for (int i = 1; i <= 3; i++) {
        lim[i] = n / 3 + (i <= n % 3 + 1);
    }
    dfs(1, 1, 0);
    if (cnt[1] + cnt[5] + cnt[0] >= lim[2] && cnt[2] + cnt[4] + cnt[3] >= lim[1]) {
        for (int i = 1; i <= n; i++) {
            if (dps[i] == 0 || dps[i] == 1 || dps[i] == 5)  col[i] = 2;
            else    col[i] = 1;
        }
    }
    else if (cnt[1] + cnt[5] + cnt[3] >= lim[2] && cnt[2] + cnt[4] + cnt[0] >= lim[1]) {
        for (int i = 1; i <= n; i++) {
            if (dps[i] == 3 || dps[i] == 1 || dps[i] == 5)  col[i] = 2;
            else    col[i] = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (now[col[i]] >= lim[col[i]]) {
            col[i] = 3;
        }
        cout << col[i] + now[col[i]] * 3 << ' ';
        now[col[i]]++;
    }
    getchar(); getchar();
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:61: error: 'col' was not declared in this scope; did you mean 'cosl'?
   28 |             if (dps[i] == 0 || dps[i] == 1 || dps[i] == 5)  col[i] = 2;
      |                                                             ^~~
      |                                                             cosl
a.cc:29:21: error: 'col' was not declared in this scope; did you mean 'cosl'?
   29 |             else    col[i] = 1;
      |                     ^~~
      |                     cosl
a.cc:34:61: error: 'col' was not declared in this scope; did you mean 'cosl'?
   34 |             if (dps[i] == 3 || dps[i] == 1 || dps[i] == 5)  col[i] = 2;
      |                                                             ^~~
      |                                                             cosl
a.cc:35:21: error: 'col' was not declared in this scope; did you mean 'cosl'?
   35 |             else    col[i] = 1;
      |                     ^~~
      |                     cosl
a.cc:39:17: error: 'col' was not declared in this scope; did you mean 'cosl'?
   39 |         if (now[col[i]] >= lim[col[i]]) {
      |                 ^~~
      |                 cosl
a.cc:42:17: error: 'col' was not declared in this scope; did you mean 'cosl'?
   42 |         cout << col[i] + now[col[i]] * 3 << ' ';
      |                 ^~~
      |                 cosl
Language: C++



/*
N頂点の木


1-Nまでの番号

iとjの距離が3なら, p[i]とp[j]の和or積が3の倍数である

このような順列を1つ見つけろ


グラフを3層にして繋げる??


xとyの距離が3でy,zも3の時, 

ペア自体がすでにむずくない?

2だけが大量に余ることは???


union findで, [これとこれはmodが同じにならない]でいける?
xが取りうるのは 0 1 2
y     x1-y2, 
とは限らなくないか??


1個おきにdegreeをとる?


距離3を探すだけでTLEか

距離が3...?




3の倍数じゃなくて3





tについたらat+b時間かかる

DPではない
貪欲じゃダメ?
早く終わる順にやってく
時刻tについたら...?
にぶたん
K店いけるとして, 
合計

先に店を決めたら; 
回る順番は


2つの店で考えると
1店目でa[0]*0+b[0]
2店目でa[0]*0+b[0]+ a[1]*(a[0]*0+b[0])+b[1]

つまり行列の掛け算


1212121212::OK
 1 
 2  1
  1


最初から全部1-2で繋げば問題なさそう...?
degが大きい順に0を振ってく?
degじゃダメそう



*/


#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  vector<vector<long>>A(N);
  for(long i=0;i<N-1;i++){
    long a,b;
    cin>>a>>b;
    A[a-1].push_back(b-1);
    A[b-1].push_back(a-1);
  }
  //1212
  vector<long>P(N,-1);
  long x=1,y=2,z=3;
  queue<long>q;q.push(0);P[0]=1;x+=3;
  
  while(q.size()){
    long f=q.front();q.pop();
    for(long n:A[f])if(P[n]==-1){
      if(P[f]%3==1){
        if(y<=N){P[n]=y;y+=3;}
        else{P[n]=z;z+=3;}
      }
      else if(P[f]%3==2){
        if(x<=N){P[n]=x;x+=3;}
        else{P[n]=z;z+=3;}
      }
      else {
        if(x<y){P[n]=x;x+=3;}
        else{P[n]=y;y+=3;}
      }
      q.push(n);
    }
  }
  for(long p:P)cout<<p<<" ";
  assert(x-3<=n&&y-3<=n&&z-3<=n)
}








Compiler output:
In file included from /usr/include/c++/14/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106,
                 from a.cc:82:
a.cc: In function 'int main()':
a.cc:117:15: error: 'n' was not declared in this scope
  117 |   assert(x-3<=n&&y-3<=n&&z-3<=n)
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n;
  cin >> n;
  vector<int> tree(n,0);
  tree.at(0)=1;
  vector<pair<int,int>> bridge;
  for(int i=0; i<n-1; i++){
    int x,y;
    cin >> x >> y;
    if(x >= y){
      bridge.at(i).first=x;
      bridge.at(i).second=y;
    }
    else{
      bridge.at(i).first=y;
      bridge.at(i).second=x;
    }
  }
  sort(pair.begin(),pair.end());
  for(int i=0; i<n-1; i++){
    if(tree.at(bridge.first)==1) tree.at(bridge.second)==0;
    else tree.at(bridge.second)=1;
  }
  int count=0;
  vector<int> zyunretu;
  for(int i=0; i<n; i++){
    if(tree.at(i)==1) count++;
  }
  if(count >= n*2/3){
    int count2=0;
    for(int i=0; i<n; i++){
      if(tree.at(i)==0){
      zyunretu.at(3*count2)=i;
      count++;
      }
    }  
  




Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: missing template arguments before '.' token
   22 |   sort(pair.begin(),pair.end());
      |            ^
a.cc:22:25: error: missing template arguments before '.' token
   22 |   sort(pair.begin(),pair.end());
      |                         ^
a.cc:24:23: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   24 |     if(tree.at(bridge.first)==1) tree.at(bridge.second)==0;
      |                       ^~~~~
a.cc:24:49: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   24 |     if(tree.at(bridge.first)==1) tree.at(bridge.second)==0;
      |                                                 ^~~~~~
a.cc:25:25: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   25 |     else tree.at(bridge.second)=1;
      |                         ^~~~~~
a.cc:39:6: error: expected '}' at end of input
   39 |     }
      |      ^
a.cc:32:21: note: to match this '{'
   32 |   if(count >= n*2/3){
      |                     ^
a.cc:39:6: error: expected '}' at end of input
   39 |     }
      |      ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast");
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  DV(G,lli,N,0,0);
  rep(i,0,N-1){
    cin >> A >> B;
    G[A-1].pb(B-1);
    G[B-1].pb(A-1);
  }
  DV(P,lli,N,0,0);
  Vec(dist,lli,N,-1);
  queue<lli> que;
  rep(i,0,N){
    que.push(i);
    dist[i]=0;
    while (!que.empty()){
      X=que.front();que.pop();
      if(dist[X]==3){
        que.push(X);
        break;
       }
      for(auto v:G[X]){
        if(dist[v]!=-1)continue;
        dist[v]=dist[X]+1;
        que.push(v);
      }
    }
    while(!que.empty()){
      X=que.front();que.pop();
      if(dist[X]==3){
        P[i].pb(X);
      }
    }
    rep(j,0,N)dist[j]=-1;
  }
  Vec(is,bool,N,1);
  Vec(Q,pint,0,pint(0,0));
  rep(i,0,N)if(P[i].size()>0)for(auto v:P[i])Q.pb(pint(min(v,i),max(v,i)));
  Vec(ans,int,N,-1);
  M=Q.size();
}

Compiler output:
a.cc:2:30: error: '#pragma GCC optimize' string is badly formed
    2 | #pragma GCC optimize("Ofast");
      |                              ^
Language: C++

本質に構築*2出されると流石に打つ手がない......

Compiler output:
a.cc:1:1: error: '\U0000672c\U00008cea\U0000306b\U000069cb\U00007bc9' does not name a type
    1 | 本質に構築*2出されると流石に打つ手がない......
      | ^~~~~~~~~~
Language: C++

#include<bits/stdc++.h> 
using namespace std; 
  vector<vector<int> nb;
// function for finding minimum no. of edge 
// using BFS 
int minEdgeBFS(vector <int> edges[], int u, 
                              int v, int n) 
{ 
    // visited[n] for keeping track of visited 
    // node in BFS 
    vector<bool> visited(n, 0); 
  
    // Initialize distances as 0 
    vector<int> distance(n, 0); 
  
    // queue to do BFS. 
    queue <int> Q; 
    distance[u] = 0; 
  
    Q.push(u); 
    visited[u] = true; 
    while (!Q.empty()) 
    { 
        int x = Q.front(); 
        Q.pop(); 
  
        for (int i=0; i<edges[x].size(); i++) 
        { 
            if (visited[edges[x][i]]) 
                continue; 
  
            // update distance for i 
            distance[edges[x][i]] = distance[x] + 1; 
            Q.push(edges[x][i]); 
            visited[edges[x][i]] = 1; 
        } 
    } 
    return distance[v]; 
} 
  
// function for addition of edge 
void addEdge(vector <int> edges[], int u, int v) 
{ 
   edges[u].push_back(v); 
   edges[v].push_back(u); 
} 
  
// Driver function 
int main() 
{ 
    // To store adjacency list of graph 
    int n;
  cin>>n;
    vector <int> edges[n]; 
 nb.assign(n+1,vector<int>());
  for(int i=0; i<n-1; ++i)
  {
  int c,g;
    cin>>c>>g;
    addEdge(edges,c-1,g-1);
   
  }
  for(int i=0; i<n; ++i)
  {
  for(int j=0; j<n; ++j)
  {
   if(minEdgeBFS(edges, i, j, n)==3)
 nb[i].push_back(j);
  }
  }
  int fn2(0),ro(1),rii(3);
  int t[n];
    for(int i=0; i<n; ++i)
    {
     if(nb[i].size()>2)
     fn2=1;
      
      if(nb[i].size()==2)
      {
    t[i]=ro;
          
         int rem = (n + 3) % 3; 
  int iti;
    if (rem == 0) 
        iti=n; 
    else
        iti=n +3-rem; 
        t[nb[i][1]]=iti-ro;
          t[nb[i][0]]=iti/ro;
   ++ro;
        
      }
      else if(t[i].size()==1)
      {
        int iti;
    if (rem == 0) 
        iti=n; 
    else
        iti=n +3-rem; 
       t[i]=ro;
        t[nb[i][0]]=iti/ro;
        ++ro;
           int rem = (n + 3) % 3; 
 
      }
if(fn2)
cout<<-1;
 else
 {
 for(int i=0; i<n; ++i)
  cout<<t[i]<<" ";
 }
}

Compiler output:
a.cc:3:22: error: template argument 1 is invalid
    3 |   vector<vector<int> nb;
      |                      ^~
a.cc:3:22: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:55:2: error: 'nb' was not declared in this scope; did you mean 'n'?
   55 |  nb.assign(n+1,vector<int>());
      |  ^~
      |  n
a.cc:93:20: error: request for member 'size' in 't[i]', which is of non-class type 'int'
   93 |       else if(t[i].size()==1)
      |                    ^~~~
a.cc:96:9: error: 'rem' was not declared in this scope; did you mean 'drem'?
   96 |     if (rem == 0)
      |         ^~~
      |         drem
a.cc:113:2: error: expected '}' at end of input
  113 | }
      |  ^
a.cc:50:1: note: to match this '{'
   50 | {
      | ^
Language: C++

using namespace std;

const int M = 100010;
const int MLV = 18; 
vector<int> G[M];
int root;
int n,q;
int parent[MLV][M];
int depth[M];

void dfs(int v,int p,int d){
	parent[0][v] = p;
	depth[v] = d;
	for(int i = 0;i < G[v].size();i++){
		if(G[v][i] != p) dfs(G[v][i],v,d + 1);
	}
}

void init(int V){
	dfs(root,-1,0);
	for(int k = 0;k+1 < MLV;k++){
		for(int v = 1;v <= V;v++){
			if(parent[k][v] < 0) parent[k+1][v] = -1;
			else parent[k+1][v] = parent[k][parent[k][v]];
		}
	}
}

int lca(int u,int v){
	if(depth[u] > depth[v]) swap(u,v);
	for(int k = 0;k < MLV;k++){
		if((depth[v] - depth[u]) >> k & 1){
			v = parent[k][v];
		}
	}
	if(u == v)return u;
	for(int k = MLV-1;k >= 0;k--){
		if(parent[k][u] != parent[k][v]){
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}

int main(){
	scanf("%d",&n);
	root = 1;
	for(int i = 0;i < n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	init(n);
	scanf("%d",&q);

	for(int i = 0;i < q;i++){
		int a,b;
		scanf("%d%d",&a,&b);

		int par = lca(a,b);
		printf("%d\n",(depth[a]-depth[par])+(depth[b]-depth[par])+1);
	}
	return 0;
}

Compiler output:
a.cc:5:1: error: 'vector' does not name a type
    5 | vector<int> G[M];
      | ^~~~~~
a.cc: In function 'void dfs(int, int, int)':
a.cc:14:27: error: 'G' was not declared in this scope
   14 |         for(int i = 0;i < G[v].size();i++){
      |                           ^
a.cc: In function 'int lca(int, int)':
a.cc:30:33: error: 'swap' was not declared in this scope
   30 |         if(depth[u] > depth[v]) swap(u,v);
      |                                 ^~~~
a.cc: In function 'int main()':
a.cc:47:9: error: 'scanf' was not declared in this scope
   47 |         scanf("%d",&n);
      |         ^~~~~
a.cc:52:17: error: 'G' was not declared in this scope
   52 |                 G[a].push_back(b);
      |                 ^
a.cc:63:17: error: 'printf' was not declared in this scope
   63 |                 printf("%d\n",(depth[a]-depth[par])+(depth[b]-depth[par])+1);
      |                 ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | using namespace std;
Language: C++


  #include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;


struct Node {
  int mod;

  vector <int> dis1;
  vector <int> dis2;
  vector <int> dis3;
}


int main(){

  cout<<-1<<endl;

 return 0;
}

Compiler output:
a.cc:27:2: error: expected ';' after struct definition
   27 | }
      |  ^
      |  ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
vector <int> son[maxn];
int a[6] = {3, 2, 1, 3, 1, 2};
int col[maxn];
int cnt[4];
int t[7], d[7];
int lim[4];
int _t1, _t2;
vector <int> _tt1, _tt2;
void dfs(int u, int fath, int dps) {
    t[dps % 6] = u;
    if (dps % 6 == 0) {
        _tt1.push_back(u);
        _t1++;
    }
    if (dps % 6 == 3) {
        _tt2.push_back(u);
        _t2++;
    }
    col[u] = a[dps % 6];
    cnt[col[u]]++;
    for (int i = 0; i < son[u].size(); i++) {
        int v = son[u][i];
        if (v != fath) {
            dfs(v, u, dps + 1);
        }
    }
}
int now[4];
int main() {
    int n;  cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;   cin >> u >> v;
        son[u].push_back(v);
        son[v].push_back(u);
    }
    for (int i = 1; i <= 3; i++) {
        lim[i] = n / 3 + (i <= n % 3 + 1);
    }
    dfs(1, 1, 0);
    memcpy(d, t, sizeof(d));
    bool flag = false;
    for (int i = 0; i < 6; i++) {
        memset(cnt, 0, sizeof(cnt));
        _t1 = 0;    _t2 = 0;
        _tt1.clear();   _tt2.clear();
        dfs(d[i], d[i], 0);
        if (cnt[1] + cnt2[2] + _t1 >= lim[1] + lim[2]) {
            for (int j = 0; j < lim[1] - cnt[1]; j++) {
                int u = _tt1[j];
                col[u] = 1;
            }
            for (int j = 0; j < lim[2] - cnt[2]; j++) {
                int u = _tt1[j];
                col[u] = 2;
            }
            flag = true;
            break;
        }
        if (cnt[1] + cnt2[2] + _t2 >= lim[1] + lim[2]) {
            for (int j = 0; j < lim[1] - cnt[1]; j++) {
                int u = _tt2[j];
                col[u] = 1;
            }
            for (int j = 0; j < lim[2] - cnt[2]; j++) {
                int u = _tt2[j];
                col[u] = 2;
            }
            flag = true;
            break;
        }
    }
    if (flag) {
        for (int i = 1; i <= n; i++) {
            if (now[col[i]] < lim[col[i]]) {
                cout << col[i] + now[col[i]] * 3 << ' ';
                now[col[i]]++;
            }
            else {
                cout << 3 + now[3] * 3 << ' ';
                now[3]++;
            }
        }
    }
    else {
        cout << -1;
    }
    getchar(); getchar();
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:22: error: 'cnt2' was not declared in this scope; did you mean 'cnt'?
   50 |         if (cnt[1] + cnt2[2] + _t1 >= lim[1] + lim[2]) {
      |                      ^~~~
      |                      cnt
a.cc:62:22: error: 'cnt2' was not declared in this scope; did you mean 'cnt'?
   62 |         if (cnt[1] + cnt2[2] + _t2 >= lim[1] + lim[2]) {
      |                      ^~~~
      |                      cnt