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
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    
    minA = minB = float('inf')
    maxA = maxB = - float('inf')
    
    for i in range(N):
        x, y = MI()
        x2, y2 = x - y, x + y
        minA = min(minA, x2)
        maxA = max(maxA, x2)
        minB = min(minB, y2)
        maxB = max(maxB, y2)
    
    print(max(maxA - minA, maxB - minB))
        
        
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,x,y])
  b.append([x-y,x,y])
a.sort()
b.sort()
ans=abs(a[0][1]-a[n-1][1])+abs(a[0][2]-a[n-1][2])
aa=abs(b[0][1]-b[n-1][1])+abs(b[0][2]-b[n-1][2])
print(max(ans,aa))

Solution (Python):
import sys
from io import StringIO
import unittest

def resolve():
    N, = map(int, input().split())

    kmin=100000000000
    kmax = 0
    lmin = 100000000000
    lmax = 0
    for i in range(N):
        x,y = map(int, input().split())
        k = y-x
        l = y+x
        kmin = min(kmin,k)
        lmin = min(lmin, l)
        kmax = max(kmax, k)
        lmax = max(lmax, l)


    print(max(kmax-kmin,lmax-lmin))
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1 1
2 4
3 2"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
1 1
1 1"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()

Solution (Python):
N,*f = map(int, open(0).read().split())
xy = [f[i*2:i*2+2] for i in range(N)]
s = [sum(z) for z in xy]
a = max(s) - min(s)
t = [z[0]-z[1] for z in xy]
b = max(t) - min(t)
print(max(a,b))

Solution (Python):
def main():
    n = int(input())
    P = [list(map(int, input().split())) for _ in range(n)]
    C0, C1 = [], []
    ans = 0

    for pi in P:
        C0.append(pi[0] - pi[1])
        C1.append(pi[0] + pi[1])

    C0min = min(C0)
    C0max = max(C0)
    C1min = min(C1)
    C1max = max(C1)

    print(max(C0max - C0min, C1max - C1min))


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
X = [0]*N
Y = [0]*N
for i in range(N):
    X[i],Y[i] = map(int,input().split())
for i in range(N):
    x = X[i]
    y = Y[i]
    b1 = x+y
    b2 = -x+y
    if i == 0:
        minb1=b1
        maxb1=b1
        minb2=b2
        maxb2=b2
        lowb1=[x,y]
        highb1=[x,y]
        lowb2=[x,y]
        highb2=[x,y]
    else:
        if b1<minb1:
            lowb1=[x,y]
            minb1 = b1
        if b1>maxb1:
            highb1=[x,y]
            maxb1 = b1
        if b2<minb2:
            lowb2=[x,y]
            minb2 = b2
        if b2>maxb2:
            highb2=[x,y]
            maxb2 = b2
            
candidate1 = highb1[0]-lowb1[0]+highb1[1]-lowb1[1]
candidate2 = lowb2[0]-highb2[0]+highb2[1]-lowb2[1]
print(max(candidate1,candidate2))

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

edge=[ab[0][0],ab[0][1],ab[0][0],ab[0][1],ab[0][0],ab[0][1],ab[0][0],ab[0][1]]
tate = 0
yoko = 0
summ = 10**10
sumn = 0

for i in range(n):
    x = ab[i][0]
    y = ab[i][1]
    if x+y <= summ :
        edge[0] = x
        edge[1] = y
        summ = x+y
    if x+y >= sumn :
        edge[2] = x
        edge[3] = y
        sumn = x+y
    if x-y <= tate:
        edge[4] =x
        edge[5] =y
        tate = x-y
    if y-x <= yoko:
        edge[6] =x
        edge[7] =y
        yoko = y-x

a = abs(edge[0]-edge[2]) +abs(edge[1]-edge[3])
b = abs(edge[0]-edge[4]) +abs(edge[1]-edge[5])
c = abs(edge[0]-edge[6]) +abs(edge[1]-edge[7])
d = abs(edge[2]-edge[4]) +abs(edge[3]-edge[5])
e = abs(edge[2]-edge[6]) +abs(edge[3]-edge[7])
f = abs(edge[4]-edge[6]) +abs(edge[5]-edge[7])

print(max(a,b,c,d,e,f))

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    n = int(input())
    XY = [tuple(map(int,input().split())) for i in range(n)]
    XY.sort()
    ans = 0
    SXY = [[0,0,0] for i in range(n)]
    for i in range(n):
        SXY[i][0] = XY[i][0] + XY[i][1] 
        SXY[i][1] = XY[i][0]
        SXY[i][2] = XY[i][1]
    SXY.sort()
    ans = abs(SXY[0][1]-SXY[-1][1])+abs(SXY[0][2]-SXY[-1][2]) 
    SXY = [[0,0,0] for i in range(n)]
    for i in range(n):
        SXY[i][0] = XY[i][1] - XY[i][0] 
        SXY[i][1] = XY[i][0]
        SXY[i][2] = XY[i][1]
    SXY.sort()
    ans = max(ans,abs(SXY[0][1]-SXY[-1][1])+abs(SXY[0][2]-SXY[-1][2])) 
    print(ans)

if __name__=='__main__':
    main()

Solution (Python):
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
p = []
q = []
i = 0
while i < N:
  p.append(x[i]+y[i])
  q.append(x[i]-y[i])
  i += 1
print(max(max(p)-min(p),max(q)-min(q)))

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

def get_ans2(tpl1, tpl2):
    ans2 = abs(tpl1[0]-tpl2[0])+abs(tpl1[1]-tpl2[1])
    return ans2

lst=[]
mx_dis1, mn_dis1 = 0, 10**9
mx_y = 0
mn_y = 10**9
mx_y_idx = -1
mn_y_idx = -1
mx_x = 0
mn_x = 10**9
mx_x_idx = -1
mn_x_idx = -1
for i in range(n):
    x, y = map(int, input().split())
    lst.append((x,y))
    dis1 = x + y
    dis2 = abs(x-y)
    mx_dis1 = max(dis1, mx_dis1)
    mn_dis1 = min(dis1, mn_dis1)
    if x>=y:
        if dis2 > mx_x:
            mx_x = dis2
            mx_x_idx = i
        if dis2 < mn_x:
            mn_x = dis2
            mn_x_idx=i
    else:
        if dis2 > mx_y:
            mx_y = dis2
            mx_y_idx = i
        if dis2 < mn_y:
            mn_y = dis2
            mn_y_idx = i
    

ans1 = mx_dis1-mn_dis1

if mx_x_idx<0:
    ans2 = get_ans2(lst[mx_y_idx], lst[mn_y_idx])
elif mn_y_idx<0:
    ans2 = get_ans2(lst[mx_x_idx], lst[mn_x_idx])
else:
    ans2 = get_ans2(lst[mx_x_idx], lst[mx_y_idx])

print(max(ans2, ans1))

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
xy = [[] for _ in range(n)]
f1 = []
f2 = []
for i in range(n):
    x, y = map(int, input().split())
    f1.append(x + y)
    f2.append(x - y)
    xy[i].append(x + y)
    xy[i].append(abs(-x - y))

print(max(max(f1) - min(f1), max(f2) - min(f2)))

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

def main():
    N = int(readline())
    m = map(int,read().split())
    XY = list(zip(m,m))

    ans = 0
    z = [x-y for (x, y) in XY]
    
    z.sort()
    ans = z[-1] - z[0]
    z = [x+y for (x, y) in XY]
    
    z.sort()
    ans = max(ans, z[-1] - z[0])

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
l = float("inf")
r = -float("inf")
b = float("inf")
a = -float("inf")
lis = []
for i in range(n):
  j,k=map(int, input().split())
  if j>r:
    r=j
  if j<l:
    l=j
  if k>a:
    a=k
  if k<b:
    b=k
  lis.append([j, k])
  
lb = -1
lbd = float("inf")

rb = -1
rbd = float("inf")

for i in range(n):
  j, k = lis[i]
  if abs(j-l)+abs(k-b)<lbd:
    lbd =  abs(j-l)+abs(k-b)
    lb=i
  if abs(r-j)+abs(k-b)<rbd:
    rbd =  abs(r-j)+abs(k-b)
    rb=i
  
ans = 0
for i in range(n):
  a, b = lis[lb]
  j, k = lis[i]
  if abs(a-j)+abs(b-k)>ans:
    ans=abs(a-j)+abs(b-k)

for i in range(n):
  a, b = lis[rb]
  j, k = lis[i]
  if abs(a-j)+abs(b-k)>ans:
    ans=abs(a-j)+abs(b-k)
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    n = int(input())
    XY = [tuple(map(int,input().split())) for i in range(n)]
    XY.sort()
    ans = 0
    SXY = [[0,0,0] for i in range(n)]
    for i in range(n):
        SXY[i][0] = XY[i][0] + XY[i][1] 
        SXY[i][1] = XY[i][0]
        SXY[i][2] = XY[i][1]
    SXY.sort()
    ans = abs(SXY[0][1]-SXY[-1][1])+abs(SXY[0][2]-SXY[-1][2]) 
    SXY = [[0,0,0] for i in range(n)]
    for i in range(n):
        SXY[i][0] = XY[i][1] - XY[i][0] 
        SXY[i][1] = XY[i][0]
        SXY[i][2] = XY[i][1]
    SXY.sort()
    ans = max(ans,abs(SXY[0][1]-SXY[-1][1])+abs(SXY[0][2]-SXY[-1][2])) 
    print(ans)

if __name__=='__main__':
    main()

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

d = [0] * N
s = [0] * N
    
for i in range(N):
  d[i] = x[i] - y[i]
  s[i] = x[i] + y[i]


print(max(max(s)-min(s), max(d)-min(d)))

Solution (Python):
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy


MOD = 10 ** 9 + 7




n = int(input())
A = [list(map(int, input().split())) for i in range(n)]
d1 = [A[i][0] - A[i][1] for i in range(n)]
d2 = [A[i][0] + A[i][1] for i in range(n)]

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

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

for i in ten:
    x = i[0]
    y = i[1]
    i[0] = x-y
    i[1] = x+y

xmax = i[0]
xmin = i[0]
ymax = i[1]
ymin = i[1]
for i in ten:
    xmax = max(xmax,i[0])
    xmin = min(xmin,i[0])
    ymax = max(ymax,i[1])
    ymin = min(ymin,i[1])

print(max(xmax-xmin,ymax-ymin))

Solution (Python):

N=int(input())
kouho=[(10**10)*(-1)]*4
kouho[2]=10**10
kouho[3]=10**10
ans=0
for i in range(N):
    x,y=map(int,input().split())
    newx=x-y
    newy=x+y
    if newx>kouho[0]:
        kouho[0]=newx
    if newx<kouho[2]:
        kouho[2]=newx
    if newy>kouho[1]:
        kouho[1]=newy
    if newy<kouho[3]:
        kouho[3]=newy
ans=max(kouho[0]-kouho[2],kouho[1]-kouho[3])
print(ans)

Solution (Python):

import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()

    pairs = []

    for i in range(N):
        x, y = MI()
        pairs.append((x, y))

    modified = []

    max_a = -1 * 10 ** 9
    min_a = 10 ** 9
    max_b = -1 * 10 ** 9
    min_b = 10 ** 9

    for i in range(len(pairs)):
        x, y = pairs[i]
        modified.append([x - y, x + y])

        max_a = max(max_a, x-y)
        min_a = min(min_a, x-y)
        max_b = max(max_b, x+y)
        min_b = min(min_b, x+y)

    ans = max(max_a - min_a, max_b - min_b)
    print(ans)


main()

Solution (Python):
import numpy as np

def dist(d1, d2):
    return abs(d1[0]-d2[0]) + abs(d1[1]-d2[1])

n = int(input())
list1 = np.zeros((n))
list2 = np.zeros((n))
xy_list = []
for i in range(n):
    x, y = map(int, input().split())
    xy_list.append([x, y])
    list1[i] = x+y
    list2[i] = x-y

num = np.zeros((4), dtype=int)
num[0] = np.argmax(list1)
num[1] = np.argmax(list2)
num[2] = np.argmin(list1)
num[3] = np.argmin(list2)

ans = 0
for d1 in range(4):
    for d2 in range(d1+1, 4):
        
        ans = max(ans, dist(xy_list[num[d1]], xy_list[num[d2]]))

print(ans)

Solution (Python):
n = int(input())
pmax = 0
pmin = 0
mmax = 0
mmin = 0
for i in range(n):
    x, y = map(int, input().split())
    if(i ==0 or pmax < x + y):
        pmax = x+y
    if(i == 0 or pmin > x+y):
        pmin = x+y
    if(i == 0 or mmax < x-y):
        mmax = x-y
    if(i == 0 or mmin > x-y):
        mmin = x-y
print(max(pmax - pmin, mmax - mmin))

Solution (Python):

(n,), *d = [[*map(int, o.split())] for o in open(0)]
M = [[x - y for x, y in d], [x + y for x, y in d]]
print(max(max(M[d]) - min(M[d]) for d in [0, 1]))

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

for i in range(N):
    a[i].append(a[i][0] + a[i][1])
    a[i].append(a[i][0] - a[i][1])

a = sorted(a, key = lambda x: x[2])
candidate1 = abs(a[0][0] - a[-1][0]) + abs(a[0][1] - a[-1][1])

a = sorted(a, key = lambda x: x[3])
candidate2 = abs(a[0][0] - a[-1][0]) + abs(a[0][1] - a[-1][1])

print(max([candidate1, candidate2]))

Solution (Python):
n=int(input())
ma=2
mi=10**9+7
mu=2
me=10**10
for i in range(n):
    x,y=map(int,input().split())
    l=x+y
    s=-x+10**9+1+y
    ma=max(ma,l)
    mi=min(mi,l)
    mu=max(mu,s)
    me=min(me,s)
print(max(ma-mi,mu-me))

Solution (Python):
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
ma = -float('inf')
mi = float('inf')
for x,y in xy:
  ma = max(ma,x-y)
  mi = min(mi,x-y)
ans = ma - mi

ma = -float('inf')
mi = float('inf')
for x,y in xy:
  ma = max(ma,x+y)
  mi = min(mi,x+y)
  
ans = max(ans, ma - mi)
print(ans)

Solution (Python):
import sys
import itertools

import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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


ans = -INF
now = abs(C[-1][1] - C[0][1]) + abs(C[-1][2] - C[0][2])
ans = max(ans, now)
now = abs(D[-1][0] - D[0][0])
ans = max(ans, now)
print(ans)

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

che_x=[0]*n
che_y=[0]*n

for i in range(n):
    che_x[i]=x[i]-y[i]
    che_y[i]=x[i]+y[i]

ans=max(max(che_x)-min(che_x),max(che_y)-min(che_y))

print(ans)

Solution (Python):
n = int(input())
fx_list = []
fy_list = []

for i in range(n):
    x,y = (int(x) for x in input().split())
    fx_list.append(x-y)
    fy_list.append(x+y)

a = max(fx_list) - min(fx_list)
b = max(fy_list) - min(fy_list)

print(max([a,b]))

Solution (Python):
n = int(input())
dist = []
max1 = -pow(10, 11)
min1 = pow(10, 11)
max2 = -pow(10, 11)
min2 = pow(10, 11) 
for i in range(n):
    x, y = (int(x) for x in input().split())
    if max1 < x + y:
        max1 = x + y
    if min1 > x + y:
        min1 = x + y
    if max2 < x - y:
        max2 = x - y
    if min2 > x - y:
        min2 = x - y
print(max(max1-min1, max2-min2))

Solution (Python):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
pos = []
for i in range(N):
	x, y = rl()
	pos.append((x,y))

pp = []
pm = []
mm = []
mp = []
for x, y in pos:
	pp.append(x+y)
	pm.append(x-y)
	mm.append(-x-y)
	mp.append(-x+y)
max_pp = max(pp)
max_pm = max(pm)
max_mm = max(mm)
max_mp = max(mp)

ans = max(max_pp+max_mm, max_pm+max_mp, max_mp+max_pm, max_mm+max_pp)
print(ans)

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

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

f0_list = [x+y for x, y in p_list]
f1_list = [x-y for x, y in p_list]

max_f0 = max(f0_list) - min(f0_list)
max_f1 = max(f1_list) - min(f1_list)

print(max([max_f0, max_f1]))

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
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 LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


N = I()
xy = [tuple(MI()) for _ in range(N)]
A = [sum(xy[i]) for i in range(N)]
a = max(A)-min(A)
B = []
for i in range(N):
    x,y = xy[i]
    B.append(x-y)
b = max(B)-min(B)

print(max(a,b))

Solution (Python):
n = int(input())
i = []
for z in range(n):
    i.append([int(s) for s in input().split()])

ur = [ind[0]+ind[1] for ind in i]
ul = [ind[0]-ind[1] for ind in i]
print(max([max(ur)-min(ur), max(ul)-min(ul)]))

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

result = max(max(xsum)-min(xsum), max(xsub)-min(xsub))
print(result)

Solution (Python):
def main():
    point_count = int(input())
    sums = []
    diffs = []
    for _ in range(point_count):
        x, y = [int(x) for x in input().split()]
        sums.append(x + y)
        diffs.append(x - y)
    pat_sum = max(sums) - min(sums)  
    pat_diff = max(diffs) - min(diffs)  
    return max(pat_sum, pat_diff)


if __name__ == '__main__':
    print(main())

Solution (Python):
import sys


N = int(sys.stdin.readline())
points = []
for _ in range(N):
    x, y = map(int, sys.stdin.readline().split())
    points.append((x, y))

f1 = []
f2 = []
for (x, y) in points:
    f1.append(x-y)
    f2.append(x+y)

ans = max(max(f1) - min(f1), max(f2) - min(f2))
print(ans)

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

mx = 9
L = [0] * N
for i in range(N):
  x, y = xy[i]
  L[i] = x + y
  mx = max(mx, x)

L.sort()
ans = L[-1] - L[0]

for i in range(N):
  x, y = xy[i]
  L[i] = mx - x + y

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

print(ans)

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

Solution (Python):
def main():
    point_count = int(input())
    sums = set()
    diffs = set()
    for _ in range(point_count):
        x, y = [int(x) for x in input().split()]
        sums.add(x + y)
        diffs.add(x - y)
    pat_sum = max(sums) - min(sums)  
    pat_diff = max(diffs) - min(diffs)  
    return max(pat_sum, pat_diff)


if __name__ == '__main__':
    print(main())

Solution (Python):
N = int(input())
xy = []
xplusy = []
xminusy = []

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


ans1 = max(xplusy) - min(xplusy)
ans2 = max(xminusy) - min(xminusy)

print(max(ans1, ans2))

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


if __name__ == '__main__':
    resolve()

Solution (Python):
def dist(p, q):
    return abs(p[0] - q[0]) + abs(p[1] - q[1])

n = int(input())
ans = 0
peri = []
P = [tuple(map(int, input().split())) for _ in range(n)]
P.sort(key=lambda p: (p[0], p[1]))
peri.append(max(P, key=lambda p: (p[0], p[1])))
peri.append(min(P, key=lambda p: (p[0], p[1])))
peri.append(max(P, key=lambda p: (p[0], -p[1])))
peri.append(min(P, key=lambda p: (p[0], -p[1])))
peri.append(max(P, key=lambda p: (-p[0], p[1])))
peri.append(min(P, key=lambda p: (-p[0], p[1])))
peri.append(max(P, key=lambda p: (-p[0], -p[1])))
peri.append(min(P, key=lambda p: (-p[0], -p[1])))
peri.append(max(P, key=lambda p: (p[1], p[0])))
peri.append(min(P, key=lambda p: (p[1], p[0])))
peri.append(max(P, key=lambda p: (-p[1], p[0])))
peri.append(min(P, key=lambda p: (-p[1], p[0])))
peri.append(max(P, key=lambda p: (p[1], -p[0])))
peri.append(min(P, key=lambda p: (p[1], -p[0])))
peri.append(max(P, key=lambda p: (-p[1], -p[0])))
peri.append(min(P, key=lambda p: (-p[1], -p[0])))
peri.append(max(P, key=lambda p: p[0]+p[1]))
peri.append(max(P, key=lambda p: -p[0]+p[1]))
peri.append(max(P, key=lambda p: p[0]-p[1]))
peri.append(max(P, key=lambda p: -p[0]-p[1]))

peri = set(peri)

for p in P:
    for q in peri:
        ans = max(ans, dist(p, q))
print(ans)

Solution (Python):
import numpy as np

N = int(input())
X = []
Y = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
cx = sum(X)/N
cy = sum(Y)/N
dist1 = []
dist2 = []

for x, y in zip(X, Y):
    dist1_ = x-cx + y-cy
    dist1.append(dist1_)
    dist2_ = (x-cx) - (y-cy)
    dist2.append(dist2_)

p1_max = np.argmax(np.array(dist1))
p1_min = np.argmin(np.array(dist1))
p2_max = np.argmax(np.array(dist2))
p2_min = np.argmin(np.array(dist2))

ans1 = abs(X[p1_max] - X[p1_min]) + abs(Y[p1_max] - Y[p1_min])
ans2 = abs(X[p2_max] - X[p2_min]) + abs(Y[p2_max] - Y[p2_min]) 

print(max(ans1, ans2))

Solution (Python):
from itertools import product


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


N, *xy = map(int, open(0).read().split())
points = [(x, y) for x, y in zip(*[iter(xy)] * 2)]
values = [-float("inf") for _ in range(4)]
outrims = [points[0], points[0], points[0], points[0]]
for x, y in points:
    for i, (opx, opy) in enumerate(product([1, -1], repeat=2)):
        v = opx * x + opy * y
        if v > values[i]:
            values[i] = v
            outrims[i] = (x, y)

ans = 0
for p in points:
    for o in outrims:
        ans = max(ans, dist(p, o))
print(ans)

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

l.sort()
lans.sort()

print(max(l[-1]-l[0],lans[-1]-lans[0]))

'''
  ll1=[ll[1],ll[0]]
  lan.append(ll1)

l.sort()
lan.sort()
we=abs(l[0][0]-l[-1][0])+abs(l[0][1]-l[-1][1])
we1=abs(lan[0][0]-lan[-1][0])+abs(lan[0][1]-lan[-1][1])
print(max(we,we1))
'''

Solution (Python):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    x = []
    y = []

    N = NI()

    for _ in range(N):
        a,b = LI()
        x.append(a+b)
        y.append(a-b)

    xm = max(x) - min(x)
    ym = max(y) - min(y)

    print(max(ym,xm))



if __name__ == '__main__':
    main()

Solution (Python):

import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys


readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XY):
    X, Y = [], []
    for x, y in XY:
        X.append(x+y)
        Y.append(x-y)
    X.sort()
    Y.sort()

    return max(X[-1]-X[0], Y[-1]-Y[0])


def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]
    print(slv(N, XY))


if __name__ == '__main__':
    main()

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

d0 = [0]*n
d1 = [0]*n
for i,[x,y] in enumerate(x) :
    d0[i] = x-y
    d1[i] = x+y
print(max(max(d0)-min(d0), max(d1)-min(d1)))

Solution (Python):



def maximize(ps):
    zs = sorted(x + y for x, y in ps)
    ws = sorted(x - y for x, y in ps)
    return max(abs(zs[0] - zs[-1]), abs(ws[0] - ws[-1]))


def main():
    n = int(input())
    ps = []
    for _ in range(n):
        ps.append(tuple(int(z) for z in input().split()))
    res = maximize(ps)
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):

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

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())
    ru = None
    rd = None
    lu = None
    ld = None

    for i in range(n):
        row = [int(x) for x in input().rstrip().split(" ")]
        if i == 0:
            ru = row
            rd = row
            lu = row
            ld = row
            continue

        if ru[0] + ru[1] < row[0] + row[1]:
            ru = row
        if rd[0] - rd[1] < row[0] - row[1]:
            rd = row
        if -lu[0] + lu[1] < -row[0] + row[1]:
            lu = row
        if -ld[0] - ld[1] < -row[0] - row[1]:
            ld = row

    ans = 0
    points = [ru, rd, lu, ld]
    for i in range(4):
        for j in range(i+1, 4):
            tmp = dist(points[i], points[j])
            if ans < tmp:
                ans = tmp

    print(ans)


if __name__ == "__main__":
    resolve()

Solution (Python):
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

one=-float('inf')
two=-float('inf')
ans=0
for i in range(n):
    x,y=xy[i]
    ans=max(ans,x+max(y+one,two-y))
    one=max(one,-(x+y))
    two=max(two,y-x)
print(ans)

Solution (Python):
N = int(input())
X,Y = [],[]
def func(p):
    return p[0]-p[1], p[0]+p[1]
for _ in range(N):
    x,y = func(list(map(int,input().split())))
    X.append(x)
    Y.append(y)
ans = 0
ans = max(max(X)-min(X),max(Y)-min(Y))
print(ans)

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

Solution (Python):
n=int(input())
xy=[list(map(int, input().split())) for _ in range(n)]
a1=0
a2=xy[0][0]+xy[0][1]
b1=xy[0][0]-xy[0][1]
b2=xy[0][0]-xy[0][1]
for i in range(n):
    res1=xy[i][0]+xy[i][1]
    res2=xy[i][0]-xy[i][1]
    a1=max(a1,res1)
    a2=min(a2,res1)
    b1=max(b1,res2)
    b2=min(b2,res2)
ans=max(a1-a2,b1-b2)
print(ans)

Solution (Python):

N = int(input())


from_0 = [(10**9, 10**9), (0,0)]
from_f = [(10**9, 10**9), (0,0)]

for i in range(N):
    x,y = map(int, input().split())
    if x + y < from_0[0][0] + from_0[0][1]:
        from_0[0] = (x,y)
    if x + y > from_0[1][0] + from_0[1][1]:
        from_0[1] = (x,y)
    
    new_y = 10**9 - y
    if x + new_y < from_f[0][0] + from_f[0][1]:
        from_f[0] = (x,new_y)
    if x + new_y > from_f[1][0] + from_f[1][1]:
        from_f[1] = (x,new_y)
    
dist_0 = abs(from_0[1][0] - from_0[0][0]) + abs(from_0[1][1] - from_0[0][1])
dist_f = abs(from_f[1][0] - from_f[0][0]) + abs(from_f[1][1] - from_f[0][1])
print(max(dist_0, dist_f))

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

max_s = 1 - (10 ** 9)
min_s = 2 * (10 ** 9)
max_t = 1 - (10 ** 9)
min_t = 2 * (10 ** 9)
for _ in range(n):
    x, y = map(int, input().split())
    s = x - y
    t = x + y
    
    max_s = max(max_s, s)
    min_s = min(min_s, s)
    max_t = max(max_t, t)
    min_t = min(min_t, t)

print(max(max_s - min_s, max_t - min_t))

Solution (Python):
n = int(input())
d1 = []
d2 = []
for _ in range(n):
    a,b = map(int,input().split())
    d1.append(a+b)
    d2.append(a-b)
print(max(max(d1)-min(d1),max(d2)-min(d2)))

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

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

def main(n,x):
    x.sort()
    xmax = [0,x[0][1]+x[0][0]]
    xmin = [0,x[0][1]+x[0][0]]
    for i in range(1,n):
        idx = x[i]
        s = idx[1]+idx[0]
        if s>xmax[1]:
            xmax = [i,s]
        elif s<xmin[1]:
            xmin = [i,s]
    m1 = abs(x[xmax[0]][0]-x[xmin[0]][0])+abs(x[xmax[0]][1]-x[xmin[0]][1])
    ymax = [0,x[0][1]-x[0][0]]
    ymin = [0,x[0][1]-x[0][0]]
    for i in range(1,n):
        idx = x[i]
        s = idx[1]-idx[0]
        if s>ymax[1]:
            ymax = [i,s]
        elif s<ymin[1]:
            ymin = [i,s]
    m2 = abs(x[ymax[0]][0]-x[ymin[0]][0])+abs(x[ymax[0]][1]-x[ymin[0]][1])
    print(max(m1,m2))
    

if __name__=="__main__":
    n,x = getval()
    main(n,x)

Solution (Python):
def main():
    point_count = int(input())
    sums = []
    diffs = []
    for _ in range(point_count):
        x, y = [int(x) for x in input().split()]
        sums.append(x + y)
        diffs.append(x - y)
    pat_sum = abs(max(sums) - min(sums))
    pat_diff = abs(max(diffs) - min(diffs))
    return max(pat_sum, pat_diff)


if __name__ == '__main__':
    print(main())

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

def dist(a,b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])
def calc(xy):
    mn1 = min(xy, key=lambda z: z[0]+z[1])
    mx1 = max(xy, key=lambda z: z[0]+z[1])

    mn2 = min(xy, key=lambda z: z[0]-z[1])
    mx2 = max(xy, key=lambda z: z[0]-z[1])

    return max(dist(mn1, mx1), dist(mn2, mx2))
    
print(calc(xy))