Language: C++

#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long lli;
lli n,a,b;
vector<pair<lli,lli> > c;
map<pair<lli,lli>,lli> cx;
map<pair<lli,lli>,lli> cy;
vector<pair<lli,lli> > k;
lli d;
vector<lli> counter;
lli ans = 0;

void dfs(lli x){
    pair<lli,lli> o = c[x];
    cx.erase(o);cy.erase(make_pair(o.second,o.first*-1));
    ans += counter[x];
    while(cx.lower_bound(make_pair(o.first-d,o.second-d)) != cx.upper_bound(make_pair(o.first-d,o.second+d-1))){
        dfs(cx.lower_bound(make_pair(o.first-d,o.second-d))->second);
    }
    while(cx.lower_bound(make_pair(o.first+d,o.second-d+1)) != cx.upper_bound(make_pair(o.first+d,o.second+d))){
        dfs(cx.lower_bound(make_pair(o.first+d,o.second-d+1))->second);
    }
    swap(o.first,o.second);o.second*=-1;
    while(cy.lower_bound(make_pair(o.first-d,o.second-d)) != cy.upper_bound(make_pair(o.first-d,o.second+d-1))){
        dfs(cy.lower_bound(make_pair(o.first-d,o.second-d))->second);
    }
    while(cy.lower_bound(make_pair(o.first+d,o.second-d+1)) != cy.upper_bound(make_pair(o.first+d,o.second+d))){
        dfs(cy.lower_bound(make_pair(o.first+d,o.second-d+1))->second);
    }
}
int main(int argc, char const *argv[]) {
    cin >> n >> a >> b;
    c = vector<pair<lli,lli> > (n);
    for(lli i = 0;i < n;i++){
        lli x,y;
        cin >> x >> y;
        c[i].first = x + y;
        c[i].second = x - y;
        cx[c[i]] = i;
        cy[make_pair(c[i].second,c[i].first*-1)] = i;
    }
    a--;b--;
    d = max(abs(c[a].first - c[b].first),abs(c[a].second - c[b].second));
    counter = vector<lli> (n);
    k = c;
    sort(k.begin(),k.end());
    for(lli i = 0;i < n;i++){
        lli t = cx[k[i]];
        counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second-d)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second+d-1));
        counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first+d,k[i].second-d+1)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first+d,k[i].second+d));
    }
    for(lli i = 0;i < n;i++) swap(k[i].first,k[i].second),k[i].second*=-1;
    sort(k.begin(),k.end());
    for(lli i = 0;i < n;i++){
        lli t = cy[k[i]];
        counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second-d)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second+d-1));
        counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first+d,k[i].second-d+1)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first+d,k[i].second+d));
    }
    dfs(a);
    cout << -ans/2 << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:48:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   48 |     sort(k.begin(),k.end());
      |     ^~~~
      |     short
a.cc:51:94: error: 'upper_bound' was not declared in this scope
   51 |         counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second-d)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second+d-1));
      |                                                                                              ^~~~~~~~~~~
a.cc:58:94: error: 'upper_bound' was not declared in this scope
   58 |         counter[t] += lower_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second-d)) - upper_bound(k.begin(),k.end(),make_pair(k[i].first-d,k[i].second+d-1));
      |                                                                                              ^~~~~~~~~~~