Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MOD = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 200100;

int N,a,b;
int A[MAXN];
string S;

int main(){
  cin>>N>>S;
  for(int i=1;i<=N;++i){
    A[i]=S[i-1]-'0';
  }
  // detecting if is 2
  vi V;
  for (int i=1;i<=N;++i){
    if (A[i]==V.back().f)++V.back().s;
    else V.pb(A[i],1);
  }
  if (SZ(V)==2){
    if (abs(V[0]-V[1]) ==2){
      cout<<2;
      return 0;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: request for member 'first' in 'V.std::vector<int>::back()', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   14 | #define f first
      |           ^~~~~
a.cc:32:24: note: in expansion of macro 'f'
   32 |     if (A[i]==V.back().f)++V.back().s;
      |                        ^
a.cc:15:11: error: request for member 'second' in 'V.std::vector<int>::back()', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   15 | #define s second
      |           ^~~~~~
a.cc:32:37: note: in expansion of macro 's'
   32 |     if (A[i]==V.back().f)++V.back().s;
      |                                     ^
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = int; _Args = {int&, int}; _Tp = int]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = int; _Args = {int&, int}; _Tp = int; allocator_type = std::allocator<int>]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int}; _Tp = int; _Alloc = std::allocator<int>; reference = int&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:33:14:   required from here
   33 |     else V.pb(A[i],1);
      |          ~~~~^~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: new initializer expression list treated as compound expression [-fpermissive]
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~