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

#include <bits/stdc++.h>
using namespace std;
const int nmax=100005;
vector<int> A[nmax],B[nmax];

void DFS(int u,int N,int color[nmax]){
    bool check=true;
    for(int i=0;i<N;i++){
        if(color[i]==0){
            check=false;
            break;
        }
    }
    if(check){
        for(int i=0;i<N;i++){
            cout<<color[i]%2<<endl;
        }
        return;
    }
        for(int i=0;i<A[u].size();i++){
            if(color[A[u][i]]==0){
                color[A[u][i]]=color[u];
                DFS(A[u][i],N,color);
            }
            }
        for(int i=0;i<B[u].size();i++){
            if(color[B[u][i]]==0){
                color[B[u][i]]=color[u]%2+1;
                DFS(B[u][i],N,color%2+1);
            }
        }
    return;
        }

int main(){
   
    int N;
    cin>>N;
    for(int i=0;i<N-1;i++){
        int x,y,z;
        cin>>x>>y>>z;
        if(z%2==0){
            A[x-1].push_back(y-1);
            A[y-1].push_back(x-1);
        }
        else if(z%2==1) {
            B[x-1].push_back(y-1);
            B[y-1].push_back(x-1);
        }
        
    }

    int color[nmax];
    color[0]=2;
    DFS(0,N,color);
}


Compiler output:
a.cc: In function 'void DFS(int, int, int*)':
a.cc:29:36: error: invalid operands of types 'int*' and 'int' to binary 'operator%'
   29 |                 DFS(B[u][i],N,color%2+1);
      |                               ~~~~~^~
      |                               |     |
      |                               int*  int
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int nmax=100005;
vector<int> A[nmax],B[nmax];
int color[nmax];
void DFS(int u,int N){
    bool check=true;
    for(int i=0;i<N;i++){
        if(color[i]==0){
            check=false;
            break;
        }
    }
    if(check){
        for(int i=0;i<N;i++){
            cout<<color[i]%2<<endl;
        }
        return;
    }
        for(int i=0;i<A[u].size();i++){
            if(color[A[u][i]]==0){
                color[A[u][i]]=color[u];
                DFS(A[u][i],N,color);
            }
            }
        for(int i=0;i<B[u].size();i++){
            if(color[B[u][i]]==0){
                color[B[u][i]]=color[u]%2+1;
                DFS(B[u][i],N,color);
            }
        }
    return;
        }

int main(){
   
    int N;
    cin>>N;
    for(int i=0;i<N-1;i++){
        int x,y,z;
        cin>>x>>y>>z;
        if(z%2==0){
            A[x-1].push_back(y-1);
            A[y-1].push_back(x-1);
        }
        else if(z%2==1) {
            B[x-1].push_back(y-1);
            B[y-1].push_back(x-1);
        }
        
    }

    color[0]=2;
    DFS(0,N);
}


Compiler output:
a.cc: In function 'void DFS(int, int)':
a.cc:23:20: error: too many arguments to function 'void DFS(int, int)'
   23 |                 DFS(A[u][i],N,color);
      |                 ~~~^~~~~~~~~~~~~~~~~
a.cc:6:6: note: declared here
    6 | void DFS(int u,int N){
      |      ^~~
a.cc:29:20: error: too many arguments to function 'void DFS(int, int)'
   29 |                 DFS(B[u][i],N,color);
      |                 ~~~^~~~~~~~~~~~~~~~~
a.cc:6:6: note: declared here
    6 | void DFS(int u,int N){
      |      ^~~
Language: Java

import java.util.Scanner;
2. 
3.class Main{
4.	public static void main(String[]$){
5. 
6.		Scanner sc = new Scanner(System.in);
7.      	int N = sc.nextInt();
8.      	if(N == 3){
9.          System.out.println(0);
10.          System.out.println(0);
11.          System.out.println(1);
12.        } else {
13.		  System.out.println(1);
14.          System.out.println(1);
15.          System.out.println(1);
16.          System.out.println(1);
17.          System.out.println(1);
18.        }
19.	}
20.}


Compiler output:
Main.java:2: error: class, interface, enum, or record expected
2. 
^
Main.java:4: error: illegal start of type
4.	public static void main(String[]$){
^
Main.java:5: error: not a statement
5. 
^
Main.java:5: error: ';' expected
5. 
  ^
Main.java:7: error: not a statement
7.      	int N = sc.nextInt();
^
Main.java:7: error: ';' expected
7.      	int N = sc.nextInt();
  ^
Main.java:8: error: not a statement
8.      	if(N == 3){
^
Main.java:8: error: ';' expected
8.      	if(N == 3){
  ^
Main.java:9: error: not a statement
9.          System.out.println(0);
^
Main.java:9: error: ';' expected
9.          System.out.println(0);
  ^
Main.java:10: error: not a statement
10.          System.out.println(0);
^
Main.java:10: error: ';' expected
10.          System.out.println(0);
   ^
Main.java:11: error: not a statement
11.          System.out.println(1);
^
Main.java:11: error: ';' expected
11.          System.out.println(1);
   ^
Main.java:12: error: not a statement
12.        } else {
^
Main.java:12: error: ';' expected
12.        } else {
   ^
Main.java:13: error: not a statement
13.		  System.out.println(1);
^
Main.java:13: error: ';' expected
13.		  System.out.println(1);
   ^
Main.java:14: error: not a statement
14.          System.out.println(1);
^
Main.java:14: error: ';' expected
14.          System.out.println(1);
   ^
Main.java:15: error: not a statement
15.          System.out.println(1);
^
Main.java:15: error: ';' expected
15.          System.out.println(1);
   ^
Main.java:16: error: not a statement
16.          System.out.println(1);
^
Main.java:16: error: ';' expected
16.          System.out.println(1);
   ^
Main.java:17: error: not a statement
17.          System.out.println(1);
^
Main.java:17: error: ';' expected
17.          System.out.println(1);
   ^
Main.java:18: error: not a statement
18.        }
^
Main.java:18: error: ';' expected
18.        }
   ^
Main.java:19: error: not a statement
19.	}
^
Main.java:19: error: ';' expected
19.	}
   ^
Main.java:20: error: illegal start of type
20.}
^
31 errors
Language: Java

import java.util.Scanner;

class Main{
	public static void main(String[]$){

		Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	if(N = 3){
          System.out.println(0);
          System.out.println(0);
          System.out.println(1);
        } else {
		  System.out.println(1);
          System.out.println(1);
          System.out.println(1);
          System.out.println(1);
          System.out.println(1);
        }
	}
}


Compiler output:
Main.java:8: error: incompatible types: int cannot be converted to boolean
      	if(N = 3){
      	     ^
1 error
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    int map[n];
    REP(i,n) map[i] = INT_MAX;
    vector<vector<pair<int, int> > > adjacent_table(n);
    int u,v,w;
    REP(i,n-1) {
      scanf("%d %d %d", &u, &v, &w);
      adjacent_table[u].push_back(make_pair(v, w));
    }
    REP(i,n) {
      int p = adjacent_table[i].size();
      REP(j,p) {
        pair<int, int> tmp = adjacent_table[i][j];
        if(map[tmp.first] == INT_MAX) {
          // まだ訪れていない
          map[tmp.first] = (tmp.second % 2 == 0)?map[i]:map[i]^1;
        }
      }
    }
    REP(i,n) printf("%d\n", map[i]);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:23: error: 'INT_MAX' was not declared in this scope
   18 |     REP(i,n) map[i] = INT_MAX;
      |                       ^~~~~~~
a.cc:8:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include <stack>
  +++ |+#include <climits>
    8 | using namespace std;
a.cc:29:30: error: 'INT_MAX' was not declared in this scope
   29 |         if(map[tmp.first] == INT_MAX) {
      |                              ^~~~~~~
a.cc:29:30: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: Java

import java.util.ArrayList;
import java.util.Scanner;
public class Main_sort {

	static int u,v,w;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] color = new Integer[n+1];
		ArrayList<Integer[]> al = new ArrayList<Integer[]>();
		color[1]=0;
		
		for(int i=0;i<n-1;i++) {
			u = sc.nextInt();
			v = sc.nextInt();
			w = sc.nextInt();
			int index=0;
			if(al.isEmpty()) {
				al.add(setInt());
				continue;
			}
			for(Integer[] in : al) {
				if(in[0] > u) {
					al.add(index,setInt());
					break;
				}
				index++;
			}
			if(index==al.size()) {
				al.add(setInt());
			}
		}
		
//		for(Integer[] branch : al) {
		for(int j=0;j<al.size();j++) {
			Integer[] branch = al.get(j);
			if(color[branch[1]] == null && color[branch[0]] == null) {
				al.add(branch);
				continue;
			}
			if(branch[2]%2==0) {
				//Even
				if(color[branch[0]] != null) {
					color[branch[1]] = color[branch[0]];
				}else {
					color[branch[0]] = color[branch[1]];
				}
			}else {
				//Odd
				if(color[branch[0]] != null) {
					color[branch[1]] = color[branch[0]] == 0 ? 1 : 0;
				}else {
					color[branch[0]] = color[branch[1]] == 0 ? 1 : 0;
				}
			}
		}
		
		sc.close();
		for(int i=1;i<n+1;i++) {
			System.out.println(color[i]);
		}

	}
	
	public static Integer[] setInt() {
		Integer[] re = new Integer[3];
		re[0] = Math.min(u, v);
		re[1] = Math.max(u, v);
		re[2] = w;
		return re;
	}

}


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

#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
bool used[111111] = {};
int dis[111111] = {};
vector<int> g[111111];
map<pair<int, int>, int> m;
void dfs(int now, int dist){
    if(used[now]){
        return;
    }
    used[now] = true;
    dis[now] = dist;
    each(i, g[now]){
        dfs(i, dist + m[mp(now, i)]);
    }
}
main(){
    INCANT;
    int n, res = 0;
    string s;
    in(n);
    rep(i, n){
        in(a[i], b[i], c[i]);
        a[i]--, b[i]--;
        g[a[i]].pb(b[i]), g[b[i]].pb(a[i]);
        m[mp(a[i], b[i])] = m[mp(b[i], a[i])] = c[i];
    }
    dfs(0, 0);
    rep(i, n){
        if(dis[i] % 2){
            print(0);
        }else{
            print(1);
        }
    }
}


Compiler output:
a.cc:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:57:12: error: 'a' was not declared in this scope
   57 |         in(a[i], b[i], c[i]);
      |            ^
a.cc:57:18: error: 'b' was not declared in this scope
   57 |         in(a[i], b[i], c[i]);
      |                  ^
a.cc:57:24: error: 'c' was not declared in this scope
   57 |         in(a[i], b[i], c[i]);
      |                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
bool used[111111] = {};
int dis[111111] = {};
vector<int> g[111111];
map<pair<int, int>, int> m;
void dfs(int now, int dist){
    if(used[now]){
        return;
    }
    used[now] = true;
    dis[now] = dist;
    each(i, g[now]){
        dfs(i, dist + m[mp(now, i)]);
    }
}
main(){
    INCANT;
    int n, res = 0;
    string s;
    in(n);
    rep(i, n){
        in(a[i], b[i], c[i]);
        a[i]--, b[i]--;
        g[a[i]].pb(b[i]), g[b[i]].pb(a[i]);
        m[mp(a[i], b[i])] = m[mp(b[i], a[i])] = c[i];
    }
    dfs(0, 0);
    rep(i, n){
        if(dis[i] % 2){
            print(0);
        }else{
            print(1);
        }
    }
}

Compiler output:
a.cc:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:57:12: error: 'a' was not declared in this scope
   57 |         in(a[i], b[i], c[i]);
      |            ^
a.cc:57:18: error: 'b' was not declared in this scope
   57 |         in(a[i], b[i], c[i]);
      |                  ^
a.cc:57:24: error: 'c' was not declared in this scope
   57 |         in(a[i], b[i], c[i]);
      |                        ^
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main() {
  int N; cin >> N;
  vector<pair<int, int> > G[10001];
  for (int i = 0; i < N; i++) {
    int u, v, w; cin >> u >> v >> w;
    u--; v--; w %= 2;
    G[u].push_back(make_pair(v, w));
  }
  queue<make_pair(int, int)> Q;
  Q.push(make_pair(0, 0));
  int color[10001] = {0};
  int checked[10001] = {0};
  while (Q.size()) {
    pair<int, int> p = Q.pop();
    checked[p.first]++;
    if (p.second % 2) color[p.first] = 1;
    for (int i = 0; i < G[p.first].size(); i++) {
      pair<int, int> n = G[p.first][i];
      if (checked[n.first]) continue;
      Q.push(make_pair(n.first, p.first + n.second));
    }
  }
  for (int i = 0; i < N; i++) {
    cout << color[i] << endl;
  }
  
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:13:28: error: template argument 1 is invalid
   13 |   queue<make_pair(int, int)> Q;
      |                            ^
a.cc:13:28: error: template argument 2 is invalid
a.cc:14:5: error: request for member 'push' in 'Q', which is of non-class type 'int'
   14 |   Q.push(make_pair(0, 0));
      |     ^~~~
a.cc:17:12: error: request for member 'size' in 'Q', which is of non-class type 'int'
   17 |   while (Q.size()) {
      |            ^~~~
a.cc:18:26: error: request for member 'pop' in 'Q', which is of non-class type 'int'
   18 |     pair<int, int> p = Q.pop();
      |                          ^~~
a.cc:24:9: error: request for member 'push' in 'Q', which is of non-class type 'int'
   24 |       Q.push(make_pair(n.first, p.first + n.second));
      |         ^~~~
Language: C++

 adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#define FAST        ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)        cerr << #x << " = " << x << endl;
#define mod         998244353
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl        '\n'
const int INF = 0x3f3f3f3f;

vector<pii> adj[100005];
int vis[100005]={0},n;
int col[100005]={0};
void dfs(int node)
{
  vis[node]=1;
  for(auto i:adj[node])
  {
    if(!vis[i.F])
    {
      if(i.S&1) col[i.F]=!col[node];
      else col[i.F]=col[node];
      dfs(i.F);
    }
  }
}
int main()
{
    FAST;
    //  #ifndef ONLINE_JUDGE
//      freopen("input.txt", "r", stdin);
//      freopen("output.txt", "w", stdout);
//  #endif
    int t; t=1;
    while(t--)
    {
       int n; cin>>n;
       rep(i,1,n)
       {
         int x,y,wt; cin>>x>>y>>wt;
         adj[x].pb({y,wt});
         adj[y].pb({x,wt});
       }
       dfs(1);
       rep(i,1,n+1) cout<<col[i]<<endl;
    }
}

Compiler output:
a.cc:1:2: error: 'adiforluls' does not name a type
    1 |  adiforluls
      |  ^~~~~~~~~~
Language: C++

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

//幅優先　ツリー　木　無効グラフ　重み付き　二部グラフ

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;
int N;
Graph G;

vector<int> res;

// v は現在見ている頂点, p は v の親
void dfs(int v, int p ,int c) {
    res[v]=c;
  for (auto e : G[v]) {
    if (e.first == p) continue;  // これがツリー探索で一般的な書き方
    if(e.second&1) dfs(e.first,v,1-c);
    else dfs(e.first, v,c);
  }
}

int main() {
  cin >> N;
  G.assign(N,vector<Edge>()); //GをN個のエッジで初期化
  for(int i=0;i<N-1;i++){
      int u,v,w;
      cin >> y >> v >> w;
      --u,--v;
      G[u].push_back(Edge(v,w));
      G[v].push_back(Edge(u,w));
  }
  res.assign(N,0);
  dfs(0,-1,1);
  for(auto v:res)cout<< v << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:14: error: 'y' was not declared in this scope
   45 |       cin >> y >> v >> w;
      |              ^
Language: C++

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

//幅優先　ツリー　木　無効グラフ　重み付き　二部グラフ

using Edge = pair<int,int>
using Graph = vector<vector<Edge> >;
int N;
Graph G;

vector<int> res;

// v は現在見ている頂点, p は v の親
void dfs(int v, int p ,int c) {
    res[v]=c;
  for (auto e : G[v]) {
    if (e.first == p) continue;  // これがツリー探索で一般的な書き方
    if(e.second&1) dfs(e.first,v,1-c);
    else dfs(e.first, v,c);
  }
}

int main() {
  cin >> N;
  G.assign(N,vector<Edge>()); //GをN個のエッジで初期化
  for(int i=0;i<N-1;i++){
      int u,v,w;
      cin >> y >> v >> w;
      --u,--v;
      G[u].push_back(Edge(v,w));
      G[v].push_back(Edge(u,w));
  }
  res.assign(N,0);
  dfs(0,-1,1);
  for(auto v:res)cout<< v << endl;

}

Compiler output:
a.cc:23:27: error: expected ';' before 'using'
   23 | using Edge = pair<int,int>
      |                           ^
      |                           ;
   24 | using Graph = vector<vector<Edge> >;
      | ~~~~~                      
a.cc:26:1: error: 'Graph' does not name a type
   26 | Graph G;
      | ^~~~~
a.cc: In function 'void dfs(int, int, int)':
a.cc:33:17: error: 'G' was not declared in this scope
   33 |   for (auto e : G[v]) {
      |                 ^
a.cc: In function 'int main()':
a.cc:42:3: error: 'G' was not declared in this scope
   42 |   G.assign(N,vector<Edge>()); //GをN個のエッジで初期化
      |   ^
a.cc:42:21: error: 'Edge' was not declared in this scope
   42 |   G.assign(N,vector<Edge>()); //GをN個のエッジで初期化
      |                     ^~~~
a.cc:42:25: error: template argument 1 is invalid
   42 |   G.assign(N,vector<Edge>()); //GをN個のエッジで初期化
      |                         ^
a.cc:42:25: error: template argument 2 is invalid
a.cc:45:14: error: 'y' was not declared in this scope
   45 |       cin >> y >> v >> w;
      |              ^
Language: C++

#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#define OPEN 0
#define N 100010
#define VISITED 1
#define UNVISITED 0
using namespace std;
vector<vector<pair<int,int>>> g(N);
int flag[N];
int color_map[N];
int dis[N];
void BFS(){
	int u =0;
	queue<int> q;
	q.push(u);
	flag[u] = VISITED;
	color_map[u] = 1;
	dis[u] = 0;
	while(!q.empty()){
		int u = q.front();q.pop();
		for(int i=0;i<(int)g[u].size();i++){
			int nx = g[u][i].first;
			int w = g[u][i].second;
			if(flag[nx] == UNVISITED){
				flag[nx] = VISITED;
				dis[nx] = dis[u] + w;
				if(dis[nx]%2 == 0)color_map[nx] = 1;
				else color_map[nx] =0;
				q.push(nx);
			}
		}
	}
}
int main(){
#if OPEN

	freopen("input.txt", "r", stdin);
#endif 
	int nv;
	cin>>nv;
	stringstream ss;
	string s;
	getline(cin, s);	//eat space

	while (getline(cin, s)) {
		ss << s;
		int u, v, w;
		//cin >> u >> v >> w;
		ss >> u;
		ss >> v;
		ss >> w;
		u = u - 1;
		v = v - 1;
		g[u].emplace_back(v, w);
		g[v].emplace_back(u, w);
		ss.str("");
		ss.clear();
	}
	memset(flag,UNVISITED,sizeof(flag));
	BFS();
	for(int i=0;i<nv;i++)cout<<color_map[i]<<'\n';
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:9: error: 'memset' was not declared in this scope
   61 |         memset(flag,UNVISITED,sizeof(flag));
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <queue>
  +++ |+#include <cstring>
    5 | #define OPEN 0
Language: C++

//#include <cstdio>
//#include <cmath>
//#include <iostream>
//#include <sstream>
//#include <string>
//#include <vector>
//#include <map>
//#include <queue>
//#include <algorithm>
//
//#ifdef _DEBUG
//#define DMP(x) cerr << #x << ": " << x << "\n"
//#else
//#define DMP(x) ((void)0)
//#endif
//
//const int MOD = 1000000007, INF = 1111111111; 
//using namespace std;
//typedef long long lint;
//
//template<class T = lint>
//struct Edge {
//	int from, to;
//	T cost;
//	Edge() {}
//	Edge(int to, T cost) : from(-1), to(to), cost(cost) {}
//	Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
//};
//
//template<class T = lint>
//vector<T> Dijkstra(vector<Edge<T>> &edges,int st) {
//	const T INF = numeric_limits<T>::max();
//	vector<T> dist(V, INF);
//	dist[st] = 0;
//
//	using Pi = pair<T, int>;
//	priority_queue<Pi, vector<Pi>, greater<Pi>> prique;
//	prique.emplace(0,st);
//
//	while (!prique.empty()) {
//		T cost;
//		int idx;
//		{cost, idx} = que.top();
//		que.pop();
//		if (dist[idx] < cost) continue;
//
//		for (auto& e : edges[idx]){
//			auto nx_cost = cost + e.cost;
//			if (dist[e.to] > nx_cost) {
//				dist[e.to] = nx_cost;
//				que.emplace(dist[e.to], e, to);
//			}
// 		}
//	}
//
//}
//
//int main() {
//
//	cin.tie(nullptr);
//	ios::sync_with_stdio(false);
//
//	int N;
//	cin >> N;
//
//	int u, v, len, st0 = INF, st1 = INF;
//	vector<Edge<int>> edges;
//
//	for (int i = 0; i < N - 1; i++) {
//		cin >> u >> v >> len;
//		edges.emplace
//	}
//
//	for (int i = 0; i < N; i++) {
//		if(UF.root(i) == UF.root(st0)) cout << '0' << "\n";
//		else cout << '1' << "\n";
//	}
//
//	return 0;
//}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, long long> P; // {to, cost}

int n;
const int N = 100010;
vector<P> G[N];
vector<int> Color(N);

void dfs(int now, int pre, int color, long long acost){ // accumlate_cost
    Color[now] = color; 
    for(int i = 0; i < G[now].size(); i++){
        P p = G[now][i];
        if(p.first == pre) continue;
        long long to_acost = p.second + acost;
        if(to_acost % 2 == acost % 2 ) dfs(p.first, now, color, to_acost);
        else dfs(p.first, now, (color == 1 ? 0 : 1), to_acost);
    }
}


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

    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int a, b;
        long long c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    
  	G.resize(n);
    Color.resize(n);
    
    dfs(0, -1, 1, 0);

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

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:11: error: request for member 'resize' in 'G', which is of non-class type 'std::vector<std::pair<int, long long int> > [100010]'
   36 |         G.resize(n);
      |           ^~~~~~
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int ans[100010], n, g=0;
bool in[100010]={};
vector<pair<int, int>> G[100010];

void dfs(int k){
  ans[k]=g%2;
  in[k]=true;
  for(int i=0; i<G[k].size(); i++){
    if(in[G[k][i]]){
    g+=G[k][i].second%2;
    dfs(G[k][i].first);
    g-=G[k][i].second%2;
    }
  }
}

int main(){
  cin>>n;
  for(int i=0; i<n-1; i++){
    int u, v;
    cin>>u>>v>>w;
    u--;  v--;
    G[u].emplace_back(v, w);
    G[v].emplace_back(u, w);
  }
  dfs(0);
  for(int i=0; i<n; i++) cout<<ans[i]<<endl;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:12:10: error: no match for 'operator[]' (operand types are 'bool [100010]' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
   12 |     if(in[G[k][i]]){
      |          ^
a.cc: In function 'int main()':
a.cc:24:16: error: 'w' was not declared in this scope
   24 |     cin>>u>>v>>w;
      |                ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

vector<vector<pii> > g;
vector<bool> color;

int dfs(int u, int p, ll dist) {
  color[u] = dist&1;
  for (auto ed : g[u]) {
  	if (ed.first != p) {
      dfs(ed.first, u, dist+ed.second);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  color.assign(n, 0);
  g.assign(n, vector<pii>());
  for (int i = 0, u, v, w; i < n-1; ++i) {
  	cin >> u >> v >> w;
    g[u-1].push_back({v-1, w});
    g[v-1].push_back({u-1, w});
  }
  dfs(0, -1, 0);
  for (int c : color) {
  	cout << c << "\n";
  }
}

Compiler output:
a.cc:8:23: error: 'll' has not been declared
    8 | int dfs(int u, int p, ll dist) {
      |                       ^~
a.cc: In function 'int dfs(int, int, int)':
a.cc:15:1: warning: no return statement in function returning non-void [-Wreturn-type]
   15 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
// http://drken1215.hatenablog.com/entry/2019/05/19/224500
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

int n;
Graph G;
vector<int> res;

void dfs(int v, int p, int c) {
    res[v] = c;
    for(auto e : G[v]) {
        if(e.first == p)
            continue;
        if(e.second & 1)
            dfs(e.first, v, 1 - c);
        else
            dfs(e.first, v, c);
    }
}

int main() {
    cin >> N;
    G.assign(N, 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(u, v));
        G[v].push_back(Edge(u, w));
    }
    res.assign(N, 0);
    dfs(0, -1, 1);
    for(auto v : res)
        cout << v << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:12: error: 'N' was not declared in this scope
   25 |     cin >> N;
      |            ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
// http://drken1215.hatenablog.com/entry/2019/05/19/224500
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

int n;
Graph G;
vector<int> res;

void dfs(int v, int p, int c) {
    res[v] = c;
    for(auto e : G[v]) {
        if(e.first == p)
            continue;
        if(e.second & 1)
            dfs(e.first, v, 1 - c);
        else
            dfs(e.first, v, c)
    }
}

int main() {
    cin >> N;
    G.assign(N, 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(u, v));
        G[v].push_back(Edge(u, w));
    }
    res.assign(N, 0);
    dfs(0, -1, 1);
    for(auto v : res)
        cout << v << endl;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:20:31: error: expected ';' before '}' token
   20 |             dfs(e.first, v, c)
      |                               ^
      |                               ;
   21 |     }
      |     ~                          
a.cc: In function 'int main()':
a.cc:25:12: error: 'N' was not declared in this scope
   25 |     cin >> N;
      |            ^
Language: C++

#include <iostream>
using namespace std;

constexpr int MAX_N = 1e5 + 7;

int N;
int edges[MAX_N+1][MAX_N+1];
int colors[MAX_N+1];

void dfs(int prev, int cur) {
  colors[cur] = edges[prev][cur] % 2 == 0 ? colors[prev] : !colors[prev];

  for (int i{1}; i <= N; ++i) {
    if (colors[i] >= 0 || edges[cur][i] == 0)
      continue;
    dfs(cur, i);
  }
}

int main() {
  fill_n(colors, MAX_N+1, -1);
  colors[0] = 0;

  cin >> N;

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

  dfs(0, u);
  for (int i{1}; i <= N; ++i) {
    cout << colors[i] << endl;
  }
}


Compiler output:
/tmp/ccyh6QDG.o: in function `dfs(int, int)':
a.cc:(.text+0x4c): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccyh6QDG.o
a.cc:(.text+0x65): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccyh6QDG.o
a.cc:(.text+0x85): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccyh6QDG.o
a.cc:(.text+0xa5): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccyh6QDG.o
/tmp/ccyh6QDG.o: in function `main':
a.cc:(.text+0x11e): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccyh6QDG.o
a.cc:(.text+0x12c): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccyh6QDG.o
a.cc:(.text+0x245): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/ccyh6QDG.o
collect2: error: ld returned 1 exit status
Language: C++

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

constexpr int MAX_N = 1e5 + 7;

int N;
int edges[MAX_N+1][MAX_N+1];
int colors[MAX_N+1];

void dfs(int prev, int cur) {
  colors[cur] = edges[prev][cur] % 2 == 0 ? colors[prev] : !colors[prev];

  for (int i{1}; i <= N; ++i) {
    if (colors[i] >= 0 || edges[cur][i] == 0)
      continue;
    dfs(cur, i);
  }
}

int main() {
  fill_n(colors, MAX_N+1, -1);
  colors[0] = 0;

  cin >> N;

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

  dfs(0, u);
  for (int i{1}; i <= N; ++i) {
    cout << colors[i] << endl;
  }
}


Compiler output:
/tmp/cc9hIQbt.o: in function `dfs(int, int)':
a.cc:(.text+0x4c): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/cc9hIQbt.o
a.cc:(.text+0x65): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/cc9hIQbt.o
a.cc:(.text+0x85): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/cc9hIQbt.o
a.cc:(.text+0xa5): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/cc9hIQbt.o
/tmp/cc9hIQbt.o: in function `main':
a.cc:(.text+0x11e): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/cc9hIQbt.o
a.cc:(.text+0x12c): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/cc9hIQbt.o
a.cc:(.text+0x245): relocation truncated to fit: R_X86_64_PC32 against symbol `colors' defined in .bss section in /tmp/cc9hIQbt.o
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
#include<stdlib.h>
int main() {
	int i,memi;
	int *ad,*wad;
	scanf("%d", &i);
    printf("\n");
	memi = i;
	ad = (int *)malloc(i * sizeof(int));
	wad= (int *)malloc(i * sizeof(int));
	while (i!=0) {
		scanf_s("%d ", &ad[i]);
		i--;
	}
	i = memi;
    printf("\n");
	while (i != 0) {
		scanf_s("%d ", &wad[i]);
		i--;
	}
	i = memi;
	while (i != 0) {
		printf("%d %d ", ad[i], wad[i]);
		i--;
	}
    printf("\n");
	/*free(ad);
	free(wad);*/
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:12:17: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   12 |                 scanf_s("%d ", &ad[i]);
      |                 ^~~~~~~
      |                 scanf
Language: C

#include<iostream>
int main() {
	int i,memi;
	int *ad,*wad;
	scanf("%d", &i);
    printf("\n");
	memi = i;
	ad = (int *)malloc(i * sizeof(int));
	wad= (int *)malloc(i * sizeof(int));
	while (i!=0) {
		scanf("%d ", &ad[i]);
		i--;
	}
	i = memi;
    printf("\n");
	while (i != 0) {
		scanf("%d ", &wad[i]);
		i--;
	}
	i = memi;
	while (i != 0) {
		printf("%d %d ", ad[i], wad[i]);
		i--;
	}
    printf("\n");
	/*free(ad);
	free(wad);*/
	return 0;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include<iostream>
int main() {
	int i,memi;
	int *ad,*wad;
	scanf("%d", &i);
    printf("\n");
	memi = i;
	ad = (int *)malloc(i * sizeof(int));
	wad= (int *)malloc(i * sizeof(int));
	while (i!=0) {
		scanf("%d", &ad[i]);
		i--;
	}
	i = memi;
    printf("\n");
	while (i != 0) {
		scanf("%d", &wad[i]);
		i--;
	}
	i = memi;
	while (i != 0) {
		printf("%d %d ", ad[i], wad[i]);
		i--;
	}
    printf("\n");
	/*free(ad);
	free(wad);*/
	return 0;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

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

const int sz = 1e5+1 ;

vector<pair<int , long long int> > adj[sz] ;
long long int d[sz] , col[sz] ;
int n ;

void bfs(int start)
{
    queue<int> q ;
    q.push(start) ;
    for(int i = 1 ; i <= n ; i++) d[i] = LLONG_MAX ;
    d[start] = 0 ;
    while(!q.empty())
    {
        int u = q.top() ;
        q.pop() ;
        for(int i = 0 ; i < adj[u].size() ; i++)
        {
            long long int w = adj[u][i].second ;
            int z = adj[u][i].first ;
            if(d[u]+w<d[z]) d[z] = d[u] + w , q.push(z) ;
        }
    }
}


int main()
{
    int  st = 0 ;
    cin>>n ;
    for(int i = 0 ; i < n-1 ; i++)
    {
        int u , v , w ;
        cin>>u>>v>>w ;
        adj[u].push_back({v,w}) ;
        adj[v].push_back({u,w}) ;
    }
    bfs(1) ;
    for(int i = 1 ; i <= n ; i++)
    {
        if(d[i]%2==0) col[i] = 0 ;
        else col[i] = -1 ;
        if(st==0 and d[i]%2!=0) st = i ;
        d[i] = 0 ;
    }
    bfs(st) ;
    for(int i = 1 ; i <= n ; i++)
    {
        if(d[i]%2==0 and col[i]==-1) col[i] = 1 ;
    }
    for(int i = 1 ; i <= n ; i++) cout<<col[i]<<endl ;
}


Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:18:19: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   18 |         int u = q.top() ;
      |                   ^~~
      |                   pop
Language: C++

#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
using namespace std;
 
int N;
vector<vector<pair<int, int>>> edge;
 
const int INIT = -1;
vector<int> color;
 
void dfs(int pos, int dist, int diff)
{
    if (color[pos] != INIT)
        return;
 
    color[pos] = dist % 2;
    for (int i = 0; i < (int)edge[pos].size(); i++) {
        int dst = edge[pos][i].first;
        int weight = edge[pos][i].second;
 
        int sum = dist + weight;
        dfs(dst, sum, sum - dist);
    }
}
 
int main(void)
{
    cin >> N;
 
    edge = vector<vector<pair<int, int>>>(N, vector<pair<int, int>>());
    for (int i = 0; i < N - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
 
        u--;
        v--;
        w %= 2;
 
        edge[u].push_back(make_pair(v, w));
        edge[v].push_back(make_pair(u, w));
    }
 
    
    color = vector<int>(N, INIT);
    dfs(0, 0, 0);
 
    for (int i = 0; i < N; i++)
        cout << color[i] << endl;
 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:5: error: 'cin' was not declared in this scope
   30 |     cin >> N;
      |     ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include<utility>
  +++ |+#include <iostream>
    5 | using namespace std;
a.cc:50:9: error: 'cout' was not declared in this scope
   50 |         cout << color[i] << endl;
      |         ^~~~
a.cc:50:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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

int main (void) {
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> graph(N, vector<pair<int, int>>());
  for (int i = 0; i < N - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    graph[u].emplace_back(v, w);
    graph[v].emplace_back(u, w);
  }

  // 頂点の色
  vector<int> color(N, -1);

  // 順に色を塗っていく
  // とりあえず0で始める
  st.push(0);
  color[leaf] = 0;

  vector<bool> visited(N, false);

  while (!st.empty()) {
    const int u = st.top(); st.pop();
    const int u_color = color[u];
    for (const auto& edge : graph[u]) {
      const int v = edge.first, w = edge.second;
      if (!visited[v]) {
        const int next_color = w % 2 == 0 ? u_color : 1 - u_color;
        color[v] = next_color;
        st.push(v);
        visited[v] = true;
      }
    }
  }
  for (const auto& c : color) {
    assert(c != -1);
    cout << c << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:3: error: 'st' was not declared in this scope; did you mean 'std'?
   22 |   st.push(0);
      |   ^~
      |   std
a.cc:23:9: error: 'leaf' was not declared in this scope
   23 |   color[leaf] = 0;
      |         ^~~~
Language: C++

#include<iostream>
#include<string>
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

  int par[1000000];
  void init(int n){
    for(int i=0; i<=n; ++i){
      par[i]=i;
    }
  }
  
  int find(int x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
  }
  
  void unite(int x, int y){
    x=find(x);
    y=find(y);
    if(x==y) return;
  }
  
  bool same(int x, int y) return find(x)==find(y);
  

int main(){
  int N;
  cin>>N;
  init(N);
  
  for(int i=1; i<N; ++i){
    int A,B,C;
    cin>>A>>B>>C;
    if(C%2==0) unite(A,B);
  }
  
  for(int i=1; i<=N; ++i){
    if(same(i,1)==true) cout<<"1"<<endl;
    else cout<<"0"<<endl;
  }
  
}


Compiler output:
a.cc: In function 'bool same(int, int)':
a.cc:27:27: error: named return values are no longer supported
   27 |   bool same(int x, int y) return find(x)==find(y);
      |                           ^~~~~~
a.cc:46:1: warning: no return statement in function returning non-void [-Wreturn-type]
   46 | }
      | ^
Language: C++

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
namespace mp = boost::multiprecision;
using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

struct s_t{
  ll u,v,w;
};

set<ll>a,b;
ll n;
map<ll,ll> mp;
vector<ll>vec;
vector<vector<ll> >v;

void dfs(ll x){              //v に関して深さ優先探索(vは頂点の番号)
  vec[x]=true;              //v に訪問済みの印を付ける

  for(ll i : v[x]){    //v に接続している各頂点i に対し
    if(vec[i]==false){
      ll u2,v2,w2;
      u2=x;
      v2=i;
      w2=mp[u2*1000000+v2];
      if(a.count(u2)){
        if(!(w2&1))a.insert(v2);
        else b.insert(v2);
      }
      else{
        if(!(w2&1))b.insert(v2);
        else a.insert(v2);
      }
      dfs(v2);           //i に関して深さ優先探索
    }
  }
}

int main(){
  cin>>n;
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  vec.assign(n,0);
  v.assign(n,vector<ll>());
  for(ll i=0;i<n-1;i++){
    s_t z;
    cin>>z.u>>z.v>>z.w;
    z.u--;
    z.v--;
    mp[z.u*1000000+z.v]=z.w&1;
    mp[z.v*1000000+z.u]=z.w&1;
    v[z.u].push_back(z.v);
    v[z.v].push_back(z.u);
  }
  a.insert(0);
  dfs(0);

  vector<ll>vvvv(n,0);
  for(auto x : a) {
    vvvv[x]=1;
  }
  for(ll i=0;i<n;i++){
    cout<<vvvv[i]<<endl;
  }
}


Compiler output:
a.cc:1:10: fatal error: boost/multiprecision/cpp_dec_float.hpp: No such file or directory
    1 | #include <boost/multiprecision/cpp_dec_float.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

int n;
vector<pair<int, int>> adj[INT_MAX];
int dst[INT_MAX];

void dfs(int u, int prv, int w){
	dst[u] = w & 1;
	for (int i = 0, nx, l; i < adj[u].size(); i++){
		nx = adj[u][i].first, l = adj[u][i].second;
		if (nx != prv){
			dfs(nx, u, w ^ l);
		}
	}
}
int main(){
	cin >> n;
	for (int i = 1, u, v, w; i < n; i++){
		cin >> u >> v >> w;
		w &= 1;
		adj[u].push_back(make_pair(v, w));
		adj[v].push_back(make_pair(u, w));
	}
	dfs(1, -1, 0);
	for (int i = 1; i <= n; i++) cout << dst[i] << '\n';
	return 0;
}


Compiler output:
/tmp/cc677lMa.o: in function `dfs(int, int, int)':
a.cc:(.text+0x2a): relocation truncated to fit: R_X86_64_PC32 against symbol `dst' defined in .bss section in /tmp/cc677lMa.o
/tmp/cc677lMa.o: in function `main':
a.cc:(.text+0x23f): relocation truncated to fit: R_X86_64_PC32 against symbol `dst' defined in .bss section in /tmp/cc677lMa.o
collect2: error: ld returned 1 exit status
Language: Java

import java.util.*;

public class Main {
  public int P = 1;
  public static int[] c;
  public static int[] d;
  static  HashMap<Integer, ArrayList<Integer>> map1;
  static  HashMap<int[], Integer> map2;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] u = new int[n - 1];
    int[] v = new int[n - 1];
    int[] w = new int[n - 1];
    map1 = new HashMap<Integer, ArrayList<Integer>>();
    map2 = new HashMap<int[], Integer>();
    c = new int[n];
    d = new int[n];
    for(int i = 0; i < n - 1; i++) {
      u[i] = sc.nextInt() - 1;
      v[i] = sc.nextInt() - 1;
      w[i] = sc.nextInt();
      if(map1.containsKey(u[i])) {
        ArrayList<Integer> list = map1.get(u[i]);
        list.add(v[i]);
        map1.put(u[i], list);
      } else {
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(v[i]);
        map1.put(u[i], list);
      }
      
      if(map1.containsKey(v[i])) {
        ArrayList<Integer> list = map1.get(v[i]);
        list.add(u[i]);
        map1.put(v[i], list);
      } else {
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(u[i]);
        map1.put(v[i], list);
      }

      int[] s1 = {u[i], v[i]};
      int[] s2 = {v[i], u[i]};
      map2.put(s1, w[i]);
      map2.put(s2, w[i]);
    }

    c[0] = 0;
    d[0] = 1;
    
    dfs(0);
    for(int i = 0; i < n; i++) {
      System.out.println(c[i]);
    }
  }

  public void dfs(int g) {
    ArrayList<Integer> list1 = map1.get(g);
    for(int i = 0; i < list1.size(); i++) {
      int f = list1.get(i);
      if(d[f] == 0) {
        d[f] = 1;
        int[] a = {g, f};
        int b = map2.get(a);
        if(b % 2 == 0) {
          c[f] = c[g];
        } else {
          c[f] = 1 - c[g];
        }
        dfs(f);
      }
    }
  }
}

Compiler output:
Main.java:52: error: non-static method dfs(int) cannot be referenced from a static context
    dfs(0);
    ^
1 error
Language: Java

import java.util.*;

public class Main {
  public int P = 1;
  public static int[] c;
  public static int[] d;
  static  HashMap<Integer, ArrayList<Integer>> map1;
  static  HashMap<int[], Integer> map2;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] u = new int[n - 1];
    int[] v = new int[n - 1];
    int[] w = new int[n - 1];
    map1 = new HashMap<Integer, ArrayList<Integer>>();
    map2 = new HashMap<int[], Integer>();
    c = new int[n];
    d = new int[n];
    for(int i = 0; i < n - 1; i++) {
      u[i] = sc.nextInt() - 1;
      v[i] = sc.nextInt() - 1;
      w[i] = sc.nextInt();
      if(map1.containsKey(u[i])) {
        ArrayList<Integer> list = map1.get(u[i]);
        list.add(v[i]);
        map1.put(u[i], list);
      } else {
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(v[i]);
        map1.put(u[i], list);
      }
      
      if(map1.containsKey(v[i])) {
        ArrayList<Integer> list = map1.get(v[i]);
        list.add(u[i]);
        map1.put(v[i], list);
      } else {
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(u[i]);
        map1.put(v[i], list);
      }

      int[] s1 = {u[i], v[i]};
      int[] s2 = {v[i], u[i]};
      map2.put(s1, w[i]);
      map2.put(s2, w[i]);
    }

    c[0] = 0;
    d[0] = 1;
    
    dfs(0);
    for(int i = 0; i < n; i++) {
      System.out.println(c[i]);
    }
  }

  public void dfs(int g) {
    ArrayList<Integer> list1 = map1.get(g);
    for(int i = 0; i < list1.size(); i++) {
      int f = list1.get(i);
      if(d[f] == 0) {
        d[f] = 1;
        int[][] a = {g, f};
        int b = map2.get(a);
        if(b % 2 == 0) {
          c[f] = c[g];
        } else {
          c[f] = 1 - c[g];
        }
        dfs(f);
      }
    }
  }
}

Compiler output:
Main.java:52: error: non-static method dfs(int) cannot be referenced from a static context
    dfs(0);
    ^
Main.java:64: error: incompatible types: int cannot be converted to int[]
        int[][] a = {g, f};
                     ^
Main.java:64: error: incompatible types: int cannot be converted to int[]
        int[][] a = {g, f};
                        ^
3 errors