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 C (GCC 9.2.1) (judge verdict: Wrong Answer)

#include<unistd.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<stdint.h>
#include<time.h>
#include<tgmath.h>
inline long max(long a, long b){return a>b?a:b;}
inline long min(long a, long b){return a>b?b:a;}
long gcd(long a, long b){return b?gcd(b, a%b):a;}

//fast(?) Input
#define buf_sz 1<<24
char buf[buf_sz];
unsigned int nextint(){
	static int idx = 0;
	if(idx == 0)read(0, buf, buf_sz);
	unsigned int res = 0;
	while(idx<buf_sz && buf[idx]<'0' || '9'<buf[idx])idx++;
	while(idx<buf_sz && '0'<=buf[idx] && buf[idx]<='9'){
		res *= 10;
		res += buf[idx++] - '0';
	}if(idx>=buf_sz)exit(1);
	return res;
}

const long mod = 1e9 + 7;
long modpow(long x, long y, long m){
    long res = 1, tmp = x;
    while(y){
        if(y&1) res = res * tmp % m;
        tmp = tmp * tmp % m;
        y >>= 1;
    }
    return res;
}
long pom(long x, long y){return modpow(x, y, mod);}
long COM(long x, long y){
    if(x < y) return 0;
    if(x < 0 || y < 0) return 0;
    long res = 1;
    for(int i=0; i<y; i++){
        res = res * (x-i) % mod * pom(y-i, mod-2) % mod;
    }
    return res;
}
int main(){
	int N = nextint();
	long maxi[2] = {}, mini[2] = {1<<40, 1<<40};
	for(int i=0; i<N; i++){
		long x = nextint();
		long y = nextint();
		maxi[0] = max(maxi[0], x-y);
		maxi[1] = max(maxi[1], x+y);
		mini[0] = min(mini[0], x-y);
		mini[1] = min(mini[1], x+y);
	}
	printf("%ld\n", max(maxi[0]-mini[0], maxi[1]-mini[1]));
	return 0;
}