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.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC
{ 
	class QuestionE
	{
		public static void Main(string[] args)
		{
			var scanner = new Scanner();

			var n = scanner.Int();

			var topRightt = (0, 0);
			var topLeft = (0, int.MaxValue);
			var bottomRight = (int.MaxValue, 0);
			var bottomLeft = (int.MaxValue, int.MaxValue);

			for (int i = 0; i < n; i++) {
				var (x, y) = scanner.Int2();

				if(i == 0) {
					topRightt = (x, y);
					topLeft = (x, y);
					bottomRight = (x, y);
					bottomLeft = (x, y);
				}

				if(x < bottomLeft.Item1 && y < bottomLeft.Item2) {
					bottomLeft = (x, y);
				}

				if (x < topLeft.Item1 && y > topLeft.Item2) {
					topLeft = (x, y);
				}

				if (x > bottomRight.Item1 && y < bottomRight.Item2) {
					bottomRight = (x, y);
				}

				if (x > topRightt.Item1 && y > topRightt.Item2) {
					topRightt = (x, y);
				}
			}

			var max1 = Math.Abs(topRightt.Item1 - bottomLeft.Item1) + Math.Abs(topRightt.Item2 - bottomLeft.Item2);
			var max2 = Math.Abs(topLeft.Item1 - bottomRight.Item1) + Math.Abs(topLeft.Item2 - bottomRight.Item2);

			Console.WriteLine(Math.Max(max1, max2));
		}

		public class Scanner
		{
			private readonly char[] delimiter_ = new char[] { ' ' };
			private readonly string filePath_;
			private readonly Func<string> reader_;
			private string[] buf_;
			private int index_;

			public Scanner(string file = "")
			{
				if (string.IsNullOrWhiteSpace(file)) {
					reader_ = Console.ReadLine;
				} else {
					filePath_ = file;
					var fs = new StreamReader(file);
					reader_ = fs.ReadLine;
				}
				buf_ = new string[0];
				index_ = 0;
			}

			public string NextLine() => reader_();
			public string Next()
			{
				if (index_ < buf_.Length) {
					return buf_[index_++];
				}

				string st = reader_();
				while (st == "") {
					st = reader_();
				}

				buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
				if (buf_.Length == 0) {
					return Next();
				}

				index_ = 0;
				return buf_[index_++];
			}

			public int Int() => int.Parse(Next());
			public long Long() => long.Parse(Next());
			public double Double() => double.Parse(Next());

			public int[] ArrayInt(int N, int add = 0)
			{
				int[] Array = new int[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Int() + add;
				}
				return Array;
			}

			public long[] ArrayLong(int N, long add = 0)
			{
				long[] Array = new long[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Long() + add;
				}
				return Array;
			}

			public double[] ArrayDouble(int N, double add = 0)
			{
				double[] Array = new double[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Double() + add;
				}
				return Array;
			}

			public (int, int) Int2(int add = 0)
			{
				var array = ArrayInt(2, add);
				return (array[0], array[1]);
			}

			public (int, int, int) Int3(int add = 0)
			{
				var array = ArrayInt(3, add);
				return (array[0], array[1], array[2]);
			}

			public (long, long) Long2(int add = 0)
			{
				var array = ArrayLong(2, add);
				return (array[0], array[1]);
			}

			public (long, long, long) Long3(int add = 0)
			{
				var array = ArrayLong(3, add);
				return (array[0], array[1], array[2]);
			}

			public (double, double) Double2(int add = 0)
			{
				var array = ArrayDouble(2, add);
				return (array[0], array[1]);
			}

			public (double, double, double) Double3(int add = 0)
			{
				var array = ArrayDouble(3, add);
				return (array[0], array[1], array[2]);
			}

			public void Save(string text)
			{
				if (string.IsNullOrWhiteSpace(filePath_)) {
					return;
				}

				File.WriteAllText(filePath_ + "_output.txt", text);
			}
		}
	}
}