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 main(sample_file = ''):

    """ convenient functions
    
    
    
    
    
    """

    """convenient decorator
    
    
        
        
        
        
        
        
        
        
        
        
    """
    
    
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product, combinations_with_replacement 
    
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  
        b, e = 2, 0  
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):   
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        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 combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict 
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest 
    from copy import deepcopy, copy 
    import operator
    from operator import itemgetter 
    
    
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd
    def gcd(a,b):
        
        
        if a<b:
            a, b = b, a
        while a%b !=0 :
            a, b = b, a%b
        return b

    
    
    
    
    
    

    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)
    def make_divisors(n, reversed=False):
        """create list of divisors
        
        Args:
            number (int): number from which list of divisors is created
            reversed (bool, optional): ascending order if False. Defaults to False.
        
        Returns:
            list: list of divisors
        """
        divisors = set()
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.add(i)
                divisors.add(n//i)
        return sorted(list(divisors),reverse=reversed)

    
    def sieve_of_eratosthenes(end, typecode="L"):
        
        

        
        import array
        import textwrap
        assert end > 1
        
        
        
        is_prime = array.array("B", (True for i in range(end)))
        
        is_prime[0] = False
        is_prime[1] = False
        
        primes = array.array(typecode)
        
        for i in range(2, end):
            if is_prime[i]:
                primes.append(i)
                for j in range(2 * i, end, i):
                    is_prime[j] = False  
        return primes

    class PrimeFactorization:
        '''初期化にO(NloglogN)/ 因数分解クエリをO(log(k))/ 素数判定クエリをO(1)
        >>> pf = PrimeFactorization(100)
        >>> pf.query(100)
        ((2, 2), (5, 2))
        
        '''
        
        
        
        
        
        
        
        def __init__(self, Num=10**6):
            from collections import defaultdict
            from math import floor
            self.Num = Num
            self.D = [-1] * (Num+1)
            for i in range(2, Num+1):
                if self.D[i] != -1:
                    continue
                self.D[i] = i
                for j in range(1, floor(Num/i)+1):
                    if self.D[j*i] != -1:
                        continue
                    else:
                        self.D[j*i] = i
        
        def query(self, k):
            ans = defaultdict(int)
            tmp = k
            while self.D[tmp] != -1:
                div = self.D[tmp]
                ans[div] += 1
                tmp = tmp//div
            return tuple(ans.items())
        
        def is_prime(self, k):
            return k == self.D[k]

    
    
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    AtoZ = list('abcdefghijklmnopqrsruvwxyz') 
    modpow = lambda a, n, p = MOD: pow(a, n, p) 
    def modinv(a, p = MOD):
        
        
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        
        
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    class UnionFindTree:
        """union find tree class
        TODO: fix this description...
        how to use (example):
        >>  uf = UnionFindTree(N) 
        >>  if uf.find_root(a) == uf.find_root(b):
        >>      do something like:
        >>      pass
        >>  else:
        >>      do something like:
        >>      L[find_root(a)] = L[find_root(a)] + L[find_root(b)]
        >>      L[find_root(b)] = L[find_root(a)]
        >>      
        >>      uf.unite(a, b)
        """
        def __init__(self, N):
            self.root = [-1] * (N+1)
            self.rank   = [0]  * (N+1)
            self.connected_num = [1] * (N+1)
    
        def find_root(self,x):
            root = self.root
            while root[x] != -1:
                x = root[x]
            return x
    
        def unite(self,x,y):
            root = self.root
            rank = self.rank
            connected_num = self.connected_num
            find_root = self.find_root
    
            rx = find_root(x)
            ry = find_root(y)
            if rx != ry:
                if rank[rx] < rank[ry]:
                    root[rx] = ry
                    rx,ry = ry,rx
                else:
                    if rank[rx] == rank[ry]:
                        rank[rx] += 1
                    root[ry] = rx       
                connected_num[rx] += connected_num[ry]

    
    
    
    class SegTree:
        """
        ref: https://qiita.com/takayg1/items/c811bd07c21923d7ec69
        init(init_val, ide_ele): 配列init_valで初期化 O(N)
        update(k, x): k番目の値をxに更新 O(logN)
        query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
        """
        def __init__(self, init_val, segfunc, ide_ele):
            """
            init_val: 配列の初期値
            segfunc: 区間にしたい操作
            ide_ele: 単位元
            n: 要素数
            num: n以上の最小の2のべき乗
            tree: セグメント木(1-index)
            """
            n = len(init_val)
            self.segfunc = segfunc
            self.ide_ele = ide_ele
            self.num = 1 << (n - 1).bit_length()
            self.tree = [ide_ele] * 2 * self.num
            
            for i in range(n):
                self.tree[self.num + i] = init_val[i]
            
            for i in range(self.num - 1, 0, -1):
                self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

        def update(self, k, x):
            """
            k番目の値をxに更新
            k: index(0-index)
            x: update value
            """
            k += self.num
            self.tree[k] = x
            while k > 1:
                self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
                k >>= 1

        def query(self, l, r):
            """
            [l, r)のsegfuncしたものを得る
            l: index(0-index)
            r: index(0-index)
            """
            res = self.ide_ele
            l += self.num
            r += self.num
            while l < r:
                if l & 1:
                    res = self.segfunc(res, self.tree[l])
                    l += 1
                if r & 1:
                    res = self.segfunc(res, self.tree[r - 1])
                l >>= 1
                r >>= 1
            return res

    
    
    
    
    
    
    
    

    def BellmanFord(N, M, ABC, vertex_start, vertex_end, value_if_inf = -1, find_shortest = False):
        """to calculate furthest or shortest length between vertex_start and vertex_end using BellmanFord algorithm
        
        Args:
            N (int): number of vertices
            M (int): number of edges
            ABC (list): [(ai, bi, ci) for _ in range(N)] where i-th edge is directed from vertex ai to vertex bi and the length is ci 
            vertex_start (int): start vertex. usually use 0.
            vertex_end (int): end vertex. usually use N-1.
            value_if_inf (int or string as you like, optional): value you want when the furthest (or shortest) distance is infinite (or -infinite). Defaults to -1.
            find_shortest (bool, optional): choose False to find furthest path. Defaults to False.
        
        Returns:
            int or string: normally int (but can be str if you set value_if_inf to str)
            
        Example:
                N, M, P = R()
                ABC = [R() for _ in range(M)]
                ABC = [(a-1, b-1, c-P) for a, b, c in ABC]
                print(BellmanFord(N, M, ABC, 0, N-1, value_if_inf = 'inf'))

        """

        def make_reachable_list(N, M, ABC, vertex_start, vertex_end):
            reachable_to_direct = defaultdict(list)
            reachable_from_direct = defaultdict(list)
            reachable_from_start = [False] * N
            reachable_to_end = [False] * N
            reachable_from_start[vertex_start] = True
            reachable_to_end[vertex_end] = True
            reachable_from_both_sides = [False] * N
            dfs_from_start = []
            dfs_to_end = []
            for a, b, c in ABC:
                reachable_to_direct[a].append(b)
                reachable_from_direct[b].append(a)
                if a == vertex_start:
                    dfs_from_start.append(b)
                    reachable_from_start[b] = True
                if b == vertex_end:
                    dfs_to_end.append(a)
                    reachable_to_end[a] = True
            while dfs_from_start:
                v = dfs_from_start.pop()
                for i in reachable_to_direct[v]:
                    if not reachable_from_start[i]:
                        reachable_from_start[i] = True
                        dfs_from_start.append(i)
            while dfs_to_end:
                v = dfs_to_end.pop()
                for i in reachable_from_direct[v]:
                    if not reachable_to_end[i]:
                        reachable_to_end[i] = True
                        dfs_to_end.append(i)
            for i in range(N):
                reachable_from_both_sides[i] = reachable_from_start[i] and reachable_to_end[i]
            return reachable_from_both_sides
        
        reachable_from_both_sides = make_reachable_list(N, M, ABC, vertex_start, vertex_end)
        
        if find_shortest:
            dist = [INF for i in range(N)]
        else:
            dist = [-INF for i in range(N)]
        
        dist[vertex_start] = 0
        for i in range(N):
            updated = False
            for a, b, c in ABC:
                if not reachable_from_both_sides[a]:
                    continue
                elif find_shortest:
                    update_condition = dist[a] + c < dist[b]
                else:
                    update_condition = dist[a] + c > dist[b]
                if dist[a] != INF and update_condition:
                    dist[b] = dist[a] + c
                    updated = True
                    if i == N-1:
                        return value_if_inf
            if not updated:
                break
        return dist[vertex_end]

    
    def warshall_floyd(number_vertex, XYD, shift_one_for_vertex=False):
        
        
        
        
        
        d = [[float("inf")]*number_vertex for i in range(number_vertex)]
        for x, y, dist in XYD:
            if shift_one_for_vertex:
                x = x - 1
                y = y - 1
            d[x][y] = dist
            d[y][x] = dist
        for i in range(number_vertex):
            d[i][i] = 0 
        for k in range(number_vertex):
            for i in range(number_vertex):
                for j in range(number_vertex):
                    d[i][j] = min(d[i][j],d[i][k] + d[k][j])
        return d


    """ initialize variables and set inputs
    
        
        
            
            
    
        
        
        
        
        
        
        
    
        
        
        
        
    
        
        
    """

    
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    r_float = lambda: float(r())
    R = lambda: list(map(int, r().split()))
    R_str = lambda: r().split()
    R_map = lambda: map(int, r().split())
    R_float = lambda: list(map(float, r().split()))
    R_tuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    
    
    
    
    
    
    
    """

    
    if sample_file:
        sys.stdin = open(sample_file)
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    N = r_int()
    XY = [R() for _ in range(N)]
    
    
    
    a = max([x + y for x, y in XY])
    b = min([x + y for x, y in XY])
    c = max([x - y for x, y in XY])
    d = min([x - y for x, y in XY])
    print(max(a-b, c-d))
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    


    
    
    

    """memo: how to use defaultdict of list
    
    Dic = defaultdict(list)
    
    Dic[x].append(y)
    
    for k, v in Dic.items():
    """
    
    """memo: how to solve binary problems
    
    >>> a = 5
    >>> bin_str_a = format(a, '
    >>> print(bin_str_a)
    0b0101 
    """
    
    """memo: how to solve the problem
    creating simple test/answer
    greed
    simple dp
    graph
    """

if __name__ == '__main__':
    main()

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

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

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

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

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l1=[]
  l2=[]
  for _ in range(n):
    a,b=LI()
    l1.append(a+b)
    l2.append(a-b)

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


print(main())

Solution (Python):
N = int(input())
P = [tuple(map(int, input().split())) for i in range(N)]

X = [x + y for x, y in P]
Y = [x - y for x, y in P]
print(max(max(X) - min(X), max(Y) - min(Y)))

Solution (Python):
N = int(input())
x = [list(map(int, input().split())) for _ in range(N)]
ax, ay = x[0][0], x[0][1]
bx, by = x[0][0], x[0][1]
cx, cy = x[0][0], x[0][1]
dx, dy = x[0][0], x[0][1]
for i in range(N):
    if abs(x[i][0] - 1) + abs(x[i][1] - 10**9) < abs(ax - 1) + abs(ay - 10**9):
        ax = x[i][0]
        ay = x[i][1]
    if abs(x[i][0] - 10**9) + abs(x[i][1] - 10**9) < abs(bx - 10**9) + abs(by - 10**9):
        bx = x[i][0]
        by = x[i][1]
    if abs(x[i][0] - 1) + abs(x[i][1] - 1) < abs(cx - 1) + abs(cy - 1):
        cx = x[i][0]
        cy = x[i][1]
    if abs(x[i][0] - 10**9) + abs(x[i][1] - 1) < abs(dx - 10**9) + abs(dy - 1):
        dx = x[i][0]
        dy = x[i][1]
print(max(abs(ax-dx)+abs(ay-dy), abs(bx-cx)+abs(by-cy)))

Solution (Python):
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
dis1 = [0] * N
dis2 = [0] * N
for i in range(N):
        dis1[i] = x[i] + y[i]
        dis2[i] = x[i] - y[i]
max_dis1 = max(dis1)
min_dis1 = min(dis1)
max_dis2 = max(dis2)
min_dis2 = min(dis2)
max_dis = max([max_dis1 - min_dis1,-min_dis2 + max_dis2])
print(max_dis)

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

Solution (Python):

N=int(input())
x=[0]*N
y=[0]*N
z=[0]*N

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

z.sort(key=lambda x:(x[0]+x[1]) )
a=z[0]
b=z[-1]

z.sort(key=lambda x:(x[0]-x[1]) )
c=z[0]
d=z[-1]

al=[a,b,c,d]

ans=0

l=len(al)
for i in range(l):
    for j in range(i+1,l):
        tmp= abs(al[i][0]-al[j][0])+ abs(al[i][1]-al[j][1])
        ans= max(ans,tmp)
print(ans)

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


maxX = max(X)
maxY = max(Y)
minX = min(X)
minY = min(Y)

ans = max(maxX - minX, maxY - minY)
print(ans)

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

f_list_0 = []
f_list_1 = []
for i in range(n):
    f_list_0.append(a_list[i][0]+a_list[i][1])
    f_list_1.append(a_list[i][0]-a_list[i][1])

ans_0 = max(f_list_0) - min(f_list_0)
ans_1 = max(f_list_1) - min(f_list_1)

print(max((ans_0, ans_1)))

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

ans = 0
a = 100000000000000
m = 0
lm = 0
rm = 0
lt  = []
rt  = []
lb = []
rb = []

for l in c:
    m = max(m,l[0]+l[1])
    a = min(a,l[0]+l[1])
    if l[0] > l[1]:
        rm = max(rm,l[0]-l[1])
    if l[0] < l[1]:
        lm = max(lm,l[1]-l[0])

for l in c:
    if l[0] + l[1] == m:
        rt.append(l)
    if l[0] + l[1] == a:
        lb.append(l)
    if l[0] > l[1] and l[0] - l[1] == rm:
        rb.append(l)
    if l[0] < l[1] and l[1] - l[0] == lm:
        lt.append(l)


if len(lt)>0 and len(rb) > 0:
    i = lt[0]
    j = rb[0]
    ans = max(ans,abs(i[0]-j[0])+abs(i[1]-j[1]))

if len(rt)>0 and len(lb) > 0:
    i = rt[0]
    j = lb[0]
    ans = max(ans,abs(i[0]-j[0])+abs(i[1]-j[1]))
print(ans)

Solution (Python):
n = int(input())
min1 = 10000000000
max1 = -10000000000
min2 = 10000000000
max2 = -10000000000

for _ in range(n):
    x, y = map(int,input().split())
    if x+y> max1:
        r1 = [x,y]
        max1 = x+y
    if x+y<min1:
        l1 = [x,y]
        min1 = x+y
    if x-y>max2:
        r2 = [x,y]
        max2 = x-y
    if x-y<min2:
        l2 = [x,y]
        min2 = x-y



print(max(max1-min1,max2-min2))

Solution (Python):
n=int(input())
ans=[]
a=[]
b=[]
c=[]
d=[]
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)
ans=[a[-1]-a[0],b[-1]-b[0]]
print(max(ans))

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

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

min_x = 10 ** 9
max_x = -(10 ** 9)
min_y = 10 ** 9
max_y = -(10 ** 9)

for i in range(n):
    a, b = map(int, input().split())
    x = a + b
    y = a - b
    min_x = min(min_x, x)
    max_x = max(max_x, x)
    min_y = min(min_y, y)
    max_y = max(max_y, y)

print(max(max_x - min_x, max_y - min_y))

Solution (Python):
def main():
    N = int(input())
    d1 = []
    d2 = []
    for _ in range(N):
        x, y = map(int, input().split())
        d1.append(x+y)
        d2.append(x-y)
    d1_dist = max(d1) - min(d1)
    d2_dist = max(d2) - min(d2)
    print(max([d1_dist, d2_dist]))

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
l = []
ll = []
for _ in range(n):
    x, y = map(int, input().split())
    l.append((x+y, x, y))
    ll.append((x-y, x, y))
l.sort()
ll.sort()
ans1 = 0
ans2 = 0



cnt = 0
while True:
    a = l[n-1-cnt]
    b = l[cnt]
    
    if a[1] >= b[1] and a[2] >= b[2]:
        ans1 = abs(b[0]-a[0])
        
        break
    if cnt >= n-1:
        break
    cnt += 1

cnt = 0
while True:
    a = ll[n-1-cnt]
    b = ll[cnt]
    if a[1] >= b[1] and b[2] >= a[2]:
        ans2 = abs(b[0]-a[0])
        
        break
    if cnt >= n-1:
        break
    cnt += 1

print(max(ans1, ans2))

Solution (Python):
def main():
  f_0 = []
  f_1 = []
  n = int(input())
  for i in range(n):
    x, y = map(int, input().split())
    f_0.append(x-y)
    f_1.append(x+y)
  print(max(max(f_0)-min(f_0),max(f_1)-min(f_1)))
  
if __name__ == "__main__":
  main()

Solution (Python):
n = int(input())
lst_plus = []
lst_minus = []

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

A = lst_plus[-1] - lst_plus[0]
B = lst_minus[-1] - lst_minus[0]

print(max([A,B]))

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

xy = []
d0, d1 = [],[]
for _ in range(N):
  x,y=map(int,input().split())
  d0.append(x-y)
  d1.append(x+y)
print(max(max(d0)-min(d0), max(d1)-min(d1)))

Solution (Python):

import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
det = lambda p, q: p[0] * q[1] - p[1] * q[0]
sub = lambda p, q: (p[0] - q[0], p[1] - q[1])


def get_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]


mdist = -1
X = get_convex_hull(X)
used = [0] * len(X)
for index, start in enumerate(X):
    
    
    sx, sy = start
    maxv = -1
    maxi = -1
    for i, xi in enumerate(X):
        if i == index:
            continue
        x, y = xi
        
        
        
        dist = abs(x - sx) + abs(y - sy)
        
        if maxv < dist:
            maxi = i
            maxv = dist
    
    
    mdist = max(mdist, maxv)

print(mdist)

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

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

ax = sorted(a, key=lambda x:(x[0], x[1]))
ay = sorted(a, key=lambda x:(x[1], x[0]))

ans = 0
lx, ly = ax[0][0], ax[0][1]
ux, uy = ax[0][0], ax[0][1]
for i in range(n):
    if ax[i][0] - lx + ax[i][1] - ly < 0:
        lx, ly = ax[i][0], ax[i][1]
    if ax[i][0] - ux + ax[i][1] - uy > 0:
        ux, uy = ax[i][0], ax[i][1]
    ans = max(ans, ux-lx + uy - ly)
    
lx, ly = ax[0][0], ax[0][1]
ux, uy = ax[0][0], ax[0][1]
for i in range(n):
    if ax[i][0] - lx + ly - ax[i][1] < 0:
        lx, ly = ax[i][0], ax[i][1]
    if ax[i][0] - ux + uy - ax[i][1] > 0:
        ux, uy = ax[i][0], ax[i][1]
    ans = max(ans, ux-lx + ly - uy)
print(ans)

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

Solution (Python):
N = int (input())
x = []*N
y = []*N
for i in range (N):
    a,b = list(map(int,input().split()))
    x.append(a)
    y.append(b)
syou = x[0]+y[0]
dai = x[0]+y[0]
for i in range (N):
    if x[i]+y[i]>dai:
        dai = x[i]+y[i]
    if x[i]+y[i]<syou:
        syou = x[i]+y[i]
ans = dai - syou
gyakusyou = 10**9 -x[i] +y[i]
gyakudai = 10**9 -x[i] + y[i]
for i in range (N):
    if 10**9 -x[i] +y[i]>gyakudai:
        gyakudai = 10**9 -x[i] +y[i]
    if 10**9 -x[i] +y[i]<gyakusyou:
        gyakusyou = 10**9 -x[i] +y[i]
if gyakudai - gyakusyou > ans:
    ans = gyakudai - gyakusyou
print (ans)

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

xys = sorted(xys, key= lambda x: x[0])

answer = 0
a = []
b = []
for xy in xys:
    a.append(xy[0] + xy[1])
    b.append(xy[0] - xy[1])
    
print(max(max(a)-min(a), max(b)-min(b)))

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

data_sum=[]
for i in range(n):
    data_sum.append(data[i][0]+data[i][1])


data_sum_1=[]
for i in range(n):
    data_sum_1.append(data[i][1]-data[i][0])

d_1=max(data_sum)-min(data_sum)
d_2=max(data_sum_1)-min(data_sum_1)

print(max(d_1,d_2))

Solution (Python):
import numpy as np

f = open(0)
N = int(f.readline())
xy = np.fromstring(f.read(), dtype=np.int64, sep=' ').reshape((-1, 2)).T.copy()
x = xy[0]
y = xy[1]
c1 = x + y
c2 = x - y
ans = max(c1.max() - c1.min(), c2.max() - c2.min())
print(ans)

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

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    N = II()
    Z = []
    for i in range(N):
        x, y = MI()
        Z.append((x-y, x+y))
    
    minx = miny = INF
    maxx = maxy = -INF
    for z in Z:
        minx = min(minx, z[0])
        maxx = max(maxx, z[0])
        miny = min(miny, z[1])
        maxy = max(maxy, z[1])
    print(max(maxx-minx, maxy-miny))
if __name__ == '__main__':
    solve()

Solution (Python):


N = int(input())

sa_lis = []
wa_lis = []

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

sa = max(sa_lis) - min(sa_lis)
wa = max(wa_lis) - min(wa_lis)

ans = max(sa,wa)

print("{}".format(ans))