Language: C++

#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#define LL long long
const int maxn = 1e5 + 5;
using namespace std;
inline int read(){
	int x = 0; char ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = (x * 10) + (ch & 15), ch = getchar();
	return x;
}
vector <pair<int, int> > X[maxn], Y[maxn];
set <pair<int, int> > sx[maxn], sy[maxn];
int n, s1, s2, d;
int x[maxn], y[maxn], lx[maxn], ly[maxn], ox[maxn], oy[maxn];
LL ans = 0;
queue <int> q;
bool vis[maxn];
void addx(int l, int f){
	set <pair<int, int> >::iterator it = lower_bound(sx[l].begin(), sx[l].end(), make_pair(oy[f] - d, 0));
	ans += 1ll * (upper_bound(X[l].begin(), X[l].end(), make_pair(oy[f] + d, n)) - lower_bound(X[l].begin(), X[l].end(), make_pair(oy[f] - d, 0)));
	if ((upper_bound(X[l].begin(), X[l].end(), make_pair(oy[f] + d, n)) - 1)->first == oy[f] + d) --ans;
	if ((lower_bound(X[l].begin(), X[l].end(), make_pair(oy[f] - d, 0))) -> first == oy[f] - d) --ans;
	if (it == sx[l].end()) return;
	while (oy[it->second] <= oy[f] + d && it != sx[l].end()){
		if (!vis[it->second]) q.push(it->second), vis[it->second] = 1;
		set <pair<int, int> >::iterator temp = it; ++temp;
		sx[l].erase(it); it = temp;
	}
}
void addy(int c, int f){
	set <pair<int, int> >::iterator it = lower_bound(sy[c].begin(), sy[c].end(), make_pair(ox[f] - d, 0));
	ans += 1ll * (upper_bound(Y[c].begin(), Y[c].end(), make_pair(ox[f] + d, n)) - lower_bound(Y[c].begin(), Y[c].end(), make_pair(ox[f] - d, 0)));
	if (it == sy[c].end()) return;
	while (ox[it->second] <= ox[f] + d && it != sy[c].end()){
		if (!vis[it->second]) q.push(it->second), vis[it->second] = 1;
		set <pair<int, int> >::iterator temp = it; ++temp;
		sy[c].erase(it); it = temp;
	}
}
void bfs(){
	q.push(s1); vis[s1] = 1;
	while (!q.empty()){
		int cur = q.front(); q.pop();
		int l1 = lower_bound(lx + 1, lx + n + 1, ox[cur] - d) - lx;
		int l2 = lower_bound(lx + 1, lx + n + 1, ox[cur] + d) - lx;
		int c1 = lower_bound(ly + 1, ly + n + 1, oy[cur] - d) - ly;
		int c2 = lower_bound(ly + 1, ly + n + 1, oy[cur] + d) - ly;
		bool f1 = (lx[l1] == ox[cur] - d), f2 = (lx[l2] == ox[cur] + d);
		bool f3 = (ly[c1] == oy[cur] - d), f4 = (ly[c2] == oy[cur] + d);
		if (f1) addx(l1, cur);
		if (f2) addx(l2, cur);
		if (f3) addy(c1, cur);
		if (f4) addy(c2, cur);
	}
}
int _abs(int x){
	return x < 0 ? -x : x;
}
int main(){
	scanf("%d%d%d", &n, &s1, &s2);
	for (int a, b, i = 1; i <= n; i++){
		a = read(), b = read();
		x[i] = a - b; y[i] = a + b;
		ox[i] = x[i], oy[i] = y[i];
		lx[i] = x[i], ly[i] = y[i];
	}
	sort(lx + 1, lx + n + 1); sort(ly + 1, ly + n + 1);
	for (int i = 1; i <= n; i++){
		x[i] = lower_bound(lx + 1, lx + n + 1, x[i]) - lx;
		y[i] = lower_bound(ly + 1, ly + n + 1, y[i]) - ly;
		X[x[i]].push_back(make_pair(oy[i], i));
		Y[y[i]].push_back(make_pair(ox[i], i));
		sx[x[i]].insert(make_pair(oy[i], i));
		sy[y[i]].insert(make_pair(ox[i], i));
	}
	for (int i = 1; i <= n; i++) sort(X[i].begin(), X[i].end());
	for (int i = 1; i <= n; i++) sort(Y[i].begin(), Y[i].end());
	d = max(_abs(ox[s1] - ox[s2]), _abs(oy[s1] - oy[s2]));
	bfs();
	printf("%lld\n", ans / 2ll);
	return 0;
}

Compiler output:
a.cc: In function 'int read()':
a.cc:12:17: error: 'isdigit' was not declared in this scope
   12 |         while (!isdigit(ch)) ch = getchar();
      |                 ^~~~~~~
a.cc:13:16: error: 'isdigit' was not declared in this scope
   13 |         while (isdigit(ch)) x = (x * 10) + (ch & 15), ch = getchar();
      |                ^~~~~~~