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):
def e_dist_max():
    N = int(input())
    Pos_z, Pos_w = [], []  
    for _ in range(N):
        x, y = [int(i) for i in input().split()]
        Pos_z.append(x + y)
        Pos_w.append(x - y)
    Pos_z.sort()
    Pos_w.sort()
    return max(Pos_z[-1] - Pos_z[0], Pos_w[-1] - Pos_w[0])

print(e_dist_max())

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

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

print(max(d))

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

L=[]





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

L=sorted(L)
ans=abs(L[0][0]-L[-1][0])
L=sorted(L, key=lambda x: x[1])
ans=max(ans, abs(L[0][1]-L[-1][1]))

print(ans)

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

fn=[lambda x:x[0]+x[1],lambda x:x[0]-x[1]]
ans=0
for f in fn:
    xy.sort(key = f)
    ans=max(ans,abs(f(xy[0])-f(xy[-1])))
print(ans)

Solution (Python):
import numpy as np



import sys
input = sys.stdin.readline



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

    z_max = 0
    z_min = 2 * 10 **9

    w_max = - 10 ** 9
    w_min = 10 ** 9

    for i in range(N):
        z = xy[i][0] + xy[i][1]
        w = xy[i][0] - xy[i][1]
        z_max = max(z_max,z)
        z_min = min(z_min,z)
        w_max = max(w_max,w)
        w_min = min(w_min,w)

    res = max(z_max-z_min,w_max-w_min)

    print(res)



main()

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

Solution (Python):
import sys
import math,bisect
sys.setrecursionlimit(10 ** 5)
from collections import defaultdict
from itertools import groupby,accumulate
from heapq import heapify,heappop,heappush
from collections import deque,Counter,OrderedDict
def I(): return int(sys.stdin.readline())
def neo(): return map(int, sys.stdin.readline().split())
def Neo(): return list(map(int, sys.stdin.readline().split()))
n = I()
A,B = [],[]
for i in range(n):
    a,b = neo()
    A += [a+b]
    B += [a-b]
A.sort()
B.sort()
Ans = max(A[-1]-A[0],B[-1]-B[0])
print(Ans)

Solution (Python):
import random

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

minn = 10**10
maxn = -10**10
minp = 10**10
maxp = -10**10

for i in range(N):
  minn = min(minn, x[i]-y[i])
  maxn = max(maxn, x[i]-y[i])
  minp = min(minp, x[i]+y[i])
  maxp = max(maxp, x[i]+y[i])

print(max(maxn-minn, maxp-minp))

Solution (Python):
N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]
z = []; w = []
for x, y in xy:
    z.append(x + y)
    w.append(x - y)

print(max(max(z)-min(z), max(w)-min(w)))

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):
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):
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
Z = sorted([x+y for x,y in A])
W = sorted([x-y for x,y in A])

print(max(Z[-1]-Z[0], W[-1]-W[0]))

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

    N = int(input())
    P = []
    M = []
    for _ in range(N):
        x, y = map(int, input().split())
        P.append(x + y)
        M.append(x - y)
    P.sort()
    M.sort()
    ans = max(P[-1] - P[0], M[-1] - M[0])
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
xy=[tuple(map(int,input().split())) for _ in range(N)]
ans=0
zmi=10**10
zma=-10**10
wmi=10**10
wma=-10**10
for x,y in xy:
    zmi=min(zmi,x+y)
    zma=max(zma,x+y)
    wmi=min(wmi,x-y)
    wma=max(wma,x-y)
print(max(zma-zmi,wma-wmi))

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

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

xpy=[]
xmy=[]

for i in range(n):
    xpy.append(xy[i][0]+xy[i][1])
    xmy.append(xy[i][0]-xy[i][1])

xpy.sort()
xmy.sort()

print(max(abs(xpy[-1]-xpy[0]),abs(xmy[-1]-xmy[0])))

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

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

xy = []

def dist(a, b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])
    
for i in range(n):
    x, y = map(int,input().split())
    xy.append([x+y, x-y])

xy.sort(key = lambda x: x[0])

min_z = xy[0][0]
max_z = xy[-1][0]

xy.sort(key = lambda x: x[1])

min_w = xy[0][1]
max_w = xy[-1][1]

print(max(abs(min_z - max_z), abs(min_w - max_w)))

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

n = int(readline())
z,w = [],[]
for _ in range(n):
    x, y = map(int,readline().split())
    z.append(x+y)
    w.append(x-y)

z.sort()
w.sort()

print(max(z[n-1]-z[0],w[n-1]-w[0]))

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

Solution (Python):



import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading



threading.stack_size(10**8)
sys.setrecursionlimit(300000)

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")


n=int(input())
ans=0
d=defaultdict(int)
d1=defaultdict(int)
m=-10**13
m1=-10**13
mi=10**13
mi1=10**13
for i in range(n):
    a,b=map(int,input().split())
    m=max(m,a+b)
    mi=min(mi,a+b)
    m1=max(m1,a-b)
    mi1=min(mi1,a-b)

print(max(m-mi,m1-mi1))

Solution (Python):
N = int(input())
X = []
Y = []
for _ in range(N):
    x, y = list(map(int, input().split()))
    X.append(x)
    Y.append(y)
    
points = []
for x, y in zip(X, Y):
    points.append((
        x + y,
        x - y
    ))
print(max(max(dim) - min(dim) for dim in zip(*points)))

Solution (Python):
N = int(input())
i = 0
a_max = 2
a_min = 2*(10**9)
s_max = 1-10**9
s_min = 10**9-1

for i in range(N):
    x,y=map(int,input().split())
    add = x+y
    sub = x-y

    if add > a_max:
        a_max = add
    if add < a_min:
        a_min = add
    
    if sub > s_max:
        s_max = sub
    if sub < s_min:
        s_min = sub

d_add = a_max - a_min
d_sub = s_max - s_min





print(max(d_add,d_sub))

Solution (Python):
n = int(input())
plus = []
minus = []

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

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

Solution (Python):
a,*b=[],
for z in[*open(0)][1:]:x,y=map(int,z.split());a+=x+y,;b+=x-y,
print(max(max(a)-min(a),max(b)-min(b)))

Solution (Python):
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]


MOD = 10**9 + 7
YES, NO, IMP = "YES", "NO", "IMPOSSIBLE"
from collections import defaultdict as ddic

N=rri()
A = rrmm(N)
X = []
Y = []
for x, y in A:
    X.append(x-y)
    Y.append(x+y)



xlo, xhi = min(X), max(X)
ylo, yhi = min(Y), max(Y)

print(max(yhi-ylo, xhi-xlo))

Solution (Python):
n = int(input())
z = [0 for _ in range(n)]
w = [0 for _ in range(n)]

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

print(max(max(z)-min(z), max(w)-min(w)))

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

Solution (Python):
n=int(input())
s,p=10**100,10**100
t,q=-1000000000000,-1000000000000

for i in range(n):
  x,y=map(int,input().split())
  s=min(s,x+y)
  t=max(t,x+y)
  p=min(p,x-y)
  q=max(q,x-y)
  
print(max(t-s,q-p))

Solution (Python):
N=int(input())
DMY=10**9

mmax=None
mmin=None
dmax=None
dmin=None
for i in range(N):
    x,y = map(int, input().split())
    if not mmax:
        mmax=(x,y,x+y)
        mmin=(x,y,x+y)
        dmax=(x,y,x+DMY-y)
        dmin=(x,y,x+DMY-y)
        continue
    if x+y > mmax[2]:
        mmax=(x,y,x+y)
    elif x+y < mmin[2]:
        mmin=(x,y,x+y)
    if x+DMY-y > dmax[2]:
        dmax=(x,y,x+DMY-y)
    elif x+DMY-y < dmin[2]:
        dmin=(x,y,x+DMY-y)

print(max(mmax[2]-mmin[2],dmax[2]-dmin[2]))

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

x_max = 0
y_max = 0
x_min = 10**9
y_min = 10**9

p_arr = [0]*n
m_arr = [0]*n

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

p_dist = max(p_arr) - min(p_arr)
m_dist = max(m_arr) - min(m_arr)
dist_max = max(p_dist, m_dist)
  
  
print(dist_max)

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

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

print(max(abs(max(xy_sum) - min(xy_sum)), abs(max(xy_dif) - min(xy_dif))))

Solution (Python):
z = []
w = []

for _ in range(int(input())):
    x, y = map(int, input().split())
    z.append(x + y)
    w.append(x - y)


z_max = max(z)
z_min = min(z)
w_max = max(w)
w_min = min(w)

print(max([abs(z_max - z_min), abs(w_max - w_min)]))

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

k = []
m = []
for i in l:
  a,b = i
  k.append(a+b)
  m.append(a-b)
k.sort()
m.sort()
print(max([k[-1]-k[0],m[-1] -m[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)
print(max(max(A)-min(A), max(B)-min(B)))

Solution (Python):
n = int(input())
hidarisita=2*10**9
migiue=0
migisita=2*10**9
hidariue=-10**9
x=[]
for i in range(0,n):
    x.append(list(map(int, input().split())))
    
for i in range(0,n):
    minlocal=x[i][0]+x[i][1]
    if minlocal<hidarisita:
        hidarisita=minlocal
    if minlocal==hidarisita:
        hidarisita2=minlocal
for i in range(0,n):
    maxlocal=x[i][0]+x[i][1]
    if maxlocal>migiue:
        migiue=maxlocal
    if maxlocal==migiue:
        migiue2=maxlocal
for i in range(0,n):
    minlocal=-x[i][0]+x[i][1]
    if minlocal<migisita:
        migisita=minlocal
    if minlocal==migisita:
        migisita2=minlocal
for i in range(0,n):
    maxlocal=-x[i][0]+x[i][1]
    if maxlocal>hidariue:
        hidariue=maxlocal
    if maxlocal==hidariue:
        hidariue2=maxlocal
aa=migiue-hidarisita
ab=migiue-hidarisita2
ba=migiue2-hidarisita
bb=migiue2-hidarisita2
cc=hidariue-migisita
cd=hidariue-migisita2
dc=hidariue2-migisita
dd=hidariue2-migisita2
print(max(aa,ab,ba,bb,cc,cd,dc,dd))

Solution (Python):
n = int(input())
u = []
v = []
ans = 0
for i in range(n):
    x, y = map(int, input().split())
    u.append(x+y)
    v.append(x-y)
ans = max(max(u) - min(u), max(v) - min(v))
print(ans)

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

tmp1 = []
tmp2 = []
for i in range(n):
    tmp1.append([xy[i][0]+xy[i][1], xy[i][0], xy[i][1]])
    tmp2.append([xy[i][0]-xy[i][1], xy[i][0], xy[i][1]])
tmp1.sort()
tmp2.sort()

ans = 0

if (tmp1[-1][2]-tmp1[0][2])*(tmp1[-1][1]-tmp1[0][1]) >= 0:
    tmp = tmp1[-1][0]-tmp1[0][0]
    ans = max(tmp, ans)
if (tmp2[-1][2]-tmp2[0][2])*(tmp2[-1][1]-tmp2[0][1]) <= 0:
    tmp = tmp2[-1][0]-tmp2[0][0]
    ans = max(tmp, ans)

print(ans)

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

tmp1 = []
tmp2 = []
for i in range(n):
    tmp1.append([xy[i][0]+xy[i][1], xy[i][0], xy[i][1]])
    tmp2.append([xy[i][0]-xy[i][1], xy[i][0], xy[i][1]])
tmp1.sort()
tmp2.sort()

if n <= 10:
    ii = n
    jj = n+1
else:
    ii = 10
    jj = 10

ans = 0
for i in range(ii):
    for j in range(1, jj):
        if (tmp1[-j][2]-tmp1[i][2])*(tmp1[-j][1]-tmp1[i][1]) >= 0:
            tmp = tmp1[-j][0]-tmp1[i][0]
            ans = max(tmp, ans)
        if (tmp2[-j][2]-tmp2[i][2])*(tmp2[-j][1]-tmp2[i][1]) <= 0:
            tmp = tmp2[-j][0]-tmp2[i][0]
            ans = max(tmp, ans)

print(ans)

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)
print(max(max(A)-min(A), max(B)-min(B)))

Solution (Python):
def main():
    n = int(input())
    
    z = []
    w = []

    for _ in range(n):
        x,y = tuple(map(int,input().split()))
        z.append(x+y)
        w.append(x-y)

    print(max(max(z)-min(z),max(w)-min(w)))

if __name__ == "__main__":
    main()

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

tmp1 = []
tmp2 = []
for i in range(n):
    tmp1.append([xy[i][0]+xy[i][1], xy[i][0], xy[i][1]])
    tmp2.append([xy[i][0]-xy[i][1], xy[i][0], xy[i][1]])
tmp1.sort()
tmp2.sort()

if n <= 1000:
    ii = n
    jj = n+1
else:
    ii = 1000
    jj = 1000

ans = 0
for i in range(ii):
    for j in range(1, jj):
        if (tmp1[-j][2]-tmp1[i][2])*(tmp1[-j][1]-tmp1[i][1]) >= 0:
            tmp = tmp1[-j][0]-tmp1[i][0]
            ans = max(tmp, ans)
        if (tmp2[-j][2]-tmp2[i][2])*(tmp2[-j][1]-tmp2[i][1]) <= 0:
            tmp = tmp2[-j][0]-tmp2[i][0]
            ans = max(tmp, ans)

print(ans)

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

Solution (Python):
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    a, b = map(int, input().split())
    x[i]=a+b
    y[i]=a-b
xmax=max(x)
xmin=min(x)
ymax=max(y)
ymin=min(y)
print(max(xmax-xmin,ymax-ymin))

Solution (Python):
def solve(xy):
    ans = 0
    pos = [xy[0] for _ in range(4)]

    for p in xy:
        if pos[0][0] + pos[0][1] < p[0] + p[1]:
            pos[0] = p
        if pos[1][0] + pos[1][1] > p[0] + p[1]:
            pos[1] = p
        if pos[2][0] - pos[2][1] < p[0] - p[1]:
            pos[2] = p
        if pos[3][0] - pos[3][1] > p[0] - p[1]:
            pos[3] = p

    return max(pos[0][0]+pos[0][1]-pos[1][0]-pos[1][1], pos[2][0]-pos[2][1]-pos[3][0]+pos[3][1])


if __name__ == "__main__":
    N = int(input())
    xy = [list(map(int, input().split())) for _ in range(N)]
    print(solve(xy))

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

N = int(input())
points = [0] * N
rx = []
ry = []
for i in range(N):
    x, y = map(int, input().split())
    rx.append(x - y)
    ry.append(x + y)
print(max(max(rx) - min(rx), max(ry) - min(ry)))

Solution (Python):

N = int(input())

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


X=[]
Y=[]
for i in range(N):
    
    
    X.append(x[i]-y[i])
    Y.append(x[i]+y[i])

dam1 = max(X) - min(X)
dam2 = max(Y) - min(Y)
print(max(dam1,dam2))

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

Solution (Python):

import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
x,y = [],[]
for i in range(n):
    a,b = ip()
    x.append(a+b)
    y.append(a-b)
print(max(max(x)-min(x),max(y)-min(y)))

Solution (Python):

N = int(input())

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


X=[]
Y=[]
for i in range(N):
    
    
    X.append(x[i]-y[i])
    Y.append(x[i]+y[i])

dam1 = max(X) - min(X)
dam2 = max(Y) - min(Y)
print(max(dam1,dam2))

Solution (Python):
N = int(input())
xys = set([tuple(map(int, input().split())) for _ in range(N)])

z = []
w = []

for xy in xys:
    z.append(xy[0]+xy[1])
    w.append(xy[0]-xy[1])




print(max(abs(max(z) - min(z)), abs(max(w) - min(w))))

Solution (Python):
n = int(input())
x = [None]*n
y = [None]*n

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



k1 = [0]*n

k2 = [0]*n
for i in range(n):
    k1[i] = -(x[i]-y[i])
    k2[i] = x[i]+y[i]

print(max(max(k1)-min(k1),max(k2)-min(k2)))

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

Solution (Python):

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

ans = 0

def measure(originX,originY):
    dist = []
    for X,Y in XY:
        dist.append(abs(X-originX)+abs(Y-originY))
    return max(dist)-min(dist)

originX = 0
originY = 0
ans = max(ans,measure(originX,originY))

originX = 10**9
originY = 0
ans = max(ans,measure(originX,originY))

originX = 0
originY = 10**9
ans = max(ans,measure(originX,originY))

originX = 10**9
originY = 10**9
ans = max(ans,measure(originX,originY))

print(ans)

Solution (Python):
def solve(xy):
    xy_diff = [] 
    xy_dist = [] 
    for x,y in xy:
        xy_diff.append([x,y,x-y])
        xy_dist.append([x,y,x+y])
    xy_diff.sort(key = lambda x:x[2])
    xy_dist.sort(key = lambda x:x[2])

    return max(xy_diff[-1][2] - xy_diff[0][2], xy_dist[-1][2] - xy_dist[0][2])

def main():
    N = int(input())
    xy = [list(map(int,input().split())) for _ in range(N)]
    print(solve(xy))

if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
xbox=[]
ybox=[]
for i in range(n):
    x,y = map(int,input().split())
    xbox.append(x)
    ybox.append(y)
xmax=max(xbox)
xmin = min(xbox)
ymax=max(ybox)
ymin=min(ybox)
box1=[]
box2=[]
box3=[]
box4=[]
for i in range(n):
    box1.append(xmax+ymax-xbox[i]-ybox[i])
    box2.append(-xmin + ymax + xbox[i] - ybox[i])
    box3.append(xmax - ymax - xbox[i] + ybox[i])
    box4.append(-xmax - ymax + xbox[i] + ybox[i])
print(max([max(box1)-min(box1),max(box2)-min(box2),max(box3)-min(box3),max(box4)-min(box4)]))

Solution (Python):
beforex_plus_y=[]
beforex_minus_y=[]
for i in range(int(input())):
  xy=list(map(int,input().split()))
  beforex_plus_y.append(xy[0]+xy[1])
  beforex_minus_y.append(xy[0]-xy[1])

print(max(max(beforex_plus_y)-min(beforex_plus_y),max(beforex_minus_y)-min(beforex_minus_y)))

Solution (Python):
import sys

readline = sys.stdin.readline
N = int(readline())
A = []
B = []
for _ in range(N):
    x, y = map(int, readline().split())
    A.append(x-y)
    B.append(x+y)
print(max(max(A) - min(A), max(B) - min(B)))

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(max(z)-min(z),max(w)-min(w)))

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    xy = list(nl() for _ in range(n))

    xpy = [x + y for x, y in xy]
    xmy = [x - y for x, y in xy]

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


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
z = [x + y for x, y in xy]
w = [x - y for x, y in xy]
z.sort()
w.sort()

ans = max(z[-1] - z[0], w[-1] - w[0])
print(ans)

Solution (Python):
import sys
from collections import Counter
import bisect



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


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

    W_max =0
    W_min= 10**9+7
    Y_max= -10**9-1
    Y_min=10**9+7

    for i in range(N):
        x,y =map(int,input().split())
        W_max =max(W_max,x+y)
        W_min =min(W_min,x+y)
        Y_max =max(Y_max,x-y)
        Y_min =min(Y_min,x-y)

    print(max(W_max - W_min,Y_max - Y_min))






if __name__ == "__main__":
    main()

Solution (Python):
a,*b=[],
for z in[*open(0)][1:]:x,y=map(int,z.split());a+=x+y,;b+=x-y,
print(max(max(a)-min(a),max(b)-min(b)))

Solution (Python):
import sys

input=sys.stdin.buffer.readline





def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))





def main():
	n=II()
	XY=[LI() for _ in range(n)]
	
	A=[]
	B=[]
	for x,y in XY:
		A.append(x+y)
		B.append(x-y)
	
	A.sort()
	B.sort()
	a=A[-1]-A[0]
	b=B[-1]-B[0]
	
	print(max(a,b))










if __name__=="__main__":
	main()

Solution (Python):
n=int(input())
a= [list(map(int, input().split())) for i in range(n)]
a1=float('inf')
a2=-float('inf')
a3=float('inf')
a4=-float('inf')

for i in range(n):
    cnt=a[i][0]+a[i][1]
    cnt1=a[i][0]-a[i][1]
    a1=min(a1,cnt)
    a2=max(a2,cnt)
    a3=min(cnt1,a3)
    a4=max(cnt1,a4)


print(max(a2-a1,a4-a3))

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

iti = -float("inf")
ni = -float("inf")
san = -float("inf")
yon = -float("inf")
for x,y in xy:
    iti = max(iti,x+y)
    ni = max(ni,x-y)
    san = max(san,-x+y)
    yon = max(yon,-x-y)

print(max(iti+yon,ni+san))

Solution (Python):
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
for i in range(N):
  X[i]=[X[i][0]+X[i][1],X[i][0]-X[i][1]]
print(max([max([X[i][j] for i in range(N)])-min([X[i][j] for i in range(N)]) for j in range(2)]))

Solution (Python):
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 = sorted(z)
w = sorted(w)


ans = max(abs(z[-1] - z[0]), abs(w[-1] - w[0]))
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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 ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()


zmax, zmin, wmax, wmin = -10 ** 9, 10 ** 9, -10 ** 9, 10 ** 9

for i in range(N):
    x, y = MAP()
    zmax = max(zmax, x + y)
    zmin = min(zmin, x + y)
    wmax = max(wmax, x - y)
    wmin = min(wmin, x - y)
print(max(zmax - zmin, wmax - wmin))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
XY = [list(mapint()) for _ in range(N)]
XY.sort(key=lambda x:x[0]+x[1])
ans_1 = abs(XY[0][0]-XY[-1][0])+abs(XY[0][1]-XY[-1][1])
XY.sort(key=lambda x:x[0]-x[1])
ans_2 = abs(XY[0][0]-XY[-1][0])+abs(XY[0][1]-XY[-1][1])
print(max(ans_1, ans_2))

Solution (Python):
if __name__ == '__main__':

    N = int(input())
    x = []
    y = []

    for _ in range(N):
        x_, y_ = map(int, input().split())
        x.append(x_)
        y.append(y_)
    xpy = [a + b for a, b in zip(x, y)]
    xmy = [a - b for a, b in zip(x, y)]
    max_1 = max(xpy)
    min_1 = min(xpy)
    max_2 = max(xmy)
    min_2 = min(xmy)
    print(max(max_1 - min_1,max_2 - min_2))

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)

p.sort()
q.sort()
print(max(max(p) - min(p), max(q) - min(q)))

Solution (Python):
N=int(input())
xp=yp=0
xn=yn=10**9
zs=[0]*N
ws=[0]*N
for i in range(N):
    xi,yi=map(int,input().split())
    zs[i]=xi+yi
    ws[i]=xi-yi
zs.sort()
ws.sort()
ans=max(zs[-1]-zs[0],ws[-1]-ws[0])
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
xy = [0] * n

xy_plus_max = -10 ** 10
xy_plus_min = 10 ** 10
xy_minus_max = -10 ** 10
xy_minus_min = 10 ** 10
for i in range(n):
    x, y = map(int, input().split())
    xy_plus_max = max(xy_plus_max, x + y)
    xy_plus_min = min(xy_plus_min, x + y)
    xy_minus_max = max(xy_minus_max, x - y)
    xy_minus_min = min(xy_minus_min, x - y)

print(max(xy_plus_max - xy_plus_min, xy_minus_max - xy_minus_min))

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

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

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

z = []
w = []

for x, y in xy:
    z.append(x + y)
    w.append(x - y)

ans = max(max(z) - min(z), max(w) - min(w))

print(ans)

Solution (Python):
n = int(input())
xy = []
for _ in range(n):
    xy.append(list(map(int,input().split())))
a,b=xy[0]
m1=a+b
p1=xy[0]
m2=a-b
p2=xy[0]
p3=xy[0]
p4=xy[0]
m3=-a-b
m4=-a+b

for x,y in xy:
    if x+y > m1:
        m1=x+y
        p1 = [x,y]
    if x-y > m2:
        m2=x-y
        p2 = [x,y]
    if -x-y > m3:
        m3 = -x-y
        p3 = [x,y]
    if -x+y > m4:
        m4 = -x+y
        p4 = [x,y]
m = 0
for x0,y0 in [p1,p2,p3,p4]:
    for x1,y1 in [p1,p2,p3,p4]:
        dis=abs(x0-x1) + abs(y0-y1)
        if dis > m:
            m = dis
print(m)

Solution (Python):
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
for i in range(N):
  X[i]=[X[i][0]+X[i][1],X[i][0]-X[i][1]]
print(max([max([X[i][j] for i in range(N)])-min([X[i][j] for i in range(N)]) for j in range(2)]))

Solution (Python):



N=int(input())

x,y=map(int,input().split())
R=x
L=x
U=y
B=y

P=[(x,y)]
for i in range(1,N):
    x,y=map(int,input().split())
    P.append((x,y))
    if R<x:R=x
    if L>x:L=x
    if U<y:U=y
    if B>y:B=y

p=P[0]

UR=p
dUR=abs(R-p[0])+abs(U-p[1])
UL=p
dUL=abs(L-p[0])+abs(U-p[1])
BR=p
dBR=abs(R-p[0])+abs(B-p[1])
BL=p
dBL=abs(L-p[0])+abs(B-p[1])

for p in P[1:]:
    if dUR>abs(R-p[0])+abs(U-p[1]):
        UR=p
        dUR=abs(R-p[0])+abs(U-p[1])
    if dUL>abs(L-p[0])+abs(U-p[1]):
        UL=p
        dUL=abs(L-p[0])+abs(U-p[1])
    if dBR>abs(R-p[0])+abs(B-p[1]):
        BR=p
        dBR=abs(R-p[0])+abs(B-p[1])
    if dBL>abs(L-p[0])+abs(B-p[1]):
        BL=p
        dBL=abs(L-p[0])+abs(B-p[1])
    

ans=abs(UR[0]-BL[0])+abs(UR[1]-BL[1])

ans2=abs(UL[0]-BR[0])+abs(UL[1]-BR[1])
if ans2>ans: ans=ans2

print(ans)

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

print(ans)

Solution (Python):
import sys
import math



input = sys.stdin.readline
 

def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))



n=inp()

min1=min2=int(1e15)
max1=max2=-int(1e15)

for i in range(n):
	x,y=invr()
	
	min1=min(min1,x+y)
	min2=min(min2,x-y)
	
	max1=max(max1,x+y)
	max2=max(max2,x-y)

ans=max(max1-min1,max2-min2)

print(ans)

Solution (Python):
N = int(input())
table = [[int(i) for i in input().split()] for N in range(N)]

a = -1
b = 10**10
c = -10**10
d = 10**10
for i in range(N):
    p = table[i][0]
    q = table[i][1]
    if a < p+q:
        a = p+q
    if b > p+q:
        b = p+q
    if c < p-q:
        c = p-q
    if d > p-q:
        d = p-q

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

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

xp=yp=0
xn=yn=10**9
zs=[0]*N
ws=[0]*N
for i in range(N):
    xi,yi=map(int,input().split())
    zs[i]=xi+yi
    ws[i]=xi-yi
zs.sort()
ws.sort()
ans=max(zs[-1]-zs[0],ws[-1]-ws[0])
print(ans)

Solution (Python):
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    a, b = map(int, input().split())
    x[i]=a+b
    y[i]=a-b
xmax=max(x)
xmin=min(x)
ymax=max(y)
ymin=min(y)
print(max(xmax-xmin,ymax-ymin))

Solution (Python):
n=int(input())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
    k,l=map(int,input().split())
    a.append((k-l,i))
    b.append((k+l,i))
    c.append((-k-l,i))
    d.append((-k+l,i))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
d.sort(reverse=True)
print(max(a[0][0]+d[0][0],b[0][0]+c[0][0]))