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

#include <cstdlib>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100005
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    //stringstream geek(x);
    //geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}
ll modInverse(ll a, ll m)
{
    a = a%m;
    for (int x=1; x<m; x++)
       if ((a*x) % m == 1)
          return x;
}
ll maxDivide(ll a, ll b)
{
  while (a%b == 0)
   a = a/b;
  return a;
}
  set<ll>ans;
void primeFactors(ll n)
{

    while (n % 2 == 0)
    {
       ans.insert(2);
        n = n/2;
    }

    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            ans.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        ans.insert(n);
}
ll is(ll no)
{   if(no==1) return 0;
    set<ll>::iterator it;
for(it=ans.begin();it!=ans.end();it++){
  no = maxDivide(no, *it);
  if(no==1) return 1;
//  if()
 // no = maxDivide(no, 3);
 // no = maxDivide(no, 5);
}
//if(no==1) return 1;
//for(it=ans.begin();it!=ans.end();it++){
//if(no==*it) return 1;
//}
  return 0;
}

int comp(string a,string b)
{
    string aa = a.append(b);
    string bb = b.append(a);

    return aa.compare(bb) > 0 ? 1: 0;

}
vector<pair<int,int> >adj[100005];
int colors[100005]={0};
dfs(int i,int color)
{
 for(int j=0;j<adj[i].size();j++)
 { int cc;
//cout<<adj[i][j].second<<endl;
     if(adj[i][j].second&1)
     {

         colors[adj[i][j].first]=1-color;
     }
     else
         colors[adj[i][j].first]=color;
     dfs(adj[i][j].first,colors[adj[i][j].first]);

 }
}
int main()
{
   int n;
   cin>>n;
   for(int i=0;i<n-1;i++)
   {
    int a,b,c;
    cin>>a>>b>>c;
    adj[a].push_back(make_pair(b,c));


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


Compiler output:
a.cc:127:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
  127 | dfs(int i,int color)
      | ^~~
a.cc: In function 'int dfs(int, int)':
a.cc:142:1: warning: no return statement in function returning non-void [-Wreturn-type]
  142 | }
      | ^
a.cc: In function 'long long int modInverse(long long int, long long int)':
a.cc:68:1: warning: control reaches end of non-void function [-Wreturn-type]
   68 | }
      | ^
Language: C

#include <stdio.h>

int main(){
  int color[100000]={};
  int N
  scanf("%d",&N);
  for(int i=0;i<N-1;i++){
    int u,v,w;
    scanf("%d",&u);
    scanf("%d",&v);
    scanf("%d",&w);
    if(w%2==0){
      color[v]=color[u];
    }else{
      color[v]=1-color[u];
    }
  }
  for(int i=0;i<N;i++){
  	printf("%d",color[i]);
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'scanf'
    6 |   scanf("%d",&N);
      |   ^~~~~
main.c:6:15: error: 'N' undeclared (first use in this function)
    6 |   scanf("%d",&N);
      |               ^
main.c:6:15: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#pragma warning( disable:4996 )

using namespace std;

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};


int main(void) {
	int n;
	scanf("%d", &n);
	UnionFind tree(n * 10);
	for (int i = 0; i < n-1; i++) {
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);
		if (w % 2 == 0) {
			tree.unite(u, v);
		}
		
		
	}
	printf("0\n");
	for (int i = 2; i <= n; i++) {
		if (tree.same(1, i)) {
			printf("0\n");
		}
		else {
			printf("1\n");
		}
	}
	
	return 0;
}

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

typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    vector<pair<ll,ll>> edge[100010];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        ll tmp_1,tmp_2,tmp_3;
        std::cin >> tmp_1>>tmp_2>>tmp_3;
        tmp_1--;
        tmp_2--;
        edge[min(tmp_1,tmp_2)].push_back({max(tmp_1,tmp_2),tmp_3});
    }
    bool black[100010];
    bool done[100010];
    Fill(black,false)
    Fill(done,false);
    
    black[0] = true;
    
    std::queue<ll> q;
    q.push(0);
    done[0] = true;
    while(!q.empty()){
        ll now = q.front();
        q.pop();
        for (auto e : edge[now]) {
            if(done[e.first]){
                continue;
            }
            done[e.first] = true;
            if(e.second % 2 == 0){
                black[e.first] = black[now];
            }else{
                black[e.first] = !black[now];
            }
            q.push(e.first);
        }
    }
    for (int i = 0; i < n; i++) {
        if(black[i]){
            std::cout << "0" << std::endl;
        }else{
            std::cout << "1" << std::endl;
        }
    }
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:22: error: expected ';' before 'Fill'
   22 |     Fill(black,false)
      |                      ^
      |                      ;
   23 |     Fill(done,false);
      |     ~~~~
Language: C++

#include "bits/stdc++.h"

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;

#include "Graph.h"

vector<int> color;

void paint(int s, int d, Weight w, Graph& g) {
	color[d] = (color[s] + w) % 2;
	for (const auto &p_e : g.vertices[d]->edges) {
		int nd = p_e->p_dst->id;
		if (nd == s)
			continue;
		paint(d, nd, p_e->weight, g);
	}
}

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

	color = vector<int>(N + 1);
	for (int i = 0; i < N - 1; i++)
	{
		int U = u[i];
		int W = w[i];
		g.add_edge(u[i], v[i], w[i]);
		g.add_edge(v[i], u[i], w[i]);
	}
	color[0] = 0;
	paint(0, 1, 0, g);

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


Compiler output:
a.cc:8:10: fatal error: Graph.h: No such file or directory
    8 | #include "Graph.h"
      |          ^~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
vector<ll> v[100005];
ll arr[100005][100005];
ll marked[100005];
void dfs_set(ll col,ll idx)
{
	marked[idx] = col;
	ll sz = v[idx].size();
	ll x;
	ll y;
	for(y= 0;y<sz;y++)
	{
		x = v[idx][y] ;
		
		if(marked[x]==0)
		{
			if(arr[idx][x]&1)
			{
				dfs_set(3-col,x);
			}
			else
			{
				dfs_set(col,x);
			}
		}
	}
}
int main()
{
	nfs;
	int t;
	t=1;
//	cin >> t;

	while(t--)
	{
		ll n;
		cin >> n;
		ll i;
		F(i,0,n-1)
		{
			ll a,b,w;
			cin >> a >> b >> w;
			v[a].p_b(b);
			v[b].p_b(a);
			arr[a][b] = w;
			arr[a][b] = w;
			
		}
		dfs_set(2,1);
		F(i,1,n+1)
		{
			cout << marked[i]-1 << endl;
		}	
	}
	return 0;

}



Compiler output:
/tmp/ccznNUWq.o: in function `dfs_set(long long, long long)':
a.cc:(.text+0x1f): relocation truncated to fit: R_X86_64_PC32 against symbol `marked' defined in .bss section in /tmp/ccznNUWq.o
a.cc:(.text+0x9f): relocation truncated to fit: R_X86_64_PC32 against symbol `marked' defined in .bss section in /tmp/ccznNUWq.o
/tmp/ccznNUWq.o: in function `main':
a.cc:(.text+0x291): relocation truncated to fit: R_X86_64_PC32 against symbol `marked' defined in .bss section in /tmp/ccznNUWq.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007

vector<pair<ll,ll> > adj[100005];
ll c[100005];

void dfs(ll x)
{
	for(ll i = 0 ; i < adj[x].size() ; i++)
	{
		ll adjver = adj[x][i].first;
		ll w1 = adj[x][i].second;

		//cout<<adjver<<" "<<x<<" "<<w1<<""<<c[adjver]<<endl;

		if(c[adjver] == -1)
		{
			if(w1 % 2 == 0)
			{
				c[adjver] = c[x];
			}
			else
			{
				c[adjver] = c[x] ^ 1;
			}

			dfs(adjver);

		}

	}
}

int main()
{
	ll n;
	cin>>n;

	for(ll i = 0 ; i < n - 1; i++)
	{
		ll u,v,w;
		cin>>u>>v>>w;

		u--;
		v--;

		adj[u].push_back({v,w});
		adj[v].push_back({u,w});

	}


	for(ll i = 0 ; i < n ; i++)
	{
		c[i] = -1;
	}

	for(ll i = 0 ; )

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

}	

Compiler output:
a.cc: In function 'int main()':
a.cc:63:24: error: expected primary-expression before ')' token
   63 |         for(ll i = 0 ; )
      |                        ^
a.cc:63:23: error: expected ';' before ')' token
   63 |         for(ll i = 0 ; )
      |                       ^~
      |                       ;
Language: C++

#include <iostream>

constexpr int MAX_N = 100000;

int N;
int edges[MAX_N][MAX_N];
int distance[MAX_N];

void dfs(int n = 0, int prev = 0);

int main(){

	std::cin >> N;

	for(int i = 0; i < N - 1; ++i){

		int u, v, w;

		std::cin >> u >> v >> w;

		--u, --v;

		edges[u][v] = edges[v][u] = w;
	}

	dfs();

	for(int i = 0; i < N; ++i){
		if(distance[i] % 2 == 0){
			std::cout << 1 << std::endl;
		}
		else{
			std::cout << 0 << std::endl;
		}
	}

	return 0;
}

void dfs(int n, int prev){

	for(int i = 0; i < N; ++i){
		if(i != prev && edges[n][i] != 0){
			distance[i] = distance[n] + edges[n][i];
			dfs(i, n);
		}
	}
}


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

#include <iostream>

constexpr int MAX_N = 100000;

int N;
int edges[MAX_N][MAX_N];
int distance[MAX_N];

void dfs(int n = 0, int prev = 0);

int main(){

	std::cin >> N;

	for(int i = 0; i < N - 1; ++i){

		int u, v, w;

		std::cin >> u >> v >> w;

		--u, --v;

		edges[u][v] = edges[v][u] = w;
	}

	dfs();

	for(int i = 0; i < N; ++i){
		if(distance[i] % 2 == 0){
			std::cout << 1 << std::endl;
		}
		else{
			std::cout << 0 << std::endl;
		}
	}

	return 0;
}

void dfs(int n, int prev){

	for(int i = 0; i < N; ++i){
		if(i != prev && edges[n][i] != 0){
			distance[i] = distance[n] + edges[n][i];
			dfs(i, n);
		}
	}
}


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

#include <iostream>
using namespace std;

const int INF = 100001;

int N;
int Graph[INF][INF] = {0};
int color[INF] = {0};

void visit(int parent)
{
	cout << parent << " " << color[parent] << endl;
	for(int i=0;i<N;i++){
		if(Graph[parent][i] != 0 && color[i] == 0){
			if(Graph[parent][i]%2 == 0){
				color[i] = color[parent];
			}else{
				color[i] = -1*color[parent];
			}
			visit(i);
		}
	}
}

int main()
{
	cin >> N;

	for(int i=0;i<N-1;i++){
		int a,b,w;
		cin >> a >> b >> w;
		Graph[a-1][b-1] = Graph[b-1][a-1] = w;
	}

	color[0] = -1;
	visit(0);

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

	return 0;
}

Compiler output:
/tmp/ccRo1csd.o: in function `visit(int)':
a.cc:(.text+0x47): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccRo1csd.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccRo1csd.o
a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccRo1csd.o
a.cc:(.text+0x11a): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccRo1csd.o
a.cc:(.text+0x133): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccRo1csd.o
a.cc:(.text+0x14e): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccRo1csd.o
/tmp/ccRo1csd.o: in function `main':
a.cc:(.text+0x275): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccRo1csd.o
a.cc:(.text+0x2a0): relocation truncated to fit: R_X86_64_PC32 against symbol `color' defined in .bss section in /tmp/ccRo1csd.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>

#define BIG 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;

typedef struct nod{
    vector<pair<long,long>> edges;
} Node;

void draw(const vector<Node>& nodes,vector<bool>& cs, long cpos,long lastp){
    Node node = nodes[cpos];
    for(auto au = node.edges.begin();au != node.edges.end();++au){
        if((*au).first == lastp)continue;
        cs[(*au).first] = (*au).second % 2 == 0 ? cs[cpos] : !cs[cpos];
        //  cout << "cpos = " << cpos << " to = " << (*au).first << " w = " << (*au).second << " new color = " << cs[(*au).first] << endl;
        draw(nodes,cs,(*au).first,cpos);
    }
}

int main() {
    long n;
    cin >> n;
    vector<Node> nodes(n,{});
    for(int i = 0;i < n - 1;++i){
        long u,v,w;
        cin >> u >> v >> w;
        --u;
        --v;
        nodes[u].edges.push_back(pair<long,long>(v,w));
        nodes[v].edges.push_back(pair<long,long>(u,w));
    }
    vector<bool> cls(n,false);
    cls[0] = true;
    draw(nodes,cls,0,-1);
    for(auto au = cls.begin();au != cls.end();++au){
        cout << (*au) << endl;
    }
}







Compiler output:
a.cc: In function 'int main()':
a.cc:34:28: error: call of overloaded 'vector(long long int&, <brace-enclosed initializer list>)' is ambiguous
   34 |     vector<Node> nodes(n,{});
      |                            ^
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = nod; _Alloc = std::allocator<nod>; size_type = long unsigned int; value_type = nod; allocator_type = std::allocator<nod>]'
  569 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = nod; _Alloc = std::allocator<nod>; size_type = long unsigned int; allocator_type = std::allocator<nod>]'
  556 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
Language: C++

#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>

#define BIG 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;

typedef struct n{
    vector<pair<long,long>> edges;
} Node;

void draw(const vector<Node>& nodes,vector<bool>& cs, long cpos,long lastp){
    Node node = nodes[cpos];
    for(auto au = node.edges.begin();au != node.edges.end();++au){
        if((*au).first == lastp)continue;
        cs[(*au).first] = (*au).second % 2 == 0 ? cs[cpos] : !cs[cpos];
      //  cout << "cpos = " << cpos << " to = " << (*au).first << " w = " << (*au).second << " new color = " << cs[(*au).first] << endl;
        draw(nodes,cs,(*au).first,cpos);
    }
}

int main() {
    long n;
    cin >> n;
    vector<Node> nodes(n,{});
    for(int i = 0;i < n - 1;++i){
        long u,v,w;
        cin >> u >> v >> w;
        --u;
        --v;
        nodes[u].edges.push_back(pair<long,long>(v,w));
        nodes[v].edges.push_back(pair<long,long>(u,w));
    }
    vector<bool> cls(n,false);
    cls[0] = true;
    draw(nodes,cls,0,-1);
    for(auto au = cls.begin();au != cls.end();++au){
        cout << (*au) << endl;
    }
}







Compiler output:
a.cc: In function 'int main()':
a.cc:34:28: error: call of overloaded 'vector(long long int&, <brace-enclosed initializer list>)' is ambiguous
   34 |     vector<Node> nodes(n,{});
      |                            ^
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = n; _Alloc = std::allocator<n>; size_type = long unsigned int; value_type = n; allocator_type = std::allocator<n>]'
  569 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = n; _Alloc = std::allocator<n>; size_type = long unsigned int; allocator_type = std::allocator<n>]'
  556 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
Language: Java

import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] d = new int[n];
        Arrays.fill(d, 1, n, Integer.MAX_VALUE);
        Map<Integer, Map<Integer, Integer>> dist = new HashMap<>();
        for (int i = 0; i < n; i++) {
            dist.put(i, new HashMap<>());
        }

        for (int i = 0; i < n - 1; i++) {
            int u = scanner.nextInt() - 1;
            int v = scanner.nextInt() - 1;
            int w = scanner.nextInt() & 1;
            dist.get(u).put(v, w);
            dist.get(v).put(u, w);
        }

        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(0);
        while (!deque.isEmpty()) {
            int i = deque.poll();
            for (Map.Entry<Integer, Integer> entry : dist.get(i).entrySet()) {
                Utils.println(i, entry.getKey(), entry.getValue());
                if (d[entry.getKey()] > d[i] + entry.getValue()) {
                    d[entry.getKey()] = d[i] + entry.getValue();
                    deque.add(entry.getKey());
                }
            }
        }

        for (int i : d) {
            System.out.println(i & 1);
        }
    }
}

Compiler output:
Main.java:28: error: cannot find symbol
                Utils.println(i, entry.getKey(), entry.getValue());
                ^
  symbol:   variable Utils
  location: class Main
1 error
Language: C++

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int n;
vector < pair < int , int > > E[100005];
int color[100005];

void dfs( int u, int par, int c ){
	color[u] = c;
  	for ( pair < int , int > e : E[u] ){
    	if ( e.first == par ) continue;
     	if ( e.second & 1 ) dfs(v,u,c^1);
      	else dfs(v,u,c);
    }
}

int main(){
  scanf("%d",&n);
  for ( int i = 0; i < n-1; i++ ){
  	int u,v,z;
    scanf("%d%d%d",&u,&v,&z);
    E[u].push_back(make_pair(v,z));
    E[v].push_back(make_pair(u,z));
  }
  
  dfs(1,-1,0);
  for ( int i = 1; i <= n; i++ ) printf("%d\n",color[i]);
  return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:14:33: error: 'v' was not declared in this scope
   14 |         if ( e.second & 1 ) dfs(v,u,c^1);
      |                                 ^
a.cc:15:18: error: 'v' was not declared in this scope
   15 |         else dfs(v,u,c);
      |                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end() 
#define endl "\n"
#define int long long int
#define ll long long
#define ld long double
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
const int mod = 1000000007;
const int N=200005;
const int inf=1e18;


bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}

void fun(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


signed main(){
    flash;
    fun();
    int t=1;
    //cin>>t;
    while(t--){
        int n,m,z;
        cin>>n>>m;
        int x,y;
        set<int> s;
        for(int i=0;i<m;i++){
            cin>>x>>y>>z;
            s.insert(y);
        }
        int p=abs(n-s.size());
        cout<<p<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:18: error: call of overloaded 'abs(long long unsigned int)' is ambiguous
   53 |         int p=abs(n-s.size());
      |               ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end() 
#define endl "\n"
#define int long long int
#define ll long long
#define ld long double
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
const int mod = 1000000007;
const int N=200005;
const int inf=1e18;


bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}

void fun(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


signed main(){
    flash;
    fun();
    int t=1;
    //cin>>t;
    while(t--){
        int n,m,z;
        cin>>n>>m;
        int x,y;
        set<int> s;
        for(int i=0;i<m;i++){
            cin>>x>>y>>z;
            s.insert(y);
        }
        cout<<abs(n-s.size())<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:18: error: call of overloaded 'abs(long long unsigned int)' is ambiguous
   53 |         cout<<abs(n-s.size())<<endl;
      |               ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
Language: C++

#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int INF = 0x3f3f3f3f;
const ll  LINF = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

int p[maxn],sz[maxn];

int find_set(int x){
    return p[x] = (p[x] == x ? x:find_set(p[x]));
}


void union_set(int x,int y){
    x = find_set(x);
    y = find_set(y);
    if(x==y) return;
    if(sz[x] > sz[y]) swap(x,y);
    p[x]=y;
    sz[y]+=sz[x];
    --ans;
}

void solve(){
	int n,m,ans=0;
    cin >> n >> m;
    ans=n;
    for(i=0;i<n;++i){ 
        int x,y,z;
        cin >> x >> y >> z;
        union_set(x,y);
    }
    cout << ans << endl;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t = 1;

    // cin >> t;

    start();

    while(t--){
    	solve();
    }

    return 0;
}

Compiler output:
a.cc: In function 'void union_set(int, int)':
a.cc:35:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |     --ans;
      |       ^~~
      |       abs
a.cc: In function 'void solve()':
a.cc:42:9: error: 'i' was not declared in this scope
   42 |     for(i=0;i<n;++i){
      |         ^
a.cc: In function 'int32_t main()':
a.cc:59:5: error: 'start' was not declared in this scope
   59 |     start();
      |     ^~~~~
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}
int n,m;
vector< vector<int> >adj(1e5+10);
vector<bool>b(1e5+10,0);
map< pair<int,int>,int>mp;
dfs(int v,int prev){
   b[v] = 1;
   for(int i = 0;i<adj[v].size();i++){
    int vi = adj[v][i];
    if(b[vi]==1) continue;
    dfs(vi,v);
   }
}
void solve(){
   cin >> n >> m;
   for(int i = 0;i<m;i++){
    int v,u,z;cin >> v >> u >> z;
    adj[v].push_back(u);
    adj[u].push_back(v);
    mp[{v,u}] = z;
    mp[{u,v}] = z;
}
    int ans = 0;
    for(int i = 1;i<=n;i++){
        if(!b[i]){
            dfs(i,0);
            ans ++;
        }
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Compiler output:
a.cc:33:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
   33 | dfs(int v,int prev){
      | ^~~
a.cc: In function 'int dfs(int, int)':
a.cc:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
   40 | }
      | ^
Language: C++

#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  1e6+5;
const ll   mod   =  1e9;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n, m, p[N], sz[N];

void make(ll n){
	for(int i = 1; i <= n; i++){
		p[i] = i;
		sz[i] = 1;
	}
}

int find(ll x){
	return (p[x] == x)? x: p[x] = find(p[x]);
}

void merge(ll x, ll y){
	ll a = find(x);
	ll b = find(y);
	if(a != b){
		if(sz[a] >= sz[b]) swap(a,b);
		p[a] = b;
		sz[b] += sz[a];
	}
}

void dfs(int x){
	v.pb(x);
	vis[x] = 1;
	for(auto it : rail[x]){
		if(!vis[it]) dfs(it);
	}
}

void solve(){
	cin >> n >> m;
	make(n);
	for(int i = 1; i <= m; i++){
		int u, v, z; cin >> u >> v >> z;
		merge(u,v);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(find(i) == i) ans++;
	}
	deb1(ans)
}

int main(){
	GODSPEED;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:57:9: error: 'v' was not declared in this scope
   57 |         v.pb(x);
      |         ^
a.cc:58:9: error: 'vis' was not declared in this scope
   58 |         vis[x] = 1;
      |         ^~~
a.cc:59:23: error: 'rail' was not declared in this scope
   59 |         for(auto it : rail[x]){
      |                       ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <set>

using namespace std;

int hoge(vector<int> &vec, int x) {
  if (x == vec[x])
    return x;
  return vec[x] = hoge(vec, vec[x]);
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n + 1);
  for (int i = 1; i <= n; ++i)
    vec[i] = i;
  while (m--) {
    int x, y, z;
    cin >> x >> y >> z;
    vec[x] = y;
  }

  for (int i = 1; i <= n; ++i)
    hoge(vec, i);

  set<int> s;
  for (int i= 1; i <= n; ++i)
    s.insert(vec[i]);

  cout << static_cast<int>(s.size()) << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:32:46: error: expected '}' at end of input
   32 |   cout << static_cast<int>(s.size()) << endl;
      |                                              ^
a.cc:13:12: note: to match this '{'
   13 | int main() {
      |            ^
Language: C++

#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;


vll par(MAX),siz(MAX);

//par[i]=iならiは根（はじめは全て根）
void init(ll n){
  rep(i,0,n){
    par[i]=i;siz[i]=1LL;
  }
  return;
}
//xの根
ll root(ll x){
  return (par[x]==x)?x:par[x]=root(par[x]);
}
//xが根の木とyが根の木を繋げる
void unite(ll x,ll y){
  x=root(x);y=root(y);
  if(x==y){return;}
  if(siz[x]<siz[y]){swap(x,y);}
  siz[x]+=siz[y];
  par[y]=x;
}
//根が同じかどうか
bool same(ll x,ll y){
  return root(x)==root(y);
}
int main(){
  ll n,m;cin>>n>>M;
  init(n);
  rep(i,0,m){
    ll x,y,z;cin>>x>>y>>z;
    unite(x-1,y-1);
  }
  set<ll>s;
  rep(i,0,n){
    
    s.insert(root(i));
  }
  cout<<s.size()<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:48:18: error: 'M' was not declared in this scope
   48 |   ll n,m;cin>>n>>M;
      |                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  int n;
  cin>>n;
  vector<vector<int>>we(n+1,vector<int>(n+1));
  vector<vector<int>>ue(n+1);
  for(int i=1;i<=n;i++){
    int u,v,w;
    cin>>u>>v>>w;
    ue[v].push_back(u);
    ue[u].push_back(v);
    we[u][v]=w;
    we[v][u]=w;
  }
  queue<int>q;
  q.push(1);
  vector<int>l(n+1);
  vector<bool>c(n+1);
  c[1]=true;
  while(!q.empty()){
    int x=q.front();
    q.pop();
    int z=ue[x].size();
    for(int i=0;i<z;i++){
      int y=ue[x][i];
      if(!c[y]){
        q.push(y);
        l[y]=l[x]+we[x][y];
        c[y]=true;
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<l[i]%2<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:2: error: expected '}' at end of input
   38 | }
      |  ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

//# define MAX_N 1000010 // 10^6 + 10
class UnionFind{
    private:
  		int MAX_N = 1000010;
        int par_[MAX_N];
        int rank_[MAX_N];
        int groups_;
    
    public:
        void init(int n){ // initializes the tree 
            for(int i=0; i<n; i++){
                par_[i] = i;
                rank_[i] = 0;
            }
            groups_ = n;
        } 
        int rootOf(int x){ // returns the root of x 
            if(par_[x] == x){
                return x;
            }
            else{
                return par_[x] = rootOf(par_[x]);
            }
        } 
        void unite(int x, int y){ // unites x and y 
            x = rootOf(x);
            y = rootOf(y);
            if(x == y) return;
            if(rank_[x] < rank_[y]){
                par_[x] = y;
                groups_--;
            }
            else{
                par_[y] = x;
                groups_--;
                if(rank_[x] == rank_[y]) rank_[x]++;
            }
        }
        bool isSameGroupe(int x, int y){ // whether x and y are united
            return rootOf(x) == rootOf(y);
        }
        int countGroups(){ // returns the number of groups
            return groups_;
        }
};

int main(void){
    int n, m;
    cin >> n >> m;

    UnionFind tree;
    tree.init(n);

    vector<int> x(m), y(m), z(m);
    for(int i=0; i<m; i++){
        cin >> x[i] >> y[i] >> z[i];
        tree.unite(x[i], y[i]);
    }

    int ans = tree.countGroups();
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc:11:18: error: invalid use of non-static data member 'UnionFind::MAX_N'
   11 |         int par_[MAX_N];
      |                  ^~~~~
a.cc:10:21: note: declared here
   10 |                 int MAX_N = 1000010;
      |                     ^~~~~
a.cc:12:19: error: invalid use of non-static data member 'UnionFind::MAX_N'
   12 |         int rank_[MAX_N];
      |                   ^~~~~
a.cc:10:21: note: declared here
   10 |                 int MAX_N = 1000010;
      |                     ^~~~~
a.cc: In member function 'void UnionFind::init(int)':
a.cc:18:17: error: 'par_' was not declared in this scope
   18 |                 par_[i] = i;
      |                 ^~~~
a.cc:19:17: error: 'rank_' was not declared in this scope; did you mean 'rand_r'?
   19 |                 rank_[i] = 0;
      |                 ^~~~~
      |                 rand_r
a.cc: In member function 'int UnionFind::rootOf(int)':
a.cc:24:16: error: 'par_' was not declared in this scope
   24 |             if(par_[x] == x){
      |                ^~~~
a.cc: In member function 'void UnionFind::unite(int, int)':
a.cc:35:16: error: 'rank_' was not declared in this scope; did you mean 'rand_r'?
   35 |             if(rank_[x] < rank_[y]){
      |                ^~~~~
      |                rand_r
a.cc:36:17: error: 'par_' was not declared in this scope
   36 |                 par_[x] = y;
      |                 ^~~~
a.cc:40:17: error: 'par_' was not declared in this scope
   40 |                 par_[y] = x;
      |                 ^~~~
Language: C

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

int main(void) {

static int i,j,l,N,M,x,y,z,a,b,c,sum,fin;
scanf_s("%d ", &N);
scanf_s("%d\n", &M);

int **An;
An = malloc(sizeof(int *) * N);

for (i = 0; i < N; i++) {
An[i] = malloc(sizeof(int) * N);
}

for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
An[i][j] = 0;
}
}

for (i = 0; i < M; i++) {

scanf_s("%d ", &x);
scanf_s("%d ", &y);
scanf_s("%d\n", &z);

An[x][y] = An[y][x] = 1;
An[x][0]++;
An[y][0]++;
}

do {
for (i = 0; i < N; i++) {
a = An[i + 1][0];
if (a >= b) {
b = a;
c = i;
}
}

if (b == 0) fin = 1;
b = 0;

for (j = i + 1; j <= N; j++) {
if (An[i][j] == 1) {
An[i][j] = An[j][i] = 0;
An[i][0]--;
An[j][0]--;
sum++;
for (l = 1; l <= N; l++) {
if (An[j][l] == 1) {
An[j][l] = An[l][j] = 0;
An[j][0]--;
An[l][0]--;
sum++;
}
}
}
}
} while (fin == 0);

printf("%d\n", (N - sum));

for (i = 0; i < N; i++) {
free(An[i]);
}
free(An);
return 0;

}


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

#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;





struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main()
{
	int n,m;
	cin>>n>>m;
vector<vector<int>> g(n);
UnionFind uf(n);
int ans=n;

	rep(i,m){
		int x,y,z;
		cin>>x>>y>>z;
		x--;y--;
		g[x].emplace_back(y);
		g[y].emplace_back(x);
		if uf.same(x) continue;
		ans--;
		uf.unite(x,y);

	}
	cout<<ans;



}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:20: error: expected '(' before 'uf'
   55 |                 if uf.same(x) continue;
      |                    ^~
      |                    (
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
// Union Find

template<typename T>
struct UnionFind
{
	vector<T> par;
	vector<T> rank;
	vector<T> sizes;
	UnionFind(T n):par(n),rank(n,0),sizes(n,1){
	   for(T i=0;i<n;i++){
	     par[i]=i;
	   }
	}
	T root(T x){
	  return par[x]==x?x:par[x]=root(par[x]);
	}

	bool unite(T x,T y){
	  if(x==y) return false;
	  x=root(x); y=root(y);
	  if(x==y) return false;
	  if(rank[x]<rank[y]) swap(x,y);
	  if(rank[x]==rank[y]) rank[x]++;
	  par[y]=x;
	  sizes[x]=sizes[x]+sizes[y];
	  return true;
	}
	bool same(T x,T y){
	  return root(x)==root(y);
	}
	T size(T x){
	  return sizes[root(x)];
	}
};
int main(){
  ll n,m;
  cin>>n>>m;
  UnionFind<ll> uf(n+1);
  rep(i,m){
    ll x,y,z,;
    cin>>x>>y>>z;
    uf.unite(x,y);
  }
  set<ll> ans;
  for(int i=1;i<=n;i++){
    ans.insert(uf.root(i));
  }
  COUT(sz(ans));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:81:14: error: expected unqualified-id before ';' token
   81 |     ll x,y,z,;
      |              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
struct Union{
  vector<int> par;
  Union(int a){
  par=vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(int a,int b){
    return (find(a)==find(b));
  }
  int size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    int c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
int main(){
  int n,m,ans=0;
  cin >> n >> m;
  Union qwerty(n);
  vector<int> x(m),y(m),z(m);
  for(int i=0;i<m;i++){
    cin >> x[i] >> y[i] >> z[i];
    qwerty.unite(x[i],y[i]);
  }
  set<int> q;
  for(int i=0;i<n;i++){
    q=qwerty.find(i);
  }
  cout << q.size() << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:20: error: no match for 'operator=' (operand types are 'std::set<int>' and 'int')
   44 |     q=qwerty.find(i);
      |                    ^
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:300:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(const std::set<_Key, _Compare, _Alloc>&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  300 |       operator=(const set&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_set.h:300:17: note:   no known conversion for argument 1 from 'int' to 'const std::set<int>&'
  300 |       operator=(const set&) = default;
      |                 ^~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:304:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(std::set<_Key, _Compare, _Alloc>&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  304 |       operator=(set&&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_set.h:304:17: note:   no known conversion for argument 1 from 'int' to 'std::set<int>&&'
  304 |       operator=(set&&) = default;
      |                 ^~~~~
/usr/include/c++/14/bits/stl_set.h:318:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  318 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_set.h:318:46: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
  318 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~