Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = ir()
a = lr()
total = 0
for i,num in enumerate(a):
    a[i]=(num-(i+1))
mean = sum(a)//n-1
ans = [0,0,0]
for i in range(mean, mean+3):
    tmp = i%3
    for num in a:
        ans[tmp]+=abs(num-i)
print(min(ans))

Fixed submission:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

n = ir()
a = lr()
total = 0
for i,num in enumerate(a):
    a[i]=(num-(i+1))
a.sort()
if n%2 == 0:
    mean = (a[n//2-1]+a[n//2])//2
else:
    mean = a[n//2]
ans = [0,0]
for i in range(mean, mean+2):
    tmp = i%2
    for num in a:
        ans[tmp]+=abs(num-i)
print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import sys
inf = 10**9+7
mod = 10**9+7
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
b.sort()
c.sort()
b_len = len(b)
c_len = len(c)
count = 0
b_list = [0 for i in range(b_len)]

for i,num in enumerate(b):
    ind_c = bisect.bisect_left(c, num)
    if c_len == ind_c:
        continue
    else:
        if c[ind_c] == num:
            while ind_c != c_len and c[ind_c] == num:
                ind_c+=1
            if ind_c != c_len:
                b_list[i] = c_len-ind_c
        else:
            b_list[i] = c_len-ind_c

# 累積和
a2 = [0]
for i in b_list:a2.append(a2[-1]+i)
def SumArea(l, r):
    return a2[r]-a2[l]


for num in a:
    ind_b = bisect.bisect_left(b, num)
    if b_len == ind_b:
        continue
    else:
        if b[ind_b] == num:
            while ind_b != b_len and b[ind_b] == num:
                ind_b += 1
            if ind_b != b_len:
                count += SumArea(ind_b, b_len)
        else:
            count += SumArea(ind_b, b_len)
print(count)


Fixed submission:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import sys
inf = 10**9+7
mod = 10**9+7
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
b.sort()
c.sort()
b_len = len(b)
c_len = len(c)
count = 0
b_list = [0 for i in range(b_len)]

for i,num in enumerate(b):
    ind_c = bisect.bisect_left(c, num)
    if c_len == ind_c:
        continue
    else:
        if c[ind_c] == num:
            ind_c = bisect.bisect_left(c, num+1)
            if c_len == ind_c:
                continue
            else:
                b_list[i] = c_len - ind_c
        else:
            b_list[i] = c_len-ind_c

# 累積和
a2 = [0]
for i in b_list:a2.append(a2[-1]+i)
def SumArea(l, r):
    return a2[r]-a2[l]


for num in a:
    ind_b = bisect.bisect_left(b, num)
    if b_len == ind_b:
        continue
    else:
        if b[ind_b] == num:
            ind_b = bisect.bisect_left(b, num+1)
            if b_len == ind_b:
                continue
            else:
                count += SumArea(ind_b, b_len)
        else:
            count += SumArea(ind_b, b_len)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10 ** 15
mod = 10 ** 9 + 7
s = input()
n = len(s)
# 区間DP ダルマ落とし
dp = [[0 for j in range(n)]for i in range(n)] # iからjまで崩せる最大値 (0オリジン)
for k in range(1,n):  # 区間長1からn-1
    for i in range(0,n-k):  # i が区間の始まり   i+k が区間の終わり
        # 両端が揃ったら消せる かつ 間が全部消えるなら
        if s[i] == 'S' and s[i+k] == 'T' and dp[i+1][i+k-1] == k-1:
            dp[i][i+k] = dp[i+1][i+k-1] + 2
        else:
            # i+j が区間を区切るところ(i+jは左側に含まれる)  | i ~ i+j  |  i+j+1 ~ i+k | で考えてる。
            # 今回は今回はダルマを崩す順番の問題
            for j in range(k):
                dp[i][i+k] = max(dp[i][i+k], dp[i][i+j] + dp[i+j+1][i+k])
print(n-dp[0][n-1])

Fixed submission:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10 ** 15
mod = 10 ** 9 + 7
s = input()
n = len(s)
stack = []
for c in s:
    if c == 'S':
        stack.append(c)
    if c == 'T':
        if stack:
            if stack.pop() == 'T':
                stack.append('T')
                stack.append(c)
        else:
            stack.append(c)
print(len(stack))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*A,=map(int,input().split())

M=1000*1000*1000+7

SS=0
for i in range(N-1):
  SS+=A[i]*sum(A[i+1:])

print("{}".format(SS%M))



Fixed submission:
N=int(input())
*A,=map(int,input().split())
M=1000*1000*1000+7
S=[0]*N

SS=0
for i in range(N-1,0,-1):
  S[i-1]=A[i]+S[i]
  SS+=A[i-1]*S[i-1]

print("{}".format(SS%M))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*A,=map(int,input().split())
M=1000*1000*1000+7
S=0
for i in range(N-1):
  for j in range(i+1,N):
    S+=A[i]*A[j]
    
print("{}".format(S%M))




Fixed submission:
N=int(input())
*A,=map(int,input().split())
M=1000*1000*1000+7
S=[0]*N

SS=0
for i in range(N-1,0,-1):
  S[i-1]=A[i]+S[i]
  SS+=A[i-1]*S[i-1]

print("{}".format(SS%M))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
*A,=map(int,input().split())
A=[1]+A
Ps=[1]*(N+1)

Ps[1]=A[1]
for i in range(2,K+1):
  Ps[i]=Ps[i-1]*A[i]
  
for i in range(K+1,N+1):
  Ps[i] = Ps[i-1]//A[i-K]*A[i]
  if Ps[i-1]<Ps[i]:
    print('Yes')
  else:
    print('No')

Fixed submission:
N,K=map(int,input().split())
*A,=map(int,input().split())
A=[1]+A

for i in range(K+1,N+1):
  if A[i-K]<A[i]:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
def check():
  deltaD=B-A
  deltaV=V-W
  if deltaD<0:
    return 'NO'  
  if deltaD==0:
    return 'YES'
  if deltaV<=0:
    return 'NO'
  if deltaV>0:
     if T>=deltaD//deltaV:
       return 'YES'
  return 'NO'

print(check())

Fixed submission:
#
print(input()[0:3])

Buggy python submission (verdict: Runtime Error):
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())

def check():
  deltaD=B-A
  deltaV=V-W
  if deltaD<0:
    return 'NO'  
  if deltaD==0:
    return 'YES'
  if deltaV<=0:
    return 'NO'
  if T>=deltaD//deltaV:
     return 'YES'
print(check())

Fixed submission:
#
print(input()[0:3])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
*A,=map(int,input().split())

def mul(A):
    m=1
    for na in A:
        if na==0:
            return 0
        m *= na
    if m>10**18:
       return -1
    return m
    
print(mul(A))

Fixed submission:
N=int(input())
*A,=map(int,input().split())

A=sorted(A,reverse=True)
def mul(A):
    if 0 in A:
      return 0
    m=1
    for na in A:
        m*=na
        if m>10**18:
          return -1
    return m
    
print(mul(A))
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
*H,=map(int,input().split())

rode=[[0 for _ in range(N)] for _ in range(N)] 
dmax=[0 for _ in range(N+1)]

for j in range(M):
    a,b=map(int,input().split())
    rode[a-1][b-1]=1
    dmax[a-1]=max(dmax[a-1],H[b-1])
    dmax[b-1]=max(dmax[b-1],H[a-1])    
          
goodv = [1 for i in range(N) if dmax[i]<H[i]]
print(len(goodv))



Fixed submission:
N,M=map(int,input().split())
*H,=map(int,input().split())

dmax=[0 for _ in range(N+1)]

for j in range(M):
    a,b=map(int,input().split())
    dmax[a-1]=max(dmax[a-1],H[b-1])
    dmax[b-1]=max(dmax[b-1],H[a-1])    
          
goodv = [1 for i in range(N) if dmax[i]<H[i]]
print(len(goodv))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
*H,=map(int,input().split())

rode=[[0 for _ in range(N)] for _ in range(N)]

for j in range(M):
    a,b=map(int,input().split())
    rode[a-1][b-1]=rode[b-1][a-1]=1

def trv(i):
  maxh=H[i]
  for j in range(N):
    if rode[i][j]>0:
        if H[j]>=maxh:
          return False
  return True

goodv = [1 for i in range(N) if trv(i) ]
print(len(goodv))

Fixed submission:
N,M=map(int,input().split())
*H,=map(int,input().split())

dmax=[0 for _ in range(N+1)]

for j in range(M):
    a,b=map(int,input().split())
    dmax[a-1]=max(dmax[a-1],H[b-1])
    dmax[b-1]=max(dmax[b-1],H[a-1])    
          
goodv = [1 for i in range(N) if dmax[i]<H[i]]
print(len(goodv))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math

N=int(input())
*A,=map(int,input().split())

def agent(a,i,j):
  return abs(i-j)==abs(a[i-1]+a[j-1])

count=0
X=list(range(1,N+1))
for c in itertools.combinations(X,2):
   if agent(A,*c):
      count+=1
      
print(count)
      

Fixed submission:
 
N=int(input())
*A,=map(int,input().split())
ref,count={},0

for i,a in enumerate(A):
  if i-a in ref:
     count += ref[i-a]
  if i+a in ref:
     ref[i+a]+=1
  else:
     ref[i+a]=1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=set({})
for _ in range(N):
  S = S | {input()}
  
x=list(S)
print(len(x))
  

Fixed submission:
N=int(input())
hash = {}
count=0
for _ in range(N):
    s=input()
    if s in hash:
      continue
    else:
      hash[s]=1
      count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import math
K=int(input())
GCD=[[0]*(K+2) for _ in range(K+2)]

def divable(a,b):
    if a==b:
        return a
    if a<b:
        a,b=b,a
    if a%b>0:
        return 1
    return math.gcd(a,b)

def make_GCD(K):
    for a in range(1,K+1):
        for b in range(1,K+1):
            GCD[a][b]=math.gcd(a,b)            
def gcd3(a,b,c):
    if a<b:
        a,b=b,a
    a=GCD[a][b]
    return GCD[a][c]
make_GCD(K)
ans=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd3(a,b,c)
            
print(ans)

Fixed submission:
K=int(input())
GCD=[[0]*(K+2) for _ in range(K+2)]
import math
def make_GCD(K):
    for a in range(1,K+1):
        for b in range(1,K+1):
            GCD[a][b]=math.gcd(a,b)            
make_GCD(K)

def gcd3(a,b,c):
    a=GCD[a][b]
    return GCD[a][c]
ans=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd3(a,b,c)            
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())

delta = abs(N-K)
print(min(N,N%K,N%delta))

Fixed submission:
N,K=map(int,input().split())
N=N%K
print(min(N,abs(N-K)))

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())

delta = abs(N-K)

while N>=delta:
  N//=delta
  delta = abs(N-K)
  if delta==0:
    N=0
    break
  
print(N)

Fixed submission:
N,K=map(int,input().split())
N=N%K
print(min(N,abs(N-K)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
*a,= map(int, input().split())

count,res={},{}

for i in range(N):
  count[a[i]]=0
  res[a[i]]=0
  
for i in range(N):
  count[a[i]]+=1

def ncn(n):
  return n*(n-1)//2

def without(a,k):
  cc = 0
  for key in count.keys():
    kc = count[key]
    if key==a[k]:
       kc-=1
    if kc>1:
       cc+=ncn(kc)
  res[a[k]]=cc      
  return cc

def result(n):
  if res[n]>0:
    return res[n]
  return 0

for k in range(N):
  if result(a[k])>0:
    print(result(a[k]))
  else:
    print(without(a,k))

Fixed submission:
N = int(input())
*a,= map(int, input().split())
count,result={},{}

for i in range(N):
  count[a[i]]=0
  result[a[i]]=0
  
def ncn(n):
  return n*(n-1)//2

for i in range(N):
  count[a[i]]+=1

total=0
for key in count.keys():
  kc = count[key]
  result[key]=ncn(kc)
  total += result[key]
  
def without(k):
  return total-count[a[k]] + 1

for k in range(N):
  print(without(k))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
*a,= map(int, input().split())
count={}
for i in range(N):
  count[a[i]]=0
for i in range(N):
  count[a[i]]+=1

def ncn(n):
  return n*(n-1)//2

def without(a,k):
  cc = 0
  for key in count.keys():
    kc = count[key]
    if key==a[k]:
       kc-=1
    if kc>1:
       cc+=ncn(kc)
  return cc
   
for k in range(N):
  print(without(a,k))

Fixed submission:
N = int(input())
*a,= map(int, input().split())
count,result={},{}

for i in range(N):
  count[a[i]]=0
  result[a[i]]=0
  
def ncn(n):
  return n*(n-1)//2

for i in range(N):
  count[a[i]]+=1

total=0
for key in count.keys():
  kc = count[key]
  result[key]=ncn(kc)
  total += result[key]
  
def without(k):
  return total-count[a[k]] + 1

for k in range(N):
  print(without(k))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
*a,= map(int, input().split())
def without(a,k):
  return a[0:k]+a[k+1:]

def sames(x):
  x=sorted(x)
  count=0
  for i in range(len(x)):
    ch=x[i]
    for j in range(i+1,len(x)):
      if x[j]!=ch:
        break
      else:
        count+=1
  return count

for k in range(N):
  print(sames(without(a,k)))

Fixed submission:
N = int(input())
*a,= map(int, input().split())
count,result={},{}

for i in range(N):
  count[a[i]]=0
  result[a[i]]=0
  
def ncn(n):
  return n*(n-1)//2

for i in range(N):
  count[a[i]]+=1

total=0
for key in count.keys():
  kc = count[key]
  result[key]=ncn(kc)
  total += result[key]
  
def without(k):
  return total-count[a[k]] + 1

for k in range(N):
  print(without(k))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
*p,= map(int, input().split())

s=[(p[n]+1)/2 for n in range(N)]
S=[0 for _ in range(N)]

S[0]=s[0]
for n in range(N-1):
    S[n+1]=s[n+1]+S[n]

def sjk(j):
    return S[j+K]-S[j]
delta = [sjk(i) for i in range(N-K)]

print(max(delta))

Fixed submission:
N,K=map(int,input().split())
*p,= map(int, input().split())

s=[(p[n]+1)/2 for n in range(N)]
S=[0]*(N+1)

def make_S(n):
    S=[0]*(n+1)
    S[0]=0
    for i in range(n):
        S[i+1]=S[i]+s[i]
    return S
S=make_S(N)

def max_delta(n,k):
    max=-1000000
    for i in range(n-k+1):
        delta = S[i+k]-S[i]
        if delta>max:
            max=delta
    return max

print(max_delta(N,K))

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
*p,= map(int, input().split())

def ex(n):
    return sum(range(1,n+1))/n    
def  ex3(p):
    return sum([ex(n) for n in p])
M=0
for i in range(N-K+1):
    x = p[i:i+K]   
    M=max(M,ex3(x))
print (M)


Fixed submission:
N,K=map(int,input().split())
*p,= map(int, input().split())

s=[(p[n]+1)/2 for n in range(N)]
S=[0]*(N+1)

def make_S(n):
    S=[0]*(n+1)
    S[0]=0
    for i in range(n):
        S[i+1]=S[i]+s[i]
    return S
S=make_S(N)

def max_delta(n,k):
    max=-1000000
    for i in range(n-k+1):
        delta = S[i+k]-S[i]
        if delta>max:
            max=delta
    return max

print(max_delta(N,K))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input().split()
NS = [int(i) for i in S]
def exist():
    s=0
    for i in range(N):
      if min(NS[:i+1])>=NS[i]:
         s+=1
    return s
if __name__=='__main__':
   print(exist())
    

Fixed submission:
N=int(input())
S=input().split()
NS = [int(i) for i in S]
def minL():
  ml=[NS[0]]
  for i in range(1,N):
     ml+=[min(ml[i-1],NS[i])]
  return ml  

MINL=minL()
def exist():
    s=0
    for i in range(N):
      if MINL[i]>=NS[i]:
         s+=1
    return s
if __name__=='__main__':
   print(exist())

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input().split()
NS = [int(i) for i in S]
def exist():
    s=0
    for i in range(N):
      cond=True
      for j in range(0,i):
         if NS[i]>NS[j]:
            cond=False
            break
      if cond:
        s+=1   
    return s
if __name__=='__main__':
   print(exist())

Fixed submission:
N=int(input())
S=input().split()
NS = [int(i) for i in S]
def minL():
  ml=[NS[0]]
  for i in range(1,N):
     ml+=[min(ml[i-1],NS[i])]
  return ml  

MINL=minL()
def exist():
    s=0
    for i in range(N):
      if MINL[i]>=NS[i]:
         s+=1
    return s
if __name__=='__main__':
   print(exist())

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input().split()
NS = [int(i) for i in S]
def exist():
    s=0
    for i in range(N):
      cond=True
      for j in range(0,i):
         if NS[i]>NS[j]:
            cond=False
      if cond:
        s+=1   
    return s
if __name__=='__main__':
   print(exist())

Fixed submission:
N=int(input())
S=input().split()
NS = [int(i) for i in S]
def minL():
  ml=[NS[0]]
  for i in range(1,N):
     ml+=[min(ml[i-1],NS[i])]
  return ml  

MINL=minL()
def exist():
    s=0
    for i in range(N):
      if MINL[i]>=NS[i]:
         s+=1
    return s
if __name__=='__main__':
   print(exist())
Buggy python submission (verdict: Runtime Error):
N,K,M=map(int, input().split(' '))
Ai =input().split(' ')
Ais = [int(s) for s in Ai]

goal = M*N
if __name__=='__main__':
  rest=goal-sum(Ais)
  print( max(0,rest) if rest<=K else -1 )



Fixed submission:
alpha = 'abcdefghijklmnopqrstuvwxyz'
if __name__=='__main__':
    print(alpha[1+alpha.index(input())])

Buggy python submission (verdict: Runtime Error):
N,K,M=map(int, input().split(' '))
Ai =input().split(' ')
Ais = [int(s) for s in Ai]

goal = M*N
current = sum(Ais)

if __name__=='__main__':
  rest=goal-sum(Ais)
  print( max(0,rest) if rest<=K else -1 )


Fixed submission:
alpha = 'abcdefghijklmnopqrstuvwxyz'
if __name__=='__main__':
    print(alpha[1+alpha.index(input())])

Buggy python submission (verdict: Runtime Error):
alpha = 'abcdefghijklmnopqrstuvwxy'
if __name__=='__main__':
    s=input()
    i = alpha.index(s)
    print(alpha[i+1])

Fixed submission:
alpha = 'abcdefghijklmnopqrstuvwxyz'
if __name__=='__main__':
    print(alpha[1+alpha.index(input())])
Buggy python submission (verdict: Runtime Error):
def get_num():
    n = int(input())
    w = int(input())
    return n,w

def check_range(n,w):
    return n in range(1,101) and w in range(n**2)


def black_tiles(n,w):
    if (check_range(n,w)):
        return n**2 - w
    else:
        raise Exception('Value out of range')


if (__name__=='__main__'):
    n,w = get_num()
    print(black_tiles(n,w))
    

Fixed submission:
def get_num():
    n = int(input())
    w = int(input())
    return n,w

def check_range(n,w):
    return n in range(1,101) and w in range(n**2+1)

def black_tiles(n,w):
    if (check_range(n,w)):
        return n**2 - w
    else:
        raise Exception('Value out of range')

if (__name__=='__main__'):
    print(black_tiles(*get_num()))

Buggy python submission (verdict: Runtime Error):
def get_num():
    n = int(input())
    w = int(input())
    return n,w

def check_range(n,w):
    return n in range(1,101) and w in range(n**2)

def black_tiles(n,w):
    if (check_range(n,w)):
        return n**2 - w
    else:
        raise Exception('Value out of range')

if (__name__=='__main__'):
    print(black_tiles(*get_num()))
    

Fixed submission:
def get_num():
    n = int(input())
    w = int(input())
    return n,w

def check_range(n,w):
    return n in range(1,101) and w in range(n**2+1)

def black_tiles(n,w):
    if (check_range(n,w)):
        return n**2 - w
    else:
        raise Exception('Value out of range')

if (__name__=='__main__'):
    print(black_tiles(*get_num()))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
import math

A = 1
count = 0
while A < N:
	B = 1
	while A * B < N:
		B += 1
		count += 1
	A += 1
print(count)


Fixed submission:
N = int(input())
import math

A = 1
count = 0
while A < N:
	B = 1
	while A * B < N:
		B += 1
		count += 1
	A += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

table_p = {}
table_m = {}

points = []
for _ in range(N):
	x, y = map(int, input().split())
	points.append((x, y))
	a = x + y
	b = x - y
	if a in table_p:
		table_p[a].append((x, y))
	else:
		table_p[a] = [(x, y)]
	if b in table_m:
		table_m[b].append((x, y))
	else:
		table_m[b] = [(x, y)]

list_p = []
list_m = []
for a, ps in table_p.items():
	list_p.append((a, ps[0]))

for b, ps in table_m.items():
	list_m.append((b, ps[0]))

list_p.sort()
list_m.sort()

topvalue = 0

for x, y in points:
	topvalue = max(topvalue, 
		m_dis(x, y, list_p[0][1][0], list_p[0][1][1]),
		m_dis(x, y, list_p[-1][1][0], list_p[-1][1][1]),
		m_dis(x, y, list_m[0][1][0], list_m[0][1][1]),
		m_dis(x, y, list_m[-1][1][0], list_m[-1][1][1]))

print(topvalue)


Fixed submission:
N = int(input())

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

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

x, y = points[0]

maxvalue_p = x + y
minvalue_p = x + y
maxvalue_m = x - y
minvalue_m = x - y
maxvalue_p_p = points[0]
minvalue_p_p = points[0]
maxvalue_m_p = points[0]
minvalue_m_p = points[0]

for x, y in points:
	p = x + y
	m = x - y
	if maxvalue_p == None or maxvalue_p < p:
		maxvalue_p = p
		maxvalue_p_p = (x, y)
	if minvalue_p == None or minvalue_p > p:
		minvalue_p = p
		minvalue_p_p = (x, y)
	if maxvalue_m == None or maxvalue_m < m:
		maxvalue_m = m
		maxvalue_m_p = (x, y)
	if minvalue_m == None or minvalue_m > m:
		minvalue_m = m
		minvalue_m_p = (x, y)

topvalue = 0

for x, y in points:
	topvalue = max(topvalue, 
		m_dis(x, y, maxvalue_p_p[0], maxvalue_p_p[1]),
		m_dis(x, y, minvalue_p_p[0], minvalue_p_p[1]),
		m_dis(x, y, maxvalue_m_p[0], maxvalue_m_p[1]),
		m_dis(x, y, minvalue_m_p[0], minvalue_m_p[1]))

print(topvalue)