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

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

int N;

int edge[10001][10001] ={-1};
int node[10001] = {0};
int visi[10001] = {0};

void dfs(int u){
    visi[u] = 1;

    for(int i = 1;i<=N;i++){
        if(edge[u][i] == -1)continue;
        if(visi[i])continue;
        node[i] = (node[u] + edge[u][i])%2;
        dfs(i);
    }

}

int Dx[6] = { 0, 0, 1, 1,-1,-1};
int Dy[6] = { 1,-1, 1, 0, 0,-1};

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;
int main(){

  cin >>N;

  for(int i = 1;i<=N;i++){
      for(int j = 1;j<=N;j++){
          edge[i][j] = -1;
      }
  }

  for(int i = 0;i < N-1;i++){
      int u,v,w;
      cin >>u>>v>>w;
      edge[u][v] = w%2;
      edge[v][u] = w%2;
  }

  node[1] = 1;
  dfs(1);

  for(int i = 1;i<=N;i++){
      if(node[i])cout <<'1'<<endl;
      else cout <<'0'<<endl;
  }
  return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }
Full class double
printf("%.16f\n",ans);
*/

Compiler output:
g++: internal compiler error: File size limit exceeded signal terminated program as
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <file:///usr/share/doc/gcc-14/README.Bugs> for instructions.
Language: C++

#include<bits/stdc++.h>
using namespace std;
int color[100010];
vector<vector<pair<int,int > > >G;
void dfs(int v,int p,int c){
  color[v]=c;
    for(int i=0;i<G[v].size();i++){
      if(G[v][i].first!=p){
        if(G[v][i].second%2==1)dfs(G,G[v][i].first,1-c);
        else dfs(G,G[v][i].first,c);
      }
    }
    return;
}
int main(){
    int n;cin>>n;
    G.resize(n+1);
    for(int i=0;i<n;i++){
        int u,v,w;cin>>u>>v>>w;
        G[u].push_back({v,w});
        G[v].push_back({u,w});
    }
    dfs(1,0,0);
    for(int i=1;i<=n;i++){
        cout<<color[i]<<endl;
    }
}


Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:9:36: error: cannot convert 'std::vector<std::vector<std::pair<int, int> > >' to 'int'
    9 |         if(G[v][i].second%2==1)dfs(G,G[v][i].first,1-c);
      |                                    ^
      |                                    |
      |                                    std::vector<std::vector<std::pair<int, int> > >
a.cc:5:14: note:   initializing argument 1 of 'void dfs(int, int, int)'
    5 | void dfs(int v,int p,int c){
      |          ~~~~^
a.cc:10:18: error: cannot convert 'std::vector<std::vector<std::pair<int, int> > >' to 'int'
   10 |         else dfs(G,G[v][i].first,c);
      |                  ^
      |                  |
      |                  std::vector<std::vector<std::pair<int, int> > >
a.cc:5:14: note:   initializing argument 1 of 'void dfs(int, int, int)'
    5 | void dfs(int v,int p,int c){
      |          ~~~~^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

struct Edge {
    int to;
    int cost;
    Edge(int t, int c) : to(t), cost(c) { }
};
using Graph = vector<vector<Edge> >;

int N;
Graph G;
vector<int> color;

//頂点0を白く塗って、dfs.
void dfs(int v, int pv, int parity){
    color[v] = parity;

    for(auto next_v : G[v]){
        if(next_v.to == pv) continue;
        if(color[next_v.to] != -1) continue;
        if(1 & next_v.cost) dfs(next_v.to, v, 1 - parity)
        dfs(next_v.to, v, parity);
    }
}

int main(){
    cin >> N;
    G.resize(N);
    color.assign(N,-1);
    for(int i = 0;i<N-1;++i){
        int from, to, cost; cin >> from >> to >> cost;
        from --; to --;
        //cout  << from << " " << to << endl;
        G[from].push_back(Edge(to, cost));
        G[to].push_back(Edge(from, cost));
    }
    dfs(0, -1, 0);
    for(int i=0;i<N-1;++i){
        if(color[i] != -1)continue;
        dfs(i, -1, 0);
    }
    for(int i=0;i<N;++i){
        cout << color[i] << endl;
    }
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:23:58: error: expected ';' before 'dfs'
   23 |         if(1 & next_v.cost) dfs(next_v.to, v, 1 - parity)
      |                                                          ^
      |                                                          ;
   24 |         dfs(next_v.to, v, parity);
      |         ~~~
Language: C++

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

vector<int> color;
vector<bool> memo;
int n;
void dfs(vector<vector<pair<int,long long>>> G, int v,int p){
    memo[v]=true;
    for(auto x:G[v]){
        if(color[x.first]!=-1 || x.first == p)continue;
        if(x.second%2==0){
            color[x.first]=color[v];
        }
        else{
            color[x.first]=1-color[v];
        }
        if(!memo[x.first])dfs(G, x.first, v);
    }
}

int main(int argc, char const *argv[])
{
    cin>>n;
    color.assign(n,-1);
    color[0]=0;
    memo.assign(n,false);
    vector<vector<pair<int,long long>>> G(n);
    for(int i=0;i<n-1;i++){
        int u,v,w;cin>>u>>v>>w;
        G[u-1].emplace_back(v-1,w);
        G[v-1].emplace_back(u-1,w);
    }
    // for(auto x:color)cout << x << endl;
    // for(int i=0;i<n;i++){
    //     for(auto v:G[i])cout << v.first << " " << v.second <<endl;
    // }
    dfs(G,0);
    for(auto x:color)cout << x << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:38:8: error: too few arguments to function 'void dfs(std::vector<std::vector<std::pair<int, long long int> > >, int, int)'
   38 |     dfs(G,0);
      |     ~~~^~~~~
a.cc:8:6: note: declared here
    8 | void dfs(vector<vector<pair<int,long long>>> G, int v,int p){
      |      ^~~
Language: C++

/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
vector<int> color;

struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) { }
};

void dfs(const vector<vector<Edge>> &G, int v, int cur, int p) {
    color[v] = cur;
    for(auto next_edge : G[v]) {
        if(next_edge.to == p) continue;
        if(next_edge.weight % 2 == 0) dfs(G, next_edge.to, cur, v);
        else dfs(G, next_edge.to, 1 - cur, v);
    }
}

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

    int n; cin >> n;
    vector<vector<Edge>> G(n);

    for(int i = 0; i < n - 1; i++) {
        int u, v, w; cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    color.assign(n, -1); //色分け配列初期化
    dfs(G, 0, 1);

    rep(i, n) {
        cout << color[i] << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:8: error: too few arguments to function 'void dfs(const std::vector<std::vector<Edge> >&, int, int, int)'
   66 |     dfs(G, 0, 1);
      |     ~~~^~~~~~~~~
a.cc:42:6: note: declared here
   42 | void dfs(const vector<vector<Edge>> &G, int v, int cur, int p) {
      |      ^~~
Language: C++

/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
vector<int> color;
vector<vector<Edge>> G;

struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) { }
};

void dfs(int v, int pre, int cur) {
    if(color[v] != -1) return;
    color[v] = cur;
    for(auto next_edge : G[v]) {
        if(next_edge.to == pre) continue;
        if(next_edge.weight & 1) dfs(next_edge.to, v, 1 - cur);
    }
}

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

    int n; cin >> n;

    G.assign(n, vector<vector<Edge>>());
    for(int i = 0; i < n - 1; i++) {
        int u, v, w; cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    color.assign(n, 0); //色分け配列初期化
    dfs(0, -1, 1);
    for(auto v : color) {
        cout << v << endl;
    }
}


Compiler output:
a.cc:34:15: error: 'Edge' was not declared in this scope
   34 | vector<vector<Edge>> G;
      |               ^~~~
a.cc:34:15: error: template argument 1 is invalid
a.cc:34:15: error: template argument 2 is invalid
a.cc:34:19: error: template argument 1 is invalid
   34 | vector<vector<Edge>> G;
      |                   ^~
a.cc:34:19: error: template argument 2 is invalid
a.cc: In function 'void dfs(int, int, int)':
a.cc:46:27: error: invalid types 'int[int]' for array subscript
   46 |     for(auto next_edge : G[v]) {
      |                           ^
a.cc: In function 'int main()':
a.cc:58:7: error: request for member 'assign' in 'G', which is of non-class type 'int'
   58 |     G.assign(n, vector<vector<Edge>>());
      |       ^~~~~~
a.cc:62:10: error: invalid types 'int[int]' for array subscript
   62 |         G[u].push_back(Edge(v, w));
      |          ^
a.cc:63:10: error: invalid types 'int[int]' for array subscript
   63 |         G[v].push_back(Edge(u, w));
      |          ^
Language: C++

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

void dfs(int v, int c, int n, int *color, int **g){
  color[v] = c;
  for(int i = 0; i < n; i++){
    if(g[v][i] != 0 && color[i] == 0){
      if(g[v][i] % 2 == 0) dfs(i, c, n, color, g);
      else dfs(i, -c, n, color, g);
    }
  }
  return;
}

int
main(int argc, char *argv[])
{
  int n, u, v, w;
  scanf("%d", &n);

  int **g;

  g = malloc(sizeof(int *) * n);
  for(int i = 0; i < n; i++){
    g[i] = malloc(sizeof(int) * n);
  }
  for(int i = 0; i < n - 1; i++){
    scanf("%d %d %d", &u, &v, &w);
    g[u - 1][v - 1] = w;
    g[v - 1][u - 1] = w;
  }
  
  int *color;

  color = malloc(sizeof(int) * n);

  dfs(0, 1, n, color, g);

  for(int i = 0; i < n; i++){
    printf("%d\n", (color[i] + 1) / 2);
  }

  for(int i = 0; i < n; i++){
    free(g[i]);
  }
  free(g);
  free(color);

  return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:23:13: error: invalid conversion from 'void*' to 'int**' [-fpermissive]
   23 |   g = malloc(sizeof(int *) * n);
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
a.cc:25:18: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   25 |     g[i] = malloc(sizeof(int) * n);
      |            ~~~~~~^~~~~~~~~~~~~~~~~
      |                  |
      |                  void*
a.cc:35:17: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   35 |   color = malloc(sizeof(int) * n);
      |           ~~~~~~^~~~~~~~~~~~~~~~~
      |                 |
      |                 void*
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n;
vector<unordered_map<int, int> >edges;
vector<int>colors;

void dfs(int n){
    DEBUG{
        cout << n << endl;
    }
    for(auto x:edges[n]){
      if(colors[x.first]!=-1){
          continue;
      } 
      DEBUG{
          printf("%d %d\n", k, v);
      }
      if(x.second%2==1)colors[x.first]=1-colors[n];
      else colors[x.first]=colors[n];
      dfs(x.first);
    }
    // for(auto x:edges[n]){
    //     if(colors[x.first]==-1)dfs(x.first);
    // }
}

int main(void) {
    cin >> n;
    colors = vector<int>(n+1,-1);
    edges = vector<unordered_map<int, int> >(n+1, unordered_map<int,int>());
    int start=n+1;
    rep(i,n-1){
        int tu,tv,tw;
        cin >> tu >> tv >> tw;
        start = min(start, min(tu,tv));
        edges[tu][tv]=tw;
        edges[tv][tu]=tw; 
    }
    DEBUG{
        cout << "start " << start << endl;
    }
    colors[start]=0;
    dfs(start);
    rep(i,n){
        cout << colors[i+1] << endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:21:29: error: 'k' was not declared in this scope
   21 |           printf("%d %d\n", k, v);
      |                             ^
a.cc:21:32: error: 'v' was not declared in this scope
   21 |           printf("%d %d\n", k, v);
      |                                ^
Language: C++

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

const long long max_n = 100010;
long long n, c[max_n];
vector<pair<long long, long long> > t[max_n];

void dfs(long long v, long long previous = -1) {
    for (int it=0; it<t[v].size(); ++it) {
        long long u = it.first;
        long long w = it.second % 2;
        if (u != previous) {
            c[u] = c[v] ^ w;
            dfs(u, v);
        }
    }
}

int main() {
    cin >> n;
    
    for (int i = 0; i < n - 1; ++i) {
        long long u, v, w;
        cin >> u >> v >> w;
        t[u].push_back(make_pair(v, w));
        t[v].push_back(make_pair(u, w));
    }
    
    dfs(1);
    
	for(int i = 1; i <=n; ++i) {
        cout << c[i] << endl;
    }
    return 0;
}





Compiler output:
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:11:26: error: request for member 'first' in 'it', which is of non-class type 'int'
   11 |         long long u = it.first;
      |                          ^~~~~
a.cc:12:26: error: request for member 'second' in 'it', which is of non-class type 'int'
   12 |         long long w = it.second % 2;
      |                          ^~~~~~
Language: C++

#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
//#define read io.read
const long long max_n=200001;
long long n,c[max_n];
vector< pair<long long,long long> > t[max_n];

void dfs(long long v,long long previous=-1)
{
    for(int it=0;it<t[v].size();++it)
	{
        long long u=it.first;
        long long w=it.second%2;
        if(u!=previous)
		{
            c[u]=c[v]^w;
            dfs(u,v);
        }
    }
}
int main()
{
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	cin >> n;
	for(int i=0;i<=n-1;i++)
	{
		int u,v,w;
		cin >> u >> v >> w;
		t[u].push_back(make_pair(v,w));
		t[v].push_back(make_pair(u,w));
	}
	dfs(1);
	for(int i=1;i<=n;i++) cout << c[i];
	return 0;
}


Compiler output:
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:62:24: error: request for member 'first' in 'it', which is of non-class type 'int'
   62 |         long long u=it.first;
      |                        ^~~~~
a.cc:63:24: error: request for member 'second' in 'it', which is of non-class type 'int'
   63 |         long long w=it.second%2;
      |                        ^~~~~~
Language: C++

#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
//#define read io.read
const long long max_n=200001;
long long n,c[max_n];
vector< pair<long long,long long> > t[max_n];

void dfs(long long v,long long previous=-1)
{
    for(int it=0;it<t[v].size();++it)
	{
        long long u=it.first;
        long long w=it.second%2;
        if(u!=previous)
		{
            c[u]=c[v]^w;
            dfs(u,v);
        }
    }
}
int main()
{
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		int u,v,w;
		cin >> u >> v >> w;
		t[u].push_back(make_pair(u,w));
		t[v].push_back(make_pair(v,w));
	}
	dfs(1);
	for(int i=1;i<=n;i++) cout << c[i];
	return 0;
}


Compiler output:
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:62:24: error: request for member 'first' in 'it', which is of non-class type 'int'
   62 |         long long u=it.first;
      |                        ^~~~~
a.cc:63:24: error: request for member 'second' in 'it', which is of non-class type 'int'
   63 |         long long w=it.second%2;
      |                        ^~~~~~
Language: C++

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

int main(){
  int n;cin>>n;
  vector<set<pair<int,int> > > a(n);	//n番めの頂点が隣接集合を持っていて、それは番号と重みを持っている。
  int a,b,c;
  pair<int,int> memo;
  for(int i=0;i<n-1;i++){
    cin>>a>>b>>c;
    memo.first=b;memo.second=c;
    a.at(a).insert(memo);
    memo.first=a memo.second=c;
    a.at(b).insert(memo);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      
    }
  }
  
  return 0;
}

Compiler output:
a.cc:4:9: fatal error: pair: No such file or directory
    4 | #include<pair>
      |         ^~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

struct UnionFind{
	int *par, *val;

	UnionFind(int N){
		par = (int *)malloc(N*sizeof(int));
		val = (int *)malloc(N*sizeof(int));
		rep(i,N){
			par[i]=i;
			val[i]=2;
		}
	}

	int root(int x){
		if(par[x] == x)return x;
		return par[x] =  root(par[x]);
	}

	void unite(int x, int y){
		int rx = root(x);
		int ry = root(y);
		if(rx == ry)return;
		if(rx < ry)par[ry]=rx;
		else par[rx] = ry;
	}

	bool same(int x, int y){
		return root(x) == root(y);
	}
};

int main(void){
	int N;
	cin>>N;
	UnionFind tree(N);
	rep(i,N){
		int u,v,w;
		cin>>u>>v>>w;
		if(w%2 == 0)tree.unite(u-1,v-1);
	}
	rep(i,N){
		if(tree.same(0,i)cout<<0<<endl;
		else cout<<1<<endl;
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:34: error: expected ';' before 'cout'
   50 |                 if(tree.same(0,i)cout<<0<<endl;
      |                                  ^~~~
      |                                  ;
a.cc:51:17: error: expected primary-expression before 'else'
   51 |                 else cout<<1<<endl;
      |                 ^~~~
a.cc:50:48: error: expected ')' before 'else'
   50 |                 if(tree.same(0,i)cout<<0<<endl;
      |                   ~                            ^
      |                                                )
   51 |                 else cout<<1<<endl;
      |                 ~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn=100010;
typedef long long ll;
const int inf=2147483647;
vector<pair<long long,long long> > t[maxn];
void dfs(long long v, long long previous=-1){
	for(long long i=0;i<t[v].size();i++){
		long long u=i.first;
		long long w=i.second%2;
		if(u!=previous){
			c[u]=c[v]^2;
			dfs(u,v);
		} 
	}
}
inline int read(){
    int f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
} 
int main(){
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		long long u,v,w;
		cin>>u>>v>>w;
		t[u].push_back(make_pair(v,w));
		t[v].push_back(make_pair(u,w));	
	}
	dfs(1);
	for(int i=1;i<=n;i++)cout<<c[i]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:9:31: error: request for member 'first' in 'i', which is of non-class type 'long long int'
    9 |                 long long u=i.first;
      |                               ^~~~~
a.cc:10:31: error: request for member 'second' in 'i', which is of non-class type 'long long int'
   10 |                 long long w=i.second%2;
      |                               ^~~~~~
a.cc:12:25: error: 'c' was not declared in this scope
   12 |                         c[u]=c[v]^2;
      |                         ^
a.cc: In function 'int main()':
a.cc:33:36: error: 'c' was not declared in this scope
   33 |         for(int i=1;i<=n;i++)cout<<c[i]<<endl;
      |                                    ^
Language: C++

#include <iostream>

using namespace std;

const int N = 200005;
int n, prev[N], last[N], target[N], w[N], t, col[N];

void add(int a, int b, int wa)
{
	t++;
	w[t] = wa;
	prev[t] = last[a];
	target[t] = b;
	last[a] = t;
}

bool visit[N];
void dfs(int x)
{
	visit[x] = 1;
	int ptr = last[x];
	while (ptr != 0)
	{
		int xx = target[ptr];
		if (!visit[xx])
		{
			if(w[ptr] % 2 == 0)
			{
				col[xx] = col[x];
			}
			else
			{
				col[xx] = ((col[x] + 1) & 1);
			}
			dfs(xx);
		}
		ptr = prev[ptr];
	}
}

int main()
{
	cin >> n;
	for (int i = 1; i < n; i ++)
	{
		int aa, bb, ww;
		cin >> aa >> bb >> ww;
		add(aa, bb, ww);
		add(bb, aa, ww);
	}
	col[1] = 0;
	dfs(1);
	for (int i =1; i <= n; i++) cout << col[i] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'void add(int, int, int)':
a.cc:12:9: error: reference to 'prev' is ambiguous
   12 |         prev[t] = last[a];
      |         ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:6:8: note:                 'int prev [200005]'
    6 | int n, prev[N], last[N], target[N], w[N], t, col[N];
      |        ^~~~
a.cc: In function 'void dfs(int)':
a.cc:37:23: error: reference to 'prev' is ambiguous
   37 |                 ptr = prev[ptr];
      |                       ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:6:8: note:                 'int prev [200005]'
    6 | int n, prev[N], last[N], target[N], w[N], t, col[N];
      |        ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const long long max_n = 100010;
long long n, c[max_n];
vector<pair<long long, long long> > t[max_n];
void dfs(long long v, long long previous = -1) {
    for (int it=0; it<t[v].size(); ++it) {
        long long u = it.first;
        long long w = it.second % 2;
        if (u != previous) {
            c[u] = c[v] ^ w;
            dfs(u, v);
        }
    }
}
int main() {
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        long long u, v, w;
        cin >> u >> v >> w;
        t[u].push_back(make_pair(v, w));
        t[v].push_back(make_pair(u, w));
    }
    dfs(1);
	for(int i = 1; i <=n; ++i) {
        cout << c[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:8:26: error: request for member 'first' in 'it', which is of non-class type 'int'
    8 |         long long u = it.first;
      |                          ^~~~~
a.cc:9:26: error: request for member 'second' in 'it', which is of non-class type 'int'
    9 |         long long w = it.second % 2;
      |                          ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int par[100010],size[100000];
void init(int n){
  for(int i=0;i<=n;i++)par[i]=i;
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return par[x]==par[y];
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y)return;
  par[x]=y;
}
int main(){
  int n;cin>>n;
  init(n);
  vector<pair<int,int>>diff(0);
  map<int,int> parity;
  for(int i=0;i<n-1;i++){
    int u,v,w;cin>>u>>v>>w;
    if(w%2==0)unite(u,v);
    else{
      diff.push_back({u,v});
    }
  }
  for(int i=0;i<diff.size();i++){
    diff.at(i).second=root(diff.at(i).second);
    diff.at(i).first=root(diff.at(i).first);
    if(diff.at(i).first>diff.at(i).second)swap(diff.at(i).first,diff.at(i).second)
  sort(diff.begin(),diff.end());
  parity[diff.at(0).first]=0;
  for(int i=0;i<diff.size();i++){
    if(parity.find(diff.at(i).first)!=parity.end())parity[diff.at(i).second]=parity[diff.at(i).first]+1;
    else if(parity.find(diff.at(i).second)!=parity.end())parity[diff.at(i).first]=parity[diff.at(i).second]+1;
  }
  for(int i=1;i<=n;i++){
    if(parity[root(i)]%2){
      cout<<0<<endl;
    }
    else cout<<1<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:83: error: expected ';' before 'sort'
   34 |     if(diff.at(i).first>diff.at(i).second)swap(diff.at(i).first,diff.at(i).second)
      |                                                                                   ^
      |                                                                                   ;
   35 |   sort(diff.begin(),diff.end());
      |   ~~~~                                                                             
a.cc:47:2: error: expected '}' at end of input
   47 | }
      |  ^
a.cc:19:11: note: to match this '{'
   19 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int par[100010],size[100000];
void init(int n){
  for(int i=0;i<=n;i++)par[i]=i;
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return par[x]==par[y];
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y)return;
  par[x]=y;
}
int main(){
  int n;cin>>n;
  init(n);
  vector<pair<int,int>>diff(0);
  map<int,int> parity;
  for(int i=0;i<n-1;i++){
    int u,v,w;cin>>u>>v>>w;
    if(w%2==0)unite(u,v);
    else{
      diff.push_back({u,v});
    }
  }
  for(int i=0;i<diff.size();i++){
    diff.at(i).second=root(diff.at(i).second);
    diff.at(i).first=root(diff.at(i).first);
    if(diff.at(i).first>diff.at(i).second)swap(diff.at(i).first,diff.at(i).second)
  }
  sort(diff.begin(),diff.end());
  map[diff.at(0).first]=0;
  for(int i=0;i<diff.size();i++){
    if(parity.find(diff.at(i).first)!=parity.end())parity[diff.at(i).second]=parity[diff.at(i).first]+1;
    else if(parity.find(diff.at(i).second)!=parity.end())parity[diff.at(i).first]=parity[diff.at(i).second]+1;
  }
  for(int i=1;i<=n;i++){
    if(parity[root(i)]%2){
      cout<<0<<endl;
    }
    else cout<<1<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:83: error: expected ';' before '}' token
   34 |     if(diff.at(i).first>diff.at(i).second)swap(diff.at(i).first,diff.at(i).second)
      |                                                                                   ^
      |                                                                                   ;
   35 |   }
      |   ~                                                                                
a.cc:37:11: error: expected ']' before '.' token
   37 |   map[diff.at(0).first]=0;
      |           ^
      |           ]
a.cc:37:7: error: conflicting declaration 'auto diff'
   37 |   map[diff.at(0).first]=0;
      |       ^~~~
a.cc:22:24: note: previous declaration as 'std::vector<std::pair<int, int> > diff'
   22 |   vector<pair<int,int>>diff(0);
      |                        ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int par[100010],size[100000];
void init(int n){
  for(int i=0;i<=n;i++)par[i]=i;
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return par[x]==par[y];
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y)return;
  par[x]=y;
}
int main(){
  int n;cin>>n;
  init(n);
  vector<pair<int,int>>diff(0);
  vector<int> parity(n+1)
  bool f=false;
  int k,inf1=100001,inf2=100002;
  for(int i=0;i<n-1;i++){
    int u,v,w;cin>>u>>v>>w;
    if(!(w%2))unite(u,v);
    if(u>v)swap(u,v);
    else diff.push_back({u,v});
  }
  sort(diff.begin(),diff.end());
  for(int i=0;i<diff.size(),i++){
      parity[root(diff.at(i).second)]=parity[root(diff.at(i).first)]+1;
  for(int i=1;i<=n;i++){
    if(parity[root(i)]%2){
      cout<<0<<endl;
    }
    else cout<<1<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:3: error: expected ',' or ';' before 'bool'
   24 |   bool f=false;
      |   ^~~~
a.cc:33:32: error: expected ';' before ')' token
   33 |   for(int i=0;i<diff.size(),i++){
      |                                ^
      |                                ;
a.cc:41:2: error: expected '}' at end of input
   41 | }
      |  ^
a.cc:19:11: note: to match this '{'
   19 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
const int MAXN=100005;
int n;
vector<pair<int,int> > v[MAXN]; //不喜欢 :\
int color[MAXN];

void dfs(int no,int father)
{
	for (int i=0;i<v[no].size();i++){
		int u=v[no][i].first;
		int w=v[no][i].second%2;
		if (u!=father){
			color[u]=color[no]^w;
			dfs(u,no);
		}
	}
}

int main()
{
	cin>>n;
	for (int i=1;i<n;i++){
		int u,vv,c;
		cin>>u>>vv>>c;
		v[u].push_back({vv,c});
		v[vv].push_back({u,c});
	}

	dfs(1,-1);

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


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:15:25: error: 'color' was not declared in this scope; did you mean 'tolower'?
   15 |                         color[u]=color[no]^w;
      |                         ^~~~~
      |                         tolower
a.cc: In function 'int main()':
a.cc:34:23: error: 'color' was not declared in this scope; did you mean 'tolower'?
   34 |                 cout<<color[i]<<endl;
      |                       ^~~~~
      |                       tolower
Language: C++

#include <bits/stdc++.h>
#define MAXN 200005
int n,cnt,hd[MAXN],v[MAXN],nxt[MAXN],w[MAXN],d[MAXN];
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void print(int x)
{
    if (x<0)
        putchar('-'),x=-x;
    if(x>9)
        print(x/10);
    putchar(x%10+'0');
}
inline void dfs(int u,int fa)
{
    for(int i=hd[u];i;i=nxt[i])
	{
	    if(v[i]!=fa)
		{
	        d[v[i]]=d[u]+w[i];
	        dfs(v[i],u);
	    }
	}
}
signed main(void)
{
    read(n);
    for(i=1;i<n;i++)
	{
		int x,y,z;
		read(x),read(y),read(z);
		v[++cnt]=y;
		nxt[cnt]=hd[x];
		w[cnt]=z;
		hd[x]=cnt;
		v[++cnt]=x;
		nxt[cnt]=hd[y];
		w[cnt]=z;
		hd[y]=cnt;
	}
    dfs(1,0);
    for(i=1;i<=n;i++)
		print(d[i]&1),putchar('\n');
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:9: error: 'i' was not declared in this scope
   41 |     for(i=1;i<n;i++)
      |         ^
a.cc:55:9: error: 'i' was not declared in this scope
   55 |     for(i=1;i<=n;i++)
      |         ^
Language: C++

#include <bits/stdc++.h>
#define MAXN 200005
int n,cnt,hd[MAXN],v[MAXN],nxt[MAXN],w[MAXN],d[MAXN];
void dfs(int u,int fa)
{
    for(int i=hd[u];i;i=nxt[i])
	{
	    if(v[i]!=fa)
		{
	        d[v[i]]=d[u]+w[i];
	        dfs(v[i],u);
	    }
	}
}
signed main(void)
{
    read(n);
    for(i=1;i<n;i++)
	{
		int x,y,z;
		read(x),read(y),read(z);
		v[++cnt]=y;
		nxt[cnt]=hd[x];
		w[cnt]=z;
		hd[x]=cnt;
		v[++cnt]=x;
		nxt[cnt]=hd[y];
		w[cnt]=z;
		hd[y]=cnt;
	}
    dfs(1,0);
    for(i=1;i<=n;i++)
		print(d[i]&1),putchar('\n');
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: too few arguments to function 'ssize_t read(int, void*, size_t)'
   17 |     read(n);
      |     ~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:371:16: note: declared here
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~
a.cc:18:9: error: 'i' was not declared in this scope
   18 |     for(i=1;i<n;i++)
      |         ^
a.cc:21:21: error: too few arguments to function 'ssize_t read(int, void*, size_t)'
   21 |                 read(x),read(y),read(z);
      |                 ~~~~^~~
/usr/include/unistd.h:371:16: note: declared here
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~
a.cc:21:29: error: too few arguments to function 'ssize_t read(int, void*, size_t)'
   21 |                 read(x),read(y),read(z);
      |                         ~~~~^~~
/usr/include/unistd.h:371:16: note: declared here
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~
a.cc:21:37: error: too few arguments to function 'ssize_t read(int, void*, size_t)'
   21 |                 read(x),read(y),read(z);
      |                                 ~~~~^~~
/usr/include/unistd.h:371:16: note: declared here
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~
a.cc:32:9: error: 'i' was not declared in this scope
   32 |     for(i=1;i<=n;i++)
      |         ^
a.cc:33:17: error: 'print' was not declared in this scope; did you mean 'rint'?
   33 |                 print(d[i]&1),putchar('\n');
      |                 ^~~~~
      |                 rint
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a[N+1];
  vector<pair<pair<int,int>,int>> pe;
  for (int i=0;i<N;i++){
    cin >> pe.first.first >> pe.first.second >> pe.second;
  }
  a[1]=0;
  sort(pe.begin(),pe.end());
  for (int i=0;i<N-1;i++){
    if(pe.second%2==0){
      if(a[pe.first.first]==0)a[pe.first.second]=0;
      else a[pe.first.second]=1;
    }
    else{
      if(a[pe.first.first]==0)a[pe.first.second]=1;
      else a[pe.first.second]=0;
    }
  }
  for(int i=1;i<N+1;i++)cout << a[i];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: 'class std::vector<std::pair<std::pair<int, int>, int> >' has no member named 'first'
   10 |     cin >> pe.first.first >> pe.first.second >> pe.second;
      |               ^~~~~
a.cc:10:33: error: 'class std::vector<std::pair<std::pair<int, int>, int> >' has no member named 'first'
   10 |     cin >> pe.first.first >> pe.first.second >> pe.second;
      |                                 ^~~~~
a.cc:10:52: error: 'class std::vector<std::pair<std::pair<int, int>, int> >' has no member named 'second'
   10 |     cin >> pe.first.first >> pe.first.second >> pe.second;
      |                                                    ^~~~~~
a.cc:15:11: error: 'class std::vector<std::pair<std::pair<int, int>, int> >' has no member named 'second'
   15 |     if(pe.second%2==0){
      |           ^~~~~~
a.cc:16:15: error: 'class std::vector<std::pair<std::pair<int, int>, int> >' has no member named 'first'
   16 |       if(a[pe.first.first]==0)a[pe.first.second]=0;
      |               ^~~~~
a.cc:16:36: error: 'class std::vector<std::pair<std::pair<int, int>, int> >' has no member named 'first'
   16 |       if(a[pe.first.first]==0)a[pe.first.second]=0;
      |                                    ^~~~~
a.cc:17:17: error: 'class std::vector<std::pair<std::pair<int, int>, int> >' has no member named 'first'
   17 |       else a[pe.first.second]=1;
      |                 ^~~~~
a.cc:20:15: error: 'class std::vector<std::pair<std::pair<int, int>, int> >' has no member named 'first'
   20 |       if(a[pe.first.first]==0)a[pe.first.second]=1;
      |               ^~~~~
a.cc:20:36: error: 'class std::vector<std::pair<std::pair<int, int>, int> >' has no member named 'first'
   20 |       if(a[pe.first.first]==0)a[pe.first.second]=1;
      |                                    ^~~~~
a.cc:21:17: error: 'class std::vector<std::pair<std::pair<int, int>, int> >' has no member named 'first'
   21 |       else a[pe.first.second]=0;
      |                 ^~~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18

using Graph = vector<vector<int>>;
Graph to,cost;

int N;
vector<int> ans;

void dfs(int x,int p){
    for(auto next : to[x]){
        if(next == p) continue;
        if(cost[x][next] % 2 == 0) ans[next] = ans[x];
        else ans[next] = 0;
        dfs(next,x);
    }
}


int main(){
    cin >> N;
    to,ans = vector<vector<int>>(N);
    cost = vector<vector<int>>(N,vector<int>(N));
    rep(i,N){
        int u,v,w;
        cin >> u >> v >> w;
        u--; v--; w--;
        to[u].push_back(v); 
        to[v].push_back(u); cost[u][v] = w;
    }
    ans[0] = 0;
    dfs(0,-1);
    rep(i,N){
        cout << ans[i] << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:35: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<std::vector<int> >')
   37 |     to,ans = vector<vector<int>>(N);
      |                                   ^
In file included from /usr/include/c++/14/vector:72,
                 from a.cc:3:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
Language: C++

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

static const int INF = (1<<21);
int d[100010] = {INF};
int M[100010][100010];
int N;

void bfs(int s){
    queue<int> q;
    q.push(s);

    int u;
    while( !q.empty()){
        u = q.front();q.pop();
        for(int v = 0;v<N;v++){
            if(M[u][v] == 0) continue;
            if(d[v] != INF) continue;
            d[v] = d[u] + M[u][v];
            q.push(v);
        }
    }
}

int main(){
    cin >>N;
    
    for(int i = 0;i<N;i++){
        for(int j = 0;j<N;j++) M[i][j] = 0;
    }

    int u,v,w;
    for(int i = 0;i<N;i++){
        cin >> u >> v >> w; u--; v--;
        M[u][v] = w;
    }
    
    d[0] = 0;
    bfs(0);

    int ans;
    for(int i = 0;i<N;i++){
        ans = d[i]%2 == 0;
        cout << ans << endl;
    }
}

Compiler output:
/tmp/ccitK0q7.o: in function `bfs(int)':
a.cc:(.text+0x12d): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccitK0q7.o
/tmp/ccitK0q7.o: in function `main':
a.cc:(.text+0x189): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccitK0q7.o
a.cc:(.text+0x1e2): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccitK0q7.o
a.cc:(.text+0x1f1): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccitK0q7.o
a.cc:(.text+0x280): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccitK0q7.o
a.cc:(.text+0x2fb): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccitK0q7.o
collect2: error: ld returned 1 exit status
Language: Java

import java.util.*;
import java.util.Map.*;

public class Main {
    private static int[] colors;
    private static Map<Integer, Integer>[] friendship;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = n - 1;
        
        colors = new int[n];
        Arrays.fill(colors, -1);
        
        friendship = new HashMap[n];
        Arrays.fill(friendship, i -> new HashMap<Integer, Integer>());
        
        while (m-- > 0) {
            int me = sc.nextInt() - 1;
            int you = sc.nextInt() - 1;
            int length = sc.nextInt();
            friendship[me].put(you, length);
            friendship[you].put(me, length);
        }
        
        dfs(0, 0);
        
        for (int c : colors) {
            System.out.println(c);
        }
    }
    
    public static void dfs(int p, int length) {
        boolean alreadyKnown = colors[p] != -1;
        if (alreadyKnown) return;
        
        if (length % 2 == 0) {
            colors[p] = 0;
        } else {
            colors[p] = 1;
        }
        
        for (Entry<Integer, Integer> entry : friendship[p].entrySet()) {
            int friend = entry.getKey();
            int length2 = entry.getValue();
            dfs(friend, length + length2);
        }
    }
}

Compiler output:
Main.java:18: error: no suitable method found for fill(Map<Integer,Integer>[],(i)->new H[...]er>())
        Arrays.fill(friendship, i -> new HashMap<Integer, Integer>());
              ^
    method Arrays.fill(long[],long) is not applicable
      (argument mismatch; Map<Integer,Integer>[] cannot be converted to long[])
    method Arrays.fill(int[],int) is not applicable
      (argument mismatch; Map<Integer,Integer>[] cannot be converted to int[])
    method Arrays.fill(short[],short) is not applicable
      (argument mismatch; Map<Integer,Integer>[] cannot be converted to short[])
    method Arrays.fill(char[],char) is not applicable
      (argument mismatch; Map<Integer,Integer>[] cannot be converted to char[])
    method Arrays.fill(byte[],byte) is not applicable
      (argument mismatch; Map<Integer,Integer>[] cannot be converted to byte[])
    method Arrays.fill(boolean[],boolean) is not applicable
      (argument mismatch; Map<Integer,Integer>[] cannot be converted to boolean[])
    method Arrays.fill(double[],double) is not applicable
      (argument mismatch; Map<Integer,Integer>[] cannot be converted to double[])
    method Arrays.fill(float[],float) is not applicable
      (argument mismatch; Map<Integer,Integer>[] cannot be converted to float[])
    method Arrays.fill(Object[],Object) is not applicable
      (argument mismatch; Object is not a functional interface)
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error