TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
a=input().split()
b=map(int,a)
maximum=max(b)
minimum=min(b)
print(maximum-minimum)

q=input()
a=input().split()
b=map(int,a)
maximum=max(b)
minimum=min(b)
print(maximum-minimum)

q=input()
a=input().split()
b=[int(i) for i in a]
maximum=max(b)
minimum=min(b)
print(maximum-minimum)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))

for i in a:
    if i < 0:
        i *= -1

a.sort()
print(a[0]-a[-1])


n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    if a[i] < 0:
        a[i] *= -1

a.sort()
print(a[-1]-a[0])


Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())

a = [int(i) for i in input().split()]

i=0

c=0
max = 0
min = 0
for i in a[i]:
  if a[i] >= max:
    max = a[i]
  elif a[i] <= min:
    min = a[i]
  else
    i +=1
    
print (max - min)
  


N = int(input())

a = [int(i) for i in input().split()]

i=0

max = 0
min = 0
for i in range(n):
  if a[i] >= max:
    max = a[i]
  elif a[i] <= min:
    min = a[i]
  else:
    continue
    
print (max - min)
  

N = int(input())

a = [int(i) for i in input().split()]

i=0

max = 0
min = 0
for i in range(n):
  if a[i] >= max:
    max = a[i]
  elif a[i] <= min:
    min = a[i]
  else
    continue
    
print (max - min)
  


N = int(input())

a = [int(i) for i in input().split()]

i=0

c=0
max = 0
min = 0
for i in range(n):
  if a[i] >= max:
    max = a[i]
  elif a[i] <= min:
    min = a[i]
  else
    i +=1
    
print (max - min)
  


n = int(input())
a = list(map(int, input().split()))
dist = []
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        dist.append(abs(a[i]-a[j]))
print(max(dist))


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n = int(input())
A = list(map(int, input().split()))

ANS = []
for i in range(len(A)):
  for j in range(i,len(A)+1):
    ANS.append(abs(A[i] - A[j]))
    
print(max(ANS))

n = int(input())
A = list(map(int, input().split()))

ANS = []
for i in range(len(A)):
  for j in range(i,len(A)):
    ANS.append(abs(A[i] - A[j]))
    
print(max(ANS))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
#-*-coding:utf-8-*-

def main():
    
    N = int(input())
    lists = list(map(int, input().split()))

    
    max_element = 0

    
    for i in range(1, N):
        diff = lists[i] - lists[i-1]
        if diff > max_element:
            max_element = diff

    print(max_element)


if __name__ == '__main__':
    main()

#-*-coding:utf-8-*-

def main():
    
    N = int(input())
    lists = list(map(int, input().split()))

    
    max_element = 0
    min_element = lists[0]

    
    for i in range(N):
        if lists[i] > max_element:
            max_element = lists[i]
        if lists[i] < min_element:
            min_element = lists[i]

    print('{}'.format(max_element - min_element))

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
 = input()
A = list(map(int, input().split()))
print(max(A) - min(A))

_ = input()
A = list(map(int, input().split()))
print(max(A) - min(A))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n=int(input())
A=list(map(int,input().split()))
A=sorted(A)
ans=A[n-1]-A[1]
print(ans)

n=int(input())
A=list(map(int,input().split()))
print(max(A)-min(A))

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N=int(input())
A=[int(i) for i in input()]
maxv=A[0]
minv=A[1]-A[0]
for i in range(N):
  maxv=max(maxv,abs(A[i]-minv))
  minv=min(minv,A[i])
print(maxv)

N=int(input())
A=[int(i) for i in input()]
maxv=A[0]
minv=A[1]-A[0]
for i in range(N):
  maxv=max(maxv,A[i]-minv)
  minv=min(minv,A[i])
print(maxv)

N=int(input())
A=[int(i) for i in input()]
maxv=A[0]
minv=A[0]
for i in range(N):
  maxv=max(maxv,A[i])
  minv=min(minv,A[i])
print(maxv-minv)

N=int(input())
A=[int(i) for i in input().split()]
maxv=A[0]
minv=A[0]
for i in range(N):
  maxv=max(maxv,A[i])
  minv=min(minv,A[i])
print(maxv-minv)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
def main():
	N = int(input())
	seq = list(map(int, input().split()))
	maks = 0
	for i in range(1, N):
		maks = max(seq[i] - seq[i - 1])
	print(maks)
	return 0
main()

def main():
	N = int(input())
	seq = list(map(int, input().split()))
	maks = 0
	for i in range(0, N):
		for j in range(i, N):
			maks = max(abs(seq[j] - seq[i]), maks)
	print(maks)
	return 0
main()

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
A = map(int, input().split())
max = 0
min = 0
for i in A:
  if max < i:
     max = i
  if min > i:
    min = i
print("{}".format(max - min))

N = int(input())
A = sorted(map(int, input().split()))
print(A[-1] - A[0])

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
_ = input()
lst = map(int, input().split())

print(max(lst) - min(lst))

_ = input()
lst = [int(i) for i in input().split()]

print(max(lst) - min(lst))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n,a=open(0);s=sorted(map(int,a.split()));print(s[-1]-s[1])

n,a=open(0);s=sorted(map(int,a.split()));print(s[-1]-s[0])

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n = int(input())
A = list(map(int,input().split())
A = sorted(A)
x = A[-1]-A[0]
print(x)



n = int(input())
S = list(map(int,input().split())

a=soretd(S)
print(max(a)-min(a))


a = list(map(int, input().split()))
a.sort()
print(a[-1] - a[0])


n = int(input())
S = list(map(int,input().split())

a=soretd(S)
print(a[-1]-a[1])


n = int(input())
A = list(map(int,input().split()))
A = sorted(A)
x = A[-1]-A[0]
print(x)


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
_n = int(input())
list = map(int(), input().split())
list.sort()

print(list[-1] - list[0])

_n = int(input())
lists = list(map(int(), input().split()))
lists.sort()

print(lists[-1] - lists[0])

_n = int(input())
lists = list(map(int, input().split()))
lists.sort()

print(lists[-1] - lists[0])

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = 0
val_min = 0
for i in range(0,N):
  if val_max < lst[i]:
    val_max = lst[i]
  elif val_min > lst[i]:
    val_min = lst[i]
print(val_max-val_min)


N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = 0
val_min = 0
for i in range(0,N):
  if val_max < i:
    val_max = i
  elseif val_min > i:
    val_min = i
print(val_max-val_min)

N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = 0
val_min = 0
for i in range(0,N):
  if val_max < i:
    val_max = i
  elif val_min > i:
    val_min = i
print(val_max-val_min)


N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = lst[0]
val_min = lst[0]
for i in lst:
  if val_max < i:
    val_max = i
  elif val_min > i:
    val_min = i
  
print(val_max-val_min)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
print(abs(max(a)-min(a))

n=int(input())
a=list(map(int,input().split()))
print(abs(a.max()-a.min())

n=int(input())
a=list(map(int,input().split()))
print(abs(max(a)-min(a)))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    print(max(A) - min(B))


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    print(max(A) - min(A))


Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
a=list(map(int,input().split()))
print(max(a)-min(a))

o=input()
a=list(map(int,input().split()))
print(max(a)-min(a))


Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
A = map(int, input().split())

As = A.sort()
ans = As[len(N)-1] - As[0]
print(ans)

N = int(input())
A = [int(i) for i in input().split()]

As = sorted(A)
ans = As[N-1] - As[0]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
if __name__ == '__main__':
    s = input()
    a = [int(i) for i in s.split()]
    mina = min(a)
    maxa = max(a)
    print(maxa - mina)



if __name__ == '__main__':
    n = input()
    s = input()
    a = [int(i) for i in s.split()]
    mina = min(a)
    maxa = max(a)
    print(maxa - mina)


Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
maxi = 0
for i in range(N-1):
  maxi = max(maxi,A[i]-A[i+1])
print(maxi)

N = int(input())
A = map(int,input())
maxi = 0
for i in range(N-1):
  maxi = max(maxi,A[i]-A[i+1])
print(maxi)

N = int(input())
A = list(map(int,input().split()))
maxi = 0
mini = float("inf")
for n in A:
  maxi = max(maxi,n)
  mini = min(mini,n)
print(maxi-mini)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
As = map(int, input().split())
max_diff = - float('inf')
for i in range(N):
    for j in range(i + 1, N):
        max_diff = max(max_diff, abs(As[i] - As[j]))
print(max_diff)


N = int(input())
As = list(map(int, input().split()))
max_diff = - float('inf')
for i in range(N):
    for j in range(i + 1, N):
        max_diff = max(max_diff, abs(As[i] - As[j]))
print(max_diff)



Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
nums = list(map(int,input().split(' ')))

max = 0
min = 1000000000

for i in nums:
    if i>max:
        max = i
    elif i<min:
        min = i
    
print(max-min)



N = int(input())
nums = list(map(int,input().split(' ')))

max = 0
min = 0

for i in nums:
    if i>max:
        max = i
    elif i<min:
        min = i
    
print(max-min)

N = int(input())
nums = list(map(int,input().split(' ')))

max = 0
min = 1000000000

for i in nums:
    if i>max:
        max = i
    if i<min:
        min = i
    
print(max-min)



Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n = int(input())
A = [map(int,input().split())]
print(max.A - min.A)

n = int(input())
A = [map(int,input().split())]
print(max(A) - min(A))


n = int(input())
A = list(map(int,input().split()))
print(max(A) - min(A))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N=int(input())
lst=input().split()
lst_i=[int(i) for i in lst]
a=max(lst_i)
b=min(lst_i)
print(lst_i)
print(abs(a-b))

N=int(input())
a=list(map(int,input().split()))
print(abs(max(a)-min(a)))

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n=input()
a=[int(i) for i in input().split(' ')]
a.sort()
print(a[N-1]-a[0])

n=input()
a=[int(i) for i in input().split(' ')]
a.sort()
print(a[-1]-a[0])

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = input()
a = sorter(map(int,input().split()))

print(a[-1] - a[0])

N = input()
a = sorted(map(int,input().split()))

print(a[-1] - a[0])


Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
A = map(int,input().split())
print(max(A)-min(A))

N = int(input())
A = map(int,input().split())
print(max(A)-min(A))

N = int(input())
A = list(map(int,input().split()))
print(max(A)-min(A))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
a = list(map(int, input().split()))
max = 0

for i in range(len(a)-1):
    if max < abs(a[i]-a[i+1]):
        max = abs(a[i]-a[i+1])

print(max)

a = list(map(int, input().split()))
print(max(a)-min(a))

a = list(map(int, input().split()))
print(max(a)-min(a))

n = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n = int(input())
l = [int(input()) for i in range(n)]
l.sort()
print(abs(l[0]) - l[-1])

n = int(input())
l = list(map(int, input().split()))
l.sort()
print(abs(int(l[0]) - int(l[-1])))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split))
print(max(A)- min(A))

N = int(input())
A = list(map(int, input().split()))
print(max(A)- min(A))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
ls = map(int,input().split())
print(max(ls)-min(ls))

N = int(input())
ls = list(map(int,input().split()))
print(max(ls)-min(ls))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N=int(input)
A=list(map(int,input().split()))
A.sort()
print(A[-1]-A[0])


N=int(input())
A=list(map(int,input().split()))
min=A[0]
max=A[0]
for i in range(N):
    if min>A[i]:
        min=A[i]
    if max<A[i]:
        max=A[i]

print(max-min)


Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n = int(input())
a = map(int, input().split())

mn = 10 ** 9
mx = 0

for i in range(n):
  if a[i] < mn:
    mn = a[i]
    
  if a[i] > mx:
    mx = a[i]

print(mx - mn)

n = int(input())
a = [int(i) for i in input().split()]
 
mn = 10 ** 9
mx = 0
 
for i in range(n):
  if a[i] < mn:
    mn = a[i]
    
  if a[i] > mx:
    mx = a[i]
  
print(mx - mn)

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
input()
num_list = [int(x) for x in input().split()]

print(num_list.max - num_list.min )

input()
num_list = [int(x) for x in input().split()]

print(max(num_list)- min(num_list))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = input()
A = input()

A_list = [A[i: i + 1] for i in range(0, len(A), 1)]

A_list_int = list(map(int, A_list))

max = max(A_list_int)
min = min(A_list_int)

print(max - min)

N = input()
A = input()


A_list = []
for i in range(0, len(A), 1):
    A_list.append(int(A[i: i + 1]))


A_list_int = list(map(int, A_list))

max = max(A_list_int)
min = min(A_list_int)

print(max - min)

N = input()
A = input()

A_list = [A[i: i + 1] for i in range(0, len(A), 1)]

A_list_int = list(map(int, A_list))

max = max(A_list_int)
min = min(A_list_int)

print(max - min)

N = input()
A_list = input().split()

A_list_int = list(map(int, A_list))

max = max(A_list_int)
min = min(A_list_int)

print(max - min)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
value = []
for part in input().split():
    value.append(int(part))

print(max(value) - min(value))

N = int(input())
    
value = []
for part in input().split():
    value.append(int(part))
    
print(max(value) - min(value))

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
Nlist = input().split()

wMax = Nlist(0)
wMin = Nlist(0)
for value in Nlist:
    if int(value) > wMax:
        wMax = int(value)
    if int(value) < wMin:
        wMin = int(value)

print(abs(wMax - wMin))

N = int(input())
Nlist = input().split()

wMax = int(Nlist[0])
wMin = int(Nlist[0])
for value in Nlist:
    if int(value) > wMax:
        wMax = int(value)
    if int(value) < wMin:
        wMin = int(value)

print(abs(wMax - wMin))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N=int(input())
A=[int(x) for x in input().split()]
ans=0
for i in range(N):
  for j in range(i+1,N):
    ans=max(ans,abs(A[i]-A[j])
print(ans)

N=int(input())
A=[int(x) for x in input().split()]
ans=0
for i in range(N):
  for j in range(i+1,N):
    ans=max(ans,abs(A[i]-A[j]))
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split())
print(max(A)-min(A))

N = int(input())
A = list(map(int,input().split()))
print(max(A)-min(A))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
A = input().split()
print(max(A)-min(A))

N = int(input())
A = list(map(int, input().split()))
print(max(A)-min(A))


Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
input()
a=map(int,input().split())
print(max(a)-min(a))


input()
a=list(map(int,input().split()))
print(max(a)-min(a))


Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
#! /usr/bin/env python
# coding: UTF-8

n = (int)(input())
list = list(int(i) for i in input().split())
print(list)
mx = max(list)
mn = min(list)
print(mx - mn)

#! /usr/bin/env python
# coding: UTF-8

n = (int)(input())
list = list(int(i) for i in input().split())
mx = max(list)
mn = min(list)
print(mx - mn)

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
print(max(a)-min(a))


N=input()
l=list(map(int,input().split()))

mx=0
for x in l:
  for y in l:
    mx=max(mx,abs(x-y))


print(mx)

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
import math
input()
x = list(map(int, input().split()))
print(math.max(x) - math.min(x))

input()
x = list(map(int, input().split()))
print(max(x) - min(x))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
input;n=list(map(int,input().split()))
print(max(n) - min(n))

input;n=list(map(itn,input().split()))
print(max(n) - min(n))

input();n=list(map(int,input().split()))
print(max(n) - min(n))

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())

num = 1

while(N >= num*2):
    num *= 2

print(num)

N = int(input())
lis = [int(i) for i in input().split()]

lis.sort()

print(lis[len(lis)-1] - lis[0])

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
return max(a) - min(a)

n = int(input())
a = list(map(int, input().split()))
print(max(a) - min(a))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
A = list(map(int, input()).split())

print(max(A) - min(N))

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

print(max(N) - min(N))

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

print(max(A) - min(A))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N =int(input())        
A =list(map(int, input(
                       
print(max(A)-min(A))

N =int(input())
A =list(map(int, input().split()))
print(max(A)-min(A))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N=int(input())
A=map(int, input().split())
maxnum=max(A)
minnum=min(A)
print(maxnum-minnum)

N=int(input())
A=map(int, input().split())
maxnum=max(A)
minnum=min(A)
print(maxnum-minnum)


N=int(input())
A=list(map(int, input().split()))
print(max(A)-min(A))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):

n = input()
l = input()
print(abs(max(l) - min(l)))


n = input()
a = input().split(" ")

l = list()
for x in a:
	l.append(int(x))

print(abs(max(l) - min(l)))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))

asorted = sorted(A)
print(asorted[N+1]-asorted[0])

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

asorted = sorted(A)
print(asorted[N]-asorted[0])


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

asorted = sorted(A)
print(asorted[N-1]-asorted[0])


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
print(abs(min(a)-max(a))

n = int(input())
a = list(map(int,input().split()))
print(abs(min(a)-max(a)))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
def main(n, a):
    ans = 0
    for i, j in permutations(a, 2):
        ans = max(ans, i - j)

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)


from itertools import permutations


def main(n, a):
    ans = 0
    for i, j in permutations(a, 2):
        ans = max(ans, i - j)

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)


Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
list = [int(i) for i in input()]
print(max(max(list)-min(list)))

n = input()
list = [int(i) for i in input().split()]
print(abs(max(list)-min(list)))

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A.

Submission attempts (in order):
n=int(input())
A=list(map(int,input().split()))
print(abs((max(A)-min(A))

n=int(input())
A=list(map(int,input().split()))
print(abs(max(A)-min(A)))

Verdicts: Runtime Error

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
import math
N = int(input())
A = [int(x) for x in input().split(' ')]
def score(A, b):
    s = 0
    for i, Ai in enumerate(A):
        s = math.abs(Ai - i - b)
    return s
s = math.inf
for b in range(min(A), max(A)):
    si = score(A, b)
    if si < s:
        s = si
print(s)

import statistics
N = int(input())
A = [int(x) for x in input().split(' ')]
def score(C, b):
    s = 0
    for i, Ci in enumerate(C):
        s += abs(Ci - b)
    return int(s)

C = [Ai - (i+1) for i, Ai in enumerate(A)]
b = statistics.median(C)
b1 = int(b)
b2 = int(b) + 1
s1 = score(C, b1)
s2 = score(C, b2)
print(min(s1, s2))

Verdicts: Runtime Error

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[n]-=i
x=sum(a)//n
ans=0
for i in a:
  ans+=abs(i-x)
print(ans)

n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[n]-=i
x=sum(a)//n
ans=0
for i in a:
  ans+=abs(i-b)
print(ans)

n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[n]-=i
x=sum(a)//n
ans=0
for i in a:
  ans+=abs(i-x)
print(ans)

n=int(input())
a=list(map(int,input().split()))
b=[0]
c=[0]
count=0
count2=0
for i in range(n):
  a[i]-=i
for i in range(n-1):
  count+=a[i+1]-a[i]
  b.append(count)
for i in range(n-1):
  count2+=b[i+1]-b[i]
  c.append(count2)
ans=10**18
for i in range(n):
  ans=min(ans,c[-1]-i*c[i])
print(ans)

n=int(input())
a=list(map(int,input().split()))
b=[0]
c=[0]
count=0
count2=0
for i in range(n):
  a[i]-=i
for i in range(n-1):
  count+=a[i+1]-a[i]
  b.append(count)
for i in range(n-1):
  count2+=b[i+1]
  c.append(count2)
ans=10**18
for i in range(n):
  ans=min(ans,c[-1]-c[i]-b[i]*(n-i-1))
print(ans)

n=int(input())
a=[int(i) for i in input().split()]
a=[a[i]-(i+1) for i in range(n)]
a.sort()
if n%2==0:
    print(sum(a[n//2:])-sum(a[0:n//2]))
else:
    print(sum(a[n//2+1:])-sum(a[0:n//2]))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
import math

N = int(input())
A = list(map(int, input().split()))
# print(N, A)

for i in range(len(A)):
    A[i] -= (i + 1)
# print(A)

# _A = list(map(abs, A))

average = math.floor(sum(A) / len(A)) - 1

for i in range(len(A)):
    A[i] = abs(A[i] - average)

sadness = sum(A)

print(sadness)


import math

N = int(input())
A = list(map(int, input().split()))
# print(N, A)

_A = [] * len(A)
for i in range(len(A)):
    _A[i] -= (i + 1)
_A.sort()
median = _A[len(A) / 2]

sadness = 0
for i in range(len(A)):
    sadness += abs(A[i] - (i + 1 + median))

print(sadness)


import math

N = int(input())
A = list(map(int, input().split()))
# print(N, A)

for i in range(len(A)):
    A[i] -= (i + 1)

left = -abs(min(A))
right = abs(max(A))
minimum = right

for b in range(left, right + 1):
    sadness = 0
    for Ai in A:
        sadness = abs(Ai - b)

    minimum = min(sadness, minimum)

print(sadness)


import math

N = int(input())
A = list(map(int, input().split()))
# print(N, A)

for i in range(len(A)):
    A[i] -= (i + 1)
# print(A)

average = math.ceil(sum(A) / len(A))

for i in range(len(A)):
    A[i] = abs(A[i] - average)

sadness = sum(A)

print(sadness)


import math

N = int(input())
A = list(map(int, input().split()))
# print(N, A)

for i in range(len(A)):
    A[i] -= (i + 1)
# print(A)

# _A = list(map(abs, A))

average = math.floor(sum(A) / len(A)) + 1

for i in range(len(A)):
    A[i] = abs(A[i] - average)

sadness = sum(A)

print(sadness)


import math

N = int(input())
A = list(map(int, input().split()))
# print(N, A)

for i in range(len(A)):
    A[i] -= (i + 1)
# print(A)

_A = map(abs, A)
_A = list(A)

average = math.ceil(sum(_A) / len(_A))

for i in range(len(A)):
    A[i] = abs(A[i] - average)

sadness = sum(A)

print(sadness)


import math

N = int(input())
A = list(map(int, input().split()))
# print(N, A)

for i in range(len(A)):
    A[i] -= (i + 1)
# print(A)

_A = list(map(abs, A))

average = math.ceil(sum(_A) / len(_A))

for i in range(len(A)):
    A[i] = abs(A[i] - average)

sadness = sum(A)

print(sadness)


import math

N = int(input())
A = list(map(int, input().split()))
# print(N, A)

_A = [A[i] - (i + 1) for i in range(len(A))]
_A.sort()
median = _A[math.ceil(len(A) / 2)]

sadness = 0
for i in range(len(A)):
    sadness += abs(A[i] - (i + 1 + median))

print(sadness)


import math

N = int(input())
A = list(map(int, input().split()))
# print(N, A)

_A = [A[i] - (i + 1) for i in range(len(A))]
_A.sort()
median = _A[math.floor(len(A) / 2)]

sadness = 0
for i in range(len(A)):
    sadness += abs(A[i] - (i + 1 + median))

print(sadness)


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
n=int(input())
A=list(map(int,input().split()))
q=0
Z=[]
for b in range(len(A)):
  q=0
  for j in A:
    q+=abs(j-b-1)
  Z.append(q)
print(min(Z))


n=int(input())
A=list(map(int,input().split()))
q=0
Z=[]
for b in range(len(A)):
  for j in A:
    q+=abs(j-b-1)
  Z.append(q)
print(min(Z))

n=int(input())
A=list(map(int,input().split()))
q=0
Z=[]
for b in range(max(A)-min(A)):
  q=0
  for j in range(n):
    q+=abs(A[j]-b-min[A]-j-1)
  Z.append(q)
print(min(Z))


n=int(input())
A=list(map(int,input().split()))
q=0
Z=[]
for b in range(max(A)):
  q=0
  for j in range(n):
    q+=abs(A[j]-b-j-1)
  Z.append(q)
print(min(Z))
print(Z)

n=int(input())
A=list(map(int,input().split()))
q=0
Z=[]
t=min(A)
for b in range(int((max(A)-min(A))//2)):
  q=0
  for j in range(n):
    q+=abs(A[j]-b-t-j-1)
  Z.append(q)
print(min(Z))


import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache




n=int(input())
A=list(map(int,input().split()))
SA=[0 for i in range(n)]
for i in range(n):
    SA[i]=A[i]-i-1
SA.sort()

if n%2==0:
    geta=(SA[n//2]+SA[n//2-1])//2
else:
    geta=SA[n//2]
ans=0
for i in range(n):
    ans+= abs(A[i]-(geta+i+1))
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
n = int(input())
an = list(map(int, input().split()))
a = []
su = 0
for i in range(n):
  a.append(an[i] - i+1) 
a.sort()
b = a[n//2]
for i in range(n):
  su += abs(an[i] - (int(b) + i))
print(su)

import statistics as s
n = int(input())
an = list(map(int, input().split()))
a = []
sum = 0
for i in range(n):
  a.append(an[i] - i+1) 
b = s.median(a)
for i in range(n):
  sum += abs(an[i] - (b + i))  
print(int(sum))

n = int(input())
an = list(map(int, input().split()))
su = 0
for i in range(n):
  an[i] -= i+1
an.sort()
b = an[n//2]
for i in range(n):
  an[i] -= b
  an[i] = abs(an[i])
print(sum(an))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
import statistics

N = int(input())
A = [int(c) for c in input().split()]
A = [abs(n - (b+i+1)) for i, n in enumerate(A)]

b = int(statistics.median(A))
print(sum([abs(n - b) for n in A]))

import statistics

N = int(input())
A = [int(c) for c in input().split()]
A = [n - (i+1) for i, n in enumerate(A)]

b = int(statistics.median(A))
print(sum([abs(n - b) for n in A]))

Verdicts: Runtime Error

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
max = max(A)
list = []
x = 0
for i in range(N):
    A[i] = A[i] -i
sum = 0
for i in range(N):
    sum = sum + A[i]
ave = int(sum/N)
for i in range(N):
    x = x + abs(A[i]-ave-1)
print(x)


N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    A[i] = A[i] - i - 1
A = sorted(A)
medN = N//2

x = 0
for i in range(N):
    x = x + abs(A[i] - A[halfN])
print(x)


N = int(input())
A = list(map(int, input().split()))
max = max(A)
list = []
x = 0
for i in range(N):
    A[i] = A[i] -i
sum = 0
for i in range(N):
    sum = sum + A[i]
ave = int(sum/N)
for i in range(N):
    x = x + abs(A[i]-ave-i)
print(x)


N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    A[i] = A[i] - i - 1
A = sorted(A)
medN = N//2

x = 0
for i in range(N):
    x = x + abs(A[i] - A[medN])
print(x)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
import math
N = int(input())
A = [int(x) for x in input().split()]
sum = 0
A_prime = [0]*N
for i in range(N):
    A_prime[i] = A[i] - i - 1
    sum += A_prime[i]

# print(sum)
ave = math.ceil(sum / N)
# print(ave)
ans = 0
for k in range(N):
    ans += abs(A[k] - (ave + k + 1))
print(ans)




N = int(input())
A = [int(x) for x in input().split()]
A_prime = [0]*N
for i in range(N):
    A_prime[i] = A[i] - i-1
A_prime = sorted(A_prime)
center = A_prime[N//2]

ans = 0
for k in range(N):
    ans += abs(A[k] - (center + k + 1))
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
# coding: utf-8
# Your code here!

N = int(input())
A = list(map(int, input().split(" ")))
A_i = [0]*N
K = [0] * 101

for i in range(N):
    A_i[i] = A[i] - i - 1

b_0 = sum(A_i) / len(A_i)
b = [0] * 101
b[0] = int(b_0)
for i in range(1,101):
    b[i] = b[0] + int(i - 50.5)
print(b)

for i in range(N):
    for j in range(11):
        K[j] = K[j] + abs(A_i[i] - b[j])

print(min(K))

# coding: utf-8
# Your code here!

N = int(input())
A = list(map(int, input().split(" ")))
A_i = [0]*N
K = [0] * 101

for i in range(N):
    A_i[i] = A[i] - i - 1

b_0 = sum(A_i) / len(A_i)
b = [0] * 101
b[0] = int(b_0)
for i in range(1,101):
    b[i] = b[0] + int(i - 50.5)

for i in range(N):
    for j in range(11):
        K[j] = K[j] + abs(A_i[i] - b[j])

print(min(K))


# Your code here!

N = int(input())
A = list(map(int, input().split(" ")))
A_i = [0]*N
K = [0] * 101

for i in range(N):
    A_i[i] = A[i] - i - 1

b_0 = sum(A_i) / len(A_i)
b = [0] * 101
b[0] = int(b_0)
for i in range(1,101):
    b[i] = b[i] + int(i - 50.5)


for i in range(N):
    for j in range(11):
        K[j] = K[j] + abs(A_i[i] - b[j])

print(min(K))

# coding: utf-8
# Your code here!

N = int(input())
A = list(map(int, input().split(" ")))
A_i = [0]*N
K = [0] * 101

for i in range(N):
    A_i[i] = A[i] - i - 1

b_0 = sum(A_i) / len(A_i)
b = [0] * 101
b[0] = int(b_0)
for i in range(1,101):
    b[i] = b[0] + int(i - 50.5)
print(b)
for i in range(N):
    for j in range(101):
        K[j] = K[j] + abs(A_i[i] - b[j])
print(K)

print(min(K))

import statistics
import math

N = int(input())
A = list(map(int, input().split(" ")))
A_i = [0]*N
K_1 = 0
K_2 = 0
K_3 = 0


for i in range(N):
    A_i[i] = A[i] - i - 1

try:
    b_1 = statistics.mode(A_i)
except:
    b_1 = int(statistics.mean(A_i))

b_2= int(statistics.mean(A_i))
b_3 = int(statistics.median(A_i))

for i in range(N):
    K_1 = K_1 + abs(A_i[i] - b_1)
    K_2 = K_2 + abs(A_i[i] - b_2)
    K_3 = K_3 + abs(A_i[i] - b_3)

print(min(K_1, K_2, K_3))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
N=int(input())
a=list (map(int,input().split()))
abs_list=[]
for b in range(-max(a),max(a)):
	c=0
	for i in range(N):
		c=abs(a[i]-(b+i+1))+c	
	abs_list.append(c)	
print(abs_list)	
print(min(abs_list))	

N=int(input())
a=list (map(int,input().split()))
abs_list=[]
for b in range(-max(a),max(a)):
	c=0
	for i in range(N):
		c=abs(a[i]-(b+i+1))+c	
	abs_list.append(c)	
print(abs_list)	
print(min(abs_list))	

N=int(input())
a=list (map(int,input().split()))
abs_list=[]
c=0
for i in range(N):
	c=(a[i]-(i+1))
	abs_list.append(c)
abs_list.sort()
b=abs_list[int(N/2)]	
d=0
for i in range(N):
	d=abs(abs_list[i]-b)+d		
print(d)	

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):

N = int(input())
A = list(map(int, input().split()))
ave = sum(A) / N

p = []
for i in range(N):
    p.append(i+1)
p_ave = sum(p) / N

b = round(ave - p_ave)

ans = 0
for i in range(N):
    ans += abs(A[i] - (b + i))
print(ans)


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

bl = []
for i in range(N):
    bl.append(A[i] - (i+1))
bl.sort()
if N % 2 == 0:
    b = (bl[N//2-1] + bl[N//2]) // 2
else:
    b = bl[N//2]

ans = 0
for i in range(N):
    ans += abs(A[i] - (b + (i+1)))
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
from statistics import median
N = int(input())
A = list(map(int, input().split()))
B = list()
sad = 0

for i in range(N):
  B.append(A[i]-i)

b = median(B)

for i in range(N):
  sad = sad + abs(A[i] - (b+i))

print(int(sad))
print(median(A))

from statistics import median
N = int(input())
A = list(map(int, input().split()))
B = list()
sad = 0

for i in range(N):
  B.append(A[i]-i)

b = median(B)

for i in range(N):
  sad = sad + abs(A[i] - (b+i))

print(int(sad))

Verdicts: Wrong Answer

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
#from collections import Counter
import math
N=int(input())
A=list(map(int,input().split()))
l=[]
n=1
for i in A:
    l.append(i-n)
    n+=1
l.sort()


c=int(math.floor(N/2))
b=A[c]
ans_l=[]
ans=0
for j in l:
    ans+=abs(j-l[b])

print(ans)

#from collections import Counter
import math
N=int(input())
A=list(map(int,input().split()))
l=[]
n=1
for i in A:
    l.append(i-n)
    n+=1
l.sort()


c=int(math.floor(N/2))

ans_l=[]
ans=0
for j in l:
    ans+=abs(j-l[c])

print(ans)

Verdicts: Runtime Error

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
import statistics
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
	A[i] = A[i] - (i+1)
A.sort()

b = statistics.median(A)

ans = 0

for i in range(N):
	ans += abs(A[i] - b)
print(ans

import statistics
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
	A[i] = A[i] - (i+1)
A.sort()

if N % 2 == 0:
	med1 = A[N // 2 - 1]
	med2 = A[N //2]
	ans = min(sum([abs(a - med1) for a in A]), sum([abs(a - med2) for a in A]))

else:
	med = A[N // 2]
	ans = sum([abs(a - med) for a in A])
	
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Snuke has an integer sequence A of length N.  He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows:    * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N))  Here, abs(x) is a function that returns the absolute value of x.  Find the minimum possible sadness of Snuke.

Submission attempts (in order):
N=int(input())
A=list(map(int,input().split()))
for i in range(N):
  A[i] = A[i] - i - 1
print( A.sum() // N )


N=int(input())
A=list(map(int,input().split()))
for i in range(N):
  A[i] = A[i] - i - 1
A.sort()
b = A[N//2]
ans = 0
for i in range(N):
  ans += abs(A[i] - b)
print(ans)
  


Verdicts: Runtime Error

Accepted