Problem p03309 (python)

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))
ans_list = []
for i in range(len(a_list)):
    ans_list.append(a_list[i] - i - 1)
import numpy as np
if len(ans_list)% 2 == 0:
    ans_list1 = sorted(ans_list)
    number1 = ans_list1[n//2]
    number2 = ans_list1[n//2 + 1]
    
    ans1 = 0
    ans2 = 0
    for i in ans_list:
        ans1 += abs(i - number1)
        ans2 += abs(i - number2)
    print(min(ans1 , ans2))
else:
    cary = ans_list
    number = int(np.median(cary))
    ans = 0
    for i in ans_list:
        ans += abs(i - number)
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int,input().split()))
ans_list = []
for i in range(len(a_list)):
    ans_list.append(a_list[i] - i - 1)
import numpy as np
if len(ans_list)% 2 == 0:
    cary1 = np.delete(ans_list, min(ans_list))
    cary2 = np.delete(ans_list, max(ans_list))
    number1 = int(np.median(cary1))
    number2 = int(np.median(cary2))
    
    ans1 = 0
    ans2 = 0
    for i in ans_list:
        ans1 += abs(i - number1)
        ans2 += abs(i - number2)
    print(min(ans1 , ans2))
else:
    cary = ans_list
    number = int(np.median(cary))
    ans = 0
    for i in ans_list:
        ans += abs(i - number)
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int,input().split()))
ans_list = []
for i in range(len(a_list)):
    ans_list.append(a_list[i] - i - 1)
import numpy as np
if len(ans_list)% 2 == 0:
    cary = np.delete(ans_list, min(ans_list))
    
else:
    cary = ans_list
number = int(np.median(cary))
ans = 0
for i in ans_list:
    ans += abs(i - number)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int,input().split()))
ans_list = []
for i in range(len(a_list)):
    ans_list.append(a_list[i] - i - 1)
import numpy as np
if len(ans_list)% 2 == 0:
    cary1 = np.delete(ans_list, max(ans_list))
    cary2 = np.delete(ans_list, min(ans_list))
    number1 = int(np.median(cary1))
    number2 = int(np.median(cary2))
    ans1 = 0
    for i in ans_list:
        ans1 += abs(i - number1)
    ans2 = 0
    for i in ans_list:
        ans2 += abs(i - number2)
    print(min(ans1 , ans2))
    
else:
    cary = ans_list
    number = int(np.median(cary))
    ans = 0
    for i in ans_list:
        ans += abs(i - number)
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int,input().split()))
ans_list = []
for i in range(len(a_list)):
    ans_list.append(a_list[i] - i - 1)
import numpy as np
if len(ans_list)% 2 == 0:
    cary1 = np.delete(ans_list, max(ans_list))
    cary2 = np.delete(ans_list, min(ans_list))
    number1 = int(np.median(cary))
    number2 = int(np.median(cary))
    ans1 = 0
    for i in ans_list:
        ans1 += abs(i - number1)
    ans2 = 0
    for i in ans_list:
        ans2 += abs(i - number2)
    print(min(ans1 , ans2))
    
else:
    cary = ans_list
    number = int(np.median(cary))
    ans = 0
    for i in ans_list:
        ans += abs(i - number)
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int,input().split()))
ans_list = []
for i in range(len(a_list)):
    ans_list.append(a_list[i] - i - 1)
import numpy as np
if len(ans_list)% 2 == 0:
    cary = np.delete(ans_list, max(ans_list))
    
else:
    cary = ans_list
number = int(np.median(cary))
ans = 0
for i in ans_list:
    ans += abs(i - number)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int,input().split()))
import numpy as np
print(int(np.median(a_list)) - (a_list.index(int(np.median(a_list))) + 1))