Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b = [int(x) for x in input().split()]
import fractions
g = fractions.gcd(a,b)
ans = 1
mama = int(g ** (1/2))
for i in range(2,mama+2):
    while True:
        if g%i != 0:
            break
        else:
            g = g/i
            flag = 1
    if flag == 1:
        ans += 1
    flag = 0
if g != 1:
    ans += 1
print(ans)

Fixed submission:
a,b = [int(x) for x in input().split()]
import fractions
g = fractions.gcd(a,b)
ans = 1
mama = int(g ** (1/2))
flag = 0
for i in range(2,mama+2):
    while True:
        if g%i != 0:
            break
        else:
            g = g/i
            flag = 1
    if flag == 1:
        ans += 1
    flag = 0
if g != 1:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
l = len(s)
for i in range(l//2):
    s = s.replace("01","").replace("10","")
print(l-len(s))

Fixed submission:
s = input()
l = len(s)
print(l-abs(s.count("1")-s.count("0")))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
l = len(s)
for i in range(l//2):
    s = s.replace("01","").replace("10","")
print(l-len(s))

Fixed submission:
s = input()
l = len(s)
print(l-abs(s.count("1")-s.count("0")))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
DP=[1000000000]*(N+1)
DP[0] = 0
DP[1] = 0
DP[2] = DP[1] + abs(h[0]-h[1])
for i in range(1,N):
    for j in range(i+1,min(i+K+1,N+1)):
        DP[j] = min(DP[j],DP[i]+abs(h[j-1]-h[i-1]))
print(DP[N])

Fixed submission:
N,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
DP = [1000000000]*N
DP[0] = 0
def handan(i,x):
    if DP[i] > x:
        DP[i] = x
for i in range(1,N):
    for j in range(min(i,k)):
        x = DP[i-j-1] + abs(h[i]-h[i-j-1])
        handan(i,x)
print(DP[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
DP = [1000000000]*N
DP[0] = 0
def handan(i,x):
    if DP[i] > x:
        DP[i] = x
for i in range(1,N):
    for j in range(min(i,k)):
        x = DP[i-j-1] + abs(h[i]-h[i-j-1])
        handan(i,x)
print(DP[N-1])

Fixed submission:
N,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
DP = [1000000000]*N
DP[0] = 0
def handan(i,x):
    if DP[i] > x:
        DP[i] = x
for i in range(1,N):
    for j in range(min(i,k)):
        x = DP[i-j-1] + abs(h[i]-h[i-j-1])
        handan(i,x)
print(DP[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
DP = [1000000000]*N
DP[0] = 0
def handan(i,x):
    if DP[i] > x:
        DP[i] = x
for i in range(1,N):
    for j in range(min(i,k)):
        x = DP[i-j-1] + abs(h[i]-h[i-j-1])
        handan(i,x)
print(DP[N-1])

Fixed submission:
N,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
DP = [1000000000]*N
DP[0] = 0
def handan(i,x):
    if DP[i] > x:
        DP[i] = x
for i in range(1,N):
    for j in range(min(i,k)):
        x = DP[i-j-1] + abs(h[i]-h[i-j-1])
        handan(i,x)
print(DP[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,W = [int(x) for x in input().split()]
l = []
for i in range(N):
    l.append([int(x) for x in input().split()])
DP = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,W+1):
    for j in range(1,N+1):
        if l[j-1][0] > i:
            DP[j][i] = DP[j-1][i]
        else:
            DP[j][i] = max(DP[j-1][i],DP[j-1][i-l[j-1][0]]+l[j-1][1])
print(DP[N][W])

Fixed submission:
N,w = [int(x) for x in input().split()]
ll = []
for i in range(N):
    abc = [int(x) for x in input().split()]
    ll.append(abc)
DP = [[0]*(w+1) for i in range(N+1)]
for i in range(1,N+1):
    for j in range(1,w+1):
        if ll[i-1][0] <= j:
            DP[i][j] = max(DP[i-1][j-ll[i-1][0]]+ll[i-1][1],DP[i-1][j])
        else:
            DP[i][j] = DP[i-1][j]
print(DP[N][w])

Buggy python submission (verdict: Time Limit Exceeded):
N,w = [int(x) for x in input().split()]
ll = []
for i in range(N):
    abc = [int(x) for x in input().split()]
    ll.append(abc)
DP = [[0]*(w+1) for i in range(N+1)]
for i in range(1,N+1):
    for j in range(1,w+1):
        if ll[i-1][0] <= j:
            DP[i][j] = max(DP[i-1][j-ll[i-1][0]]+ll[i-1][1],DP[i-1][j])
        else:
            DP[i][j] = DP[i-1][j]
print(DP[N][w])

Fixed submission:
N,w = [int(x) for x in input().split()]
ll = []
for i in range(N):
    abc = [int(x) for x in input().split()]
    ll.append(abc)
DP = [[0]*(w+1) for i in range(N+1)]
for i in range(1,N+1):
    for j in range(1,w+1):
        if ll[i-1][0] <= j:
            DP[i][j] = max(DP[i-1][j-ll[i-1][0]]+ll[i-1][1],DP[i-1][j])
        else:
            DP[i][j] = DP[i-1][j]
print(DP[N][w])
Buggy python submission (verdict: Runtime Error):
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
lm = []
lp = []
while l:
    x = l.pop(0)
    if x >= 0:
        lp.append(x)
    else:
        lm.append(-x)
ans = 100000000000
if lm and lp:
  for i in range(min(len(lp),K)):
    if K - i - 1 > 0:
      ans = min(ans,2*lp[i] + lm[-(K-i-1)],lp[i] + 2*lm[-(K-i-1)])
    else:
      ans = min(ans,lp[i])
elif lp:
  ans = lp[K-1]
else:
  ans = lm[1-K]
print(ans)

Fixed submission:
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
ans = 100000000000
for i in range(N-K+1):
  le = l[i]
  ri = l[i+K-1]
  ans = min(ans,abs(le)+abs(ri-le),abs(ri)+abs(ri-le))
print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
lm = []
lp = []
while l:
    x = l.pop(0)
    if x >= 0:
        lp.append(x)
    else:
        lm.append(-x)
ans = 100000000000
if lm and lp:
  for i in range(min(len(lp),K)):
    ans = min(ans,2*lp[i] + lm[-(K-i-1)],lp[i] + 2*lm[-(K-i-1)])
elif lp:
  ans = lp[K-1]
else:
  ans = lm[1-K]
print(ans)

Fixed submission:
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
ans = 100000000000
for i in range(N-K+1):
  le = l[i]
  ri = l[i+K-1]
  ans = min(ans,abs(le)+abs(ri-le),abs(ri)+abs(ri-le))
print(ans)
Buggy python submission (verdict: Runtime Error):
a = input()
k = int(input())
b = list(a)
if k == 1:
    print(b[0])
else:
    for i in range(100):
        if int(b[i]) != 1:
            print(b[i])
            break

Fixed submission:
a = input()
k = int(input())
b = list(a)
if k == 1:
    print(b[0])
    exit()
else:
    for i in range(k):
        if int(b[i]) != 1:
            print(b[i])
            exit()
print(1)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = [int(x) for x in input().split()]
ll = [[0] * (N+1) for i in range(N+1)]
for i in range(M):
    l,r = [int(x) for x in input().split()]
    ll[l][r] += 1
for i in range(1,N+1):
    for j in range(1,N+1):
        ll[i][j] += ll[i-1][j]
for i in range(Q):
    ans = 0
    p,q = [int(x) for x in input().split()]
    for i in range(p,q+1):
        ans += ll[q][i]-ll[p-1][i]
    print(ans)

Fixed submission:
N,M,Q = [int(x) for x in input().split()]
ll = [[0] * (N+1) for i in range(N+1)]
for i in range(M):
    l,r = [int(x) for x in input().split()]
    ll[l][r] += 1
for i in range(1,N+1):
    for j in range(1,N+1):
        ll[i][j] += ll[i-1][j]
for i in range(Q):
    ans = 0
    p,q = [int(x) for x in input().split()]
    for i in range(p,q+1):
        ans += ll[q][i]-ll[p-1][i]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
l = [int(x) for x in input().split()]
s = [0] * (N+1)
for i in range(N):
    s[i+1] = s[i] + l[i]
s.sort()
ans = 0
owari = False
for i in range(N+1):
    if owari:
        break
    x = s.pop(0)
    count = 1
    for j in range(N+1):
        if not s:
            owari = True
            if count != 1:
              ans += math.factorial(count) // (math.factorial(count-2)*2)
            break
        elif x == s[0]:
            s.pop(0)
            count += 1
        elif count != 1:
            ans += math.factorial(count) // (math.factorial(count-2)*2)
            break
        else:
            break
print(ans)

Fixed submission:
N = int(input())
l = [int(x) for x in input().split()]
s = [0] * (N+1)
for i in range(N):
    s[i+1] = s[i] + l[i]
s.sort()

#count
table= {}
for i in range(N+1):
    if s[i] in table:
        table[s[i]] += 1
    else:
        table[s[i]] = 1
ans = 0
for key,val in table.items():
    if val >= 2:
        ans += val*(val-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
l = [int(x) for x in input().split()]
s = [0] * (N+1)
for i in range(N):
    s[i+1] = s[i] + l[i]
s.sort()
ans = 0
owari = False
for i in range(N+1):
    if owari:
        break
    x = s.pop(0)
    count = 1
    for j in range(N+1):
        if not s:
            owari = True
            if count != 1:
              ans += math.factorial(count) // (math.factorial(count-2)*2)
            break
        elif x == s[0]:
            s.pop(0)
            count += 1
        elif count != 1:
            ans += math.factorial(count) // (math.factorial(count-2)*2)
            break
        else:
            break
print(ans)

Fixed submission:
N = int(input())
l = [int(x) for x in input().split()]
s = [0] * (N+1)
for i in range(N):
    s[i+1] = s[i] + l[i]
s.sort()

#count
table= {}
for i in range(N+1):
    if s[i] in table:
        table[s[i]] += 1
    else:
        table[s[i]] = 1
ans = 0
for key,val in table.items():
    if val >= 2:
        ans += val*(val-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ll = []
for i in range(3):
    l = [int(x) for x in input().split()]
    ll.append(l)
if l[0][0] - l[0][1] != l[1][0] - l[1][1] or l[2][0] - l[2][1] != l[1][0] - l[1][1]:
    print("No")
    exit()
if l[0][2] - l[0][1] != l[1][2] - l[1][1] or l[2][2] - l[2][1] != l[1][2] - l[1][1]:
    print("No")
    exit()
if l[0][0] - l[1][0] != l[0][1] - l[1][1] or l[0][2] - l[1][2] != l[0][1] - l[1][1]:
    print("No")
    exit()
if l[2][0] - l[1][0] != l[2][1] - l[1][1] or l[2][2] - l[1][2] != l[2][1] - l[1][1]:
    print("No")
    exit()
print("Yes")

Fixed submission:
l = []
for i in range(3):
    ll = [int(x) for x in input().split()]
    l.append(ll)
if l[0][0] - l[0][1] != l[1][0] - l[1][1] or l[2][0] - l[2][1] != l[1][0] - l[1][1]:
    print("No")
    exit()
if l[0][2] - l[0][1] != l[1][2] - l[1][1] or l[2][2] - l[2][1] != l[1][2] - l[1][1]:
    print("No")
    exit()
if l[0][0] - l[1][0] != l[0][1] - l[1][1] or l[0][2] - l[1][2] != l[0][1] - l[1][1]:
    print("No")
    exit()
if l[2][0] - l[1][0] != l[2][1] - l[1][1] or l[2][2] - l[1][2] != l[2][1] - l[1][1]:
    print("No")
    exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ind = 0
rieki = []
if N == 2:
    print(1)
    exit()
sairi = 0
while True:
    ma = max(a[ind+1:N])
    kioku = ind+1
    ind = a.index(ma)
    if kioku != ind:
        mi = min(a[kioku:ind])
        if ma - mi > sairi:
            sairi = ma- mi
            ans = 1 
        elif ma - mi == sairi:
            ans += 1 
    if ind == N-1:
        break
print(ans)

Fixed submission:
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = []
mi = 10**9
for i in range(N):
    mi = min(mi,a[i])
    ans.append(a[i]-mi)
print(ans.count(max(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ind = 0
rieki = []
if N == 2:
    print(1)
    exit()
while True:
    ma = max(a[ind+1:N])
    kioku = ind+1
    ind = a.index(ma)
    if kioku != ind:
        mi = min(a[kioku:ind])
        rieki.append(ma-mi)
    if ind == N-1:
        break
rieki.sort(reverse = True)
ans = 1
for i in range(len(rieki)-1):
  if rieki[i] == rieki[i+1]:
    ans += 1
  else:
    break
print(ans)

Fixed submission:
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = []
mi = 10**9
for i in range(N):
    mi = min(mi,a[i])
    ans.append(a[i]-mi)
print(ans.count(max(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ind = 0
rieki = []
if N == 2:
    print(1)
    exit()
while True:
    ma = max(a[ind+1:N])
    kioku = ind+1
    ind = a.index(ma)
    if kioku != ind:
        mi = min(a[kioku:ind])
        rieki.append(ma-mi)
    if ind == N-1:
        break
rieki.sort(reverse = True)
ans = 1
for i in range(len(rieki)-1):
  if rieki[i] == rieki[i+1]:
    ans += 1
  else:
    break
print(ans)

Fixed submission:
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = []
mi = 10**9
for i in range(N):
    mi = min(mi,a[i])
    ans.append(a[i]-mi)
print(ans.count(max(ans)))

Buggy python submission (verdict: Runtime Error):
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ind = 0
rieki = []
while True:
    ma = max(a[ind+1:N])
    kioku = ind+1
    ind = a.index(ma)
    if kioku != ind:
        mi = min(a[kioku:ind])
        rieki.append(ma-mi)
    if ind == N-1:
        break
print(rieki.count(max(rieki)))

Fixed submission:
N,T = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = []
mi = 10**9
for i in range(N):
    mi = min(mi,a[i])
    ans.append(a[i]-mi)
print(ans.count(max(ans)))
Buggy python submission (verdict: Runtime Error):
import copy
a = list(input())
n = len(a)-1
ans = 0
for i in range(2 ** n):
    l=[]
    l = copy.copy(a)
    dokoka = [0]*(n)
    for j in range(n):
        if ((i >> j)&1):
            dokoka[j] = 1
    x = l.pop(0)
    while True:
      d = dokoka.pop(0)
      if d == 0:
          x += l.pop(0)
      else:
          ans += int(x)
          x = l.pop(0)
      if not dokoka:
          ans += int(x)
          break
print(ans)

Fixed submission:
import copy
a = list(input())
n = len(a)-1
ans = 0
if n == 0:
  print(int(a[0]))
else:
  for i in range(2 ** n):
    l=[]
    l = copy.copy(a)
    dokoka = [0]*(n)
    for j in range(n):
        if ((i >> j)&1):
            dokoka[j] = 1
    x = l.pop(0)
    while True:
      d = dokoka.pop(0)
      if d == 0:
          x += l.pop(0)
      else:
          ans += int(x)
          x = l.pop(0)
      if not dokoka:
          ans += int(x)
          break
  print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import sympy
import math

input = sys.stdin.readline

n = int(input())
ans = 0

for a in range(1,n+1):
    ans += (n-1) // a
    
print(ans)


Fixed submission:
import sys

input = sys.stdin.readline

n = int(input())
ans = 0

for a in range(1,n+1):
    ans += (n-1) // a
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline



S = input()
T = input()

S = S.replace('\n','')
T = T.replace('\n','')

s_list = list(S)
t_list = list(T)

itti = 0
max_itti = 0
for s in s_list:
    if s == t_list[itti]:
        itti += 1
        max_itti = max(max_itti,itti)
    else:
        itti = 0
flag = False

if max_itti == 0:
    for s in s_list:
        for t in t_list:
            if s == t:
                max_itti = 1
                flag = True
            if flag:
                break
        if flag:
            break
                

print(len(t_list) - max_itti)

Fixed submission:
import sys

input = sys.stdin.readline



S = input()
T = input()

S = S.replace('\n','')
T = T.replace('\n','')

s_list = list(S)
t_list = list(T)

itti = 0
min_count = 10**5
for i in range(len(s_list)):
    if i + len(t_list) > len(s_list):
        break
    count = 0
    for j in range(len(t_list)):
        if not s_list[i+j] == t_list[j]:
            count += 1
    min_count = min(count,min_count)

print(min_count)

Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline



S = input()
T = input()

s_list = list(S)
s_list = s_list[:-1]
t_list = list(T)
t_list = t_list[:-1]

itti = 0
max_itti = 0
for s in s_list:
    if s == t_list[itti]:
        itti += 1
        max_itti = max(max_itti,itti)
    else:
        itti = 0
flag = False

if max_itti == 0:
    for s in s_list:
        for t in t_list:
            if s == t:
                max_itti = 1
                flag = True
            if flag:
                break
        if flag:
            break
                

print(len(t_list) - max_itti)

Fixed submission:
import sys

input = sys.stdin.readline



S = input()
T = input()

S = S.replace('\n','')
T = T.replace('\n','')

s_list = list(S)
t_list = list(T)

itti = 0
min_count = 10**5
for i in range(len(s_list)):
    if i + len(t_list) > len(s_list):
        break
    count = 0
    for j in range(len(t_list)):
        if not s_list[i+j] == t_list[j]:
            count += 1
    min_count = min(count,min_count)

print(min_count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int , input().split()))
    max_number = 10 ** 18
    result = 1
    if 0 in A:
        print(0)
        return
    for a in A:
        result = result * a
    if result > max_number:
        print(-1)
    else:
        print(result)

    return


if __name__ == '__main__':
    main()


Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int , input().split()))
    max_number = 10 ** 18
    result = 1
    if 0 in A:
        print(0)
        return
    for a in A:
        result = result * a
        if result > max_number:
            print(-1)
            return
    print(result)
    return


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int , input().split()))
    result = reduce(lambda x, y: x * y, A)
    max_number = 10 ** 18
    if 0 in A:
        print(0)
        return
    if result > max_number:
        print(-1)
    else:
        print(result)

    return


if __name__ == '__main__':
    main()


Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int , input().split()))
    max_number = 10 ** 18
    result = 1
    if 0 in A:
        print(0)
        return
    for a in A:
        result = result * a
        if result > max_number:
            print(-1)
            return
    print(result)
    return


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int , input().split()))
    result = reduce(lambda x, y: x * y, A)
    max_number = 10 ** 18
    if result > max_number:
        print(-1)
    else:
        print(result)

    return


if __name__ == '__main__':
    main()

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int , input().split()))
    max_number = 10 ** 18
    result = 1
    if 0 in A:
        print(0)
        return
    for a in A:
        result = result * a
        if result > max_number:
            print(-1)
            return
    print(result)
    return


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import math

def main():
    input = sys.stdin.readline
    #1行に複数の入力の時は.split()使う
    AB = input().split()
    A, B = int(AB[0]), B = int(AB[1].replace(".",""))
    print(A*B // 100)
    return


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import math

def main():
    input = sys.stdin.readline
    #1行に複数の入力の時は.split()使う
    AB = input().split()
    A, B = int(AB[0]),int(AB[1].replace(".",""))
    print(A*B // 100)
    return


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
import math

def main():
    input = sys.stdin.readline
    #1行に複数の入力の時は.split()使う
    AB = input().split()
    A, B = int(AB[0]), B = int(AB[0].replace(".",""))
    print(A*B // 100)
    return


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import math

def main():
    input = sys.stdin.readline
    #1行に複数の入力の時は.split()使う
    AB = input().split()
    A, B = int(AB[0]),int(AB[1].replace(".",""))
    print(A*B // 100)
    return


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline

x = int(input())


for i in range(-1000,1000):
    for j in range(-1000,1000):
        if i**5 + j**5 == x:
            print(i,j)
            break


Fixed submission:
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline

x = int(input())


for i in range(1,1000):
    for j in range(-1000,1000):
        if i**5 - j**5 == x:
            print(i,j)
            exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq


input = sys.stdin.readline
n = int(input())

result = 0
for i in range(1,n):
    result += i
    
print(result)

Fixed submission:
import sys
import heapq


input = sys.stdin.readline
n = int(input())
result = n*(n-1)//2
print(result)

Buggy python submission (verdict: Runtime Error):
import sys
import heapq


input = sys.stdin.readline
n = int(input())
n_list = list(range(1,n))
print(sum(n_list))

Fixed submission:
import sys
import heapq


input = sys.stdin.readline
n = int(input())
result = n*(n-1)//2
print(result)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import sys

def main():
    input = sys.stdin.readline
    n,m = map(int, input().split())
    x_list = list(map(int, input().split()))
    if m == 1:
        print(0)
        exit(0)
    sabun_list = []
    x_list.sort()
    for i,x in  enumerate(x_list):
        if i == 0:
            continue
        sabun_list.append(x - x_list[i-1])
    result = 0
    sum_max_sabun = 0
    for i in range(n-1):
        max_index = sabun_list.index(max(sabun_list))
        sum_max_sabun += sabun_list[max_index]
        sabun_list.pop(max_index)
    
    result = (x_list[-1] - x_list[0]) - sum_max_sabun

    print(result)

    return


if __name__ == '__main__':
    main()

Fixed submission:
# -*- coding: utf-8 -*-

import sys

def main():
    input = sys.stdin.readline
    n,m = map(int, input().split())
    x_list = list(map(int, input().split()))
    if n >= m:
        print(0)
        exit(0)
    sabun_list = []
    x_list.sort()
    for i,x in  enumerate(x_list):
        if i == 0:
            continue
        sabun_list.append(x - x_list[i-1])
    result = 0
    sum_max_sabun = 0
    sabun_list.sort(reverse=True)
    sum_max_sabun = sum(sabun_list[:n-1])
    
    result = (x_list[-1] - x_list[0]) - sum_max_sabun

    print(result)

    return


if __name__ == '__main__':
    main()