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

#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main() {
    ll N,cnt=0;
    cin>>N;
    vector<ll> data(N);
    rep0(i,N){cin>>data.at(i);}
    rep0(i,N){
        if(data.at(i)==i+1){
            
                
                ll s=data.at();
          
                data.at()=data[i+1];
                data[i+1]=s;
                cnt++;

            
        }
    }
    cout<<cnt<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:29: error: no matching function for call to 'std::vector<long long int>::at()'
   17 |                 ll s=data.at();
      |                      ~~~~~~~^~
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:1180:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
 1180 |       at(size_type __n)
      |       ^~
/usr/include/c++/14/bits/stl_vector.h:1180:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1199:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::at(size_type) const [with _Tp = long long int; _Alloc = std::allocator<long long int>; const_reference = const long long int&; size_type = long unsigned int]'
 1199 |       at(size_type __n) const
      |       ^~
/usr/include/c++/14/bits/stl_vector.h:1199:7: note:   candidate expects 1 argument, 0 provided
a.cc:19:24: error: no matching function for call to 'std::vector<long long int>::at()'
   19 |                 data.at()=data[i+1];
      |                 ~~~~~~~^~
/usr/include/c++/14/bits/stl_vector.h:1180:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
 1180 |       at(size_type __n)
      |       ^~
/usr/include/c++/14/bits/stl_vector.h:1180:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1199:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::at(size_type) const [with _Tp = long long int; _Alloc = std::allocator<long long int>; const_reference = const long long int&; size_type = long unsigned int]'
 1199 |       at(size_type __n) const
      |       ^~
/usr/include/c++/14/bits/stl_vector.h:1199:7: note:   candidate expects 1 argument, 0 provided
Language: C

#include <stdio.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)

int main() {
	int n,tmp,ans=0;
	scanf("%d\n", &n);
	rep(i,n) {
		scanf("%d", &tmp);
		if (tmp == i+1) {ans++; i++;}
	printf("%d", ans);
}

Compiler output:
main.c: In function 'main':
main.c:12:1: error: expected declaration or statement at end of input
   12 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>p(N+2);
  for(int i=1;i<=N;i++)
    cin>>p.at(i);
  p.at(0)=-1; p.at(N+1)=-1;
  int sum=0;
  for(int i=1;i<=N+1;i++){
  if(p.at(i)==i)
    sum++;
    else{
     A.push_back(sum); sum=0;
    }
    }int ans=0;
  for(auto x:p){
  ans+=(1+sum)/2;
  }cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:6: error: 'A' was not declared in this scope
   15 |      A.push_back(sum); sum=0;
      |      ^
Language: C++

#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin >> n;
  int a, ans = 0;
  reps(i, n){
    cin >> a[i];
  }
  reps(i, n){
    if(a == i){
      swap(a[i], a[i + 1]);
      ans ++;
    }
  }
  cout << ans << '\n';
  return 0;
}


Compiler output:
a.cc:6:28: error: extended character 　 is not valid in an identifier
    6 | #define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
      |                            ^
a.cc: In function 'int main()':
a.cc:30:13: error: invalid types 'int[int]' for array subscript
   30 |     cin >> a[i];
      |             ^
a.cc:34:13: error: invalid types 'int[int]' for array subscript
   34 |       swap(a[i], a[i + 1]);
      |             ^
a.cc:34:19: error: invalid types 'int[int]' for array subscript
   34 |       swap(a[i], a[i + 1]);
      |                   ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
  int n;
  scanf("%d", &n);
  
  int ans = 0;
  int tmp = 0;
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    
    if (a == i) {
      tmp++;
    }
    else {
      ans += (tmp + 1) / 2;
      tmp = 0;
    }
  }
  printf("%d\n", ans + (tmp + 1) / 2;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:37: error: expected ')' before ';' token
   24 |   printf("%d\n", ans + (tmp + 1) / 2;
      |         ~                           ^
      |                                     )
Language: C++

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

int main() {
    int N; cin >> N;
    vector<int> p(N+1);
    p[0] = -1;
    for (int i = 1; i <= N; i++) {
        cin >> p[i];
    }
    int tmp = 1;
    int ans = 0;
    while (tmp <= N) {
        if (p[tmp] == tmp) {
            ans++;
            if (tmp+1 <= N)
                swap(p[tmp], p[tmp+1]);
        }
        tmp++
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:14: error: expected ';' before '}' token
   22 |         tmp++
      |              ^
      |              ;
   23 |     }
      |     ~
Language: C++

int main(){
  int N, count, cap;
  cin >> N >> count >> cap;
  
  vector<int> num(N);
  for (int i = 0; i < N; i++){
    if (num.at(i) = i){
      cap == num.at(i) ;
      num.at(i) == num.at(i - 1);
      num.at(i - 1) == cap;
      count++;
    }
    else
      return(0);
  }
  cout >> count >> endl;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >> N >> count >> cap;
      |   ^~~
a.cc:5:3: error: 'vector' was not declared in this scope
    5 |   vector<int> num(N);
      |   ^~~~~~
a.cc:5:10: error: expected primary-expression before 'int'
    5 |   vector<int> num(N);
      |          ^~~
a.cc:7:9: error: 'num' was not declared in this scope; did you mean 'enum'?
    7 |     if (num.at(i) = i){
      |         ^~~
      |         enum
a.cc:16:3: error: 'cout' was not declared in this scope; did you mean 'count'?
   16 |   cout >> count >> endl;
      |   ^~~~
      |   count
a.cc:16:20: error: 'endl' was not declared in this scope
   16 |   cout >> count >> endl;
      |                    ^~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



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

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a;
  a = 0;
  in(n);
  vector<ll> a(n), b(n, 0);
  rep(i, n){
    in(a[i]);
    if(a[i] == i + 1)
      b[i]++;
  }
  rep(i, n - 1){
    if(b[i] == 1){
      b[i]--;
      a++;
      b[i + 1]--;
    }
  }
  out(a);
  memi;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:14: error: conflicting declaration 'std::vector<long long int> a'
   21 |   vector<ll> a(n), b(n, 0);
      |              ^
a.cc:18:9: note: previous declaration as 'll a'
   18 |   ll n, a;
      |         ^
a.cc:23:9: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   23 |     in(a[i]);
      |         ^
a.cc:11:22: note: in definition of macro 'in'
   11 | #define in(n) cin >> n
      |                      ^
a.cc:24:9: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   24 |     if(a[i] == i + 1)
      |         ^
Language: C++

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<string>
#define dint __int128
using namespace std;
#define kk putchar(32)
#define gc getchar()
#define fup(i,a,b) for(int i=a,i##e=b;i<=i##e;++i)
#define fdn(i,a,b) for(int i=a,i##e=b;i>=i##e;--i)
#define mem(a,b) memset(a,b,sizeof(a))
#define hh putchar(10)
#define ll long long
inline ll rrr(){ll x,f=1;char a;while((a=gc)<48||a>57)if(a==45)f=-1;
for(x=a^48;(a=gc)>47&&a<58;x=(x<<3)+(x<<1)+(a^48));return f*x;}
void Main();int main(){Main();return 0;}

void Main()
{
    int n;cin>>n;
    fup(i,1,n)a[i]=rrr();
    int ans=0;
    fup(i,1,n){
        if(a[i]==i)++ans,++i;
    }
    cout<<ans;
}




Compiler output:
a.cc: In function 'void Main()':
a.cc:29:15: error: 'a' was not declared in this scope
   29 |     fup(i,1,n)a[i]=rrr();
      |               ^
a.cc:32:12: error: 'a' was not declared in this scope
   32 |         if(a[i]==i)++ans,++i;
      |            ^
Language: C++

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  ll n;cin>>n;
  llans=0;
  vector<ll>p(n+1);
  
  for(ll i=1;i<=n;i++){
    cin>>p.at(i);
  }
    for(ll i=1;i<=n;i++){
      if(i==p.at(i)){
        if(i!=n-1){
          p.at(i+1)=p.at(i);
        }
        ans++;
      }
    }
  cout<<ans;
}
        
   

  
    
  


Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: 'llans' was not declared in this scope; did you mean 'llabs'?
   14 |   llans=0;
      |   ^~~~~
      |   llabs
a.cc:25:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |         ans++;
      |         ^~~
      |         abs
a.cc:28:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |   cout<<ans;
      |         ^~~
      |         abs
Language: C++

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  ll n;cin>>n;
  llans=0;
  vector<ll>p(n+1);
  
  for(int i=1;i<=n;i++){
    cin>>p.at(i);
  }
    for(int i=1;i<=n;i++){
      if(i==p.at(i)){
        if(i!=n-1){
          p.at(i+1)=p.at(i);
        }
        ans++;
      }
    }
  cout<<ans;
}
        
   

  
    
  


Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: 'llans' was not declared in this scope; did you mean 'llabs'?
   14 |   llans=0;
      |   ^~~~~
      |   llabs
a.cc:25:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |         ans++;
      |         ^~~
      |         abs
a.cc:28:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |   cout<<ans;
      |         ^~~
      |         abs
Language: C++

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

int main(){
    int n , mistake = 0;
  　cin >> n;
    vector<int> yiyi(n);
    for(int i = 0 ; i < n;i++){
        cin >> yiyi.at(i);
    }
    for(int i = 0 ; i < n;i++){
        if(yiyi.at(i) == (i+1)){
            mistake++;
            i++;
        }
    }
    cout << mistake << endl;
}

Compiler output:
a.cc:8:3: error: extended character 　 is not valid in an identifier
    8 |   　cin >> n;
      |   ^
a.cc: In function 'int main()':
a.cc:8:3: error: '\U00003000cin' was not declared in this scope
    8 |   　cin >> n;
      |   ^~~~~
Language: C++

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

int main() {
    int n; scanf("%d", &n)l

    int res = 0;
    for (int i=1; i<=n; i++) {
        int a; scanf("%d", &a);
        res += (i == a);
    }

    printf("%d\n", min(n-1, res));
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:27: error: expected ';' before 'l'
    5 |     int n; scanf("%d", &n)l
      |                           ^
      |                           ;
a.cc:10:9: error: 'res' was not declared in this scope
   10 |         res += (i == a);
      |         ^~~
a.cc:13:29: error: 'res' was not declared in this scope
   13 |     printf("%d\n", min(n-1, res));
      |                             ^~~
Language: Java

import java.util.Scanner;

public class main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int arr[] = new int [n+1]; 
		boolean flag = false;
		for(int i=1 ; i <= n ; i++){
			arr[i] = scanner.nextInt();
		}
		int count = 0;
		int i = 1;
		
		while(flag == false){
			if(i == n+1){
				i=1;
			}
			if(arr[i] == i){
				if(i!=n){
					int temp = arr[i];
					arr[i] = arr[i+1];
					arr[i+1] = temp;
					i++;
					count ++;
				}else{
					int temp = arr[i];
					arr[i] = arr[i-1];
					arr[i-1] = temp;
					i++;
					count ++;
				}
			}else{
				i++;
			}
			
			if(i == n+1){
				for(int j=1 ; j<=n ; j++){
					if(arr[j] == j){
						break;
					}
					if(j == n) flag = true;
				}
			}
		}
		
		
		for(int j = 1 ; j<=n ; j++){
			System.out.print(arr[j]+" ");
		}
		System.out.println();
		System.out.println(count);
		
	}
}


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

#include <stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int flag = 0;
  int out = 0;
  for(int i = 1; i < n+1; i++){
    scanf("%d",&j);
    if(i == j){
      flag++;
      out++;
    }else{
      if(flag > 1){
        out = out - flag / 2
      }
      flag = 0;
    }
  }
}


Compiler output:
main.c: In function 'main':
main.c:8:17: error: 'j' undeclared (first use in this function)
    8 |     scanf("%d",&j);
      |                 ^
main.c:8:17: note: each undeclared identifier is reported only once for each function it appears in
main.c:14:29: error: expected ';' before '}' token
   14 |         out = out - flag / 2
      |                             ^
      |                             ;
   15 |       }
      |       ~
Language: C++

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

int main()
{
 	int n;
  	cin>>n;
	int arr[n];
  	for(int i=0;i<n;i++)
      cin>>arr[i];
    int count=0;
  	for(int i=0;i<n-1;i++)
    {
      if(arr[i]==(i+1))
      {  
        count++;
        temp=arr[i];
        arr[i+1]=arr[i];
        arr[i]=temp;
      }
    }
  	if(arr[n-1]==n)
  		count++;
  
  	cout<<count<<endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'temp' was not declared in this scope; did you mean 'tm'?
   17 |         temp=arr[i];
      |         ^~~~
      |         tm
Language: C++

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

int main()
{
 	int n;
  	cin>>n;
	int arr[n];
  	for(int i=0;i<n;i++)
      cin>>arr[i];
    int adjcount=0;
  	int sincount=0;
  	int prevadj=-1;
  	int prev=0;
  	int curr=0,next=1;
  	int i=0;
  	flag=0;
  	while(next<n){
    	if(curr==arr[curr])
        {
          	if(next==arr[next])
            {
              	adjcount+=2;
              	prevadj=next;
              	prev=next;
              	curr=curr+2;
              	next=next+2;
              	
            }
        }
      
      	if((prevadj==(curr-1)) && (prevadj!=-1) && (curr==arr[curr]))
        {
         	 adjcount+=1;
          	 prev=curr;
          	 curr++;	
          
        }
      	else if(curr==arr[curr])
        {
          	adjcount+=1
        }
    }
  
  
  
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'flag' was not declared in this scope
   17 |         flag=0;
      |         ^~~~
a.cc:41:28: error: expected ';' before '}' token
   41 |                 adjcount+=1
      |                            ^
      |                            ;
   42 |         }
      |         ~
Language: C++

#include <iostream>
#include <vector>

using namespaee std;

int main() {
  int n = 0;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
  }
  int cnt = 0;
  for (int i=0; i<n; i++) {
    if (i+1 == a.at(i)) {
      cnt++;
    }
  }
  cout << (cnt%2 == 0 ? cnt/2 : cnt/2 + 1) << endl;
  return 0;
}


Compiler output:
a.cc:4:7: error: expected nested-name-specifier before 'namespaee'
    4 | using namespaee std;
      |       ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |   cin >> n;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int> a(n);
      |   ^~~~~~
a.cc:9:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/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:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> a(n);
      |          ^~~
a.cc:11:12: error: 'a' was not declared in this scope
   11 |     cin >> a.at(i);
      |            ^
a.cc:15:16: error: 'a' was not declared in this scope
   15 |     if (i+1 == a.at(i)) {
      |                ^
a.cc:19:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   19 |   cout << (cnt%2 == 0 ? cnt/2 : cnt/2 + 1) << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:19:47: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   19 |   cout << (cnt%2 == 0 ? cnt/2 : cnt/2 + 1) << endl;
      |                                               ^~~~
      |                                               std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i=0;i<N;i++) {
            int A = Integer.parseInt(sc.next());
            if (A==(i+1)) {
                cnt++;
                i++;
            }
        }
        System.out.println(ans);
    }
}

Compiler output:
Main.java:11: error: cannot find symbol
                cnt++;
                ^
  symbol:   variable cnt
  location: class Main
1 error
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:54: error: request for member 'i' in '(cnt --)', which is of non-class type 'int'
   14 |         if(A[i] == i + 1 && A[i + 1] == i + 2)cnt--. i++;
      |                                                      ^
Language: Java

from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    N = int(input())
    p = list(map(int,input().split()))
    ans = 0
    for i in range(N):
        if p[i] == i+1:
            ans += 1

    print(ans)    
if __name__ == "__main__":
    main() #endline===============================================

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
from collections import deque,defaultdict,Counter
^
Main.java:9: error: illegal character: '#'
#import numpy as np
^
Main.java:10: error: illegal character: '#'
#import sympy as syp(???????)
^
Main.java:37: error: '{' expected
class UnionFind:
               ^
Main.java:53: error: class, interface, enum, or record expected
        if px < py:
              ^
Main.java:64: error: illegal character: '#'
def main(): #startline-------------------------------------------
            ^
Main.java:74: error: illegal character: '#'
    main() #endline===============================================
           ^
7 errors
Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

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

    ll p[n+1] = {};
    REP(i,n)
    {
        cin >> p[i];
        --p[i];
    }

    ll res = 0;

    REP(i,n)
    {
        if(i == p[i])
        {
            if(i+1 = p[i+1])
            {
                ++res;
                ++i;//skip
            }
            else
            {
                ++res;
            }
        }
    }

    cout << res << endl;

    return 0;    
}



Compiler output:
a.cc: In function 'int main()':
a.cc:31:17: error: lvalue required as left operand of assignment
   31 |             if(i+1 = p[i+1])
      |                ~^~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {

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

	int counter = 0;
	for (int i = 0; i < n-1; i++) {
		if (p[i] == i+1) {
			counter++;
			i++;
		}
	}
	if (p[n - 1] == n && n%2!=0) { counter++; }
	cout << counter << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:22:33: error: expected '}' at end of input
   22 |         cout << counter << endl;
      |                                 ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C

#include<bits/stdc++.h>
int n,i,f=1,ans;
int main(){
	std::cin>>n;
	int p[n];
	for(;i<n;)std::cin>>p[i],(p[i]==++i&&f)?ans++,f=0:f=1;
	std::cout<<ans;
	return 0;
}

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

vv#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int n;
    cin >> n;
    vi v(n);
    rep(i,n){
        cin >> v[i];
    }
    int ans = 0;
    rep(i, n)
    {
        if(v[i]==i+1){
            ans++;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:1:3: error: stray '#' in program
    1 | vv#include "bits/stdc++.h"
      |   ^
a.cc:1:1: error: 'vv' does not name a type
    1 | vv#include "bits/stdc++.h"
      | ^~
a.cc:8:9: error: 'pair' does not name a type
    8 | typedef pair<int,int> P;
      |         ^~~~
a.cc:9:9: error: 'vector' does not name a type
    9 | typedef vector<int> vi;
      |         ^~~~~~
a.cc:10:9: error: 'vector' does not name a type
   10 | typedef vector<vi> vvi;
      |         ^~~~~~
a.cc: In function 'int main()':
a.cc:15:5: error: 'cin' was not declared in this scope
   15 |     cin >> n;
      |     ^~~
a.cc:16:5: error: 'vi' was not declared in this scope
   16 |     vi v(n);
      |     ^~
a.cc:18:16: error: 'v' was not declared in this scope
   18 |         cin >> v[i];
      |                ^
a.cc:23:12: error: 'v' was not declared in this scope
   23 |         if(v[i]==i+1){
      |            ^
a.cc:28:5: error: 'cout' was not declared in this scope
   28 |     cout << ans << endl;
      |     ^~~~
a.cc:28:20: error: 'endl' was not declared in this scope
   28 |     cout << ans << endl;
      |                    ^~~~
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
 	Scanner scanner = new Scanner(System.in);
    int[] numbers = new int[scanner.nextInt()];
    for (int ix = 0; ix < numbers.length; ix++) {
       numbers[ix] = scanner.nextInt();
    }
	
    int swaps = 0;
    for (int ix = 0; ix < numbers.length; ix++) {
      if (numbers[ix] == x) {
        swaps++;
		if (ix < numbers.length - 1) {
          int temp = numbers[ix];
          numbers[ix] = numbers[ix + 1];
          numbers[ix + 1] = temp;
        } else if (ix >= 0) {
          int temp = numbers[ix];
          numbers[ix] = numbers[ix - 1];
          numbers[ix - 1] = temp;
        }
      }
    }
    
	System.out.println(swaps);
  }
}

Compiler output:
Main.java:13: error: cannot find symbol
      if (numbers[ix] == x) {
                         ^
  symbol:   variable x
  location: class Main
1 error
Language: C++

#include <iostream>
using namespace std;

int main(){
    int n, i, buf, m=-1, c=0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> buf;
        if(m == -1 && buf == i){
            m = buf;
        }else if(m!=-1 && buf == i{
            c += buf - m;
        }
    }
    cout << min(c, n-c-1);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:35: error: expected ')' before '{' token
   11 |         }else if(m!=-1 && buf == i{
      |                 ~                 ^
      |                                   )
a.cc:14:5: error: expected primary-expression before '}' token
   14 |     }
      |     ^
Language: C++

#include <iostream>
using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int b[n];
  for(int i=0;i<n;i++){
    if(a[i]==i){
      b[i]=1;
    }
    else{
      b[i]=0:
    }
  }
  for(int i=0;i<n-1;i++){
    if(b[i]==1&&b[i+1]==1){
      b[i+1]=2;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(b[i]==1){
      ans++;
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: expected ';' before ':' token
   17 |       b[i]=0:
      |             ^
      |             ;
Language: C++

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;
int p[111111];

signed main() {
   cin >> N;
   rep (i, N) {
      cin >> p[i];
   }

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

   if (N&1) {
      if (p[i] == N) {
         ans++;
      }
   }

   cout << ans << endl;

   return 0;
}

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

#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

/*void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<111111;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}

int COM(int n,int k){
	if(n<k)return 0;
	if(n<0||k<0)return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}*/

//}

int n;
vector<int> a;
int ans;
bool flg;

main(){
  cin>>n;
  rep(i,n){
    if(i+1==tmp){
      if(flg){
        a.back()++;
        }else{
        flg==true;
        a.pb(1);
        }
      }
    else flg=false;
    }
  for(int x:a)ans+=(x+1)/2;
  dans;
}


Compiler output:
a.cc:8:9: warning: "INT_MAX" redefined
    8 | #define INT_MAX LLONG_MAX
      |         ^~~~~~~
In file included from /usr/include/c++/14/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:38,
                 from a.cc:5:
/usr/lib/gcc/x86_64-linux-gnu/14/include/limits.h:120:9: note: this is the location of the previous definition
  120 | #define INT_MAX __INT_MAX__
      |         ^~~~~~~
a.cc:66:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   66 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:69:13: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   69 |     if(i+1==tmp){
      |             ^~~
      |             tm
Language: Java

public class Main {

    int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] p = new int[N];
        int c = 0;
        long ans = 0;
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
            if (p[i] == i + 1) {
                c++;
            } else if (c <= 1) {
                ans += c;
            } else {
                ans += c - 1;
                c = 0;
            }
        }
        if (c <= 1) {
            ans += c;
        } else {
            ans += c - 1;
            c = 0;
        }
        System.out.println(ans);
    }
}

Compiler output:
Main.java:10: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:10: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
ll ans;
string S;
ll N;
ll T[101];
ll p[100001];

int main() {
	cin >> N;
	rep(i, 1, N + 1) {
		cin >> p[i];
	}
	ans = 0;
	ll count = 0;
	rep(i, 1, N + 1) {
		if (p[i] == i) {
			count++;
			if (count == 2) {
				count = 0;
				ans++;
			}
		}
		else {
			if (count == 1) {
				count = 0;
				ans++;
			}
		}
	}
	if (count == 1) {
		count = 0;
		ans++;
	cout << ans << endl;
	cin >> ans;
	return 0;
}


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

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int n,c=0;
	cin>>n;
	int p[100000];
	for(int i=0;i<n;i++)cin>>p[i];
	for(int i=0;i<n;i++){
		if(p[i]==i+1){
			swap(p[i],p[i+1];);
			c++;
		}
	}
	cout<<c<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:41: error: expected ')' before ';' token
   13 |                         swap(p[i],p[i+1];);
      |                             ~           ^
      |                                         )
a.cc:13:42: error: expected primary-expression before ')' token
   13 |                         swap(p[i],p[i+1];);
      |                                          ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int n,c=0;
	cin>>n;
	int p[100000];
	for(int i=0;i<n;i++)cin>>p[i];
	for(int i=0;i<n;i++){
		if(p[i]==i+1)swap(p[i],p[i+1])c++;
	}
	cout<<c<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:47: error: expected ';' before 'c'
   12 |                 if(p[i]==i+1)swap(p[i],p[i+1])c++;
      |                                               ^
      |                                               ;
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int n;
	cin>>n;
	int p[100000];
	for(int i=0;i<n;i++)cin>>p[i];
	for(int i=0;i<n;i++){
		if(p[i]==i+1)swap(p[i],p[i+1])c++;
	}
	cout<<c<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:47: error: expected ';' before 'c'
   12 |                 if(p[i]==i+1)swap(p[i],p[i+1])c++;
      |                                               ^
      |                                               ;
a.cc:14:15: error: 'c' was not declared in this scope
   14 |         cout<<c<<endl;
      |               ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main(){
    int i,N,ans;
cin >> N;
vector <int> p(N);
for(i=0;i<N;i++){
    cin >> p[i];
}
ans = 0;
for(i=0;i<N-1;i++){
if(p[i]==i+1){
    p[i+1]=p[i];
    ans +=1
}
}
if(p[N-1]==N){
    ans += 1;
}
cout << ans << endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:12: error: expected ';' before '}' token
   15 |     ans +=1
      |            ^
      |            ;
   16 | }
      | ~
Language: C++

#include <stdio.h>

                                                                                                
  
int main(void){
                                                                                                
   
    long long n, i, t;

    long long p[100010];

    long long k = 0;
   
      
    scanf("%lld", &n );
     
   

    for( i = 1 ; i <= n ; i = i + 1 ){

         scanf("%lld", &p[i] );      

         }


    for( i = 1 ; i <= n - 1 ; i = i + 1 ){

         if( p[i] == i || p[i + 1] == i + 1 ){

             t = p[i];

             p[i] = p[i + 1];

             p[i + 1] = t

             k += 1;

             }

         }



    printf("%lld\n", k );


    return 0;
                                                          
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:26: error: expected ';' before 'k'
   34 |              p[i + 1] = t
      |                          ^
      |                          ;
   35 | 
   36 |              k += 1;
      |              ~
Language: C++

#include<iostream>
#include<algorithm> 
using namespace std;
int main()
{
int n,i,x,n=0;
cin>>n;
vector <int> p(n,0);
for(i=0;i<n;i++) cin>>p[i];
for(i=0;i<n-1;i++)
{
if((p[i]==(i+1))and(p[i+1]==(i+2)))
{
x=p[i];
p[i]=p[i+1];
p[i+1]=x;
n++;
}
}
for(i=0;i<n;i++)
{
if(p[i]==(i+1))
{
x=p[i];
if(i==(n-1))
{
p[i]=p[i-1];
p[i-1]=x;
}
else
{
p[i]=p[i+1];
p[i+1]=x;
}
n++;
}
}
cout<<n;
system ("pause"); 
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:11: error: redeclaration of 'int n'
    6 | int n,i,x,n=0;
      |           ^
a.cc:6:5: note: 'int n' previously declared here
    6 | int n,i,x,n=0;
      |     ^
a.cc:8:1: error: 'vector' was not declared in this scope
    8 | vector <int> p(n,0);
      | ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include<algorithm>
  +++ |+#include <vector>
    3 | using namespace std;
a.cc:8:9: error: expected primary-expression before 'int'
    8 | vector <int> p(n,0);
      |         ^~~
a.cc:9:23: error: 'p' was not declared in this scope
    9 | for(i=0;i<n;i++) cin>>p[i];
      |                       ^
a.cc:12:5: error: 'p' was not declared in this scope
   12 | if((p[i]==(i+1))and(p[i+1]==(i+2)))
      |     ^
a.cc:22:4: error: 'p' was not declared in this scope
   22 | if(p[i]==(i+1))
      |    ^
Language: C++

#include<iostream>
#include<string.h> 
#include<map>
#include<math.h>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<stdio.h>
using namespace std;
int main(){
int a,g,f;
int s[10000];
cin>>a;
for(int i=1;i<=a;i++)
cin>>s[i];
for(int j=1;j<=a;j++)
if(s[j]<s[j+1]) g=s[j],s[j]=s[j+1],s[j+1]=s[j];
if((j=1) and s[j]=1）
cout<<s'; 
return 0;
}

Compiler output:
a.cc:20:8: warning: missing terminating ' character
   20 | cout<<s';
      |        ^
a.cc:20:8: error: missing terminating ' character
   20 | cout<<s';
      |        ^~ 
a.cc: In function 'int main()':
a.cc:19:5: error: 'j' was not declared in this scope
   19 | if((j=1) and s[j]=1）
      |     ^
a.cc:19:19: error: unable to find numeric literal operator 'operator""\U0000ff09'
   19 | if((j=1) and s[j]=1）
      |                   ^~~
a.cc:22:1: error: expected primary-expression before '}' token
   22 | }
      | ^
a.cc:21:10: error: expected ')' before '}' token
   21 | return 0;
      |          ^
      |          )
   22 | }
      | ~         
a.cc:19:3: note: to match this '('
   19 | if((j=1) and s[j]=1）
      |   ^
a.cc:22:1: error: expected primary-expression before '}' token
   22 | }
      | ^
Language: C++

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

#define INF 100000000

int n, p[100001], dp[100001];

int rec(int idx) {
    if(idx == n) return 0;
    if(idx < 0) return INF;
    if(~dp[idx]) return dp[idx];


    int ret = INF;
    if(idx + 1 == p[idx]) {
        swap(p[idx], p[idx + 1]);
        ret = min(ret, rec(idx + 1) + 1);
        swap(p[idx], p[idx + 1]);
        swap(p[idx], p[idx - 1]);
        ret = min(ret, rec(idx - 1) + 1);
        swap(p[idx], p[idx - 1]);
    } else {
        ret = rec(idx + 1);
    }

    return dp[idx] = ret;
 }

int main() {

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

    memset(dp, -1, sizeof(dp));
    cout << rec(0) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:5: error: 'memset' was not declared in this scope
   37 |     memset(dp, -1, sizeof(dp));
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: Java

import java.util.Scanner;

public class abc72d {
	public static void main(String[] args) {
		int times = 0;
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] plist = new int[N];
		for (int i = 0; i < N; i++) {
			plist[i] = scanner.nextInt();
	    }
	    
	    for (int i = 0; i < N; i++) {
	    	if (i == 0 && plist[i] == 1) {
	    		swap(0, 1, plist);
	    		times++;
	    	} else if (i == N-1 && plist[i] == N) {
	    		swap(N-1, N-2, plist);
	    		times++;
	    	} else if (plist[i] == i+1) {
	    		if (plist[i-1] != i) {
	    			swap(i, i-1, plist);
	    			times++;
	    		} else {
	    			swap(i, i+1, plist);
	    			times++;
	    		}
	    	}
	    }
	    
	   System.out.println(times);
	   }
	   
   public static void swap(int a, int b, int[] list) {
   		int temp;
   		temp = list[a];
   		list[a] = list[b];
   		list[b] = temp;
   }
 } 
		

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

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

struct Queue_data
{
    long long len;
    vector<long long> p;
};

int main()
{
    long long ans = LLONG_MAX;
    long long N;
    cin >> N;
    vector<long long> p;
    p.resize(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> p[i];
    }

    bool flag = true;
    for (long long i = 0; i < N - 1; i++)
    {
        if (p[i] == i + 1)
        {
            long long tmp = p[i];
            p[i] = p[i + 1];
            p[i + 1] = tmp;
        }
    }

    if (p[N - 1] == N)
    {
        long long tmp = p[N - 1];
        p[N - 1] = p[N - 2];
        p[N - 2] = tmp;
    }

    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:21: error: 'LLONG_MAX' was not declared in this scope
   14 |     long long ans = LLONG_MAX;
      |                     ^~~~~~~~~
a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 | using namespace std;
Language: C

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

int main(){
	int N;
	scanf("%d",&N);
	int *P=malloc(N*sizeof(int));
	int i;
	for (i=0;u<N;i++){
		scanf("%d",&P[i]);
	}
	int *Q=P;
	int ans=0;
	if (P[0]==1){
		Q[0]=P[1];
		Q[1]=P[1];
		ans++;
	}
	for (i=1;i<N;i++){
		if (P[i]==i+1){
			if (P[i+1]==i+2){
				Q[i]=P[i+1];
				Q[i+1]=P[i];
				ans++;
			}
			else{
				Q[i]=P[i-1];
				Q[i-1]=P[i];
				ans++;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:18: error: 'u' undeclared (first use in this function)
    9 |         for (i=0;u<N;i++){
      |                  ^
main.c:9:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main()
{
int N, p[100000], cnt = 0;
bool pc[100000];
cin >> N:
for(int i = 1; i <= N; i++) cin >> p[i];
for(int i = 1; i <= N; i++){
if(p[i] == i){
pc[i] = false;
}else{
pc[i] = true;
}
if(pc[i] == false) swap(p[i], p[i + 1]), cnt++;
}
cout << cnt << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: expected ';' before ':' token
    9 | cin >> N:
      |         ^
      |         ;
a.cc:10:16: error: 'i' was not declared in this scope
   10 | for(int i = 1; i <= N; i++) cin >> p[i];
      |                ^