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

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

int main(){
	int N;
	cin>>N;
	int a[N];
	for(int i=0;i<N;++i){
		cin>>a[i];
	}
	int max=*max_element(a,a+N);
	int min=*min_element(a,a+N);
	int ans=0;
	int tmp=0;
	for(int x=min;x<max+1;++x){
		for(int i=0;i<N;++i){
			if(abs(a[i]-x)<=1)tmp++;
		}
		if(ans<tmp)ans=tmp;
		tmp=0;
	}
	cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: 'max_element' was not declared in this scope
   12 |         int max=*max_element(a,a+N);
      |                  ^~~~~~~~~~~
a.cc:13:18: error: 'min_element' was not declared in this scope
   13 |         int min=*min_element(a,a+N);
      |                  ^~~~~~~~~~~
Language: C++

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

int main(){
	int N;
	cin>>N;
	int a[N];
	for(int i=0;i<N;++i){
		cin>>a[i];
	}
	int max=*max_element(a,a+N);
	int min=*min_element(a,a+N);
	int ans=0;
	int tmp=0;
	for(int x=min;x<max+1;++x){
		for(int i=0;i<N;++i){
			if(abs(a[i]-x)<=1)tmp++;
		}
		if(ans<tmp)ans=tmp;
		tmp=0;
	}
	cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: 'max_element' was not declared in this scope
   12 |         int max=*max_element(a,a+N);
      |                  ^~~~~~~~~~~
a.cc:13:18: error: 'min_element' was not declared in this scope
   13 |         int min=*min_element(a,a+N);
      |                  ^~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;

int main(){
	int N;
	cin>>N;
	int a[N];
	for(int i=0;i<N;++i){
		cin>>a[i];
	}
	int max=*std::max_element(a,a+N);
	int min=*std::min_element(a,a+N);
	int ans=0;
	int tmp=0;
	for(int x=min;x<max+1;++x){
		for(int i=0;i<N;++i){
			if(abs(a[i]-x)<=1)tmp++;
		}
		if(ans<tmp)ans=tmp;
		tmp=0;
	}
	cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:23: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
   11 |         int max=*std::max_element(a,a+N);
      |                       ^~~~~~~~~~~
      |                       tuple_element
a.cc:12:23: error: 'min_element' is not a member of 'std'; did you mean 'tuple_element'?
   12 |         int min=*std::min_element(a,a+N);
      |                       ^~~~~~~~~~~
      |                       tuple_element
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin>>N;
	
	vector<int> vea(N),
	vector<int> veb(N),
	vector<int> vec(N),
	vector<int> ved(N),
	
	for(int i=0; i<N; i++){
		cin>>veb.at(i);
		vea.at(i)=veb.at(i)-1;
		vec.at(i)=veb.at(i)+1;
	}
	for(int i=0; i<N; i++){
		vea.at(i)=vea.at(i);
		vea.at(i+N)=veb.at(i);
		vea.at(i+N*2)=vec.at(i);
	}
	sort(ved.begin(), ved.end());
	
	int A=0,B=0,C=0;
	for(int i=0; i<N*3-1; i++){
		if(ved.at(i)==ved.at(i+1)){
			A++;
		}
		else{
			if(A>B){
				B=A;
			}
			A=0;
		}
	}
	cout<<B+1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:21: error: invalid declarator before 'veb'
    8 |         vector<int> veb(N),
      |                     ^~~
a.cc:12:22: error: 'i' was not declared in this scope
   12 |         for(int i=0; i<N; i++){
      |                      ^
a.cc:19:29: error: 'veb' was not declared in this scope; did you mean 'vea'?
   19 |                 vea.at(i+N)=veb.at(i);
      |                             ^~~
      |                             vea
a.cc:20:31: error: 'vec' was not declared in this scope; did you mean 'vea'?
   20 |                 vea.at(i+N*2)=vec.at(i);
      |                               ^~~
      |                               vea
a.cc:22:14: error: 'ved' was not declared in this scope; did you mean 'vea'?
   22 |         sort(ved.begin(), ved.end());
      |              ^~~
      |              vea
Language: C++

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

int main() {
  int n; cin>>n;
  int a[n];
  int count[100002]={0};
  rep(i, n){cin>>a[i];}
  
 rep(i, n){
   int p=a[i];
   count[p-1]++;count[p]++;count[p+1]++;
}

  sort(count,count+100002);
  cout<<count[100001]<<endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:19:29: error: expected '}' at end of input
   19 |   cout<<count[100001]<<endl;
      |                             ^
a.cc:7:12: note: to match this '{'
    7 | int main() {
      |            ^
Language: C++

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

struct ch{
	int value,num;
}f[10001];

bool cmp(ch a,ch b){
	return a.value>b.value;
}

int main(){
	int N;
	scanf("%d",&N);
	for(int i=1;i<=10001;++i){
		f[i].num=i-1;
	}
	for(int i=0;i!=N;++i){
		int a;
		scanf("%d",&a);
		++f[a];
		++f[a+1];
		++f[a+2];
	}
	sort(f,f+10002,cmp);
	cout<<f[0].num<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:17: error: no match for 'operator++' (operand type is 'ch')
   21 |                 ++f[a];
      |                 ^~~~~~
a.cc:22:17: error: no match for 'operator++' (operand type is 'ch')
   22 |                 ++f[a+1];
      |                 ^~~~~~~~
a.cc:23:17: error: no match for 'operator++' (operand type is 'ch')
   23 |                 ++f[a+2];
      |                 ^~~~~~~~
Language: C++

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

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

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

    int maximum = 0;
    int ans = 0;
    for (auto itr = map.begin(); itr != map.end(); itr++)
    {
        if (itr->second > maximum)
        {
            ans = itr->first;
        }
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:14: error: expected ']' before '-' token
   14 |         map[a - 1]++;
      |              ^~
      |              ]
a.cc:14:19: error: expected initializer before '++' token
   14 |         map[a - 1]++;
      |                   ^~
a.cc:14:19: error: expected ';' before '++' token
a.cc:15:15: error: expected initializer before '++' token
   15 |         map[a]++;
      |               ^~
a.cc:16:14: error: expected ']' before '+' token
   16 |         map[a + 1]++;
      |              ^~
      |              ]
a.cc:16:19: error: expected initializer before '++' token
   16 |         map[a + 1]++;
      |                   ^~
a.cc:21:24: error: missing template arguments before '.' token
   21 |     for (auto itr = map.begin(); itr != map.end(); itr++)
      |                        ^
a.cc:21:44: error: missing template arguments before '.' token
   21 |     for (auto itr = map.begin(); itr != map.end(); itr++)
      |                                            ^
Language: C++

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

int main(){
    int n,k=1e5+10;
    cin>>n;
    int a[n],t[k]={};
    for(int i=0;i<n;i++){
        cin>> a[i];
        t[a[i]]++;
    }
    int sum[k]={},ans=0;
    for(int i=1;i+1<k;i++){
        sum[i]=t[i-1]+t[i]+t[i＋1];
        ans=max(ans,sum[i]);
    }

    cout<<ans;


}



Compiler output:
a.cc: In function 'int main()':
a.cc:14:30: error: 'i\U0000ff0b1' was not declared in this scope
   14 |         sum[i]=t[i-1]+t[i]+t[i＋1];
      |                              ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(100001);
  int a;
  for(int i = 0; i < N; i++) {
    cin >> a;
    a++;
    data.at(a - 1)++;
    data.at(a)++;
    data.at(a + 1)++;
  }
  sort(data.begin(), sort.end());
  cout << data.at(100000) << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:27: error: overloaded function with no contextual type information
   15 |   sort(data.begin(), sort.end());
      |                           ^~~
Language: C++

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

int main(){
  int N;
  cin>>N;
  vector<int> a(100002);
  for(int i=0;i<N;i++){
    cin>>x;
    a[x]++
  }
  int max=0;
  for(int i=1;i<=100000;i++){
    if(ans<a[i]+a[i+1]+a[i-1])ans=a[i]+a[i+1]+a[i-1];
    }
  cout << max << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: 'x' was not declared in this scope
    9 |     cin>>x;
      |          ^
a.cc:14:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |     if(ans<a[i]+a[i+1]+a[i-1])ans=a[i]+a[i+1]+a[i-1];
      |        ^~~
      |        abs
Language: C++

package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func r() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := r()

	vs := make([]int, 100001)
	max := -int(^uint(0)>>1) - 1
	for a, i := 0, 0; i < n; i++ {
		a = r()

		vs[a]++
		switch a {
		case 0:
			vs[a+1]++
		case 100000:
			vs[a-1]++
		default:
			vs[a-1]++
			vs[a+1]++
		}

		if a != 0 && vs[a-1] > max {
			max = vs[a-1]
		}
		if a != 100000 && vs[a+1] > max {
			max = vs[a+1]
		}
		if vs[a] > max {
			max = vs[a]
		}
	}

	fmt.Println(max)
}


Compiler output:
a.cc:1:1: error: 'package' does not name a type
    1 | package main
      | ^~~~~~~
a.cc:19:1: error: 'func' does not name a type
   19 | func main() {
      | ^~~~
Language: C++

#include <iostream>
using namespace std;

int main(){
    int n,i,buf1,buf2;a=0,b=0,c=0,m=0,count=0;
    cin >> n >> buf1;
    count++;
    for(i=1; i<n; i++){
        cin >> buf2;
        if(buf1 == buf2){
            count++;
        }else{
            buf1 = buf2;
            a = b;
            b = c;
            c = count;
            count = 0;
        }
        m = max(a+b+c,m);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:23: error: 'a' was not declared in this scope
    5 |     int n,i,buf1,buf2;a=0,b=0,c=0,m=0,count=0;
      |                       ^
a.cc:5:27: error: 'b' was not declared in this scope
    5 |     int n,i,buf1,buf2;a=0,b=0,c=0,m=0,count=0;
      |                           ^
a.cc:5:31: error: 'c' was not declared in this scope
    5 |     int n,i,buf1,buf2;a=0,b=0,c=0,m=0,count=0;
      |                               ^
a.cc:5:35: error: 'm' was not declared in this scope
    5 |     int n,i,buf1,buf2;a=0,b=0,c=0,m=0,count=0;
      |                                   ^
a.cc:5:39: error: 'count' was not declared in this scope
    5 |     int n,i,buf1,buf2;a=0,b=0,c=0,m=0,count=0;
      |                                       ^~~~~
Language: C++

#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


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

	


Compiler output:
a.cc: In function 'int main()':
a.cc:49:29: error: expected '}' at end of input
   49 |         cout << ans << endl;
      |                             ^
a.cc:13:1: note: to match this '{'
   13 | {
      | ^
Language: C++

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int s[n];
  for(int i=0;i<100000;i++){
    s[i]=0;
  }
  for(int i=0;i<n;i++){
    s[a[i]]++;
  }
  int ans=0;
  for(int i=0;i<n-2;i++){
    ans=max(ans,s[i]+s[i+1]+s[i+2]);
  }
  cout <<　ans << endl;
}

Compiler output:
a.cc:23:10: error: extended character 　 is not valid in an identifier
   23 |   cout <<　ans << endl;
      |          ^
a.cc: In function 'int main()':
a.cc:23:10: error: '\U00003000ans' was not declared in this scope
   23 |   cout <<　ans << endl;
      |          ^~~~~
Language: C++

#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};

int main(){/
    ll N; cin >> N;
    const ll al = 1e5 + 10;
    map<ll, ll> m;
    REP(i, al) m[i] = 0;
    REP(i, N){
        ll a; cin >> a; m[a]++;
    }
    
    ll ret = 0;
    REP(i, al - 2){
        ll tmp = m[i] + m[i+1] + m[i+2];
        ret = max(ret, tmp);
    }
    cout << ret << endstr;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:12: error: expected primary-expression before '/' token
   49 | int main(){/
      |            ^
a.cc:50:8: error: expected primary-expression before 'N'
   50 |     ll N; cin >> N;
      |        ^
a.cc:50:18: error: 'N' was not declared in this scope
   50 |     ll N; cin >> N;
      |                  ^
Language: C++

#include <iostream>
using namespace std;

int main(){
    int N,a[100000],b[100000],max;
    cin >> N;
    for (int i=0; i<N; ++i) cin >> a[i];
    int j;
        for (int i=0; i<N; ++i){
                    if (a[i]==j){
                       b[j-1] += 1;
                       b[j] += 1;
                       b[j+1] +=1;
            }
        }
    
    max = b[0];
    for (int i=0; i<N; ++i){
        if (max< b[i]) max = b[i];
    }
    cout << max/3 << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:21:27: error: expected '}' at end of input
   21 |     cout << max/3 << endl;
      |                           ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <iostream>
using namespace std;

int main(){
    int N,a[100000],b[100000],max;
    cin >> N;
    for (int i=0; i<N; ++i) cin >> a[i];
    int j;
        for (int i=0; i<N; ++i){
                    if (a[i]==j){
                       b[j-1] += 1;
                       b[j] += 1;
                       b[j+1] +=1;
            }
        }
    }
    max = b[0];
    for (int i=0; i<N; ++i){
        if (max< b[i]) max = b[i];
    }
    cout << max/3 << endl;
}

Compiler output:
a.cc:17:5: error: 'max' does not name a type
   17 |     max = b[0];
      |     ^~~
a.cc:18:5: error: expected unqualified-id before 'for'
   18 |     for (int i=0; i<N; ++i){
      |     ^~~
a.cc:18:19: error: 'i' does not name a type
   18 |     for (int i=0; i<N; ++i){
      |                   ^
a.cc:18:24: error: expected unqualified-id before '++' token
   18 |     for (int i=0; i<N; ++i){
      |                        ^~
a.cc:21:5: error: 'cout' does not name a type
   21 |     cout << max/3 << endl;
      |     ^~~~
a.cc:22:1: error: expected declaration before '}' token
   22 | }
      | ^
Language: C++

#include <iostream>
using namespace std;

int main(){
    int N,a[100000],b[100000],max;
    cin >> N;
    for (int i=0; i<N; ++i) cin >> a[i];
    int j;
        for (int i=0; i<N; ++i){
                    if (a[i]==j){
                       b[j-1] += 1;
                       b[j] += 1;
                       b[j+1] +=1;
            ]
        }
    }
    max = b[0];
    for (int i=0; i<N; ++i){
        if (max< b[i]) max = b[i];
    }
    cout << max/3 << endl;
}

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

#include <iostream>
using namespace std;

int main(){
    int,N,a[100000],b[100000],max;
    cin >> N;
    for (int i=0; i<N; ++i) cin >> a[i];
    int j;
    for (int i=0; i<N; ++i){
        if (a[i-1]==j) b[j-1] += 1;
        if (a[i]==j) b[j-1] += 1;
        if (a[i+1]==j) b[j-1] += 1;
    }
    max = b[0];
    for (int i=0; i<N; ++i){
        if (max< b[i]) max = b[i];
    }
    cout << max/3 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:8: error: expected unqualified-id before ',' token
    5 |     int,N,a[100000],b[100000],max;
      |        ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define mod MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    ll n; cin >> n;
    ll a[n];
    map<ll, ll> mp_none, mp_pp, mp_mi;
    vector<ll> v;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        mp_none[a[i]]++;
        mp_pp[a[i]]++;
        mp_mi[a[i]]++;
        v.push_back(a[i]);
        v.push_back(a[i]+1);
        v.push_back(a[i]-1);
    }
    ll m = v.size();
    ll ans = 0;
    for(ll i = 0; i < m; i++){
        ans = max(ans, mp[v[i]]);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:24: error: 'mp' was not declared in this scope; did you mean 'm'?
   27 |         ans = max(ans, mp[v[i]]);
      |                        ^~
      |                        m
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int n;
    scanf("%d",&n);
    array<int,100100> mp={};
    int tmp;
    while(n--){
        scanf("%d", &tmp);
        mp[tmp]++;
        mp[tmp+2]++;
        mp[tmp+1]++;
    }
    int result=0;
    for(auto &x:mp){
        result=max(result,x);
    }
    cout << result << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:23: error: variable 'std::array<int, 100100> mp' has initializer but incomplete type
   21 |     array<int,100100> mp={};
      |                       ^~
a.cc:8:1: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>'
    7 | #include <map>
  +++ |+#include <array>
    8 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){

	int N, A[100010];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int cnt[100010];
	for (int i = 0; i < 100010; i++) {
		cnt[i] = 0;
	}
	for (int i = 0; i < N; i++){
		cnt[A[i]]++;
		cnt[A[i]+1 ]++;
		cnt[A[i]-1]++;
	}

	sort(cnt.begin(), cnt.end(),greater<int>());

	cout << cnt[0] << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:18: error: request for member 'begin' in 'cnt', which is of non-class type 'int [100010]'
   20 |         sort(cnt.begin(), cnt.end(),greater<int>());
      |                  ^~~~~
a.cc:20:31: error: request for member 'end' in 'cnt', which is of non-class type 'int [100010]'
   20 |         sort(cnt.begin(), cnt.end(),greater<int>());
      |                               ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){

	int N, A[100010];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int cnt[100010];
	for (int i = 0; i < 100010; i++) {
		cnt[i] = 0;
	}
	for (int i = 0; i < N; i++){
		cnt[A[i]]++;
		cnt[A[i]+1 ]++;
		cnt[A[i]-1]++;
	}

	sort(cnt.begin(), cnt.end().greater<int>());

	cout << cnt[0] << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:18: error: request for member 'begin' in 'cnt', which is of non-class type 'int [100010]'
   20 |         sort(cnt.begin(), cnt.end().greater<int>());
      |                  ^~~~~
a.cc:20:31: error: request for member 'end' in 'cnt', which is of non-class type 'int [100010]'
   20 |         sort(cnt.begin(), cnt.end().greater<int>());
      |                               ^~~
a.cc:20:37: error: invalid use of 'struct std::greater<int>'
   20 |         sort(cnt.begin(), cnt.end().greater<int>());
      |                                     ^~~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <map>

using namespace std;

map<int, int> T;

void CountNum(int n) {
  if (T.count(n) > 0) {
    // cout << "n:" << n << ", increment" << endl;
    T[n]++;
  } else {
    T.insert(make_pair(n, 1));
    // cout << "n:" << n << ", insert" << endl;
  }
}

int main() {
  int N;
  cin >> N;
  int n;
  vector<int> a;
  for (int i = 0; i < N; ++i) {
    cin >> n;
    a.push_back(n);
  }
  sort(a.begin(), a.end());
  
  for (int i = 0; i < N; ++i) {
    n = a[i];
    CountNum(n);
    if (n > 0) {
      CountNum(n-1);     
    }
    CountNum(n+1);
    // cout << "----------" << endl;
  }

  int max = 0;
  for(map<int, int>::iterator it = T.begin(); it != T.end(); it++) {
    pair<int, int> T = *it;
    if (T.second > max) {
      max = T.second;
    }
    // cout << "k:" << T.first << ", v:" << T.second << endl;
  }
  
  cout << max << endl;

}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
int n;
int a[maxx];
map <int, int> mp;
map <int, int> vis;

int main() {
	mp.clear();
	vis.clear();
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		vis[a[i]]++;
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		mp[a[i]] = via[a[i]] + via[a[i] - 1] + vis[a[i] + 1];
	}
	for(int i = 1; i <= n; i++) ans = max(ans, mp[a[i]]);
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:28: error: 'via' was not declared in this scope; did you mean 'vis'?
   20 |                 mp[a[i]] = via[a[i]] + via[a[i] - 1] + vis[a[i] + 1];
      |                            ^~~
      |                            vis
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k[100005];
  cin>>n;
  vector<int>l(n,0)
  for(int i=0;i<n;++i){
    cin>>k[i];
    l[k[i]-1]++;
  }
  int ans=0;
  for(int i=0;i<n;++i){
    ans=max(ans,l[i]+l[i-1]+l[i+1]);
  }
  cout<<ans<<endl;
}


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

#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k[100005],;
  cin>>n;
  vector<int>l(n,0)
  for(int i=0;i<n;++i){
    cin>>k[i];
    l[k[i]-1]++;
  }
  int ans=0;
  for(int i=0;i<n;++i){
    ans=max(ans,l[i]+l[i-1]+l[i+1]);
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:19: error: expected unqualified-id before ';' token
    4 |   int n,k[100005],;
      |                   ^
a.cc:7:3: error: expected ',' or ';' before 'for'
    7 |   for(int i=0;i<n;++i){
      |   ^~~
a.cc:7:15: error: 'i' was not declared in this scope
    7 |   for(int i=0;i<n;++i){
      |               ^
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> a(100000);
  int b;
  REP(i,N){
    cin >> b;
    a[b]++;
  }
  
  for(int i=1;i<99999;i++){
      int sum = a[i-1] + a[i] + a[i+1];
      ans = max(ans,sum);
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |       ans = max(ans,sum);
      |       ^~~
      |       abs
a.cc:36:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vecotr<int> a(N);
  int ans = 0;
  for(int i=0;i<N;i++){
    int sum = 0;
    int X = a[i];
    for(int j=0;j<N;j++){
      if(X == a[j] || abs(X - a[j]) == 1) sum++;
    }
    ans = max(ans,sum);
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:3: error: 'vecotr' was not declared in this scope
   25 |   vecotr<int> a(N);
      |   ^~~~~~
a.cc:25:10: error: expected primary-expression before 'int'
   25 |   vecotr<int> a(N);
      |          ^~~
a.cc:29:13: error: 'a' was not declared in this scope
   29 |     int X = a[i];
      |             ^
Language: C++

using namespace std;

int main(){
  int a[100000], N, max = 0;
  int cnt[100000] = {};

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

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
    if(a[j] == a[i] || a[j] == a[i] - 1 || a[j] == a[i] + 1) cnt[i]++;
    }
    if(max < cnt[i]) max = cnt[i];
  }

  cout<<max<<endl;


  return 0;
}

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

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

int main(){
  int n,a[100000],maxn=0;
  cin>>n;
  for(int i=0;i<n; i++){
    cin>>a[i];
  }
  for(int i=0; i<100000; i++){
    int cnt=0;
    for(int j=0;j<n; j++){
      if(i-1<=a[j]&&a[j]<=i+1){
	cnt++;
	//cout<<j<<endl;
      }
    }
    //cout<<cnt<<endl;
    maxn = max(maxn,cnt);
  }
  cout<<maxn<<endl;
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin>>n;
      |   ^~~
a.cc:19:12: error: 'max' was not declared in this scope; did you mean 'maxn'?
   19 |     maxn = max(maxn,cnt);
      |            ^~~
      |            maxn
a.cc:21:3: error: 'cout' was not declared in this scope
   21 |   cout<<maxn<<endl;
      |   ^~~~
a.cc:21:15: error: 'endl' was not declared in this scope
   21 |   cout<<maxn<<endl;
      |               ^~~~
Language: C++

#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  int N;
  cin >> N;

  ll int a[100010] = {};

  for(ll int i = 0; i < N; i++){
    ll int x;
    cin>>x;
    a[x]++;
  }
  ll int ans = -1;
  for(int i = 1; i < N; i++){
    ll int sum = a[i - 1] + a[i] + a[i + 1];
    ll ans = max(sum, ans);
  }
  cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: two or more data types in declaration of 'a'
   13 |   ll int a[100010] = {};
      |   ^~
a.cc:15:7: error: two or more data types in declaration of 'i'
   15 |   for(ll int i = 0; i < N; i++){
      |       ^~
a.cc:15:21: error: 'i' was not declared in this scope
   15 |   for(ll int i = 0; i < N; i++){
      |                     ^
a.cc:16:5: error: two or more data types in declaration of 'x'
   16 |     ll int x;
      |     ^~
a.cc:17:10: error: 'x' was not declared in this scope
   17 |     cin>>x;
      |          ^
a.cc:18:5: error: 'a' was not declared in this scope
   18 |     a[x]++;
      |     ^
a.cc:20:3: error: two or more data types in declaration of 'ans'
   20 |   ll int ans = -1;
      |   ^~
a.cc:22:5: error: two or more data types in declaration of 'sum'
   22 |     ll int sum = a[i - 1] + a[i] + a[i + 1];
      |     ^~
a.cc:22:18: error: 'a' was not declared in this scope
   22 |     ll int sum = a[i - 1] + a[i] + a[i + 1];
      |                  ^
a.cc:23:18: error: 'sum' was not declared in this scope
   23 |     ll ans = max(sum, ans);
      |                  ^~~
a.cc:25:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int sum[100010] = {};
  int n;
  cin >> n;
  
  REP(i,n){
    int a;
    cin >> a;
    sum[a+1]++;
    sum[a]++;
    sum[a+2]++
  }
  
  int ans = 0;
  REP(i,100010){
    ans = max(ans,sum[i]);
  }
  
  cout << ans << endl;


 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:15: error: expected ';' before '}' token
   25 |     sum[a+2]++
      |               ^
      |               ;
   26 |   }
      |   ~
Language: C++

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

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

  vector<long> vec(n);

  for (int i = 0; i < n; i++) {

    cin >> vec[i];
  }

  sort(vec.begin(), vec.end());
  int N = *vec.back();

  vector<long> ar(N + 1, 0);
  vector<long> cou(N + 1, 0);

  ar[0] = 0;
  ar[vec[0]] = count(vec.begin(), vec.end(), vec[0]);
  for (int i = 1; i < n; i++) {
    if (vec[i] != vec[i - 1])
      ar[vec[i]] = count(vec.begin(), vec.end(), vec[i]);
  }

  cou[0] = ar[0] + ar[1];
  cou[vec[n - 1] + 1] = ar[vec[n - 1]] + ar[vec[n - 1] + 1];
  for (int i = 1; i < vec[n - 1] + 1; i++) {
    cou[i] = ar[i] + ar[i + 1] + ar[i - 1];
  }

  // sort(cou.begin(), cou.begin() + vec[n - 1] + 1, greater<int>());

  cout << *max_element(cou.begin(), cou.begin() + (vec[n - 1] + 1)) << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:11: error: invalid type argument of unary '*' (have '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   20 |   int N = *vec.back();
      |           ^~~~~~~~~~~
Language: C++

#include <iostream>
using namespace std;
int f[110000];
int main(void){
    // Your code here!
    int n;
    cin >> n;
    int res = 0
    for (int i = 0; i < n; i++) f[i]++;
    for (int i = 0; i < 100000; i++) {
        int ans = f[i - 1] + f[i] + f[i + 1];
        res = max(res, ans);
    }
    cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: expected ',' or ';' before 'for'
    9 |     for (int i = 0; i < n; i++) f[i]++;
      |     ^~~
a.cc:9:21: error: 'i' was not declared in this scope
    9 |     for (int i = 0; i < n; i++) f[i]++;
      |                     ^
Language: C++

// ConsoleApplication11.cpp : アプリケーションのエントリ ポイントを定義します。
//



// ConsoleApplication10.cpp : アプリケーションのエントリ ポイントを定義します。
//


// ConsoleApplication10.cpp : アプリケーションのエントリ ポイントを定義します。
//
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;


int main()
{
	int N, M, X, y, j, c,ans, i, k, ptr,l, m, sum;
	cin >> N;
	vector<int> A(N*3);
	int B[300000] = {};
	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (i = N; i < 2 * N; i++) {
		A[i]=A[i-N]+1;
	}
	for (i = 2*N; i < 3 * N; i++) {
		A[i] = A[i - 2*N] - 1;
	}
	sort(A.begin(), A.end());
	int ptr;
	ptr = 0;
	m = 0;
	while (ptr < 3 * N) {
		int cc = A[ptr];
		while (ptr < 3 * N&&A[ptr] == cc) {
			ptr++;
			B[m]++;
		}
		m++;
	}
	
	sort(B, B + m, greater<int>());

	cout << B[0] << endl;







	return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:35:13: error: redeclaration of 'int ptr'
   35 |         int ptr;
      |             ^~~
a.cc:21:41: note: 'int ptr' previously declared here
   21 |         int N, M, X, y, j, c,ans, i, k, ptr,l, m, sum;
      |                                         ^~~
Language: C++

// ConsoleApplication11.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"


// ConsoleApplication10.cpp : アプリケーションのエントリ ポイントを定義します。
//


// ConsoleApplication10.cpp : アプリケーションのエントリ ポイントを定義します。
//
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;


int main()
{
	int N, M, X, y, j, c,ans, i, k, ptr,l, m, sum;
	cin >> N;
	vector<int> A(N*3);
	int B[300000] = {};
	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (i = N; i < 2 * N; i++) {
		A[i]=A[i-N]+1;
	}
	for (i = 2*N; i < 3 * N; i++) {
		A[i] = A[i - 2*N] - 1;
	}
	sort(A.begin(), A.end());
	int ptr;
	ptr = 0;
	m = 0;
	while (ptr < 3 * N) {
		int cc = A[ptr];
		while (ptr < 3 * N&&A[ptr] == cc) {
			ptr++;
			B[m]++;
		}
		m++;
	}
	
	sort(B, B + m, greater<int>());

	cout << B[0] << endl;







	return 0;
}





Compiler output:
a.cc:4:10: fatal error: stdafx.h: No such file or directory
    4 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
using namespace std;
#define maxn 100001

vector<int> cnt(maxn);
int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < maxn; i++) {
    cnt[i] += count(a.begin(), a.end(), i);
    cnt[i] += count(a.begin(), a.end(), i-1);
    cnt[i] += count(a.begin(), a.end(), i+1);
  }
  int answer = *max_element(cnt.begin(), cnt.end());
  cout << answer << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: 'count' was not declared in this scope; did you mean 'cnt'?
   12 |     cnt[i] += count(a.begin(), a.end(), i);
      |               ^~~~~
      |               cnt
a.cc:16:17: error: 'max_element' was not declared in this scope
   16 |   int answer = *max_element(cnt.begin(), cnt.end());
      |                 ^~~~~~~~~~~
Language: C

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
 
int n,x=0,y;
int a[100100];
cin>>n;
for(int i=0;i<n;i++)
    cin>>a[i];

int s[100100]={0};    
for(int i=0;i<n;i++)
    s[a[i]]++;
for(int i=0;i<100100;i++)
    x=max(x,s[i]+s[i+1]+s[i+2]);
cout<<x;
                                                                                    
system("pause");
return 0;
}    

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

#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
using namespace std;
int a[10004];
int main(){
int n,most=0,cra=0;,big=0;
cin>>n;
for (int i=0;i<n;i++)
  cin>>a[i];
for (int q=0;q<n;q++){
if (a[q] > big)
big = a[q];
}
for (int k=0;k<big;k++){
for (int j=0;j<n;j++)
if ((a[j] + 1 == k) or (a[j] - 1 == k) or (a[j] == k))
cra++;
if (cra >= most)
most = cra;
cra=0;
}
cout<<most;
system ("pause");
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:20: error: expected primary-expression before ',' token
   11 | int n,most=0,cra=0;,big=0;
      |                    ^
a.cc:11:21: error: 'big' was not declared in this scope
   11 | int n,most=0,cra=0;,big=0;
      |                     ^~~
a.cc:12:1: error: 'cin' was not declared in this scope
   12 | cin>>n;
      | ^~~
a.cc:8:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    7 | #include <complex>
  +++ |+#include <iostream>
    8 | using namespace std;
a.cc:27:1: error: 'cout' was not declared in this scope
   27 | cout<<most;
      | ^~~~
a.cc:27:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
using namespace std;
int a[10004];
int main(){
int n,most=0,cra=0;
cin>>n;
for (int i=0;i<n;i++)
  cin>>a[i];
sort (a,a+n);
for (int i=0;i<a[n-1];i++){
for (int j=0;j<n;j++){
if ((a[j] + 1 == i) or (a[j] - 1 == i) or (a[j] == i))
cra++;
}
if (cra > most)
most = cra;
cra=0;
}
cout<<most;
system ("pause");
return 0;
}

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

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

using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)

int mem[100000];

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  memset(&mem, 0, sizeof(mem));
  REP(i, n) {
    int a_in;
    cin >> a_in;
    mem[a_in]++;
  }
  int ans = mem[0] + mem[1];
  FOR(i, 1, 99998) {
    int num = mem[i - 1] + mem[i] + mem[i + 1];
    ans = max(ans, num);
  }
  ans = max(ans, mem[99998] + mem[99999]);
  cout << ans << endl;
  return 0;
}

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

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

using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)

int mem[100000];

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  memset(mem, 0, sizeof(mem));
  REP(i, n) {
    int a_in;
    cin >> a_in;
    mem[a_in]++;
  }
  int ans = mem[0] + mem[1];
  FOR(i, 1, 99998) {
    int num = mem[i - 1] + mem[i] + mem[i + 1];
    ans = max(ans, num);
  }
  ans = max(ans, mem[99998] + mem[99999]);
  cout << ans << endl;
  return 0;
}

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

#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int main() {
	// your code goes here
	int n, cnt=1; cin >> n;
	vector<int> v(n);

	for(int i=0; i<n; i++) {
		cin >> v[i];
		sum += v[i];
	}
	
	sort(v.begin(), v.end());
	
	int m=v[0];
	
	for(int i=0; i<n-1; i++) {
		if(abs(m-v[i]) <= 2 || v[i] == m) cnt++;
		else {
			m = v[i];
			cnt=1;
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

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

#include <iostream>
using namespace std;

int main() {

    int n;
    int a[100000], v[100003] = {0};

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        v[a[i]]++, v[a[i] + 1]++, v[a[i] + 2]++;
    }
    cout << *max_element(v, v + 100003) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:14: error: 'max_element' was not declared in this scope
   14 |     cout << *max_element(v, v + 100003) << endl;
      |              ^~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
//int max(int a,)
int bm(int a[],int n)
{
  int max=0,m,i;
  for(i=0;i<n;i++)
  {
    if(a[i]>max)max=a[i];
  }
  return max;
}
int main()
{
  int n,i,a[100005]={0},x;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>x;
    a[x-1]++;a[x]++;a[x+1]++;
  }
  cout<<bm(a)<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:11: error: too few arguments to function 'int bm(int*, int)'
   22 |   cout<<bm(a)<<endl;
      |         ~~^~~
a.cc:4:5: note: declared here
    4 | int bm(int a[],int n)
      |     ^~
Language: C++

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstring.h>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<map>
#include<set>
#include<sstream>
using namespace std;
int n,a[100010],b[100100],mx=-1;
int main()
{
  	cin>>n;
  	for (int i=0;i<n;i++)
      	cin>>a[i];
  	for (int i=0;i<n;i++){
      	b[a[i]+1]++;
      	b[a[i]]++;
      	b[a[i]-1]++;
    }
  	for (int i=0;i<n;i++)
      	mx=max(b[i],mx);
 	cout<<mx;
  	return 0;
}

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

1#include<iostream>
 2#include<algorithm>
 3#include<functional>
 4using namespace std;
 5int main(){
 6  int N,a[100000],i,b[100000];
 7  cin>>N;
 8  for(i=0;i<N;i++){
 9    cin>>a[i];
10  }
11  for(i=0;i<N;i++){
12    b[a[i]-1]++;
13    b[a[i]]++;
14    b[a[i]+1]++;
15  }
16  sort(b,b+100000,greater<int>());
17  cout<<b[0]<<endl;
18  return 0;
19}




Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | 1#include<iostream>
      |  ^
a.cc:2:3: error: stray '#' in program
    2 |  2#include<algorithm>
      |   ^
a.cc:3:3: error: stray '#' in program
    3 |  3#include<functional>
      |   ^
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 1#include<iostream>
      | ^
a.cc:5:2: error: expected unqualified-id before numeric constant
    5 |  5int main(){
      |  ^~~~
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	map<int,int>ma;
	rep(i,n){
		int a;cin>>a;
		ma[a]++;
	}
	int out=0;
	for(auto a:ma){
		int t=a->first;
		out=max(out,ma[t]+ma[t-1]+ma[t+1]);
	}
	cout<<out<<endl;
}








Compiler output:
a.cc: In function 'int main()':
a.cc:55:24: error: base operand of '->' has non-pointer type 'std::pair<const int, int>'
   55 |                 int t=a->first;
      |                        ^~
Language: C++

#include <bits/stdc++.h>

using namespace std;

map<int, int> score;

int main(){
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(score.count(a[i]) = 0){
      score[a[i]] = 0;
    }
    score[a[i]]++;
    ans = max(ans, score[a[i] - 1] + score[a[i]] + score[a[i] + 1]);
  }
  cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:19: error: lvalue required as left operand of assignment
   13 |     if(score.count(a[i]) = 0){
      |        ~~~~~~~~~~~^~~~~~
Language: C++

//*Sample program for Pointers*/

#include<iostream>
#include<string>


void swap_ref(int &a, int &b) {
  int tmp = a;
  a = b;
  b = tmp;
}

int main()
{
  // 整数の入力
  int n;
  std::cin >> n;
  // スペース区切りの整数の入力
  int a[n];
  for(int i=0;i<n;i++){
    std::cin >> a[i];
    //std::cout << a[i] << std::endl;
  }

  int count[100002];
  for(int i=0;i<100002;i++){
    count[i]=0;
  }

  for(int i=0;i<n;i++){
    count[a[i]] += 1;
    count[a[i]+1] += 1;
    count[a[i]+2] += 1;
  }

  int max = *std::max_element(count, count+100002);
  //int index = distance(a, max);
  std::cout<<max<<std::endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:19: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
   36 |   int max = *std::max_element(count, count+100002);
      |                   ^~~~~~~~~~~
      |                   tuple_element
Language: C

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

int n[100000] = { 0 };

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

int main(void) {
	int N;
	int ans = 1, cnt1 = 1, cnt2 = 0, flag = 1, def = 2;

	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &n[i]);
	qsort(n, N, sizeof(int), sort);

	for (int i = 0; i < N; i++) {
		if (n[i] == n[i + 1]) cnt1++;
		else if ((n[i + 1] - n[i]) <= def) {
			cnt2 = cnt1;
			cnt1++;
			def = def - (n[i + 1] - n[i]);
		}
		else {
			ans = max(ans, cnt1);
			cnt1 = cnt1 - cnt2;
			cnt2 = 0;
			def = 2;
		}
	}

	printf("%d\n", ans);

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:27:31: error: implicit declaration of function 'max'; did you mean 'fmax'? [-Wimplicit-function-declaration]
   27 |                         ans = max(ans, cnt1);
      |                               ^~~
      |                               fmax
Language: C

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,i,k=0,c=0;
    cin >> n;
    int arr[n];
    for(i=0; i<n; i++)cin >> arr[i];
    sort(arr,arr+n);
    for(i=0; i<n; i++)cout << arr[i] << " ";
    for(int j=n-1; j>0; j--)
    {
        int d;
        d=arr[j]-arr[j-1];
        if(d==0)
        {
            c++;
            continue;
        }
        if(d==1)
        {
            c++;
            for(int z=j-2; z>=0; z--)
            {
                int l;
                l=arr[j]-arr[z];
                if(l==1||l==2)c++;
                if(l>2)break;
            }
            //cout << c << " ";
            //cout << c << arr[j] << " ";
        }
        if(c>=k)
        {
            k=c;
            c=0;
        }

    }
    cout << k+1;
    return 0;
}


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