Language: C++

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS;
 
template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}
 
// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)
 
int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 1, Max = -1, Min = 3e9+1;
  string s;
  bool ok=true;
  cin >> n;
  VL a(100000,0);
  rep(i,n){
    cin >> m;
    a[m]++;
  }
  for(int i=1; i<100000-1; i++){
    chmax(Max,a[i-1]+a[i]+a[i+1]);
  }
  pri(Max);
  return 0;
}
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 1, Max = -1, Min = 3e9+1;
  string s;
  bool ok=true;
  cin >> n;
  VL a(n+1,0);
  rep(i,n){
    cin >> m;
    a[m]++;
  }
  for(int i=1; i<100000-1; i++){
    chmax(Max,a[i-1]+a[i]+a[i+1]);
  }
  pri(Max);
  return 0;
}

Compiler output:
a.cc:78:17: error: redefinition of 'const long long int mod'
   78 | const long long mod = 1e9 + 7;
      |                 ^~~
a.cc:10:17: note: 'const long long int mod' previously defined here
   10 | const long long mod = 1e9 + 7;
      |                 ^~~
a.cc:94:6: error: redefinition of 'template<class T, class U> bool chmax(T&, U)'
   94 | bool chmax(T &a, U b) {
      |      ^~~~~
a.cc:26:6: note: 'template<class T, class U> bool chmax(T&, U)' previously declared here
   26 | bool chmax(T &a, U b) {
      |      ^~~~~
a.cc:102:6: error: redefinition of 'template<class T, class U> bool chmin(T&, U)'
  102 | bool chmin(T &a, U b) {
      |      ^~~~~
a.cc:34:6: note: 'template<class T, class U> bool chmin(T&, U)' previously declared here
   34 | bool chmin(T &a, U b) {
      |      ^~~~~
a.cc:110:10: error: redefinition of 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<_Tp>&)'
  110 | ostream &operator<<(ostream &os, vector<T> &v) {
      |          ^~~~~~~~
a.cc:42:10: note: 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<_Tp>&)' previously declared here
   42 | ostream &operator<<(ostream &os, vector<T> &v) {
      |          ^~~~~~~~
a.cc:121:5: error: redefinition of 'int main()'
  121 | int main() {
      |     ^~~~
a.cc:53:5: note: 'int main()' previously defined here
   53 | int main() {
      |     ^~~~