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

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

struct UinonFind{
    private:
    vector<int> parent;
    public:
    void reset(int N){
        parent.clear();
        for(int i=0; i<N; i++) parent.push_back(i);
    }
    int root(int a){
        if(parent[a] == a) return a;
        return parent[a] = root(parent[a]);
    }
    void unite(int a, int b){
        int rootA = root(a);
        int rootB = root(b);
        if(rootA != rootB) parent[a] = rootB;
    }
    bool same(int a, int b){
        return root(a) == root(b);
    }
};

int main(){
    iostream::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;
    int p[100000];
    for(int i=0; i<N; i++){
        cin >> p[i];
        p[i]--;
    }
    UnionFind uf;
    uf.reset(N);
    for(int i=0; i<M; i++){
        int x, y;
        cin >> x >> y;
        uf.unite(x-1, y-1);
    }
    int ans = 0;
    for(int i=0; i<N; i++){
        if(uf.same(i, p[i])) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:5: error: 'UnionFind' was not declared in this scope; did you mean 'UinonFind'?
   59 |     UnionFind uf;
      |     ^~~~~~~~~
      |     UinonFind
a.cc:60:5: error: 'uf' was not declared in this scope
   60 |     uf.reset(N);
      |     ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int par[100001];
int length[100001];
void init(int n){
  for(int i=1;i<=n;i++){
    par[i]=i;
    length=1;
  }
  return;
}
int root(int n){
  if(par[n]==n)return n;
  return root(par[n]);
}
void unit(int x,int y){
  int x=root(x);
  int y=root(y);
  if(a==b)return;
  if(length[x]>length[y]){
    par[y]=x;
    length[x]++;
  }
  else{
    par[x]=y;
    length[y]++;
  }
  return;
}
int main(){
  int n,m;cin>>n>>m;
  int p[n];for(int i=0;i<n;i++)cin>>p[i];
  int x[m],y[m];for(int i=0;i<m;i++)cin>>x[i]>>y[i];
  init(n);
  for(int i=0;i<m;i++){
    unit(x[i],y[i]);
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(root(p[i])==root(i+1))sum++;
  }
  cout<<sum<<endl;
}
  

Compiler output:
a.cc: In function 'void init(int)':
a.cc:8:11: error: incompatible types in assignment of 'int' to 'int [100001]'
    8 |     length=1;
      |     ~~~~~~^~
a.cc: In function 'void unit(int, int)':
a.cc:17:7: error: declaration of 'int x' shadows a parameter
   17 |   int x=root(x);
      |       ^
a.cc:16:15: note: 'int x' previously declared here
   16 | void unit(int x,int y){
      |           ~~~~^
a.cc:18:7: error: declaration of 'int y' shadows a parameter
   18 |   int y=root(y);
      |       ^
a.cc:16:21: note: 'int y' previously declared here
   16 | void unit(int x,int y){
      |                 ~~~~^
a.cc:19:6: error: 'a' was not declared in this scope
   19 |   if(a==b)return;
      |      ^
a.cc:19:9: error: 'b' was not declared in this scope
   19 |   if(a==b)return;
      |         ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};


int main() {
  int N, M;

  cin >> N >> M;

  vector<int> p(N);
  int x, y;

  union_find uf(N);

  for(int i = 0; i < N; i++) {
    cin >> p[i];
    p[i]--;
  }

  for(int i = 0; i < M; i++){
    cin >> x >> y;

    x--;
    y--;
    x = uf.find(x);
    y = uf.find(y);

    uf.unite(x, y);
  }

  vector<vector<int>> a(N), b(N);
  int k;
  for(int i = 0; i < N; i++){
    k = uf.find(i);
    a[k].push_back(i);
    b[k].push_back(p[i]);
  }

  int count = 0;

  // for (int i = 0; i < N; i++){
  //   if(!a[i].empty()){
  //     for(int x : a[i]){
  //       for(int y : b[i]){
  //         if (x == y) {
  //           count++;
  //            break;
  //          }
  //       }
  //     }
  //   }
  // }

  for (int i = 0; i < n; i++) {
		if (!a[i].empty()) {
			set<int> s(b[i].begin(), b[i].end());
			for (int x : a[i])if (s.count(x))count++;
		}
	}
  cout << count << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:89:23: error: 'n' was not declared in this scope
   89 |   for (int i = 0; i < n; i++) {
      |                       ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int root(vector<int> uni, int iter){
  int parent = iter;

  while(parent != uni[parent]){
    parent = uni[parent];
  }
  return parent;
}

int main() {
  int N, M;

  cin >> N >> M;

  vector<int> p(N), U(N), rank(N);
  int x, y;

  for(int i = 0; i < N; i++) {
    cin >> p[i];
    p[i]--;
    rank[i] = 0;
    U[i] = i;
  }
  for(int i = 0; i < M; i++){
    cin >> x >> y;

    x--;
    y--;
    if (rank[x] > rank[y]){
      U[root(U, y)] = root(U, x);
    } else{
      U[root(U, x)] = root(U, y);
      if(rank[x] == rank[y]) rank[y]++;
    }
  }
  int count = 0;

  //for(int i = 0; i < N; i++) cout << i  << ":" << root(U,i) << endl;
  for (int i = 0; i < N; i++){
    if ((i == p[i]){
      count++;
    }else if (root(U, i) == root(U, p[i])){
      count++;
    }
  }

  cout << count << endl;



  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:20: error: expected ')' before '{' token
   63 |     if ((i == p[i]){
      |        ~           ^
      |                    )
a.cc:68:3: error: expected primary-expression before '}' token
   68 |   }
      |   ^
Language: Java

import java.util.*;

public class Test {
    public static void main(String[] args) {
        //Scanner sc = new Scanner(System.in);
        int N = 5;
        int M = 2;
        /*int[] p = new int[N+1];
        int[][] xy = new int[M+1][2];

        for(int i=1;i<=N;i++){
            p[i] = sc.nextInt();
        }
        for(int i=1;i<=M;i++){
            int left = sc.nextInt();
            int right = sc.nextInt();
            xy[i][0] = Math.min(left,right);
            xy[i][1] = Math.max(left,right);
        }*/
        int[] p = {0,5,3,1,4,2};
        int[][] xy = {{0,0},{1,3},{4,5}};
        int[] record = new int[N+1];
        for(int i=1;i<=N;i++){
            record[i] = i;
        }
        myComparator mC = new myComparator();
        Arrays.sort(xy,mC);
        for(int i=1;i<=M;i++){
            int left = xy[i][0];
            int right = xy[i][1];
            record[right] = record[left];
        }
        HashMap<Integer,HashSet<Integer>> map = new HashMap<>();
        for(int i=1;i<=N;i++){
            if(!map.containsKey(record[i])) {
                HashSet<Integer> cur = new HashSet<>();
                cur.add(record[i]);
                map.put(i,cur);
            }
            else{
                map.get(record[i]).add(i);
            }
        }
        int ans =0;
        for(int j=1;j<=N;j++){
            if(map.get(record[j]).contains(p[j])) ans++;
        }
        System.out.println(ans);


        //System.out.println(ans.get(ans.size()-1));
    }
    static class myComparator implements Comparator<int[]>{
        public int compare(int[] t1, int[] t2){
            return 2*123456*(t1[0]-t2[0])+t1[1]-t2[1];
        }
    }
}

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

#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

const int N=1e5+100;

int p[N];

int par[N];

void init(int n)
{
  for(int i=1;i<=n;i++)
    par[i]=i;
}

int get(int x)
{
  return x==par[x]?x:par[x]=get(par[x]);
}

void un(int x,int y)
{
  x=get(x),y=get(y);
  if(x==y)
    return;
  if(rand()%2)
    par[x]=y;
  else
    par[y]=x;
}

signed main()
{
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)
    cin>>p[i];
  init();
  while(m--)
  {
    int x,y;
    cin>>x>>y;
    un(x,y);
  }
  int ans=0;
  for(int i=1;i<=n;i++)
    ans+=get(i)==get(p[i]);
  cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:100:7: error: too few arguments to function 'void init(ll)'
  100 |   init();
      |   ~~~~^~
a.cc:72:6: note: declared here
   72 | void init(int n)
      |      ^~~~
Language: C++

#include<bits/stdc++.h>
#define MAXN 3010010
#define Max 25
using namespace std;

int index[MAXN];
int par[MAXN];

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

void Union(int x , int y) {
	int T , X = rep(x);
	int Y = rep(y);
	if(X < Y) T = X , X = Y , Y = T;
	if(X != Y) par[X] = Y;
}

int main()
{
//	freopen("in.txt" , "r" , stdin);
	int N , K , x , y;
	cin >> N >> K;
	int arr[N + 1] , U[K + 1];
	for(int i = 1 ; i <= N ; i++) par[i] = i;
	for(int i = 1 ; i <= N ; i++) cin >> arr[i] , index[arr[i]] = i;
	for(int i = 0 ; i < K ; i++) cin >> x >> y , Union(arr[x] , arr[y]);
	for(int i = 1 ; i <= N ; i++) {
		int x = rep(i) , y = rep(arr[i]);
		if(x == y) {
			arr[ index[ i ] ] = arr[i];
			index[ arr[i] ] = index[i];
			arr[i] = i;

		}
	}
	int cnt = 0;
	for(int i = 1 ; i <= N ; i++) if(i == arr[i]) cnt++;
	cout << cnt << endl;
}


Compiler output:
a.cc:6:15: error: 'int index [3010010]' redeclared as different kind of entity
    6 | int index[MAXN];
      |               ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:28:60: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   28 |         for(int i = 1 ; i <= N ; i++) cin >> arr[i] , index[arr[i]] = i;
      |                                                            ^
a.cc:33:35: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   33 |                         arr[ index[ i ] ] = arr[i];
      |                                   ^
a.cc:34:30: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   34 |                         index[ arr[i] ] = index[i];
      |                              ^
a.cc:34:48: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   34 |                         index[ arr[i] ] = index[i];
      |                                                ^
Language: C++

#include<stdio.h>
const int MAXL 1e5 + 10;
int Tree[MAXL];
int findRoot(int x) {
	if (Tree[x] == x) return x;
	else return Tree[x] = findRoot(Tree[x]);
}

int list[MAXL];
int belong[MAXL];

int main() {
	int n, m;
	while (scanf("%d%d", &n, &m) != EOF) {
		for (int i = 1; i <= n; i++) {
			scanf("%d", &list[i]);
			Tree[i] = i;
		}
		while (m--) {
			int a, b;
			scanf("%d%d", &a, &b);
			a = findRoot(a);
			b = findRoot(b);
			if (a != b) {
				Tree[a] = b;
			}
		}

		for (int i = 1; i <= n; i++) {
			belong[list[i]] = findRoot(i);
		}
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			if (belong[i] == findRoot(i))
				ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Compiler output:
a.cc:2:16: error: expected initializer before numeric constant
    2 | const int MAXL 1e5 + 10;
      |                ^~~
a.cc:3:10: error: 'MAXL' was not declared in this scope
    3 | int Tree[MAXL];
      |          ^~~~
a.cc: In function 'int findRoot(int)':
a.cc:5:13: error: 'Tree' was not declared in this scope
    5 |         if (Tree[x] == x) return x;
      |             ^~~~
a.cc: At global scope:
a.cc:9:10: error: 'MAXL' was not declared in this scope
    9 | int list[MAXL];
      |          ^~~~
a.cc:10:12: error: 'MAXL' was not declared in this scope
   10 | int belong[MAXL];
      |            ^~~~
a.cc: In function 'int main()':
a.cc:16:38: error: 'list' was not declared in this scope
   16 |                         scanf("%d", &list[i]);
      |                                      ^~~~
a.cc:17:25: error: 'Tree' was not declared in this scope
   17 |                         Tree[i] = i;
      |                         ^~~~
a.cc:25:33: error: 'Tree' was not declared in this scope
   25 |                                 Tree[a] = b;
      |                                 ^~~~
a.cc:30:25: error: 'belong' was not declared in this scope; did you mean 'long'?
   30 |                         belong[list[i]] = findRoot(i);
      |                         ^~~~~~
      |                         long
a.cc:30:32: error: 'list' was not declared in this scope
   30 |                         belong[list[i]] = findRoot(i);
      |                                ^~~~
a.cc:34:29: error: 'belong' was not declared in this scope; did you mean 'long'?
   34 |                         if (belong[i] == findRoot(i))
      |                             ^~~~~~
      |                             long
Language: C++

#include<stdio.h>
const MAXL 1e5 + 10;
int Tree[MAXL];
int findRoot(int x) {
	if (Tree[x] == x) return x;
	else return Tree[x] = findRoot(Tree[x]);
}

int list[MAXL];
int belong[MAXL];

int main() {
	int n, m;
	while (scanf("%d%d", &n, &m) != EOF) {
		for (int i = 1; i <= n; i++) {
			scanf("%d", &list[i]);
			Tree[i] = i;
		}
		while (m--) {
			int a, b;
			scanf("%d%d", &a, &b);
			a = findRoot(a);
			b = findRoot(b);
			if (a != b) {
				Tree[a] = b;
			}
		}

		for (int i = 1; i <= n; i++) {
			belong[list[i]] = findRoot(i);
		}
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			if (belong[i] == findRoot(i))
				ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Compiler output:
a.cc:2:7: error: 'MAXL' does not name a type
    2 | const MAXL 1e5 + 10;
      |       ^~~~
a.cc:3:10: error: 'MAXL' was not declared in this scope
    3 | int Tree[MAXL];
      |          ^~~~
a.cc: In function 'int findRoot(int)':
a.cc:5:13: error: 'Tree' was not declared in this scope
    5 |         if (Tree[x] == x) return x;
      |             ^~~~
a.cc: At global scope:
a.cc:9:10: error: 'MAXL' was not declared in this scope
    9 | int list[MAXL];
      |          ^~~~
a.cc:10:12: error: 'MAXL' was not declared in this scope
   10 | int belong[MAXL];
      |            ^~~~
a.cc: In function 'int main()':
a.cc:16:38: error: 'list' was not declared in this scope
   16 |                         scanf("%d", &list[i]);
      |                                      ^~~~
a.cc:17:25: error: 'Tree' was not declared in this scope
   17 |                         Tree[i] = i;
      |                         ^~~~
a.cc:25:33: error: 'Tree' was not declared in this scope
   25 |                                 Tree[a] = b;
      |                                 ^~~~
a.cc:30:25: error: 'belong' was not declared in this scope; did you mean 'long'?
   30 |                         belong[list[i]] = findRoot(i);
      |                         ^~~~~~
      |                         long
a.cc:30:32: error: 'list' was not declared in this scope
   30 |                         belong[list[i]] = findRoot(i);
      |                                ^~~~
a.cc:34:29: error: 'belong' was not declared in this scope; did you mean 'long'?
   34 |                         if (belong[i] == findRoot(i))
      |                             ^~~~~~
      |                             long
Language: C++

#include <bits/stdc++.h>
using namespace std;
int p[100001];
int parent[100001];
int findparent(int x)
{
	if(parent[x]!=x)
		parent[x]=findparent(parent[x]);
	return parent[x];
}
void unionset(int a,int b)
{
	if((a=findparent(a))==(b=findparent(b)))
		return 0;
	parent[a]=b;
	return;
}
int main()
{
	int n,m,i,ans=0,b,c;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
		parent[i]=i;
	for(i=1;i<=n;i++)
		scanf("%d",&p[i]);
	for(i=0;i<m;i++)
	{
		scanf("%d %d",&b,&c);
		unionset(p[b],p[c]);
	}
	for(i=1;i<=n;i++)
	{
		if(findparent(p[i])==findparent(i))
			ans++;
	}
	printf("%d",ans);
	return 0;
}

Compiler output:
a.cc: In function 'void unionset(int, int)':
a.cc:14:24: error: return-statement with a value, in function returning 'void' [-fpermissive]
   14 |                 return 0;
      |                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int p[100001];
int parent[100001];
int findparent(int x)
{
	if(parent[x]!=x)
		parent[x]=findparent(parent[x]);
	return parent[x];
}
void unionset(int a,int b)
{
	if((a=findparent(a))==(b=findparent(b)))
		return 0;
	parent[a]=b;
}
int main()
{
	int n,m,i,ans=0,b,c;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
		parent[i]=i;
	for(i=1;i<=n;i++)
		scanf("%d",&p[i]);
	for(i=0;i<m;i++)
	{
		scanf("%d %d",&b,&c);
		unionset(p[b],p[c]);
	}
	for(i=1;i<=n;i++)
	{
		if(findparent(p[i])==findparent(i))
			ans++;
	}
	printf("%d",ans);
	return 0;
}

Compiler output:
a.cc: In function 'void unionset(int, int)':
a.cc:14:24: error: return-statement with a value, in function returning 'void' [-fpermissive]
   14 |                 return 0;
      |                        ^
Language: C++

n,m = map(int, input().split())
p = list(map(int, input().split()))
par = [i for i in range(n)]

def root(x):
	tmp = par[x]
	if tmp == x:
		return x
	else:
		a = root(tmp)
		par[x] = a
		return a

def merge(x, y):
	x = root(x)
	y = root(y)
	if x != y:
		par[x] = y
		return

for i in range(m):
	x, y = map(int, input().split())
	merge(x-1, y-1)

ans = 0

for i in range(n):
	if p[i]-1 == i:
		ans += 1
	elif root(p[i]-1) == root(i):
		ans += 1

print(ans)


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,m = map(int, input().split())
      | ^
Language: Java

import java.util.Scanner;

class UnionFind{
  int[] parent;

  public void init(int N){
    parent = new int[N];
    for (int i = 0; i < N;  i++)
      parent[i] = i;
  }
  public int root(int x){
    if (parent[x] == x) return x;
    else{
      return parent[x] = root(parent[x]);
    }
  }
  public void unite(int x, int y){
    if (same(x, y)) return;
    int xroot = root(x);
    int yroot = root(y);
    parent[xroot] = yroot;
    return;
  }
  public boolean same(int x, int y){
    return (root(x) == root(y));
  }
}

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] pArray = new int[N];
    int[] x = new int[M];
    int[] y = new int[M];
    UnionFind unionFind = new UnionFind(N);
    for (int i = 0; i < N; i++){
      pArray[i] = scanner.nextInt() - 1;
    }
    for (int i = 0; i < M; i++){
      x[i] = scanner.nextInt() - 1;
      y[i] = scanner.nextInt() - 1;
      unionFind.unite(x[i], y[i]);
    }
    int count = 0;
    for (int i = 0; i < N; i++){
      if(unionFind.same(i, pArray[i])) count++;
    }
    System.out.println(count);
  }
}


Compiler output:
Main.java:37: error: constructor UnionFind in class UnionFind cannot be applied to given types;
    UnionFind unionFind = new UnionFind(N);
                          ^
  required: no arguments
  found:    int
  reason: actual and formal argument lists differ in length
1 error
Language: Java

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class MAin {
	public static Map<Integer, ArrayList<Integer>> map;
	public static int N;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		N = scan.nextInt();
		int M = scan.nextInt();
		int []p = new int[N];
		int []x = new int[M];
		int []y = new int[M];
		for(int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		}
		for(int i = 0; i < M; i++) {
			x[i] = scan.nextInt();
			y[i] = scan.nextInt();
		}
		scan.close();

		// 隣接リスト
		map = new TreeMap<Integer, ArrayList<Integer>>();
		for(int i = 0; i < M; i++) {
			if(!map.containsKey(x[i])) {
				ArrayList<Integer> list = new ArrayList<Integer>();
				list.add(y[i]);
				map.put(x[i], list);
			}else {
				map.get(x[i]).add(y[i]);
			}
			if(!map.containsKey(y[i])) {
				ArrayList<Integer> list = new ArrayList<Integer>();
				list.add(x[i]);
				map.put(y[i], list);
			}else {
				map.get(y[i]).add(x[i]);
			}
		}

//		for(int i : map.keySet()) {
//			System.out.print(i + " : ");
//			for(int j = 0; j < map.get(i).size(); j++) {
//				System.out.print(map.get(i).get(j) + " ");
//			}
//			System.out.println();
//		}

		int []color = new int[N + 1];
		Arrays.fill(color, 0);

		assignColor(color);
//		for(int i = 1; i <= N; i++) {
//			System.out.println(color[i]);
//		}
		int k = N;
		int t = 0;
		for(int i = 1; i <= N; i++) {
			for(int j = 0; j < N; j++) {
				if(k == p[j]) {
					t = j + 1;
					break;
				}
			}
			if(color[t] == color[k]) {
				System.out.println(k);
				System.exit(0);
			}
			k--;
		}


	}
	public static void dfs(int r, int c, int[] color) {
		Deque<Integer> stack = new ArrayDeque<Integer>();
		stack.push(r);
		color[r] = c;
		while(!stack.isEmpty()) {
			int u = stack.getFirst();
			stack.pop();
			if(map.containsKey(u)) {
				for(int i = 0; i < map.get(u).size(); i++) {
					int v = map.get(u).get(i);
					if(color[v] == 0) {
						color[v] = c;
						stack.push(v);
					}
				}
			}
		}
	}
	public static void assignColor(int[] color) {
		int id = 1;
		for(int i = 1; i <= N; i++) {
			if(color[i] == 0) {
				dfs(i, id++, color);
			}
		}
	}
}

Compiler output:
Main.java:9: error: class MAin is public, should be declared in a file named MAin.java
public class MAin {
       ^
1 error
Language: Java

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;


class UnionTree{
    int[] tree;

    public UnionTree(int N){
        tree = new int[N];
        for(int i = 0; i < N; i++) tree[i] = i;
    }

    //return root
    public int root(int x){
        if(tree[x] == x) return x;
        else{
            tree[x] = root(tree[x]);
            return tree[x];
        }
    }

    //decision same group
    public boolean same(int x, int y){
        return (root(x) == root(y));
    }
    
    //unite group
    public void unite(int x, int y){
        if(same(x, y)) return;
        /* connect xroot to yroot */
        int rootx = root(x);
        int rooty = root(y);
        tree[rootx] = rooty;
        return;
    }
}
 
class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] p = new int[N];
        UnionTree tree = new UnionTree(N);

        
        for(int i = 0; i < N; i++){
            p[i] = sc.nextInt() - 1;
        }

        for(int i = 0; i < M; i++){
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            tree.unite(x, y);
        }

        int c = 0;
        for(int i = 0; i < N; i++){
            if(tree.same(root(i), tree.root(p[i]))) c++;
        }

        System.out.println(c);
        
        return ;
    }
}

Compiler output:
Main.java:62: error: cannot find symbol
            if(tree.same(root(i), tree.root(p[i]))) c++;
                         ^
  symbol:   method root(int)
  location: class Main
1 error
Language: C++

#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;

vector<int> p;
bool exists = false;
bool used[100000];
void iter(int target, int num, vector<pair<int, int>> &t) {
	if (exists) return;

	for (size_t i = 0; i < t.size(); i++)
	{
		if (!used[i]) {
			used[i] = true;
			if (t[i].first == num) {
				if (p[t[i].second - 1] == target) {
					res++;
					exists = true;
				}
				iter(target, t[i].second, t);
			}
			else if (t[i].second == num) {
				if (p[t[i].first - 1] == target) {
					res++;
					exists = true;
				}
				iter(target, t[i].first, t);
			}
			if (exists) break;
			used[i] = false;
		}
	}

}

class UnionFind {
public:
	vector<size_t> parent;
	vector<size_t> rank;
protected:
	size_t findParent(size_t x) {
		if (parent[x] == x) {
			return x;
		}
		else {
			size_t p = findParent(parent[x]);
			parent[x] = p;
			return p;
		}
	}
public:
	explicit UnionFind(size_t size) {
		parent.reserve(size);
		rank.reserve(size);
		for (size_t i = 0; i < size; i++)
		{
			parent[i] = i;
			rank[i] = 0;
		}
	}
	virtual ~UnionFind() {}
	void unite(size_t x, size_t y) {
		size_t xi = findParent(x);
		size_t yi = findParent(y);
		if (xi == yi) return;
		if (rank[xi] < rank[yi]) {
			parent[xi] = yi;
		}
		else if (rank[xi] > rank[yi]) {
			parent[yi] = xi;
		}
		else {
			parent[yi] = xi;
			rank[xi]++;
		}
	}

	bool isSame(size_t x, size_t y) {
		return findParent(x) == findParent(y);
	}

};

void Equals() {


	int N,M;
	cin >> N >> M;
	p = vector<int>(N,0);
	for (size_t i = 0; i < N; i++)
	{
		cin >> p[i];
	}

	UnionFind uf(N);
	for (size_t i = 0; i < M; i++)
	{
		int x, y;
		cin >> x >> y;
		uf.unite(x - 1, y - 1);
	}
	int res = 0;

	for (size_t i = 0; i < N; i++)
	{
		if (uf.isSame(i, p[i] - 1)) {
			res++;
		}
	}

	cout << res;
}

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

Compiler output:
a.cc: In function 'void iter(int, int, std::vector<std::pair<int, int> >&)':
a.cc:25:41: error: 'res' was not declared in this scope
   25 |                                         res++;
      |                                         ^~~
a.cc:32:41: error: 'res' was not declared in this scope
   32 |                                         res++;
      |                                         ^~~
Language: C++

#include <iostream>
#include <string>
#include <list>
#include <cstring>

//#define USE_SET

int trans[N][N] = {0};

int main(void) {
  std::string str;

  std::cin >> str;
  int N = std::stoi(str);

  std::cin >> str;
  int M = std::stoi(str);

  int p[N] = {0};
  int xy[M][2] = {0};
  for (size_t i = 0; i < N; i++) {
    for (size_t j = 0; j < N; j++) {
      trans[i][j] = 0;
    }
  }

  for (size_t i = 0; i < N; i++) {
    std::cin >> str;
    p[i] = std::stoi(str);
  }

  for (size_t i = 0; i < M; i++) {
    std::cin >> str;
    xy[i][0] = std::stoi(str);
    std::cin >> str;
    xy[i][1] = std::stoi(str);
  }

  for (size_t i = 0; i < M; i++) {
    auto x = xy[i][0] - 1;
    auto y = xy[i][1] - 1;
    trans[x][y] = 1;
    trans[y][x] = 1;
  }

  size_t count;
  do {
    count = 0;
    for (size_t i = 0; i < N; i++) {
      for (size_t j = 0; j < N; j++) {
        auto t = trans[i][j];
        if (t) {
          for (size_t k = 0; k < N; k++) {
            if (trans[j][k] && trans[i][k] == 0) {
              trans[i][k] = 1;
              count++;
            }
          }
        }
      }
    }
    //printf("%zd\n", count);
  } while(count != 0);

  int score = 0;
  for (size_t i = 0; i < N; i++) {
    //printf(" %zd %d\n", i + 1, p[i]);
    if(p[i] == i + 1) {
      score++;
    } else {
      if (trans[i][p[i] - 1]) {
        score++;
      }
    }
  }

#if 0
  int idx = 0;
  for (size_t i = 0; i < N; i++) {
    for (size_t j = 0; j < N; j++) {
      if (trans[i][j]) {
        printf("%zd\n", i);
        idx = i;
        goto NEXT;
      }
    }
  }
NEXT:
  for (size_t i = 0; i < N; i++) {
    if (trans[idx][i]) {
      score++;
    } else {
      if(p[i] == i) {
        score++;
      }
    }
    printf("%d @ (%d, %zd : %d)\n", score, idx, i, trans[idx][i]);
  }

  if ((N - score) % 2 != 0) {
    score--;
  }
#endif

  printf("%d\n", score);
#if 0
  for (size_t i = 0; i < N; i++) {
    for (size_t j = 0; j < N; j++) {
      printf("%2d ", trans[i][j]);
    }
    printf("\n");
  }
#endif
#endif
  return 0;
}

Compiler output:
a.cc:114:2: error: #endif without #if
  114 | #endif
      |  ^~~~~
a.cc:8:11: error: 'N' was not declared in this scope
    8 | int trans[N][N] = {0};
      |           ^
a.cc:8:14: error: 'N' was not declared in this scope
    8 | int trans[N][N] = {0};
      |              ^
a.cc: In function 'int main()':
a.cc:23:7: error: 'trans' was not declared in this scope; did you mean 'wctrans'?
   23 |       trans[i][j] = 0;
      |       ^~~~~
      |       wctrans
a.cc:42:5: error: 'trans' was not declared in this scope; did you mean 'wctrans'?
   42 |     trans[x][y] = 1;
      |     ^~~~~
      |     wctrans
a.cc:51:18: error: 'trans' was not declared in this scope; did you mean 'wctrans'?
   51 |         auto t = trans[i][j];
      |                  ^~~~~
      |                  wctrans
a.cc:71:11: error: 'trans' was not declared in this scope; did you mean 'wctrans'?
   71 |       if (trans[i][p[i] - 1]) {
      |           ^~~~~
      |           wctrans
Language: C++

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

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define RREP(i,n,s) for(int i=(int)(s);i>=(int)(n);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n,m;cin>>n>>m;
    vector<int> p(n);
    REP(i,n) {
        int q; cin>>q; q--;
        p[i] = q;
    }

    vector<vector<int>> e(n, vector<int>(0));
    REP(i,m) {
        int x,y;cin>>x>>y;
        x--;y--;
        e[x].push_back(y);
        e[y].push_back(x);
    }

    bool b[n];
    fill(b, b+n, false);
    vector<vector<int>> s;
    REP(i,n) {
        if(b[i]) continue;
        vector<int> tmp;

        queue<int> q;
        q.push(i);
        b[x] = true;
        tmp.push_back(x);
        while(!q.empty()) {
            int x = q.front();
            q.pop();

            FOR(j, e[x]) {
                if(!b[*j]) {
                    q.push(*j);
                    b[*j] = true;
                    tmp.push_back(*j);
                }
            }
        }
        s.push_back(tmp);
    }

    int cnt = 0;
    REP(i,s.size()) {
        vector<int> v = s[i];
        vector<int> p2;
        REP(j, v.size()) {
            p2.push_back(p[v[j]]);
        }
        REP(j, v.size()) {
            if(find(ALL(p2), v[j]) != p2.end()) cnt++;
        }
    }

    cout << cnt << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:11: error: 'x' was not declared in this scope
   47 |         b[x] = true;
      |           ^
Language: C++

#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

const int maxn = 100000 + 10;

int par[maxn];

int find_par(int k) {
	if (par[k] == -1) {
		return k;
	}
	else {
		return par[k] = find_par(par[k]);
	}
}

void join(int p, int q) {
	int x = find_par(p);
	int y = find_par(q);

	if (x == y)
		return;
	par[x] = y;
}

int N, M;
int nums[maxn];
int sw[maxn][2];
vector<set<int> > vse;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> N >> M;
	for (int i = 1; i <= N; i++)
		cin >> nums[i];
	for (int i = 0; i < M; i++) {
		cin >> sw[i][0] >> sw[i][1];
	}

	memset(par, -1, sizeof(par));
	for (int i = 0; i < M; i++) {
		join(sw[i][0], sw[i][1]);
	}

	bool visited[maxn];
	memset(visited, false, sizeof(visited));
	for (int i = 1; i <= N; i++) {
		if (!visited[i]) {
			int pp = find_par(i);
			set<int> si;
			
			for (int j = i; j <= N; j++) {
				if (find_par(j) == pp) {
					si.insert(j);
					visited[j] = true;
				}
			}
			vse.push_back(si);
		}
	}

	int res = 0;
	vector<int> vi(maxn);
	auto vi_it = vi.begin();
	for (int i = 0; i < vse.size(); i++) {
		set<int> si = vse[i];
		set<int> t;
		for (auto it = si.begin(); it != si.end(); it++) {
			t.insert(nums[*it]);
		}

		int incr = 0;
		for (auto it = si.begin(); it != si.end(); it++) {
			if (t.count(*it))
				res++;
		}
	}
	cout << res << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:9: error: 'memset' was not declared in this scope
   48 |         memset(par, -1, sizeof(par));
      |         ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include <algorithm>
  +++ |+#include <cstring>
    7 |
Language: C

#include <iostream>
#include <string>
#include <set>

#include<vector>
#define MAX_N 100
using namespace std;

//要素数はN個
int par[MAX_N];
int ufrank[MAX_N];

void init(int n)
{
    for (int i = 0; i < n; ++i)
    {
        par[i] = i;
        ufrank[i] = 0;
    }
}

//木の根を求める
int find(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (ufrank[x] < ufrank[y])
    {
        par[x] = y;
    }
    else
    {
        par[y] = x;
        if (ufrank[x] == ufrank[y])
            ufrank[x]++;
    }
}

//xとyが同じ集合に属するか調べる
bool same(int x, int y)
{
    return find(x) == find(y);
}


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

    vector<int> v(n);
    for (int i = 0; i < n;++i){
        cin >> v[i];
    }
    init(n + 1);
    int x, y;
    for (int i = 0; i < m; ++i)
    {
        cin >> x >> y;
        unite(x, y);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        if(same(i+1,v[i])){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

const int N = 100000;
vector<int> s[N];
int pos[N][N] = {0};
int b[N];
int p[N];

bool dfs(int x, int y, set<int> &v) {
    if (x == y) return true;
    if (pos[x][y] == 1) return true;
    if (v.count(x)) return false;
    v.insert(x);
    for (int n : s[x]) {
        if (dfs(n, y, v)) {
            pos[x][y] = 1;
            return true;
        }
    }
    pos[x][y] = -1;
    return false;
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    forn(i, 0, n) {
        int x;
        scanf("%d ", &x);
        x--;
        p[i] = x;
        b[x] = i;
    }
    forn(i, 0, m) {
        int x, y;
        scanf("%d %d", &x, &y);
        x--; y--;
        s[x].push_back(y);
        s[y].push_back(x);
    }
    int ans = 0;
    forn(i, 0, n) {
        set<int> v;
        if (dfs(b[i], i, v)) {
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Compiler output:
/tmp/ccLmbvgw.o: in function `main':
a.cc:(.text+0x1ef): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccLmbvgw.o
a.cc:(.text+0x206): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccLmbvgw.o
a.cc:(.text+0x2ed): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccLmbvgw.o
collect2: error: ld returned 1 exit status
Language: C++

/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
// #include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N, M; cin >> N >> M;
    vi p(N);
    REP(i, N) {
        cin >> p[i];
        p[i]--;
    }

    init(N);

    int x, y;
    REP(i, M) {
        cin >> x >> y;
        x--;
        y--;
        unite(x, y);
    }

    vi used(N, 0);

    int res = 0;
    REP(i, N) {
        if( same(i, p[i]) ) res++;
        else if ( i == p[i] ) res++;
    }

    cout << res << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:81:5: error: 'init' was not declared in this scope; did you mean 'int'?
   81 |     init(N);
      |     ^~~~
      |     int
a.cc:88:9: error: 'unite' was not declared in this scope
   88 |         unite(x, y);
      |         ^~~~~
a.cc:95:13: error: 'same' was not declared in this scope
   95 |         if( same(i, p[i]) ) res++;
      |             ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  short a;cin>>a;
  set<string>S;
  for(int i=0;i<s.size();i++)
    for(int j=i+1;j<min(i+k+1,int(s.size()));j++)
      S.insert(s.begin+i(),s.begin+j());
  vector<string>A(S.size());
  for(int i=0;i<A.size();i++){
    A[i]=S.top();
    S.pop();
  }
  sort(A.begin(),A.end());
  cout<<A[a]<<endl;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:8:27: error: 'k' was not declared in this scope
    8 |     for(int j=i+1;j<min(i+k+1,int(s.size()));j++)
      |                           ^
a.cc:9:25: error: 'i' cannot be used as a function
    9 |       S.insert(s.begin+i(),s.begin+j());
      |                        ~^~
a.cc:9:37: error: 'j' cannot be used as a function
    9 |       S.insert(s.begin+i(),s.begin+j());
      |                                    ~^~
a.cc:12:12: error: 'class std::set<std::__cxx11::basic_string<char> >' has no member named 'top'
   12 |     A[i]=S.top();
      |            ^~~
a.cc:13:7: error: 'class std::set<std::__cxx11::basic_string<char> >' has no member named 'pop'
   13 |     S.pop();
      |       ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  short a;cin>>a;
  set<string>S;
  for(int i=0;i<s.size();i++)
    for(int j=i+1;j<min(i+5,s.size());j++)
      S.insert(s.begin+i(),s.begin+j());
  vector<string>A(S.size());
  for(int i=0;i<A.size();i++){
    A[i]=S.top();
    S.pop();
  }
  sort(A.begin(),A.end());
  cout<<A[a]<<endl;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:8:24: error: no matching function for call to 'min(int, std::__cxx11::basic_string<char>::size_type)'
    8 |     for(int j=i+1;j<min(i+5,s.size());j++)
      |                     ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:8:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
    8 |     for(int j=i+1;j<min(i+5,s.size());j++)
      |                     ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:8:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    8 |     for(int j=i+1;j<min(i+5,s.size());j++)
      |                     ~~~^~~~~~~~~~~~~~
a.cc:9:25: error: 'i' cannot be used as a function
    9 |       S.insert(s.begin+i(),s.begin+j());
      |                        ~^~
a.cc:9:37: error: 'j' cannot be used as a function
    9 |       S.insert(s.begin+i(),s.begin+j());
      |                                    ~^~
a.cc:12:12: error: 'class std::set<std::__cxx11::basic_string<char> >' has no member named 'top'
   12 |     A[i]=S.top();
      |            ^~~
a.cc:13:7: error: 'class std::set<std::__cxx11::basic_string<char> >' has no member named 'pop'
   13 |     S.pop();
      |       ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  short a;cin>>a;
  set<string>S;
  for(int i=0;i<s.size();i++)
    for(int j=i+1;j<s.size();j++)
      S.insert(s.begin+i(),s.begin+j());
  vector<string>A(S.size());
  for(int i=0;i<A.size();i++){
    A[i]=S.top();
    S.pop();
  }
  sort(A.begin(),A.end());
  cout<<A[a]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:25: error: 'i' cannot be used as a function
    9 |       S.insert(s.begin+i(),s.begin+j());
      |                        ~^~
a.cc:9:37: error: 'j' cannot be used as a function
    9 |       S.insert(s.begin+i(),s.begin+j());
      |                                    ~^~
a.cc:12:12: error: 'class std::set<std::__cxx11::basic_string<char> >' has no member named 'top'
   12 |     A[i]=S.top();
      |            ^~~
a.cc:13:7: error: 'class std::set<std::__cxx11::basic_string<char> >' has no member named 'pop'
   13 |     S.pop();
      |       ^~~
Language: C++

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int NX = 1e5 + 5;

int N, M;
vector<int> adj[NX];
int used[NX], p[NX];

vector<int> num;
map<int, int> pos;

void dfs(int node) {
    if(visit[node])
        return;
    visit[node] = 1;
    num.pb(p[node]);
    pos[node] = 1;
    for(int x: adj[node]) {
        dfs(x);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;

    REP(i, 0, N) {
        cin >> p[i];
        --p[i];
    }

    REP(i, 0, M) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    int res = 0;
    REP(i, 0, N) {
        if(!visit[i]) {
            pos.clear();
            num.clear();
            dfs(i);
            for(int x: num) 
                if(pos[x]) ++res;
        }
    }
    cout << res << "\n";
    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:30:13: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   30 |     if(visit[node])
      |             ^
a.cc:32:10: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   32 |     visit[node] = 1;
      |          ^
a.cc: In function 'int main()':
a.cc:59:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   59 |         if(!visit[i]) {
      |                  ^