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# (.NET Core 3.1.201) (judge verdict: Wrong Answer)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{

    class Program
    {
        public static (long m, long s)[,] dp;
        public static long mod;

        static long power(long a, long b, long modulo)
        {
            long result = 1;
            long buff = a;
            for (int i = 1; i <= b; i *= 2)
            {
                result = result * ((b / i % (2) == 1) ? buff : 1) % modulo;
                buff = (buff * buff) % modulo;
            }
            return result % modulo;
        }
        static long binomal(long n, long r, long modulo)
        {
            long result = 1;
            for (long i = 0; i < r; i++)
            {
                result = (result * (n - i)) % modulo;
                result = (result * power(i + 1, modulo - 2, modulo)) % modulo;
            }
            return result;
        }
        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);

                var vals = Console.ReadLine().Split(' ').
                    Select(x => int.Parse(x)).ToList();

                
                var N = vals[0];
                List<(int x, int y)> A = new List<(int, int)>();
                List<(int x, int y)> B = new List<(int, int)>();
                for (int i = 0; i < N; i++)
                {
                    var v=Console.ReadLine().Split(' ').
                    Select(x => int.Parse(x)).ToList();
                    A.Add((v[0], v[1]));
                    B.Add((v[1], v[0]));
                }
                A.Sort();
                B.Sort();
                var ans = 0;
                foreach (var a in A)
                {
                    var d = Math.Abs(a.x - A[0].x) + Math.Abs(a.y - A[0].y);
                    var d2= Math.Abs(a.x - A[N-1].x) + Math.Abs(a.y - A[N-1].y);
                    var d3= Math.Abs(a.x - B[0].x) + Math.Abs(a.y - B[0].y);
                    var d4 = Math.Abs(a.x - B[N - 1].x) + Math.Abs(a.y - B[N - 1].y);
                    ans = Math.Max(ans, d);
                    ans = Math.Max(ans, d2);
                    ans = Math.Max(ans, d3);
                    ans = Math.Max(ans, d4);
                }

                

                Console.WriteLine(ans);

                Console.Out.Flush();
            }//cheked




        }
        static long gcd(long a, long b)
        {
            long large = Math.Max(a, b);
            long small = Math.Min(a, b);
            while (large % small != 0)
            {
                var S = small;
                small = large % small;
                large = S;
            }
            return small;
        }
    }

}