Problem:
Score : 900 points

Problem Statement

There are N pinholes on the xy-plane. The i-th pinhole is located at (x_i,y_i).

We will denote the Manhattan distance between the i-th and j-th pinholes as d(i,j)(=|x_i-x_j|+|y_i-y_j|).

You have a peculiar pair of compasses, called Manhattan Compass.
This instrument always points at two of the pinholes.
The two legs of the compass are indistinguishable, thus we do not distinguish the following two states: the state where the compass points at the p-th and q-th pinholes, and the state where it points at the q-th and p-th pinholes.

When the compass points at the p-th and q-th pinholes and d(p,q)=d(p,r), one of the legs can be moved so that the compass will point at the p-th and r-th pinholes.

Initially, the compass points at the a-th and b-th pinholes.
Find the number of the pairs of pinholes that can be pointed by the compass.

Constraints

2≦N≦10^5

1≦x_i, y_i≦10^9

1≦a < b≦N

When i ≠ j, (x_i, y_i) ≠ (x_j, y_j)

x_i and y_i are integers.

Input

The input is given from Standard Input in the following format:

N a b
x_1 y_1
:
x_N y_N

Output

Print the number of the pairs of pinholes that can be pointed by the compass.

Sample Input 1

5 1 2
1 1
4 3
6 1
5 5
4 8

Sample Output 1

4

Initially, the compass points at the first and second pinholes.

Since d(1,2) = d(1,3), the compass can be moved so that it will point at the first and third pinholes.

Since d(1,3) = d(3,4), the compass can also point at the third and fourth pinholes.

Since d(1,2) = d(2,5), the compass can also point at the second and fifth pinholes.

No other pairs of pinholes can be pointed by the compass, thus the answer is 4.

Sample Input 2

6 2 3
1 3
5 3
3 5
8 4
4 7
2 5

Sample Output 2

4

Sample Input 3

8 1 2
1 5
4 3
8 2
4 7
8 8
3 3
6 6
4 8

Sample Output 3

7

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

struct P {
    int64_t x, y;

    bool operator<(const P& p) const {
        int64_t t1 = x + y;
        int64_t t2 = p.x + p.y;
        return t1 != t2 ? t1 < t2 : x < p.x;
    }
    void rot90() {
        x *= -1;
        swap(x, y);
    }
    void rot270() {
        swap(x, y);
        x *= -1;
    }
};

set<P> sp[2];
vector<P> vp[2];
int64_t d, m;

void dfs(P o) {
    int k[2][2] = { 1, 0, 2, 3, };
    for (int j = 0; j < 2; j++) {
        if (j == 1) o.rot90();
        P r[4] = {
            { o.x + d, o.y },
            { o.x, o.y + d },
            { o.x - d, o.y },
            { o.x, o.y - d },
        };
        if (j == 1) {
            for (int i = 0; i < 4; i++) {
                int s = i % 2 == 0 ? 1 : -1;
                r[k[0][i]].x += s;
                r[k[0][i]].y -= s;
            }
        }
        for (int h = 0; h < 2; h++) {
            auto i0 = lower_bound(vp[j].begin(), vp[j].end(), r[k[h][0]]);
            auto i1 = upper_bound(           i0, vp[j].end(), r[k[h][1]]);
            m += i1 - i0;

            auto i2 = sp[j].lower_bound(r[k[h][0]]);
            auto i3 = sp[j].upper_bound(r[k[h][1]]);
            vector<P> v;
            while (i2 != i3) {
                P p = *i2;
                v.push_back(p);
                sp[j].erase(i2++);
                p.rot90();
                sp[j ^ 1].erase(p);
            }
            for (P& p : v) {
                if (j == 1) p.rot270();
                dfs(p);
            }
        }
    }
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    a--;
    b--;

    vp[0] = vector<P>(n);
    for (int i = 0; i < n; i++) {
        cin >> vp[0][i].x >> vp[0][i].y;
    }
    vp[1] = vp[0];
    for (int i = 0; i < n; i++) {
        vp[1][i].rot90();
    }

    P pa[2] = { vp[0][a], vp[1][a] };
    d = abs(vp[0][a].x - vp[0][b].x) + abs(vp[0][a].y - vp[0][b].y);

    for (int j = 0; j < 2; j++) {
        sort(vp[j].begin(), vp[j].end());
        sp[j] = set<P>(vp[j].begin(), vp[j].end());
        sp[j].erase(pa[j]);
    }
    m = 0;
    dfs(pa[0]);

    cout << m / 2 << endl;

    return 0;
}