Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if b<=a:
  if a = 1 or a = 12 :
    print(a)
  else:
    print(a+1)
else:
  print(a)

Fixed submission:
a,b = map(int,input().split())
c = a - 1
if b<a :
  print(c)
else:
  print(a)

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if b<=a:
  if a = 1:
    print(a)
  else:
    print(a+1)
else:
  print(a)

Fixed submission:
a,b = map(int,input().split())
c = a - 1
if b<a :
  print(c)
else:
  print(a)
Buggy python submission (verdict: Runtime Error):
a,b = map(int(),input().split())
c = a*b
d = c%2
if d==1:
  print("Odd")
else:
  print("Even")

Fixed submission:
a,b = map(int,input().split())
c = a*b
d = c%2
if d==1:
  print("Odd")
else:
  print("Even")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 桁数の入力
a = int(input())
# スペース区切りの整数の入力
b = input().split()
b.sort()
min = b[0]
b.reverse()
max = b[0]
print(int(max)-int(min))

Fixed submission:
# -*- coding: utf-8 -*-
def gcd(x, y):
    while x % y:
        x, y = y, x % y
    return y

def lcm(x, y):
    return (x * y) // gcd(x, y)

# 整数の入力
n = int(input())
print(lcm(2, n))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 桁数の入力
a = input()
# スペース区切りの整数の入力
b = input().split()
b = list(map(int, b))
print(max(a) - min(a))

Fixed submission:
# -*- coding: utf-8 -*-
# 桁数の入力
a = input()
# スペース区切りの整数の入力
b = input().split()
b = list(map(int, b))
print(max(b) - min(b))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 桁数の入力
a = int(input())
# スペース区切りの整数の入力
b = input().split()
b = list(map(int, b))
c = list(range(1, a + 1))
d = []
for i, j in zip(b, c):
    d.append(i-j)

d.sort()
e = d[a // 2]
f = 0
for i in range(5):
    f += abs(d[i] - e)
print(f)

Fixed submission:
# -*- coding: utf-8 -*-
# 桁数の入力
a = int(input())
# スペース区切りの整数の入力
b = input().split()
b = list(map(int, b))
c = list(range(1, a + 1))

d = []
for i, j in zip(b, c):
    d.append(i-j)
d.sort()
e = d[a // 2]
f = 0
for i in range(a):
    f += abs(d[i]-e)

print(f)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
n = int(sys.stdin.readline())
a = [x for x in sys.stdin.readline().split()]
b = []
for i in range(n):
    b = b[::-1]
    b.insert(0, a[i])
print(" ".join(b))

Fixed submission:
import sys
n = int(sys.stdin.readline())
a = [x for x in sys.stdin.readline().split()]
b = [a[i] for i in range(n) if i % 2 != 0]
rb = b[::-1]
c = [a[i] for i in range(n) if i % 2 == 0]
rc = c[::-1]

if n % 2 == 0:
    ans = rb + c
else:
    ans = rc + b

ans = " ".join(ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
n = int(sys.stdin.readline())
a = [int(x) for x in sys.stdin.readline().split()]
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
b_str = list(map(str, b))
print(" ".join(b_str))

Fixed submission:
import sys
n = int(sys.stdin.readline())
a = [x for x in sys.stdin.readline().split()]
b = [a[i] for i in range(n) if i % 2 != 0]
rb = b[::-1]
c = [a[i] for i in range(n) if i % 2 == 0]
rc = c[::-1]

if n % 2 == 0:
    ans = rb + c
else:
    ans = rc + b

ans = " ".join(ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
n = int(sys.stdin.readline())
a = [int(x) for x in sys.stdin.readline().split()]
b = []
for i in range(n):
    b.append(a[i])
    b.reverse()
b_str = list(map(str, b))
print(" ".join(b_str))

Fixed submission:
import sys
n = int(sys.stdin.readline())
a = [x for x in sys.stdin.readline().split()]
b = [a[i] for i in range(n) if i % 2 != 0]
rb = b[::-1]
c = [a[i] for i in range(n) if i % 2 == 0]
rc = c[::-1]

if n % 2 == 0:
    ans = rb + c
else:
    ans = rc + b

ans = " ".join(ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
a = input().split()
b = []
for i in range(n):
    b.append(a[i])
    b.reverse()
print(' '.join(b))

Fixed submission:
import sys
n = int(sys.stdin.readline())
a = [x for x in sys.stdin.readline().split()]
b = [a[i] for i in range(n) if i % 2 != 0]
rb = b[::-1]
c = [a[i] for i in range(n) if i % 2 == 0]
rc = c[::-1]

if n % 2 == 0:
    ans = rb + c
else:
    ans = rc + b

ans = " ".join(ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

tmp = [int(p.replace('W', '-1')) if p == 'W' else int(p.replace('E', '1')) for p in list(S)]

result = []
cnt = 0
for CTO in range(N):
    for MEM in range(N):
        if MEM == CTO:
            continue
        if CTO < MEM:
            if tmp[CTO] == -1:
                if (tmp[MEM] + tmp[CTO]) == 0:
                    cnt += 1
            if tmp[CTO] == 1:
                if (tmp[MEM] + tmp[CTO]) != 0:
                    cnt += 1

        if MEM < CTO:
            if tmp[CTO] == -1:
                if (tmp[MEM] + tmp[CTO]) != 0:
                    cnt += 1
            if tmp[CTO] == 1:
                if  (tmp[MEM] + tmp[CTO]) == 0:
                    cnt += 1
    result.append(cnt)
    cnt = 0

result_x = [ result[i] for i in range(N) if result[i] != 0]
print(min(result_x))

Fixed submission:
N = int(input())
S = list(input())

w = 0
e = S[1:].count('E')

leader = S[0]
min_mem=e
cnt_mem=0

for i in range(1, N):
    if leader ==  'W':
        w += 1
    leader = S[i]

    if leader == 'E':
        e -= 1

    cnt_mem = w + e
    if cnt_mem < min_mem:
        min_mem = cnt_mem

print(min_mem)

Buggy python submission (verdict: Runtime Error):
	N = int(input())
S = input()

tmp = [int(p.replace('W', '-1')) if p == 'W' else int(p.replace('E', '1')) for p in list(S)]

result = []
cnt = 0
for CTO in range(N):
    for MEM in range(N):
        print(CTO)
        if MEM == CTO:
            continue
        if CTO < MEM:
            if tmp[CTO] == -1:
                if (tmp[MEM] + tmp[CTO]) == 0:
                    cnt += 1
            if tmp[CTO] == 1:
                if (tmp[MEM] + tmp[CTO]) != 0:
                    cnt += 1

        if MEM < CTO:
            if tmp[CTO] == -1:
                if (tmp[MEM] + tmp[CTO]) != 0:
                    cnt += 1
            if tmp[CTO] == 1:
                if  (tmp[MEM] + tmp[CTO]) == 0:
                    cnt += 1
        print(cnt)
    result.append(cnt)
    cnt = 0

result_x = [ result[i] for i in range(N) if result[i] != 0]
print(min(result_x))

Fixed submission:
N = int(input())
S = list(input())

w = 0
e = S[1:].count('E')

leader = S[0]
min_mem=e
cnt_mem=0

for i in range(1, N):
    if leader ==  'W':
        w += 1
    leader = S[i]

    if leader == 'E':
        e -= 1

    cnt_mem = w + e
    if cnt_mem < min_mem:
        min_mem = cnt_mem

print(min_mem)
Buggy python submission (verdict: Runtime Error):
import sys
std = sys.stdin.read()
std_arr = std.split('\n')
persons = int(std_arr[0])
li = std_arr[1].split()
day = int(li[0])
mod = int(li[1])
patici = {}
p = 0
for i in range(2, len(std_arr)): 
    patici[p] =  int(std_arr[i])
    p += 1

if p != persons:
    print('lack of argument!!!')
    exit()

choko = 0
for i in patici.keys():
    for x in range(0, 100):   
        if (x + 1) * patici[i] + 1 < day :
            print((x + 1) * patici[i] + 1 )
            choko += 1

print(choko + mod)

Fixed submission:
import sys

def main(inp_list):
    #print(inp_list)
    A, B, C, D = map(int, inp_list)
    return min(A, B) + min(C, D)

def init(MODE):
    arr = []
    if MODE == 0:
        while True:
            try:
                arr.append(int(input()))
            except:
                break
        return arr

if __name__ == '__main__':
    """ MODE: 0 縦, 1 縦横, 2 横 """
    MODE = 0
    inp_list = init(MODE)
    print(main(inp_list))
Buggy python submission (verdict: Runtime Error):
import sys
std = sys.stdin.read()
std_arr = std.split('\n')
persons = int(std_arr[0])
li = std_arr[1].split()
day = int(li[0])
mod = int(li[1])
patici = {}
p = 0
for i in range(2, len(std_arr)): 
    patici[p] =  int(std_arr[i])
    p += 1

if p != persons:
    print('lack of argument!!!')
    exit()

choko = 0
for i in patici.keys():
    for x in range(0, 100):   
        if (x + 1) * patici[i] + 1 < day :
            print((x + 1) * patici[i] + 1 )
            choko += 1

print(choko + mod)

Fixed submission:
import sys

def _calc(Ai, j):
    if j != 0:
        return j * Ai + 1
    if j == 0:
        return 1

def main(inp_list):
    # return inp_list
     N = inp_list[0]
     D = inp_list[1][0]
     X = inp_list[1][1]
     A = inp_list[2:]
     #return type(A[0][0])
     results =[ _calc(per[0], i) for per in A  for i in range(0,100) if _calc(per[0], i) < D + 1]
     return len(list(results)) + X

def init(MODE):
    if MODE == 0:
        while True:
            try:
                result = int(input())
                yield result
            except:
                break

    if MODE == 1:
        while True:
            try:
                li=list(map(int,input().split()))
                yield li
            except:
                break
if __name__ == '__main__':
    """ MODE: 0 縦, 1 縦横, 2 横 """
    MODE = 1
    inp_list = init(MODE)
    print(main(list(inp_list)))
Buggy python submission (verdict: Runtime Error):
import numpy as np

a = input()
b = []
b = input().split()
ans = 0
for i in a-1:
  for j in a-1:
    c = b[i]-b[j]
    if(ans < np.abs(c):
       ans = c
print(c)

Fixed submission:
import numpy as np

a = int(input())
b = input().split()
c = []
for i in range(a):
  c.append(int(b[i]))
ans = 0
for i in range(a):
  for j in range(a):
    d = c[i] - c[j]
    d = np.abs(d)
    if(ans < d):
       ans = d
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=input().split()
n=int(n)
k=int(k)

if n==k:
	print(1)
elif n//(k-1)=1:
	print(2)
else:
	print(n//(k-1))

Fixed submission:
str=input()
list=list(str)
a=0
for i in range(4):
	if list[i]=="+":
		a=a+1
	else:
		a=a-1
print(a)

Buggy python submission (verdict: Runtime Error):
n,k=input().split()
n=int(n)
k=int(k)

print(n//(k-1))

Fixed submission:
str=input()
list=list(str)
a=0
for i in range(4):
	if list[i]=="+":
		a=a+1
	else:
		a=a-1
print(a)
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b=int(b)

if a>8 and b>8
	print(":)")
else:
	print("Yay")

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b)

if a>8 or b>8:
	print(":(")
else:
	print("Yay!")
Buggy python submission (verdict: Runtime Error):
d,n=input().split()
d=int(d)
n=int(n)

if d=0:
	print(d)
elif d=1:
	print(n*10)
else:
	print(n*10000)

Fixed submission:
d,n=input().split()
d=int(d)
n=int(n)

if d==0:
	if n==100:
		print(101)
	else:
		print(n)
elif d==1:
	if n==100:
		print(10100)
	else:
		print(n*100)
else:
	if n==100:
		print(1010000)
	else:
		print(n*10000)
Buggy python submission (verdict: Runtime Error):
s=input()
list=list(s)

a=700
print(list)
for i in range(len(list))
	if list[i]=="○":
		a=a+700
	else:
		a=a
print(a)

Fixed submission:
s=input()
list=list(s)

a=700
#print(list)
for i in range(len(list)):
	if list[i]=="o":
		#print(list[i])
		a=a+100
	else:
		a=a
print(a)
Buggy python submission (verdict: Runtime Error):
from math import ceil
N, K = map(int, input().split)
nums = list(map(int, input().split))
index = nums.index(1)
print(ceil(index / (K - 1)) + ceil((N - index - 1) / (K - 1)))

Fixed submission:
import math
N, K = map(int, input().split())
nums = input()
print(math.ceil((N - 1) / (K - 1)))
Buggy python submission (verdict: Runtime Error):
N, Z, W = map(int, input().split())
cards = list(map(int, input().split()))

if N == 1:
    print(cards[0] - W)
else:
    x = abs(cards[-1] - cards[-2])
    y = abs(cards[-1] - W)
    print(max(x, y))

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

n = 1
for _ in range(M):
    n *= 2

print(n * ((N - M) * 100 + M * 1900))

Buggy python submission (verdict: Runtime Error):
def main(N, M):
    n = 1
    for _ in range(M):
        n *= 2

    print n * ((N - M) * 100 + M * 1900)

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

n = 1
for _ in range(M):
    n *= 2

print(n * ((N - M) * 100 + M * 1900))

Buggy python submission (verdict: Runtime Error):
n = 1
for _ in range(N):
    n *= 2

return n * ((M - N) * 100 + N * 1900)

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

n = 1
for _ in range(M):
    n *= 2

print(n * ((N - M) * 100 + M * 1900))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

sa = b - a
east = (1 + sa) * sa / 2
snow = int(east - b)
print(snow)

Fixed submission:
N = int(input())

if N <= 999:
	print('ABC')

if N > 999:
	print('ABD')

Buggy python submission (verdict: Runtime Error):
word = input()
number = int(word)
if number <= 999:
  print(ABC)
if number > 999:
  print(ABD)

Fixed submission:
word = input()
number = int(word)
if number <= 999:
  print("ABC")
if number > 999:
  print("ABD")
Buggy python submission (verdict: Runtime Error):
import numpy as np
from statistics import median
N = int(input())
A = list(map(lambda x:int(x),input().split(" ")))
npA = np.array(A)
B = npA-(1+np.arange(len(npA)))
opt_b = median(B)
print(int(np.sum(np.abs(B-opt_b))))

Fixed submission:
N = int(input())
if N%2 == 0:
    ans = N
else:
    ans = N*2
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(lambda x:int(x),input().split(" ")))
npA = np.array(A)
B = npA-(1+np.arange(len(npA)))
opt_b = statistics.median(B)
print(int(np.sum(np.abs(B-opt_b))))

Fixed submission:
import numpy as np
from statistics import median
N = int(input())
A = list(map(lambda x:int(x),input().split(" ")))
npA = np.array(A)
B = npA-(1+np.arange(len(npA)))
opt_b = median(B)
print(int(np.sum(np.abs(B-opt_b))))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
costs = [0]*N
for i in range(N):
    tmp = A[:]
    A.pop(i)
    A.insert(0,0)
    A.append(0)
    #print(A)
    costs[i] = sum(np.abs(np.diff(A)))
    A = tmp
for i in range(len(costs)):
    print(costs[i])

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
print(min(A,B)+min(C,D))
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
cnt = 0
while len(set(S)) !=1:
    if S[-1] == 'W':
        j=1
        while S[-j] != 'B':
            S[-j] = 'B'
            j+=1
        S.append('B')
    elif S[-1] == 'B':
        j=1
        while S[-j] != 'W':
            S[-j] = 'W'
            j+=1
        S.append('W')
    cnt += 1
print(cnt)

Fixed submission:
S = list(input())
cnt = 0
key = S[0]
for i in range(1,len(S)):
    if key != S[i]:
        key = S[i]
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python
# coding: UTF-8


def sad(list, b):
    value = 0
    n = 1
    for a in list:
        value += abs(a - (b+n))
        n += 1
    return value


def main():
    mn = 1000000
    n = (int)(input())
    lst = list(int(i) for i in input().split())
    mx = max(lst)
    for i in range(mx):
        if(sad(lst, i) < mn):
            mn = sad(lst, i)
    print(mn)

if __name__ == '__main__':
    main()

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

def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m%n)

def main():
    n = int(input())

    print(int(n*2/gcd(n,2)))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
print(abs(max(a)-min(a)))

Fixed submission:
N=int(input())

if N%2==0:
  print(N)
else:
  print(N*2)

Buggy python submission (verdict: Runtime Error):
N=int(input())
lst=input().split()
lst_i=[int(i) for i in lst]
a=max(lst_i)
b=min(lst_i)
print(abs(a-b))

Fixed submission:
N=int(input())

if N%2==0:
  print(N)
else:
  print(N*2)
Buggy python submission (verdict: Runtime Error):
a,b,c,x,y=map(int,input().split())
if a+b>2*c and x>y:
    if a<2*c:
        print(2*c*y+a*(x-y))
    else:
        print(2*c*x)
elif a+b>2*c and x<y:
    if b<2*c:
        print(2*c*x+b*(y-x))
    else:
        print(2*c*y)
else:
    print(a*x+b*y)

Fixed submission:
a=input()
print(700+a.count("o")*100)

Buggy python submission (verdict: Runtime Error):
a,b,c,x,y=map(int,input().split())
if a+b>2*c and x>y:
    if a<2*c:
        print(2*c*y+a*(x-y))
    else:
        print(2*c*x)
elif a+b>2*c and x<y:
    if b<2*c:
        print(2*c*x+b*(y-x))
    else:
        print(2*c*y)
else:
    print(a*x+b*y)

Fixed submission:
a=input()
print(700+a.count("o")*100)

Buggy python submission (verdict: Runtime Error):
a,b,c,x,y=map(int,input().split())
if a+b>2*c and x>=y:
    if a<2*c:
        print(2*c*y+a*(x-y))
    else:
        print(2*c*x)
elif a+b>2*c and x<y:
    if a<2*c:
        print(2*c*x+b*(y-x))
    else:
        print(2*c*y)
else:
    print(a*x+b*y)

Fixed submission:
a=input()
print(700+a.count("o")*100)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
for i in range((2*n)+1):
    if i % 2==0 and i % n==0 and i>0:
        print(i)
        break
    else:
        continue


Fixed submission:
n = int(input())
if n % 2 ==0:
    print(n)
else: 
    print(2*n)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N < 1000:
    print('ABC'+str(N)
else:
    print('ABD'+str(N-1000))

Fixed submission:
N = int(input())
if N >= 1000:
    print('ABD')
else:
    print('ABC')
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
n = (b-a)
sum = 0
for i in range(1,n):
    sum +=i
    if n**2= a+b+(sum-a)*2:    
        print(sum-a)
    else: 
        continue

Fixed submission:
a,b = map(int,input().split())
n = (b-a)
sum = 0
for i in range(1,n):
    sum +=i
    if n**2==a+b+(sum-a)*2:    
        print(sum-a)
    else: 
        continue
Buggy python submission (verdict: Runtime Error):
N, M, X =map(int,input().split())
A = list(map(int,input().split()))

t= [i for i in A if i> 0 and i< X]
s= [i for i in A if i> X and i <N]

print(min(len(t),len(s)))

Fixed submission:
A, B, X= map(int,input().split())
if A <= X and A + B >=X:
    print('YES')
else: 
    print('NO')
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for d in range(A +1):
    for e in range(B+ 1):
        for f in range(C+1):
            if d* 500 + e* 100 + f*50 == X:
                count = count + 1
input(int(count))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for d in range(A +1):
    for e in range(B+ 1):
        for f in range(C+1):
            if d* 500 + e* 100 + f*50 == X:
                count = count + 1
print(int(count))

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for d in range(A +1):
    for e in range(B+ 1):
        for f in range(C+1):
            if d* 500 + e* 100 + f*50 == X:
                count = count + 1
input(int(count))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for d in range(A +1):
    for e in range(B+ 1):
        for f in range(C+1):
            if d* 500 + e* 100 + f*50 == X:
                count = count + 1
print(int(count))

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for d in range(A +1):
    for e in range(B+ 1):
        for f in range(C+1):
            if d* 500 + e* 100 + f*50 == X:
                count = count + 1
input(int(count))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for d in range(A +1):
    for e in range(B+ 1):
        for f in range(C+1):
            if d* 500 + e* 100 + f*50 == X:
                count = count + 1
print(int(count))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(_) for _ in input().split()]

sub_num = [0]*(2*10**6)

for i in range(1, n+1):
#    print(abs(int(a[i-1]-i)))
    sub_num[abs(int(a[i-1]-i))] += 1

b = -sub_num.index(max(sub_num))
#print(b)

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

print(result)

Fixed submission:
n = int(input())

if(n % 2 == 0):
    print(n)
else:
    print(n*2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(_) for _ in input().split()]

sub_num = [0]*(2*10**6)

for i in range(1, n+1):
#    print(abs(int(a[i-1]-i)))
    sub_num[abs(int(a[i-1]-i))] += 1

b = -sub_num.index(max(sub_num))
#print(b)

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

print(result)

Fixed submission:
import numpy as np

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

sub_num = []

for i in range(1, n+1):
#    print(abs(int(a[i-1]-i)))
    sub_num.append(int(a[i-1]-i))


b = np.median(sub_num)
#print(b)

result = 0
for i in range(n):
    result += abs(sub_num[i] - b)

print(int(result))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(_) for _ in input().split()]

sub_num = [0]*(2*10**5)

for i in range(1, n+1):
#    print(abs(int(a[i-1]-i)))
    sub_num[abs(int(a[i-1]-i))] += 1

b = -sub_num.index(max(sub_num))
#print(b)

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

print(result)

Fixed submission:
import numpy as np

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

sub_num = []

for i in range(1, n+1):
#    print(abs(int(a[i-1]-i)))
    sub_num.append(int(a[i-1]-i))


b = np.median(sub_num)
#print(b)

result = 0
for i in range(n):
    result += abs(sub_num[i] - b)

print(int(result))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

result = 10**10
for i in range(n):
    west_s = s[:i]
    east_s = s[(i+1):]
#    print(west_s)
#    print(east_s)
    
#    print(west_s.count("W"))
#    print(east_s.count("E"))
    
    if((west_s.count("W")+east_s.count("E")) < result):
        result = west_s.count("W")+east_s.count("E")

print(result)

Fixed submission:
n = int(input())
s = input()


score = s[1:].count("E")
result = score

for i in range(1,n):
    if(s[i]=="E"):
        score -= 1
    if(s[i-1]=="W"):
        score += 1
    
    if(score < result):
        result = score

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())

len_s = len(s)
str_list = []
for i in range(len_s):
    for j in range(1, len_s-i+1):
#        print(s[i:i+j])
        if(not(s[i:i+j] in str_list)):
            str_list.append(s[i:i+j])
        
#print(str_list)
s_str_list = sorted(str_list)
#print(s_str_list)
print(s_str_list[K-1])

Fixed submission:
s = input()
K = int(input())

len_s = len(s)
str_list = []
for i in range(len_s):
    j_lim = min(len_s-i+1, 6)
    for j in range(1, j_lim):
#        print(s[i:i+j])
        if(not(s[i:i+j] in str_list)):
            str_list.append(s[i:i+j])
        
#print(str_list)
s_str_list = sorted(str_list)
#print(s_str_list)
print(s_str_list[K-1])