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 l_inf_dist(x,y,x0,y0):
    return max(abs(x - x0), abs(y - y0))

N = int(input())
pts = [tuple(map(int, input().split())) for _ in range(N)]
pts_conv_x = [pts[i][1] + pts[i][0] for i in range(N)]
pts_conv_y = [pts[i][1] - pts[i][0] for i in range(N)]

x_max_ind = pts_conv_x.index(max(pts_conv_x))
x_min_ind = pts_conv_x.index(min(pts_conv_x))
y_max_ind = pts_conv_y.index(max(pts_conv_y))
y_min_ind = pts_conv_y.index(min(pts_conv_y))

x_max_pt = (pts_conv_x[x_max_ind], pts_conv_y[x_max_ind])
x_min_pt = (pts_conv_x[x_min_ind], pts_conv_y[x_min_ind])
y_max_pt = (pts_conv_x[y_max_ind], pts_conv_y[y_max_ind])
y_min_pt = (pts_conv_x[y_min_ind], pts_conv_y[y_min_ind])

dist_max = 0
for i in range(N):
    dist_max = max(dist_max, l_inf_dist(x_max_pt[0], x_max_pt[1], pts_conv_x[i], pts_conv_y[i]), l_inf_dist(x_min_pt[0], x_min_pt[1], pts_conv_x[i], pts_conv_y[i]), l_inf_dist(y_max_pt[0], y_max_pt[1], pts_conv_x[i], pts_conv_y[i]), l_inf_dist(y_min_pt[0], y_min_pt[1], pts_conv_x[i], pts_conv_y[i]))

print(dist_max)

Solution (Python):
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

N = INT()
U = []
V = []
for i in range(N):
    x, y = MAP()
    U.append(x+y)
    V.append(x-y)

U.sort()
V.sort()
ans = max(U[-1]-U[0], V[-1]-V[0])
print(ans)

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

X = []
Y = []
ans = 0

for i in range(N):
    x, y = map(int, input().split())
    X.append(x+y)
    Y.append(x-y)
    
m = [max(X), max(Y)]
s = [min(X), min(Y)]
    
for i in range(2):
    ans = max(ans, m[i]-s[i])
    
print(ans)

Solution (Python):
from math import *
import fractions
import sys
import collections
import itertools
import pprint
from collections import deque
from heapq import *
import copy
N=int(input())
points=[list(map(int,input().split())) for _ in range(N)]


chebmax0=-float("inf")
chebmin0=float("inf")
chebmax1=-float("inf")
chebmin1=float("inf")


for l in points:
    chebmax0=max(chebmax0,l[0]-l[1])
for l in points:
    chebmin0=min(chebmin0,l[0]-l[1])
for l in points:
    chebmax1=max(chebmax1,l[0]+l[1])
for l in points:
    chebmin1=min(chebmin1,l[0]+l[1])

print(max(chebmax0-chebmin0,chebmax1-chebmin1))

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

tmp1 = max(data_pp) + max(data_mm)
tmp2 = max(data_mp) + max(data_pm)
tmp3 = max(data_pm) + max(data_mp)
tmp4 = max(data_mm) + max(data_pp)
print(max(tmp1, tmp2, tmp3, tmp4))
def d(p1, p2):
    xA = p1[0]
    xB = p2[0]

    yA = p1[1]
    yB = p2[1]
    return max(xA + yA - (xB + yB), - (xA - yA) - -1 * (xB - yB), xA - yA - (xB - yB), -1*(xA + yA)- -1 * (xB + yB))

Solution (Python):
input=__import__('sys').stdin.readline
def getdist(a,b):return abs(a[0]-b[0])+abs(a[1]-b[1])
n=int(input())
s=[]
for _ in range(n):s.append([*map(int,input().split())])
ans=0
def ff1(x):return x[0]+x[1]
def ff2(x):return x[0]-x[1]
f1=sorted(s,key=ff1)
f2=sorted(s,key=ff2)
ans=max(ans,getdist(f1[0],f1[-1]))
ans=max(ans,getdist(f1[0],f1[1]))
ans=max(ans,getdist(f1[-1],f1[-2]))
ans=max(ans,getdist(f2[0],f2[-1]))
ans=max(ans,getdist(f2[0],f2[1]))
ans=max(ans,getdist(f2[-1],f2[-2]))
print(ans)

Solution (Python):
import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():
    N = in_n()
    xy_diff = [0] * N
    xy_plus = [0] * N

    for i in range(N):
        x, y = in_nn()
        xy_diff[i] = x - y
        xy_plus[i] = x + y

    d1 = max(xy_diff) - min(xy_diff)
    d2 = max(xy_plus) - min(xy_plus)

    print(max(d1, d2))


if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
x = [0]*N
y = [0]*N
f_0 = [0]*N
f_1 = [0]*N
for i in range(N):
    x[i],y[i] = map(int, input().split())
    f_0[i] = x[i] - y[i]
    f_1[i] = x[i] + y[i]
    
print(max(max(f_0)-min(f_0),max(f_1)-min(f_1)))

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

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

L1 = [i[0] + i[1] for i in xy]
L2 = [i[0] - i[1] for i in xy]

m1 = max(L1) - min(L1)
m2 = max(L2) - min(L2)

print( max(m1, m2) )

Solution (Python):
n=int(input())
l_x=[]
l_y=[]

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

	l_x.append(x+y)
	l_y.append(x-y)

tmpx=max(l_x)-min(l_x)
tmpy=max(l_y)-min(l_y)

if tmpx>tmpy:
	print(tmpx)
else:
	print(tmpy)

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

n = int(input())

INF = float('inf')

plusmax = minusmax =-INF
plusmin = minusmin = INF

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

    x_minus_y = x-y
    x_plus_y = x+y

    plusmax = max(plusmax, x_plus_y)
    plusmin = min(plusmin, x_plus_y)
    minusmax = max(minusmax, x_minus_y)
    minusmin = min(minusmin, x_minus_y)

ans0 = plusmax - plusmin
ans1 = minusmax - minusmin
print( max(ans0, ans1))

Solution (Python):
input=__import__('sys').stdin.readline
def getdist(a,b):return abs(a[0]-b[0])+abs(a[1]-b[1])
n=int(input())
s=[]
for _ in range(n):s.append([*map(int,input().split())])
ans=0
sx=sorted(s)
sy=sorted(s,key=lambda x:x[1])
ans=max(ans,getdist(sx[-1],sx[-2]))
ans=max(ans,getdist(sx[0],sx[1]))
ans=max(ans,getdist(sy[-1],sy[-2]))
ans=max(ans,getdist(sy[0],sy[1]))
def ff1(x):return x[0]+x[1]
def ff2(x):return x[0]-x[1]
f1=sorted(s,key=ff1)
f2=sorted(s,key=ff2)
ans=max(ans,getdist(f1[0],f1[-1]))
ans=max(ans,getdist(f1[0],f1[1]))
ans=max(ans,getdist(f1[-1],f1[-2]))
ans=max(ans,getdist(f2[0],f2[-1]))
ans=max(ans,getdist(f2[0],f2[1]))
ans=max(ans,getdist(f2[-1],f2[-2]))
def ff1(x):return abs(x[0]+x[1])
def ff2(x):return abs(x[0]-x[1])
f1=sorted(s,key=ff1)
f2=sorted(s,key=ff2)
ans=max(ans,getdist(f1[0],f1[-1]))
ans=max(ans,getdist(f1[0],f1[1]))
ans=max(ans,getdist(f1[-1],f1[-2]))
ans=max(ans,getdist(f2[0],f2[-1]))
ans=max(ans,getdist(f2[0],f2[1]))
ans=max(ans,getdist(f2[-1],f2[-2]))
print(ans)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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

    ans = max(max(A)-min(A), max(B)-min(B))
    print(ans)


if __name__ == '__main__':
    main()

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

arr1=sorted(arr1)
p=arr1[-1]-arr1[0]
arr2=sorted(arr2)
q=arr2[-1]-arr2[0]
print(max(p,q))

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):
n = int(input())
mi0,ma0 = 10**9,-(10**9)
mi1,ma1 = 10**9,-(10**9)
for i in range(n):
    a,b = map(int, input().split())
    c,d = a-b,a+b
    if c < mi0:
        mi0 = c
    if c > ma0:
        ma0 = c
    if d < mi1:
        mi1 = d
    if d > ma1:
        ma1 = d
print(max(ma0-mi0,ma1-mi1))

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

top1= -10**10
bot1= 10**10
top2= -10**10
bot2= 10**10
for _ in range(n):
	
	x,y = map(int, input().split(' '))
	tot1= x+y
	tot2= x-y
	if tot1> top1:
		top1= tot1
	if tot1< bot1:
		bot1= tot1
	if tot2>top2:
		top2= tot2
	if tot2<bot2:
		bot2= tot2

print(max(top1-bot1, top2-bot2))

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

ans = 0
for i in range(2):
    ans = max(ans, max(d[i])-min(d[i]))
print(ans)

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


ans = -float("inf")

left = -float("inf")
right = float("inf")
for i in range(N):
    left = max(left, X[i]-Y[i])
    right = min(right, X[i]-Y[i])

ans = max(ans, left - right)

left = -float("inf")
right = float("inf")
for i in range(N):
    left = max(left, X[i]+Y[i])
    right = min(right, X[i]+Y[i])

ans = max(ans, left - right)

print(ans)

Solution (Python):

MOD = 10 ** 9 + 7
INFI = 10**10

import math
from collections import deque
import itertools
import heapq

from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint




def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default




def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def soinsubunkai_e(n,m): 
    a = set()
    i = 1
    while n>1:
        a.add(m[n])
        n=n//m[n]
    nokori=n
    a.add(nokori)
    return a

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def era(n): 
    b=[i for i in range(n+1)]
    for i in range(2,int(math.sqrt(n)+10)):
        j=1
        temp=i*j
        while temp<=n:
            b[temp]=min(i,b[temp])
            temp+=i
    return b


def main():
    
    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=sorted(a)
    b=sorted(b)
    aa=abs(a[0]-a[-1])
    bb=abs(b[0]-b[-1])
    print(max(aa,bb))












if __name__ == "__main__":

    main()

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

x.sort()
y.sort()

print(max(abs(y[0] - y[-1]), abs(x[-1] - x[0])) if x and y else abs(x[-1] - x[0]) if x else abs(y[0] - y[-1]))

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


p=max(M)-min(M)
q=max(N)-min(N)
print(max(p,q))

Solution (Python):

import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter

from functools import lru_cache
import copy


input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7




def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])




n = inp()
data = [inpl() for _ in range(n)]
lotate_x = [x - y for x, y in data]
lotate_y = [x + y for x, y in data]
ans = max(max(lotate_x) - min(lotate_x), max(lotate_y) - min(lotate_y))
print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

INF = float("inf")


from scipy.spatial.distance import chebyshev
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
ans = 0
plus = []
minus = []
for i in range(N):
    li = xy[i]
    x = li[0]
    y = li[1]
    plus.append(x+y)
    minus.append(x-y)
ans = 0
ans = max(max(plus)-min(plus),max(minus)-min(minus))
print(ans)

Solution (Python):
N = int(input())
a14=set([])
a23=set([])
for _ in range(N):
	x,y=map(int, input().split())
	a14.add(x+y)
	a23.add(x-y)


b14=max(a14)-min(a14)
b23=max(a23)-min(a23)

print(max(b14,b23))

Solution (Python):

N=int(input())
za=list()
for i in range(N):
    za.append(list(map(int,input().split())))
che=list()
for i in range(N):
    a=za[i][0]-za[i][1]
    b=za[i][0]+za[i][1]
    che.append([a,b])
dai1=-1*10**9
syou1=2*(10**9)
dai2=-1*10**9
syou2=2*(10**9)
ans1=0
ans2=0
for i in range(N):
    dai1=max(dai1,che[i][0])
    syou1=min(syou1,che[i][0])
    dai2=max(dai2,che[i][1])
    syou2=min(syou2,che[i][1])
ans1=dai1-syou1
ans2=dai2-syou2
print(max(ans1,ans2))

Solution (Python):
n = int(input())
max_XminusY = -float('inf')
min_XminusY =  float('inf')
max_XplusY  = -float('inf')
min_XplusY  =  float('inf')

for _ in range(n):
    x, y = map(int, input().split())
    max_XminusY = max(max_XminusY, x - y)
    min_XminusY = min(min_XminusY, x - y)
    max_XplusY  = max(max_XplusY, x + y)
    min_XplusY  = min(min_XplusY, x + y)

print(max(abs(max_XminusY - min_XminusY), abs(max_XplusY - min_XplusY)))

Solution (Python):

import sys


def solve(N: int, x):
    x = list(set(x))
    xs = [_[0] for _ in x]
    ys = [_[1] for _ in x]
    sum_n = [x_+y_ for x_, y_ in zip(xs, ys)]
    sum_m = [x_-y_ for (x_,y_) in zip(xs, ys)]

    a = max(max(sum_n)- min(sum_n), max(sum_m)-min(sum_m))
    print(a)
    

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    x = [()] * (N)  
    y = [int()] * (N)  
    for i in range(N):
        x[i] = (int(next(tokens)),int(next(tokens)))
    solve(N, x)

if __name__ == '__main__':
    main()

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

a = [x[i]+y[i] for i in range(n)]
b = [x[i]-y[i] for i in range(n)]
ans1 = max(a)-min(a)
ans2 = max(b)-min(b)
print(max(ans1,ans2))

Solution (Python):

from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    N = I()
    XY = LIR(N)

    Z = sorted([x+y for x, y in XY])
    W = sorted([x-y for x, y in XY])
    print(max(Z[-1] - Z[0], W[-1] - W[0]))

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=[[0 for j in range(2)] for i in range(n)]

hu=[-1,-10**9]
hs=[-1,2*(10**9)]
mu=[-1,0]
ms=[-1,10**9]

for i in range(n):
    x,y=map(int,input().split())
    a[i][0]=x
    a[i][1]=y
    z1=y-x
    z2=x+y
    if z1>hu[1]:
        hu[0]=i
        hu[1]=z1
    if z1<ms[1]:
        ms[0]=i
        ms[1]=z1
    if z2<hs[1]:
        hs[0]=i
        hs[1]=z2
    if z2>mu[1]:
        mu[0]=i
        mu[1]=z2

m=abs(a[mu[0]][0]-a[hs[0]][0]) + abs(a[mu[0]][1]-a[hs[0]][1])
h=abs(a[hu[0]][0]-a[ms[0]][0]) + abs(a[hu[0]][1]-a[ms[0]][1])

print(max(m, h))

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

x, y = map(int, input().split())

rt = (x, y)
rb = (x, y)
lt = (x, y)
lb = (x, y)

for _ in range(N-1):
    x, y = map(int, input().split())
    if (x + y - rt[0] - rt[1] > 0):
        rt = (x, y)
    if (x + y - lb[0] - lb[1] < 0):
        lb = (x, y)
    if (x - y - rb[0] + rb[1] > 0):
        rb = (x, y)
    if (x - y - lt[0] + lt[1] < 0):
        lt = (x, y)

def dist(p, q):
    return (abs(p[0]-q[0]) + abs(p[1]-q[1]))
print(max(dist(rt, lb), dist(rb, lt)))

Solution (Python):
n = int(input())
ps = []
ms = []
xs = []
ys = []
for i in range(n):
    x,y = map(int, input().split())
    ps.append(x+y)
    ms.append(x-y)
    xs.append(x)
    ys.append(y)
ps.sort()
ms.sort()
a1 = ps[-1]-ps[0]
a2 = ms[-1]-ms[0]
print(max(a1,a2))

Solution (Python):

def solve():
    N = int(input())
    Z = list(tuple(map(int,input().split())) for _ in range(N))
    L = []

    L1 = sorted(z[0]+z[1] for z in Z)
    L.append(L1[-1]-L1[0])

    L1 = sorted(z[0]-z[1] for z in Z)
    L.append(L1[-1]-L1[0])

    L1 = sorted(-z[0]+z[1] for z in Z)
    L.append(L1[-1]-L1[0])

    L1 = sorted(-z[0]-z[1] for z in Z)
    L.append(L1[-1]-L1[0])
    return str(max(L))

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

Solution (Python):
import sys
input = sys.stdin.readline
from math import gcd
from functools import reduce
from collections import defaultdict


def read():
    N = int(input().strip())
    XY = []
    for i in range(N):
        x, y = map(int, input().strip().split())
        XY.append((x, y))
    return N, XY


def solve(N, XY):
    ans = []
    XY.sort(key=lambda a: a[0] + a[1])
    x0, y0 = XY[0]
    x1, y1 = XY[-1]
    ans.append(abs(x1-x0) + abs(y1-y0))
    XY.sort(key=lambda a: a[1] - a[0])
    x0, y0 = XY[0]
    x1, y1 = XY[-1]
    ans.append(abs(x1-x0) + abs(y1-y0))
    return max(ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

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

ans = max([max(x) - min(x),max(y) - min(y)])
print(ans)

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

xzy = []
for _ in range(4):
  xzy.append([])

for x, y in xy:
  xzy[0].append(x + y)
  xzy[1].append(x - y)
  xzy[2].append(-x + y)
  xzy[3].append(-x - y)


anses = []
for z in xzy:
  anses.append(max(z) - min(z))
print(max(anses))

Solution (Python):


n = int(input())
point_set = set()
point_dict1 = {}
point_dict2 = {}
for i in range(n):
    x, y = map(int, input().split())
    point_set.add((x, y))
    point_dict1[x + y] = (x, y)
    point_dict2[y - x] = (x, y)
if len(point_set) == 1:
    print(0)
else:
    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):
import sys
def input(itr=iter(sys.stdin.readlines())):  
    return next(itr).rstrip('\n\r')


import math

N = int(input())

max_sum = -math.inf
min_sum = math.inf
max_diff = -math.inf
min_diff = math.inf
for _ in range(N):
    x, y = map(int, input().split())
    max_sum = max(max_sum, x+y)
    min_sum = min(min_sum, x+y)
    max_diff = max(max_diff, x-y)
    min_diff = min(min_diff, x-y)

answer = max(max_sum - min_sum, max_diff - min_diff)
print(answer)

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

f0 = []
f1 = []
for i in XY:
    f0.append(i[0]-i[1])
    f1.append(i[0]+i[1])

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

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




INF = 10 ** 20
MOD = 10 ** 9 + 7


ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
flush = lambda: sys.stdout.flush()



def main():
    n = ni()
    d = [na() for _ in range(n)]

    tINF = 10 ** 15

    max_numR = -INF
    min_numR = INF
    max_numL = -INF
    min_numL = INF

    for x, y in d:
        max_numR = max(max_numR, x + y)
        min_numR = min(min_numR, x + y)

        max_numL = max(max_numL, tINF - x + y)
        min_numL = min(min_numL, tINF - x + y)

    ans = max(max_numR - min_numR, max_numL - min_numL)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):






def modinv(n,p):
    return pow(n,p-2,p)

def main():
    
    

    n = int(input())
    coords = []
    for i in range(n):
        coords.append([int(x) for x in input().split()])
    
    r = int(1e9)
    x1, y1 = [0, 0]
    x2, y2 = [r, 0]
    x3, y3 = [0, r]
    x4, y4 = [r, r]

    d1 = []
    d2 = []
    d3 = []
    d4 = []
    
    for x, y in coords:
        d1.append(abs(x-x1) + abs(y - y1))
        d2.append(abs(x-x2) + abs(y - y2))
        d3.append(abs(x-x3) + abs(y - y3))
        d4.append(abs(x-x4) + abs(y - y4))

    d1.sort()
    d2.sort()
    d3.sort()
    d4.sort()

    
    
    
    

    print(max(d1[-1] - d1[0], d2[-1] - d2[0], d3[-1] - d3[0], d4[-1] - d4[0]))



py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

if __name__ == '__main__':
   main()

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

x = []
y = []
for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
d1_max = x[0]+y[0]
d1_min = x[0]+y[0]
d2_max = x[0] - y[0]
d2_min = x[0]-y[0]
ans = -1
for i in range(1,n):
    d1_max = max(d1_max,x[i]+y[i])
    d1_min = min(d1_min,x[i]+y[i])
    d2_max = max(d2_max,x[i] - y[i])
    d2_min = min(d2_min,x[i]-y[i])
    ans = max((d1_max-d1_min),(d2_max-d2_min))
print(ans)

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

Solution (Python):



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

n = int(input())
point = []
p = []
m = []
for i in range(n):
    a,b = mp()
    point.append((a,b))
    p.append(a+b)
    m.append(a-b)
print(max(max(p)-min(p), max(m)-min(m)))

Solution (Python):

N = int(input())
p_list = []
for _ in range(N):
    a, b = input().split()
    a, b = int(a), int(b)
    p_list.append((a, b))





def det(p, q):
    return p[0]*q[1] - p[1]*q[0]


def sub(p, q):
    return (p[0]-q[0], p[1]-q[1])

def convex_hull(points):
    
    n = len(points)
    points.sort()
    size_convex_hull = 0
    ch = []
    for i in range(n):
        while size_convex_hull > 1:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(points[i], ch[-2])
            if det(v_cur, v_new) > 0:
                break
            size_convex_hull -= 1
            ch.pop()
        ch.append(points[i])
        size_convex_hull += 1

    t = size_convex_hull
    for i in range(n-2, -1, -1):
        while size_convex_hull > t:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(points[i], ch[-2])
            if det(v_cur, v_new) > 0:
                break
            size_convex_hull -= 1
            ch.pop()
        ch.append(points[i])
        size_convex_hull += 1

    return ch[:-1]




""" try max time """




p_list = convex_hull(p_list)

from itertools import combinations

max_len = 0
for a, b in combinations(p_list, 2):
    max_len = max(max_len, abs(a[0] - b[0]) + abs(a[1] - b[1]))

print(max_len)

Solution (Python):
N = int(input())
X, Y = zip(*[[int(a) for a in input().split()] for _ in range(N)])

L = [(x, y, x + y, y - x) for x, y in zip(X, Y)]

L.sort(key = lambda a : a[2])  
ans = abs(L[0][0] - L[-1][0]) + abs(L[0][1] - L[-1][1])

L.sort(key = lambda a : a[3])  
ans = max(ans, abs(L[0][0] - L[-1][0]) + abs(L[0][1] - L[-1][1]))
print(ans)

Solution (Python):
n = int(input())
a = []
m1, m2, m3, m4 = [-10**10]*4

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

x = []
y = []
for _ in range(n):
    u, v = [int(x) for x in input().strip().split()]
    x.append(u)
    y.append(v)
    
    
    
    
    

res = maxAbsValExpr(x, y, n)
print(res)

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

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

Solution (Python):
import numpy as np

N = int(input())
XY_set = set(tuple(map(int, input().split())) for _ in range(N))
N = len(XY_set)

XY45 = np.array([(x + y, x - y) for x, y in XY_set]).T
ans = max(XY45[0].max() - XY45[0].min(),
          XY45[1].max() - XY45[1].min())
print(ans)

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