criyle/codenet-compile-errors huggingface dataset:
Language: Java


import java.util.*;

public class Main {
    public static void main(String[] args) {
        final Main2 main2 = new Main2();
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        final Map<Integer, List<A>> integerListMap = new HashMap<>();

        for (int i = 0; i < n - 1; i++) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();
            final int c = scanner.nextInt();

            integerListMap.computeIfAbsent(a, e -> new ArrayList<>())
                    .add(main2.new A(b, c % 2 == 0));
        }

        final int[] ints = new int[n + 1];
        for (int i = 0; i < n + 1; i++) {
            ints[i] = -1;
        }

        boolean first = true;
        for (Map.Entry<Integer, List<A>> integerListEntry : integerListMap.entrySet()) {
            if (first) {
                ints[integerListEntry.getKey()] = 0;
                first = false;
            }

            if (ints[integerListEntry.getKey()] == -1) {
                for (A a : integerListEntry.getValue()) {
                    if (ints[a.getD()] != -1) {
                        if (a.getL()) {
                            ints[integerListEntry.getKey()] = ints[a.getD()];
                        } else {
                            ints[integerListEntry.getKey()] = 1 - ints[a.getD()];
                        }
                        break;
                    }
                }
            }

            for (A a : integerListEntry.getValue()) {
                if(a.getL()){
                    ints[a.getD()] = ints[integerListEntry.getKey()];
                }else{
                    ints[a.getD()] = 1-ints[integerListEntry.getKey()];
                }
            }
        }

        for(int i = 1;i<n+1;i++){
            System.out.println(ints[i]);
        }
    }

    class A {
        private final int d;
        private final boolean l;

        A(int d, boolean l) {
            this.d = d;
            this.l = l;
        }


        public boolean getL() {
            return l;
        }

        public int getD() {
            return d;
        }
    }
}


Compiler output:
Main.java:6: error: cannot find symbol
        final Main2 main2 = new Main2();
              ^
  symbol:   class Main2
  location: class Main
Main.java:6: error: cannot find symbol
        final Main2 main2 = new Main2();
                                ^
  symbol:   class Main2
  location: class Main
2 errors
Language: C++

#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<vector<int>>dis(N, vector<int>(N));
  vector<vector<int>>tree(N, vector<int>(N));
  vecotr<int>ans(N);
  vecotr<int>size(N, 0);
  ans[0] = 0;
  for (int i = 0; i < N - 1; i ++) {
    int a, b, w;
    cin >> a >> b >> w;
    a --;
    b --;
    tree[a][size[a]] = b;
    tree[b][size[b]] = a;
    dis[a][size[a]] = w % 2;
    dis[b][size[b]] = w % 2;
    size[a] ++;
    size[b] ++;
  }
  queue<int> n;
  n.push(0);
  while(!n.empty()) {
    int u = n.front();
    n.pop();
    for (int i = 0; i < size[u]; i ++) {
      ans[tree[u][i]] = ans[u] + dis[u][i];
      if (size[tree[u][i]]) n.push(tree[u][i]);
    }
  }
  for (int i = 0; i < N; i ++) {
    cout << ans[i] % 2 << endl;
  }
}
  
    

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'vecotr' was not declared in this scope
   10 |   vecotr<int>ans(N);
      |   ^~~~~~
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vecotr<int>ans(N);
      |          ^~~
a.cc:11:10: error: expected primary-expression before 'int'
   11 |   vecotr<int>size(N, 0);
      |          ^~~
a.cc:12:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |   ans[0] = 0;
      |   ^~~
      |   abs
a.cc:18:17: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   18 |     tree[a][size[a]] = b;
      |                 ^
a.cc:19:17: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   19 |     tree[b][size[b]] = a;
      |                 ^
a.cc:20:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   20 |     dis[a][size[a]] = w % 2;
      |                ^
a.cc:21:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   21 |     dis[b][size[b]] = w % 2;
      |                ^
a.cc:22:9: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   22 |     size[a] ++;
      |         ^
a.cc:23:9: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   23 |     size[b] ++;
      |         ^
a.cc:30:29: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   30 |     for (int i = 0; i < size[u]; i ++) {
      |                             ^
a.cc:32:15: error: invalid types '<unresolved overloaded function type>[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   32 |       if (size[tree[u][i]]) n.push(tree[u][i]);
      |               ^
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:42:41: error: expected primary-expression before ':' token
   42 |     if(same(i,1)==true) cout<<"1"<<endl;:
      |                                         ^
a.cc:46:1: warning: no return statement in function returning non-void [-Wreturn-type]
   46 | }
      | ^
Language: C

#include <stdio.h>
#include <math.h>
#define MAX_NUMBER_OF_NODE 100000

int main() {
  int number_n, i, temp_node_a, temp_node_b, temp_distance;
  scanf("%d", &number_n);
  int *node_name[MAX_NUMBER_OF_NODE];
  int value_0 = 0, value_1 = 1;
  *node_name = &value_0;
  for(i = 0; i < number_n - 1; i++) {
    node_name[i] = &value_0;
  }
  for(i = 0; i < number_n - 1; i++) {
    scanf("%d %d %d", &temp_node_a, &temp_node_b, &temp_distance);
    if(temp_distance % 2 == 0) {
      node_name[temp_node_b] = node_name[temp_node_a];
    }
  }
  for(i = 1; i <= number_n; i++) {
    printf("%d\n", node_name[i]);
  }*/
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:22:5: error: expected expression before '/' token
   22 |   }*/
      |     ^
Language: C++

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_p
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
vecll dis;
vec col;
vector<bool> done;
vector<queue<pll>> v;
void func(ll k,ll d){
    dis[k]=d;
    done[k]=true;
    while(!v[k].empty()){
        ll p=v[k].front().first,di=v[k].front().second;
        v[k].pop();
        if(done[p])continue;
        func(p,di+d);
    }
    return;
}
int main(){
    int n=in();
    dis.resize(n);
    dis[0]=0;
    col.resize(n);
    v.resize(n);
    done.resize(n,false);
    rep(i,n-1){
        int x=in()-1,y=in()-1,d=in();
        v[x].push(mp(y,d));
        v[y].push(mp(x,d));
    }
    func(0,0);
    rep(i,n){
        col[i]=dis[i]%2==0?0:1;
        cout<<col[i]<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:12: error: 'make_p' was not declared in this scope
   29 | #define mp make_p
      |            ^~~~~~
a.cc:58:19: note: in expansion of macro 'mp'
   58 |         v[x].push(mp(y,d));
      |                   ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  lint n,i;cin>>n;
  set<int> sp[n]={};
  vint u(n),v(n),w(n);vint mp(n,-1);
  for(i=0;i<(n-1);i++){
     cin>>u[i]>>v[i]>>w[i];
    if(w[i]%2){
      sp[u[i]-1].insert(v[i]-1);
      sp[v[i]-1].insert(u[i]-1);
      mp[u[i]]=2;mp[v[i]]=2;
    }
  }
  auto itr,otr;
  for(i=0;i<n;i++){
    if(mp[i]==2){
       mp[i]=0;
       otr=sp[i].end();
      for(itr=sp[i].begin();itr!=sp[i].end;itr++){
         mp[*itr]=1;
      }
      break;
    }
  }
  
  for(int j=i+1;j<n;j++){
    if(mp[j]==0){
       otr=sp[j].end();
      for(itr=sp[i].begin();itr!=sp[i].end;itr++){
         mp[*itr]=1;
      }
    }else if(mp[j]==1){
       otr=sp[j].end();
      for(itr=sp[i].begin();itr!=sp[i].end;itr++){
         mp[*itr]=0;
      }
      
    }else if(mp[j]==2){
       otr=sp[j].end();
      for(itr=sp[i].begin();itr!=sp[i].end;itr++){
         if(mp[*itr]==0){mp[j]=1;}else if(mp[*itr]==1){mp[j]=0;}
      }
      if(mp[j]==0){for(itr=sp[i].begin();itr!=sp[i].end;itr++){
         mp[*itr]=0;
      }
                  }
      else{
      for(itr=sp[i].begin();itr!=sp[i].end;itr++){
         mp[*itr]=1;
      }
      }
    }
  }
    for(int j=i+1;j<n;j++){
    if(mp[j]==0){
       otr=sp[j].end();
      for(itr=sp[i].begin();itr!=sp[i].end;itr++){
         mp[*itr]=1;
      }
    }else if(mp[j]==1){
       otr=sp[j].end();
      for(itr=sp[i].begin();itr!=sp[i].end;itr++){
         mp[*itr]=0;
      }
      
    }else if(mp[j]==2){
       otr=sp[j].end();
      for(itr=sp[i].begin();itr!=sp[i].end;itr++){
         if(mp[*itr]==0){mp[j]=1;}else if(mp[*itr]==1){mp[j]=0;}
      }
      if(mp[j]==0){for(itr=sp[i].begin();itr!=sp[i].end;itr++){
         mp[*itr]=0;
      }
                  }
      else{
      for(itr=sp[i].begin();itr!=sp[i].end;itr++){
         mp[*itr]=1;
      }
      }
    }
  }
for(i=0;i<n;i++){
  
 cout<<mp[i]<<endl;
  
}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:3: error: declaration of 'auto itr' has no initializer
   26 |   auto itr,otr;
      |   ^~~~
a.cc:26:3: error: declaration of 'auto otr' has no initializer
Language: C++

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

int main(){
    int N;
    cin >> N;
    int u[N-1];
    int v[N-1];
    int w[N-1];
    int color[N] ={2};

    for (int i = 0; i < N-1; i++)
    {
        cin >> u[i] >> v[i] >> w[i];
    }
    
    color[u[0]] = 0;
    int j = 1;
    while(j){
        
        for (int i = 0; i < N; i++)
        {
            if(color[u[i]] != 2){
                color[v[i]] = (color[u[i]] + w[i] % 2) % 2;
            }
            else if(color[v[i]] != 2){
                color[u[i]] = (color[v[i]] + w[i] % 2) % 
            }
        }

        for (int i = 0; i < N; i++)
        {
            if(color[i] == 2){
                break;
            }
            if(i == N-1) j = 0;
        }
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:29:13: error: expected primary-expression before '}' token
   29 |             }
      |             ^
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:43: error: incompatible types: int cannot be converted to int[]
      int[][] s1 = {u[i], v[i]};
                     ^
Main.java:43: error: incompatible types: int cannot be converted to int[]
      int[][] s1 = {u[i], v[i]};
                           ^
Main.java:44: error: incompatible types: int cannot be converted to int[]
      int[][] s2 = {v[i], u[i]};
                     ^
Main.java:44: error: incompatible types: int cannot be converted to int[]
      int[][] s2 = {v[i], u[i]};
                           ^
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};
                        ^
7 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int countMax,count,value,num;
  countMax=0;
  count=0;
  vector<int> u(N),v(N),w(N),a(N);
  for (int i = 0; i < N; i++) {
  　cin >> u.at(i)>>v.at(i)>>w.at(i);
  }
  for (int i = 0; i < N; i++) {
  　value=w.at(i);
    for (int j = 0; j < N; i++) {
      if(j==i){
        continue;
      }
      if(w.at(j)==value){
        if(u.at(j)==u.at(i)||u.at(j)==v.at(i)){
          count++;
        }
        if(v.at(j)==u.at(i)||v.at(j)==v.at(i)){
          count++;
        }
      }
    }
    if(count>countMax){
      countMax=count;
      num=i;
    }
  }
  
  value=w.at(num);
  a.at(u.at(num))=1;
  a.at(v.at(num))=1;
  for (int j = 0; j < N; j++) {
    if(j==num){
      continue;
    }
    if(w.at(j)==value){
      if(u.at(j)==u.at(num)||u.at(j)==v.at(num)){
        a.at(u.at(j))=1;
       }
      if(v.at(j)==u.at(num)||v.at(j)==v.at(num)){
        a.at(v.at(j))=1
      }
    }
  }
  for (int j = 0; j < N; j++) {
    cout<<a.at(j)<<endl;
  }

}

Compiler output:
a.cc:12:3: error: extended character 　 is not valid in an identifier
   12 |   　cin >> u.at(i)>>v.at(i)>>w.at(i);
      |   ^
a.cc:15:3: error: extended character 　 is not valid in an identifier
   15 |   　value=w.at(i);
      |   ^
a.cc: In function 'int main()':
a.cc:12:3: error: '\U00003000cin' was not declared in this scope
   12 |   　cin >> u.at(i)>>v.at(i)>>w.at(i);
      |   ^~~~~
a.cc:15:3: error: '\U00003000value' was not declared in this scope; did you mean 'value'?
   15 |   　value=w.at(i);
      |   ^~~~~~~
      |   value
a.cc:47:24: error: expected ';' before '}' token
   47 |         a.at(v.at(j))=1
      |                        ^
      |                        ;
   48 |       }
      |       ~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nummax 101000
using namespace std;

int i, j, N, n, u[nummax], v[nummax], w[nummax], ww, ans[nummax], ca[nummax][nummax], cb[nummax][nummax], cnum[nummax];

void DP(int n, int cc)
{
	for (j = 0; j < cnum[n]; j++)
	{
		if (cb[n][j] != 2)
		{
			ans[cb[n][j]] = (cc + cb[n][j]) % 2;
			cb[j][n] = 2;
			DP(ca[n][j], cb[n][j]);
		}
	}
}

int main() {
	cin >> N;
	for (i = 1; i <= N; i++)
	{
		cnum[i] = 0;
	}
	for (i = 1; i < N; i++)
	{
		cin >> u[i] >> v[i] >> w[i];
		ww = w[i] % 2;
		ca[cnum[v[i]]][cnum[u[i]]] = v[i];
		ca[cnum[u[i]]][cnum[v[i]]] = u[i];
		cb[cnum[v[i]]][cnum[u[i]]] = ww;
		cb[cnum[u[i]]][cnum[v[i]]] = ww;
		cnum[u[i]]++;
		cnum[v[i]]++;
	}
	n = 1;
	ans[1] = 0;
	DP(n, 0);

	for(i = 1; i <= N; i++)
		cout << ans[i] << endl;
}

Compiler output:
/tmp/ccV2Whvk.o: in function `DP(int, int)':
a.cc:(.text+0x40): relocation truncated to fit: R_X86_64_PC32 against symbol `cb' defined in .bss section in /tmp/ccV2Whvk.o
a.cc:(.text+0x73): relocation truncated to fit: R_X86_64_PC32 against symbol `cb' defined in .bss section in /tmp/ccV2Whvk.o
a.cc:(.text+0xa2): relocation truncated to fit: R_X86_64_PC32 against symbol `cb' defined in .bss section in /tmp/ccV2Whvk.o
a.cc:(.text+0xf2): relocation truncated to fit: R_X86_64_PC32 against symbol `cb' defined in .bss section in /tmp/ccV2Whvk.o
a.cc:(.text+0x120): relocation truncated to fit: R_X86_64_PC32 against symbol `cb' defined in .bss section in /tmp/ccV2Whvk.o
a.cc:(.text+0x179): relocation truncated to fit: R_X86_64_PC32 against symbol `cnum' defined in .bss section in /tmp/ccV2Whvk.o
/tmp/ccV2Whvk.o: in function `main':
a.cc:(.text+0x1ce): relocation truncated to fit: R_X86_64_PC32 against symbol `cnum' defined in .bss section in /tmp/ccV2Whvk.o
a.cc:(.text+0x2e3): relocation truncated to fit: R_X86_64_PC32 against symbol `cnum' defined in .bss section in /tmp/ccV2Whvk.o
a.cc:(.text+0x313): relocation truncated to fit: R_X86_64_PC32 against symbol `cnum' defined in .bss section in /tmp/ccV2Whvk.o
a.cc:(.text+0x37f): relocation truncated to fit: R_X86_64_PC32 against symbol `cnum' defined in .bss section in /tmp/ccV2Whvk.o
a.cc:(.text+0x3af): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include <climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

int cost[100010][100010];
vector<int> e[100010];
int ans[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int cost[n+1][n+1];
    vector<int> e[n+1];
    int ans[n+1];
    rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        e[a].pb(b);
        cost[a][b]=c;
    }
    queue<int> que;
    que.push(1);
    memset(ans,INF,sizeof(ans));
    ans[1]=0;
    rep(j,n-1){
        int x=que.front();
        que.pop();
        for(int i:e[x]){
            if(cost[x][i]%2==0){
                ans[i]=ans[x];
            }
            else ans[i]=1-ans[x];
            que.push(i);
        }
    }
    for(int i=1;i<=n;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Compiler output:
/tmp/ccdk8XdK.o: in function `__tcf_0':
a.cc:(.text+0x5f4): relocation truncated to fit: R_X86_64_PC32 against symbol `e' defined in .bss section in /tmp/ccdk8XdK.o
a.cc:(.text+0x5fb): relocation truncated to fit: R_X86_64_PC32 against symbol `e' defined in .bss section in /tmp/ccdk8XdK.o
/tmp/ccdk8XdK.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x622): relocation truncated to fit: R_X86_64_PC32 against symbol `e' defined in .bss section in /tmp/ccdk8XdK.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);
      }
    }
  }
}

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    System.out.println(ans);
  }
}

Compiler output:
Main.java:77: error: class, interface, enum, or record expected
import java.util.*;
^
1 error
Language: C++

#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;
 
int main(){
  long long int N;
  cin >> N;
  
  long long int u[N-1], v[N-1], w[N-1];
  int c[N]; // 1からの距離.
  bool b[N] = {}; //色が判明しているかどうか
  queue<pair<int, bool>> con[N]; // つながってる頂点と、自分と色が同じかを格納
  
  for(int i = 0; i < N-1; i++){
    long long int tw;
    cin >> u[i] >> v[i] >> tw;
    w[i] = tw % w;
    con[u[i]-1].push(make_pair(v[i]-1, w==0));
    con[v[i]-1].push(make_pair(u[i]-1, w==0));
  }
  b[0] = true;
  c[0] = 0;
  
  queue<int> q;
  q.push(0);
  
  while(q.empty() == false){
    int i = q.front();
    int cq = con[i];
    while(cq.empty() == false){
      auto vc = cq.front();
      if(b[vc.first])
        continue;
      
      c[vc.first] = vc.second ? c[i] : 1-c[i];
      b[vc.first] = true;
      q.push(i);
      cq.pop();
    }
    q.pop();
  }
  for(int i = 0; i < N; i++){
    cout << c[i];
  }
  
  cout << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:15: error: invalid operands of types 'long long int' and 'long long int [(N + -1)]' to binary 'operator%'
   22 |     w[i] = tw % w;
      |            ~~ ^ ~
      |            |    |
      |            |    long long int [(N + -1)]
      |            long long int
a.cc:34:19: error: cannot convert 'std::queue<std::pair<int, bool> >' to 'int' in initialization
   34 |     int cq = con[i];
      |              ~~~~~^
      |                   |
      |                   std::queue<std::pair<int, bool> >
a.cc:35:14: error: request for member 'empty' in 'cq', which is of non-class type 'int'
   35 |     while(cq.empty() == false){
      |              ^~~~~
a.cc:36:20: error: request for member 'front' in 'cq', which is of non-class type 'int'
   36 |       auto vc = cq.front();
      |                    ^~~~~
a.cc:43:10: error: request for member 'pop' in 'cq', which is of non-class type 'int'
   43 |       cq.pop();
      |          ^~~
Language: C++

#include<iostream>
using namespace std;

const int MAX_N = 1e5;
int N;
int u[MAX_N], v[MAX_N], W[MAX_N];
int clr[MAX_N];

void solve()
{
  	clr[v[1]] = 0;
  	if(w[1] % 2 == 0) clr[v[1]] = 0;
  	else clr[v[1]] = 1;
	for(int i = 2; i < N-1; i++){
      	
      if(clr[u[i]] != 0 && w[i] % 2 == 0)
        	clr[v[i]] = clr[u[i]];
      else if(clr[v[i]] != 0 && w[i] % 2 == 0)
          	clr[u[i]] = clr[v[i]];
    }
  for(int i = 0; i < N; i++)
    cout << clr[i] << endl;
}
int main()
{
  	int u, v, w;
   	cin >> N;
	for(int i = 1; i < N; i++){
		cin >> u[i] >> v[i] >> w[i];
    }
  	solve();
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:12:12: error: 'w' was not declared in this scope
   12 |         if(w[1] % 2 == 0) clr[v[1]] = 0;
      |            ^
a.cc:16:28: error: 'w' was not declared in this scope
   16 |       if(clr[u[i]] != 0 && w[i] % 2 == 0)
      |                            ^
a.cc: In function 'int main()':
a.cc:29:25: error: invalid types 'int[int]' for array subscript
   29 |                 cin >> u[i] >> v[i] >> w[i];
      |                         ^
a.cc:29:33: error: invalid types 'int[int]' for array subscript
   29 |                 cin >> u[i] >> v[i] >> w[i];
      |                                 ^
a.cc:29:41: error: invalid types 'int[int]' for array subscript
   29 |                 cin >> u[i] >> v[i] >> w[i];
      |                                         ^
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mod 1000000007
#define ff first
#define ss second
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
//int p=0;
//ll arr[1000002];
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
void dfs(vector<pair<int,int> >v[],int vis[],int node,int ans[])
{
    vis[node]=1;
   // p++;
    for(auto u : v[node])
    {
        if(!vis[u.ff])
        {
            if((u.ss)%2==0)
                ans[u.ff]=ans[node];
            else
                ans[u.ff]=!ans[node];
            dfs(v,vis,u.ff,ans);
        }
    }
}
int main()
{
    fast();
    int n;
    cin>>n;
    int x,y,w,i;
    //map<pair<int,int>,int>mp;
     int ans[n+1];
    ans[1]=0;
    vector<pair<int,int> >v[n+1];
    for(i=0;i<n-1;i++)
    {
        cin>>x>>y>>w;
       // mp[{x,y}]=w;
       // mp[{y,x}]=w;
        v[x].pb({y,w});
        v[y].pb({x,w});
    }
    int vis[n+1]={0};
    dfs(v,vis,1,ans);
   // cout<<p<<endl;
    for(i=1;i<=n;i++)
        cout<<ans[i]<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:54:16: error: no matching function for call to 'std::vector<std::pair<int, int> >::emplace_back(<brace-enclosed initializer list>)'
   54 |         v[x].pb({y,w});
      |         ~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/vector.tcc:111:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {}; _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; reference = std::pair<int, int>&]'
  111 |       vector<_Tp, _Alloc>::
      |       ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:111:7: note:   candidate expects 0 arguments, 1 provided
a.cc:55:16: error: no matching function for call to 'std::vector<std::pair<int, int> >::emplace_back(<brace-enclosed initializer list>)'
   55 |         v[y].pb({x,w});
      |         ~~~~~~~^~~~~~~
/usr/include/c++/14/bits/vector.tcc:111:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {}; _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; reference = std::pair<int, int>&]'
  111 |       vector<_Tp, _Alloc>::
      |       ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:111:7: note:   candidate expects 0 arguments, 1 provided
Language: C++

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define wtf32 23
struct nd{
    int to, w;
    nd(int t, int ww) : to(t), w(ww) {}
};
std::vector<nd> vec[100005];
int drg[100005];
bool vis[100005];
bool col[100005];
int main(){
    int n;
    std::cin >> n;
    int u,v,w;
    for(int i = 1; i < n; ++ i){
        std::cin >> u >> v >> w;
        vec[u].push_back(nd(v,w));
        vec[v].push_back(nd(u,w));
        drg[u] ++;
        drg[v] ++;
    }
    std::queue<int> que;
    vis[1] = true;
    que.push(1);
    while(!que.empty()){
        int it = que.front();
        que.pop();
        for(auto &ir : vec[it]){
            if (!vis[ir.to]) {
                if (ir.w & 1) col[ir.to] = !col[it];
                else col[ir.to] = col[it];
                que.push(ir.to);
                vis[ir.to] = true;
            }
        }
    }
    for(int i =1 ; i<= n; ++ i){
        std::cout << col[i] << std::endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:10: error: 'queue' is not a member of 'std'
   25 |     std::queue<int> que;
      |          ^~~~~
a.cc:5:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    4 | #include <vector>
  +++ |+#include <queue>
    5 | #define wtf32 23
a.cc:25:16: error: expected primary-expression before 'int'
   25 |     std::queue<int> que;
      |                ^~~
a.cc:27:5: error: 'que' was not declared in this scope
   27 |     que.push(1);
      |     ^~~
Language: C++

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include <climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

int cost[100010][100010];
vector<int> e[100010];
int flag,ans[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        e[a].pb(b);
        e[b].pb(a);
        cost[a][b]=c;
    }
    queue<int> que;
    que.push(1);
    memset(ans,INF,sizeof(ans));
    ans[1]=0;
    rep(j,n-1){
        int x=que.front();
        que.pop();
        for(int i:e[x]){
            if(cost[x][i]%2==0){
                ans[i]=ans[x];
            }
            else ans[i]=1-ans[x];
            que.push(i);
        }
    }
    for(int i=1;i<=n;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Compiler output:
/tmp/ccVfPifm.o: in function `main':
a.cc:(.text+0xa9): relocation truncated to fit: R_X86_64_PC32 against symbol `e' defined in .bss section in /tmp/ccVfPifm.o
a.cc:(.text+0xdb): relocation truncated to fit: R_X86_64_PC32 against symbol `e' defined in .bss section in /tmp/ccVfPifm.o
a.cc:(.text+0x175): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccVfPifm.o
a.cc:(.text+0x183): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccVfPifm.o
a.cc:(.text+0x1d1): relocation truncated to fit: R_X86_64_PC32 against symbol `e' defined in .bss section in /tmp/ccVfPifm.o
a.cc:(.text+0x265): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccVfPifm.o
a.cc:(.text+0x27a): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccVfPifm.o
a.cc:(.text+0x293): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccVfPifm.o
a.cc:(.text+0x2b5): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccVfPifm.o
a.cc:(.text+0x335): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccVfPifm.o
/tmp/ccVfPifm.o: in function `__tcf_0':
a.cc:(.text+0x3b6): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
using namespace std;

const int MAX_N = 1e5;
int N;
int u[MAX_N], v[MAX_N], W[MAX_N];
int clr[MAX_N];

void solve()
{
  	clr[v[1]] = 0;
  	if(w[1] % 2 == 0) clr[v[1]] = 0;
  	else clr[v[1]] = 1;
	for(int i = 2; i < N-1; i++){
      	
      if(clr[u[i]] != 0 && w[i] % 2 == 0)
        	clr[v[i]] = clr[u[i]];
      else if(clr[v[i]] != 0 && w[i] % 2 == 0)
          	clr[u[i]] = clr[v[i]];
    }
}
int main()
{
  	int u, v, w;
   	cin >> N;
	for(int i = 1; i < N; i++){
		cin >> u[i] >> v[i] >> w[i];
    }
  	solve();
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:12:12: error: 'w' was not declared in this scope
   12 |         if(w[1] % 2 == 0) clr[v[1]] = 0;
      |            ^
a.cc:16:28: error: 'w' was not declared in this scope
   16 |       if(clr[u[i]] != 0 && w[i] % 2 == 0)
      |                            ^
a.cc: In function 'int main()':
a.cc:27:25: error: invalid types 'int[int]' for array subscript
   27 |                 cin >> u[i] >> v[i] >> w[i];
      |                         ^
a.cc:27:33: error: invalid types 'int[int]' for array subscript
   27 |                 cin >> u[i] >> v[i] >> w[i];
      |                                 ^
a.cc:27:41: error: invalid types 'int[int]' for array subscript
   27 |                 cin >> u[i] >> v[i] >> w[i];
      |                                         ^
Language: C++

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

void main(){
  int N;
  cin>>N;
  
  int par[N+1];
  int rank[N+1];
  
  for(int i=0; i<=N; ++i){
    par[i]=i;
    rank[i]=0;
  }
  
  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;
    if(rank[x]<rank[y]) par[x]=y;
    else{
      par[y]=x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  
  bool same(int x, int y) return find(x)==find(y);
  
  
  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:9:1: error: '::main' must return 'int'
    9 | void main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:21:18: error: a function-definition is not allowed here before '{' token
   21 |   int find(int x){
      |                  ^
a.cc:26:27: error: a function-definition is not allowed here before '{' token
   26 |   void unite(int x, int y){
      |                           ^
a.cc:37:27: error: a function-definition is not allowed here before 'return'
   37 |   bool same(int x, int y) return find(x)==find(y);
      |                           ^~~~~~
a.cc:43:16: error: 'unite' was not declared in this scope
   43 |     if(C%2==0) unite(A,B);
      |                ^~~~~
a.cc:47:8: error: 'same' was not declared in this scope
   47 |     if(same(i,1)==true) cout<<"1"<<endl;:
      |        ^~~~
a.cc:47:41: error: expected primary-expression before ':' token
   47 |     if(same(i,1)==true) cout<<"1"<<endl;:
      |                                         ^
Language: C++

#include<iostream>
#include<queue>
using namespace std;
int main(){
    long long n,v1,v2,w,c;
    cin>>n;
    long long tree[n][n]={},ans[n]={};
    bool visit[n]={};
    for(int i=1;i<n;i++){
        cin>>v1>>v2>>w;
        tree[v1-1][v2-1]=tree[v2-1][v1-1]=w;
    }
    queue<int>q;
    q.push(0);
    ans[0]=1;
    visit[0]=true;
    while(!q.empty()){
        c=q.front(),q.pop();
        for(int i=0;i<n;i++){
            /*if(tree[c][i]!=0&&!visit[i]){
                visit[i]=true;
                if(tree[c][i]%2==0){
                    ans[i]=1;
                    q.push(i);
                }
            */}
        }
    }
    //for(auto x:ans)cout<<x<<endl;
    return 0;
}

Compiler output:
a.cc:30:5: error: expected unqualified-id before 'return'
   30 |     return 0;
      |     ^~~~~~
a.cc:31:1: error: expected declaration before '}' token
   31 | }
      | ^
Language: C++

/*
 * Author    : raj1307 - Raj Singh
 * Institute : Jalpaiguri Government Engineering College
 * Date      : 19.05.19
 */
#include <bits/stdc++.h>
using namespace std;
 
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int col[N]={0},a[N][N];
vector<int>graph[N];
bitset<N> vis;

void dfs(int v,int d){
	vis[v] = 1;
	if(d%2==0)
	    col[v]=1;
	for(auto i:graph[v])
		if(!vis[i]) dfs(i,d+a[i][v]);
}


signed main() {
    fio
    int n;
	cin>>n;
	int x,y,w;
	for(int i=0;i<n-1;i++){
	    cin>>x>>y>>w;
	    graph[x].push_back(y);
	    graph[y].push_back(x);
	    a[x][y]=w;
	    a[y][x]=w;
	}
	
	for(int i=1;i<n+1;i++){
	    if(vis[i]==0) dfs(i,0);
	}
	
	for(int i=1;i<n+1;i++){
	    cout<<col[i]<<endl;
	}
	
	
	
	
	
	
	
	
	
	
	return 0;
}

Compiler output:
/tmp/ccL90rvz.o: in function `dfs(long long, long long)':
a.cc:(.text+0x1c): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccL90rvz.o
a.cc:(.text+0x83): relocation truncated to fit: R_X86_64_PC32 against symbol `graph' defined in .bss section in /tmp/ccL90rvz.o
a.cc:(.text+0xd1): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccL90rvz.o
/tmp/ccL90rvz.o: in function `main':
a.cc:(.text+0x217): relocation truncated to fit: R_X86_64_PC32 against symbol `graph' defined in .bss section in /tmp/ccL90rvz.o
a.cc:(.text+0x241): relocation truncated to fit: R_X86_64_PC32 against symbol `graph' defined in .bss section in /tmp/ccL90rvz.o
a.cc:(.text+0x2d5): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccL90rvz.o
/tmp/ccL90rvz.o: in function `__tcf_0':
a.cc:(.text+0x39a): relocation truncated to fit: R_X86_64_PC32 against symbol `graph' defined in .bss section in /tmp/ccL90rvz.o
a.cc:(.text+0x3a1): relocation truncated to fit: R_X86_64_PC32 against symbol `graph' defined in .bss section in /tmp/ccL90rvz.o
/tmp/ccL90rvz.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x3c8): relocation truncated to fit: R_X86_64_PC32 against symbol `graph' defined in .bss section in /tmp/ccL90rvz.o
collect2: error: ld returned 1 exit status
Language: C++

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

int main () {
    int n;
    cin >> n;
    vector <vector<int> > vec(n - 1, vector <int> (3));
    vector<int> colors (n, -1);
    colors[0] = 1;
    for (int i = 0; i < n; ++i) {
        cin >> vec[i][0] >> vec[i][1] >> vec[i][2];
    }
    sort(vec.begin(), vec.end());
    for (auto v: vec) {
        // cout << v[0] << v[1] << v[2] << endl;
        if (colors[v[0]-1] != -1) {
            colors[v[1]-1] = (colors[v[0]-1] + (v[2] % 2 != 0)) % 2;
        }
    }
    for (auto i: colors) {
        if (i == -1) cout << 0 << endl;
        else cout << i << endl;
    }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   15 |     sort(vec.begin(), vec.end());
      |     ^~~~
      |     short
Language: C++

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

template<class Abel> struct UnionFind {
    vector<long long> par;
    vector<long long> rank;
    vector<Abel> diff_weight;

    UnionFind(long long n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(long long n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (long long i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    long long root(long long x) {
        if (par[x] == x) {
            return x;
        }
        else {
            long long r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(long long x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(long long x, long long y) {
        return root(x) == root(y);
    }

    bool merge(long long x, long long y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(long long x, long long y) {
        return weight(y) - weight(x);
    }
};

long long main() {
    long long n,i;
    cin >> n;
    UnionFind<long long> uf(n);
    for (long long i = 0; i < n-1; ++i) {
        long long l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        if (uf.issame(l, r)) {
        
            
        }
        else {
            uf.merge(l, r, d);
        }
    }
    for(i=0; i<n; i++){
    	cout << uf.diff(0, i)%2 << endl;
    }
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

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

int main(){
  int N;
  cin>>N;
  
  int par[N+1];
  int rank[N+1];
  
  for(int i=0; i<=N; ++i){
    par[i]=i;
    rank[i]=0;
  }
  
  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;
    if(rank[x]<rank[y]) par[x]=y;
    else{
      par[y]=x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  
  bool same(int x, int y) return find(x)==find(y);
  
  
  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 'int main()':
a.cc:21:18: error: a function-definition is not allowed here before '{' token
   21 |   int find(int x){
      |                  ^
a.cc:26:27: error: a function-definition is not allowed here before '{' token
   26 |   void unite(int x, int y){
      |                           ^
a.cc:37:27: error: a function-definition is not allowed here before 'return'
   37 |   bool same(int x, int y) return find(x)==find(y);
      |                           ^~~~~~
a.cc:43:16: error: 'unite' was not declared in this scope
   43 |     if(C%2==0) unite(A,B);
      |                ^~~~~
a.cc:47:8: error: 'same' was not declared in this scope
   47 |     if(same(i,1)==true) cout<<"1"<<endl;:
      |        ^~~~
a.cc:47:41: error: expected primary-expression before ':' token
   47 |     if(same(i,1)==true) cout<<"1"<<endl;:
      |                                         ^
Language: C++

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

template<class Abel> struct UnionFind {
    vector<long long> par;
    vector<long long> rank;
    vector<Abel> diff_weight;

    UnionFind(long long n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(long long n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (long long i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    long long root(long long x) {
        if (par[x] == x) {
            return x;
        }
        else {
            long long r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(long long x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(long long x, long long y) {
        return root(x) == root(y);
    }

    bool merge(long long x, long long y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(long long x, long long y) {
        return weight(y) - weight(x);
    }
};

long long main() {
    long long n,i;
    cin >> n;
    UnionFind<long long> uf(n);
    for (long long i = 0; i < n-1; ++i) {
        long long l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        if (uf.issame(l, r)) {
        
            
        }
        else {
            uf.merge(l, r, d);
        }
    }
    for(i=0; i<n; i++){
    	cout << uf.diff(0, i)%2;
    }
}


Compiler output:
cc1plus: error: '::main' must return 'int'