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

import java.util.Scanner;class Main{public static void main(String[] args){Scanner scanner=new Scanner(System.in);int N=scanner.nextInt();boolean[] a=new boolean[N+1];for(int i=1;i<N+1;i++){a[i]=scanner.nextInt();}int ans=0;for(int i=1;i<N;i++){if(a[i]==i){a[i]=a[i+1]=false;ans++;}}System.out.println(ans);}}

Compiler output:
Main.java:1: error: incompatible types: int cannot be converted to boolean
import java.util.Scanner;class Main{public static void main(String[] args){Scanner scanner=new Scanner(System.in);int N=scanner.nextInt();boolean[] a=new boolean[N+1];for(int i=1;i<N+1;i++){a[i]=scanner.nextInt();}int ans=0;for(int i=1;i<N;i++){if(a[i]==i){a[i]=a[i+1]=false;ans++;}}System.out.println(ans);}}
                                                                                                                                                                                                                  ^
Main.java:1: error: incomparable types: boolean and int
import java.util.Scanner;class Main{public static void main(String[] args){Scanner scanner=new Scanner(System.in);int N=scanner.nextInt();boolean[] a=new boolean[N+1];for(int i=1;i<N+1;i++){a[i]=scanner.nextInt();}int ans=0;for(int i=1;i<N;i++){if(a[i]==i){a[i]=a[i+1]=false;ans++;}}System.out.println(ans);}}
                                                                                                                                                                                                                                                            ^
2 errors
Language: Java


import java.util.Scanner;

class Main{
        public static void main(String[] args){
                Scanner scanner=new Scanner(System.in);
                int N=scanner.nextInt();
                boolean[] a=new boolean[N+1];
                for(int i=1;i<N+1;i++){
                        a[i]=scanner.nextInt();
                }

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

                System.out.println(ans);
        }
}

Compiler output:
Main.java:10: error: incompatible types: int cannot be converted to boolean
                        a[i]=scanner.nextInt();
                                            ^
Main.java:15: error: incomparable types: boolean and int
                        if(a[i]==i){
                               ^
2 errors
Language: C++

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

  vector<int> p(N+1);
  // index is 1 originated.
  for (int i = 1; i < N+1; i++) {
    cin >> p[i];
  }

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

  if (p[N] == N) {   // 右端だけ左とスワップ
    count++;
    temp = p[N];
    p[N] = p[N-1];
    p[N-1] = temp;
  }

  cout << count << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
    4 |   cin >> N;
      |   ^~~
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int> p(N+1);
      |   ^~~~~~
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int> p(N+1);
      |          ^~~
a.cc:9:12: error: 'p' was not declared in this scope
    9 |     cin >> p[i];
      |            ^
a.cc:15:9: error: 'p' was not declared in this scope
   15 |     if (p[i] == i) {
      |         ^
a.cc:23:7: error: 'p' was not declared in this scope
   23 |   if (p[N] == N) {   // 右端だけ左とスワップ
      |       ^
a.cc:30:3: error: 'cout' was not declared in this scope; did you mean 'count'?
   30 |   cout << count << endl;
      |   ^~~~
      |   count
a.cc:30:20: error: 'endl' was not declared in this scope
   30 |   cout << count << endl;
      |                    ^~~~
Language: C++

#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=1e4+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T> inline T gcd(T&a,T&b){return b==0?a:gcd(b,a%b);}
template<typename T> inline T lcm(T&a,T&b){return a/gcd(a,b)*b;}
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
int n,a[maxn];
int main(){
    read(n);
    for (int i=1;i<=n;i++) b[i]=read(a[i]);
    int cnt=0,ans;
    for (int i=1;i<n;i++){
        if (a[i]==i) swap(a[i],a[i+1]),cnt++;
    }
    if (a[n]==n) cnt++;
    ans=cnt;
 /*   cnt=0;
    for (int i=n;i>1;i--){
        if (b[i]==i) swap(b[i],b[i-1]),cnt++;
    }
    if (b[1]==1) cnt++;
    ans=min(ans,cnt);*/
    printf("%d\n",ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:28: error: 'b' was not declared in this scope
   44 |     for (int i=1;i<=n;i++) b[i]=read(a[i]);
      |                            ^
Language: C

#include<stdio.h>

int main(void)
{
 int N;
 char p[100001];
 unsigned a,i;
 int j=0,tmp=0;

 scanf("%d",N);
 for(a=0;a<N;a++){
  scanf("%c",p[a]);
 }

 for(i=0;N[i]!='\0';i++){
  if(N[i]<N[i+1]){
   tmp=N[i];
   N[i]=N[i+1];
   N[i+1]=tmp;
   j++;
  }
  else{
  };
 }
printf("%d\n",j);


return 0;
}

Compiler output:
main.c: In function 'main':
main.c:15:11: error: subscripted value is neither array nor pointer nor vector
   15 |  for(i=0;N[i]!='\0';i++){
      |           ^
main.c:16:7: error: subscripted value is neither array nor pointer nor vector
   16 |   if(N[i]<N[i+1]){
      |       ^
main.c:16:12: error: subscripted value is neither array nor pointer nor vector
   16 |   if(N[i]<N[i+1]){
      |            ^
main.c:17:9: error: subscripted value is neither array nor pointer nor vector
   17 |    tmp=N[i];
      |         ^
main.c:18:5: error: subscripted value is neither array nor pointer nor vector
   18 |    N[i]=N[i+1];
      |     ^
main.c:18:10: error: subscripted value is neither array nor pointer nor vector
   18 |    N[i]=N[i+1];
      |          ^
main.c:19:5: error: subscripted value is neither array nor pointer nor vector
   19 |    N[i+1]=tmp;
      |     ^
Language: C++

#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n;
    vector<int> p;
    cin >> n;
    REP(i, n){
        int x;
        cin >> x;
        p.pb(x);
    }

    int renzoku = 0;
    int cnt = 0;
    REP(i, n){
        if(p[i] == i+1){
            cnt++;
            renzoku++;
            if(renzoku == 2) cnt--;
        }else{
            renzoku = 0;
        }
    }

    cout << cnt << endl;
}


Compiler output:
a.cc:24:9: error: multiple types in one declaration
   24 | typedef LL int;
      |         ^~
a.cc:24:12: error: declaration does not declare anything [-fpermissive]
   24 | typedef LL int;
      |            ^~~
Language: C++

#include <iostream>
using namespace std;
int a[100001],n,m=0,tot=0;
void search(int j)
{
	if(a[j]==j)
	{
		m++;
		search(j+1);
	}
	else
	{
		i=j;
	}
}
int main()
{
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	for(i=1;i<=n;i++)
	{
		int ans;
		search(i);
		if(m%2==1) tot+=(m+1)/2;
		else tot+=m/2;
		m=0;
	}
	cout<<tot;
	return 0;
}

Compiler output:
a.cc: In function 'void search(int)':
a.cc:13:17: error: 'i' was not declared in this scope
   13 |                 i=j;
      |                 ^
a.cc: In function 'int main()':
a.cc:19:13: error: 'i' was not declared in this scope
   19 |         for(i=1;i<=n;i++) cin>>a[i];
      |             ^
a.cc:20:13: error: 'i' was not declared in this scope
   20 |         for(i=1;i<=n;i++)
      |             ^
Language: C++

#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
      int n,i,r1=0,r2=0,res=0,rr=0;
      cin>>n;
      int a[n+10],b[n+10],c[n+10];
      map<int,int>m;
      int dp[n+10];
      for(i=0;i<=n+2;i++) dp[i]=0;
      for(i=1;i<=n;i++)
      {
            cin>>a[i];
            b[i]=a[i];
      } 
      if(a[1]==1&&a[n]==n)
      {
            rr=1;
            swap(a[1],a[n]);
            swap(b[1],b[n]);
            swap(c[1],c[n]);
      }
      for(i=1;i<=n;i++)
      {
            if(b[i]==i)
            {
                  r1++;
                  swap(b[i],b[i+1]);
            }
            dp[i]=r1;
      }
      res=r1;
      for(i=n;i>0;i--)
      {
            if(a[i]==i)
            {
                  r2++;
                  swap(a[i],a[i-1]);
                  res=min(res,dp[max(0,i-2)]+r2);
                        
            }
            else
            res=min(res,dp[i-1]+r2);
            dp[i]=r2;
      }
      r1=0;
      for(i=1;i<=n;i++)
      {
            if(c[i]==i)
            {
                  r1++;
                  swap(c[i],c[i+1]);
                  res=min(res,dp[i+2]+r1);
            }
else
res=min(res,dp[i+1]+r1]);

      }
      cout<<res+rr;
      return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:23: error: expected ')' before ']' token
   61 | res=min(res,dp[i+1]+r1]);
      |        ~              ^
      |                       )
Language: C++

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int p[100001],b[100001];
int main(){
	int n,ans=0;
	cin>>n;
	p[0]=-1;
	REP(i,1,n+1){
		cin>>p[i];
		if(p[i]==i){
			b[i]++;
			if(b[i-1]==0){
				ans++;
			}
		}
		if(b[i-1]==1&&p[i-2]==i)
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
	
}


Compiler output:
a.cc:57:9: error: 'cout' does not name a type
   57 |         cout<<ans<<endl;
      |         ^~~~
a.cc:58:9: error: expected unqualified-id before 'return'
   58 |         return 0;
      |         ^~~~~~
a.cc:60:1: error: expected declaration before '}' token
   60 | }
      | ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
int main(){
    int n;
    cin >> n;
    long long cnt = 0;
    for(int i = 1; i <= n;i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n;++i){
        if(i == 1 && a[i]==i){
            swap(a[i],a[i + 1]);
            cnt++;
        }
        else if(i == n&& a[i]==i){
            swap(a[n], a[n - 1]);
            cnt++;
        }
        else {
            if(a[i] == i){
                swap(a[i], a[i - 1]);
                cnt++;
            }
        }
    }
    cout << cnt;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:16: error: 'a' was not declared in this scope
    9 |         cin >> a[i];
      |                ^
a.cc:12:22: error: 'a' was not declared in this scope
   12 |         if(i == 1 && a[i]==i){
      |                      ^
Language: C++

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 100005;
int n, a[N], sum;
int main () {
cin >> n;
memset(a, -1, sizeof(a));
for (int i = 1; i <= n; i ++) {
cin >> a[i];
}
for (int i = 1; i <= n; i ++) {
if (a[i] == i) {
if (a[i + 1] == i + 1) {
int t = a[i];
a[i] = a[i + 1];
a[i + 1] = t;
sum ++;
continue;
}
if (i == n) {
int t = a[i];
a[i] = a[i-1];
a[i-1] = t;
sum ++;
}
else
{
int t = a[i];
a[i] = a[i+1];
a[i+1]=t;
sum ++;
}
}
cout << sum;
return 0;
}

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

#include<iostream>

using namespace std;

int N, p[100000];
bool needed[100000];

int DP();

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> p[i];
		if(p[i] == i + 1){
			needed[i] = true;
		}
	}
	cout << DP() << endl;
	return 0;
}

void swip(int *a, int *b){
	int buff = *a;
	*a = *b;
	*b = buff;
	return;
}

int DP(){
	int num = INT_MAX;
	bool flag = true;
	for(int i = 0; i < N; i++){
		if(needed[i] == true){
			flag = false;
			//左開始
			swip(&p[i - 1], &p[i]);
			needed[i] = false;
			if(p[i - 1] == i){
				needed[i - 1] = true;
			}else{
				needed[i - 1] = false;
			}
			int buff = DP();
			if(num > buff + 1){
				num = buff + 1;
			}
			needed[i] = true;
			swip(&p[i], &p[i - 1]);
			if(p[i - 1] == i){
				needed[i - 1] = true;
			}else{
				needed[i - 1] = false;
			}
			//左終了
			//右開始
			swip(&p[i], &p[i + 1]);
			needed[i] = false;
			if(p[i + 1] == i + 2){
				needed[i + 1] = true;
			}else{
				needed[i + 1] = false;
			}
			buff = DP();
			if(num > buff + 1){
				num = buff + 1;
			}
			swip(&p[i + 1], &p[i]);
			needed[i] = true;
			if(p[i + 1] == i + 2){
				needed[i + 1] = true;
			}else{
				needed[i + 1] = false;
			}
			//右終了
		}
	}
	if(flag == true){
		num = 0;
	}
	return (num);
}

Compiler output:
a.cc: In function 'int DP()':
a.cc:30:19: error: 'INT_MAX' was not declared in this scope
   30 |         int num = INT_MAX;
      |                   ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include<iostream>
  +++ |+#include <climits>
    2 |
Language: Java


import java.util.Scanner;

public class Main {

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

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

			int count = 0;
//			while (!check(p)) {
//				for (int i = 0; i < p.length; i++) {
//					if (i == p[i]) {
//						if (i < p.length - 1) {
//							int tmp = p[i];
//							p[i] = p[i + 1];
//							p[i + 1] = tmp;
//							break;
//						} else {
//							int tmp = p[i];
//							p[i] = p[0];
//							p[0] = tmp;
//							break;
//						}
//					}
//				}
//				count++;
//			}

			boolean renzoku = false;
			for (int i = 0; i < p.length; i++) {
				if (i == p[i]) {
					if (!renzoku) {
						count++;
						renzoku = true;
					} else {
						renzoku = false;
					}
				} else {
					renzoku = false;
				}
			}

			System.out.println(count);
		}
	}

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

#include <bits/stdc++.h>

using namespace std;

int N, a[100005], sol, fcv[100005];
vector < int > pos;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> a[i];
        
        if (a[i] == i) {
            pos.push_back(i);
        }
    }
    
    while (ok) {
        ok = 0;
        for (int i = 1; i <= N; ++i) {
            if (a[i] == i) {
                if (i == 1) {
                    swap(a[i], a[i + 1]);
                    ++sol;
                    ok = 1;
                    continue;
                }
                
                if (i == N) {
                    swap(a[i], a[i - 1]);
                    ++sol;
                    ok = 1;
                    continue;
                }
                
                if (a[i - 1] != i - 1) {
                    swap(a[i], a[i - 1]);
                    ++sol;
                    ok = 1;
                } else if (a[i + 1] != i + 1) {
                    swap(a[i], a[i + 1]);
                    ++sol;
                    ok = 1;
                }
            }
        }
    }
    
    
    cout << sol << '\n';
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:12: error: 'ok' was not declared in this scope
   19 |     while (ok) {
      |            ^~
Language: C++

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<vector>
#include<map>
#include<queue> 
#include<algorithm>
using namespace std;
#define maxn
#define ll long long
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m;
int a[maxn];
int main(){
	n=read();
	for(int i=1;i<=n;i++)
		if(i==read()) ans++;
	printf("%d\n",ans);
}

Compiler output:
a.cc:19:5: error: storage size of 'a' isn't known
   19 | int a[maxn];
      |     ^
a.cc: In function 'int main()':
a.cc:23:31: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |                 if(i==read()) ans++;
      |                               ^~~
      |                               abs
a.cc:24:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
   24 |         printf("%d\n",ans);
      |                       ^~~
      |                       abs
Language: C++

#include "bits/stdc++"
using namespace std;

int main(){
int n;
cin>>n;
vector<int> a(n+1);
int ans=0;
for(int i=1;i<n+1;i++)cin>>a[i];
for(int i=1;i<n;i++){
if(a[i]==i&&a[i+1]==i+1){
ans++;
i++;
}else if(a[i]==i){
ans++;
}
}

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

Compiler output:
a.cc:1:10: fatal error: bits/stdc++: No such file or directory
    1 | #include "bits/stdc++"
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>A(100000);
  for(int X=0;X<N;X++){
    int S;cin>>S;
    if(S!=0){
      A[S-1]++;
    }
    if(S!=N-1){
      A[S+1]++;
    }
    A[S]++;
  }
  int U=-1;
  int I;
  for(int X=0;X<N;X++){
    if(U<A[X]){
      U=A[X];
      I=X-1;
    }
  }
  cout<<I<<endl;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>A(100000);
  for(itn X=0;X<N;X++){
    int S;cin>>S;
    if(S!=0){
      A[S-1]++;
    }
    if(S!=N-1){
      A[S+1]++;
    }
    A[S]++;
  }
  int U=-1;
  int I;
  for(int X=0;X<N;X++){
    if(U<A[X]){
      U=A[X];
      I=X-1;
    }
  }
  cout<<I<<endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:42:7: error: 'itn' was not declared in this scope; did you mean 'int'?
   42 |   for(itn X=0;X<N;X++){
      |       ^~~
      |       int
a.cc:42:15: error: 'X' was not declared in this scope
   42 |   for(itn X=0;X<N;X++){
      |               ^
Language: C++

#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  vll ans(100010);
  rep(i,n){
    for(j,3){
      ans[a[i]+j]++;
    }
  }
  ll cu=0;
  ll v=0;
  rep(i,sz(ans)){
    if(cu<ans[i]){
      cu=ans[i];
      v=i;
    }
  }
  v--;
  COUT(v);
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:41:9: error: 'j' was not declared in this scope
   41 |     for(j,3){
      |         ^
a.cc:44:3: error: expected primary-expression before '}' token
   44 |   }
      |   ^
a.cc:43:6: error: expected ';' before '}' token
   43 |     }
      |      ^
      |      ;
   44 |   }
      |   ~   
a.cc:44:3: error: expected primary-expression before '}' token
   44 |   }
      |   ^
a.cc:43:6: error: expected ')' before '}' token
   43 |     }
      |      ^
      |      )
   44 |   }
      |   ~   
a.cc:41:8: note: to match this '('
   41 |     for(j,3){
      |        ^
a.cc:44:3: error: expected primary-expression before '}' token
   44 |   }
      |   ^
Language: C++

#include <bits/stdc++.h>

using namespace std;




int main() {
    int a,b[100010],c[100010],d=0;
    cin >> a;
  
    for(int i=0;i<a;i++)
         cin >> b[i];
  
  fir(int i=0;i<a;i++){
      c[b[i]-1]++; 
      c[b[i]]++; 
      c[b[i]+1]++;
    }
  
    for(int i=0;i<=100001;i++){
        d = max(d, c[i]);
    }
  
    cout << d << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:7: error: expected primary-expression before 'int'
   15 |   fir(int i=0;i<a;i++){
      |       ^~~
a.cc:15:15: error: 'i' was not declared in this scope
   15 |   fir(int i=0;i<a;i++){
      |               ^
Language: C++

#include <bits/stdc++.h>

using namespace std;




int main() {
    int a,b[100010],c[100010],d=0;
    cin >> a;
  
    for(int i=1;i<=a;i++)
         cin >> b[i];
  
  fir(int i=0;i<a;i++){
      c[b[i]-1]++; 
      c[b[i]]++; 
      c[b[i]+1]++;
    }
  
    for(int i=-1;i<=100001;i++){
        d = max(d, c[i]);
    }
  
    cout << d << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:7: error: expected primary-expression before 'int'
   15 |   fir(int i=0;i<a;i++){
      |       ^~~
a.cc:15:15: error: 'i' was not declared in this scope
   15 |   fir(int i=0;i<a;i++){
      |               ^
Language: C++

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a,M=0,b[100010];
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a;
    b[a]++;
  }
  for(int i=1; i<=100000; i++) {
    M=max(M,a[i-1]+a[i]+a[i+1]);
  }
  cout << M << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:14: error: invalid types 'int[int]' for array subscript
   13 |     M=max(M,a[i-1]+a[i]+a[i+1]);
      |              ^
a.cc:13:21: error: invalid types 'int[int]' for array subscript
   13 |     M=max(M,a[i-1]+a[i]+a[i+1]);
      |                     ^
a.cc:13:26: error: invalid types 'int[int]' for array subscript
   13 |     M=max(M,a[i-1]+a[i]+a[i+1]);
      |                          ^
Language: C++

// BY KUTBILIM
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
//	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;cin >> n;
	int a[n];
	long long c[1000000] = {0,};
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] != 0){
			c[a[i]-1]++;
			c[a[i]+1]++;
			c[a[i]]++;
		}else{
			c[a[i]+1]
		}
	}
	long long mx = 0;
	for(int i = 1; i <= 100000; i++){
		mx = max(mx,c[i]);
	}
	cout << mx;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:34: error: expected ';' before '}' token
   21 |                         c[a[i]+1]
      |                                  ^
      |                                  ;
   22 |                 }
      |                 ~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <tuple>
#include <cmath>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;

#define rep(i, m) for(ll i=0;i<(m);i++)
#define rep1(i, m) for(ll i=1;i<=(m);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int N;
int b[100010];

int main() {
   cin >> N;
   rep(i, N) {
      int i;
      cin >> i;
      b[i]++;
   }
   int maxval = 0;
   rep(i, 100000) {
      maxval = max((i >= 1) ? (b[i-1] + b[i] + b[i+1]) : (b[i] + b[i+1]), maxval);
   }
   cout << maxval << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:11: error: redeclaration of 'int i'
   25 |       int i;
      |           ^
a.cc:24:8: note: 'll i' previously declared here
   24 |    rep(i, N) {
      |        ^
a.cc:12:26: note: in definition of macro 'rep'
   12 | #define rep(i, m) for(ll i=0;i<(m);i++)
      |                          ^
Language: C

#include<stdio.h>
int f[100002];
int main() {
	int N;
	int max = -1;
	int crt = ;
	int ans = 0;
	scanf("%d", &N);
	int *A = (int)malloc(sizeof(int)*N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
		f[A[i]]++;
		if (max < A[i])
		{
			max = A[i];
		}
	}

	for (int i = 0; i < max; i++)
	{
		crt = f[i] + f[i + 1] + f[i + 2];
		if (ans < crt)
		{
			ans = crt;
		}
	}
	printf("%d\n", ans);

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:19: error: expected expression before ';' token
    6 |         int crt = ;
      |                   ^
main.c:9:23: error: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
    9 |         int *A = (int)malloc(sizeof(int)*N);
      |                       ^~~~~~
main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
    1 | #include<stdio.h>
  +++ |+#include <stdlib.h>
    2 | int f[100002];
main.c:9:23: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
    9 |         int *A = (int)malloc(sizeof(int)*N);
      |                       ^~~~~~
main.c:9:23: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c:9:18: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    9 |         int *A = (int)malloc(sizeof(int)*N);
      |                  ^
main.c:9:18: error: initialization of 'int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
Language: C

#include <stdio.h>

int b[100001];

int main()
{
    int i,j,n,max=0,c;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        if(a[i] != 0)
        {
            ++b[a[i]-1];
            ++b[a[i]];
            ++b[a[i]+1];
        }
        else
        {
            ++b[a[i]];
            ++b[a[i]+1];
        }
        if( b[a[i]] > max )
        {
            max=b[a[i]];
        }
        if( b[a[i]+1] > max )
        {
            max=b[a[i]+1];
        }
        if( b[a[i]-1] > max && a[i] != 0 )
        {
            max=b[a[i]-1];
        }
    }
    printf("%d",max);
    return 0;
}
Comment in Markdown


Compiler output:
main.c:40:1: error: unknown type name 'Comment'
   40 | Comment in Markdown
      | ^~~~~~~
main.c:40:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Markdown'
   40 | Comment in Markdown
      |            ^~~~~~~~
Language: C++

#include <stdio.h>

int b[100001];

int main()
{
    int i,j,n,max=0,c;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        if(a[i] != 0)
        {
            ++b[a[i]-1];
            ++b[a[i]];
            ++b[a[i]+1];
        }
        else
        {
            ++b[a[i]];
            ++b[a[i]+1];
        }
        if( b[a[i]] > max )
        {
            max=b[a[i]];
        }
        if( b[a[i]+1] > max )
        {
            max=b[a[i]+1];
        }
        if( b[a[i]-1] > max && a[i] != 0 )
        {
            max=b[a[i]-1];
        }
    }
    printf("%d",max);
    return 0;
}
Comment in Markdown


Compiler output:
a.cc:40:1: error: 'Comment' does not name a type
   40 | Comment in Markdown
      | ^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int n, a[MAX], b, ans = 0;

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &b);
    a[b]++;
  }
  for(int i = 0; i < n-2; i++){
    ans = max(ans, a[i]+a[i+1]+a[i+2]);
  }
  printf("%d\n", ans);
}

Compiler output:
a.cc:4:10: error: 'MAX' was not declared in this scope
    4 | int n, a[MAX], b, ans = 0;
      |          ^~~
a.cc: In function 'int main()':
a.cc:10:5: error: 'a' was not declared in this scope
   10 |     a[b]++;
      |     ^
a.cc:13:20: error: 'a' was not declared in this scope
   13 |     ans = max(ans, a[i]+a[i+1]+a[i+2]);
      |                    ^
Language: C++

#include<iostream>
using namespace std;
int a[100005];
int b[100005];
int main()
{
	int n,i;
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	cin>>n;
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<n;i++)
	{if(a[i]==0)
	{
		b[a[i]]+=1;
		b[a[i]+1]+=1;
	}
	else {
		b[a[i]]+=1;
		b[a[i]-1]+=1;
		b[a[i]+1]+=1;
	}
	}
	int min=1;
	for(i=0;i<n+10;i++)
		{
			if(b[i]>min)
				min=b[i];
		}
		cout<<min;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'memset' was not declared in this scope
    8 |         memset(a,0,sizeof(a));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
	int a[100005],n,i,j;
	cin>>n;
	memset(a,0,sizeof(a));
	int big=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(x>big)
		big=x;
		a[x]++;
		if(x>=1)
		a[x-1]++;
		a[x+1]++;
	}
	int zd=0;
	for(int i=0;i<=big+1;i++)
		if(a[i]>zd)
			zd=a[i];
	cout<<zd<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:7:9: error: 'memset' was not declared in this scope
    7 |         memset(a,0,sizeof(a));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <iostream>
using namespace std;
const int maxn=1e5+10;
int a[maxn],b[1000000];
int main(int argc, char *argv[])
{
	int n;
	cin>>n; 
	memset(b,0,sizeof(b));
	for(int i=0;i<n;i++){
        cin>>a[i];
        b[a[i]+1]++;
	}
	int max=0;
	for(int i=0;i<n;i++){
		int h=b[a[i]]+b[a[i]+1]+b[a[i]+2];
		  if(h>max)max=h;
	}
	cout<<max<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:9:9: error: 'memset' was not declared in this scope
    9 |         memset(b,0,sizeof(b));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	long long  int n,m,cnt=1; 
	int s[1001];
	cin>>n;
	 for(int i=0;i<n;i++)
	 {
	 cout<<s[i];
	 }
	 cout<<a;
}


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

#include <bits/stdc++.h>
using namespace std;
    long long am[123456],aam[123456],sam[123456],index[123456];

int main()
{
    long long n;
    scanf("%lld",&n);

    for(long long i=0; i<n; i++){
        scanf("%lld",am+i);
        aam[i] = am[i]+1;
        sam[i] = am[i]-1;
    }

    for(long long i=0; i<n; i++){
        index[am[i]]++;
        index[aam[i]]++;
        index[sam[i]]++;
    }

    sort(index, index+n);
    printf("%lld\n", index[n-1]);
    return 0;
}

Compiler output:
a.cc:3:62: error: 'long long int index [123456]' redeclared as different kind of entity
    3 |     long long am[123456],aam[123456],sam[123456],index[123456];
      |                                                              ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:17:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   17 |         index[am[i]]++;
      |              ^
a.cc:18:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   18 |         index[aam[i]]++;
      |              ^
a.cc:19:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   19 |         index[sam[i]]++;
      |              ^
a.cc:22:22: error: invalid operands of types '<unresolved overloaded function type>' and 'long long int' to binary 'operator+'
   22 |     sort(index, index+n);
      |                 ~~~~~^~
a.cc:23:27: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   23 |     printf("%lld\n", index[n-1]);
      |                           ^
Language: C

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){

    int x;
    cin>>x;
    a[x]++;
}
int ma=a[0]+a[1];
for(int i=2;i<N;i++){
    int t=a[i-2]+a[i-1]+a[i];
    if(t>ma)ma=t;
}
cout<<ma<<endl;
return 0;
}


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

#include <bits/stdc++.h>
//#define ll long long
using namespace std;
    long long am[123456],aam[123456],sam[123456],index[123456];

int main()
{
    long long n;
    scanf("%lld",&n);

    for(long long i=0; i<n; i++){
        scanf("%lld",am+i);
        aam[i] = am[i]+1;
        sam[i] = am[i]-1;
    }

    for(long long i=0; i<n; i++){
        index[am[i]]++;
        index[aam[i]]++;
        index[sam[i]]++;
    }

    sort(index, index+n);
    printf("%lld\n", index[n-1]);
    return 0;
}


Compiler output:
a.cc:4:62: error: 'long long int index [123456]' redeclared as different kind of entity
    4 |     long long am[123456],aam[123456],sam[123456],index[123456];
      |                                                              ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:18:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   18 |         index[am[i]]++;
      |              ^
a.cc:19:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   19 |         index[aam[i]]++;
      |              ^
a.cc:20:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   20 |         index[sam[i]]++;
      |              ^
a.cc:23:22: error: invalid operands of types '<unresolved overloaded function type>' and 'long long int' to binary 'operator+'
   23 |     sort(index, index+n);
      |                 ~~~~~^~
a.cc:24:27: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   24 |     printf("%lld\n", index[n-1]);
      |                           ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define mam 123456
using namespace std;
    ll am[mam];

    ll aam[mam],sam[mam];

    ll index[mam];

int main()
{
    ll n;
    scanf("%lld",&n);

    for(int i=0; i<n; i++){
        scanf("%lld",am+i);
        aam[i] = am[i]+1;
        sam[i] = am[i]-1;
    }

    for(int i=0; i<n; i++){
        index[am[i]]++;
        index[aam[i]]++;
        index[sam[i]]++;
    }

    sort(index, index+n);
    printf("%lld\n", index[n-1]);
    return 0;
}


Compiler output:
a.cc:9:17: error: 'long long int index [123456]' redeclared as different kind of entity
    9 |     ll index[mam];
      |                 ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:23:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   23 |         index[am[i]]++;
      |              ^
a.cc:24:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   24 |         index[aam[i]]++;
      |              ^
a.cc:25:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   25 |         index[sam[i]]++;
      |              ^
a.cc:28:22: error: invalid operands of types '<unresolved overloaded function type>' and 'long long int' to binary 'operator+'
   28 |     sort(index, index+n);
      |                 ~~~~~^~
a.cc:29:27: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   29 |     printf("%lld\n", index[n-1]);
      |                           ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define mam 123456
using namespace std;
    ll am[mam];

    ll aam[mam],sam[mam];

    ll index[mam];

int main()
{
    ll n;
    scanf("%lld",&n);

    for(int i=0; i<n; i++)
        scanf("%lld",am+i);

    for(int i=0; i<n; i++){
        aam[i] = am[i]+1;
        sam[i] = am[i]-1;
    }

    for(int i=0; i<n; i++){
        index[am[i]]++;
        index[aam[i]]++;
        index[sam[i]]++;
    }

    sort(index, index+n);
    printf("%lld\n", index[n-1]);
    return 0;
}


Compiler output:
a.cc:9:17: error: 'long long int index [123456]' redeclared as different kind of entity
    9 |     ll index[mam];
      |                 ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:25:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   25 |         index[am[i]]++;
      |              ^
a.cc:26:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   26 |         index[aam[i]]++;
      |              ^
a.cc:27:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   27 |         index[sam[i]]++;
      |              ^
a.cc:30:22: error: invalid operands of types '<unresolved overloaded function type>' and 'long long int' to binary 'operator+'
   30 |     sort(index, index+n);
      |                 ~~~~~^~
a.cc:31:27: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   31 |     printf("%lld\n", index[n-1]);
      |                           ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define mam 123456
using namespace std;
    ll am[mam];

    ll aam[mam],sam[mam];

    ll index[mam];

int main()
{
    ll n;
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",am+i);
    for(int i=0;i<n;i++){
        aam[i]=am[i]+1;
        sam[i]=am[i]-1;
    }
    for(int i=0;i<n;i++){
        index[am[i]]++;
        index[aam[i]]++;
        index[sam[i]]++;
    }
    sort(index,index+n);
    printf("%lld", index[n-1]);
    return 0;
}


Compiler output:
a.cc:9:17: error: 'long long int index [123456]' redeclared as different kind of entity
    9 |     ll index[mam];
      |                 ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:22:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   22 |         index[am[i]]++;
      |              ^
a.cc:23:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   23 |         index[aam[i]]++;
      |              ^
a.cc:24:14: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   24 |         index[sam[i]]++;
      |              ^
a.cc:26:21: error: invalid operands of types '<unresolved overloaded function type>' and 'long long int' to binary 'operator+'
   26 |     sort(index,index+n);
      |                ~~~~~^~
a.cc:27:25: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   27 |     printf("%lld", index[n-1]);
      |                         ^
Language: C++

#include<cstdio>
#include<iostream>
#define Maxn 100010
using namespace std;
int n,x,a[Maxn] = {0};
int main()
{
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>x;
        a[x]++;
        a[x+1]++;
        a[x-1]++;
    }
    sort(a,a+Maxn);
    cout<<a[Maxn-1]<<endl;
    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=100003;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a,na[N],ans=0;
	cin>>n;
	CLR(na);
	FOR(i,1,n+1){
		cin>>a;
		++a;
		++na[a];
		na[a-1]++;
		na[a+1]++;
	}
	FOR(i,0,N){
		ans=max(ans,a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:30: error: invalid types 'll {aka long long int}[int]' for array subscript
   23 |                 ans=max(ans,a[i]);
      |                              ^
Language: Java

import java.util.*;

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

        int N = scanner.nextInt();

        int[] nums = new int[100000];
        int max = 0;

        for (int i = 0; i < N; i++) {
            int tmp = Integer.parseInt(scanner.next());
            nums[tmp]++;
        }

        for (int i = 1; i < nums.length-1; i++) {
            max = Math.max(max, nums[i-1]+nums[i]+nums[i+1])
        }

        System.out.println(max);
    }
}


Compiler output:
Main.java:18: error: ';' expected
            max = Math.max(max, nums[i-1]+nums[i]+nums[i+1])
                                                            ^
1 error
Language: Java

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

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

        int N = scanner.nextInt();

        if (N == 1) {
            System.out.println("1");
            return;
        }

        ArrayList<Integer> a = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            a.add(Integer.parseInt(scanner.next()));
        }

        a.sort(Comparator.reverseOrder());

        int count = 1;
        int maxCount = 1;
        int before = -1;
        

        for (int i = 0; i < N - 1; i++) {
            int tmp = a.get(i) - a.get(i+1);
            
            if (tmp == 1) {
                if (before == 1) {
                    count = 3;
                } else if (before == 0) {
                    count++;
                } else {
                    count = 2;
                }
            } else if (tmp == 0 && before == 0 || before == 1) {
                count++;
            }
            
            if (count > maxCount) {
                maxCount = count;
            }

            before = Integer.parseInt(tmp);
        }

        System.out.println(count);
    }
}


Compiler output:
Main.java:48: error: incompatible types: int cannot be converted to String
            before = Integer.parseInt(tmp);
                                      ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error