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

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

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

    vector<pair<int,ll>> g(N);
    for (int i=0; i<N-1; ++i)  {
        int a, b;
        cin >> a >> b >> c;
        --a; --b;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    vector<int> dist(N,-1);
    queue<int> que;

    dist[0]=0;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(auto nv : G[v]) {
            if()
            if(nv.second%2==0) dist[nv.first]=dist[v];
            else if(nv.second%2==1 && dist[v]==0) dist[nv.first]=1;
            else dist[nv.first]=0;
            que.push(nv.first);
        }
    }
    for(int v=0; v<N; ++v) cout << dist[v] << "\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:26: error: 'c' was not declared in this scope
   18 |         cin >> a >> b >> c;
      |                          ^
a.cc:20:9: error: 'G' was not declared in this scope
   20 |         G[a].push_back({b,c});
      |         ^
a.cc:32:23: error: 'G' was not declared in this scope
   32 |         for(auto nv : G[v]) {
      |                       ^
a.cc:33:16: error: expected primary-expression before ')' token
   33 |             if()
      |                ^
Language: C++

#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<P>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
 
 vector<bool> seen ;
  int dist[100005] ;
 void dfs(const Graph G,int v){
  seen[v]=true ;
  for(auto u :G[v]){
    if(seen[u.first]) continue ;
    dist[u.first] = u.second-dist[v] ;
    dfs(G,u.first) ;
 }
 }
int main(){
   int n ;cin>>n ;
  Graph G(n) ;
  rep(i,n-1){
    int a,b ;ll c ;
    cin>>a>>b>>c ;
    a--; b--;
    int d=0 ;
    if(c%2!=0) d++ ;
    G[a].pb(mpa(b,d)) ;
    G[b].pb(mpa(a,d)) ;
  }
  dist[0]=0 ;
  seen.assign(n,false) ;
  dfs(G,0) ;
  rep(i,n){
  cout<<dist[i]<<endl;
  return 0;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:48:4: error: expected '}' at end of input
   48 |   }
      |    ^
a.cc:30:11: note: to match this '{'
   30 | int main(){
      |           ^
Language: C++

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

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

int n;
G g;
vector<int> ans(n);

void dfs(int v, int p, int c) {
  ans[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;
  rep(i,n-1) {
    int u, v;
    ll w;
    cin >> u >> v >> w;
    u--; v--;
    g[u].push_back(pair<int,ll>(v,w));
    g[v].push_back(pair<int,ll>(u,w));
  }
  ans.assign(n,0);
  dfs(0, -1, 0);

  for (auto d : ans) cout << d << endl;

  return 0;
}


Compiler output:
a.cc:14:1: error: 'G' does not name a type
   14 | G g;
      | ^
a.cc: In function 'void dfs(int, int, int)':
a.cc:19:17: error: 'g' was not declared in this scope
   19 |   for (auto e : g[v]) {
      |                 ^
a.cc: In function 'int main()':
a.cc:33:5: error: 'g' was not declared in this scope
   33 |     g[u].push_back(pair<int,ll>(v,w));
      |     ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int ans[100002];
vector<pair<int,int> >adj[100002];

void DFS(int x,int y,int cost)
{
    if(ans[y] != -1)return;
    if(x == 0)ans[y]=0;
    else ans[y]=(ans[x]+cost)%2;
    for(PII z : adj[y])DFS(y,z.first,z.second);
}

int main()
{
    FAST();
    int i,n,x,y,z;
    cin >> n;
    ans[1]=-1;
    for(i=2;i<=n;i++)
    {
        ans[i]=-1;
        cin >> x >> y >> z;
        z%=2;
        adj[x].emplace_back(y,z);
        adj[y].emplace_back(x,z);
    }
    DFS(0,1,1);
    for(i=1;i<=n;i++)cout << ans[i] << '\n';
    return 0;
}


Compiler output:
a.cc: In function 'void DFS(int, int, int)':
a.cc:15:9: error: 'PII' was not declared in this scope
   15 |     for(PII z : adj[y])DFS(y,z.first,z.second);
      |         ^~~
a.cc:16:1: error: expected primary-expression before '}' token
   16 | }
      | ^
a.cc:15:48: error: expected ';' before '}' token
   15 |     for(PII z : adj[y])DFS(y,z.first,z.second);
      |                                                ^
      |                                                ;
   16 | }
      | ~                                               
a.cc:16:1: error: expected primary-expression before '}' token
   16 | }
      | ^
a.cc:15:48: error: expected ')' before '}' token
   15 |     for(PII z : adj[y])DFS(y,z.first,z.second);
      |        ~                                       ^
      |                                                )
   16 | }
      | ~                                               
a.cc:16:1: error: expected primary-expression before '}' token
   16 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using Edge = pair<ll,ll>;
using Graph =vector<vector<Edge>>;
vector<int> color;
Graph G;
ll N;
void dfs(ll v,ll o=-1,ll c=0){
for(auto u:G[v]){
  if(u.first==o)continue;
  if(i.second%2!=0)c=1-c;
  dfs(i.first,v,c);
  
}
}
int main() {
cin>>N;
G.resize(N);
rep(i,N-1){
  ll a,d,c;
  cin>>a>>d>>c;
  --a;
  --d;
  G[a].push_back(Edge(d,c));
  G[d].push_back(Edge(a,c));
}
color.resize(N,-1);
color[0]=0;
dfs(0);
rep(i,N)cout<<color[i]<<endl;
return 0;
}


Compiler output:
a.cc: In function 'void dfs(ll, ll, ll)':
a.cc:14:6: error: 'i' was not declared in this scope
   14 |   if(i.second%2!=0)c=1-c;
      |      ^
a.cc:15:7: error: 'i' was not declared in this scope
   15 |   dfs(i.first,v,c);
      |       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=1; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using Edge = pair<int,int>;
using Graph =vector<vector<Edge>>;
vector<int> color;
Graph G;
void dfs(int v, int p, int c) {
    color[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() {
int N;
cin>>N;
Graph G(N+1);
rep(i,N){
  int a,d,c;
  cin>>a>>d>>c;
  G[a].push_back(Edge(d,c));
  G[d].push_back(Edge(a,c));
}
color.assign(N+1,-1);
dfs(1,G);
rep(i,N+1)cout<<color[i]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:7: error: cannot convert 'Graph' {aka 'std::vector<std::vector<std::pair<int, int> > >'} to 'int'
   29 | dfs(1,G);
      |       ^
      |       |
      |       Graph {aka std::vector<std::vector<std::pair<int, int> > >}
a.cc:10:21: note:   initializing argument 2 of 'void dfs(int, int, int)'
   10 | void dfs(int v, int p, int c) {
      |                 ~~~~^
Language: C++

#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#include <map>
#include <cmath>
#include <cctype>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;
vector<vector<pair<int,int>>> z(100010);
int ans[100010];
bool used[100010];
void dfs(int v, int w){
    if(w%2==0){
        ans[v]=1;
    }else{
        ans[v]=0;
    }
    for(auto t;z[v]){
        if(!used[i.first]){
            used[i.first]=true;
            dfs(i.first,i.second+w);
        }
    }
}

int main()
{
    int N,i;
    cin >> N;
    vector<int> x(N); 
    rep(i,N){
        int u,v,w;
        cin >> u >> v >> w;
        u--;
        v--;
        z[u].push_back(make_pair(v,w));
        z[v].push_back(make_pair(u,w));
    }
    bool T=true;
    T=samestring(s, t);
    if(s==t){
        cout << "same" << endl;
    }else{
        if(T){
            cout << "case-insensitive" << endl;
        }else{
            cout << "different" << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:28:9: error: declaration of 'auto t' has no initializer
   28 |     for(auto t;z[v]){
      |         ^~~~
a.cc:28:19: error: could not convert 'z.std::vector<std::vector<std::pair<int, int> > >::operator[](((std::vector<std::vector<std::pair<int, int> > >::size_type)v))' from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<int, int> > >, std::vector<std::pair<int, int> > >::value_type' {aka 'std::vector<std::pair<int, int> >'} to 'bool'
   28 |     for(auto t;z[v]){
      |                   ^
      |                   |
      |                   __gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<int, int> > >, std::vector<std::pair<int, int> > >::value_type {aka std::vector<std::pair<int, int> >}
a.cc:28:20: error: expected ';' before ')' token
   28 |     for(auto t;z[v]){
      |                    ^
      |                    ;
a.cc:29:18: error: 'i' was not declared in this scope
   29 |         if(!used[i.first]){
      |                  ^
a.cc: In function 'int main()':
a.cc:50:18: error: 's' was not declared in this scope
   50 |     T=samestring(s, t);
      |                  ^
a.cc:50:21: error: 't' was not declared in this scope
   50 |     T=samestring(s, t);
      |                     ^
a.cc:50:7: error: 'samestring' was not declared in this scope
   50 |     T=samestring(s, t);
      |       ^~~~~~~~~~
Language: C++

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

int main() {
    int n;cin>>n;
    vector<pair<int,int>> a[n];
    for (int i=0;i<n-1;i++) {
        int b,c,d;cin>>b>>c>>d;
        a[b-1].push_back({c-1,d});
        a[c-1].push_back({b-1,d});
    }
    ll dist[n]{};
    int vis[n]{};
    queue<int> q;
    q.push(0);
    while (q.size()) {
        int v=q.front();q.pop();
        vis[v]=1;
        for (auto p:a[v])
            if (!vis[p.first]) {
                dist[p.first]=dist[v]+p.second;
                q.push(p.first);
            }
    }
    for (inti i=0;i<n;i++)
        cout<<dist[i]%2<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:10: error: 'inti' was not declared in this scope; did you mean 'int'?
   26 |     for (inti i=0;i<n;i++)
      |          ^~~~
      |          int
a.cc:26:19: error: 'i' was not declared in this scope
   26 |     for (inti i=0;i<n;i++)
      |                   ^
Language: C++

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

int main() {
    int n;cin>>n;
    vector<pair<int,int,>> a[n];
    for (int i=0;i<n-1;i++) {
        int b,c,d;cin>>b>>c>>d;
        a[b-1].push_back({c-1,d});
        a[c-1].push_back({b-1,d});
    }
    ll dist[n]{};
    int vis[n]{};
    queue<int> q;
    q.push(0);
    while (q.size()) {
        int v=q.front();q.pop();
        vis[v]=1;
        for (auto p:a[v])
            if (!vis[p.first]) {
                dist[p.first]=dist[v]+p.second;
                q.push(p.first);
            }
    }
    for (inti i=0;i<n;i++)
        cout<<dist[i]%2<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:24: error: wrong number of template arguments (3, should be 2)
    7 |     vector<pair<int,int,>> a[n];
      |                        ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
   89 |     struct pair;
      |            ^~~~
a.cc:7:25: error: template argument 1 is invalid
    7 |     vector<pair<int,int,>> a[n];
      |                         ^~
a.cc:7:25: error: template argument 2 is invalid
a.cc:10:16: error: request for member 'push_back' in 'a[(b - 1)]', which is of non-class type 'int'
   10 |         a[b-1].push_back({c-1,d});
      |                ^~~~~~~~~
a.cc:11:16: error: request for member 'push_back' in 'a[(c - 1)]', which is of non-class type 'int'
   11 |         a[c-1].push_back({b-1,d});
      |                ^~~~~~~~~
a.cc:20:24: error: 'begin' was not declared in this scope
   20 |         for (auto p:a[v])
      |                        ^
a.cc:20:24: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:20:24: error: 'end' was not declared in this scope
   20 |         for (auto p:a[v])
      |                        ^
a.cc:20:24: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:26:10: error: 'inti' was not declared in this scope; did you mean 'int'?
   26 |     for (inti i=0;i<n;i++)
      |          ^~~~
      |          int
a.cc:26:19: error: 'i' was not declared in this scope
   26 |     for (inti i=0;i<n;i++)
      |                   ^
Language: C++

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int N;
vector<pair<int, ll>> tree[100005];
int color[100005];

void dfs(int v, int from, ll dist) {
	color[v] = dist % 2;
	for (auto p : tree[v]) {
		if (p.first == from) continue;
		dfs(p.first, v, dist + p.second);
	}
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> N;
    tree.assign(N + 3, vector<pair<int, ll>>());
    REP(i, N - 1) {
    	ll x, y, w;
    	cin >> x >> y >> w;
    	tree[x].push_back({y, w});
    	tree[y].push_back({x, w});
    }
    dfs(1, 0, 0);
    FOR(i, 1, N) {
    	cout << color[i] << "\n";
    }
    

}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:10: error: request for member 'assign' in 'tree', which is of non-class type 'std::vector<std::pair<int, long int> > [100005]'
   45 |     tree.assign(N + 3, vector<pair<int, ll>>());
      |          ^~~~~~
Language: C++

#include<bits/stdc++.h>
#include<queue>
using namespace std;
vector<queue<int>>tree;
vector<queue<int>>wi;
vector<int>cl;
vector<int>si;
void dfs(int x, int c) {
  cl[x] = c;
  for (int i = 0; i < si[x]; i ++) {
    int u = tree[x].front();
    tree[x].pop();
    tree[x].push(u);
    int w = wi[x].front();
    wi[x].pop();
    wi[x].push(w);
    if (cl[u] != -1) continue;
    int d = (c + w) % 2;
    dfs(u, d);
  }
}
int main () {
  int N;
  cin >> N;
  tree.resuze(N);
  wi.resize(N);
  cl.assign(N, -1);
  si.assign(N, 0);
  for (int i = 0; i < N - 1; i ++) {
    int a, b, w;
    cin >> a >> b >> w;
    a --;
    b --;
    tree[a].push(b);
    tree[b].push(a);
    w %= 2;
    wi[a].push(w);
    wi[b].push(w);
    si[a] ++;
    si[b] ++;
  }
  dfs(0, 0);
  for (int i = 0; i < N; i ++) cout << cl[i] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:8: error: 'class std::vector<std::queue<int> >' has no member named 'resuze'; did you mean 'resize'?
   25 |   tree.resuze(N);
      |        ^~~~~~
      |        resize
Language: C++

#include<bits/stdc++.h>
#include<queue>
vector<queue<int>>tree;
vector<queue<int>>wi;
vector<int>cl;
vector<int>si;
void dfs(int x, int c) {
  cl[x] = c;
  for (int i = 0; i < si[x]; i ++) {
    int u = tree[x].front();
    tree[x].pop();
    tree[x].push(u);
    int w = wi[x].front();
    wi[x].pop();
    wi[x].push(w);
    if (cl[u] != -1) continue;
    int d = (c + w) % 2;
    dfs(u, d);
  }
}
using namespace std;
int main () {
  int N;
  cin >> N;
  tree.resuze(N);
  wi.resize(N);
  cl.assign(N, -1);
  si.assign(N, 0);
  for (int i = 0; i < N - 1; i ++) {
    int a, b, w;
    cin >> a >> b >> w;
    a --;
    b --;
    tree[a].push(b);
    tree[b].push(a);
    w %= 2;
    wi[a].push(w);
    wi[b].push(w);
    si[a] ++;
    si[b] ++;
  }
  dfs(0, 0);
  for (int i = 0; i < N; i ++) cout << cl[i] << endl;
}

Compiler output:
a.cc:3:1: error: 'vector' does not name a type
    3 | vector<queue<int>>tree;
      | ^~~~~~
a.cc:4:1: error: 'vector' does not name a type
    4 | vector<queue<int>>wi;
      | ^~~~~~
a.cc:5:1: error: 'vector' does not name a type
    5 | vector<int>cl;
      | ^~~~~~
a.cc:6:1: error: 'vector' does not name a type
    6 | vector<int>si;
      | ^~~~~~
a.cc: In function 'void dfs(int, int)':
a.cc:8:3: error: 'cl' was not declared in this scope; did you mean 'c'?
    8 |   cl[x] = c;
      |   ^~
      |   c
a.cc:9:23: error: 'si' was not declared in this scope; did you mean 'i'?
    9 |   for (int i = 0; i < si[x]; i ++) {
      |                       ^~
      |                       i
a.cc:10:13: error: 'tree' was not declared in this scope; did you mean 'free'?
   10 |     int u = tree[x].front();
      |             ^~~~
      |             free
a.cc:13:13: error: 'wi' was not declared in this scope; did you mean 'w'?
   13 |     int w = wi[x].front();
      |             ^~
      |             w
a.cc: In function 'int main()':
a.cc:25:3: error: 'tree' was not declared in this scope; did you mean 'free'?
   25 |   tree.resuze(N);
      |   ^~~~
      |   free
a.cc:26:3: error: 'wi' was not declared in this scope
   26 |   wi.resize(N);
      |   ^~
a.cc:27:3: error: 'cl' was not declared in this scope
   27 |   cl.assign(N, -1);
      |   ^~
a.cc:28:3: error: 'si' was not declared in this scope; did you mean 'sin'?
   28 |   si.assign(N, 0);
      |   ^~
      |   sin
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
using namespace std;
using LL = long long;
using Edge = pair<LL,LL>;

LL N;
vector<bool> seen(N);
vector<vector<Edge>> G(N);
vector<LL> color(N);
void dfs(LL v)
{
	seen[v] = true;
	for(auto e: G[v])
	{
		if(seen[e.first] == true) continue;
		if(e.second % 2 == 0)
		{
			color[e.first] = color[v];
			dfs(e.first);
		}
		else if(e.second % 2 == 1)
		{
			color[e.first] = 1 - color[v];
			dfs(e.first);
		}
	}
}
int main()
{
	cin >> N;
	LL i;
	for(i = 0;i < N-1;i++)
	{
		LL tmpv1,tmpv2,tmpweight;
		cin >> tmpv1 >> tmpv2 >> tmpweight;
		tmpv1--; tmpv2--;
		G[tmpv1].push_back({tmpv2,tmpweight});
		G[tmpv2].push_back({tmpv1,tmpweight});
	}
	seen.assign(N,false);
	color[0] = 0;
	dfs(0)
	for(i = 0;i < N;i++)
	{
		cout << color[i] << endl;
	}
	return 0;
}
	


Compiler output:
a.cc: In function 'int main()':
a.cc:47:15: error: expected ';' before 'for'
   47 |         dfs(0)
      |               ^
      |               ;
   48 |         for(i = 0;i < N;i++)
      |         ~~~    
a.cc:48:28: error: expected ';' before ')' token
   48 |         for(i = 0;i < N;i++)
      |                            ^
      |                            ;
Language: C++

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using edge=pair<int ,llint>
using Graph=vector<vector<edge>>;

llint n;
Graph G;
vectot<llint>dir;

void dfs(int v,int p,int cur){
	color[v]=cur;
	for(auto e:G[v]){
		if(e.first==p)continue;
		if(e.secound & 1)dfs(e.first-1,v,1-cur);//長さが奇数
		else dfs(e.first,v,cur);
	}
}

void solve(){
	cin >> n;
	G.assign(N, vector<edge>());
	for(int i=0;i<n-1;i++){
		llint a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		G[a].push_back(edge(b,c));
		G[b].push_back(edge(a,c));

	}
	dir.assign(n,0);
	dfs(0,-1,1);
	for(auto d:dir)cout << d << endl;
}

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


Compiler output:
a.cc:13:28: error: expected ';' before 'using'
   13 | using edge=pair<int ,llint>
      |                            ^
      |                            ;
   14 | using Graph=vector<vector<edge>>;
      | ~~~~~                       
a.cc:17:1: error: 'Graph' does not name a type
   17 | Graph G;
      | ^~~~~
a.cc:18:1: error: 'vectot' does not name a type
   18 | vectot<llint>dir;
      | ^~~~~~
a.cc: In function 'void dfs(int, int, int)':
a.cc:21:9: error: 'color' was not declared in this scope
   21 |         color[v]=cur;
      |         ^~~~~
a.cc:22:20: error: 'G' was not declared in this scope
   22 |         for(auto e:G[v]){
      |                    ^
a.cc: In function 'void solve()':
a.cc:31:9: error: 'G' was not declared in this scope
   31 |         G.assign(N, vector<edge>());
      |         ^
a.cc:31:18: error: 'N' was not declared in this scope
   31 |         G.assign(N, vector<edge>());
      |                  ^
a.cc:31:28: error: 'edge' was not declared in this scope
   31 |         G.assign(N, vector<edge>());
      |                            ^~~~
a.cc:31:32: error: template argument 1 is invalid
   31 |         G.assign(N, vector<edge>());
      |                                ^
a.cc:31:32: error: template argument 2 is invalid
a.cc:40:9: error: 'dir' was not declared in this scope; did you mean 'div'?
   40 |         dir.assign(n,0);
      |         ^~~
      |         div
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int N;
int tree[100000][100000];
int color[100000];

int dfs(int n){
    REP(i,N){
        if(tree[n][i] > 0 and color[i] == -1){
            color[i] = tree[n][i]%2?(1^color[n]):color[n];
            dfs(i);
        }
    }
    return 0;
}

int main(void){
    cin >> N;
    REP(i,N) color[i] = -1;
    int u,v,w;
    REP(i,N-1){
        cin >> u >> v >> w;
        tree[u-1][v-1] = w;
        tree[v-1][u-1] = w;
    }
    color[0] = 0;
    dfs(0);
    REP(i,N) cout << color[i] << endl;

    return 0;
}



Compiler output:
/tmp/cckpfRQm.o: in function `dfs(int)':
a.cc:(.text+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cckpfRQm.o
a.cc:(.text+0x9e): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cckpfRQm.o
a.cc:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cckpfRQm.o
/tmp/cckpfRQm.o: in function `main':
a.cc:(.text+0x11c): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cckpfRQm.o
a.cc:(.text+0x1f6): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cckpfRQm.o
a.cc:(.text+0x221): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/cckpfRQm.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<vector>

using namespace std;

vector<vector<int>>node;
int main() {
  int n[5] = {1,1,1,1,1}
  for(int s:n)cout << s << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: expected ',' or ';' before 'for'
    9 |   for(int s:n)cout << s << endl;
      |   ^~~
Language: C++

#include<iostream>
#include<vector>

using namespace std;

vector<vector<int>>node;
int main() {
  int n[5] = {1,0,1,0,1}
  for(int s:n)cout << s << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: expected ',' or ';' before 'for'
    9 |   for(int s:n)cout << s << endl;
      |   ^~~
Language: C++

from collections import deque

n=int(input())
d=[[-1 for j in range(n)] for i in range(n)]
g=[[] for i in range(n)]
color=[-1 for i in range(n)]
color[0]=0
for i in range(n):
  d[i][i]=0

for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  d[u][v]=w
  d[v][u]=w
  g[u].append(v)
  g[v].append(u)

que=deque([0])

while que:
  now=que.popleft()
  for i in g[now]:
    if color[i]!=-1:
      continue
    if d[now][i]%2==0:
      color[i]=0
    else:
      color[i]=1
    que.append(i)

for i in range(n):
  print(color[i])

Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
Language: C++

N, M = map(int, input().split())
V = [[] for _ in range(N)]
visited = [False for _ in range(N)]
ans = 0

for _ in range(M):
	x, y, z = map(int, input().split())
	V[x - 1].append(y - 1)
	V[y - 1].append(x - 1)
	
for i in range(N):
	if V[i] == []:
		visited[i] = True
		ans += 1
	
def dfs(cur):
	visited[cur] = True
	for adj in V[cur]:
		if visited[adj]: continue
		dfs(adj)
	
while not all(visited):
	cur = visited.index(False)
	visited[cur] = True
	dfs(cur)
	ans += 1
	
print(ans)


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N, M = map(int, input().split())
      | ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Edge = pair<ll, ll>;
using Graph = vector<vector<Edge>>;

// 白0 黒1
vector<int> color;
void dfs(Graph G, int v, int c) {
    color[v] = c;
    for (Edge next_v : G[v]) {
        if (next_v.second % 2 == 0) {
            dfs(G, next_v.first, c);
        }
        else {
            dfs(G, next_v.first, 1 - c);
        }
    }
}

int main() {
    // 頂点数
    int N; cin >> N;

    // グラフ
    Graph G(N);
    for (int i = 0; i < N - 1; i++) {
        ll from, to, weight;
        cin >> from >> to >> weight;
        from--; to--;
        G[from].push_back(make_pair(to, weight));
        G[to].push_back(make_pair(from, weight));
    }
    
    color.assign(N);
    color[0] = 0;
    dfs(G, 0, 0);
    for (int i = 0; i < N; i++) {
        cout << color[i] << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:17: error: no matching function for call to 'std::vector<int>::assign(int&)'
   36 |     color.assign(N);
      |     ~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:828:9: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Alloc = std::allocator<int>]'
  828 |         assign(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:828:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:808:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int; value_type = int]'
  808 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:808:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:855:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  855 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:855:43: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
  855 |       assign(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
Language: C

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#define INF 1e16
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;
typedef pair<long long, int> P;

int main() {
    int N;
    cin >> N;
    vector<vector<pair<int, long long>>> Graph(N);
    rep(i, N - 1) {
        int u, v;
        long long w;
        cin >> u >> v >> w;
        Graph[u - 1].push_back(make_pair(v - 1, w));
        Graph[v - 1].push_back(make_pair(u - 1, w));
    }
    
    vector<long long> dist(N, INF);
    vector<bool> used(N, false);
    priority_queue<P, vector<P>, greater<P>> pq;
    dist[0] = 0;
    pq.push(make_pair(0LL, 0));
    while (pq.size() > 0) {
        int ver = pq.top().second;
        long long cost = pq.top().first;
        pq.pop();
        if (used[ver]) continue;
        for (auto x : Graph[ver]) {
            int v = x.first;
            long long alt = cost + x.second;
            if (alt < dist[v]) {
                dist[v] = alt;
                pq.push(make_pair(alt, v));
            }
        }
        used[ver] = true;
    }
    
    rep(i, N) cout << dist[i] % 2 << endl;
    return 0;
}


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

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n;
  scanf("%d%", &n);
  vector<vector<pii>> g(n); v1i f(n);
  rep(i, n){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c); --a; --b;
    g[a].push_back({b, c});
    g[b].push_back({a, c});
  }
  deque<int> d;
  d.push_back(0);
  int tmp = 0;
  v1b e(n, 1); e[0] = 0;
  while(!d.empty()){
    d.pop_front();
    for(auto h: v[tmp]){
      if(e[h.fi]){
        e[h.fi] = 0;
        d.push_back(h.fi);
        f[h.fi] = f[tmp] + h.se;
      }
    }
    tmp = d.front();
  }
  rep(i, n){
    if(f[i] & 0) printf("0\n");
    else printf("0\n");
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:17: error: 'v' was not declared in this scope
   46 |     for(auto h: v[tmp]){
      |                 ^
Language: C++

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

void srch(vector<int> &ans, vector<vector<pair<int, int>>> &cnct, int a){
  if(cnct.at(a).size() == 0){
    return;
  }
  
  pair<int, int> num = cnct.at(a).at(cnct.at(a).size() - 1);
  if(num.second % 2 == 1){
    if(ans.at(a) == 0){
      ans.at(num.first) = 1;
    }else{
      ans.at(num.first) = 0;
    }
  }else{
    if(ans.at(a) == 0){
      ans.at(num.first) = 0;
    }else{
      ans.at(num.first) = 1;
    }
  }
  cnct.at(a).pop_back();
  srch(ans, cnct, a);
}

int main(){
  int N;
  cin >> N;
  
  vector<vector<int>> dot(N, vector<int>(3));
  vector<int> ans(N, 2);
  for(int i = 0; i < N; i++){
    cin >> dot.at(i).at(0) >> dot.at(i).at(1) >> dot.at(i).at(2);
    dot.at(i).at(0)--;
    dot.at(i).at(1)--;
  }
  
  vector<vector<pair<int, int>>> cnct(N);
  for(int i = 0; i < N; i++){
    cnct.at(dot.at(i).at(0)).push_back(make_pair(dot.at(i).at(1), dot.at(i).at(2)));
    cnct.at(dot.at(i).at(1)).push_back(make_pair(dot.at(i).at(0), dot.at(i).at(2)));
  }
  
  ans.at(0) = 0;
  srch(ans, cnct, 0);
  
  for(int i = 0; i < N; i++){
    cout << ans.at(i) << endl;
  }
}

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

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


using Graph = vector<vector<int>>;
using vi vector<int>;
using length vector<vi>;

// 二部グラフ判定
vector<int> color;
void dfs(const Graph &G, const length &L, int v, int cur = 0) {
    color[v] = cur;
    for (auto next_v : G[v]) {
        if(color[next_v] != -1) continue;
        if(L.at(v).at(next_v) % 2 == 0){
           dfs(G, L, next_v, cur);
        }
        else{
           dfs(G, L, next_v, 1 - cur);
        }
    }
    return;
}

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

  Graph G(N);
  length L(N, vi(N));
  
  for (int i = 0; i < N-1; ++i) {
      int a, b;
      cin >> a >> b;
      G.at(a-1).push_back(b-1);
      G.at(b-1).push_back(a-1);
      int w;
      cin >> w;
      L.at(a-1).at(b-1) = w;
      L.at(b-1).at(a-1) = w;
  }
  
  color.assign(N, -1);
  dfs(G, L, 0, 0);
  for(int i = 0; i < N; i++){
    cout << color.at(i) << endl;
  }
  
}


Compiler output:
a.cc:6:7: error: expected nested-name-specifier before 'vi'
    6 | using vi vector<int>;
      |       ^~
a.cc:7:7: error: expected nested-name-specifier before 'length'
    7 | using length vector<vi>;
      |       ^~~~~~
a.cc:11:32: error: 'length' does not name a type
   11 | void dfs(const Graph &G, const length &L, int v, int cur = 0) {
      |                                ^~~~~~
a.cc: In function 'void dfs(const Graph&, const int&, int, int)':
a.cc:15:14: error: request for member 'at' in 'L', which is of non-class type 'const int'
   15 |         if(L.at(v).at(next_v) % 2 == 0){
      |              ^~
a.cc: In function 'int main()':
a.cc:30:3: error: 'length' was not declared in this scope
   30 |   length L(N, vi(N));
      |   ^~~~~~
a.cc:39:7: error: 'L' was not declared in this scope
   39 |       L.at(a-1).at(b-1) = w;
      |       ^
a.cc:44:10: error: 'L' was not declared in this scope
   44 |   dfs(G, L, 0, 0);
      |          ^
Language: C++

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


using Graph = vector<vector<int>>;
using length = vector<vector<int>>;

// 二部グラフ判定
vector<int> color;
void dfs(const Graph &G, const length &L, int v, int cur = 0) {
    color[v] = cur;
    for (auto next_v : G[v]) {
        if(color[next_v] != -1) continue;
        if(length.at(v).at(next_v) % 2 == 0){
           dfs(G, L, next_v, cur);
        }
        else{
           dfs(G, L, next_v, 1 - cur);
        }
    }
    return;
}

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

  Graph G(N);
  length L(N);
  
  for (int i = 0; i < N-1; ++i) {
      int a, b;
      cin >> a >> b;
      G.at(a-1).push_back(b-1);
      G.at(b-1).push_back(a-1);
      int w;
      cin >> w;
      length.at(a-1).at(b-1) = w;
      length.at(b-1).at(a-1) = w;
  }
  
  color.assign(N, -1);
  dfs(G, L, 0, 0);
  for(int i = 0; i < N; i++){
    cout << color.at(i) << endl;
  }
  
}


Compiler output:
a.cc: In function 'void dfs(const Graph&, const length&, int, int)':
a.cc:14:18: error: expected unqualified-id before '.' token
   14 |         if(length.at(v).at(next_v) % 2 == 0){
      |                  ^
a.cc: In function 'int main()':
a.cc:38:13: error: expected unqualified-id before '.' token
   38 |       length.at(a-1).at(b-1) = w;
      |             ^
a.cc:39:13: error: expected unqualified-id before '.' token
   39 |       length.at(b-1).at(a-1) = w;
      |             ^
Language: C++

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

using vi = vector<int>;
using vvi = vector<vi>;

vvi vec(100001, vi(3));

// 二部グラフ判定
vector<int> color;
void dfs(const Graph &G, const length &L, int v, int cur = 0) {
    color[v] = cur;
    for (auto next_v : G[v]) {
        if(color[next_v] != -1) continue;
        if(length.at(v).at(next_v) % 2 == 0){
           dfs(G, L, next_v, cur);
        }
        else{
           dfs(G, L, next_v, 1 - cur);
        }
    }
    return;
}

int main(){
  int N;
  cin >> N;
  
  //グラフ
  using Graph = vector<vector<int>>;
  using length = vector<vector<int>>;

  Graph G(N);
  length L(N);
  
  for (int i = 0; i < N-1; ++i) {
      int a, b;
      cin >> a >> b;
      G.at(a-1).push_back(b-1);
      G.at(b-1).push_back(a-1);
      int w;
      cin >> w;
      length.at(a-1).at(b-1) = w;
      length.at(b-1).at(a-1) = w;
  }
  
  color.assign(N, -1);
  dfs(G, L, 0, 0);
  for(int i = 0; i < N; i++){
    cout << color.at(i) << endl;
  }
  
}

Compiler output:
a.cc:11:16: error: 'Graph' does not name a type
   11 | void dfs(const Graph &G, const length &L, int v, int cur = 0) {
      |                ^~~~~
a.cc:11:32: error: 'length' does not name a type
   11 | void dfs(const Graph &G, const length &L, int v, int cur = 0) {
      |                                ^~~~~~
a.cc: In function 'void dfs(const int&, const int&, int, int)':
a.cc:13:25: error: invalid types 'const int[int]' for array subscript
   13 |     for (auto next_v : G[v]) {
      |                         ^
a.cc:15:12: error: 'length' was not declared in this scope
   15 |         if(length.at(v).at(next_v) % 2 == 0){
      |            ^~~~~~
a.cc: In function 'int main()':
a.cc:43:13: error: expected unqualified-id before '.' token
   43 |       length.at(a-1).at(b-1) = w;
      |             ^
a.cc:44:13: error: expected unqualified-id before '.' token
   44 |       length.at(b-1).at(a-1) = w;
      |             ^
a.cc:48:7: error: invalid initialization of reference of type 'const int&' from expression of type 'Graph' {aka 'std::vector<std::vector<int> >'}
   48 |   dfs(G, L, 0, 0);
      |       ^
a.cc:11:23: note: in passing argument 1 of 'void dfs(const int&, const int&, int, int)'
   11 | void dfs(const Graph &G, const length &L, int v, int cur = 0) {
      |          ~~~~~~~~~~~~~^
Language: C++

#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep(i,s,n)for(ll i = s;i<n;i++)
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<vector<int>> VVi;
ll MOD = 1e9 + 7;

ll c[100001] = {};
ll v[100001] = {};
ll d[100001] = {};
vector<vector<pair<ll, ll>>> V;

void dfs(ll id,ll dis) {
    c[id] = dis;
    v[id] = true;

    for (auto p : V[id]) {
        if (!v[p.first]) {
            dfs(p.first, dis + p.second);
        }
    }
}

int main()
{
    ll n; cin >> n;
    V.resize(n+1);

    rep(i, 0, n - 1) {
        ll u, v, w; cin >> u >> v >> w;
        V[u].push_back({ v,w });
        V[v].push_back({ u,w });
    }

    dfs(1,0);

    repe(i, 1, n) {
        cout << (c[i] & 1) << endl;
    }

    return 0;
}

Compiler output:
a.cc:6:9: error: 'vector' does not name a type
    6 | typedef vector<int> Vi;
      |         ^~~~~~
a.cc:7:9: error: 'vector' does not name a type
    7 | typedef vector<vector<int>> VVi;
      |         ^~~~~~
a.cc:13:1: error: 'vector' does not name a type
   13 | vector<vector<pair<ll, ll>>> V;
      | ^~~~~~
a.cc: In function 'void dfs(ll, ll)':
a.cc:19:19: error: 'V' was not declared in this scope
   19 |     for (auto p : V[id]) {
      |                   ^
a.cc: In function 'int main()':
a.cc:28:11: error: 'cin' was not declared in this scope
   28 |     ll n; cin >> n;
      |           ^~~
a.cc:29:5: error: 'V' was not declared in this scope
   29 |     V.resize(n+1);
      |     ^
a.cc:40:9: error: 'cout' was not declared in this scope
   40 |         cout << (c[i] & 1) << endl;
      |         ^~~~
a.cc:40:31: error: 'endl' was not declared in this scope
   40 |         cout << (c[i] & 1) << endl;
      |                               ^~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
struct edge { int to, ll cost; };
vector<vector<edge>> g;
vector<int> ans;

void dfs(int v, ll o = 0, int p = -1) {
	o %= 2;
	if (o == 0) ans[v] = 0;
	else ans[v] = 1;
	rep(i, g[v].size()) {
		int u = g[v][i].to; ll c = g[v][i].cost;
		if (u == p)continue;
		return dfs(u, o + c, v);
	}
}

int main() {
	int n;
	cin >> n;
	g.resize(n);
	ans.resize(n);
	rep(i, n - 1) {
		int u, v;
        ll k;
		cin >> u >> v >> k;
		u--; v--;
		g[u].push_back(edge{ v, k });
		g[v].push_back(edge{ u, k });
	}
	dfs(0);
	rep(i, n) cout << ans[i] << endl;
}

Compiler output:
a.cc:10:23: error: expected ';' at end of member declaration
   10 | struct edge { int to, ll cost; };
      |                       ^~
      |                         ;
a.cc:10:26: error: 'cost' does not name a type; did you mean 'const'?
   10 | struct edge { int to, ll cost; };
      |                          ^~~~
      |                          const
a.cc: In function 'void dfs(int, ll, int)':
a.cc:19:52: error: '__gnu_cxx::__alloc_traits<std::allocator<edge>, edge>::value_type' {aka 'struct edge'} has no member named 'cost'
   19 |                 int u = g[v][i].to; ll c = g[v][i].cost;
      |                                                    ^~~~
a.cc: In function 'int main()':
a.cc:35:41: warning: narrowing conversion of 'k' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   35 |                 g[u].push_back(edge{ v, k });
      |                                         ^
a.cc:36:41: warning: narrowing conversion of 'k' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   36 |                 g[v].push_back(edge{ u, k });
      |                                         ^
Language: C++

#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int, int> P;

int main() {
  int N;
  cin >> N;
  vector<vector<P>> graph(N);
  for (int i = 0; i < N - 1; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    graph[u - 1].push_back(make_pair(v - 1, w));
    graph[v - 1].push_back(make_pair(u - 1, w));
  }
  
  vector<int> d(N, 1000000000);
  d[0] = 0;
  vector<bool> used(N, false);
  priority_queue<P> pq;
  pq.push(make_pair(0, 0));
  while (pq.size() > 0) {
    int minCost = pq.top().first;
    int minVertex = pq.top().second;
    pq.pop();
    if (used[minVertex]) continue;
    for (int i = 0; i < graph[minVertex].size(); ++i) {
      int alt = minCost + graph[minVertex][i].second;
      if (alt < d[graph[minVertex][i].first]) {
        d[graph[minVertex][i].first] = alt;
        pq.push(make_pair(alt, graph[minVertex][i].first));
      }
    }
    used[minVertex] = true;
  }
  
  for (int i = 0; i < N; ++i) cout << d[i] % 2 << endl;
  return 0;

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


import java.util.ArrayList;
import java.util.Scanner;

public class D {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		color = new int[n];
		
		@SuppressWarnings("unchecked")
		ArrayList<Edge>[] edges = new ArrayList[n];
		
		for(int i = 0; i < n; i++) {
			edges[i] = new ArrayList<Edge>();
		}
		
		for(int i = 0; i < n - 1; i++) {
			int u = sc.nextInt() - 1;
			int v = sc.nextInt() - 1;
			int w = sc.nextInt();
			
			edges[u].add(new Edge(v, w));
			edges[v].add(new Edge(u, w));
		}
		
		ArrayList<Integer> queue = new ArrayList<Integer>();
		
		color[0] = BLACK;
		queue.add(0);
		
		while(!queue.isEmpty()) {
			int v = queue.remove(0);
			
			for(int i = 0; i < edges[v].size(); i++) {
				Edge e = edges[v].get(i);
				
				if(color[e.to] == NONE) {
					if(e.cost % 2 == 0) {
						color[e.to] = color[v];
					}
					else if(color[i] == BLACK){
						color[e.to] = WHITE;
					}
					else {
						color[e.to] = BLACK; 
					}
					
					queue.add(e.to);
				}
			}
		}
		
		for(int i = 0; i < n; i++) {
			System.out.println(color[i]);
		}
	}
	
	static int color[];
	static final int NONE = -1;
	static final int BLACK = 1;
	static final int WHITE = 0;

}

class Edge {
	int to;
	int cost;
	
	Edge(int to, int cost){
		this.to = to;
		this.cost = cost;
	}
}

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

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)


using namespace std;

const int maxE = 1000100;
int parent[maxE];
int parent_rank[maxE];


void init(int max_element) {
	for (int i = 0; i < max_element; i++) {
		parent[i] = i;
		parent_rank[i] = 1; 
	}
}

int find(int x) {
	if (x == parent[x]) return x;
	
	parent[x] = find(parent[x]);
	return parent[x];
}

bool isSame(int x, int y) {
	return find(x) == find(y);
}



void link(int x, int y) {
	if (x == y) return;
	if (parent_rank[x] > parent_rank[y]) {
		parent[y] = x;
		return;
	}
	parent[x] = y;
	if (parent_rank[x] == parent_rank[y]) {
		parent_rank[y]++;
	}
}

void unite(int x, int y) {
	link(find(x),find(y));
}



int main() {

	int n, m;

	cin >> n >> m;
	init(n + 50);


	rep(i, m) {
		int x, y, z;
		cin >> x >> y >> z;
		link(x, y);
	}


	set<int> s;
	for(int i = 1; i <= n; i++)
		s.insert(find(i));
	}
	cout << s.size() << endl;
	return 0;

}


Compiler output:
a.cc:87:9: error: 'cout' does not name a type
   87 |         cout << s.size() << endl;
      |         ^~~~
a.cc:88:9: error: expected unqualified-id before 'return'
   88 |         return 0;
      |         ^~~~~~
a.cc:90:1: error: expected declaration before '}' token
   90 | }
      | ^