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 Rust (1.15.1) (judge verdict: Wrong Answer)

// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

// 未verify

trait Monoid {
    fn unity() -> Self;
    fn op(&self, &Self) -> Self;
}

#[derive(Clone, Debug)]
struct SegmentTree<T: Monoid + std::clone::Clone> {
    dat: Vec<T>,
    length: usize,
}

impl<T: Monoid + std::clone::Clone> SegmentTree<T> {
    fn new(n: usize) -> SegmentTree<T> {
        let mut len = 1;
        while len < n {
            len <<= 1;
        }
        SegmentTree {
            dat: vec![T::unity(); len*2],
            length: n,
        }
    }

    fn len(&self) -> usize {
        self.length
    }

    fn update(&mut self, i: usize, val: T) {
        assert!(i < self.len());
        let mut p = self.dat.len()/2-1+i;
        self.dat[p] = val;
        while p != 0 {
            p = (p-1)/2;
            self.dat[p] = self.dat[2*p+1].op(&self.dat[2*p+2]);
        }
    }

    fn query(&self, l: usize, r: usize) -> T {
        self.query_(l, r, 0, 0, self.dat.len()/2)
    }

    fn get(&self, ind: usize) -> T {
        self.dat[self.dat.len()/2+ind-1].clone()
    }

    fn query_(&self, l: usize, r: usize, i: usize, a: usize, b: usize) -> T {
        if l <= a && b <= r {
            self.dat[i].clone()
        } else if !(r <= a || b <= l) {
            let retl = self.query_(l, r, i*2+1, a, (a+b)/2);
            let retr = self.query_(l, r, i*2+2, (a+b)/2, b);
            retl.op(&retr)
        } else {
            T::unity()
        }
    }

    // fn debug(&self) {
    //     printvec(&self.dat);
    // }
}

impl Monoid for bool {
    fn unity() -> Self {
        false
    }

    fn op(&self, rhs: &Self) -> Self {
        *self || *rhs
    }
}

trait BinarySearch {
    type E;
    fn lower_bound(&self, &(Self::E)) -> usize;
    fn upper_bound(&self, &(Self::E)) -> usize;
}

impl<T> BinarySearch for Vec<T>
where T: std::cmp::Ord {
    type E = T;
    fn lower_bound(&self, e: &(Self::E)) -> usize {
         match self.binary_search(e) {
             Ok(p) => p,
             Err(p) => p,
         }
    }
    fn upper_bound(&self, e: &(Self::E)) -> usize {
        match self.binary_search(e) {
            Ok(p) => p+1,
            Err(p) => p,
        }
    }
}

fn reachable(c: usize) -> Vec<bool> {
    let mut res = Vec::new();
    
    res
}

impl Monoid for i64 {
    fn unity() -> Self {
        0
    }

    fn op(&self, rhs: &Self) -> Self {
        *self + *rhs
    }
}

#[derive(Debug)]
struct Seg<'a> {
    xy: Vec<Vec<i64>>, 
    yx: Vec<Vec<i64>>,
    xs: Vec<i64>,
    ys: Vec<i64>,
    ps: &'a Vec<(i64, i64)>,
    segx: Vec<SegmentTree<i64>>,
    segy: Vec<SegmentTree<i64>>,
}

impl<'a> Seg<'a> {
    fn new(ps: &'a Vec<(i64, i64)>) -> Self {
        let mut xs: Vec<_> = ps.iter().map(|&(x, y)| x).collect();
        xs.sort();
        xs.dedup();
        let xs = xs;
        let mut ys: Vec<_> = ps.iter().map(|&(x, y)| y).collect();
        ys.sort();
        ys.dedup();
        let ys = ys;
        let mut xy = vec![Vec::new(); xs.len()];
        let mut yx = vec![Vec::new(); ys.len()];
        for &(x, y) in ps {
            xy[xs.lower_bound(&x)].push(y);
            yx[ys.lower_bound(&y)].push(x);
        }
        for e in &mut xy {
            e.sort();
        }
        for e in &mut yx {
            e.sort();
        }
        Seg {
            segx: xy.iter().map(|v| SegmentTree::new(v.len())).collect(),
            segy: yx.iter().map(|v| SegmentTree::new(v.len())).collect(),
            xy: xy,
            yx: yx,
            xs: xs,
            ys: ys,
            ps: ps,
        }
    }

    fn count(&self, (x, y): (i64, i64), r: i64) -> i64 {
        let mut res = 0;
        if let Ok(p) = self.xs.binary_search(&(x-r)) {
            res += self.segx[p].query(
                self.xy[p].lower_bound(&(y-r)),
                self.xy[p].upper_bound(&(y+r)),
            );
        }
        if let Ok(p) = self.xs.binary_search(&(x+r)) {
            res += self.segx[p].query(
                self.xy[p].lower_bound(&(y-r)),
                self.xy[p].upper_bound(&(y+r)),
            );
        }
        if let Ok(p) = self.ys.binary_search(&(y-r)) {
            res += self.segy[p].query(
                self.yx[p].lower_bound(&(x-r+1)),
                self.yx[p].upper_bound(&(x+r-1)),
            );
        }
        if let Ok(p) = self.ys.binary_search(&(y+r)) {
            res += self.segy[p].query(
                self.yx[p].lower_bound(&(x-r+1)),
                self.yx[p].upper_bound(&(x+r-1)),
            );
        }
        res
    }

    fn update(&mut self, r: i64) {
    
        for &(x, y) in self.ps {
            if self.count((x, y), r) > 0 {
                self.set((x, y));
            }
        }

        for &(x, y) in self.ps.iter().rev() {
            if self.count((x, y), r) > 0 {
                self.set((x, y));
            }
        }
    }

    fn set(&mut self, (x, y): (i64, i64)) {
        let p = self.xs.lower_bound(&x);
        self.segx[p].update(self.xy[p].binary_search(&y).unwrap(), 1);
        let p = self.ys.lower_bound(&y);
        self.segy[p].update(self.yx[p].binary_search(&x).unwrap(), 1);
    }

    fn print(&self, (x, y): (i64, i64)) {
        let p = self.xs.lower_bound(&x);
        debug!(self.segx[p].get(self.xy[p].binary_search(&y).unwrap()));
        let p = self.ys.lower_bound(&y);
        debug!(self.segy[p].get(self.yx[p].binary_search(&x).unwrap()));
    }
}


fn main() {
    let (n, a, b) = {
        let (n, mut a, mut b) = readl!(usize, usize, usize);
        a -= 1;
        b -= 1;
        (n, a, b)
    };
    let mut ps = Vec::with_capacity(n);
    for _ in 0..n {
        let (x, y) = readl!(i64, i64);
        ps.push((x-y, x+y));
    }
    let r = std::cmp::max((ps[a].0-ps[b].0).abs(), (ps[a].1-ps[b].1).abs());
    let sp = [ps[a], ps[b]];
    let ps = ps;
    let mut seg = Seg::new(&ps);
    // debug!(ps);
    // debug!(seg.xs);
    // debug!(seg.ys);
    // debug!(seg.xy);
    // debug!(seg.yx);
    
    for &e in &sp {
        seg.set(e);
    }
    seg.update(r);
    // debug!(seg);
    // for &e in &ps {
    //     debug!(e);
    //     debug!(seg.count(e, r));
    // }

    let mut ans = 0;
    for &e in ps.iter() {
        ans += seg.count(e, r);
    }
    println!("{}", ans/2);

}