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



Sample input:
3
1 1
2 4
3 2


Sample output:
4

Submission status: Wrong Answer

Solution code:
n=int(input())

max_d=(1,1)
min_d=(10**9,10**9)
for _ in range(n):
  x,y=map(int,input().split())
  d=(x,y)
  if sum(max_d)<sum(d):
    max_d=d
  if sum(min_d)>sum(d):
    min_d=d
print(sum(max_d)-sum(min_d))

Submission status: Wrong Answer

Solution code:
n=int(input())
xy=[list(map(int,input().split()))for _ in range(n)]
xy1ma=0
xy1mi=10**10
xy2ma=0
xy2mi=10**10
for x,y in xy:
  xy1ma=max(xy1ma,x-y)
  xy1mi=min(xy1mi,x-y)
  xy2ma=max(xy2ma,x+y)
  xy2mi=min(xy2mi,x+y)
print(max(xy1ma-xy1mi,xy2ma-xy2mi))

Submission status: Wrong Answer

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

ans=0
i=0
for i in range(n-1):
    j=i+1
    while j<n:
        m=abs(data[i][0]-data[j][0])+abs(data[i][0]-data[j][0])
        ans=max(ans,m)
        j+=1

print(ans)

Submission status: Wrong Answer

Solution code:
import os
from io import BytesIO, IOBase
import sys
def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(list(map(int, input().split())))
    a.sort(reverse=True)
    x = a[0][0]
    y = a[0][1]
    ma = 0
    for i in range(1, n):
        ma = max(ma, abs(x - a[i][0]) + abs(y - a[i][1]))
    x = a[-1][0]
    y = a[-1][1]
    for i in range(n - 2, -1, -1):
        ma = max(ma, abs(x - a[i][0]) + abs(y - a[i][1]))
    print(ma)
# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

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


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


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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
xy=[list(map(int,input().split()))for _ in range(n)]
xy1ma=0
xy1mi=10**9
xy2ma=0
xy2mi=10**9
for x,y in xy:
  xy1ma=max(xy1ma,x-y)
  xy1mi=min(xy1mi,x-y)
  xy2ma=max(xy2ma,x+y)
  xy2mi=min(xy2mi,x+y)
print(max(xy1ma-xy1mi,xy2ma-xy2mi))

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    xy = [list(map(int, input().split())) for _ in [0]*n]
    z = [max(x+y, x-y) for x, y in xy]
    print(max(z)-min(z))


main()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0 for _ in range(n)]
for i in range(n):
    x[i] = list(map(int, input().split()))
    x[i].append(x[i][0]**2 + x[i][1]**2)
x.sort(key = lambda s:s[2])
ans = 0
for i in x:
    ans = max(ans, abs(x[-1][0] - i[0]) + abs(x[-1][1] - i[1]))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
maxx, minx, maxy, miny = 0, 10 ** 10, 0, 10 ** 10
for i in range(n):
    x, y = map(int, input().split())
    x, y = x + y, x - y
    maxx = max(x, maxx)
    minx = min(x, minx)
    maxy = max(y, maxy)
    miny = min(y, miny)
print(max(maxx - minx, maxy - miny))

Submission status: Wrong Answer

Solution code:
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

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

def inverse(N, mod):
	return (pow(N, mod - 2, mod))

def main():
	N = int(input())
	L = []
	for i in range(N):
		x, y = getlist()
		L.append(x + y)
	L.sort()
	ans = L[-1] - L[0]
	print(ans)





if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
minn=10**18
maxx=-10**18
for _ in range(input()):
    x,y=[int(i) for i in raw_input().split()]
    minn=min(minn,x+y)
    maxx=max(maxx,x+y)
print maxx-minn

Submission status: Wrong Answer

Solution code:
n = int(input())
mi= 10**10
ma = -10**10
for i in range(n):
  a,b = map(int,input().split())
  mi = min(mi,a+b)
  ma = max(ma,a+b)
print(abs(mi-ma))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0 for _ in range(n)]
for i in range(n):
    x[i] = list(map(int, input().split()))
x.sort(key = lambda s:s[0])
ans = 0
for i in x:
    ans = max(ans, abs(x[0][0] - i[0]) + abs(x[0][1] - i[1]))
x.sort(key = lambda w:w[1])
for i in x:
    ans = max(ans, abs(x[0][0] - i[0]) + abs(x[0][1] - i[1]))
print(ans)

Submission status: Wrong Answer

Solution code:
Row = int(input())
List = []
for i in range (Row):
  List.append(list(map(int, input().split())))
Slist = [0]*Row
for i in range(Row):
  Slist[i] = abs(List[i][0]) + abs(List[i][1])
Slist.sort()
res = Slist[Row-1] - Slist[0]
print(res)

Submission status: Wrong Answer

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

m1 = 0
mp1 = 0
for i in range(N):
  d = abs(x[i]-x[0])+abs(y[i]-y[0])
  if d>m1:
    m1 = d
    mp1 = i

m2 = 0
mp2 = 0
for i in range(N):
  d = abs(x[i]-x[mp1])+abs(y[i]-y[mp1])
  if d>m2:
    m2 = d
    mp2 = i

ans = 0
for i in range(N):
  ans = max(ans, abs(x[i]-x[mp2])+abs(y[i]-y[mp2]))

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
mn = 10 ** 10
mx = -10 ** 10
for _ in range(N):
  x, y = map(int, input().split())
  mn = min(mn, x + y)
  mx = max(mx, x + y)
print(abs(mx - mn))

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *XY = map(int, read().split())

    P = [x + y for x, y in zip(*[iter(XY)] * 2)]
    mi = min(P)
    ma = max(P)

    print(abs(mi - ma))

    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

m = 0
mp = 0
for i in range(N):
  d = abs(x[i]-x[0])+abs(y[i]-y[0])
  if d>m:
    m = d
    mp = i

ans = 0
for i in range(N):
  ans = max(ans, abs(x[i]-x[mp])+abs(y[i]-y[mp]))

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    d = [sum(map(int, input().split())) for _ in range(n)]
    d.sort()
    print(d[-1] - d[0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

def dist(A, B):
	return abs(A[0]-B[0]) + abs(A[1]-B[1])

N = INT()
xy = [LIST() for _ in range(N)]
xy.sort(key=lambda x:x[0])
a = xy[0]
b = xy[-1]

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
kyori = []
for i in range(N):
    tmp = xy[i][0] + xy[i][1]
    kyori.append((i, tmp))


kyori.sort(key=lambda x: x[1])
print(abs(xy[kyori[0][0]][0] - xy[kyori[-1][0]][0]) + abs(xy[kyori[0][0]][1] - xy[kyori[-1][0]][1]))

Submission status: Wrong Answer

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *                      # ll = deepcopy(l)
from heapq import *                     # heappush(hp,x)
from string import *                    # alpha = ascii_lowercase
from random import *                    # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *                    # bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin                   # bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize                 # minn = -maxsize
from operator import *                  # d = sorted(d.items(), key=itemgetter(1))
from itertools import *                 # pre = [0] + list(accumulate(l))
from decimal import Decimal             # a = Decimal(a)    # use this for math questions
from collections import Counter         # d = dict(Counter(l))
from collections import defaultdict     # d = defaultdict(list)

'''
3
1 1
2 4
3 2
'''

def solve(l):
	n = len(l)
	d = defaultdict(int)
	ll = []
	for x,y in l:
		ll.append(x+y)
	return abs(min(ll) - max(ll))

N = int(stdin.readline())
L = []
for i in range(N):
	a,b = map(int, input().split())
	L.append([a,b])
ans = solve(L)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
mn = 10 ** 10
mx = 0
for _ in range(N):
  x, y = map(int, input().split())
  mn = min(mn, x + y)
  mx = max(mx, x + y)
print(abs(mx - mn))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

x = xy[:,0]
y = xy[:,0]

a = x+y
b = -x+y

ans = max(a.max() - a.min(), b.max()-b.min())
print(ans)

Submission status: Wrong Answer

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *                      # ll = deepcopy(l)
from heapq import *                     # heappush(hp,x)
from string import *                    # alpha = ascii_lowercase
from random import *                    # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *                    # bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin                   # bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize                 # minn = -maxsize
from operator import *                  # d = sorted(d.items(), key=itemgetter(1))
from itertools import *                 # pre = [0] + list(accumulate(l))
from decimal import Decimal             # a = Decimal(a)    # use this for math questions
from collections import Counter         # d = dict(Counter(l))
from collections import defaultdict     # d = defaultdict(list)

'''
3
1 1
2 4
3 2
'''

def solve(l):
	n = len(l)
	d = defaultdict(int)
	ll = []
	for x,y in l:
		ll.append(x+y)
	return abs(max(ll) - min(ll))

	

N = int(stdin.readline())
L = []
for i in range(N):
	a,b = map(int, input().split())
	L.append([a,b])
ans = solve(L)
print(ans)

Submission status: Wrong Answer

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

xy.sort()

ans = 0
t = xy[0][0]

for i in range(n):
    xy[i][0] -= t

for x,y in xy:
    ans = max(ans, x + abs(y - xy[0][1]))

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
kyori = []
for i in range(N):
    tmp = xy[i][0] + xy[i][1]
    kyori.append((i, tmp))

kyori.sort(key=lambda x: x[1])
print(kyori[-1][1] - kyori[0][1])

Submission status: Wrong Answer

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

far = 0
dist = 0
x0 = xys[0][0]
y0 = xys[0][1]
for i, (x, y) in enumerate(xys):
    if abs(x - x0) + abs(y - y0) > dist:
        dist = abs(x - x0) + abs(y - y0)
        far = i

x0, y0 = xys[i]
far = 0
for i, (x, y) in enumerate(xys):
    if abs(x - x0) + abs(y - y0) > dist:
        dist = abs(x - x0) + abs(y - y0)
        far = i

print(dist)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[list(map(int, input().split()))  for _ in range(N)]
maxd=0
for i in range(N):
    for j in range(i+1,N):
        maxd=max(maxd,abs(A[i][0]-A[j][0])+abs(A[i][1]-A[j][1]))

print(maxd)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
 
x = []
y = []
distance = []
 
for i in range(n):
  x1, y1 = input().split()
  x1 = int(x1)
  y1 = int(y1)
  x.append(x1)
  y.append(y1)
 
for i in range(len(x)):
  for j in range(i+1,len(x)):
    temp = abs(x[i] - x[j]) + abs(y[i] - y[j])
    distance.append(temp)
  max = distance[0]
  if distance[i-1] > max:
    max = distance[i-1]

print(max)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
 
x = []
y = []
distance = []
 
for i in range(n):
  x1, y1 = input().split()
  x1 = int(x1)
  y1 = int(y1)
  x.append(x1)
  y.append(y1)
 
for i in range(len(x)):
  for j in range(i+1,len(x)):
    temp = abs(x[i] - x[j]) + abs(y[i] - y[j])
    distance.append(temp)

max = distance[0]
 
for i in range(1,len(distance)-1):
  if distance[i] >= max:
    max = distance[i]
 
print(max)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
cords = []
for i in range(n):
    x,y = map(int, input().split())
    cords.append([x,y]);

maxi = 0
for i in range(len(cords)):
    for j in range(i+1, len(cords)):
        dist = abs(cords[j][0]-cords[i][0]) + abs(cords[j][1]-cords[i][1])
        maxi = max(maxi, dist)
print(maxi)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import sys
input = sys.stdin.readline

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

def md(x1,y1,x2,y2):
    return abs(int(x1)-int(x2)) + abs(int(y1)-int(y2))

r = [md(i[0], i[1],j[0], j[1]) for i,j in itertools.product(xy, xy)]
print(max(r))

Submission status: Time Limit Exceeded

Solution code:
import itertools
import sys
input = sys.stdin.readline

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

def md(x1,y1,x2,y2):
    return abs(x1-x2) + abs(y1-y2)

r = [md(i[0], i[1],j[0], j[1]) for i,j in itertools.product(xy, xy)]
print(max(r))

Submission status: Time Limit Exceeded

Solution code:
import itertools
N = int(input())
xy = []
for i in range(N):
    xy.append(list(map(int, input().split())))

def md(x1,y1,x2,y2):
    return abs(x1-x2) + abs(y1-y2)

r = [md(i[0], i[1],j[0], j[1]) for i,j in itertools.product(xy, xy)]
print(max(r))

Submission status: Time Limit Exceeded

Solution code:
import itertools
N = int(input())
xy = []
for i in range(N):
    xy.append(list(map(int, input().split())))

def md(x1,y1,x2,y2):
    return abs(x1-x2) + abs(y1-y2)

target_list = [(i[0], i[1],j[0], j[1]) for i,j in itertools.product(xy, xy)]
r = [md(t[0], t[1],t[2], t[3]) for t in target_list]
print(max(r))

Submission status: Time Limit Exceeded

Solution code:
import itertools
N = int(input())
xy = []
for i in range(N):
    xy.append(list(map(int, input().split())))

def md(x1,y1,x2,y2):
    return abs(x1-x2) + abs(y1-y2)

target_list = [(i[0], i[1],j[0], j[1]) for i,j in itertools.product(xy, xy)]
target = set(target_list)

s = set()
for t in target:
    s.add(md(t[0], t[1],t[2], t[3]))

print(max(s))

Submission status: Time Limit Exceeded

Solution code:
import itertools
N = int(input())
xy = []
for i in range(N):
    xy.append(list(map(int, input().split())))

def md(x1,y1,x2,y2):
    return abs(x1-x2) + abs(y1-y2)

s = set()
for i,j in itertools.product(xy, xy):
    s.add(md(i[0], i[1],j[0], j[1]))

print(max(s))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

max = 0
for i in range(N):
    for j in range(i+1,N):
        dist = abs(dots[i][0]-dots[j][0])+abs(dots[i][1]-dots[j][1])
        if dist > max:
            max = dist

print(max)

Submission status: Time Limit Exceeded

Solution code:
N= int(input())
L = []
for i in range(N):
  t=tuple(map(int, input().split()))
  L.append(t)
dis = 0
for i in range(N-1):
  for j in range(i+1,N):
    d = abs(L[i][0]-L[j][0])+abs(L[i][1]-L[j][1])
    if d>dis:
      dis = d
print(dis)

Submission status: Time Limit Exceeded

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

x = np.empty(N, dtype=np.longlong)
y = np.empty(N, dtype=np.longlong)

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

ind = np.argsort(x)
X = x[ind]
Y = y[ind]

max_dist = [0]
for i in range(1, N):
    max_dist.append(np.max(-X[:i] - Y[:i]) + X[i] + Y[i])
    max_dist.append(np.max(-X[:i] + Y[:i]) + X[i] - Y[i])

print(max(max_dist))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
l = list()
for i in range(n):
  l.append(list(map(int, input().split())))
array = np.array(l)
max_d = 0
for i in range(n):
  for j in range(i,n):
    d = np.abs(array[i,0] - array[j,0]) + np.abs(array[i,1] - array[j,1])
    if max_d < d:
      max_d = d
print(max_d)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = list()
for i in range(n):
  l.append(list(map(int, input().split())))
max_d = 0
for i in range(n):
  for j in range(i,n):
    d = abs(l[i][0] - l[j][0]) + abs(l[i][1] - l[j][1])
    if max_d < d:
      max_d = d
print(max_d)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x = [0] * N
y = [0] * N

for i in range(N):
    coordinates = input().split(' ')
    x[i] = int(coordinates[0])
    y[i] = int(coordinates[1])

# print(x, y)

distance_max = 0
for i in range(N):
    for j in range(i + 1, N):
        distance = abs(x[j] - x[i]) + abs(y[j] - y[i])
        distance_max = max(distance_max, distance)

print(distance_max)

Submission status: Time Limit Exceeded

Solution code:
x = [0 for i in range(((10**9)+1)) ]
y = [0 for i in range(((10**9)+1)) ]

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

a = less(x)
b = less(y)
c = more(x)
d = more(y)
print(abs(a-c) + abs(b-d))


def less(x):
	flag1= 0
	for i in range((10**9)+1):
		if flag1 > 0:
			break
		else:
			 if x[i] == 1:
			 	flag1 = i

	return flag1

def more(x):
	flag2 = 0
	for i in range((10**9)+1):
		if x[i] == 1: 
			flag2 = i

	return flag2

Submission status: Time Limit Exceeded

Solution code:
"""AtCoder Beginner Contest 178.

E
"""

import sys


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


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


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

    points = []

    ans = 0
    for _ in range(n):
        points.append(list(map(int, input().split(' '))))

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

    print(ans)


main()

Submission status: Time Limit Exceeded

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

dis=[[] for i in range(N)]

for i in range(N):
    for j in range(N):
        dis[i].append((abs(arr[i][0]-arr[j][0])+abs(arr[i][1]-arr[j][1])))

ans=0
for i in range(N):
    ans=max(ans,max(dis[i]))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
X = []
Y = []

for _ in range(n):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

max_dist = 0

for i in range(n//2+1):
    for j in range(n//2+1):
        if i != j:
            dist = abs(X[i]-X[j]) + abs(Y[i]-Y[j])
            if dist > max_dist:
                max_dist = dist

print(max_dist)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
X = []
Y = []

for _ in range(n):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

max_dist = 0

for i in range(n):
    for j in range(n):
        if i != j:
            dist = abs(X[i]-X[j]) + abs(Y[i]-Y[j])
            if dist > max_dist:
                max_dist = dist

print(max_dist)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
xy=[]
for i in range(n):
  XY=[int(x) for x in input().split()]
  xy.append(XY)

ans=0
for i in range(n):
  for j in range(i+1,n):
    now=abs(xy[i][0]-xy[j][0])+abs(xy[i][1]-xy[j][1])
    ans=max(ans,now)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    pts = []
    m = 0
    while N != 0:
        x, y = map(int, input().split())
        for i in range(len(pts)):
            m = max(m, abs(pts[i][0] - x)+ abs(pts[i][1]-y))
        pts+= [[x,y]]
        N = N - 1
    print(m)

main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    pts = []
    while N != 0:
        x, y = map(int, input().split())
        pts+= [[x,y]]
        N = N - 1

    m = 0
    for i in range(0,len(pts)):
        for j in range(0,i):
            m = max(m, abs(pts[i][0]-pts[j][0]) + abs(pts[i][1] - pts[j][1]))
    print(m)

main()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
x=[]
for i in range(N):
    x.append(list(map(int,input().split())))
t=0
for i in range(N):
    for j in range(N):
        if t <(abs(x[i][0]-x[j][0])+abs(x[i][1]-x[j][1])):
            t=abs(x[i][0]-x[j][0])+abs(x[i][1]-x[j][1])
print(t)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
x=[]
for i in range(N):
    x.append(list(map(int,input().split())))
t=[]
for i in range(N):
    for j in range(N):
        t.append(abs(x[i][0]-x[j][0])+abs(x[i][1]-x[j][1]))
print(max(t))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
p=[]
for i in range(N):
    p.append(list(map(int, input().split())))
q=[]
for i in range(N):
    for j in range(N-i):
        q.append(abs(p[i][0]-p[i+j][0])+abs(p[i][1]-p[i+j][1]))
print(max(q))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
 
n = int(input())
x = np.empty(n, dtype=int)
y = np.empty(n, dtype=int)
 
for i in range(n):
  x[i], y[i] = [int(d) for d in input().split()]

dist = 0
for i in range(n - 1):
  dist = max(
    dist,
    np.max(np.abs(x[i] - x[i+1:]) + np.abs(y[i] - y[i+1:]))
  )
print(dist)

Submission status: Time Limit Exceeded

Solution code:
def dist(ls1,ls2):
  return abs(ls1[0]-ls2[0])+abs(ls1[1]-ls2[1])
N = int(input())
zahyou = []
for _ in range(N):
  x_y = list(map(int, input().split()))
  zahyou.append(x_y)
maxi = 0
for n1 in range(N-1):
  for n2 in range(n1+1, N):
    maxi = max(maxi, dist(zahyou[n1],zahyou[n2]))
print(maxi)

Submission status: Time Limit Exceeded

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

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

s=0
for i in range(n-1):
  for j in range(i+1,n):
    if f(l[i],l[j])>s:
      s=f(l[i],l[j])
print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
b = 0

for i in range(n):
    for j in range(i,n):
        b = max(b, (abs(a[i][0] - a[j][0]) + abs(a[i][1] - a[j][1])))
print(b)

Submission status: Time Limit Exceeded

Solution code:
nums = []
for i in range(0, int(input())):
  nums.append(input())

vals = []
for start in nums:
  x1 = int(start.split(" ")[0])
  y1 = int(start.split(" ")[1])
  for end in nums:
    x2 = int(end.split(" ")[0])
    y2 = int(end.split(" ")[1])
    vals.append(abs(x1 - x2) + abs(y1 - y2))

print(max(vals))

Submission status: Time Limit Exceeded

Solution code:
nums = []
for i in range(0, int(input())):
  nums.append(input())

max_num = 0
curr = 0
for start in nums:
  x1 = int(start.split(" ")[0])
  y1 = int(start.split(" ")[1])
  for end in nums:
    x2 = int(end.split(" ")[0])
    y2 = int(end.split(" ")[1])
    curr = abs(x1 - x2) + abs(y1 - y2)
    if curr > max_num:
      max_num = curr
      
print(max_num)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
m = []
for _ in range(n):
  l = list(map(int,input().split()))
  m.append(l)
mx = float('-inf')
for i in range(n):
  for j in range(i+1,n):
    mx = max(mx,abs(m[i][0]-m[j][0])+abs(m[i][1]-m[j][1]))
print(mx)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
z = [list(map(int, input().split())) for i in range(n)]
d = [max(z[i][0] - z[j][0], z[j][0] - z[i][0]) + max(z[i][1] - z[j][1], z[j][1] - z[i][1]) for i in range(n-1) for j in range(i+1, n)]
print(max(d))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
z = [list(map(int, input().split())) for i in range(n)]
m = 0
d = 0
for i in range(n-1):
  for j in range(i+1, n):
    d = 0
    d += max(z[i][0] - z[j][0], z[j][0] - z[i][0])
    d += max(z[i][1] - z[j][1], z[j][1] - z[i][1])
    if d>m:
      m = d
print(m)

Submission status: Time Limit Exceeded

Solution code:
s=input().split()
N=int(s[0])
x=[]
y=[]
for i in range(N):
    s2=input().split()
    x.append(int(s2[0]))
    y.append(int(s2[1]))
X=[]

for i in range(N):
    for j in range(N):
        X.append(abs(x[i]-x[j])+abs(y[i]-y[j]))
print(max(X))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
X=[]
Y=[]
man=0
for m in range(N):
    x,y=map(int, input().split())
    X.append(x)
    Y.append(y)
for i in range(N):
    for j in range(i,N):
        res=abs(X[i]-X[j])+abs(Y[i]-Y[j])
        if man<res:
            man=res
print(man)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

max_dis = 0
for j in range(n) :
    for k in range(n - j) :
        dis = max(abs(xy_sum[j] - xy_sum[k]), abs(xy_dif[j] - xy_dif[k]))
        max_dis = max(max_dis, dis)
        
print(max_dis)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
xy=[map(int,input().split()) for i in range(N)]
x,y=[list(j) for j in zip(*xy)]


t=0
s=0
m=0
for k in range(0,len(x)-1):
  for l in range(k,len(y)):
      if abs(x[k]-x[l])<t:
         m=m
      elif abs(y[k]-y[l])<s:
         m=m
      elif abs(x[k]-x[l])+abs(y[k]-y[l])>m:
         m=abs(x[k]-x[l])+abs(y[k]-y[l])
         t=abs(x[k]-x[l])
         s=abs(y[k]-y[l])
    
print(m)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
xy=[map(int,input().split()) for i in range(N)]
x,y=[list(j) for j in zip(*xy)]


t=0
m=0
for k in range(0,len(x)-1):
  for l in range(k,len(y)):
      if abs(x[k]-x[l])<t:
         m=m
      elif abs(x[k]-x[l])+abs(y[k]-y[l])>m:
         m=abs(x[k]-x[l])+abs(y[k]-y[l])
         t=abs(x[k]-x[l])
    
print(m)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
def dist(a, b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])

def cross(a, b, c, d):
    return (b[0]-a[0])*(d[1]-c[1]) - (b[1]-a[1])*(d[0]-c[0])
def cross3(a, b, c):
    return (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])

def convex_hull(ps):
    qs = []
    N = len(ps)
    for p in ps:
        # 一直線上で高々2点にする場合は ">=" にする
        while len(qs) > 1 and cross3(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    t = len(qs)
    for i in range(N-2, -1, -1):
        p = ps[i]
        while len(qs) > t and cross3(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    return qs
def rotating_calipers(ps):
    qs = convex_hull(ps)
    n = len(qs)
    if n == 2:
        return dist(qs[0], qs[1])
    i = j = 0
    for k in range(n):
        if qs[k] < qs[i]: i = k
        if qs[j] < qs[k]: j = k
    res = 0
    si = i; sj = j
    while i != sj or j != si:
        res = max(res, dist(qs[i], qs[j]))
        if cross(qs[i], qs[i-n+1], qs[j], qs[j-n+1]) < 0:
            i = (i + 1) % n
        else:
            j = (j + 1) % n
    return res

N, = map(int, input().split())
ps = []
for i in range(N):
    a, b = map(int, input().split())
    ps.append((a, b))
ps.sort(key=lambda x:x[0])
print(rotating_calipers(ps))

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
def dist(a, b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])

def cross(a, b, c, d):
    return (b[0]-a[0])*(d[1]-c[1]) - (b[1]-a[1])*(d[0]-c[0])
def cross3(a, b, c):
    return (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])

def convex_hull(ps):
    qs = []
    N = len(ps)
    for p in ps:
        # 一直線上で高々2点にする場合は ">=" にする
        while len(qs) > 1 and cross3(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    t = len(qs)
    for i in range(N-2, -1, -1):
        p = ps[i]
        while len(qs) > t and cross3(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    return qs
def rotating_calipers(ps):
    qs = convex_hull(ps)
    n = len(qs)
    if n == 2:
        return dist(qs[0], qs[1])
    i = j = 0
    for k in range(n):
        if qs[k] < qs[i]: i = k
        if qs[j] < qs[k]: j = k
    res = 0
    si = i; sj = j
    while i != sj or j != si:
        res = max(res, dist(qs[i], qs[j]))
        if cross(qs[i], qs[i-n+1], qs[j], qs[j-n+1]) < 0:
            i = (i + 1) % n
        else:
            j = (j + 1) % n
    return res

N, = map(int, input().split())
ps = []
for i in range(N):
    a, b = map(int, input().split())
    ps.append((a, b))
ps.sort()
print(rotating_calipers(ps))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
X=[]
for i in range(N):
    X.append(list(map(int,input().split())))

#D=[]
d_max=0
for i in range(0,N-1):
    for j in range(i+1,N):
        #D.append(abs(X[i][0]-X[j][0])+abs(X[i][1]-X[j][1]))
        if d_max<abs(X[i][0]-X[j][0])+abs(X[i][1]-X[j][1]):
            d_max=abs(X[i][0]-X[j][0])+abs(X[i][1]-X[j][1])
#print(max(D))
print(d_max)