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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    a.push_back(int("tourist"));
    each(i, a)--i;
    int ans = 0;
    FOR(i, 0, n) {
        if (a[a[i]] == i) {
            a[a[i]] = n;
            ++ans;
        }
    }
    cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:17: error: cast from 'const char*' to 'int' loses precision [-fpermissive]
   42 |     a.push_back(int("tourist"));
      |                 ^~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, a, n) for (int i = a; i < (n); ++i)

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	
	int count = 0;
	rep(i, 0, n)
	{
		if (i+1 == a[i]) ++code;
	}
	cout << count << endl;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:36: error: 'code' was not declared in this scope
   19 |                 if (i+1 == a[i]) ++code;
      |                                    ^~~~
Language: C++

#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main() {
  int n, s = 0;
  cin >> n;
  vector<int> r(n);
  vector<vector<bool>> v(n, vector<bool>(n, 0));
  rep(i, n){
    cin >> r[i];
    --r[i];
    v[i][r[i]] = 1;
  }
  rep(i, n){
    if(v[i][r[i]] && v[r[i][i]]) ++s;
  }
  cout << s << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:28: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   17 |     if(v[i][r[i]] && v[r[i][i]]) ++s;
      |                            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
        A.at(i)--;
    }
    for (int i = 0; i < N; i++){
        if (A.at(A.at(i) == i){
            ans++;
        }
    }
    cout << ans / 2 << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:31: error: expected ')' before '{' token
   18 |         if (A.at(A.at(i) == i){
      |            ~                  ^
      |                               )
a.cc:21:5: error: expected primary-expression before '}' token
   21 |     }
      |     ^
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    set<int> se[100100];
    int res = 0;
    rep(i, n) {
        cin >> a[i];
        if(se[i].count(a[i]) ++res;
        se[a[i]].insert(i);
    }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:59:23: error: lvalue required as increment operand
   59 |         if(se[i].count(a[i]) ++res;
      |            ~~~~~~~~~~~^~~~~~
a.cc:60:27: error: expected ')' before ';' token
   60 |         se[a[i]].insert(i);
      |                           ^
      |                           )
a.cc:59:11: note: to match this '('
   59 |         if(se[i].count(a[i]) ++res;
      |           ^
a.cc:60:24: error: could not convert 'se[a.std::vector<int>::operator[](((std::vector<int>::size_type)i))].std::set<int>::insert(i)' from 'std::pair<std::_Rb_tree_const_iterator<int>, bool>' to 'bool'
   60 |         se[a[i]].insert(i);
      |         ~~~~~~~~~~~~~~~^~~
      |                        |
      |                        std::pair<std::_Rb_tree_const_iterator<int>, bool>
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    set<int> se[100100];
    int res = 0;
    rep(i, n) {
        cin >> a[i];
        if(se[i].count(a[i]]) ++res;
        se[a[i]].insert(i);
    }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:59:28: error: expected ')' before ']' token
   59 |         if(se[i].count(a[i]]) ++res;
      |                       ~    ^
      |                            )
a.cc:59:28: error: expected ')' before ']' token
   59 |         if(se[i].count(a[i]]) ++res;
      |           ~                ^
      |                            )
a.cc:59:28: error: expected primary-expression before ']' token
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    set<int> se[100100];
    int res = 0;
    rep(i, n) {
        cin >> a[i];
        if(se[i].count[a[i]]) ++res;
        se[a[i]].insert(i);
    }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:59:23: error: invalid types '<unresolved overloaded function type>[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   59 |         if(se[i].count[a[i]]) ++res;
      |                       ^
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> A;
  for(int i=0; i<N; i++){
    int a; cin >> a;
    A.push_back(a);
  }
  int count=0;
  for(int i=0; i<N; i++){
    if(i+1==A[A[i]-1]) count++;
  }
  cout << count/2 << endl;
  return 0;
}
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A;
  for(int i=0; i<N; i++){
    int a; cin >> a;
    A.push_back(a);
  }
  int count=0;
  for(int i=0; i<N; i++){
    if(i+1==A[A[i]-1]) count++;
  }
  cout << count/2 << endl;
  return 0;
}


Compiler output:
a.cc:22:5: error: redefinition of 'int main()'
   22 | int main(){
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main(){
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    ll n,ans = 0;
    cin >> n;
    vector<ll> a(n,0);
    rep(i, n)cin >> a[i];
    rep(i, n){a
        if (i + 1 == a[a[i] - 1]) {
            ++ans;
        }
        a.erase(a.begin());
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: expected ';' before 'if'
   30 |     rep(i, n){a
      |                ^
      |                ;
   31 |         if (i + 1 == a[a[i] - 1]) {
      |         ~~
Language: Java

import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i < n;i++)a[i]=sc.nextInt();
      int cnt = 0;
      boolean friend = new boolean[n];
      Arrays.fill(friend,true);
      int cnt = 0;
      for(int i = 0;i < n;i++){
      	if(a[a[i]]==i&&a[i]==true&&a[a[i]]==true){
        	cnt++;
            a[i]=false;
            a[a[i]]=false;
        }
      }
      System.out.println(cnt);
    }
}

Compiler output:
Main.java:9: error: incompatible types: boolean[] cannot be converted to boolean
      boolean friend = new boolean[n];
                       ^
Main.java:10: error: no suitable method found for fill(boolean,boolean)
      Arrays.fill(friend,true);
            ^
    method Arrays.fill(long[],long) is not applicable
      (argument mismatch; boolean cannot be converted to long[])
    method Arrays.fill(int[],int) is not applicable
      (argument mismatch; boolean cannot be converted to int[])
    method Arrays.fill(short[],short) is not applicable
      (argument mismatch; boolean cannot be converted to short[])
    method Arrays.fill(char[],char) is not applicable
      (argument mismatch; boolean cannot be converted to char[])
    method Arrays.fill(byte[],byte) is not applicable
      (argument mismatch; boolean cannot be converted to byte[])
    method Arrays.fill(boolean[],boolean) is not applicable
      (argument mismatch; boolean cannot be converted to boolean[])
    method Arrays.fill(double[],double) is not applicable
      (argument mismatch; boolean cannot be converted to double[])
    method Arrays.fill(float[],float) is not applicable
      (argument mismatch; boolean cannot be converted to float[])
    method Arrays.fill(Object[],Object) is not applicable
      (argument mismatch; boolean cannot be converted to Object[])
Main.java:11: error: variable cnt is already defined in method main(String[])
      int cnt = 0;
          ^
Main.java:13: error: incomparable types: int and boolean
      	if(a[a[i]]==i&&a[i]==true&&a[a[i]]==true){
      	                   ^
Main.java:13: error: incomparable types: int and boolean
      	if(a[a[i]]==i&&a[i]==true&&a[a[i]]==true){
      	                                  ^
Main.java:15: error: incompatible types: boolean cannot be converted to int
            a[i]=false;
                 ^
Main.java:16: error: incompatible types: boolean cannot be converted to int
            a[a[i]]=false;
                    ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
7 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c=0;cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a.at(i);
  for(int i=0;i<n-1;i++){
    if(a.at(a.at(i)-1)==i+1){
      c++;
      a.at(a.at(i))=0
    }
  }
  cout<<c<<endl;
    

Compiler output:
a.cc: In function 'int main()':
a.cc:10:22: error: expected ';' before '}' token
   10 |       a.at(a.at(i))=0
      |                      ^
      |                      ;
   11 |     }
      |     ~                 
a.cc:13:17: error: expected '}' at end of input
   13 |   cout<<c<<endl;
      |                 ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include <iostream>
using namespace std;
int main()
{
	long n,ans=0;
	cin >> n;
	long a[n+1];
	for(i=1;i<=n;i++){
		cin >> a[i];
	} 
	for(i=1;i<=n;i++){
		if(i=a[a[i]]){
			ans++;
		}
	} 
	cout << ans << endl;
	return 0;
}


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

#include <bits/stdc++.h>

using namespace std;

int main(){
 int n; 
  cin >>  n;
  
  vector<int> a(n+1)
  for(int i=1;i<=n;i++){
   cin >> a[i];
  }
  
  int res=0;
  for(int i=1;i<=n;i++){
   if(a[a[i]]==i) res++;
  }
   cout << res/2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: expected ',' or ';' before 'for'
   10 |   for(int i=1;i<=n;i++){
      |   ^~~
a.cc:10:15: error: 'i' was not declared in this scope
   10 |   for(int i=1;i<=n;i++){
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
	cin >>N;
	vector<int> s(N,0);
	int count = 0;
for(int i=0;i<N;i++){
	cin >> s.at(i);
}
for(inti=0;i<N;i++){
	if(s.at(i)==s.at(s.at(i)))
count += 1;
}
  
cout << count/2 << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
	cin >>N;
	vector<int> s(N,0)
	int count = 0;
for(i=0;i<N;i++){
	cin >> s.at(i);
}
for(i=0;i<N;i++){
	if(s.at(i)==s.at(s.at(i)))
count += 1;
}
cout << count/2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: expected ',' or ';' before 'int'
    8 |         int count = 0;
      |         ^~~
a.cc:9:5: error: 'i' was not declared in this scope
    9 | for(i=0;i<N;i++){
      |     ^
a.cc:12:5: error: 'i' was not declared in this scope
   12 | for(i=0;i<N;i++){
      |     ^
a.cc:14:10: error: overloaded function with no contextual type information
   14 | count += 1;
      |          ^
a.cc:16:14: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator/'
   16 | cout << count/2 << endl;
      |         ~~~~~^~
Language: C++

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

signed main(){
	int n;cin>>n;
	vector<int>a(n);
	for(auto&& w:a)cin>>w;
	int sm=0;
	for(i=0;i<n;i++){
		int x=a[i];
		int y=a[x-1];
		if(i==y-1)sm++;
	}
	cout<<sm/2<<endl;
}

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

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

signed main(){
	int n;cin>>n;
	vector<int>a(n);
	for(auto&& w:a)cin>>w;
	int sm=0;
	for(i=0;i<n;i++){
		int x=a[i];
		int y=a[x-1];
		if(i==y-1)sm++;
	}
	cout<<sm/2<<endl;
}

Compiler output:
a.cc:1:16: warning: extra tokens at end of #include directive
    1 | #include <>bits/stdc++.h>
      |                ^
a.cc:1:10: fatal error: >bit: No such file or directory
    1 | #include <>bits/stdc++.h>
      |          ^~~~~~
compilation terminated.
Language: C

n = int(input())
A = list(map(int, input().split()))
cnt = 0
for i,a in enumerate(A):
    if i == A[a - 1] - 1:
        cnt +=1
print(cnt // 2)


Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | n = int(input())
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
main.c:1:5: error: expected expression before 'int'
    1 | n = int(input())
      |     ^~~
Language: C++

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

int main() {
  int = n,ans = 0;
  cin >> n;
  vector<int> rb(n);
  for(int i = 0; i < n; i++){
    cin >> rb.at(i);
  }
  for(int j; j < n; j++){
    if(rb.at(j) == rb.at(rb.at(j)))
      ans++;
  }
  cout << ans / 2 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:7: error: expected unqualified-id before '=' token
    5 |   int = n,ans = 0;
      |       ^
a.cc:6:10: error: 'n' was not declared in this scope; did you mean 'yn'?
    6 |   cin >> n;
      |          ^
      |          yn
a.cc:13:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |       ans++;
      |       ^~~
      |       abs
a.cc:15:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   15 |   cout << ans / 2 << endl;
      |           ^~~
      |           abs
Language: C++

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

int N,A[100010];
set<int> s[100010];

int main(){
  cin >> N;
  int ans = 0;
  for(int i=1;i<=N;i++){
    cin >> A[i];
    s[A[i]].insert(i);
  }
  int ans = 0;
  for(int i=1;i<=N;i++) if(s[i].count(A[i])==1)) ans++;
  cout << ans/2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:7: error: redeclaration of 'int ans'
   15 |   int ans = 0;
      |       ^~~
a.cc:10:7: note: 'int ans' previously declared here
   10 |   int ans = 0;
      |       ^~~
a.cc:16:48: error: expected primary-expression before ')' token
   16 |   for(int i=1;i<=N;i++) if(s[i].count(A[i])==1)) ans++;
      |                                                ^
Language: C++

//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int n, k[100005], ans;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) { cin >> k[i]; }
	for (int i = 1; i <= n; i++) {
		if (a[a[i]] == i) {
			++ans;
		}
	}
	cout << ans / 2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:21: error: 'a' was not declared in this scope
   40 |                 if (a[a[i]] == i) {
      |                     ^
Language: C++

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

int main() {
  int n,cnt=0;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) {
    cin >> v[i];
  }
  for(int i=0; i<n; i++) {
    if(s[i]==s[s[i]+1]&&i<s[i]+1) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:8: error: 's' was not declared in this scope
   12 |     if(s[i]==s[s[i]+1]&&i<s[i]+1) {
      |        ^
Language: C++

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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int& x : A) cin >> x, --x;
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (i == a[a[i]]);
  }
  cout << ans / 2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:18: error: 'a' was not declared in this scope
   14 |     ans += (i == a[a[i]]);
      |                  ^
Language: C++

#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int& x : A) cin >> x, --x;
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      ans += (i == A[j] && j == A[i]);
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> A(N);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> A(N);
      |          ^~~
a.cc:9:17: error: 'A' was not declared in this scope
    9 |   for (int& x : A) cin >> x, --x;
      |                 ^
a.cc:14:20: error: 'A' was not declared in this scope
   14 |       ans += (i == A[j] && j == A[i]);
      |                    ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, ans = 0;
  cin >> n;
  vector<int> v(n);
  for(int &x : v) {
    cin >> x;
    x--;
  }
  for(int i = 0; i < (int) v.size(); i++) {
    ans += i == v[v[i]];
  }
  cout << x / 2 << '\n';
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:11: error: 'x' was not declared in this scope
   18 |   cout << x / 2 << '\n';
      |           ^
Language: C++

use std::io;

fn next_int() -> i64 {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn next_vec() -> Vec<i64> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|n| n.parse().unwrap()).collect()
}

fn main() {
    let n = next_int();
    let a = next_vec();

    let mut cnt = 0;

    for i in 0..n {
        let idx = i as usize;
        let idx2 = a[idx] as usize;
        cnt += if a[idx2-1] == i + 1 {1} else {0};
    }

    println!("{:?}", cnt/2);
}


Compiler output:
a.cc:21:14: error: too many decimal points in number
   21 |     for i in 0..n {
      |              ^~~~
a.cc:1:1: error: 'use' does not name a type
    1 | use std::io;
      | ^~~
a.cc:3:1: error: 'fn' does not name a type
    3 | fn next_int() -> i64 {
      | ^~
a.cc:9:1: error: 'fn' does not name a type
    9 | fn next_vec() -> Vec<i64> {
      | ^~
a.cc:15:1: error: 'fn' does not name a type
   15 | fn main() {
      | ^~
Language: C++

 namespace std;

int main(){
int N,a[100001];
cin>>N;
for(int i=1;i<N+1;i++){
  cin>>a[i];
}

int count,b;
for(int i=1;i<N+1;i++){
   b=a[i];
   if(i==a[b]){count++;}
}
cout<<count/2;



return 0;
}

Compiler output:
a.cc:1:15: error: expected '{' before ';' token
    1 |  namespace std;
      |               ^
a.cc: In function 'int main()':
a.cc:5:1: error: 'cin' was not declared in this scope
    5 | cin>>N;
      | ^~~
a.cc:15:1: error: 'cout' was not declared in this scope; did you mean 'count'?
   15 | cout<<count/2;
      | ^~~~
      | count
Language: C

#include <stdio.h>

int main(){
	int N = 100000;
	scanf("%d\n", &N);
	int usagi[100000];

	for (size_t i = 0; i < N; i++) {
		scanf("%d", &usagi[i]);
	}
	int count = 0;
	for (size_t i = 0; i < N; i++) {
		for (size_t j = i+1; j < N; j++) {
			if(usagi[i] == j+1 && usagi[j] == i+1){
				count++;
				break;
			}
		}
	}
	printf("%d\n", count);
	return 0;

Compiler output:
main.c: In function 'main':
main.c:21:9: error: expected declaration or statement at end of input
   21 |         return 0;
      |         ^~~~~~
Language: C++

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1000000000

int a[100001];
bool used[100001];
 
int main(){
    int n;
    scanf("%d",&n);
    REP(i,n){
        scant("%d",a+i);
        a[i]--;
        used[i] = false;
    }
    int c = 0;
    REP( i,n){
        if(!used[i] && a[a[i]]==i){
            c++;
            used[i] = used[a[i]] = true;
        }
    }
    printf("%d\n",c);

    return 0;
}

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

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1000000000

int a[100001];
bool used[100001];
 
int main(){
    scanf("%d",&n);
    REP(i,n){
        scant("%d",a+i);
        a[i]--;
        used[i] = false;
    }
    int c = 0;
    REP( i,n){
        if(!used[i] && a[a[i]]==i){
            c++;
            used[i] = used[a[i]] = true;
        }
    }
    printf("%d\n",c);

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:17: error: 'n' was not declared in this scope; did you mean 'yn'?
   19 |     scanf("%d",&n);
      |                 ^
      |                 yn
a.cc:21:9: error: 'scant' was not declared in this scope; did you mean 'scanf'?
   21 |         scant("%d",a+i);
      |         ^~~~~
      |         scanf
Language: C++

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1000000000

int a[100001];
bool used[100001];
 
int main(){
    scanf("%d",&n);
    REP(i,n){
        scant("%d",a+i);
        a[i]--;
        used[i] = false;
    }
    int c = 0;
    REP( i,n){
        if(!used[i] && a[a[i]]==i){
            c++;
            used[i] = used[a[i]] = true;
        }
    }
    printf(”%d\n",c);

    return 0;
}

Compiler output:
a.cc:32:12: error: extended character ” is not valid in an identifier
   32 |     printf(”%d\n",c);
      |            ^
a.cc:32:15: error: stray '\' in program
   32 |     printf(”%d\n",c);
      |               ^
a.cc:32:17: warning: missing terminating " character
   32 |     printf(”%d\n",c);
      |                 ^
a.cc:32:17: error: missing terminating " character
   32 |     printf(”%d\n",c);
      |                 ^~~~~
a.cc: In function 'int main()':
a.cc:19:17: error: 'n' was not declared in this scope; did you mean 'yn'?
   19 |     scanf("%d",&n);
      |                 ^
      |                 yn
a.cc:21:9: error: 'scant' was not declared in this scope; did you mean 'scanf'?
   21 |         scant("%d",a+i);
      |         ^~~~~
      |         scanf
a.cc:32:12: error: '\U0000201d' was not declared in this scope
   32 |     printf(”%d\n",c);
      |            ^
a.cc:32:14: error: 'd' was not declared in this scope
   32 |     printf(”%d\n",c);
      |              ^
Language: C++

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int,int>pii;

const int maxn=1e5+55;
int a;
int main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	int n;
	cin>>n;
	// map<int,set<int> >mpp;
	for(int i=1 ; i<=n ; i++) {
		cin>>a;

		mpp[i].insert(a);
	}
	int cnt=0;
	for(map<int,int>::iterator it=mpp.begin() ; it!=mpp.end() ; it++) {
		int u=it->ff;
		for(set<int>::iterator it2=it->ss.begin() ; it2!=it->ss.end() ; it2++) {
			int v=*it2;
			if(mpp[v].find(u)!=mpp.end()) {	
				++cnt;
				mpp[v].erase(u);
				break;
			}
		} 
		mpp[u].erase(v);
	}
	
	/*for (int i=1 ; i<=n ; i++) {
		if(a[a[i]]==i)
			cnt++;
	}*/
	cnt/=2;
	cout<<cnt<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: 'mpp' was not declared in this scope; did you mean 'mp'?
   22 |                 mpp[i].insert(a);
      |                 ^~~
      |                 mp
a.cc:25:39: error: 'mpp' was not declared in this scope; did you mean 'mp'?
   25 |         for(map<int,int>::iterator it=mpp.begin() ; it!=mpp.end() ; it++) {
      |                                       ^~~
      |                                       mp
a.cc:27:51: error: request for member 'begin' in 'it.std::_Rb_tree_iterator<std::pair<const int, int> >::operator->()->std::pair<const int, int>::second', which is of non-class type 'int'
   27 |                 for(set<int>::iterator it2=it->ss.begin() ; it2!=it->ss.end() ; it2++) {
      |                                                   ^~~~~
a.cc:27:73: error: request for member 'end' in 'it.std::_Rb_tree_iterator<std::pair<const int, int> >::operator->()->std::pair<const int, int>::second', which is of non-class type 'int'
   27 |                 for(set<int>::iterator it2=it->ss.begin() ; it2!=it->ss.end() ; it2++) {
      |                                                                         ^~~
a.cc:35:30: error: 'v' was not declared in this scope
   35 |                 mpp[u].erase(v);
      |                              ^
Language: C++

#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
using namespace std;
int a[1e5];

int main(){
	int N,j,num;
	num=0;
	cin >> N;
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<N;i++){
		j = a[i];
		if(a[j-1]==i+1)
			num = num+1;	
	}
	cout << num/2 << endl;
	return 0;
};

Compiler output:
a.cc:6:7: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    6 | int a[1e5];
      |       ^~~
a.cc:6:7: error: could not convert '1.0e+5' from 'double' to 'long unsigned int'
    6 | int a[1e5];
      |       ^~~
      |       |
      |       double
a.cc:6:7: error: size of array 'a' has non-integral type 'double'
Language: C++

#include <bits/stdc++.h>

int main()
{
vector<int> pairs;
int n;
int value;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>value;
pairs[i] = value;
}
int count =0;
for(int i=1;i<=n;i++)
{
if(pairs[pairs[i]]==i)
{
 count++;
}

cout<<count/2;
}

return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:1: error: 'vector' was not declared in this scope
    5 | vector<int> pairs;
      | ^~~~~~
a.cc:5:1: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 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/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:5:8: error: expected primary-expression before 'int'
    5 | vector<int> pairs;
      |        ^~~
a.cc:8:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 | cin>>n;
      | ^~~
      | std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:12:1: error: 'pairs' was not declared in this scope
   12 | pairs[i] = value;
      | ^~~~~
a.cc:17:4: error: 'pairs' was not declared in this scope
   17 | if(pairs[pairs[i]]==i)
      |    ^~~~~
a.cc:22:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   22 | cout<<count/2;
      | ^~~~
      | std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C

# include <stdio.h>
//# include <iostream>
//# include <cstdio>
//# include <conio.h>

//using namespace std;

const int N = 100100;

int n, a [N], i, j, k;

int main ()
{
   scanf ("%d", &n);
   
   for ( i=1; i <= n; i++ )
      scanf ("%d", &a [i]);

   for ( i=1; i <= n; i++ )
   {
      j = a [i];
      if ( a [j] == i )
         k++;
   }

   printf ("%d", k/2);

//getch();
   return 0;
}


Compiler output:
main.c:10:8: error: variably modified 'a' at file scope
   10 | int n, a [N], i, j, k;
      |        ^
Language: C

#include <iostream>
using namespace std;
int main(){
	int n;
	scanf("%d", &n);
	int *x = new int[n];
	for (int i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	int count = 0;
	for (int i = 0; i < n-1; i++){
		for (int j = i + 1; j < n; j++){
			if (x[i] == j + 1 && x[j] == i+1){
				count++;
				if (count == n / 2) break;
				break;
			}
		}
	}

	printf("%d", count);
	free(x);
	return 0;
}

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

#include <stdio.h>
int main(){
	int n;
	scanf("%d", &n);
	int *x = new int[n];
	for (int i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	int count = 0;
	for (int i = 0; i < n-1; i++){
		for (int j = i + 1; j < n; j++){
			if (x[i] == j + 1 && x[j] == i+1){
				count++;
				if (count == n / 2) break;
				break;
			}
		}
	}

	printf("%d", count);
	free(x);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:5:18: error: 'new' undeclared (first use in this function)
    5 |         int *x = new int[n];
      |                  ^~~
main.c:5:18: note: each undeclared identifier is reported only once for each function it appears in
main.c:5:22: error: expected ',' or ';' before 'int'
    5 |         int *x = new int[n];
      |                      ^~~
main.c:21:9: error: implicit declaration of function 'free' [-Wimplicit-function-declaration]
   21 |         free(x);
      |         ^~~~
main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'free'
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | int main(){
main.c:21:9: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
   21 |         free(x);
      |         ^~~~
main.c:21:9: note: include '<stdlib.h>' or provide a declaration of 'free'
Language: C++

# cook your code here
a = int(raw_input())
ss = raw_input().split()
lst = []
c = 0

i = 0
for s in ss:
    if s not in lst:
        if int(ss[int(ss[i])-1]) == i+1:
            c=c+1
            lst.append(s)
            lst.append(ss[int(ss[i])-1])
    i=i+1
    

    

print c

Compiler output:
a.cc:1:3: error: invalid preprocessing directive #cook
    1 | # cook your code here
      |   ^~~~
a.cc:2:1: error: 'a' does not name a type
    2 | a = int(raw_input())
      | ^
Language: C++

#include <iostream>
#include <string>

using namespace std;

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

    string likes;
    cin >> likes;

    int pairs = 0;
    for(int i = 0; i < number; i++){
        int r1 = i+1;
        int r1_likes = atoi(likes[i*2]);
        int r2_likes = atoi(likes[r1_likes*2]);

        if(r1 == r2_likes)
            pairs++;
    }
    cout << pairs << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:28: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const char*' [-fpermissive]
   17 |         int r1_likes = atoi(likes[i*2]);
      |                        ~~~~^~~~~~~~~~~~
      |                            |
      |                            __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~
a.cc:18:28: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const char*' [-fpermissive]
   18 |         int r2_likes = atoi(likes[r1_likes*2]);
      |                        ~~~~^~~~~~~~~~~~~~~~~~~
      |                            |
      |                            __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;
int main(void) {
	long n,l[100000];
	int  p=0;
	cin >> n ;
	for (long i = 1; i < n+1; i++) {
		cin >> l[i];
	}
	for (long i = 1; i < n/2+1; i++) {
		if (i == l[l[i]]) {
			p++;
		}
	}

	std::cout << p << std::endl;
	return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: expected '}' at end of input
   18 |         return 0;
      |                  ^
a.cc:4:16: note: to match this '{'
    4 | int main(void) {
      |                ^
Language: C++

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


#define ll long long
#define ull unsigned long long
#define pb push_back

#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()


bool flag[100001][100001];
bool visited[100001];
int a[100001];

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);

   ll n,cnt=0,i,j;
   cin>>n;

   fr(i,1,n)
    scanf("%d",&a[i]) , flag[i][a[i]]=1;

   fr(i,1,n)
    {
        if(visited[i]==0)
        {
            if(flag[i][a[i]]==1 && flag[a[i]][i]==1)
                cnt++ , visited[i]=1 , visited[a[i]]=1;
        }
    }

    cout<<cnt<<endl;



    return 0;
}




Compiler output:
/tmp/ccCuUIf6.o: in function `main':
a.cc:(.text+0x3f): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccCuUIf6.o
a.cc:(.text+0x6c): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccCuUIf6.o
a.cc:(.text+0xaf): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccCuUIf6.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccCuUIf6.o
a.cc:(.text+0x112): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccCuUIf6.o
a.cc:(.text+0x146): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccCuUIf6.o
a.cc:(.text+0x163): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccCuUIf6.o
a.cc:(.text+0x16f): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccCuUIf6.o
collect2: error: ld returned 1 exit status
Language: Java

import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] num = new int[a];
		for (int i = 0; i < a; i++) {
			num[i] = sc.nextInt();
		}
		sc.close();
		int count = 0;
		
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < a; i++) {
			if (i + 1 <= num[i]) {
				if (map.containsKey(key))
				map.put(i + 1, num[i]);
			}
			else {
				map.put(num[i], i + 1);
			}
		}
		System.out.println(a - map.size());
	}

	
}

Compiler output:
Main.java:17: error: cannot find symbol
				if (map.containsKey(key))
				                    ^
  symbol:   variable key
  location: class Main
1 error
Language: C

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

int main() {
	int n;
	int *a = malloc(n * sizeof(int));
	int result = 0;
	for(int i=0; i<n; i++){
		scanf("%d", a+i);
	}
	for(int i=0; i<n; i++){
		if(a[i]!=-1 && a[a[i]]=i){
			result++;
			a[i] = -1;
			a[a[i]] = -1;
		}
	}
	printf("%d", result);
}

Compiler output:
main.c: In function 'main':
main.c:12:39: error: lvalue required as left operand of assignment
   12 |                 if(a[i]!=-1 && a[a[i]]=i){
      |                                       ^
Language: Java

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ni = sc.nextInt();
		int au[] = new int[ni];

		int nj =1;
		int tnum=0;

		au[0] =  sc.nextInt();
//		for (int i=1; i < ni; i++){
//			au[i] =  sc.nextInt();
//		}
		for (int i=1; i < ni; i++){
			tnum = sc.nextInt();
			boolean flg = true;
			for (int j =0; j< nj; j++){
				if(tnum == au[j]){
					flg = false;
				}
			}
			if (flg){
				//System.out.println(nj);
				au[nj] = tnum;
				nj++;
			}

		}

//		System.out.println(nj);
//		for(int j=0; j < nj;j++){
//			System.out.println(au[j]);
//		}
		System.out.println(au.length);
		if (nj%2 == 0){
			System.out.println(nj/2);
		}else{
			System.out.println(0);
		}
		sc.close();
	}

Compiler output:
Main.java:44: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

s1 = raw_input()
s2 = raw_input()
s2 = s2.split(" ")
f = 0
for a,b in enumerate(s2):
    if s2[b] == str(a):
        f++
print f

Compiler output:
a.cc:1:1: error: 's1' does not name a type
    1 | s1 = raw_input()
      | ^~
Language: C++

int main() {

	long int n;
	cin >> n;
	vector<vector<long int> > friends;

	friends.resize(n);
	for (long int i = 0; i < n; ++i) {
		friends[i].resize(n);
	}

	for(long int i = 0 ; i < n ; i++) {
		for (long int k = 0 ; k < n ; k++) {
			friends[i][k] = 0;
		}
	}

	for(long int i = 0 ; i < n ; i++) {
		long int place;
		cin >> place;
		friends[i][place-1] = 1;
	}

	long int counter = 0;
	for(long int j = 0 ; j < n ; j++) {
		for (long int k = 0 ; k < n ; k++) {
			if(friends[j][k] && friends[k][j]) {
				counter++;
			}
		}
	}

	cout << counter/2;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin >> n;
      |         ^~~
a.cc:5:9: error: 'vector' was not declared in this scope
    5 |         vector<vector<long int> > friends;
      |         ^~~~~~
a.cc:5:23: error: expected primary-expression before 'long'
    5 |         vector<vector<long int> > friends;
      |                       ^~~~
a.cc:7:9: error: 'friends' was not declared in this scope; did you mean 'friend'?
    7 |         friends.resize(n);
      |         ^~~~~~~
      |         friend
a.cc:33:9: error: 'cout' was not declared in this scope
   33 |         cout << counter/2;
      |         ^~~~
Language: Java

public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n+1];
        for(int i=1;i<=n;i++){
            arr[i] = in.nextInt();
        }
        List<Integer> toAvoid = new ArrayList<>();
        int counter = 0;
        for(int i=1;i<=n;i++){
            if(i!=arr[i] && !toAvoid.contains(i)){
                if(arr[arr[i]] == i){
                    counter++;
                    toAvoid.add(i);
                    toAvoid.add(arr[i]);
                }
            }
        }
        System.out.println(counter);
    }

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args) {
              ^
  (use --enable-preview to enable unnamed classes)
1 error