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 (Python):
import sys
input=sys.stdin.readline

n=int(input())

pointx=[]
pointy=[]
for i in range(n):
    x,y=map(int,input().split())
    pointx.append(x-y)
    pointy.append(x+y)

ans=0
pointx.sort()
pointy.sort()
ans=pointx[-1]-pointx[0]
ans=max(ans,pointy[-1]-pointy[0])

print(ans)

Solution (Python):
N = int(input())
P = []
for i in range(N):
    x,y = map(int,input().split())
    P.append([x,y])
L,R = [],[]
F = 10**9
for a,b in P:
    L.append(a+b)
    R.append(F-b+a)
print(max(max(L)-min(L),max(R)-min(R)))

Solution (Python):
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
import sys
gcd = math.gcd

n = ni()
xpy = []
xmy = []
for i in range(n):
    x,y = ma()
    xpy.append(x+y)
    xmy.append(x-y)
xpy.sort()
xmy.sort()
a1=abs(xpy[0]-xpy[-1])
a2 = abs(xmy[0]-xmy[-1])
print(max(a1,a2))

Solution (Python):
N = int(input())

X = []
Y = []

P = []
Q = []

for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    P.append(x + y)
    Q.append(x - y)

print(max(max(P) - min(P), max(Q) - min(Q)))

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()


da = []
daa = []

for i in range(n):
    x,y = m()

    da.append([x+y,x,y])
    daa.append([x-y,x,y])

da.sort()
daa.sort()

print(max(abs(da[0][0]-da[-1][0]),abs(daa[0][0]-daa[-1][0])))

Solution (Python):
import bisect

n = int(input())
xy = [tuple(map(int, input().split())) for i in range(n)]
xy.sort(key=lambda x: x[0] + x[1])
a = xy[0]
xy.sort(key=lambda x: x[0] - x[1])
b = xy[0]
xy.sort(key=lambda x: -x[0] + x[1])
c = xy[0]
xy.sort(key=lambda x: -x[0] - x[1])
d = xy[0]

def man(a:tuple, b:tuple):
    return abs(a[0]-b[0])+abs(a[1]-b[1])

ans = 0
ans = max(ans, man(a, b))
ans = max(ans, man(a, c))
ans = max(ans, man(a, d))
ans = max(ans, man(b, c))
ans = max(ans, man(b, d))
ans = max(ans, man(d, d))
print(ans)

Solution (Python):
xy = []
xy2 = []

N = int(input())
for i in range(N):
    x, y = map(int, input().split())
    xy.append(x+y)
    xy2.append(x-y)

min_xy = min(xy)
max_xy = max(xy)
min_xy2 = min(xy2)
max_xy2 = max(xy2)

ans = max(max_xy - min_xy, min_xy2 - max_xy2, max_xy2 - min_xy2, min_xy - max_xy)
print(ans)

Solution (Python):

n = int(input())
point_list = []

for i in range(n):
    x, y = map(int, input().split())
    point_list.append([x,y])

max1 = [point_list[0][0] + point_list[0][1], 0]
min1 = [point_list[0][0] + point_list[0][1], 0]
max2 = [point_list[0][0] - point_list[0][1], 0]
min2 = [point_list[0][0] - point_list[0][1], 0]

for i in range(1, n):
    sum1 = point_list[i][0] + point_list[i][1]
    sum2 = point_list[i][0] - point_list[i][1]
    if sum1 > max1[0]:
        max1 = [sum1, i]
    
    if sum1 < min1[0]:
        min1 = [sum1, i]

    if sum2 > max2[0]:
        max2 = [sum2, i]
    
    if sum2 < min2[0]:
        min2 = [sum2, i]
    
man1 = abs(point_list[max1[1]][0]-point_list[min1[1]][0]) + abs(point_list[max1[1]][1]-point_list[min1[1]][1])
man2 = abs(point_list[max2[1]][0]-point_list[min2[1]][0]) + abs(point_list[max2[1]][1]-point_list[min2[1]][1])

ans = max([man1, man2])
print(ans)

Solution (Python):
n=int(input())
ans=[];ans2=[]
for i in range(n):
    a,b=map(int,input().split())
    ans.append(a+b)
    ans2.append(10**9+1-a+b)
print(max( max(ans)-min(ans), max(ans2)-min(ans2)))

Solution (Python):
import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter



input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def fact_and_inv(SIZE):
    inv = [0] * SIZE  
    fac = [0] * SIZE  
    finv = [0] * SIZE  
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def solve():
    n = getN()

    points = [getList() for i in range(n)]

    inf = 10 ** 10

    org = []
    far = []
    for x, y in points:
        org.append(x + y)
        far.append(y + inf-x)

    org.sort()
    far.sort()

    a1 = abs(org[0] - org[-1])
    a2 = abs(far[0] - far[-1])

    ans = max(a1, a2)
    print(ans)

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    
    solve()

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    N = int(input())
    X = set()
    Y = {}
    for _ in range(N):
        x, y = map(int, input().split())
        X.add(x)
        if x not in Y:
            Y[x] = {y}
        else:
            Y[x].add(y)
    X = sorted(list(X))
    NX = len(X)
    for x in X:
        Y[x] = sorted(list(Y[x]))

    ymin = Y[X[0]][0]
    ymax = Y[X[0]][-1]
    ans = 0
    for i in range(1, NX):
        x = X[i]
        dx = X[i] - X[i-1]
        ymin_new = Y[x][0]
        ymax_new = Y[x][-1]
        ans = max(ans, ymax - ymin_new + dx, ymax_new - ymin + dx)
        ymax = max(ymax + dx, ymax_new)
        ymin = min(ymin - dx, ymin_new)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from math import trunc
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n = ni()

ans1 = []
ans2 = []
max_xy = 10**9
for _ in range(n):
    x, y = na()
    ans1.append(x+y)
    ans2.append((max_xy-x)+y)

print(max(max(ans1) - min(ans1), max(ans2) - min(ans2)))

Solution (Python):
import sys
input = sys.stdin.readline

def dist(p1,p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])

points = []
N = int(input())
for i in range(N):
    x, y = map(int, input().split())
    points.append((x,y))

cand = []
for i in (-1,0,1):
    for j in (-1,0,1):
        best = -10 ** 9
        bestP = (0,0)
        for p in points:
            val = i * p[0] + j * p[1]
            if val > best:
                best = val
                bestP = p
        cand.append(bestP)
                
best = 0
for i in cand:
    for p in points:
       best = max(best,dist(i,p))
print(best)

Solution (Python):
def main():
    import sys
    N=int(sys.stdin.readline())

    xpy=[]
    xmy=[]

    for i in range(N):
        x,y=list(map(int,sys.stdin.readline().split()))
        xpy.append(x+y)
        xmy.append(x-y)

    t1=max(xpy)-min(xpy)
    t2=max(xmy)-min(xmy)

    print(max(t1,t2))

main()

Solution (Python):



N = int(input())
XY= [list(map(int, input().split())) for _ in range(N)]

pmaxint = -10**10
pminint = 10**10
mmaxint = -10**10
mminint = 10**10

for x, y in XY:
    t1 = x + y
    t2 = x - y
    if t1 > pmaxint:
        pmaxint = t1
    if t1 < pminint:
        pminint = t1
    
    if t2 > mmaxint:
        mmaxint = t2
    if t2 < mminint:
        mminint = t2

print(max(abs(pmaxint - pminint), abs(mmaxint - mminint)))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
data = list(map(int,read().split()))

inf = 10**15
axis_p_max = -1 * inf
axis_p_min = inf
axis_m_max = -1 * inf
axis_m_min = inf

it = iter(data)
for x,y in zip(it,it):
    axis_p_max = max(axis_p_max, x+y)
    axis_p_min = min(axis_p_min, x+y)
    axis_m_max = max(axis_m_max, x-y)
    axis_m_min = min(axis_m_min, x-y)

ans = max(axis_p_max-axis_p_min, axis_m_max-axis_m_min)
print(ans)

Solution (Python):
def func(x, y):
    res, n = 0, len(x)
    for p, q in [[1, 1], [1, -1], [-1, 1], [-1, -1]]:
        smallest = p * x[0] + q * y[0] + 0
        for i in range(n):
            cur = p * x[i] + q * y[i]
            res = max(res, cur - smallest)
            smallest = min(smallest, cur)
    return res

n = int(input())
x,y = [],[]
for i in range(n):
    a,b = list(map(int,input().split()))
    x.append(a)
    y.append(b)
print(func(x,y))

Solution (Python):
sumi=[]
diff=[]
t=int(input())
for _ in range(t):
  z=list(map(int,input().split()))
  sumi.append(z[0]+z[1])
  diff.append(z[0]-z[1])
print (max(max(diff)-min(diff),max(sumi)-min(sumi)))

Solution (Python):

n = int(input())

l1 = []
l2 = []

for i in range(n):
    x1,y1 = map(int,input().split())
    l1.append(x1-y1)
    l2.append(x1+y1)

l1 = sorted(l1)
l2 = sorted(l2)
a = l1[-1]
b = l1[0]
c = l2[-1]
d = l2[0]
ans = max(a-b, c-d)
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]

xy.sort()

xy2 = [(x-y,x+y) for x,y in xy]

xd, yd = zip(*xy2)

dx = max(xd) - min(xd)
dy = max(yd) - min(yd)
print(max(dx,dy))

Solution (Python):
n = int(input())
s = [list(map(int, input().split())) for _ in range(n)]
ans = 0
ma1, mi1 = -10000000000, 10000000000
ma2, mi2 = -10000000000, 10000000000
for i in range(n):
    x = s[i][0] + s[i][1]
    y = s[i][0] - s[i][1]
    ma1 = max(ma1, x)
    mi1 = min(mi1, x)
    ma2 = max(ma2, y)
    mi2 = min(mi2, y)
    ans = max(ans, ma1 - mi1, ma2 - mi2)
print(ans)

Solution (Python):
n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]

xy1 = []
xy2 = []

for x,y in xy:
    xy1.append(x+y)
    xy2.append(x-y)

xy1.sort()
xy2.sort()

print(max(xy1[-1] - xy1[0], xy2[-1] - xy2[0]))

Solution (Python):
n=int(input())
p=[]
m=[]

for i in range(n):
    x,y=list(map(int,input().split()))
    p.append(x+y)
    m.append(x-y)

minp=min(p)
maxp=max(p)
minm=min(m)
maxm=max(m)

ans=[maxp-minp,maxm-minm,minm,maxm,minp-maxp]
print(max(ans))

Solution (Python):
num = int(input())
sumList = [0] * num
minusList = [0] * num
for id in range(num):
    x, y = map(int, input().split())
    sumList[id-1] = x + y
    minusList[id-1] = x - y
sumMax = max(sumList) - min(sumList)
minusMax = max(minusList) - min(minusList)
print(max(sumMax, minusMax))

Solution (Python):
import sys


def f(x, y):
    return x - y, x + y


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    x = [0] * n
    y = [0] * n
    for i in range(n):
        x[i], y[i] = map(int, input().split())
    f0 = [0] * n
    f1 = [0] * n
    for i in range(n):
        f0[i], f1[i] = f(x[i], y[i])
    print(max(max(f0) - min(f0), max(f1) - min(f1)))


if __name__ == "__main__":
    main()

Solution (Python):
from collections import deque
N = int(input())

AM, Am, BM, Bm = -1*10**9*2, 10**9*2, -1*10**9*2, 10**9*2
for _ in range(N):
    x, y = map(int, input().split())
    AM = max(AM, x+y)
    Am = min(Am, x+y)
    BM = max(BM, x-y)
    Bm = min(Bm, x-y)


print(max(AM-Am, BM-Bm))

Solution (Python):
N = int(input())
xpy = [0]*N
xmy = [0]*N
for i in range(N):
  x,y = map(int, input().split())
  xpy[i] = x+y
  xmy[i] = x-y
xpy.sort()
xmy.sort()
print(max(xpy[-1]-xpy[0],xmy[-1]-xmy[0]))

Solution (Python):


import os,sys
from io import BytesIO, IOBase

def main():
    n = int(input())
    maxi_pl = 0
    mini_pl = 10**10
    maxi_mi = -10**10
    mini_mi = 10**10
    for _ in range(n):
        x,y = map(int,input().split())
        maxi_pl = max(maxi_pl,x+y)
        mini_pl = min(mini_pl,x+y)
        maxi_mi = max(maxi_mi,x-y)
        mini_mi = min(mini_mi,x-y)
    print(max(maxi_pl-mini_pl,maxi_mi-mini_mi))


BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())

a, b = map(int, input().split())
mini = a+b
maxi = a+b

mini1 = a-b
maxi1 = a-b

for i in range(n-1):
    a, b = map(int, input().split())
    
    mini = min(a+b, mini)
    maxi = max(a+b, maxi)
    mini1 = min(a-b, mini1)
    maxi1 = max(a-b, maxi1)
    
ans = max(maxi-mini, maxi1-mini1)
print(ans)

Solution (Python):
n=int(input())

ans=[]
ans1=[]

for _ in range(n):
  a,b=map(int,input().split())
  d=a-b
  c=a+b
  ans.append(c)
  ans1.append(d)
  
m=min(ans)
M=max(ans)

P=M-m
Q=max(ans1)-min(ans1)

print(max(P,Q))

Solution (Python):
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]
L_1 = [l[0]+l[1] for l in L]
L_2 = [(10**9+1-l[0])+l[1] for l in L]
L_3 = [(10**9+1-l[1])+l[0] for l in L]
L_4 = [(10**9+1-l[0])+(10**9+1-l[1]) for l in L]
L_1.sort()
a = L_1[-1]-L_1[0]
L_2.sort()
b = L_2[-1]-L_2[0]
L_3.sort()
c = L_3[-1]-L_3[0]
L_4.sort()
d = L_4[-1]-L_4[0]
print(max(a,b,c,d))

Solution (Python):


import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union


























from operator import itemgetter              




def main():
    Num = Union[int, float]
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    
    
    
    n = ii()
    L = []
    for _ in range(n):
        x, y = mi()
        L.append((x - y, x + y))
    
    candidate = []
    for d in range(2):
        M = max(map(lambda x: x[d], L))
        m = min(map(lambda x: x[d], L))
        candidate.append(M - m)

    print(max(candidate))


if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    X = [] 
    Y = [] 
    for i in range(N):
        x,y=mi()
        X.append(x+y)
        Y.append(x-y)
    
    X.sort()
    Y.sort()
    ans = max(X[-1]-X[0],Y[-1]-Y[0])

    print(ans)







if __name__ == "__main__":
    main()

Solution (Python):
import sys
import io, os
input = sys.stdin.buffer.readline

n = int(input())

Z = [0]*n
W = [0]*n
for i in range(n):
    x, y = map(int, input().split())
    
    Z[i] = x+y
    W[i] = x-y

Z.sort()
W.sort()


maxz = Z[-1]-Z[0]
maxw = W[-1]-W[0]
ans = max(maxw, maxz)
print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n=I()

A1=[]
A2=[]
for i in range(n):
    x,y=LI()
    A1+=[x+y]
    A2+=[x-y]

ans=max(max(A1)-min(A1),max(A2)-min(A2))
print(ans)

Solution (Python):
n=int(input())
num=[list(map(int,input().split())) for _ in range(n)]
n1=[]
num1=10**9
ans=0
for i in range(n):
    n1.append(num[i][0]+num[i][1])
ans=max(ans,max(n1)-min(n1))
n1=[]
for i in range(n):
    n1.append(num1-num[i][0]+num[i][1])
ans=max(ans,max(n1)-min(n1))
print(ans)

Solution (Python):


import sys
input=sys.stdin.readline

def main():
    N = int(input())
    R = [tuple(map(int, input().split())) for i in range(N)]
    A = sorted(R, key = lambda x: x[0] + x[1])
    B = sorted(R, key = lambda x: x[0] - x[1])
    a = abs(A[-1][0] - A[0][0]) + abs(A[-1][1] - A[0][1])
    b = abs(B[-1][0] - B[0][0]) + abs(B[-1][1] - B[0][1])
    print(max(a, b))
    
    
    
if __name__=="__main__":
    main()

Solution (Python):
N = int(input())

p = [0] * N
m = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    p[i] = x + y
    m[i] = x - y

pm = max(p) - min(p)
mm = max(m) - min(m)

print(max(pm, mm))

Solution (Python):
def main():
    n = int(input())
    xy = [list(map(int, input().split())) for _ in [0]*n]
    z1 = [x+y for x, y in xy]
    z2 = [x-y for x, y in xy]
    z3 = [-x+y for x, y in xy]
    z4 = [-x-y for x, y in xy]
    print(max([max(z1)-min(z1), max(z2)-min(z2),
               max(z3)-min(z3), max(z4)-min(z4)]))


main()

Solution (Python):
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
d1, d2, d3, d4 = [[] for _ in range(4)]
for a, b in xy:
    d1.append(a + b)
    d2.append(a - b)
    d3.append(-a + b)
    d4.append(-a - b)
ans = 0
for d in d1, d2, d3, d4:
    ans = max(ans, max(d) - min(d))
print(ans)

Solution (Python):
n=int(input())

xy=[[int(_) for _ in input().split()]for i in range(n)]

print(max(max([a[0]+a[1] for  a in xy])-min([a[0]+a[1] for  a in xy]),max([a[0]-a[1] for  a in xy])-min([a[0]-a[1] for  a in xy])))

Solution (Python):
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

ans1 = []
ans2 = []
for i in range(n):
    x, y = info[i]
    ans1.append(x + y)
    ans2.append(x - y)
    
ans1 = sorted(ans1)
ans2 = sorted(ans2)
ans = max(abs(ans1[0] - ans1[-1]), abs(ans2[0] - ans2[-1]))
print(ans)

Solution (Python):

import os,sys
from io import BytesIO, IOBase


def maxAbsValExpr(arr1,arr2) :
    minX, maxX = min(arr1), max(arr1)
    minY, maxY = min(arr2), max(arr2)

    ans = 0
    for point in [(minX, minY), (maxX, minY), (minX, maxY), (maxX, maxY)]:
        minD = float('inf')
        maxD = float('-inf')
        for i in range(0, len(arr1)):
            distance = abs(arr1[i] - point[0]) + abs(arr2[i] - point[1])
            minD = min(minD, distance)
            maxD = max(maxD, distance)
        ans = max(ans, maxD - minD)
    return ans
def main():
    x=[]
    y=[]
    for i in range(int(input())):

        a,b =map(int,input().split())
        x.append(a)
        y.append(b)
    print(maxAbsValExpr(x,y))
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Solution (Python):
def sep():
    return map(int,input().strip().split(" "))
import sys
sys.setrecursionlimit(2*10**5)
from random import randint
def lis():
    return list(sep())

def maxAbsValExpr(x, y):
    res, n = 0, len(y)
    for p, q in [ [-1, 1], [-1, -1],[1, 1], [1, -1]]:
        smallest = p * x[0] + q * y[0] + 0
        for i in range(n):
            cur =   q * y[i] + p * x[i]
            res = max(res, cur - smallest)
            smallest = min(smallest, cur)
    return res
n=int(input())
x=[]
y=[]
for _ in range(n):
    a,b=sep()
    x.append(a)
    y.append(b)
print(maxAbsValExpr(x,y))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



def dist(A, B):
	return abs(A[0]-B[0]) + abs(A[1]-B[1])

N = INT()
xy = [LIST()+[i] for i in range(N)]

xy1 = [[xy[i][0]+xy[i][1], i] for i in range(N)]
xy1.sort(key=lambda x:x[0])
idx_a = xy1[0][1]
idx_b = xy1[-1][1]
a = xy[idx_a]
b = xy[idx_b]

xy2 = [[-xy[i][0]+xy[i][1], i] for i in range(N)]
xy2.sort(key=lambda x:x[0])
idx_c = xy2[0][1]
idx_d = xy2[-1][1]
c = xy[idx_c]
d = xy[idx_d]

print(max(dist(a, b), dist(a, c), dist(a, d), dist(b, c), dist(b, d), dist(c, d)))

Solution (Python):
import sys
input = sys.stdin.buffer.readline

INF = 10**18

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

XY.sort()

ans = 0
x0, y0 = XY[0]
m1 =  -x0+y0
m2 = x0+y0
for x, y in XY:
    ans = max(ans, x+m1 - y)
    ans = max(ans, y - (-x+m2))
    m1 = max(m1, -x+y)
    m2 = min(m2, x+y)
print(ans)

Solution (Python):
N = int(input())
coords, minus, plus = [], [], []
for _ in range(N):
    x, y = map(int,input().split())
    coords.append([x,y])
    minus.append(x-y)
    plus.append(x+y)

minus.sort()
plus.sort()

ans = 0
for x, y in coords:
    now_minus, now_plus = x-y, x+y
    ans = max(ans, abs(now_minus-minus[0]), abs(now_minus-minus[-1]))
    ans = max(ans, abs(now_plus-plus[0]), abs(now_plus-plus[-1]))

print(ans)

Solution (Python):
n,*z=map(int,open(0).read().split())
a,b=[],[]
for x,y in zip(*[iter(z)]*2):
    a+=x+y,
    b+=x-y,
print(max(abs(max(a)-min(a)),abs(max(b)-min(b))))

Solution (Python):
n = int(input())

X_min = float("inf")
X_max = -float("inf")
Y_min = float("inf")
Y_max = -float("inf")

for _ in range(n):
    x, y = map(int, input().split())
    X = x - y
    Y = x + y
    X_min = min(X_min, X)
    X_max = max(X_max, X)
    Y_min = min(Y_min, Y)
    Y_max = max(Y_max, Y)

print(max(X_max-X_min, Y_max-Y_min))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

MAX_P = 0
MIN_P = 10 ** 10
MAX_M = -(10 ** 10)
MIN_M = 10 ** 10

for x, y in XY:
    P = x + y
    M = x - y

    MAX_P = max(MAX_P, P)
    MIN_P = min(MIN_P, P)

    MAX_M = max(MAX_M, M)
    MIN_M = min(MIN_M, M)

ans = max(MAX_P - MIN_P, MAX_M - MIN_M)

print(ans)

Solution (Python):
N = int(input())

plus = []
minus = []
for _ in range(N):
    x,y = map(int,input().split())
    plus.append(x+y)
    minus.append(x-y)

ans1 = max(plus) - min(plus)
ans2 = max(minus) - min(minus) 

print(max(ans1,ans2))

Solution (Python):
N = int(input())

points_pp = []
points_pn = []
points_np = []
points_nn = []
for _ in range(N):
  x, y = map(int, input().split())
  points_pp.append(x+y)
  points_nn.append(-x-y)
  
  points_pn.append(x-y)
  points_np.append(-x+y)
  
ans_pp = max(points_pp) - min(points_pp)  
ans_pn = max(points_pn) - min(points_pn)  
ans_np = max(points_np) - min(points_np)  
ans_nn = max(points_nn) - min(points_nn)
print(max(ans_pp, ans_pn, ans_np, ans_nn))

Solution (Python):
n = int(input())
xy1 = []
xy2 = []
for _ in range(n):
    x, y = map(int, input().split())
    xy1.append(x+y)
    xy2.append(x-y)
ans = max(max(xy1)-min(xy1), max(xy2)-min(xy2))
print(ans)

Solution (Python):
N=int(input())
A=[]
min_x=10**9+1
min_y=10**9+1
B=[0 for i in range(N)]
C=[0 for i in range(N)]
for i in range(N):
    x,y=map(int,input().split())
    A.append([x,y])
    min_x=min(min_x,x)
    min_y=min(min_y,y)
for i in range(N):
    A[i][0]=A[i][0]-min_x
    A[i][1]=A[i][1]-min_y
    B[i]=A[i][0]+A[i][1]
    C[i]=A[i][0]-A[i][1]
print(max(max(B)-min(B),max(C)-min(C)))

Solution (Python):
import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)

n=int(input())
table=[(x-y,x+y)for x,y in [map(int,input().split()) for i in range(n)]]
a,b=[table[0][0]]*2,[table[0][1]]*2
ans=0
for x,y in table:
    ans=max(ans,abs(x-a[0]),abs(x-a[1]),abs(y-b[0]),abs(y-b[1]))
    a[0]=min(x,a[0])
    a[1]=max(a[1],x)
    b[0]=min(b[0],y)
    b[1]=max(b[1],y)
print(ans)

Solution (Python):
N = int(input())

data1 = []
data2 = []
for i in range(N):
    x,y = map(int,input().split())
    data1.append(x+y)
    data2.append(y-x)

p = max(data1)-min(data1)
q = max(data2)-min(data2)

print(max(p,q))

Solution (Python):
N = int(input())
px = []
py = []
cro1 = []
cro2 = []
for i in range(N):
    x,y = map(int,input().split())
    px.append((x,y))
    py.append((x,y))
    cro1.append(x+y)
    cro2.append(y-x)
"""
px.sort()
py.sort(key=lambda x:x[1])
"""
cro1.sort()
cro2.sort()
print(max(cro1[-1]-cro1[0],cro2[-1]-cro2[0]))

Solution (Python):
def main():
    n = int(input())
    d1 = []
    d2 = []
    for _ in range(n):
        x, y = map(int, input().split())
        d1.append(x + y)
        d2.append(x - y)
    d1.sort()
    d2.sort()
    print(max(d1[-1] - d1[0], d2[-1] - d2[0]))


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
P=[]
M=[]
for i in range(n):
    x,y=map(int,input().split())
    P.append(x+y)
    M.append(x-y)
dP=abs(max(P)-min(P))
dM=abs(max(M)-min(M))
print(max(dP,dM))

Solution (Python):
n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]
for i, v in enumerate(p):
    x, y = v
    p[i] = x-y, x+y

xm, ym = -10**9, -10**9
xw, yw = 10**9, 10**9
for x, y in p:
    xm = max(xm, x)
    xw = min(xw, x)
    ym = max(ym, y)
    yw = min(yw, y)


ans = max(abs(xm - xw), abs(ym - yw))
print(ans)

Solution (Python):
n=int(input())
z=[]
c=[]
for j in range(n):
    x1,y1=[int(j) for j in input().split()]
    z.append(x1+y1)
    c.append(x1-y1)
za=max(z)
zi=min(z)
ca=max(c)
ci=min(c)
mx=max(za-zi,ca-ci)
print(mx)