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

#include <bits/stdc++.h>

using namespace std;

int a[111111];
int n;

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

	int an = 0;
	for(int i=1; i<=n; i++){
		int l = i, r = n;
		while(l <= r){
			int md = (l + r) >> 1;
            if(a[md] - a[i] > 2)
                r = md - 1;
			else
                l = md + 1;
		}
		an = max(an, l - i);
	}
	printf("%d",an);
	return 0;
}


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

import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

public class Arraymodification {
	public static void main(String [] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<>();
		for(int i = 0 ; i < n ; i++) {
			int temp = sc.nextInt();
			if(!map.containsKey(temp)) {
			map.put(temp, 1);
			}
			else {
			map.put(temp,map.get(temp)+1);}
		}
		int [] arr = new int[100001];
		for(Entry<Integer, Integer> entry : map.entrySet()) {
		    Integer key = entry.getKey();
		    Integer value = entry.getValue();
		    arr[key] = value;
		}
		int [] n_arr = new int [100001];
		for(int i = 1 ; i < 100000 ; i ++) {
			n_arr[i] = arr[i-1] + arr[i] + arr[i+1];
		}
		int max = - 1;
		for(int i = 0 ; i < 100001 ; i++) {
			if(n_arr[i] > max) {
				max = n_arr[i];
			}
		}
		System.out.println(max);
	}
}

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

import java.util.Scanner;

public class ArrayModification {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		scan.nextLine();

		int[] array = new int[n];
		int max = 0;
		for (int i = 0; i < n; i++) {
			array[i] = scan.nextInt();
			if (array[i] > max) {
				max = array[i];
			}
		}
		int[] result = new int[max + 2];
		int ans = 0;
		for (int i = 0; i < n; i++) {
			result[array[i]]++;
			result[array[i] - 1]++;
			result[array[i] + 1]++;

		}
		max = 0;
		for (int i = 0; i < n; i++) {
			if (result[i] > max) {
				max = result[i];
			}
		}
		System.out.println(max);

	}

}


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

#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int array[n];
    for(int i=0;i<n;i++){
    cin>>array[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
				int chosen = array[i];
				int result = 0;
				for (int j = 0; j < n; j++) {
					if (abs(array[j] - array[i]) == 1 || abs(array[j] - array[i]) == 0) {
						result++;
					}
				}
				ans = max(ans, result);
			}

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


Compiler output:
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <stdlib.h>
^
Main.java:8: error: not a statement
    cin>>n;
       ^
Main.java:9: error: not a statement
    int array[n];
              ^
Main.java:11: error: not a statement
    cin>>array[i];
       ^
Main.java:25: error: not a statement
    cout << ans << endl;
                ^
Main.java:5: error: unnamed classes are a preview feature and are disabled by default.
int main()
^
  (use --enable-preview to enable unnamed classes)
Main.java:9: error: ';' expected
    int array[n];
               ^
8 errors
Language: Java

import java.util.HashMap;
import java.util.Scanner;

public class solve2 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int counter = 0;
		HashMap<Integer, Integer> hash = new HashMap<>();

		int[] array = new int[N];
		for (int i = 0; i < N; i++) {

			array[i] = scan.nextInt();
			if (hash.get(array[i]) == null)
				hash.put(array[i], 1);
			else
				hash.put(array[i], (hash.get(array[i])) + 1);

			if (hash.get(array[i] - 1) == null)
				hash.put(array[i] - 1, 1);
			else
				hash.put(array[i] - 1, hash.get(array[i] - 1) + 1);

			if (hash.get(array[i] + 1) == null)
				hash.put(array[i] + 1, 1);
			else
				hash.put(array[i] + 1, hash.get(array[i] + 1) + 1);

		}
		Object[] array2 = hash.keySet().toArray();
		int max = 0;
		int j= 0;
		for (int i = 0; i < array2.length; i++) {
			if ((int) hash.get(array2[i]) > max){
				max = (int) hash.get(array2[i]);
			j = i;	
			}
			
		}
		System.out.println(max);
//		System.out.println(array2[j]);

	}

}


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

#include <iostream>
#include <algorithm>
#include <fstream>

using namespace std;

int main()
{
    int n;
    cin >> n ;
    int A[n];
    for (int i=0;i<n;i++)
        cin >> A[i];
    sort(A,A+n);
    int Max=0;
    for (int i=0;i<n;i++){
        Max=max(std::upper_bound(A,A+n,A[i]+1)-A-(std::lower_bound(A,A+n,A[i]-1)-A),Max);
    }
    cout << Max;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: no matching function for call to 'max(long int, int&)'
   17 |         Max=max(std::upper_bound(A,A+n,A[i]+1)-A-(std::lower_bound(A,A+n,A[i]-1)-A),Max);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:17:16: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   17 |         Max=max(std::upper_bound(A,A+n,A[i]+1)-A-(std::lower_bound(A,A+n,A[i]-1)-A),Max);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:17:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   17 |         Max=max(std::upper_bound(A,A+n,A[i]+1)-A-(std::lower_bound(A,A+n,A[i]-1)-A),Max);
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: Java

import java.util.Scanner;

public class ArrayModification {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		scan.nextLine();

		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = scan.nextInt();
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int chosen = array[i];
			int result = 0;
			for (int j = 0; j < n; j++) {
				if (Math.abs(array[j] - array[i]) == 1 || Math.abs(array[j] - array[i]) == 0) {
					result++;
				}
			}
			ans = Math.max(ans, result);
		}
		System.out.println(ans);

	}

}


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

n = gets.to_i
inputs = gets.chomp.split(" ").map{ |n| n.to_i }
result,output = 0,0
nums = []
for i in 0..inputs.max+1
	nums.push(inputs.count(i))
end

for i in 1..nums.length-1
	result = nums[i-1..i+1].sum
	output = output > result ? output : result
end

puts output

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
n = gets.to_i
^
1 error
Language: C


int n; //要素数


scanf("%d", &n);
int a[n];//整数列

int i , ii;//ループ用

for(i = 0; i < n; i++){
  scanf("%d", &a[i]);
}//整数列の値を取得

int tmp;

for(i = 0; i < n;i++){
  for(ii = i; ii < n; ii++){
    if(a[i] > a[ii]){
      tmp = a[i];
      a[i] = a[ii];
      a[ii] = tmp;
    }
  }
}

int count = 0, countmax = 0;

int b = 0, c = 0, f = a[0];//bcは前の数字の個数fは探索中の数字
for(i = 0; i < n; i++){
  if(a[i] == f){
    count++;
    if(b + c + count > countmax){
      countmax = b + c + count;
    }
  }else if(a[i] == f + 1){
    b = c;
    c = count;
    count = 1;
    f = a[i];
    if(b + c + count > countmax){
      countmax = b + c + count;
    }
  }else if(a[i] == f + 2){
    b = count;
    c = 0;
    count = 1;
    f = a[i];
    if(b + c + count > countmax){
      countmax = b + c + count;
    }
  }else{
    b = 0;
    c = 0;
    count = 1;
    f = a[i];
    if(b + c + count > countmax){
      countmax = b + c + count;
    }
  }
}

printf("%d", countmax);


Compiler output:
main.c:5:7: error: expected declaration specifiers or '...' before string constant
    5 | scanf("%d", &n);
      |       ^~~~
main.c:5:13: error: expected declaration specifiers or '...' before '&' token
    5 | scanf("%d", &n);
      |             ^
main.c:6:5: error: variably modified 'a' at file scope
    6 | int a[n];//整数列
      |     ^
main.c:10:1: error: expected identifier or '(' before 'for'
   10 | for(i = 0; i < n; i++){
      | ^~~
main.c:10:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   10 | for(i = 0; i < n; i++){
      |              ^
main.c:10:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   10 | for(i = 0; i < n; i++){
      |                    ^~
main.c:16:1: error: expected identifier or '(' before 'for'
   16 | for(i = 0; i < n;i++){
      | ^~~
main.c:16:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   16 | for(i = 0; i < n;i++){
      |              ^
main.c:16:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   16 | for(i = 0; i < n;i++){
      |                   ^~
main.c:28:23: error: initializer element is not constant
   28 | int b = 0, c = 0, f = a[0];//bcは前の数字の個数fは探索中の数字
      |                       ^
main.c:29:1: error: expected identifier or '(' before 'for'
   29 | for(i = 0; i < n; i++){
      | ^~~
main.c:29:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   29 | for(i = 0; i < n; i++){
      |              ^
main.c:29:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   29 | for(i = 0; i < n; i++){
      |                    ^~
main.c:62:8: error: expected declaration specifiers or '...' before string constant
   62 | printf("%d", countmax);
      |        ^~~~
main.c:62:14: error: expected declaration specifiers or '...' before 'countmax'
   62 | printf("%d", countmax);
      |              ^~~~~~~~
Language: C++

#include<iostream>
 
using namespace std;
 
int main(){
  int n,a,b[100001]{0};
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    for(int j=a-1;j<a+1;j++){
      if(j=>0&&j=<100000)b[j]++;
    }
  }
  int MAX=0;
  for(int i=0;i<=100000;i++){
    if(b[i]>MAX)MAX=b[i];
  }
  cout << MAX << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: expected primary-expression before '>' token
   11 |       if(j=>0&&j=<100000)b[j]++;
      |            ^
a.cc:11:18: error: expected primary-expression before '<' token
   11 |       if(j=>0&&j=<100000)b[j]++;
      |                  ^
Language: C++

#include <iostream>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;
int main(void){
  int n, i, max;
  cin >> n;
  int a[100001] = {}, cnt[100001] = {};
  REP(i, n){
    cin >> a[i];
    cnt[a[i]-1]++;
    cnt[a[i]  ]++;
    cnt[a[i]+1]++;
  }
  max = *max_element(cnt,cnt+100001);
  cout << max << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'max_element' was not declared in this scope
   14 |   max = *max_element(cnt,cnt+100001);
      |          ^~~~~~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#define REP(i,n) for(int i=0;i<(n);i++)
#define EREP(i,x,n) for(int i=(x);i<(n);i++)
#define FOR(i,n) for(int i=1;i<(n);i++)
using namespace std;
int main(){
	long int n,a[100100],some1[100100],some2,max=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<100100;i++){
		some1[i]=0;
	}
	if(n==1){
		max=1;
	}
	else if(n==2){
		if(a[0]==a[1]){
			max=2;
		}
		else if(abs(a[0]-a[1])<=2){
			max=2;
		}
		else{
			min=1;
		}
	}
	else{
		for(int i=0;i<n;i++){
			some1[a[i]]++;
			some1[a[i]+1]++;
			some1[a[i]+2]++;
		}
		for(int i=0;i<100100;i++){
			if(max<some1[i]){
				max=some1[i];
			}
		}
	}
	cout<<max<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:29: error: overloaded function with no contextual type information
   31 |                         min=1;
      |                             ^
Language: C++

#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=1e5+10;
int a[maxn]={0},n;
int main()
{
 int x;
 scanf('%d",&n);
 for(int i=1;i<=n;i++)
 {
  scanf('%d",&x);
 a[x]++;
 }
 int ans=0;
 for(int i=1;i<=1e5+3;i++)
 {
  ans=max(ans,a[i]+a[i+1]+a[i+2]);
 }
 printf('%d",ans);
 return 0;
}

Compiler output:
a.cc:9:8: warning: missing terminating ' character
    9 |  scanf('%d",&n);
      |        ^
a.cc:9:8: error: missing terminating ' character
    9 |  scanf('%d",&n);
      |        ^~~~~~~~~
a.cc:12:9: warning: missing terminating ' character
   12 |   scanf('%d",&x);
      |         ^
a.cc:12:9: error: missing terminating ' character
   12 |   scanf('%d",&x);
      |         ^~~~~~~~~
a.cc:20:9: warning: missing terminating ' character
   20 |  printf('%d",ans);
      |         ^
a.cc:20:9: error: missing terminating ' character
   20 |  printf('%d",ans);
      |         ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:10:2: error: expected primary-expression before 'for'
   10 |  for(int i=1;i<=n;i++)
      |  ^~~
a.cc:10:14: error: 'i' was not declared in this scope
   10 |  for(int i=1;i<=n;i++)
      |              ^
a.cc:21:2: error: expected primary-expression before 'return'
   21 |  return 0;
      |  ^~~~~~
Language: C++

#include <iostream>
#include <string.h>
#include <algorithm>

#define REP(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;
int main(void){
  int n, i, j, max, max2;
  cin >> n;
  int a[100000] = {}, cnt[100000] = {};


  for(i=0;i<n;i++){
    cin >> a[i];
  }
  max = *max_element(a,a+n)+2;
  for(i=0;i<max;i++){
    for(j=0;j<n;j++){
      if((i == a[j]-1) || (i == a[j]) || (i == a[j]+1)) cnt[i]++;
    }
  }
  max2 = *max_element(cnt,cnt+n)
  if(max2 == 0) max2 = 1;
  cout << max2 << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:33: error: expected ';' before 'if'
   22 |   max2 = *max_element(cnt,cnt+n)
      |                                 ^
      |                                 ;
   23 |   if(max2 == 0) max2 = 1;
      |   ~~
Language: C++

#include<iostream>
using namespace std;

 int main(){
  int n, N[100];

  cin >> n;

  for ( int i = 0; i < n; i++ ) cin >> N[i];
  
  for ( int i = 0; i < n; i++ ) cout << N[i];



  if (N=1) cout << 1;

  else 

  int X, X[100];
  int m=0;

  for ( int X = 1; X <= n; X++ ) {
   if (N[i]=X) m++;
   if (N[i]=X-1) m++;
   if (N[i]=X+1) m++;
   cout << m << endl;
   










  
 return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:15:8: error: incompatible types in assignment of 'int' to 'int [100]'
   15 |   if (N=1) cout << 1;
      |       ~^~
a.cc:19:10: error: conflicting declaration 'int X [100]'
   19 |   int X, X[100];
      |          ^
a.cc:19:7: note: previous declaration as 'int X'
   19 |   int X, X[100];
      |       ^
a.cc:23:10: error: 'i' was not declared in this scope
   23 |    if (N[i]=X) m++;
      |          ^
a.cc:24:10: error: 'i' was not declared in this scope
   24 |    if (N[i]=X-1) m++;
      |          ^
a.cc:25:10: error: 'i' was not declared in this scope
   25 |    if (N[i]=X+1) m++;
      |          ^
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 |  int main(){
      |            ^
Language: C++

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

int main(){
    int n, now, cnt=0, ans=0;
    vector<int> a_set, cnt_v;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++) scanf("%d",a+i);
    sort(a,a+n);
    now=a[0];
    a_set.push_back(a[0]);
    for(int i=0; i<n; i++){
        if(now==a[i]) cnt++;
        else{
            cnt_v.push_back(cnt);
            a_set.push_back(a[i]);
            cnt=1;
            now=a[i];
        }
    }
    cnt_v.push_back(cnt);

    int c[3];
    int L=(int)a_set.size();
    for(int i=0; i<L;i++){
        c[0]=cnt_v[i];
        c[1]=cnt_v[i];
        c[2]=cnt_v[i];
        if(i>0 && a_set[i-1]==a_set[i]-1){
            c[0]+=cnt_v[i-1];
            c[1]+=cnt_v[i-1];
        }
        if(i<L-1 && a_set[i+1]==a_set[i]+1){
            c[0]+=cnt_v[i+1];
            c[2]+=cnt_v[i+1];
        }
        if(i>1 && a_set[i-2]==a_set[i]-2){
            c[1]+=cnt_v[i-2];
        }
        if(i<L-2 && a_set[i+2]==a_set[i]+2){
            c[2]+=cnt_v[i+2];
        }

        if(ans < *max_element(c, c+3)){
            ans=*max_element(c, c+3);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |     sort(a,a+n);
      |     ^~~~
      |     short
a.cc:46:19: error: 'max_element' was not declared in this scope
   46 |         if(ans < *max_element(c, c+3)){
      |                   ^~~~~~~~~~~
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int size = 100000;
            long len = sc.nextInt();
            int[] num;
            num = new int[len];
            int[] box;
            box = new int[size];
            int i;
            int max=0;
            for(i = 0;i < size ;i++) box[i] = 0;
        try{
            for(i = 0;i < len ;i++)num[i] = sc.nextInt();
            for(int n : num){
                if(n!=0) box[n-1]++;
                box[n]++;
                box[n+1]++;
            }
            for(int b : box){
                if(max < b) max = b;
            }
            System.out.print(max);
        }
        catch(Exception e){
            System.out.print("error");
        }
	}
}

Compiler output:
Main.java:8: error: incompatible types: possible lossy conversion from long to int
            num = new int[len];
                          ^
1 error
Language: C++

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	int a[100005], n, cnt,maxx,b;
	while (cin >> n)
	{
		memset(a, 0, sizeof(a));
		maxx = 1;
		int mina, maxa;
		cin >> b;
		a[b]++;
		mina = b, maxa = b;
		for (int i = 2; i <= n; i++)
		{
			cin >> b;
			a[b]++;
			if (mina > b)
				mina = b;
			if (maxa < b)
				maxa = b;
		}
		for (int i = mina; i <= maxa-2; i++)
		{
			if (a[i] + a[i + 1] + a[i + 2] > maxx)
				maxx = a[i] + a[i + 1] + a[i + 2];
		}
		cout << maxx << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'memset' was not declared in this scope
   11 |                 memset(a, 0, sizeof(a));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | #include <string>
Language: C++

#include <iostream>
using namespace std;

int main() {
	int N;
	cin >> N;
	int *a = new int[N];
	int max = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (max < a[i])
			max = a[i];
	}
	sort(a, a+N);
	int count = 0;
	int result = 0;
	for (int X = 0; X <= max; X++) {
		for (int i = 0; i < N; i++) {
			if (a[i] + 1 == X || a[i] - 1 == X || a[i] == X)
				count++;
			if (a[i] - 1 > X)
				break;
		}
		if (result < count)
			result = count;
		count = 0;
	}
	cout << result << endl;
	delete[] a;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |         sort(a, a+N);
      |         ^~~~
      |         short
Language: C

#include <stdio.h>
int main(void)
{
  int a[100000],plus[100000],minus[100000],count[10]=0;
  int N,i,max=0;
  scanf("%d", &N);
  for(i=0;i<N;i++){
    scanf("%d", &a[i]);
    plus[i]=a[i]+1;
    minus[i]=a[i]-1;
    count[plus[i]]+=1;
    count[minus[i]]+=1;
    count[a[i]]+=1;
  }
  for(i=0;i<10;i++){
    if(max<count[i]){
      max=count[i];
    }
  }
  printf("%d",max);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:4:54: error: invalid initializer
    4 |   int a[100000],plus[100000],minus[100000],count[10]=0;
      |                                                      ^
Language: C++

#include <iostream>
using namespace std;

int main() {
	int N;
	cin >> N;
	int *a = new int[N];
	int max = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (max < a[i])
			max = a[i];
	}
	std::sort(a, &a[N]);
	int count = 0;
	int result = 0;
	for (int X = 0; X <= max; X++) {
		for (int i = 0; i < N; i++) {
			if (a[i] + 1 == X || a[i] - 1 == X || a[i] == X)
				count++;
			if (a[i] - 1 > X)
				break;
		}
		if (result < count)
			result = count;
		count = 0;
	}
	cout << result << endl;
	delete[] a;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:14: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   14 |         std::sort(a, &a[N]);
      |              ^~~~
      |              qsort
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int N, a[100010];
int main(){
	cin>>N
	
	REP(i, 0, N){
		int aa;
		cin>>aa;
		
		if(aa>0) a[aa-1]++;
		a[aa]++;
		a[aa+1]++;
	}
	
	int mx=0;
	REP(i, 0, 100000){
		mx=max(mx, a[i]);
	}
	cout<<mx<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: expected ';' before 'for'
    8 |         cin>>N
      |               ^
      |               ;
a.cc:10:13: error: 'i' was not declared in this scope
   10 |         REP(i, 0, N){
      |             ^
a.cc:4:35: note: in definition of macro 'REP'
    4 | #define REP(i, a, n) for(int i=a; i<n; i++)
      |                                   ^
Language: C++

#include <iostream>
using namespace std;

int main() {
	int N;
	cin >> N;
	int *a = new int[N];
	int max = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (max < a[i])
			max = a[i];
	}
	sort(a, &a[N]);
	int count = 0;
	int result = 0;
	for (int X = 0; X <= max; X++) {
		for (int i = 0; i < N; i++) {
			if (a[i] + 1 == X || a[i] - 1 == X || a[i] == X)
				count++;
			if (a[i] - 1 > X)
				break;
		}
		if (result < count)
			result = count;
		count = 0;
	}
	cout << result << endl;
	delete[] a;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |         sort(a, &a[N]);
      |         ^~~~
      |         short
Language: Java

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

    private final static Scanner sc = new Scanner(System.in);

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        int n = nextInt();
        Map<Integer, Integer> highMap = new HashMap<>(n);
        Map<Integer, Integer> lowMap = new HashMap<>(n);
        Map<Integer, Integer> origMap = new HashMap<>(n);

        for (int i = 0; i < n; i++) {
            int a = nextInt();
            int high = a + 1;
            int low = a - 1;

            putCountMap(highMap, high);
            putCountMap(lowMap, low);
            putCountMap(origMap, a);
        }

        Map<Integer, Integer> mergeMap = Stream.of(highMap, lowMap, origMap)
                .flatMap(m -> m.entrySet().stream())
                .collect(Collectors.toMap(Entry::getKey, Entry::getValue, Integer::sum));

        // マージされたマップを降順ソート
        List<Entry<Integer, Integer>> mergeEntry = new ArrayList<Entry<Integer, Integer>>(mergeMap.entrySet());
        valueReverseSort(mergeEntry);

        out(mergeEntry.get(0).getValue());
    }

    private static void valueReverseSort(List<Entry<Integer, Integer>> highEntry) {
        Collections.sort(highEntry, new Comparator<Entry<Integer, Integer>>() {
            //compareを使用して値を比較する
            public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2)
            {
                //降順
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });
    }

    private static void putCountMap(Map<Integer, Integer> map, int value) {
        if (map.containsKey(value)) {
            map.put(value, map.get(value) + 1);
        } else {
            map.put(value, 1);
        }
    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt() {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString() {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }

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

#include <iostream>
#include <cmath>
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;

int countX(int max_new, int dif);

int N;
vector<int> a;
int max_a = 0;

int main(){
    cin >> N;
    for (int i =0; i <N; ++i) {
        int input;
        cin >> input;
        a.push_back(input);
        max_a = max(max_a, input);
    }
    
    int num_X = 0;
    
    for (int max_new = 0; max_new <max_a +2; ++max_new) {
        int X_new = 0;
        
        X_new += countX(max_new, 0);
        X_new += countX(max_new, 1);
        X_new += countX(max_new, -1);
        
        num_X = max(num_X, X_new);
    }
    
    cout << num_X << endl;
    
    return 0;
}

int countX(int max_new, int dif){
    int i_count = 0;
    
    for (int i =0; i <N; ++i) {
        if (a[i] + dif == max_new) {
            ++i_count
        }
    }
    return i_count
}

Compiler output:
a.cc: In function 'int countX(int, int)':
a.cc:48:22: error: expected ';' before '}' token
   48 |             ++i_count
      |                      ^
      |                      ;
   49 |         }
      |         ~             
a.cc:51:19: error: expected ';' before '}' token
   51 |     return i_count
      |                   ^
      |                   ;
   52 | }
      | ~
Language: C++

#include <cstdio>
using namespace std;

int a[100005], b[100005];

int main(){

  int n, x, max = 0;
  scanf("%d", &n);
  for (int i=0; i<n; i++){
    scanf("%d", &a[i]);
    b[a[i]]++;
    b[a[i]+1]++;
    b[a[i]+2]++;
  }
  x = 0;
  for (int i=1; i <= 100005; i++)
    if(b[i] > max){
      x = i-1;
      max = b[i];
 }
  cout << x << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:22:3: error: 'cout' was not declared in this scope
   22 |   cout << x << endl;
      |   ^~~~
a.cc:2:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <cstdio>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:22:16: error: 'endl' was not declared in this scope
   22 |   cout << x << endl;
      |                ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <cstdio>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define mp make_pair
#define f first
#define s second
#define y1 yasfasf
#define kz ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILE "substring"
#define fr freopen(FILE".in", "r", stdin); freopen(FILE".out", "w", stdout);
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef struct node* treap;

const int N = 3e5 + 11, inf = 1e9;
const ll linf = 1e18, mod = 1e9 + 7;

int n, a[N];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d", &x);
		a[x]++;
	}
	for(int i = 1; i <= 100000; ++i)
		ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
	cout << ans;	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:30: error: 'x' was not declared in this scope
   29 |                 scanf("%d", &x);
      |                              ^
a.cc:33:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |                 ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
      |                 ^~~
      |                 abs
a.cc:34:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |         cout << ans;
      |                 ^~~
      |                 abs
Language: C++

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue>
#include<string>
#include<deque>
#include<set>
#include<vector>
#include<map>
#define ll long long
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    int a[100005];
    int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];	
	 } 
	 int ans=0;
	 for(int i=0;i<n-1;i++)
	 {
	 	if(a[i]==i+1)
	 	{
	 	swap(a[i],a[i+1]);
		 ans++;	
		 }
		 
	 	
	 }
	 if(a[n]==i+1)
	 ans++;
	 cout<<ans<<endl; 
		return 0;
 } 


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

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    int cnt=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]==i+1) cnt++;
    cout<<(cnt+1)/2;
}

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

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


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

#include<bits/stdc++.h>
using namespace std;
int c[100005];
int main(){
    int n;
    cin >> n;
    int p[n];
    int ans=0;
    for(int i=0;i<n;i++){
        cin >> p[i];
        if(p[i]==i+1)c[i]++;
    }
    for(int i=0;i<n-1;i++){
        if(c[i]==1){
            c[i]=0;
            c[i+1]=0;
            ans++
        }
    }
    cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:18: error: expected ';' before '}' token
   17 |             ans++
      |                  ^
      |                  ;
   18 |         }
      |         ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++)cin >> p[i];
    int ans=0;
    int tmp=0;
    if(n%2==0){
        for(int i=0;i<n-1;i+=2)if(p[i]==i+1 || p[i+1]==i+2)ans++;
        if(a[0]!=1 && a[n-1]!=n)for(int i=1;i<n-1;i+=2)if(p[i]==i+1 || p[i+1]==i+2)tmp++;
        ans=min(ans,tmp);
    }
    else{
        if(p[n-1]!=n)for(int i=0;i<n-2;i+=2)if(p[i]==i+1 || p[i+1]==i+2)ans++;
        if(p[0]!=1)for(int i=1;i<n-1;i+=2)if(p[i]==i+1 || p[i+1]==i+2)tmp++;
       ans=min(ans,tmp);
    }    
    cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: 'a' was not declared in this scope
   12 |         if(a[0]!=1 && a[n-1]!=n)for(int i=1;i<n-1;i+=2)if(p[i]==i+1 || p[i+1]==i+2)tmp++;
      |            ^
Language: C++

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


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


Compiler output:
a.cc: In function 'int main()':
a.cc:38:3: error: expected primary-expression before '}' token
   38 |   }
      |   ^
Language: C++

#include<algorithm>
using namespace std;
int n,ans,a[100001];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		if (a[i]==i)
		{
			swap(a[i+1],a[i]);
			ans++;
		}
	printf("%d",ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'scanf' was not declared in this scope
    6 |         scanf("%d",&n);
      |         ^~~~~
a.cc:14:9: error: 'printf' was not declared in this scope
   14 |         printf("%d",ans);
      |         ^~~~~~
a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    1 | #include<algorithm>
  +++ |+#include <cstdio>
    2 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;cin>>n;
    vector<ll> v(n);
    REP(i,n)cin>>v[i];
    ll cnt=0;
    vector<ll> w(n);
    REP(i,n)if(v[i]==i+1)w[i]=1;
    REP(i,n-1){
        if(w[i]==1){
            w[i]=0;
            w[i+1]=0;
            cnt++;
        }
    }
    if(w[n-1]==1){
        w[n-1]=0:
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:17: error: expected ';' before ':' token
   29 |         w[n-1]=0:
      |                 ^
      |                 ;
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(a,b,n) for(ll a = (ll)(b); a < (ll)(n); a++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

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

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  ll res = 0;
  rep(i, n-1) {
    ll tmp = i+1;
    if (v.at(i) == tmp) {
      res++;
      if (tmp.at(i+1) == tmp+1) i++;
    }
  } 
  cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:15: error: request for member 'at' in 'tmp', which is of non-class type 'll' {aka 'long long int'}
   65 |       if (tmp.at(i+1) == tmp+1) i++;
      |               ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back


int main(){

 int n; cin>>n;
 int a[n];

 rep(i,n)
   cin>>a[i];

   rep(i,n){

    if(a[i] == i+1){
        ans++;
        if(i == n-1) swap(a[i],a[i-1]);
        else  swap(a[i],a[i+1]); }
   }

    cout<<ans<<endl;

return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   20 |         ans++;
      |         ^~~
      |         abs
a.cc:25:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |     cout<<ans<<endl;
      |           ^~~
      |           abs
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:25: error: expected ';' before 'for'
    7 |     vector<int>p(N);swap
      |                         ^
      |                         ;
    8 |     for(int i = 0; i < N; i++) {
      |     ~~~                  
a.cc:8:18: error: statement cannot resolve address of overloaded function
    8 |     for(int i = 0; i < N; i++) {
      |                  ^
a.cc:8:20: error: 'i' was not declared in this scope
    8 |     for(int i = 0; i < N; i++) {
      |                    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const int MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};


int main() {
	int N;
  	cin >> N;
  	vi p(N);
  	vevtor<bool> q(N,false);
  	rep(i,N){
    	cin >> p[i];
      	if(p[i] != i+1) q[i] = true;
    }
  	int count=0;
  	rep(i,N){
    	if(q[i] == false&& i != N-1){
        	bool x = q[i];
          	q[i] = q[i+1];
          	q[i+1] = x;
          	count++;
        }
      	else if(q[i] == false && i=N-1){
        	bool x = q[N-1];
          	q[N-1] = q[N-2];
          	q[N-2] = x;
        }
    }
	cout << count << endl;
  	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'vevtor' was not declared in this scope
   24 |         vevtor<bool> q(N,false);
      |         ^~~~~~
a.cc:24:16: error: expected primary-expression before 'bool'
   24 |         vevtor<bool> q(N,false);
      |                ^~~~
a.cc:27:25: error: 'q' was not declared in this scope
   27 |         if(p[i] != i+1) q[i] = true;
      |                         ^
a.cc:31:12: error: 'q' was not declared in this scope
   31 |         if(q[i] == false&& i != N-1){
      |            ^
Language: C++

N = int(input())
p = list(map(int, input().split()))
li = range(1, N+1)
count = 0
for i in range(len(p) - 1):
    if p[i] == li[i]:
        p[i], p[i + 1] = p[i + 1], p[i]
        count += 1
print(count)

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
  long long N,a,counter=0;
  cin>>N;
  long long a[100000];
  for (long long i=1; i<=N; i++){
  cin>>a[i];}
  for (long long i=1; i<=N; i++){
  if(a[i]==i){
  counter++;
  a[i+1]=i;}}
  cout<<counter<<endl;}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:8:13: error: conflicting declaration 'long long int a [100000]'
    8 |   long long a[100000];
      |             ^
a.cc:6:15: note: previous declaration as 'long long int a'
    6 |   long long N,a,counter=0;
      |               ^
a.cc:10:9: error: invalid types 'long long int[long long int]' for array subscript
   10 |   cin>>a[i];}
      |         ^
a.cc:12:7: error: invalid types 'long long int[long long int]' for array subscript
   12 |   if(a[i]==i){
      |       ^
a.cc:14:4: error: invalid types 'long long int[long long int]' for array subscript
   14 |   a[i+1]=i;}}
      |    ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: conflicting declaration 'int a [100000]'
    8 |   int a[100000];
      |       ^
a.cc:6:9: note: previous declaration as 'int a'
    6 |   int N,a,counter=0;
      |         ^
a.cc:10:9: error: invalid types 'int[int]' for array subscript
   10 |   cin>>a[i];}
      |         ^
a.cc:12:7: error: invalid types 'int[int]' for array subscript
   12 |   if(a[i]==i){
      |       ^
a.cc:14:4: error: invalid types 'int[int]' for array subscript
   14 |   a[i+1]=i;}}
      |    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int ans=0;
    int N;
    cin >> N;
    int p[N];
    rep(i,N) {
        cin >> p[i];
        if(p[i]==i+1) ans++;
    }
    rep(i,N-1){
        if(p[i]==i+1 && p[i+1] == i+2) {
            ans--;
            i++
        }
    }
    cout << ans << endl;



}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:16: error: expected ';' before '}' token
   27 |             i++
      |                ^
      |                ;
   28 |         }
      |         ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};

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

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