criyle/codenet-compile-errors huggingface dataset:
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;
  map <ll, ll> score;
  rep(i, n) {
    ll a;
    cin >> a;
    for (ll i = -1; i <= 1; i++) {
      if (score.count(a+i)) score.at(a+i)++;
      else score[a+i] = 1;
    }
  }
  ll res = 0;
  for (auto p : score) res = max(res, p.second)
  cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:48: error: expected ';' before 'cout'
   68 |   for (auto p : score) res = max(res, p.second)
      |                                                ^
      |                                                ;
   69 |   cout << res << endl;
      |   ~~~~
Language: Java

import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),max=0;
    int[] a=new int[n],b=new int[i];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
      b[a[i]]++;
    }
    Arrays.sort(a);
    for(int i=a[0];i<=a[n-1];i++){
      int f=b[i-1]+b[i]+b[i+1];
      max=(int)Math.max(f,max);
    }
    System.out.println(max);
          
  }
}


Compiler output:
Main.java:8: error: cannot find symbol
    int[] a=new int[n],b=new int[i];
                                 ^
  symbol:   variable i
  location: class Main
1 error
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  int x = 100001;
  vector<int> v(x);
  int sum=0;
 
  sort(a.begin(),a.end());
  vector<int> b(100000); 
  for(int i=0; i<n; i++){
    b[a[i]]++;
  }
  
  
  for(int i=a[0]; i<=a[n-1]; i++){
    if(a[0] == 0){
      sum = b[i] + b[i+1];
    }
    else{
      sum = b[i-1] + b[i] + b[i+1];
    }
   }
    v[i] = sum;
    sum=0;
   
  }
  
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  
  cout << v[0] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:7: error: 'i' was not declared in this scope
   31 |     v[i] = sum;
      |       ^
a.cc: At global scope:
a.cc:36:7: error: expected constructor, destructor, or type conversion before '(' token
   36 |   sort(v.begin(),v.end());
      |       ^
a.cc:37:10: error: expected constructor, destructor, or type conversion before '(' token
   37 |   reverse(v.begin(),v.end());
      |          ^
a.cc:39:3: error: 'cout' does not name a type
   39 |   cout << v[0] << endl;
      |   ^~~~
a.cc:40:9: error: expected unqualified-id before 'return'
   40 |         return 0;
      |         ^~~~~~
a.cc:41:1: error: expected declaration before '}' token
   41 | }
      | ^
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  int x = 100001;
  vector<int> v(x);
  int sum=0;
  sort(a.begin(),a.end());
  
  for(int i=a[0]; i<=a[n-1]; i++){
   for(int j=0; j<n; j++){
    if(a[j]-i == 0 || abs(a[j]-i) == 1){
      sum++;
    }
   }
    v[i] = sum;
    sum=0;
   
  }
  
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end())
  
  cout << v[0] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:29: error: expected ';' before 'cout'
   29 |   reverse(v.begin(),v.end())
      |                             ^
      |                             ;
   30 | 
   31 |   cout << v[0] << endl;
      |   ~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> num(N);
    vector<int> ansv(100002);
    rep(i, 0, N) cin >> num[i];
    int ans = 0, count;
    rep(i, 0, N){
        ansv[num[i]]++;
        ansv[num[i]+1]++;
        ansv[num[i]+2]++;
    }
    int ans = 0;
    rep(i, 0, 1000002) ans = max(ans, ansv[i]);
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: redeclaration of 'int ans'
   20 |     int ans = 0;
      |         ^~~
a.cc:14:9: note: 'int ans' previously declared here
   14 |     int ans = 0, count;
      |         ^~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(){
  int n;
  cin >> n;
  assert(n>0);
  int line[1e5+10];
  for(auto&i:line)i=0;
  for(int i=0;i<n;++i){
    int x;
    cin >> x;
    assert(0<= x and x <= 1e5);
    ++line[x];
  }
  int ans = 0;
  for(int i=1;i<1e5;++i){
    ans = max(ans,line[i-1]+line[i]+line[i+1]);
  }
  cout << ans << endl;
  return 0;
}

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

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

int main(void) {
    int64_t N;
    int64_t key;
    int64_t maxcount = 0;
    int64_t sum;
    int64_t last;
    cin >> N;

    map<int64_t,int64_t> a;
    for(int i=0;i<N;i++) {
        cin >> key;
        a[key-1]++;
    }

    for(map<int64_t,int64_t>::iterator it = a.begin();it != a.end();++it) {
        sum = it->second;
        last = it->first;
//printf("sum:%ld\n", sum);
        auto it2 = it;
        ++it2;
        if(it2 != a.end() && ((last+2) >= it2->first)){
            sum+=it2->second;
            ++it2;
            if(it2 != a.end()&&((last+2) >= it2->fist))  sum+=it2->second;
        }
        if(maxcount < sum) maxcount = sum;
    }
    
    cout << maxcount << "\n";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:50: error: 'struct std::pair<const long int, long int>' has no member named 'fist'; did you mean 'first'?
   27 |             if(it2 != a.end()&&((last+2) >= it2->fist))  sum+=it2->second;
      |                                                  ^~~~
      |                                                  first
Language: C++

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

int main(void) {
    int64_t N;
    int64_t key;
    int64_t maxcount = 0;
    int64_t sum;
    int64_t last;
    cin >> N;

    map<int64_t,int64_t> a;
    for(int i=0;i<N;i++) {
        cin >> key;
        a[key-1]++;
    }

    for(map<int64_t,int64_t>::iterator it = a.begin();it != a.end();++it) {
        sum = it->second;
        last = it->first;
//printf("sum:%ld\n", sum);
        auto it2 = it;
        ++it2;
        if(it2 != a.end() && ((last+2) >= it2.first)){
            sum+=it2->second;
            ++it2;
            if(it2 != a.end()&&((last+2) >= it2.fist))  sum+=it2->second;
        }
        if(maxcount < sum) maxcount = sum;
    }
    
    cout << maxcount << "\n";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:47: error: 'struct std::_Rb_tree_iterator<std::pair<const long int, long int> >' has no member named 'first'
   24 |         if(it2 != a.end() && ((last+2) >= it2.first)){
      |                                               ^~~~~
a.cc:27:49: error: 'struct std::_Rb_tree_iterator<std::pair<const long int, long int> >' has no member named 'fist'
   27 |             if(it2 != a.end()&&((last+2) >= it2.fist))  sum+=it2->second;
      |                                                 ^~~~
Language: C

#include<stdio.h>

int main(void){
	int N;
	int i;
	char a[100000][100000]
	int cnt[100000] = {0};
	int X = 0;
	int max;
	
	scanf("%d", N);
	
	for(i = 0;i < N;i++){
		scanf("%d", &a[i]);
		cnt[a[i] - 1]++;
	}
	
	for(i = 1;i < N - 1;i++){
		if(cnt[i - 1] + cnt[i] + cnt[i + 1] > X)
			X = cnt[i - 1] + cnt[i] + cnt[i + 1];
	}
	
	printf("%d", &X);
	
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:31: error: expected ';' before 'int'
    6 |         char a[100000][100000]
      |                               ^
      |                               ;
    7 |         int cnt[100000] = {0};
      |         ~~~                    
main.c:14:30: error: 'a' undeclared (first use in this function)
   14 |                 scanf("%d", &a[i]);
      |                              ^
main.c:14:30: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  int ans = 0;
  for(int i = a[0]; i <= a[n-1]; i++) {
    int now = 0;
    rep(j,n) {
      int difference = max(a[j] - i, i - a[j]);
      if(difference <= 1) now++;
    }
    ans = max(now,ans);
  }
  cout << ans << endl;
}

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

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

int main(){
    int n,i;
    int a[100001];
    int count[100001];
    int tmp = 0;
    int max = 0;
    int ans;
    
    scanf("%d",&n);
    rep(i,n){
        scanf("%d",&a[i]);
        coutn[a[i]]++;
    }
    
    for(i = 0; i < 99998; i++){
        tmp = count[i] + count[i+1] + count[i+2];
        if(tmp > max){
            max = tmp;
//            printf("%d is good ... %d\n",i,max);
        }
    }
    printf("%d\n",max);
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:15:9: error: 'coutn' undeclared (first use in this function); did you mean 'count'?
   15 |         coutn[a[i]]++;
      |         ^~~~~
      |         count
main.c:15:9: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:16:31: error: 'coust' was not declared in this scope; did you mean 'count'?
   16 |   cout<<a[count]+a[count+1]+a[coust-1]<<endl;}
      |                               ^~~~~
      |                               count
Language: C++

N = int(input())
a = list(map(int, input().split()))

num_list = [0 for _ in range(10 ** 5)]
for i in a:
    if i > 1:
        num_list[i - 2] += 1
    num_list[i - 1] += 1
    if i < 10 ** 5:
        num_list[i] += 1
print(max(num_list))


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

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

int main(){
  int n, s = 0; scanf("%d", &n);
  map<int, int> m;
  rep(i, n){
    int a; scanf("%d", &a);
    m[a]++;
  }
  rep(i, 1e5-1) s = max(s, m[i]+m[i+1]+m[i+2]);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'map' was not declared in this scope
    6 |   map<int, int> m;
      |   ^~~
a.cc:6:3: note: suggested alternatives:
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:102:11: note:   'std::map'
  102 |     class map
      |           ^~~
/usr/include/c++/14/map:89:13: note:   'std::pmr::map'
   89 |       using map
      |             ^~~
a.cc:6:7: error: expected primary-expression before 'int'
    6 |   map<int, int> m;
      |       ^~~
a.cc:9:5: error: 'm' was not declared in this scope
    9 |     m[a]++;
      |     ^
a.cc:11:28: error: 'm' was not declared in this scope
   11 |   rep(i, 1e5-1) s = max(s, m[i]+m[i+1]+m[i+2]);
      |                            ^
a.cc:11:21: error: 'max' was not declared in this scope; did you mean 'std::max'?
   11 |   rep(i, 1e5-1) s = max(s, m[i]+m[i+1]+m[i+2]);
      |                     ^~~
      |                     std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; ++i) cin >> a.at(i);
  
  vector<int> cnt(1e5+1);
  for (int x : a) cnt.at(a)++;
  int res = -1;
  for (int i=1; i<1e5; ++i) {
    if (res < cnt.at(i-1) + cnt.at(i) + cnt.at(i+1)) res = cnt.at(i-1) + cnt.at(i) + cnt.at(i+1);
  }
  cout << res << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:25: error: no matching function for call to 'std::vector<int>::at(std::vector<int>&)'
   12 |   for (int x : a) cnt.at(a)++;
      |                   ~~~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1180:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
 1180 |       at(size_type __n)
      |       ^~
/usr/include/c++/14/bits/stl_vector.h:1180:20: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1180 |       at(size_type __n)
      |          ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1199:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::at(size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
 1199 |       at(size_type __n) const
      |       ^~
/usr/include/c++/14/bits/stl_vector.h:1199:20: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1199 |       at(size_type __n) const
      |          ~~~~~~~~~~^~~
Language: C++

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int n,a[110000];
signed main(){
  cin>>n;
  rep(i,n){
    int aa;cin>>aa;
    a[aa-1]++;
    a[aa]++;
    a[aa+1]++;
  }
  sort(a, a+n, greater<int>())
  cout << a[0] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:31: error: expected ';' before 'cout'
   48 |   sort(a, a+n, greater<int>())
      |                               ^
      |                               ;
   49 |   cout << a[0] << endl;
      |   ~~~~
Language: C++

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

int main() {
  int N;
  cin >> N;
  
  int M = 100001;
  
  int a[M];
  int num;
  
  for (int i = 0; i < N; i++) {
    cin >> num;
    
    a[num-1]++;
    a[num]++;
    a[num+1]++;
  }
  
  int ans = 0;
  
  for ( int i = 1; i < 100001; i++) {
    if (ans < a[i]) {
      ans = a[i];
  }
  cout << ans << endl;
}

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

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

bool check (string s){
  int n = s.length();
  if (n%2==1){
    return false;
  }
  else {
    return (s.substr(0,n/2-1)==s.substr(n/2));
  }
}

int choise_sort (int n, int a[]){
  int index;
  for (int i=0; i<n-1; i++){
    int min = a[i], num;
    for (int j=i; j<n-1; j++){
      if (a[j+1]<min){
        min = a[j+1];
        num = j+1;
      }
    }
    index = a[i];
    a[i] = min;
    a[num] = index;
  }
}

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

  vector<int> a(3*n);
  for (int i=0; i<3*n; i+=3){
    cin >> a.at(i);
    a.at(i+1) = a.at(i)-1;
    a.at(i+2) = a.at(i)+1;
  }

  int index=0, max=0;
  sort (a.begin(),a.end());
  for (int i=0; i<3*n-1; i++){
    if (a.at(i)==a.at(i+1)){
      index++;
    }
    else {
      if (index>max){
        max = index;
        index = 0;
      }
    }
  }

  cout << max << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int choise_sort(int, int*)':
a.cc:30:1: warning: no return statement in function returning non-void [-Wreturn-type]
   30 | }
      | ^
a.cc: In function 'int main()':
a.cc:44:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   44 |   sort (a.begin(),a.end());
      |   ^~~~
      |   short
Language: C++

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

bool check (string s){
  int n = s.length();
  if (n%2==1){
    return false;
  }
  else {
    return (s.substr(0,n/2-1)==s.substr(n/2));
  }
}

int sort (int n, int a[]){
  int index;
  for (int i=0; i<n-1; i++){
    int min = a[i], num;
    for (int j=i; j<n-1; j++){
      if (a[j+1]<min){
        min = a[j+1];
        num = j+1;
      }
    }
    index = a[i];
    a[i] = min;
    a[num] = index;
  }
}

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

  vector<int> a(3*n);
  for (int i=0; i<3*n; i+=3){
    cin >> a.at(i);
    a.at(i+1) = a.at(i)-1;
    a.at(i+2) = a.at(i)+1;
  }

  int index=0, max=0;
  sort (a.begin(),a.end());
  for (int i=0; i<3*n-1; i++){
    if (a.at(i)==a.at(i+1)){
      index++;
    }
    else {
      if (index>max){
        max = index;
        index = 0;
      }
    }
  }

  cout << max << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int sort(int, int*)':
a.cc:30:1: warning: no return statement in function returning non-void [-Wreturn-type]
   30 | }
      | ^
a.cc: In function 'int main()':
a.cc:44:16: error: cannot convert 'std::vector<int>::iterator' to 'int'
   44 |   sort (a.begin(),a.end());
      |         ~~~~~~~^~
      |                |
      |                std::vector<int>::iterator
a.cc:16:15: note:   initializing argument 1 of 'int sort(int, int*)'
   16 | int sort (int n, int a[]){
      |           ~~~~^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  int Min=a.at(0);
  int Max=a.at(N-1);
  int ans=0;
  map<int,int>M;
  for(int i=Min-2;i<=Max;i++)
    M[i]=0;
  for(int i=0;i<N;i++)
    M.at(a.at(i))++;
  int ans=0;
  int sum=0;
  for(int i=Min-2;i<=Max-2;i++){
  sum+=(M.at(i+2)-M.at(i));
    if(ans<=sum)
      ans=sum;
  }
  
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:7: error: redeclaration of 'int ans'
   18 |   int ans=0;
      |       ^~~
a.cc:12:7: note: 'int ans' previously declared here
   12 |   int ans=0;
      |       ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  int64_t Min=a.at(0);
  int64_t Max=a.at(N-1);
  int ans=0;
  map<int,int>M;
  for(int64_t i=Min-2;i<=Max)
    M[i]=0;
  for(int i=0;i<N;i++)
    M.at(A.at(i))++;
  int ans=0;
  int64_t sum=+M.at(Min-1);
  for(int i=Min-2;i<=Max-2;i++){
  sum+=(M.at(i+2)-M.at(i));
    if(ans<=sum)
      ans=sum;
  }
  
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:29: error: expected ';' before ')' token
   14 |   for(int64_t i=Min-2;i<=Max)
      |                             ^
      |                             ;
a.cc:17:10: error: 'A' was not declared in this scope
   17 |     M.at(A.at(i))++;
      |          ^
a.cc:18:7: error: redeclaration of 'int ans'
   18 |   int ans=0;
      |       ^~~
a.cc:12:7: note: 'int ans' previously declared here
   12 |   int ans=0;
      |       ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  int Min=a.at(0);
  int Max=a.at(N-1);
  int ans=0;
  for(int i=Min;i<=Max;i++){
    int sum=0;
    for(int j=0;j<N;j++){
  if(abs(i-a.at(j))<=1))
     sum++;
  }   if(ans<=sum)
     ans=sum;
  
  }cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:24: error: expected primary-expression before ')' token
   16 |   if(abs(i-a.at(j))<=1))
      |                        ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  int Min=a.at(0);
  int Max=a.at(N-1);
  int ans=0;
  for(int i=Min;i<=Max;i++){
    int sum=0;
    for(int j=0;j<N;j++){
  if(abs(i-a.at(j)<=1)
     sum++;
  }   if(ans<=sum)
     ans=sum;
  
  }cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:23: error: expected ';' before 'sum'
   16 |   if(abs(i-a.at(j)<=1)
      |                       ^
      |                       ;
   17 |      sum++;
      |      ~~~               
a.cc:18:3: error: expected primary-expression before '}' token
   18 |   }   if(ans<=sum)
      |   ^
a.cc:17:12: error: expected ')' before '}' token
   17 |      sum++;
      |            ^
      |            )
   18 |   }   if(ans<=sum)
      |   ~         
a.cc:16:5: note: to match this '('
   16 |   if(abs(i-a.at(j)<=1)
      |     ^
a.cc:18:3: error: expected primary-expression before '}' token
   18 |   }   if(ans<=sum)
      |   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  int Min=a.at(0);
  int Max=a.at(N-1);
  int ans=0;
  for(int i=Min;i<=Max;i++){
    int sum=0;
    for(int j=0;j<N;j++){
  if(abs(i-a.at(j))
     sum++;
  }   if(ans<=sum)
     ans=sum;
  
  }cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:20: error: expected ';' before 'sum'
   16 |   if(abs(i-a.at(j))
      |                    ^
      |                    ;
   17 |      sum++;
      |      ~~~            
a.cc:18:3: error: expected primary-expression before '}' token
   18 |   }   if(ans<=sum)
      |   ^
a.cc:17:12: error: expected ')' before '}' token
   17 |      sum++;
      |            ^
      |            )
   18 |   }   if(ans<=sum)
      |   ~         
a.cc:16:5: note: to match this '('
   16 |   if(abs(i-a.at(j))
      |     ^
a.cc:18:3: error: expected primary-expression before '}' token
   18 |   }   if(ans<=sum)
      |   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  int Min=a.at(0);
  int Max=a.at(N-1);
  int ans=0;
  for(int i=Min;i<=Max;i++){
    int sum=0;
    for(int j=0;j<N;j++){
  if(abs(i-A.at(j))
     sum++;
  }   if(ans<=sum)
     ans=sum;
  
  }cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:12: error: 'A' was not declared in this scope
   16 |   if(abs(i-A.at(j))
      |            ^
a.cc:18:3: error: expected primary-expression before '}' token
   18 |   }   if(ans<=sum)
      |   ^
a.cc:17:12: error: expected ')' before '}' token
   17 |      sum++;
      |            ^
      |            )
   18 |   }   if(ans<=sum)
      |   ~         
a.cc:16:5: note: to match this '('
   16 |   if(abs(i-A.at(j))
      |     ^
a.cc:18:3: error: expected primary-expression before '}' token
   18 |   }   if(ans<=sum)
      |   ^
Language: Java

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] a = new int[N];
        int[] X = new int[1_000_00];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
            X[a[i]]++;
        }
        int res = 0;
        for (int i = 0; i < 1_000_00; i++) {
            if (i != 0 && i != 1_000_00 - 1) {
                res = Math.max(res, X[i - 1] + X[i] + X[i + 1]);
            }
            if (i == 0) {
                res = Math.max(res, X[0] + X[1]);
            }
            if (i == 1_000_00 - 1) {
                res = Math.max(res, X[1_000_00 - 1] + X[1_000_00 - 1 - 1]);
            }
        }
        System.out.println(res);

    }

    private long gcd(long x, long y) {
        if (y == 0) {
            return x;
        }
        return gcd(y, x % y);
    }

    private long lcm(long x, long y) {
        return x * y / gcd(x, y);
    }

    private long lcm(long[] a) {
        long x = a[0];
        for (int i = 0; i < a.length; i++) {
            x = lcm(a[i], x);
        }
        return x;
    }
}


Compiler output:
Main.java:8: error: cannot find symbol
        test main = new test();
        ^
  symbol:   class test
  location: class Main
Main.java:8: error: cannot find symbol
        test main = new test();
                        ^
  symbol:   class test
  location: class Main
2 errors
Language: C++

#include <iostream>
using namespace std;
 
#define Max(a, b) ((a>b)?a:b)
 
int main() {
  int n;
  cin >> n;
  int a[n], cnt[100000] = {};
  for (int i=0; i<n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  int ans = 0;
  for (int i=1; i<100000-1; i++)
    ans = Max(ans, cnt[i-1]+cnt[i]+cnt[i+1]);
  cout << ans << '\n';
  return 0;
}
#include <iostream>
using namespace std;

#define Max(a, b) ((a>b)?a:b)

int main() {
  int n;
  cin >> n;
  int a[n], cnt[100000] = {};
  for (int i=0; i<n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  int ans = 0;
  for (int i=1; i<100000-1; i++)
    ans = Max(ans, cnt[i-1]+cnt[i]+cnt[i+1]);
  cout << ans << '\n';
  return 0;
}
提出情報
提出日時

Compiler output:
a.cc:25:5: error: redefinition of 'int main()'
   25 | int main() {
      |     ^~~~
a.cc:6:5: note: 'int main()' previously defined here
    6 | int main() {
      |     ^~~~
a.cc:39:1: error: '\U000063d0\U000051fa\U000060c5\U00005831' does not name a type
   39 | 提出情報
      | ^~~~~~~~
Language: C++

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

using namespace std;

int main(){
    int n ;
    cin >> n;
    vector<int> a(n);

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


    
    int cnt = 0;
    int maxCnt = 0;
    for(int i = 0; i < n; i++){
        cnt = 0;
        x = a[i];
        
        for(int j = 0; j < n; j++){
            if(x-1 == a[j] || a[j] == x + 1 || a[j] == x ){
                cnt++;
            }
        }
        if(cnt > maxCnt){
            maxCnt = cnt;
        }
    }
    cout << maxCnt << endl;
}

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

n = int(input())
a = list(map(int,input().split()))
cnt = [0] * (max(a) + 1)
for i in range(n):
         cnt[a[i]] += 1
sumcnt = [0]
for i in range(len(cnt)):
         sumcnt.append(sumcnt[i]+cnt[i])
ans = 0
for i in range(len(sumcnt) - 3):
         if ans < sumcnt[i+3] - sumcnt[i]:
                  ans = sumcnt[i+3] - sumcnt[i]
print(ans)


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

//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N; cin >> N;
	vector<ll> a(N); rep(i, N)cin >> a[i];

	sort(ALL(a));

	vector<ll> cnt(a[N-1] + 1)
	rep(i, N) cnt[a[i]]++;
	

	ll mx = cnt[0] + cnt[1];
	for (int i = 1; i <= a[N - 1]; i++) {
		if (i == a[N - 1]) {
			mx = max(mx, cnt[i - 1] + cnt[i]);
			continue;
		}
		mx = max(mx, cnt[i - 1] + cnt[i] + cnt[i + 1]);
	}

	cout << mx << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:18: error: expected ',' or ';' before 'for'
   22 | #define rep(i,N) for(int i = 0; i < N;i++)
      |                  ^~~
a.cc:62:9: note: in expansion of macro 'rep'
   62 |         rep(i, N) cnt[a[i]]++;
      |         ^~~
a.cc:62:13: error: 'i' was not declared in this scope
   62 |         rep(i, N) cnt[a[i]]++;
      |             ^
a.cc:22:33: note: in definition of macro 'rep'
   22 | #define rep(i,N) for(int i = 0; i < N;i++)
      |                                 ^
Language: C++

#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define all(a)  (a).begin(),(a).end()


signed main(){
  int n;
  cin>>n;
  V<int> a(n);
  fo(i,n){
    cin>>a[i];
  }
  Sort(a);
  int ans=0;
  fo(i,n+1){
    int x=i;
    int b=0;
    fo(j,n){
      if(a[i]+1==x)
        b++;
      else if(a[i]==x)
        b++;
      else if(a[i]-1==x)
        b++;
      else
        continue;
      ams=max(ans,b);
    }
  }
  cout<<ans<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:50:7: error: 'ams' was not declared in this scope; did you mean 'ans'?
   50 |       ams=max(ans,b);
      |       ^~~
      |       ans
Language: C

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

int main()
{
  int n;
  
  scanf("%d",&n);
  
  int a[n];
  int i,j;
  int x;
  int count[100002]={};
  int ans=0;
  int tmp;
  
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    count[a[i]]++;   
  }
  
  for(i=0;i<n;i++)
  {
    x=a[i];
    if(x==0)
    {
     tmp=count[x]+count[x+1];
    }
    else
    {
     tmp=count[x-1]+count[x]+count[x+1];
    }
    if(ans<=tmp)
    {
      ans=tmp;
    }
  
  }

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

#include<bits/std++.h>

using namespace std;

int main()
{
  long long n; cin >> n;
  vector<long long> a(n);
  for(auto i: a) cin >> i;
  long long canst = 0;
  for(long long i = 0;i < n;i++)
  {
    long long flag = 0;
    for(long long j = 0;j < n;j++)
    {
      if(a[i] - 1 <= a[j]&&a[i] + 1 >= a[j])
        flag++;
    }
    canst = max(canst, flag);
  }
  cout << canst << endl;
}


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

#include<bits/std++.h>

int main()
{
  long long n; cin >> n;
  vector<long long> a(n);
  for(auto i: a) cin >> i;
  long long canst = 0;
  for(long long i = 0;i < n;i++)
  {
    long long flag = 0;
    for(long long j = 0;j < n;j++)
    {
      if(a[i] - 1 <= a[j]&&a[i] + 1 >= a[j])
        flag++;
    }
    canst = max(canst, flag);
  }
  cout << canst << endl;
}

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

#include <iostream>
using namespace std;

int main() {
  	int N;
  	cin >> N;
  	int a[N];
  	int res = 0, a = 0, b = 0;
  	for (int i = 0; i < N; i++){
      	cin >> a[i];
    }
  	int num[1000000];
    for (int i = 0; i < N; i++){
      	num[a[i]]++;
      	num[a[i] + 1]++;
      	num[a[i] - 1]++;
    }
  	for (int i = 1; i <= N; i++){
      	a = num[i];
      	if (a > b) {
          	b = a;
          	res = i;
        }
    }
  	cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:22: error: conflicting declaration 'int a'
    8 |         int res = 0, a = 0, b = 0;
      |                      ^
a.cc:7:13: note: previous declaration as 'int a [N]'
    7 |         int a[N];
      |             ^
a.cc:19:11: error: incompatible types in assignment of 'int' to 'int [N]'
   19 |         a = num[i];
      |         ~~^~~~~~~~
a.cc:20:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   20 |         if (a > b) {
      |             ~~^~~
a.cc:21:21: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   21 |                 b = a;
      |                     ^
      |                     |
      |                     int*
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
map<LL,LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>n
    for(i=0,k=0; i<n; i++)
    {
        cin>>o;
        v[o]++;
        v[o-1]++;
        v[o+1]++;
        k=max(k,max(max(v[o],v[o-1]),v[o+1]));

    }
  cout<<k<<endl;
    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:11: error: expected ';' before 'for'
   43 |     cin>>n
      |           ^
      |           ;
   44 |     for(i=0,k=0; i<n; i++)
      |     ~~~    
a.cc:44:26: error: expected ';' before ')' token
   44 |     for(i=0,k=0; i<n; i++)
      |                          ^
      |                          ;
Language: C++

//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n;
  cin>>n;
  vl a(n);
  map<ll,ll>M;
  rep(i,n)cin>>a[i];
  rep(i,n){
    M[a[i]+1]++;
    M[a[i]]++;
    M[a[i]-1]++;
  }
  MAX=0;
  for(auto p:M){
    MAX=max(MAX,p.second);
  }
  cout<<MAX<<endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:25:3: error: 'MAX' was not declared in this scope
   25 |   MAX=0;
      |   ^~~
Language: Java

import java.util.*;
public class Main{

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      if(n == 1) {
        System.out.println(1);
        return;
      }

      int[] arr = new int[100001];
      for(int i = 0; i < n; i++)
        arr[sc.nextInt()]++;
      
      int max = 0;
      for(int i = 1; i < arr.length - 1; i++) {
          max = Math.max(max, arr[i-1] + arr[i] + arr[i+1])
      }

      System.out.println(max);
  }
}


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

#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
   cin >> a.at(i);
  }
  sort(ALL(a));
  int result = 1;
  int i = 0;
  while(i < N){
    int counter = 1;
    int j = i + 1;
    bool flag = false;
    while(j < N && a.at(j) <= a.at(i) + 2){
      //if(a.at(j) != a.at(i) && a.at(j-1) == a.at(i)) flag = true;;
      counter++;
      j++;
    }
    //if(flag) i = j;
    else i++;
    if(counter > result) result = counter;
  }
  cout << result << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'else' without a previous 'if'
   24 |     else i++;
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M=0;cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A.at(i);
  sort(A.begin(),A.end());
  for(int i=1;i<=A.at(N-1);i++){
    M=max(M,upper_bound(A.begin(),A.end(),i)-upper_bound(A.begin(),A.end(),i-2));
  }
  cout<<M<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: no matching function for call to 'max(int&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
    9 |     M=max(M,upper_bound(A.begin(),A.end(),i)-upper_bound(A.begin(),A.end(),i-2));
      |       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: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:9:10: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
    9 |     M=max(M,upper_bound(A.begin(),A.end(),i)-upper_bound(A.begin(),A.end(),i-2));
      |       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:
/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:9:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    9 |     M=max(M,upper_bound(A.begin(),A.end(),i)-upper_bound(A.begin(),A.end(),i-2));
      |       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M=0;cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A.at(i);
  sort(A.begin(),A.end());
  for(int i=1;i<=A.at(N-1);i++){
    M=max(M,upper_bound(A.begin(),A.end(),i)-upper_bound(A.begin(),A.end(),i-2))
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: no matching function for call to 'max(int&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
    9 |     M=max(M,upper_bound(A.begin(),A.end(),i)-upper_bound(A.begin(),A.end(),i-2))
      |       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: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:9:10: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
    9 |     M=max(M,upper_bound(A.begin(),A.end(),i)-upper_bound(A.begin(),A.end(),i-2))
      |       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:
/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:9:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    9 |     M=max(M,upper_bound(A.begin(),A.end(),i)-upper_bound(A.begin(),A.end(),i-2))
      |       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:10:2: error: expected '}' at end of input
   10 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++){
    cin >> data[i];
  }
  int min = *min_element(data.begin(), data.end());
  int max = *max_element(data.begin(), data.end());
  int count = 0;
  for(int x = min - 1; x <= max + 1; x++){
    int count1 = 0
    for(int i = 0; i < N; i++){
      if(x == (data[i] + 1) || x == (data[i]) || x == (data[i] - 1)){
        count1++;
      }
    }
    if(count1 > count) count = count1;
  }
  cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: expected ',' or ';' before 'for'
   16 |     for(int i = 0; i < N; i++){
      |     ^~~
a.cc:16:20: error: 'i' was not declared in this scope
   16 |     for(int i = 0; i < N; i++){
      |                    ^
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++){
    cin >> data[i];
  }
  int min = *min_element(data.begin(), data.end());
  int max = *max_element(data.begin(), data.end());
  int count = 0;
  for(int x = min - 1; x <= max + 1; x++){
    for(int i = 0; i < N; i++){
      if(x == (data[i] + 1) || x == (data[i]) || x == (data[i] - 1)){
        count1++;
      }
    }
    if(count1 > count) count = count1;
  }
  cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'count1' was not declared in this scope; did you mean 'count'?
   17 |         count1++;
      |         ^~~~~~
      |         count
a.cc:20:8: error: 'count1' was not declared in this scope; did you mean 'count'?
   20 |     if(count1 > count) count = count1;
      |        ^~~~~~
      |        count
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++){
    cin >> data[i];
  }
  int min = *min_element(data.begin(), data.end());
  int max = *max_element(data.begin(), data.end());
  int count = 0
  for(int x = min - 1; x <= max + 1; x++){
    for(int i = 0; i < N; i++){
      if(x == (data[i] + 1) || x == (data[i]) || x == (data[i] - 1)){
        count1++;
      }
    }
    if(count1 > count) count = count1;
  }
  cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: expected ',' or ';' before 'for'
   14 |   for(int x = min - 1; x <= max + 1; x++){
      |   ^~~
a.cc:14:24: error: 'x' was not declared in this scope
   14 |   for(int x = min - 1; x <= max + 1; x++){
      |                        ^