Problem:
Score : 500 points

Problem Statement

There are N points on the 2D plane, i-th of which is located on (x_i, y_i).
There can be multiple points that share the same coordinate.
What is the maximum possible Manhattan distance between two distinct points?

Here, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.

Constraints

2 \leq N \leq 2 \times 10^5

1 \leq x_i,y_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
x_2 y_2
:
x_N y_N

Output

Print the answer.

Sample Input 1

3
1 1
2 4
3 2

Sample Output 1

4

The Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.

Sample Input 2

2
1 1
1 1

Sample Output 2

0

Solution in Rust (1.42.0) (judge verdict: Wrong Answer)

#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:[(isize,isize);a],
    }
    let mut c:(isize, isize)=(b[0].0,b[0].1);
    let mut d:(isize, isize)=(b[0].0,b[0].1);
    let mut e:(isize, isize)=(b[0].0,b[0].1);
    let mut f:(isize, isize)=(b[0].0,b[0].1);
    let mut g:(isize, isize)=(99999999999, 99999999999);
    for i in 0..a {
        if (b[i].0).abs()+(b[i].1).abs()< (g.0).abs() + (g.1).abs() {
            g.0=b[i].0;
            g.1=b[i].1;
        }
        if 0<=b[i].0&&0<=b[i].1&&(b[i].0).abs()+(b[i].1).abs()>(c.0).abs()+(c.1).abs(){
            c.0=b[i].0;
            c.1=b[i].1;
        }
        else if 0<=b[i].0&&0>=b[i].1&&(b[i].0).abs()+(b[i].1).abs()>(d.0).abs()+(d.1).abs(){
            d.0=b[i].0;
            d.1=b[i].1;
        }
        else if 0>=b[i].0&&0>=b[i].1&&(b[i].0).abs()+(b[i].1).abs()>(e.0).abs()+(e.1).abs(){
            e.0=b[i].0;
            e.1=b[i].1;
        }
        else if 0>=b[i].0&&0<=b[i].1&&(b[i].0).abs()+(b[i].1).abs()>(f.0).abs()+(f.1).abs(){
            f.0=b[i].0;
            f.1=b[i].1;
        }
    }
    println!("{}",max(max(max((g.0-c.0).abs()+(g.1-c.1).abs(),(g.0-d.0).abs()+(g.1-d.1).abs()),max((g.0-e.0).abs()+(g.1-e.1).abs(),(g.0-f.0).abs()+(g.1-f.1).abs())),max(max((d.0-c.0).abs()+(d.1-c.1).abs(),(f.0-c.0).abs()+(f.1-c.1).abs()),max((e.0-c.0).abs()+(e.1-c.1).abs(),max((d.0-e.0).abs()+(d.1-e.1).abs(),max((d.0-f.0).abs()+(d.1-f.1).abs(),(e.0-f.0).abs()+(e.1-f.1).abs()))))))
}