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: Runtime Error

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

Submission status: Runtime Error

Solution code:
l, m = list(), list()
for _ in range(int(input())):
	x, y = map(int, input().split())
        l.append([x, y])
        m.append([y, x])
l.sort(), m.sort()
print(max(l[-1][0]-l[0][0]+l[-1][1]-l[0][1], m[-1][0]-l[0][0]+l[-1][1]-l[0][1]))

Submission status: Runtime Error

Solution code:
l, m = list(), list()
for _ in range(int(input())):
	x, y = map(int, input().split())
    l.append([x, y])
    m.append([y, x])
l.sort(), m.sort()
print(max(l[-1][0]-l[0][0]+l[-1][1]-l[0][1], m[-1][0]-l[0][0]+l[-1][1]-l[0][1]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
cheby = []
for i in range(n):
    l = [xy[i][0]-xy[i][1],xy[i][0]+xy[i][1]]
    cheby.append(l)

xmax = 0
xmin = 10**10
ymax = 0
ymin = 10**10
for i in range(n):
    if cheby[i][0] >= xmax :
        xmax = cheby[i][0]
        xa = i
    if cheby[i][0] =< xmin :
        xmin = cheby[i][0]
        xi = i
    if cheby[i][1] >= ymax :
        ymax = cheby[i][1]
        ya = i
    if cheby[i][1] =< ymin :
        ymin = cheby[i][1]
        yi = i

if abs(xmax-xmin) > abs(ymax-ymin):
    print(abs(xy[xa][0]-xy[xi][0])+abs(xy[xa][1]-xy[xi][1]))
else :
    print(abs(xy[ya][0]-xy[yi][0])+abs(xy[ya][1]-xy[yi][1]))

Submission status: Runtime Error

Solution code:
import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    x, y = i2(N)

    Mw = max(x[i]+y[i] for i in range(N))
    mw = min(x[i]+y[i] for i in range(N))
    Mz = max(abs(a[i]-y[i]) for i in range(N))
    mz = min(abs(x[i]-y[i]) for i in range(N))

    print(max(Mz-mz, Mw-mw))
    


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
/*
	JAI JAGANNATH!
*/
//@Author : zanj0

#include<bits/stdc++.h>
using namespace std;

typedef long long int lli;

#define ff              first
#define ss              second
#define pb              push_back
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            lli x; cin>>x; while(x--)

void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void solve() {
	lli n;
	cin >> n;
	vector <lli> a(n);
	vector <lli> b(n);
	for (lli i = 0, x, y; i < n; i++) {
		cin >> x >> y;
		a[i] = x + y;
		b[i] = x - y;
	}
	lli ret = 0;
	lli maxVal = INT_MIN;
	lli minVal = INT_MAX;
	for (lli i : a) {
		maxVal = max(i, maxVal);
		minVal = min(i, minVal);
	}
	ret = max(ret, maxVal - minVal);
	maxVal = INT_MIN;
	minVal = INT_MAX;
	for (lli i : b) {
		maxVal = max(i, maxVal);
		minVal = min(i, minVal);
	}
	ret = max(ret, maxVal - minVal);
	cout << ret << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

Submission status: Runtime Error

Solution code:
import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    xy = np.array(xy)
    # print(xy)

    diffs = np.expand_dims(xy,axis=1) - np.expand_dims(xy,axis=0)
    md = np.sum(np.abs(diffs),axis=-1)
    res = md.max()

    # print(diffs)
    # print(md)

    print(res)



main()

Submission status: Runtime Error

Solution code:
n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
cheby = []
for i in range(n):
    l = [xy[i][0]-xy[i][1],xy[i][0]+xy[i][1]]
    cheby.append(l)

xmax = 0
xmin = 10**10
ymax = 0
ymin = 10**10
for i in range(n):
    if cheby[i][0] > xmax :
        xmax = cheby[i][0]
        xa = i
    if cheby[i][0] < xmin :
        xmin = cheby[i][0]
        xi = i
    if cheby[i][1] > ymax :
        ymax = cheby[i][1]
        ya = i
    if cheby[i][1] < ymin :
        ymin = cheby[i][1]
        yi = i

if abs(xmax-xmin) >= abs(ymax-ymin):
    print(abs(xy[xa][0]-xy[xi][0])+abs(xy[xa][1]-xy[xi][1]))
else :
    print(abs(xy[ya][0]-xy[yi][0])+abs(xy[ya][1]-xy[yi][1]))

Submission status: Runtime Error

Solution code:
n = int(input())
maxsum = -float('inf')
minsum = float('inf')
maxdif = -float('inf')
mindif = float('inf')
for i in range(n):
  x, y = map(int, input().split())
  trysum = x + y
  trydif = x - y
  if trysum >= maxsum:
    maxsum = trysum
  if trysum <= minsum:
    minsum = trysum
  if trydif >= maxdif:
    maxdif = trydif
  if trydif <= minsum:
    mindif = trydif
print(max(maxsum - minsum, maxdif - mindif)

Submission status: Runtime Error

Solution code:
from collections import defaultdict
dic = defaultdict(list)
inf = 10**6
N = int(input())
l = []
z = []
xma, xmi, yma, ymi = 0, inf, 0, inf
for _ in range(N):
    x, y = map(int, input().split())
    xma = max(xma, x)
    yma = max(yma, y)
    xmi = min(xmi, x)
    ymi = min(ymi, y)
    l.append([x, y])
    z.append(x+y)
z.sort()
ans = z[-1]-z[0]

for t in l:
    a = t[0]+t[1]
    dic[a].append(t)
for u in dic:
    dic[u].sort()
    b = dic[u][-1][0]-dic[u][0][0]
    ans = max(2*b,ans)
    
l1, l2, l3, l4 = [], [], [], []
for k in l:
    if k[0]==xma:
        l1.append([k[1], k[0]])
    elif k[1]==yma:
        l2.append([k[0], k[1]])
    elif k[0]==xmi:
        l3.append([k[1], k[0]])
    elif k[1]==ymi:
        l4.append([k[0], k[1]])
l1.sort()
l2.sort()
l3.sort()
l4.sort()
print(xma, xmi, yma, ymi)
print(l1, l2, l3, l4)
ans = max(ans, abs(l1[0][1]-l3[-1][1])+abs(l1[0][0]-l3[-1][0]))
ans = max(ans, abs(l1[-1][1]-l3[0][1])+abs(l1[-1][0]-l3[0][0]))
ans = max(ans, abs(l2[0][1]-l4[-1][1])+abs(l2[0][0]-l4[-1][0]))
ans = max(ans, abs(l2[-1][1]-l4[0][1])+abs(l2[-1][0]-l4[0][0]))

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
 
N = int(input())
nums=[]
for _ in range(N):
  nums.append(list(map(int,input().split())))
spots = np.array(nums)
diffs = np.expand_dims(spots, axis=1) - np.expand_dims(spots, axis=0)
distances = np.sum(abs(diffs), axis=-1)
 
print(distances.max())

Submission status: Runtime Error

Solution code:
N = int(input())
K = []
for i in range(N):
    x, y = map(int,input().split())
    t = x + y
    if x <= 0:
        t -= 4*abs(x)
    if y <= 0:
        t -= 4*abs(y)
    K.append([t, x, y])

K.sort()
ans = K[-1][0] - K[0][0]
for i in range(N-1):
    if K[i][0] == K[i+1][0]:
        A.append(K[i+1][1])
    else:
        ans = max(ans, max(A) - min(A))
        A = [K[i][1]]
print(ans)

Submission status: Runtime Error

Solution code:
from collections import defaultdict
dic = defaultdict(list)
inf = 10**6
N = int(input())
l = []
z = []
xma, xmi, yma, ymi = 0, inf, 0, inf
for _ in range(N):
    x, y = map(int, input().split())
    xma = max(xma, x)
    yma = max(yma, y)
    xmi = min(xmi, x)
    ymi = min(ymi, y)
    l.append([x, y])
    z.append(x+y)
z.sort()
ans = z[-1]-z[0]

for t in l:
    a = t[0]+t[1]
    dic[a].append(t)
for u in dic:
    dic[u].sort()
    b = dic[u][-1][0]-dic[u][0][0]
    ans = max(2*b,ans)
    
l1, l2, l3, l4 = [], [], [], []
for k in l:
    if k[0]==xma:
        l1.append([k[1], k[0]])
    elif k[0]==yma:
        l2.append([k[0], k[1]])
    elif k[1]==xmi:
        l3.append([k[1], k[0]])
    elif k[1]==ymi:
        l4.append([k[0], k[1]])
l1.sort()
l2.sort()
l3.sort()
l4.sort()
       
ans = max(ans, abs(l1[0][1]-l3[-1][1])+abs(l1[0][0]-l3[-1][0]))
ans = max(ans, abs(l1[-1][1]-l3[0][1])+abs(l1[-1][0]-l3[0][0]))
ans = max(ans, abs(l2[0][1]-l4[-1][1])+abs(l2[0][0]-l4[-1][0]))
ans = max(ans, abs(l2[-1][1]-l4[0][1])+abs(l2[-1][0]-l4[0][0]))

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
max_t = -float('inf')
min_t = float('inf')
dic_p_x = {}
for _ in range(n):
  x, y = map(int, input().split())
  c = x + y
  if c > max_t:
    max_t = c
  if c < min_t:
    min_t = c
  if not dic_p[c]:
    dic_p[c] = []
  dic_p_x[c].append(x)
max_d = max_t - min_t
for key, lst in dic_p.items():
  a, b = max(lst), min(lst)
  dis = 2 * (a - b)
  max_d = max(max_d, dis)
print(max_d)

Submission status: Runtime Error

Solution code:
N = int(input())
xys = []

for _ in range(N):
    xys.append(list(map(int, input().split(" "))))

max_dist = 0

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

ll sum() { return 0; }
template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl;

void solve() {

}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif

//    int tc; cin >> tc;
//    TC(tc) solve();
	int n, x, y;
	cin >> n;
//	vector<pll> v;
//	REP(i,n){
//		cin >> x >> y;
//		v.pb({x,y});
//	}
//	ll r0=INFF, c0=INFF;
//	sort(ALL(v), [r0,c0](pll& a, pll& b){
//		return abs(r0-a.fi)+abs(c0-a.se) < abs(r0-b.fi)+abs(c0-b.se);
//	});
//	ll ans=0;
//	REP(i,n){
//		FOR(j,i+1,n){
//			MAX(ans, (abs(v[i].fi-v[j].fi)+abs(v[i].se-v[j].se)));
//		}
//	}
//	OUT(ans);
//	cout << v[n-1].fi << " " << v[n-1].se << endl;
//	OUT((abs(v[0].fi-v[n-1].fi)+abs(v[0].se-v[n-1].se)));
	int miA=INT_MAX, miB=INT_MAX, mxA=INT_MIN, mxB=INT_MIN;
	REP(i,n){
		cin >> x >> y;
		MIN(miA,x+y);
		MAX(mxA,x+y);
		MIN(miB,x-y);
		MAX(mxB,x-y);
	}
	OUT(max({
		abs(mxA-miA),
		abs(mxB-miB)
	}));
    return 0;
}

Submission status: Runtime Error

Solution code:
l = [];
for i in range(int(input())):
	x = list(map(int,input().split()));
	l.append(x);
sum = 0;
for i in range(len(l)):
	for j in range(len(l)):
		if i!=j:
			k = abs(len[i][0]-len[j][0])+abs(len[i][1]-len[j][1]);
			if(sum<k)
				sum = k;
print(sum)

Submission status: Runtime Error

Solution code:
N = int(input())

ListN = [[0 for i in range(2)] for j in range(N)]

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

ListN = list(map(list, set(map(tuple, ListN))))

ListNZ = [0 for i in range(N)]

minz =10**5
maxz =0 

mini=0
maxi=0

for i in range(N-1):
  ListNZ = (ListN[i][0]**2 + ListN[i][i]**2)**0.5
  if minz >= ListNZ[i]:
    mini = i
  elif  maxz <= ListNZ[i]:
    maxi = i
      
print(abs(ListN[mini][0] - ListN[maxi][0]) + abs(ListN[mini][1] - ListN[maxi][1]))

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter

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()
A = LIST()
B = LIST()

C1 = Counter(A)
C2 = Counter(B)
for k, v in C1.items():
    if v > N-C2[k]:
        No()
        exit()

ans1 = B[N//2:] + B[:N//2]
ans2 = B[ceil(N, 2):] + B[:ceil(N, 2)]
ans3 = B[ceil(N, 2)+1:] + B[:ceil(N, 2)+1]

def check(A, B):
    for i in range(N):
        if A[i] == B[i]:
            return False
    return True

if check(A, ans1):
    Yes()
    print(*ans1)
elif check(A, ans2):
    Yes()
    print(*ans2)
else:
    print(*ans3)

Submission status: Runtime Error

Solution code:
points = []
max = 0
for i in range(int(input())):
    a,b = map(int, input().split())
    points.append([a,b])
               
for i in points:
    tempanswer = 0
    for j in points[i:]:
        tempanswer = abs(j[0] - i[0]) + abs(i[1] - j[1])
        if tempanswer > max:
            max = tempanswer
               
print(max)

Submission status: Runtime Error

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
xy = [readInts() for _ in range(n)]
max_xplusy = -1
min_xplusy = INF
ax,ay = None,None
bx,by = None,None
for i in range(n):
    x,y = xy[i]
    if max_xplusy < x+y:
        ax,ay = x,y
        max_xplusy = max(max_xplusy, x+y)
    if min_xplusy > x+y:
        bx,by = x,y
        min_xplusy = min(min_xplusy, x+y)
a = abs(ax-bx) + abs(ay - by)
max_xminusy = -1
min_xminusy = INF
ax,ay = None,None
bx,by = None,None
for i in range(n):
    x,y = xy[i]
    if max_xminusy < x-y:
        ax,ay = x,y
        max_xplusy = max(max_xplusy, x-y)
    if min_xminusy > x-y:
        bx,by = x,y
        min_xplusy = min(min_xplusy, x-y)
b = abs(ax-bx) + abs(ay - by)
print(max(a,b))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
data = []
for i in range(n):
	x,y = readInts()
	data.append([x+y,x,y])

data.sort(key=lambda x:x[0])
ans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))
data.sort(key=lambda x:x[1])
ans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))
data.sort(key=lambda x:x[2])
ans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# map(int, input().split())
N = int(input())

def dist(dot1, dot2):
    dx = abs(dot1[0]-dot2[0])
    dy = abs(dot1[1]-dot2[1])
    return dx+dy

dots = []

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

# 全探索
# max_len = 0
# for i in range(N):
#     for j in range(i):
#         max_len = max(max_len, dist(dots[i], dots[j]))

# print(max_len)

class Quadrant():
    def __init__(self, dots, x_axis, y_axis):
        self.dots = dots
        self.x_axis = x_axis
        self.y_axis = y_axis
        self.quads = [list() for i in range(2) for j in range(2)]

        for dot in dots:
            self.quads[int(dot[0]>x_axis)][int(dot[1]>y_axis)].append(dot)
        
        self.is_ins = [len(self.quads[i][j]) != 0 for i in range(2) for j in range(2)]

def search_max(dots, now_max_len):
    if len(dots) <= 9:
        for i in range(len(dots)):
            for j in range(len(dots)):
                max_len = max(max_len, dist(dots[i],dots[j]))
        
        return max_len

    x_axis = int(sum([dot[0] for dot in dots])/len(dots))
    y_axis = int(sum([dot[1] for dot in dots])/len(dots))

    quad = Quadrant(dots, x_axis, y_axis)

    # 対角線どうしの最大計算
    if quad.is_ins[0][0] and quad.is_ins[1][1]:
        max_plus_taikaku_1 = max([dist(dot, (x_axis,y_axis) for dot in quad.quads[0][0])]) + \
                           max([dist(dot, (x_axis,y_axis) for dot in quad.quads[1][1])])
    if quad.is_ins[1][0] and quad.is_ins[0][1]:
        max_plus_taikaku_2 = max([dist(dot, (x_axis,y_axis) for dot in quad.quads[1][0])]) + \
                           max([dist(dot, (x_axis,y_axis) for dot in quad.quads[0][1])])
    max_len = max(max_len,max_plus_taikaku_1,max_plus_taikaku_2)
    # 同軸上
    if quad.is_ins[0][0] and quad.is_ins[0][1]:
        max_len = search_max(quad.quads[0][0]+quad.quads[0][1], max_len)
    if quad.is_ins[1][0] and quad.is_ins[1][1]:
        max_len = search_max(quad.quads[1][0]+quad.quads[1][1], max_len)
    if quad.is_ins[0][0] and quad.is_ins[1][0]:
        max_len = search_max(quad.quads[0][0]+quad.quads[1][0], max_len)
    if quad.is_ins[0][1] and quad.is_ins[1][1]:
        max_len = search_max(quad.quads[0][1]+quad.quads[1][1], max_len)

    return max_len

print(search_max(dots,0))

Submission status: Runtime Error

Solution code:
import statistics

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

sumX = []
sumY = []
for x,y in XY:
    sumX.append(x)
    sumY.append(y)
avaX = statistics.median(sumX)
avaY = statistics.median(sumY)

zone1 = []
zone2 = []
zone3 = []
zone4 = []
for x,y in XY:
    if x < avaX and y >= avaY:
        zone1.append((x,y,abs(x-avaX)+abs(y-avaY)))
    elif x < avaX and y < avaY:
        zone4.append((x,y,abs(x-avaX)+abs(y-avaY)))
    elif x >= avaX and y >= avaY:
        zone2.append((x,y,abs(x-avaX)+abs(y-avaY)))
    elif x >= avaX and y < avaY:
        zone3.append((x,y,abs(x-avaX)+abs(y-avaY)))

zone1.sort()
zone2.sort()
zone3.sort()
zone4.sort()

ans = 0
ans = max(ans,zone1[-1][2]+zone3[-1][2])
ans = max(ans,zone2[-1][2]+zone4[-1][2])
print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)

def main():
    N = int(input())
    x = [0] * N
    y = [0] * N
    for i in range(N):
        x[i], y[i] = map(int, input().split())
    
    x, y = sort_zip(x, y)
    x_max = x[-1]
    x_min = x[0]
    
    y, x = sort_zip(y, x)
    y_max = y[0]
    y_min = y[-1]
    
    print(max((x_max - x_min) + (y_max - y_min)))

    

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from itertools import combinations
import sys

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

min_diff = 10**9
max_diff = 1
min_sum = 2 * 10**9
max_sum = 2

for x,y in XY:
    min_diff = min(x-y, min_diff)
    max_diff = max(x-y, max_diff)
    min_sum = min(x+y, min_sum)
    max_sum = max(x+y, max_sum)

cand_set = set()
for x,y in XY:
    if x-y in (min_diff, max_diff) or x+y in (min_sum, max_sum):
        cand_set.add((x, y))

if len(cand_set) == N:
    print(max(max_sum-min_sum, mad_diff - min_diff))
    sys.exit()

dist = 0
for p1, p2 in combinations(cand_set, 2):
    dist = max(dist, abs(p1[0]-p2[0]) + abs(p1[1]-p2[1]))
    
print(dist)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
X = []
Y = []
maxX = 0
minX = 10**9
maxY = 0
minY = 10**9

minxy =  float("inf")
maxxy =  -float("inf")
minnxy = float("inf")
maxnnx = -float("inf")
N = int(input())
for i in range(N):
  x, y = map(int, input().split())
  minxy = min(minxy, y-x)
  maxxy = min(maxxy, y-x)
  minnxy = min(minnxy, x + y)
  maxnxy = max(maxnxy, x + y)
  X.append(x)
  Y.append(y)
  maxX, minX = max(maxX, x), min(minX, x)
  maxY, minY = max(maxY, y), min(minY, y)
maxXmaxY = 0
maxXminY = 10**9
minXmaxY = 0
minXminY = 10**9
maxYmaxX = 0
maxYminX = 10**9
minYmaxX = 0
minYminX = 10**9
for i in range(N):
  if X[i]==maxX:
    maxXmaxY = max(maxXmaxY, Y[i])
    maxXminY = min(maxXminY, Y[i])
  if X[i]==minX:
    minXmaxY = max(minXmaxY, Y[i])
    minXminY = min(minXminY, Y[i])
  if Y[i]==maxY:
    maxYmaxX = max(maxYmaxX, X[i])
    maxYminX = min(maxYminX, X[i])
  if Y[i]==minY:
    minYmaxX = max(minYmaxX, X[i])
    minYminX = min(minYminX, X[i])
ans = maxX - minX  + max(abs(maxXmaxY-minXminY),abs(maxXminY-minXmaxY))
ans = max(ans, maxY - minY  + max(abs(maxYmaxX-minYminX),abs(maxYminX-minYmaxX)))
ans = max(ans, maxYmaxX - minX + maxY - minXminY)
ans = max(ans, maxX - maxYminX + maxY - minXminY)
ans = max(ans, minYmaxX - minX + minXmaxY - minY)
ans = max(ans, maxX - minYminX + maxXmaxY - minY)
ans = max(ans, maxxy-minxy, maxnxy-minnxy)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
i, ma, mi = 0, 0, 10**9
x = []
y = []
while i < N
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)
    ma = max(x[i]*y[i], ma)
    mi = min(x[i]*y[i], mi)
    if ma == x[i]*y[i]:
        cma = i
    if mi == x[i]*y[i]:
        cmi = i
    i += 1
print(abs(x[cma] - x[cmi]) + abs(y[cma] - y[cmi]))

Submission status: Runtime Error

Solution code:
import numpy as np
from scipy.spatial.distance import cityblock


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

max = 0
for i in len(N):
    for j in len(N):
        # if s[i] == s[j]:
        #     continue
        # else:
        cb = abs(s[i][0] - s[j][0]) + abs(s[i][1] - s[j][1])
        if cb > max:
            max = cb
print(max)

Submission status: Runtime Error

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

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

#print(x_)
ans = 0
for l in range(n):
	for r in range(n-1,l,-1):
#		print(l,r)
		x = x_[r][0] - x_[l][0]
		if x < 0:
			x = -x
        y = x_[r][1] - x_[l][1]
		if y < 0:
			y = -y
		kyori = x + y

		print(kyori)
		if kyori > ans:
			ans = kyori
print(ans)

Submission status: Runtime Error

Solution code:
#ABC178 E
import numpy as np
n = int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
min = math.sqrt(10**9 *2)
max = 0
min_idx = 0
max_idx = 0
for i in range(n):
  tmp = x[i]**2 + y[i]**2
  if tmp < min:
    min_idx = i
  if tmp > max:
    max_idx = i

ans = abs(x[max_idx] - x[min_idx]) + abs(y[max_idx] - y[min_idx])
print(ans)

Submission status: Runtime Error

Solution code:
N=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: Runtime Error

Solution code:
N = int(input())
i, ma, mi = 0, 0, 10**18
x = []
y = []
while i < N
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)
    ma = max(x[i]*y[i], ma)
    mi = min(x[i]*y[i], mi)
    if ma == x[i]*y[i]:
        cma = i
    if mi == x[i]*y[i]:
        cmi = i
    i += 1
print(abs(x[cma] - x[cmi]) + abs(y[cma] - y[cmi]))

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import jit
n = int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

@jit
def one(x,y):
    a=np.zeros(0)
    b=np.zeros(0)
    for i in range(10000):
        for j in range(i+1,10000):
            a = np.insert(a,0,abs(x[j]-x[i]))
            b = np.insert(b,0,abs(y[j]-y[i]))
    c = a+b
    print(int(c[np.argmax(c)]))

one(x,y)

Submission status: Runtime Error

Solution code:
n=int(input())
l=[input().split() for _ in range(n)]
dp=[0]*(n+2)
dp1=[0]*(n+2)
for i in range(n):
    for j in range(1,n):
        if not (l[i][0]==0 and l[j][0]==0):
            dp[i+j] = max(abs(int(l[i][0]) - int(l[j][0])), dp[i+j-1])
        if not (l[i][1] == 0 and l[j][1] == 0):
            dp1[i+j] = max(abs(int(l[i][1]) - int(l[j][1])), dp[i+j-1])
dp=sorted(dp)
dp1=sorted(dp1)
print(int(dp[-1])+int(dp1[-1]))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
a = [[0] *2] * N
for i in range(N):
    a[i] = list(map(int, input().split()))
cities = np.array(a)
all_diffs = np.expand_dims(cities, axis=1) - np.expand_dims(cities, axis=0)
distance = np.sum(np.abs(all_diffs), axis=-1)
print(np.max(distance))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

lg = 0
for i in range(a):
  for j in range(i,a):
    tl = abs(b[i][0] - b[j][0])
    if t1 < lg: continue
    t2 = abs(b[i][1] - b[j][1])
    t3 = t1 + t2
    lg = t3 if t3 > lg else lg

print(lg)

Submission status: Runtime Error

Solution code:
N = int(input())

ListN = [[0 for i in range(2)] for j in range(N)]

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

ListN = list(map(list, set(map(tuple, ListN))))

ListNZ = [0 for i in range(N)]

minz =10**9
maxz =0 

mini=0
maxi=0

for i in range(N):
  ListNZ = (ListN[i][0]**2 + ListN[i][i]**2)**0.5
  if minz >= ListNZ[i]:
    mini = i
  elif  maxz <= ListNZ[i]:
    maxi = i
      
print(abs(ListN[mini][0] - ListN[maxi][0]) + abs(ListN[mini][1] - ListN[maxi][1]))

Submission status: Runtime Error

Solution code:
from sys import stdin

N = int(stdin.readline().strip())
vals = [None,None,None,None]
xminy_min = float("inf")
xminy_max = 0 
xplusy_min = float("inf")
xplusy_max = 0
for _ in range(N):
    x,y = map(int,stdin.readline().strip().split())
    xpy = abs(x+y)
    xmy = abs(x-y)
    if xpy < xplusy_min:
        xplusy_min = xpy
        vals[2] = (x,y)
    if xpy > xplusy_max:
        xplusy_max = xpy
        vals[3] = (x,y)
    
    if xmy < xminy_min:
        xminy_min = xmy
        vals[0] = (x,y)
    if xmy > xminy_max:
        xminy_max = xmy
        vals[1] = (x,y)

g_max = 0
for i in range(4):
    for j in range(i+1,4):
        x_diff = abs(vals[i][0] - vals[j][0])
        y_diff = abs(vals[i][1]-vals[j][1])
        g_max = max(g_max,x_diff+y_diff)
print(g_max)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from sys import stdin

N = int(stdin.readline().strip())
vals = [None,None,None,None]
xminy_min = float("inf")
xminy_max = 0 
xplusy_min = float("inf")
xplusy_max = 0
for _ in range(N):
    x,y = map(int,stdin.readline().strip().split())
    xpy = abs(x+y)
    xmy = abs(x-y)
    print("yes")
    if xpy < xplusy_min:
        xplusy_min = xpy
        vals[2] = (x,y)
    if xpy > xplusy_max:
        xplusy_max = xpy
        vals[3] = (x,y)
    
    if xmy < xminy_min:
        xminy_min = xmy
        vals[0] = (x,y)
    if xmy > xminy_max:
        xminy_max = xmy
        vals[1] = (x,y)

g_max = 0
print(vals)
for i in range(4):
    for j in range(i+1,4):
        x_diff = abs(vals[i][0] - vals[j][0])
        y_diff = abs(vals[i][1]-vals[j][1])
        g_max = max(g_max,x_diff+y_diff)
print(g_max)

Submission status: Runtime Error

Solution code:
n = int(input())

mod = pow(10, 9) + 7
l = []
for i in range(2001):
    if i < 3:
        l.append(0)
    elif 3 <= i <= 5:
        l.append(1)
    else:

        sum_ = 1
        for j in range(i-5):
            sum_ += l[i-(3+j)]
            sum_ = sum_ % mod
        l.append(sum_)

print(l[n])