Language: C++

#include <iostream>
#include <map>
#include <set>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

const int inf = 1e6;

int n, a, b;
int x[100000];
int y[100000];
int d;
int c[100000];
map<int, set<P>> p, q;
map<int, vector<int>> f, g;
int u[100000];

vector<int>::iterator lb(vector<int>& v, int x){
  return lower_bound(v.begin(), v.end(), x);
}
vector<int>::iterator ub(vector<int>& v, int x){
  return upper_bound(v.begin(), v.end(), x);
}

void dfsall(set<P>::iterator b, set<P>::iterator a);
void dfs(int i){
  u[i] = 1;
  p[x[i]].erase(p[x[i]].lower_bound(P(y[i], -inf)), p[x[i]].upper_bound(P(y[i], inf)));
  q[y[i]].erase(q[y[i]].lower_bound(P(x[i], -inf)), q[y[i]].upper_bound(P(x[i], inf)));

  dfsall(p[x[i] - d].upper_bound(P(y[i] + d, inf)), p[x[i] - d].lower_bound(P(y[i] - d, -inf)));
  dfsall(p[x[i] + d].upper_bound(P(y[i] + d, inf)), p[x[i] + d].lower_bound(P(y[i] - d, -inf)));
  dfsall(q[y[i] - d].lower_bound(P(x[i] + d, -inf)), q[y[i] - d].upper_bound(P(x[i] - d, inf)));
  dfsall(q[y[i] + d].lower_bound(P(x[i] + d, -inf)), q[y[i] + d].upper_bound(P(x[i] - d, inf)));
}
void dfsall(set<P>::iterator b, set<P>::iterator a){
  vector<P> v(a, b);
  for(P& x: v){
    dfs(x.second);
  }
}

int main(){
  cin >> n >> a >> b;
  --a;
  --b;
  rep(i, n){
    int p, q;
    cin >> p >> q;
    x[i] = p - q;
    y[i] = p + q;
  }
  d = max(abs(x[a] - x[b]), abs(y[a] - y[b]));
  rep(i, n){
    p[x[i]].insert(P(y[i], i));
    q[y[i]].insert(P(x[i], i));
    f[x[i]].push_back(y[i]);
    g[y[i]].push_back(x[i]);
  }
  for(auto& v: f){
    sort(v.second.begin(), v.second.end());
  }
  for(auto& v: g){
    sort(v.second.begin(), v.second.end());
  }
  rep(i, n){
    c[i] += ub(f[x[i] - d], y[i] + d) - lb(f[x[i] - d], y[i] - d);
    c[i] += ub(f[x[i] + d], y[i] + d) - lb(f[x[i] + d], y[i] - d);
    c[i] += lb(g[y[i] - d], x[i] + d) - ub(g[y[i] - d], x[i] - d);
    c[i] += lb(g[y[i] + d], x[i] + d) - ub(g[y[i] + d], x[i] - d);
  }
  dfs(a);
  ll ans = 0;
  rep(i, n){
    if(u[i]){
      ans += c[i];
    }
  }
  cout << ans / 2 << endl;
  return 0;
}

Compiler output:
a.cc:21:10: error: 'vector' was not declared in this scope
   21 | map<int, vector<int>> f, g;
      |          ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include <algorithm>
  +++ |+#include <vector>
    5 | 
a.cc:21:20: error: template argument 2 is invalid
   21 | map<int, vector<int>> f, g;
      |                    ^~
a.cc:21:20: error: template argument 4 is invalid
a.cc:24:1: error: 'vector' does not name a type
   24 | vector<int>::iterator lb(vector<int>& v, int x){
      | ^~~~~~
a.cc:27:1: error: 'vector' does not name a type
   27 | vector<int>::iterator ub(vector<int>& v, int x){
      | ^~~~~~
a.cc: In function 'void dfsall(std::set<std::pair<int, int> >::iterator, std::set<std::pair<int, int> >::iterator)':
a.cc:43:3: error: 'vector' was not declared in this scope
   43 |   vector<P> v(a, b);
      |   ^~~~~~
a.cc:43:3: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:43:11: error: expected primary-expression before '>' token
   43 |   vector<P> v(a, b);
      |           ^
a.cc:43:13: error: 'v' was not declared in this scope
   43 |   vector<P> v(a, b);
      |             ^
a.cc: In function 'int main()':
a.cc:63:6: error: invalid types 'int[int]' for array subscript
   63 |     f[x[i]].push_back(y[i]);
      |      ^
a.cc:64:6: error: invalid types 'int[int]' for array subscript
   64 |     g[y[i]].push_back(x[i]);
      |      ^
a.cc:66:16: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   66 |   for(auto& v: f){
      |                ^
      |                std::begin
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:66:16: error: 'end' was not declared in this scope; did you mean 'std::end'?
   66 |   for(auto& v: f){
      |                ^
      |                std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
a.cc:69:16: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   69 |   for(auto& v: g){
      |                ^
      |                std::begin
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:69:16: error: 'end' was not declared in this scope; did you mean 'std::end'?
   69 |   for(auto& v: g){
      |                ^
      |                std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
a.cc:73:17: error: invalid types 'int[int]' for array subscript
   73 |     c[i] += ub(f[x[i] - d], y[i] + d) - lb(f[x[i] - d], y[i] - d);
      |                 ^
a.cc:73:13: error: 'ub' was not declared in this scope; did you mean 'u'?
   73 |     c[i] += ub(f[x[i] - d], y[i] + d) - lb(f[x[i] - d], y[i] - d);
      |             ^~
      |             u
a.cc:73:45: error: invalid types 'int[int]' for array subscript
   73 |     c[i] += ub(f[x[i] - d], y[i] + d) - lb(f[x[i] - d], y[i] - d);
      |                                             ^
a.cc:73:41: error: 'lb' was not declared in this scope; did you mean 'll'?
   73 |     c[i] += ub(f[x[i] - d], y[i] + d) - lb(f[x[i] - d], y[i] - d);
      |                                         ^~
      |                                         ll
a.cc:74:17: error: invalid types 'int[int]' for array subscript
   74 |     c[i] += ub(f[x[i] + d], y[i] + d) - lb(f[x[i] + d], y[i] - d);
      |                 ^
a.cc:74:45: error: invalid types 'int[int]' for array subscript
   74 |     c[i] += ub(f[x[i] + d], y[i] + d) - lb(f[x[i] + d], y[i] - d);
      |                                             ^
a.cc:75:17: error: invalid types 'int[int]' for array subscript
   75 |     c[i] += lb(g[y[i] - d], x[i] + d) - ub(g[y[i] - d], x[i] - d);
      |                 ^
a.cc:75:45: error: invalid types 'int[int]' for array subscript
   75 |     c[i] += lb(g[y[i] - d], x[i] + d) - ub(g[y[i] - d], x[i] - d);
      |                                             ^
a.cc:76:17: error: invalid types 'int[int]' for array subscript
   76 |     c[i] += lb(g[y[i] + d], x[i] + d) - ub(g[y[i] + d], x[i] - d);
      |                 ^
a.cc:76:45: error: invalid types 'int[int]' for array subscript
   76 |     c[i] += lb(g[y[i] + d], x[i] + d) - ub(g[y[i] + d], x[i] - d);
      |                                             ^