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):
n=int(input())
zp=[]
zl=[]
for i in range(n):
    a,b=map(int,input().split())
    zp.append(a+b)
    zl.append(a-b)
ans=max((max(zp)-min(zp)),(max(zl)-min(zl)))
print(ans)

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


def func(x, m):
    return x % m



def main():
    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
    
    ans = max(max(z) - min(z), max(w) - min(w))
    
    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):


def main():
    n = int(input())
    z = [[], []]
    for i in range(n):
        x, y = map(int, input().split())
        z[0].append(x + y)
        z[1].append(x - y)
    z[0] = sorted(z[0])
    z[1] = sorted(z[1])
    print(max(z[0][-1] - z[0][0], z[1][-1] - z[1][0]))



if __name__ == '__main__':
    main()

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

p_one = input()
p_one_list = p_one.split(' ')

zmax = int(p_one_list[0]) + int(p_one_list[1])
zmin = int(p_one_list[0]) + int(p_one_list[1])
wmax = int(p_one_list[0]) - int(p_one_list[1])
wmin = int(p_one_list[0]) - int(p_one_list[1])


for i in range(1, n):
    line = input()
    tmp = line.split(' ')
    z = int(tmp[0]) + int(tmp[1])
    w = int(tmp[0]) - int(tmp[1])
    zmax = max(zmax, z)
    wmax = max(wmax, w)
    zmin = min(zmin, z)
    wmin = min(wmin, w)


z_ans = zmax - zmin
w_ans = wmax - wmin


print(f'{max(z_ans, w_ans)}')

Solution (Python):
N=int(input())
A=[0]*(N)
B=[0]*(N)
for i in range(N):
    x,y=map(int, input().split())
    A[i]=x+y
    B[i]=x-y

A=sorted(A)
B=sorted(B)

print(max(A[-1]-A[0],B[-1]-A[0],A[-1]-A[0],B[-1]-B[0]))

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

A=sorted(A)
B=sorted(B)

print(max(A[-1]-A[0],B[-1]-A[0],A[-1]-A[0],B[-1]-B[0]))

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

A=sorted(A)
B=sorted(B)

print(max(A[-1]-A[0],B[-1]-A[0],A[-1]-A[0],B[-1]-B[0]))

Solution (Python):
n = int(input())
point_dict1 = {}
point_dict2 = {}
for i in range(n):
    x, y = map(int, input().split())
    point_dict1[x + y] = (x, y)
    point_dict2[y - x] = (x, y)
min_point1 = min(point_dict1)
max_point1 = max(point_dict1)
min_point2 = min(point_dict2)
max_point2 = max(point_dict2)
print(max(max_point1 - min_point1, max_point2 - min_point2))

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
a=[]
b=[]
for i in range(n):
  a.append(l[i][0]+l[i][1])
  b.append(l[i][0]-l[i][1])
print(max(max(a)-min(a),max(b)-min(b)))

Solution (Python):


N=int(input())

Z=[]
W=[]

for _ in range(N):
    x,y=map(int,input().split())
    Z.append(x+y)
    W.append(x-y)
    
print(max(max(Z)-min(Z),max(W)-min(W)))

Solution (Python):
N = int(input())
x, y = map(int, input().split())
d = [x - y, x - y, x + y, x + y]
for i in range(1,N):
  x, y = map(int, input().split())
  d[0] = max(d[0], x-y)
  d[1] = min(d[1], x-y)
  d[2] = max(d[2], x+y)
  d[3] = min(d[3], x+y)
print(max(d[0]-d[1], d[2]-d[3]))

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

Solution (Python):
n = int(input())
a, b = [], []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x+y)
    b.append(x-y)

a.sort()
b.sort()

ans = max(a[-1]-a[0], b[-1]-b[0])
print(ans)

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

n=int(input())
a,b,c,d=-10**9,10**9,-10**9,10**9
for _ in range(n):
	x,y=map(int,input().split())
	a=max(a,x+y)
	b=min(b,x+y)
	c=max(c,x-y)
	d=min(d,x-y)
print(max(a-b,c-d))

Solution (Python):
n=int(input())
a,b,c,d=-10**9,10**9,-10**9,10**9
for _ in range(n):
	x,y=map(int,input().split())
	a=max(a,x+y)
	b=min(b,x+y)
	c=max(c,x-y)
	d=min(d,x-y)
print(max(a-b,c-d))

Solution (Python):
N = int(input())
A = []; B = []
for i in range(N):
  x,y = map(int,input().split())
  a = x+y; A.append(a)
  b = x-y; B.append(b)
A.sort();B.sort()
Max_A = A[-1] - A[0]
Max_B = B[-1] - B[0]
ans = max(Max_A,Max_B)
print(ans)

Solution (Python):
import math
import sys



def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    _x = []
    _y = []
    for _ in range(n):
        x, y = input_int_list()
		
        _x.append(x - y)
        _y.append(x + y)
	
    ans = max(max(_x) - min(_x), max(_y) - min(_y))

    print(ans)
    return


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
p = [[None] for i in range(N)]

for i in range(N):
    p[i] = list(map(int, input().split()))

p.sort()


INFINITE = 5 * 10**9
maxUp = {}
minDown = {}

for i in range(1, N):
    maxUp[i] = max(maxUp.get(i-1, -INFINITE), p[i-1][1] - p[i-1][0])
for i in range(1, N):
    minDown[i] = min(minDown.get(i-1, INFINITE), p[i-1][0] + p[i-1][1])




ans = -INFINITE
for i in range(1, N):
    ans = max(ans, 
        p[i][0] - p[i][1] + maxUp.get(i, -INFINITE)
    )
    ans = max(ans, 
        p[i][0] + p[i][1] - minDown.get(i, INFINITE)
    )
print(ans)

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

x=[]
y=[]

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

print(max(max(x)-min(x),max(y)-min(y)))

Solution (Python):
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=998244353

n=int(input())
A=[]
for i in range(n):
    x,y=INPUT()
    a=x+y
    b=y-x
    A.append([a,b])
A.sort()
ans=0
maxiy=A[0][1]
miniy=maxiy
for i in range(n):
    ans=max(max(abs(A[i][0]-A[0][0]),max(abs(A[i][1]-maxiy),abs(A[i][1]-miniy))),ans)
    maxiy=max(maxiy,A[i][1])
    miniy=min(miniy,A[i][1])
print(ans)

Solution (Python):
n= int(input())
a = [list(map(int, input().split())) for i in range(n)]
b = []
c = []
for i in range(n):
  b.append(a[i][0]+a[i][1])
  c.append(a[i][0]-a[i][1])
maxbc=[max(b)-min(b), max(c)-min(c)]
print(max(maxbc))

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)
p.sort()
m.sort()
print(max(p[-1]-p[0],m[-1]-m[0]))

Solution (Python):
N = int(input())
XYs = [[],[]]
for _ in range(N):
  x,y = map(int, input().split())
  XYs[0].append(x-y)
  XYs[1].append(x+y)
  
print(max(max(XYs[0])-min(XYs[0]), max(XYs[1])-min(XYs[1])))

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

xyp = []
xym = []

for _ in range(N):
    x, y = map(int, input().split())
    xyp.append(x+y)
    xym.append(x-y)
    
xyp.sort()
xym.sort()

print(max(xyp[-1] - xyp[0], xym[-1] - xym[0]))

Solution (Python):



import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline




n = int(input())
d1 = [] * n
d2 = [] * n

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

print(max(max(d1) - min(d1), max(d2)-min(d2)))

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

N = int(input())
l1, l2 = [], []

for _ in range(N):
    x, y = map(int, input().split())
    l1.append(x+y)
    l2.append(x-y)

print(max(max(l1)-min(l1), max(l2)-min(l2)))

Solution (Python):
def main():
    n = int(input())
    xym, xyM, x_ym, x_yM = 10**9, -10**9, 10**9, -10**9
    for _ in range(n):
        x, y = map(int, input().split())
        xy, x_y = x+y, x-y
        xym, xyM, x_ym, x_yM = min(xym, xy), max(xyM, xy), min(x_ym, x_y), max(x_yM, x_y)
    print(max(xyM-xym, x_yM-x_ym))

if __name__ == "__main__":
    main()

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

Solution (Python):
n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]
q = [[x+y, x-y] for x, y in p]
print(max(max(q)[0] - min(q)[0], max(q, key=lambda x: x[1])[1] - min(q, key=lambda x: x[1])[1]))

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

def main():
    n=int(input())
    XY=[tuple(map(int,input().split())) for _ in range(n)]
    U,V=[],[]
    for x,y in XY:
        U.append(x+y)
        V.append(x-y)
    print(max(max(U)-min(U),max(V)-min(V)))
    
if __name__=='__main__':
    main()

Solution (Python):
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
zmax=zmin=L[0][0]+L[0][1]
wmax=wmin=L[0][0]-L[0][1]
for a,b in L:
    z,w=a+b,a-b
    zmax=max(zmax,z)
    zmin=min(zmin,z)
    wmax=max(wmax,w)
    wmin=min(wmin,w)
print(max(zmax-zmin,wmax-wmin))

Solution (Python):
N=int(input())
zls=[0 for _ in range(N)]
wls=[0 for _ in range(N)]
for i in range(N):
  x,y=[int(s) for s in input().split()]
  zls[i]=x+y
  wls[i]=x-y
print(max([max(zls)-min(zls),max(wls)-min(wls)]))

Solution (Python):
from operator import itemgetter, attrgetter

class P:
    def __init__(self, x, y):
        self.x, self.y = x, y
    def __add__(self, p): return P(self.x + p.x, self.y + p.y)
    def __sub__(self, p): return P(self.x - p.x, self.y - p.y)
    def dot(self, p): return (self.x*p.x + self.y*p.y)
    def cross(self, p): return (self.x*p.y - self.y*p.x)
    def abs(self): return (abs(self.x) + abs(self.y))

def convex_hull(Ps):
    Ps.sort(key=attrgetter('x', 'y'))
    ret1, ret2 = list(), list()
    for i in range(len(Ps)):
        k = len(ret1)
        while k>=2 and (Ps[i]-ret1[k-1]).cross(ret1[k-1]-ret1[k-2]) <= 0:
            ret1.pop()
            k = len(ret1)
        ret1.append(Ps[i])
    for i in range(len(Ps)):
        k = len(ret2)
        while k>=2 and (Ps[i]-ret2[k-1]).cross(ret2[k-1]-ret2[k-2]) >= 0:
            ret2.pop()
            k = len(ret2)
        ret2.append(Ps[i])
    return ret1 + ret2[::-1]

N = int(input())
Ps = list()
for i in range(N):
    x, y = list(map(int, input().split()))
    Ps.append(P(x, y))


CPs = convex_hull(Ps)


ans = 0
for i in range(len(CPs)):
    for j in range(i, len(CPs)):
        mdis = (CPs[i]-CPs[j]).abs()

        if ans < mdis: ans = mdis

print (ans)

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

N = int(readline())
X,Y = [None] * N, [None] * N
for i in range(N):
  x,y = map(int,readline().split())
  X[i],Y[i] = x + y,x - y

print(max(abs(max(X) - min(X)),abs(max(Y) - min(Y))))

Solution (Python):
n = int(input())
k = [0] * n
l = [0] * n
for i in range(n):
  x, y = [int(i) for i in input().split()]
  k[i] = x + y
  l[i] = x - y
print(max(max(k)-min(k), max(l)-min(l)))

Solution (Python):

import base64
import subprocess
import zlib


exe_bin = "c%1D

open("./kyomu", 'wb').write(zlib.decompress(base64.b85decode(exe_bin)))
subprocess.run(["chmod +x ./kyomu"], shell=True)
subprocess.run(["./kyomu"], shell=True)

Solution (Python):
def main():
    N = int(input())
    points = [None] * N
    for i in range(N):
        x, y = map(int, input().split())
        points[i] = (x, y)
    ans = 0
    points.sort(reverse=True)
    topright = points[0][0] + points[0][1]
    bottomright = points[0][0] - points[0][1]
    for i in range(N):
        tr = points[i][0] + points[i][1]
        br = points[i][0] - points[i][1]
        ans = max([ans, abs(topright - tr), abs(bottomright - br)])
        topright = max(topright, tr)
        bottomright = max(bottomright, br)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N = int(input())
    points = [None] * N
    for i in range(N):
        x, y = map(int, input().split())
        points[i] = (x, y)
    ans = 0
    points.sort(reverse=True)
    topright = points[0][0] + points[0][1]
    bottomright = points[0][0] - points[0][1]
    for i in range(N):
        tr = points[i][0] + points[i][1]
        br = points[i][0] - points[i][1]
        ans = max([ans, abs(topright - tr), abs(bottomright - br)])
        topright = max(topright, tr)
        bottomright = max(bottomright, br)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
  p, q = [int(j) for j in input().split(' ')]
  a[i] = p+q
  b[i] = p-q

a.sort()
b.sort()
print(max(a[-1] - a[0], b[-1] - b[0]))

Solution (Python):
from sys import stdin

input = stdin.readline


MOD = 10**9 + 7



def solve():
    N = int(input())
    point = [tuple(map(int,inp.split())) for inp in stdin.read().splitlines()]
    pa = max(point,key = lambda x: x[0] + x[1])
    pb = min(point,key = lambda x: x[0] + x[1])
    pc = max(point,key = lambda x: x[0] - x[1])
    pd = min(point,key = lambda x: x[0] - x[1])
    r1 = pa[0] + pa[1] - pb[0] - pb[1]
    r2 = pc[0] - pc[1] + pd[1] - pd[0]
    print(max(r1,r2))
if __name__ == '__main__':
    solve()

Solution (Python):
n = int(input())
z = []
w = []
for i in range(n):
    x,y = map(int,input().split())
    z.append(x+y)
    w.append(x-y)
zmax = max(z)-min(z)
wmax = max(w)-min(w)
print(max(zmax,wmax))

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

Solution (Python):



def main():
    n = int(input())

    ls = []
    for i in range(n):
        p = list(map(int, input().split()))
        np = (p[0] + p[1], p[0] - p[1])
        ls.append(np)

    minx = float("inf")
    miny = float("inf")
    maxx = -float("inf")
    maxy = -float("inf")

    for i in range(len(ls)):
        x, y = ls[i]
        minx = min(minx, x)
        miny = min(miny, y)
        maxx = max(maxx, x)
        maxy = max(maxy, y)

    print(max(maxx - minx, maxy - miny))


main()

Solution (Python):
n = int(input())
p = []
for i in range(n):
    x,y = map(int,input().split())
    p.append([x,y])
q = []
r = []
for i in range(n):
    q.append(p[i][0]+p[i][1])
    r.append(p[i][0]-p[i][1])
q.sort()
r.sort()
ans = max(abs(q[-1]-q[0]),abs(r[-1]-r[0]))
print(ans)

Solution (Python):
n=int(input())
xy=[list(map(int, input().split())) for i in range(n)]
z=list(map(lambda x: x[0]+x[1], xy))
w=list(map(lambda x: x[0]-x[1], xy))
print(max(max(z)-min(z), max(w)-min(w)))

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

points = []

for i in range(n) :
    point = list(map(int, input().split(" ")))
    points.append(point)

z = []
w = []

for i in range(len(points)) :
    z.append(points[i][0] + points[i][1])

for i in range(len(points)) :
    w.append(points[i][0] - points[i][1])

max_z = max(z) - min(z)
max_w = max(w) - min(w)

if max_z > max_w :
    print(max_z)
else :
    print(max_w)

Solution (Python):
def main():
    N = int(input())
    x, y = map(int, input().split())
    a1 = x + y
    a2 = x + y
    b1 = y - x
    b2 = y - x
    N -= 1
    while N != 0:
        x, y = map(int, input().split())
        a1 = max(a1, x + y)
        a2 = min(a2, x + y)
        b1 = max(b1, y - x)
        b2 = min(b2, y - x)
        N = N - 1
    print(max(a1 - a2, b1 - b2))

main()

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)

ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def a_int(): return int(readline())


def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


def read_matrix(H, W):
    '''return np.ndarray shape=(H,W) matrix'''
    lines = []
    for _ in range(H):
        lines.append(read())
    lines = ' '.join(lines)  
    return np.fromstring(lines, sep=' ', dtype=np.int64).reshape(H, W)


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


MOD = 10**9 + 7
INF = 2**31  


from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  
from functools import reduce
from math import gcd


def lcm(a, b):
    
    g = gcd(a, b)
    return a // g * b





N = a_int()
XY = read_matrix(N, 2)
X = XY[:, 0]
Y = XY[:, 1]
f0 = X - Y
f1 = X + Y

print(max(f0.max() - f0.min(), f1.max() - f1.min()))

Solution (Python):
import numpy as np
N = int(input())

x = []
y = []
xy1 = []
xy2 = []

for i in range(N):
    a, b = (int(t) for t in input().split())
    x.append(a)
    y.append(b)
    xy1.append(a + b)
    xy2.append(a - b)

max1 = max(xy1) - min(xy1)
max2 = max(xy2) - min(xy2)
print(max((max1, max2)))

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

Solution (Python):



def get_points_and_convert(pts):
    x, y = pts
    return x + y, x - y


def main():
    n = int(input())
    points = [
        get_points_and_convert(map(int, input().split()))
        for _ in range(n)
    ]
    plus_coords, minus_coords = list(zip(*points))
    plus_dist = max(plus_coords) - min(plus_coords)
    minus_dist = max(minus_coords) - min(minus_coords)
    print(max(plus_dist, minus_dist))


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
l0 = [[int(i) for i in input().split()] for _ in range(N)]
l1 = [0] * N
l2 = [0] * N
for cnt, val in enumerate(l0):
    l1[cnt] = val[0] + val[1]
    l2[cnt] = val[0] - val[1]
l1.sort()
l2.sort()
print(max(l1[-1] - l1[0], l2[-1] - l2[0]))

Solution (Python):
def main():
    n = int(input())
    pt = []
    for _ in range(n):
        x,y = map(int,input().split())
        pt.append([x,y])
    a,b,c = [],[],[]
    for p in pt:
        a.append(p[0]+p[1])
        b.append(p[0]-p[1])
        c.append(p[1]-p[0])
    ans = 0
    if max(a)-min(a)>ans:
        ans = max(a)-min(a)
    if max(b)-min(b)>ans:
        ans = max(b)-min(b)
    if max(c)-min(c)>ans:
        ans = max(c)-min(c)
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
L = [[int(l) for l in input().split()] for _ in range(N)]

L1 = [0]*N
L2 = [0]*N
for i in range(N):
    L1[i] = L[i][0]+L[i][1]
    L2[i] = L[i][0]-L[i][1]

L1.sort()
L2.sort()
print(max(L1[-1]-L1[0], L2[-1]-L2[0]))

Solution (Python):
n = int(input())
a = []
b = []
for i in range(n):
  x,y = map(int, input().split())
  a.append(x+y)
  b.append(x-y)
a.sort()
b.sort()

ans = a[-1]-a[0]
c = b[-1]-b[0]
print (max(ans,c))

Solution (Python):
def manhattan(n, x, y):
    x2 = [0] * n
    y2 = [0] * n
    for i in range(n):
        x2[i] = x[i] - y[i]
        y2[i] = x[i] + y[i]
    print(max(max(x2) - min(x2), max(y2) - min(y2)))

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import defaultdict
from collections import deque
import bisect
from decimal import *
from functools import reduce
def main():
    N = I()
    Dots = defaultdict()
    xpyp = []
    xpyn = []
    xnyp = []
    xnyn = []
    for i in range(N):
        x, y = MI()
        Dots[i] = (x, y)
        xpyp.append(x + y)
        xpyn.append(x - y)
        xnyp.append(- x + y)
        xnyn.append(- x - y)
    xpyp_max = max(xpyp) - min(xpyp)
    xpyn_max = max(xpyn) - min(xpyn)
    xnyp_max = max(xnyp) - min(xnyp)
    xnyn_max = max(xnyn) - min(xnyn)
    print(max(xpyp_max, xpyn_max, xnyp_max, xnyn_max))

if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
a=10**9
z_max=-1*a
z_min=a
w_max=-1*a
w_min=a
for x,y in l: 
  z_max=max(z_max,x+y)
  z_min=min(z_min,x+y)
  w_max=max(w_max,x-y)
  w_min=min(w_min,x-y)
print(max(z_max-z_min,w_max-w_min))

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

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

pos_max = xy[0][0]+xy[0][1]
pos_min = xy[0][0]+xy[0][1]
neg_max = xy[0][0]-xy[0][1]
neg_min = xy[0][0]-xy[0][1]
for item in xy:
  pos_v = item[0] + item[1]
  neg_v = item[0] - item[1]
  pos_max = pos_v if pos_v > pos_max else pos_max
  pos_min = pos_v if pos_v < pos_min else pos_min
  neg_max = neg_v if neg_v > neg_max else neg_max
  neg_min = neg_v if neg_v < neg_min else neg_min

pos_result = pos_max - pos_min
neg_result = neg_max - neg_min
print(pos_result if pos_result >= neg_result else neg_result)

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

th = pow(10, 9)
z_max = -th
z_min = th
w_max = -th
w_min = th

for x, y in xy_array:
    z_max = max(x + y, z_max)
    z_min = min(x + y, z_min)
    w_max = max(x - y, w_max)
    w_min = min(x - y, w_min)

ans = max(z_max - z_min, w_max - w_min)
print(ans)

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

th = pow(10, 9)
right_up_max = -th
left_down_min = th
left_up_max = -th
right_down_min = th

for x, y in xy_array:
    right_up_max = max(x + y, right_up_max)
    left_down_min = min(x + y, left_down_min)
    left_up_max = max(x - y, left_up_max)
    right_down_min = min(x - y, right_down_min)

ans = max(right_up_max - left_down_min, left_up_max - right_down_min)
print(ans)

Solution (Python):
N = int(input())
lis = []
d1 = []
d2 = []
for i in range(N):
    x,y = map(int,input().split())
    lis.append([x,y])
    d1.append(x-y)
    d2.append(x+y)
ans = max(d1) - min(d1)
ans = max(ans,max(d2) - min(d2))
print(ans)

Solution (Python):
n = int(input())
l = [[] for i in range(4)]
for i in range(n):
    x, y = map(int, input().split())
    l[0].append(x+y)
    l[1].append(x-y)
    l[2].append(-x+y)
    l[3].append(-x-y)
for i in range(4):
    l[i].sort()
ans = 0
for i in range(4):
    ans = max(ans, l[i][-1] - l[i][0])
print(ans)

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

if __name__ == '__main__':
    main()

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

Solution (Python):
n=int(input())
a=[]
j=k=0
def s(a):
    return a[0]+a[1]
def ss(a):
    return a[0]-a[1]
for i in range(n):
    f=list(map(int,input().split()))
    a.append(f)
aa=min(map(s,a))
b=max(map(s,a))
c=min(map(ss,a))
d=max(map(ss,a))
print(max(abs(d-c),abs(b-aa)))

Solution (Python):
import sys

n = int(sys.stdin.buffer.readline())
z, w = [0]*n, [0]*n
for i, a in enumerate(sys.stdin.buffer.readlines()):
    x, y = map(int, a.split())
    z[i] = x+y
    w[i] = x-y
print(max(abs(max(z)-min(z)), abs(max(w)-min(w))))

Solution (Python):
N = int(input())
XY = [[int(_) for _ in input().split()] for _ in range(N)]
ans = -1
for dx, dy in ((1, 1), (-1, 1), (-1, -1), (1, -1)):
    xy2 = [x * dx + y * dy for x, y in XY]
    ans = max(ans, max(xy2) - min(xy2))
print(ans)

Solution (Python):
import sys
from operator import itemgetter

N = int(input())
V = set()
for s in sys.stdin.readlines():
    x, y = map(int, s.split())
    V.add((x + y, x - y))

y_max = max(V, key=itemgetter(1))[1]
y_min = min(V, key=itemgetter(1))[1]
x_max = max(V, key=itemgetter(0))[0]
x_min = min(V, key=itemgetter(0))[0]

print(max(x_max - x_min, y_max - y_min))

Solution (Python):
import numpy as np

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

xy45 = [[xy[i][0] - xy[i][1], xy[i][0] + xy[i][1]] for i in range(N)]
xy45 = np.array(xy45)

print(max(max(xy45[:, 0]) - min(xy45[:, 0]), max(xy45[:, 1]) - min(xy45[:, 1])))

Solution (Python):
import numpy as np
def solve(n, x, y):
    x = np.asarray(x)
    y = np.asarray(y)
    z = x + y
    w = x - y
    return max(np.max(z) - np.min(z), np.max(w) - np.min(w))

n = int(input())
x, y = zip(*[map(int, input().split()) for i in range(n)])
print(solve(n, x, y))

Solution (Python):
def solve(n, x, y):
    z = [u + v for u, v in zip(x, y)]
    w = [u - v for u, v in zip(x, y)]
    return max([max(z) - min(z), max(w) - min(w)])

n = int(input())
x, y = zip(*[map(int, input().split()) for i in range(n)])
print(solve(n, x, y))

Solution (Python):
N =  int(input())
A =  [list(map(int, (input().split(' ')))) for i in range(N)]

hoge = [sum(a) for a in A]
fuga = [a[0] - a[1] for a in A]
print(max(max(hoge) - min(hoge), max(fuga) - min(fuga)))

Solution (Python):
def get_ints():
    return list(map(int,input().split()))

n = int(input())
a, b = [], []
for i in range(n):
    x, y = get_ints()
    a.append(x-y)
    b.append(x+y)

a.sort()
b.sort()
ans = max(a[-1] - a[0], b[-1] - b[0])
print(ans)

Solution (Python):
def get_ints():
  return list(map(int,input().split()))

n = int(input())
a,b = [],[]
for i in range(n):
  x,y = get_ints()
  a.append(x+y)
  b.append(x-y)

a.sort()
b.sort()
ans = max(a[-1]-a[0], b[-1]-b[0])
print(ans)

Solution (Python):
import sys


def input():
    return sys.stdin.readline()[:-1]


N = int(input())

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

print(max(max(plus)-min(plus), max(minus)-min(minus)))

Solution (Python):
import sys
import re
import queue
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []



def main():
	N = i_input()

	x_y_list = []

	for i in range(0,N):
		tmpx,tmpy = i_map()
		x_y_list.append((tmpx,tmpy))

	z_list = []
	w_list = []
	for i in range(0,N):
		tmpz = x_y_list[i][0] + x_y_list[i][1]
		tmpw = x_y_list[i][0] - x_y_list[i][1]
		z_list.append(tmpz)
		w_list.append(tmpw)

	print(max(max(map(lambda x : (x),z_list))-min(map(lambda x: (x), z_list)),max(map(lambda x : (x),w_list))-min(map(lambda x: (x),w_list))))
	
	return


if __name__ == '__main__':
	main()

Solution (Python):
"""AtCoder Beginner Contest 178.

E
"""

import sys


def input() -> str:  
    """Input."""
    return sys.stdin.readline()[:-1]


def calc(p1: list, p2: list) -> int:
    """Calc Manhattan Distance."""
    return abs(p2[1] - p1[1]) + abs(p2[0] - p1[0])


def main():
    """Run."""
    n = int(input())

    patterns = {
        'lt': (1, 1),
        'rt': (-1, 1),
        'lb': (-1, -1),
        'rb': (1, -1),
    }

    points: dict = {k: None for k in patterns.keys()}

    for _ in range(n):
        p = list(map(int, input().split(' ')))

        for k, (x, y) in patterns.items():
            max_p = points[k]

            if max_p:
                max_p_pos = (max_p[0] * x) + (max_p[1] * y)
                p_pos = (p[0] * x) + (p[1] * y)
                if max_p_pos < p_pos:
                    points[k] = p
            else:
                points[k] = p

    ans = 0
    for i, p1 in enumerate(points.values()):
        for p2 in list(points.values())[i + 1:]:
            ans = max(ans, calc(p1, p2))

    print(ans)


main()

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

xpy = []
xmy = []


for _ in range(N):
    x, y = map(int, input().split())

    xpy.append(x + y)
    xmy.append(x - y)

print(max(max(xpy) - min(xpy), max(xmy) - min(xmy)))

Solution (Python):
n=int(input())
zmi=wmi=int(1e+10)
zma=wma=int(-1e+10)
for i in range(n):
    xi,yi=map(int,input().split())
    zma=max(xi+yi,zma)
    wma=max(xi-yi,wma)
    zmi=min(xi+yi,zmi)
    wmi=min(xi-yi,wmi)
print(max(zma-zmi,wma-wmi))

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

add = sorted([x+y for x, y in xy])
sub = sorted([x-y for x, y in xy])

print(max(add[-1]-add[0], sub[-1]-sub[0]))

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

plus,minus = [],[]
for i in range(n):
    a,b = map(int,input().split())
    plus.append(a+b)
    minus.append(a-b)

plus.sort()
minus.sort()

print(max(plus[-1]-plus[0],minus[-1]-minus[0]))

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