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

# include <bits/stdc++.h>

using namespace std;

int ufd[101010];

// find checks whether both a and b belong to the same set. If not, it creates an edge between them.
int find (int x)
{
    if (x == ufd[x])
        {
            return x;        
        }
    return ufd[x] = find(ufd[x]);
}


void Union (int a, int b)
{
    ufd[find(a)] = find(b):
}

// Initially, all n elements are disjoint but as we get new inputs, we are able to create sets for them. if i != ufd[i], implies (i, ufd[i]) have an edge between them.

int main() 
{
    int n, m;
    scanf("%d%d", &n, &m);
    
    for (int i = 1; i <= n; i++)
        {
            ufd[i] = i;        
        }
    
    for (int i = 0; i < m; i++)
        {
            int x, y;
            scanf("%d%d%*d", &x, &y);
            
            // Perform disjoint set union of the two inputs
            Union(x, y);         
        }

    int ans = 0;
    for (int i = 1; i <= n; i++)
        {
            if (i == find(i))
                {
                    ++ans;
                }        
        }    
    printf("%d\n", ans);
    
    return 0;
}

Compiler output:
a.cc: In function 'void Union(int, int)':
a.cc:20:27: error: expected ';' before ':' token
   20 |     ufd[find(a)] = find(b):
      |                           ^
      |                           ;
Language: C++

/*
我的心脏怦怦跳，监管者就在附近
*/
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<windows.h>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
int a[1001],b[1001],z;int f[100001];
int find(int x)
{
	if(x==f[x])
	{
		return x;
	}
	else
	{
		return f[x]=find(f[x]);
	}
}
int main()
{
	int n,m,cut=0;
	cin>>n>>m;int i;
	for(i=1;i<=n;i++)
	{
		f[i]=i;
	}
	int x,y,z;
	for(i=0;i<m;i++)
	{
		cin>>x>>y>>z;
		int fx=find(x),fy=find(y);
		if(fx!=fy) {
			f[fx]=fy;cut++;
		}
	}
	cout<<n-cut;
	return 0;
}


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

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

Compiler output:
a.cc:3:2: error: #else without #if
    3 | #else
      |  ^~~~
a.cc:5:2: error: #endif without #if
    5 | #endif
      |  ^~~~~
a.cc:27:9: warning: "trace" redefined
   27 | #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
      |         ^~~~~
a.cc:4:9: note: this is the location of the previous definition
    4 | #define trace(...)
      |         ^~~~~
a.cc:26: error: unterminated #ifdef
   26 | #ifdef TRACE
a.cc: In function 'void __f(const char*, Arg1&&)':
a.cc:6:21: error: expected unqualified-id before '\xa'
    6 | #define endl        '\n'
      |                     ^~~~
a.cc:33:48: note: in expansion of macro 'endl'
   33 |     std::cerr << name << " = " << arg1 << std::endl;
      |                                                ^~~~
a.cc:33:46: error: expected ';' before '\xa'
   33 |     std::cerr << name << " = " << arg1 << std::endl;
      |                                              ^
      |                                              ;
Language: C

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

int max_array_point(int ary[], int ary_num) {
  int i;
  int max = -1;
  int point = 0;
  for(i = 0; i < ary_num; i++) {
    if(max < ary[i]) {
      max = ary[i];
      point = i;
    }
  }
  return point;
}

int main() {
  int i;

  int n_val, m_val, x_val[100000], y_val[100000], z_val[100000];
  scanf("%d %d", &n_val, &m_val);
  for(i = 0; i < m_val; i++) scanf("%d %d %d", &x_val[i], &y_val[i], &z_val[i]);

  int *card_flag;
  card_flag = (int *)malloc(sizeof(int) * (n_val + 1));
  for(i = 0; i < n_val + 1; i++) card_flag[i] = 0;

  int *hint_flag;
  hint_flag = (int *)malloc(sizeof(int) * (m_val));
  for(i = 0; i < m_val; i++) hint_flag[i] = 0;

  int num_hint[100000 + 1] = {0};
  for(i = 0; i < m_val; i++) {
    num_hint[x_val[i]]++;
    num_hint[y_val[i]]++;
  }

  int num_magic = 0;
  int num_hint_max;
  while(1) {
    num_hint_max = max_array_point(num_hint, n_val + 1);
    if(card_flag[num_hint_max] == 0) {
      for(i = 0; i < m_val; i++) {
        if(hint_flag[i] == 0
         && (x_val[i] == num_hint_max || y_val[i] == num_hint_max)) {
          hint_flag[i] = 1;
          card_flag[x_val[i]] = 1;
          card_flag[y_val[i]] = 1;
        }
      }
      num_magic++;
    }
    num_hint[num_hint_max] = 0;
    int repeat_flag = 0;
    for(i = 1; i < n_val + 1; i++) {
      if(card_flag[i] == 0) repeat_flag++;
    }
    if(repeat_flag == 0) break;
    for(i = 0; i < m_val; i++) {
      if(card_flag[x_val[i]] == 1 && card_flag[y_val[i]] == 1) {
        hint_flag[i] = 1;
      }
    }
    int repeat_flag = 0;
    for(i = 0; i < m_val; i++) {
      if(hint_flag[i] == 0) repeat_flag++;
    }
    if(repeat_flag == 0) break;
  }

  for(i = 1; i < n_val + 1; i++) {
    if(card_flag[i] == 0) num_magic++;
  }

  printf("%d\n", num_magic);

  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:64:9: error: redefinition of 'repeat_flag'
   64 |     int repeat_flag = 0;
      |         ^~~~~~~~~~~
main.c:54:9: note: previous definition of 'repeat_flag' with type 'int'
   54 |     int repeat_flag = 0;
      |         ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

struct UnionFind
{
    vector<int> par, rank;
    UnionFind(int N) : par(N), rank(N)
    {
        REP(i, N)
        {
            par[i] = i;  //the parent of the node
            rank[i] = 0; //the rank of the tree
        }
    }
    int find(int x)
    { //Find the root of x
        if (par[x] == x)
        {
            return x;
        }
        else
        {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y)
    { //Unite (the set of x) and (the set of y)
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (rank[x] < rank[y])
        { //larger rank is above
            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);
    }
};

int main()
{
    int n,m;
    cin >> n >> m;
    UnionFind gp(n);
    int x[m], y[m], z[m];
    REP(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        x[i] = a - 1;
        y[i] = b - 1;
        z[i] = c % 2;
    }
    REP(i,m){
        gp.unite(x[i], y[i]);
    }
    set<int> parset;
    REP(i, n){
        parset.insert(gp.find[i]);
    }
    cout << parset.size() << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:81:30: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   81 |         parset.insert(gp.find[i]);
      |                              ^
Language: Java

import java.util.Scanner;

import tool.Tools.UnionFind;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[] X = new int[M];
        int[] Y = new int[M];
        int[] Z = new int[M];
        for (int i = 0; i < M; i++) {
            X[i] = scanner.nextInt() - 1;
            Y[i] = scanner.nextInt() - 1;
            Z[i] = scanner.nextInt() - 1;
        }
        UnionFind find = new UnionFind(N);
        for (int i = 0; i < M; i++) {
            find.connect(X[i], Y[i]);
        }
        boolean[] ans = new boolean[N];
        for (int i = 0; i < N; i++) {
            ans[find.root(i)] = true;
        }
        int cnt = 0;
        for (boolean b : ans) {
            if (b) {
                cnt++;
            }
        }
        System.out.println(cnt);

    }
}


Compiler output:
Main.java:3: error: package tool.Tools does not exist
import tool.Tools.UnionFind;
                 ^
Main.java:19: error: cannot find symbol
        UnionFind find = new UnionFind(N);
        ^
  symbol:   class UnionFind
  location: class Main
Main.java:19: error: cannot find symbol
        UnionFind find = new UnionFind(N);
                             ^
  symbol:   class UnionFind
  location: class Main
3 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,count=0;
  cin>>n>>m;
  int ax[m];ay[m];az[m];
  int ar[n];
  for(int i=0;i<m;++i)
  {
    cin>>ax[i]>>ay[i]>>az[i];
  }
  count++;
  ar[ax[0]-1]=1;
  ar[ay[0]-1]=1;
  for(int i=1;i<m;++i)
  {
    if((ax[i]==1)||(ay[i]==1)){ar[ax[i]-1]=1;ar[ay[i]-1]=1;}
    else{count++;ar[ax[i]-1]=1;ar[ay[i]-1]=1;}
  }
  for(int i=0;i<n;++i)
  {
    if(ar[i]!=1){count++;}
  }
  cout<<count;
         

Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: error: 'ay' was not declared in this scope; did you mean 'ax'?
    7 |   int ax[m];ay[m];az[m];
      |             ^~
      |             ax
a.cc:7:19: error: 'az' was not declared in this scope; did you mean 'ax'?
    7 |   int ax[m];ay[m];az[m];
      |                   ^~
      |                   ax
a.cc:25:15: error: expected '}' at end of input
   25 |   cout<<count;
      |               ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int Search(int n, const vector<int> &par) {
	if (par[n] == n)
		return n;
	else
		return Search(par[n], par);
}

void uni(const int a, const int b, vector<int> &par, vector<int> &dep) {
	if (dep[a] < dep[b])
		par[a] = b;
	else if (dep[a] > dep[b])
		par[b] = a;
	else {
		par[b] = a;
		dep[a]++;
	}
}

int main(void) {
	int num, m, a, b, z, i = 0, j, ans = 0;
	scanf_s("%d%d", &num, &m);
	vector<int> par(num + 1), dep(num + 1, 0), exi(num + 1, true);
	for (; i <= num; i++)
		par[i] = i;
	for (i = 0; i < m; i++) {
		scanf("%d%d%d", &a, &b, &z);
		a = Search(a, par);
		b = Search(b, par);
		if (a != b)
			uni(a, b, par, dep);
	}
	for (i = 1; i <= num; i++) {
		a = Search(i, par);
		if (exi[a]) {
			ans++;
			exi[a] = false;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   26 |         scanf_s("%d%d", &num, &m);
      |         ^~~~~~~
      |         scanf
Language: C++

#include "bits/stdc++.h"
using ll = long long;
using namespace std;

vector<ll> ans(N+1);


void find(ll x,ll y){
ans[x]=y;
}
void uni(ll x,ll y){
find(x,y);
}




int main(){
ll N;
cin>>N;
ll x,y,z;

for(ll i=0;i<=N;i++){
ans[i]=i;
}

for(ll i=0;i<N;i++){
cin>>x>>y>>z;
uni(x,y);
}
z=0;
for(ll i=1;i<=N;i++){
if(ans[i]==i)
        z++;

}


}


Compiler output:
a.cc:5:16: error: 'N' was not declared in this scope
    5 | vector<ll> ans(N+1);
      |                ^
Language: C++

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

vector<int> par(100000);
vector<int> ran(100000,1);

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

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

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> x(m),y(m),z(m);
  for(int i=0;i<m;i++)
    cin >> x[i] >> y[i] >> z[i];
  co=n;
  for(int i=0;i<m;i++){
    if(check(x[i]-1,y[i]-1)){
      int co--;
      unite(x[i]-1,y[i]-1);
    }
  }
  cout << co << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:3: error: 'co' was not declared in this scope; did you mean 'cos'?
   37 |   co=n;
      |   ^~
      |   cos
a.cc:40:13: error: expected initializer before '--' token
   40 |       int co--;
      |             ^~
Language: C++

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

vector<int> par(100000);
vector<int> ran(100000,1);

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

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

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> x(m),y(m),z(m);
  for(int i=0;i<m;i++)
    cin >> x[i] >> y[i] >> z[i];
  co=n;
  for(int i=0;i<m;i++){
    if(check(x[i]-1,y[i]-1)){
      co--;
      unite(x[i]-1,y[i]-1);
    }
  }
  cout << co << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:3: error: 'co' was not declared in this scope; did you mean 'cos'?
   37 |   co=n;
      |   ^~
      |   cos
Language: C++

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

int N,M,ans;
vector<int> visit;
vector<set<int> > adj;

void dfs(int i){
  visit[i]=1;
  for(int a:adj[i]) if(visit[a]==0) dfs(a);
}

int main(){
  cin >> N >> M;
  visit.resize(n+1);
  adj.resize(n+1);
  for(int i=0; i<M; ++i){
    int x,y,z; cin >> x >> y >> z;
    adj[x].insert(y);
    adj[y].insert(x);
  }

  for(int i=1; i<=N; ++i){
    if(visit[i]==0){
      ++ans;
      dfs(i);
    }
  }

  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:9:3: error: reference to 'visit' is ambiguous
    9 |   visit[i]=1;
      |   ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:5:13: note:                 'std::vector<int> visit'
    5 | vector<int> visit;
      |             ^~~~~
a.cc:10:24: error: reference to 'visit' is ambiguous
   10 |   for(int a:adj[i]) if(visit[a]==0) dfs(a);
      |                        ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:5:13: note:                 'std::vector<int> visit'
    5 | vector<int> visit;
      |             ^~~~~
a.cc: In function 'int main()':
a.cc:15:3: error: reference to 'visit' is ambiguous
   15 |   visit.resize(n+1);
      |   ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:5:13: note:                 'std::vector<int> visit'
    5 | vector<int> visit;
      |             ^~~~~
a.cc:15:16: error: 'n' was not declared in this scope
   15 |   visit.resize(n+1);
      |                ^
a.cc:24:8: error: reference to 'visit' is ambiguous
   24 |     if(visit[i]==0){
      |        ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:5:13: note:                 'std::vector<int> visit'
    5 | vector<int> visit;
      |             ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

typedef vector<int> vi;

void ff(vi e[], int x, bool v[]) {
    v[x] = true;
    for (int y : e[x]) {
        if (!v[y]) {
            ff(e, y, v);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vi e[n];
    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--
        e[x].push_back(y);
        e[y].push_back(x);
    }

    bool v[n];
    memset(v, 0, sizeof(v));
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (!v[i]) {
            ans++;
            ff(e, i, v);
        }
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: expected ';' before 'e'
   25 |         x--, y--
      |                 ^
      |                 ;
   26 |         e[x].push_back(y);
      |         ~
Language: C++

#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

typedef vector<int> vi;

void ff(vi e[], int x, bool v[]) {
    v[x] = true;
    for (int y : e[x]) {
        if (!v[y]) {
            ff(e, y, v);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vi e[n];
    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--
        e[x].push_back(y);
        e[y].push_back(x);
    }

    bool v[n];
    memset(v, 0, sizeof(v));
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (!v[i]) {
            ans++;
            ff(e, i);
        }
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: expected ';' before 'e'
   25 |         x--, y--
      |                 ^
      |                 ;
   26 |         e[x].push_back(y);
      |         ~        
a.cc:36:15: error: too few arguments to function 'void ff(vi*, int, bool*)'
   36 |             ff(e, i);
      |             ~~^~~~~~
a.cc:9:6: note: declared here
    9 | void ff(vi e[], int x, bool v[]) {
      |      ^~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> vi;

void ff(vi e[], int x, bool v[]) {
    v[x] = true;
    for (int y : e[x]) {
        if (!v[y]) {
            ff(e, y, v);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vi e[n];
    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--
        e[x].push_back(y);
        e[y].push_back(x);
    }

    bool v[n];
    memset(v, 0, sizeof(v));
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (!v[i]) {
            ans++;
            ff(e, i);
        }
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: expected ';' before 'e'
   24 |         x--, y--
      |                 ^
      |                 ;
   25 |         e[x].push_back(y);
      |         ~        
a.cc:30:5: error: 'memset' was not declared in this scope
   30 |     memset(v, 0, sizeof(v));
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <vector>
  +++ |+#include <cstring>
    3 | 
a.cc:35:15: error: too few arguments to function 'void ff(vi*, int, bool*)'
   35 |             ff(e, i);
      |             ~~^~~~~~
a.cc:8:6: note: declared here
    8 | void ff(vi e[], int x, bool v[]) {
      |      ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> tp;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
typedef pair<pii, int> piipi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<LL, pii> plpii;
typedef pair<LD, LD> pdd;
typedef pair<LD, int> pdi;
typedef pair<LD, LL> pdl;
typedef pair<int, LD> pid;
typedef pair<LL, LD> pld;
const int mod = 1e9 + 7;
const int hf = 999983;
const int N = 1e6;
int root(int a){
    return p[a] == a?a:(p[a]=root(p[a]));
}
void merge(int a, int b){
    a = root(a), b = root(b);
    if(a != b) p[a] = b;
}
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=n;i++) p[i] = i;
    for(int i=1;i<=m;i++){
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        merge(a, b);
    }   
    int ans = 0;
    for(int i=1;i<=n;i++) if(i == root(i)) ans++;
    printf("%d\n", ans);
}


Compiler output:
a.cc: In function 'int root(int)':
a.cc:23:12: error: 'p' was not declared in this scope
   23 |     return p[a] == a?a:(p[a]=root(p[a]));
      |            ^
a.cc: In function 'void merge(int, int)':
a.cc:27:16: error: 'p' was not declared in this scope
   27 |     if(a != b) p[a] = b;
      |                ^
a.cc: In function 'int main()':
a.cc:32:27: error: 'p' was not declared in this scope
   32 |     for(int i=1;i<=n;i++) p[i] = i;
      |                           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int> tree; 
int r
int root(int x){
  if (tree[x]==x){
    return x;
  }
  else{
  	int r=root(tree[x]);
    return tree[x] = r;
  }
}
int main(){
  int n,m;
  cin >>n>>m;
  int z;
  for (int i=0; i<n; i++){
    tree[i]=i;
  }
  vector<int> x(m);
  vector<int> y(m);
  int rx,ry;
  for (int i=0; i<m; i++){
    cin >> x[i] >> y[i] >> z;
    x[i]--;
    y[i]--;
    rx=root(x[i]);
    ry=root(y[i]);
    if(rx != ry){
      tree[rx] = ry;
    }
  }
  int count=0;
  for (int i=0; i<n; i++){
    if (tree[i]==i){
      count++;
    }
  }
  cout << count << endl;
}
   
   


Compiler output:
a.cc:5:1: error: expected initializer before 'int'
    5 | int root(int x){
      | ^~~
a.cc: In function 'int main()':
a.cc:28:8: error: 'root' was not declared in this scope
   28 |     rx=root(x[i]);
      |        ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int MAX=10000000
vector<int> tree(MAX); 
int root(int x){
  if (tree[x]==x){
    return x;
  }
  if (tree[x] != x){
    return tree[x] = root(tree[x]);
  }
}
int main(){
  int n,m;
  cin >>n>>m;
  int z;
  for (int i=0; i<n; i++){
    tree[i]=i;
  }
  vector<int> x(m);
  vector<int> y(m);
  int rx,ry;
  for (int i=0; i<m; i++){
    cin >> x[i] >> y[i] >> z;
    x[i]--;
    y[i]--;
    rx=root(x[i]);
    ry=root(y[i]);
    if(rx != ry){
      tree[rx] = ry;
    }
  }
  int count=0;
  for (int i=0; i<n; i++){
    if (tree[i]==i){
      count++;
    }
  }
  cout << count << endl;
}
   
   


Compiler output:
a.cc:4:1: error: expected ',' or ';' before 'vector'
    4 | vector<int> tree(MAX);
      | ^~~~~~
a.cc: In function 'int root(int)':
a.cc:6:7: error: 'tree' was not declared in this scope; did you mean 'free'?
    6 |   if (tree[x]==x){
      |       ^~~~
      |       free
a.cc:9:7: error: 'tree' was not declared in this scope; did you mean 'free'?
    9 |   if (tree[x] != x){
      |       ^~~~
      |       free
a.cc: In function 'int main()':
a.cc:18:5: error: 'tree' was not declared in this scope; did you mean 'free'?
   18 |     tree[i]=i;
      |     ^~~~
      |     free
a.cc:30:7: error: 'tree' was not declared in this scope; did you mean 'free'?
   30 |       tree[rx] = ry;
      |       ^~~~
      |       free
a.cc:35:9: error: 'tree' was not declared in this scope; did you mean 'free'?
   35 |     if (tree[i]==i){
      |         ^~~~
      |         free
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int> tree; 
int root(int x){
  if (tree[x]==x){
    return x;
  }
  if (tree[x] != x){
    return tree = root(tree[x]);
  }
}
int main(){
  int n,m;
  cin >>n>>m;
  int z;
  vector <int> tree(n);
  for (int i=0; i<n; i++){
    tree[i]=i;
  }
  vector<int> x(m);
  vector<int> y(m);
  int rx,ry;
  for (int i=0; i<m; i++){
    cin >> x[i] >> y[i] >> z;
    x[i]--;
    y[i]--;
    rx=root(x[i],tree);
    ry=root(y[i],tree);
    if(rx != ry){
      tree[rx] = ry;
    }
  }
  int count=0;
  for (int i=0; i<n; i++){
    if (tree[i]==i){
      count++;
    }
  }
  cout << count << endl;
}
   
   


Compiler output:
a.cc: In function 'int root(int)':
a.cc:9:31: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int')
    9 |     return tree = root(tree[x]);
      |                               ^
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:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'int' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc: In function 'int main()':
a.cc:27:12: error: too many arguments to function 'int root(int)'
   27 |     rx=root(x[i],tree);
      |        ~~~~^~~~~~~~~~~
a.cc:4:5: note: declared here
    4 | int root(int x){
      |     ^~~~
a.cc:28:12: error: too many arguments to function 'int root(int)'
   28 |     ry=root(y[i],tree);
      |        ~~~~^~~~~~~~~~~
a.cc:4:5: note: declared here
    4 | int root(int x){
      |     ^~~~
Language: C++

#include <iostream>

using namespace std;

int main(void) {
    int n,m;
    cin >> n >> m;
    int group[n];
    int cnt = 0;

    for (int i=0; i<n; i++) group[i]=0;

    for (int i=0; i<m; i++) {
        int x,y,z;
        cin >> x >> y >> z;
        if ( group[x-1] != 0 ) {
            group[y-1] = group[x-1];
        } else if ( group[y-1] != 0 ) {
            group[x-1] = group[y-1];
        } else {
            group[x-1] = group[y-1] = ++cnt;
        }
    }
    // for (int i=0; i<n; i++) cout << group[i] << " ";
    // cout << endl;
    
    cout << cnt + count(group, group+n, 0) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:19: error: 'count' was not declared in this scope; did you mean 'cnt'?
   27 |     cout << cnt + count(group, group+n, 0) << endl;
      |                   ^~~~~
      |                   cnt
Language: C++

// template version 1.10
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings {{{
#define infile "../test/sample-1.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
//}}}

// dump macro {{{
#if defined(PCM) || defined(LOCAL)
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42 #define dump_2d(...) 42
#endif
// }}}

//%snippet.set('unionfind')%
struct UnionFind {
  vector<int> data;  // size defined only for root node
  int count;

  UnionFind(int size) : data(size, -1), count(size){ }

  bool merge(int x, int y) {
    x=root(x); y=root(y);
    if (x!=y) {
      if (data[y]<data[x]) swap(x, y);
      data[x]+=data[y]; data[y]=x;
      count--;
    }
    return x != y;
  }
  int root(int x) {
    return (data[x]<0 ? x : data[x]=root(data[x]));
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
//%snippet.end%

int solve(){
  int N,M;cin>>N>>M;
  UnionFind uf(N);
  rep(m,M){
    int x,y,z;cin>>x>>y>>z;
    x--;y--;
    uf.merge(x,y);
  }
  cout << uf.count << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Compiler output:
a.cc:47:22: error: '#' is not followed by a macro parameter
   47 |   #define dump_1d(...) 42 #define dump_2d(...) 42
      |                      ^
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        int n,m;
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer in=new StringTokenizer(br.readLine());
        n=Integer.parseInt(in.nextToken());
        m=Integer.parseInt(in.nextToken());
        in=null;
        Union_Find tree=new Union_Find(n);
        for(int i=0;i<m;i++){
            in=new StringTokenizer(br.readLine());
            int a=Integer.parseInt(in.nextToken()),b=Integer.parseInt(in.nextToken());
            in=null;
            tree.Union(a,b);
            a=null;b=null;
        }
        m=null;
        br=null;
        System.out.println(tree.get_tree(n));
    }
}
class Union_Find{
    private int[] t,s;
    public Union_Find(int max_length){
        t=new int[max_length];
        s=new int[max_length];
        for(int i=0;i<max_length;i++){
            t[i]=i;
            s[i]=1;
        }
    }
    void Union(int x,int y){
        x--;y--;
        if (same(x, y)) return;
        int tx = Find(x), ty = Find(y);
        if (s[tx] < s[ty]) {
            s[ty] += s[tx];
            t[tx] = ty;
        }
        else if (s[tx] > s[ty]) {
            s[tx] += s[ty];
            t[ty] = tx;
        }
        else if (tx > ty) {
            t[tx] = ty;
            s[ty] += s[tx];
        }
        else {
            t[ty] = tx;
            s[tx] += s[ty];
        }
    }
    int Find(int n) {
        if (t[n] == n)
            return n;
        else
            return t[n] = Find(t[n]);
    }
    boolean same(int x, int y) {
        return Find(x-1) == Find(y-1);
    }
    int get_Size(int a) {
        return s[a-1];
    }
    int get_tree(int size){
        HashSet<Integer> st=new HashSet<>();
        for(int i=0;i<size;i++){
            st.add(Find(i));
        }
        return st.size();
    }
}


Compiler output:
Main.java:22: error: incompatible types: <null> cannot be converted to int
            a=null;b=null;
              ^
Main.java:22: error: incompatible types: <null> cannot be converted to int
            a=null;b=null;
                     ^
Main.java:24: error: incompatible types: <null> cannot be converted to int
        m=null;
          ^
3 errors
Language: C++

#include <bits/stdc++.h>

using namespace std;
const int maxn=1e5+5;
vector<int>v[maxn];
struct node
{
    int x,y,z,id;
    friend operator < (node a,node b)
    {
        return (a.x<b.x)||(a.x==b.x&&a.y<b.y);
    }
}a[maxn];
int b[maxn];
int n,m;

int main()
{

    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        if(x>y) swap(x,y);
        v[x].push_back(y);
        a[i].x=x,a[i].y=y,a[i].z=z;
    }
    sort(a+1,a+1+m);
    memset(b,-1,sizeof(b));
    int ans=0;
    for(int i=1;i<=m;i++)
    {
        if(b[a[i].x]==-1)
        {
            b[a[i].x]=2;
            ans++;
        }
        int len=v[a[i].x].size();
        for(int j=0;j<len;j++)
        {
            b[v[a[i].x][j]]=b[i];
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(b[i]==-1)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Compiler output:
a.cc:9:12: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive]
    9 |     friend operator < (node a,node b)
      |            ^~~~~~~~
Language: Java

import java.util.*;
class Main{
  public static main(String[] args){
    int n=sc.nextInt();
    UnionFind uf=new UnionFind(n);
    int m=sc.nextInt();
    for(int i=0;i<m;i++){
      uf.makeSame(sc.nextInt()-1,sc.nextInt()-1);
      sc.nextInt();
    }
    System.out.println(uf.length);
  }
}
class UnionFind{
  int length;
  int[] parent;
  int[] deep;
  UnionFind(int length){
    this.length=length;
    parent=new int[length];
    for(int i=0;i<length;i++){
      parent[i]=i;
    }
    deep=new int[length];
  }
  int getRoot(int x){
    if(parent[x]==x){
      return x;
    }else{
      return parent[x]=getRoot(x);
    }
  }
  void makeSame(int x,int y){
    rootX=getRoot(x);
    rootY=getRoot(y)
      if(rootX==rootY){
        return;
      }else if(deep[rootX]>deep[rootY]){
        parent[rootY]=parent[rootX];
      }else{
        parent[rootX]=parent[rootY];
        if(deep[rootX]==deep[rootY])deep[rootY]++;
      }
    length--;
  }
  boolean isSame(int x,int y){
    return getRoot(x)==getRoot(y);
  }
}

Compiler output:
Main.java:3: error: invalid method declaration; return type required
  public static main(String[] args){
                ^
Main.java:35: error: ';' expected
    rootY=getRoot(y)
                    ^
2 errors
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <queue>

using namespace std;

vector<vector<int>> to;
vector<bool> used;

void dfs(int x) {
	if (!used[i]) {
		used[i] = true;
		for (auto y: to[x]) {
			dfs(y);
		}
	}
}

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

	int x, y, z;

	to.assign(n, vector<int>());
	for (int i = 0; i < m; i++) {
		cin >> x >> y >> z;
		x--;
		y--;

		to[x].emplace_back(y);
		to[y].emplace_back(x);
	}

	int ans = 0;
	used.assign(n, false);

	for (int i = 0; i < n; i++) {
		if (used[i]) {
			continue;
		}
		ans++;

		dfs(i);
	}

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:16:19: error: 'i' was not declared in this scope
   16 |         if (!used[i]) {
      |                   ^
Language: C

#include<stdio.h>

class Lut{
private:
  int lut[100000];
public:
  Lut();
  int get(int x);
  void set(int x, int y);
};


Lut::Lut(){
  for(int i=0;i<100000;i++){
    lut[i]=0;
  }
}

int Lut::get(int x){
  while(lut[x]>0){
    x=lut[x];
  }
  return x;
}

void Lut::set(int x, int y){
  lut[x]=lut[y];
  return;
}

int main() {
	int n, m;
	int a, b, c;
	int N[100000];
	scanf("%d %d", &n, &m);
	int i,j;
	int tp;
	int count = 0;
	int groups = 0;
	for (i = 0; i < n; i++) N[i] = 0;
    Lut LUT;
	for (i = 0; i < m; i++) {
		scanf("%d %d %d", &a, &b, &c);
        a=a-1;
        b=b-1;
		if (N[a] == 0 && N[b] == 0) {
			count++;
			groups++;
			N[a] = groups;
			N[b] = groups;
		}
		else if (N[a] == 0 && N[b] != 0) {
			count++;
			N[a] = N[b];
		}
		else if (N[a] != 0 && N[b] == 0) {
			count++;
			N[b] = N[a];
		}
		else if( LUT.get(N[a]) != LUT.get(N[b]) ){
			count++;
            LUT.set(N[b],N[a]);
		}
	}
	printf("%d\n", n-count);

	return 0;
}

Compiler output:
main.c:3:1: error: unknown type name 'class'
    3 | class Lut{
      | ^~~~~
main.c:3:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    3 | class Lut{
      |          ^
main.c:13:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before '::' token
   13 | Lut::Lut(){
      |    ^~
main.c:19:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '::' token
   19 | int Lut::get(int x){
      |        ^~
main.c:26:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '::' token
   26 | void Lut::set(int x, int y){
      |         ^~
main.c: In function 'main':
main.c:41:5: error: unknown type name 'Lut'
   41 |     Lut LUT;
      |     ^~~
main.c:60:29: error: request for member 'get' in something not a structure or union
   60 |                 else if( LUT.get(N[a]) != LUT.get(N[b]) ){
      |                             ^
main.c:60:46: error: request for member 'get' in something not a structure or union
   60 |                 else if( LUT.get(N[a]) != LUT.get(N[b]) ){
      |                                              ^
main.c:62:16: error: request for member 'set' in something not a structure or union
   62 |             LUT.set(N[b],N[a]);
      |                ^
Language: C++

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  vector<int> y(m);
  vector<int> z(m);
  int i;
  for(i = 0; i < m; i++)
  {
    cin >> x.at(i) >> y.at(i) >> z.at(i);
  }
  vector<bool> known(n,false);
  int cost = 0;
  queue<int> que;
  for(i = 0; i < m; i++)
  {
    if(i == 0)
    {
      cost++;
      known.at(x.at(i)-1) = true;
      known.at(y.at(i)-1) = true;
    }
    else
    {
      if(known.at(x.at(i)-1) == false && known.at(y.at(i)-1) == false)
      {
        que.push(i);
      }
      else
      {
        known.at(x.at(i)-1) = true; 
        known.at(y.at(i)-1) = true;
      }
    }
  }
  int qprevsize = n-1;
  while(!que.empty())
  {
    if(queprevsize == que.size())
    {
      int k = que.front();
      cost++;
      known.at(x.at(k)-1) = true;
      known.at(y.at(k)-1) = true;
      que.pop();
    }
    queprevsize = que.size();
    for(i = 0; i < que.size(); i++)
    {
      if(known.at(x.at(que.front())-1) == false && known.at(y.at(que.front())-1) == false)
      {
        que.push(que.front());
        que.pop();
      }
      else
      {
        known.at(x.at(que.front())-1) = true; 
        known.at(y.at(que.front())-1) = true;
        que.pop();
      }
    }
  }
  for(i = 0; i < n; i++)
  {
    if(known.at(i) != true)
    {
      cost++;
    }
  }
  cout << cost << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:8: error: 'queprevsize' was not declared in this scope; did you mean 'qprevsize'?
   43 |     if(queprevsize == que.size())
      |        ^~~~~~~~~~~
      |        qprevsize
a.cc:51:5: error: 'queprevsize' was not declared in this scope; did you mean 'qprevsize'?
   51 |     queprevsize = que.size();
      |     ^~~~~~~~~~~
      |     qprevsize
Language: C++

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

struct UnionFind {
    // 各点は親を保存する
    vector<int> par;

    // parをn個の-1で初期化
    // これはその島が持っている頂点数を表す
    UnionFind(int n): par(n, -1)　{ }
    void init(int n) { par.assign(n, -1); }

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

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

    bool merge(int x, int y) {
        if (root(x) == root(y)) return false;
        if (par[x] > par[y]) swap(x,y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};


int main() {
    int N,M;
    UnionFind uf(N);
    cin >> n >> M;
    vector<int> x,y,z;
    for (int i=0; i<M; i++) {
        cin >> x[i] >> y[i] >> z[i];
        --x[i], --y[i];
    }
    for (int i=0; i<M;i++) uf.merge(x[i], y[i]);
    // uniqueな要素を格納する
    set<int> se;
    for (int i=0; i<N; i++) se.insert(uf.root(i));
    return (int)se.size();

}

Compiler output:
a.cc:12:33: error: extended character 　 is not valid in an identifier
   12 |     UnionFind(int n): par(n, -1)　{ }
      |                                 ^
a.cc: In constructor 'UnionFind::UnionFind(int)':
a.cc:12:33: error: expected '{' before '\U00003000'
   12 |     UnionFind(int n): par(n, -1)　{ }
      |                                 ^~
a.cc: In function 'int main()':
a.cc:43:12: error: 'n' was not declared in this scope
   43 |     cin >> n >> M;
      |            ^
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;


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

  vector<vector<int>> to(n); //edge nのグラフ
  for(int i=0; i<m-1; i++){
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  
  vector<int> ans(n, 1);
  
  ans[0] = 0;
  for (int j=0; j<n; j++) {
    for(int i=0; i<to[j].size(); i++) { // edge x につながっている辺i=0, 1, ...を見る
      int y = to[j][i]; //つながっている先のedge
      if(ans[y]==0) ans[j] = 0; // つながっている先が0なら自分を0にしても良い
      if(j<y) ans[y] = 0;
    }
  }
  
  int sum = 0;
  for (int i=0; i<n; i++) {
    sum += ans[i];
  }
  
  cout 

Compiler output:
a.cc: In function 'int main()':
a.cc:43:7: error: expected ';' at end of input
   43 |   cout
      |       ^
      |       ;
a.cc:43:7: error: expected '}' at end of input
a.cc:13:12: note: to match this '{'
   13 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 

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;

    UnionFind tree(m);

    int cnt=n;
    int kosu[n];
      for(int i=0;i<n;i++){
      kosu[i]=0;}
  
  cout<<par[5]<<endl;
  cout<<tree.root(5)<<endl;
  
    for(int i = 0; i < m; i++) {
        int  x, y, ppp;
        cin >> x >> y >> ppp;
        tree.unite(x-1, y-1); // xの木とyの木を併合する

    }

        cout<<tree.root(1)<<" "<<tree.root(5)<<endl;
      if(tree.same(1,5)){
        cout<<255<<endl;}

  
  for(int i=0;i<n;i++){
    kosu[tree.root(i)]++;}
  
  for(int i=0;i<n;i++){
    if(kosu[i]){
      cnt-=kosu[i]-1;
    }
  }

    cout << cnt << endl;
    return 0;
}

 


Compiler output:
a.cc: In function 'int main()':
a.cc:48:9: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   48 |   cout<<par[5]<<endl;
      |         ^~~
      |         __pstl::execution::v1::par
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~