ZhenlongDai/ACPR huggingface dataset:
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

x.sort()
y = [abs(x2 - x1) for x1, x2 in zip(x[1:], x[:-1])]
y.sort()

print(sum(y[:-(n-1)]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

x.sort()
y = [abs(x2 - x1) for x1, x2 in zip(x[1:], x[:-1])]
y.sort()

if n == 1:
    print(sum(y))
else:
    print(sum(y[:-(n-1)]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

def submit():
    n, m = map(int, input().split())
    xlist = list(map(int, input().split()))

    if n >= m:
        print(0)
    else:
        xlist.sort()
        dlist = [xlist[i + 1] - xlist[i] for i in range(m - 1)]
        dlist.sort()
        print(sum(dlist[:-n + 1]))


if __name__ == "__main__":
    submit()

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):


def submit():
    n, m = map(int, input().split())
    xlist = list(map(int, input().split()))

    if n >= m:
        print(0)
    else:
        xlist.sort()
        dlist = [xlist[i + 1] - xlist[i] for i in range(m - 1)]
        dlist.sort()

        if n == 1:
            print(sum(dlist))
        else:
            print(sum(dlist[:1 - n]))


if __name__ == "__main__":
    submit()

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

def pin(type=int):
    return map(type,input().split())




N,M=pin()
P=sorted(list(pin()))
print("*",P)
PP=[abs(P[j+1]-P[j]) for j in range(M-1)]
print(PP)
Q=sorted(PP)
print(Q)
if N>=M:
    print(0)
else:
    for i in range(N-1):
        Q.pop()
    print(sum(Q))
    

Failing test case input:
110 1
-25885

Expected output:
0


Actual output:
* [-25885]
[]
[]
0


Fixed submission (verdict: Accepted):

def pin(type=int):
    return map(type,input().split())




N,M=pin()
P=sorted(list(pin()))

PP=[abs(P[j+1]-P[j]) for j in range(M-1)]

Q=sorted(PP)

if N>=M:
    print(0)
else:
    for i in range(N-1):
        Q.pop()
    print(sum(Q))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
line=list(map(int,input().split()))
if n >= m:
  print(0)
line.sort()
stock=0
distance=[]
for i in line:
  distance.append(i-stock)
  stock=i
distance.pop(0)
distance.sort()
ans=0
for i in range(m-n):
  ans+= distance[i]
print(ans)


Failing test case input:
110 0
-4980

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
line=list(map(int,input().split()))
if n >= m:
  print(0)
else:
  line.sort()
  stock=0
  distance=[]
  for i in line:
    distance.append(i-stock)
    stock=i
  distance.pop(0)
  distance.sort()
  ans=0
  for i in range(m-n):
    ans+= distance[i]
  print(ans)
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())
lx = list(map(int,input().split()))

lx.sort()
dx = []
s = 0

for i in range(len(lx)-1):
  dx.append(lx[i+1]-lx[i])

if n == 1:
  print(lx[m-1]-lx[0])
elif m <= n:
  print(0)
else:
  dx.sort()
  print(dx)
  for i in range(len(dx)-n+1):
    s = s + dx[i]
  print(s)

Failing test case input:
2 5
2 12 0 4 22

Expected output:
12


Actual output:
[2, 2, 8, 10]
12


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
lx = list(map(int,input().split()))

lx.sort()
dx = []
s = 0

for i in range(len(lx)-1):
  dx.append(lx[i+1]-lx[i])

if n == 1:
  print(lx[m-1]-lx[0])
elif m <= n:
  print(0)
else:
  dx.sort()
  for i in range(len(dx)-n+1):
    s = s + dx[i]
  print(s)

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())

List = list(map(int,input().split()))
List.sort()

sa = []

for i in range(M-1):
  a = List[i+1] - List[i]
  sa.append(a)
  
sa.sort()

print(sum(sa[N-1:]))

Failing test case input:
3 7
-8 0 0 9 -100 0 17

Expected output:
16


Actual output:
117


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

List = list(map(int,input().split()))
List.sort()

sa = []

for i in range(M-1):
  a = List[i+1] - List[i]
  sa.append(a)
  
sa.sort()
l = len(sa)

if N >= M:
  print(0)
else:
  print(sum(sa[:l-N+1]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N, M = map(int, input().split())

x = list(map(int, input().split()))
x.sort()

diff = [0] * (M-1)

for i in range(len(x) -1):
    diff[i] = abs(x[i+1] - x[i])

diff.sort()

print(sum(diff[:(-N+1)]))


Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):


import sys

N, M = map(int, input().split())

if (N >= M):
    print(0)
    sys.exit(0)

x = list(map(int, input().split()))
x.sort()

diff = [0] * (M-1)

for i in range(len(x) -1):
    diff[i] = abs(x[i+1] - x[i])

diff.sort()
idx = len(diff) - N + 1
print(sum(diff[:idx]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())
w = list(map(int,input().split()))
w.sort()
li = []
for i in range(len(w)-1):
    a = w[i+1]-w[i]
    li.append(a)
li.sort(reverse = True)


b = sum(li[:(n-1)])
d = abs(max(w)) + abs(min(w))

print(d-b)

Failing test case input:
100 1
-100000

Expected output:
0

Actual output:
200000


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
li = list(map(int,input().split()))
li2 = []
li.sort()
for i in range(m-1):
    li2.append(abs(li[i]-li[i+1]))
li2.sort()

if n >= m:
    print(0)
else:
    print(sum(li2[0:m-n]))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

koma_dist = []

for i in range(m - 1):
    koma_dist.append(x[i + 1] - x[i])

if n<m:
    print(sum(sorted(koma_dist)[:-(n - 1)]))
else:
    print(0)


Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

koma_dist = []

for i in range(m - 1):
    koma_dist.append(x[i + 1] - x[i])

if n<m:
    print(sum(sorted(koma_dist)[:m-n]))
else:
    print(0)

Problem: p03137
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
nm = input()
nm = nm.split()
n = int(nm[0])
m = int(nm[1])
nums = input()
nums = nums.split()
nums2 = []
for i in nums:
  nums2.append(int(i))
nums3 = []
i = 1
while i<len(nums2):
  nums3.append(nums2[i]-nums2[i-1])
  i+=1
nums3.sort()
nums3 = nums3[:n-2]
print(sum(nums3))

Failing test case input:
3 7
-8 -1 0 9 -100 2 17

Expected output:
17


Actual output:
-109


Fixed submission (verdict: Accepted):
nm = input()
nm = nm.split()
n = int(nm[0])
m = int(nm[1])
nums = input()
nums = nums.split()
nums2 = []
for i in nums:
  nums2.append(int(i))
nums2.sort()
nums3 = []
i = 1
while i<len(nums2):
  nums3.append(nums2[i]-nums2[i-1])
  i+=1
nums3.sort()
nums3 = nums3[:len(nums3)-n+1]
if(n>=m):
  print(0)
else:
  print(sum(nums3))

Problem: p03137
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
if n >= m:
  print(0)
  exit()
l = list(map(int,input().split()))
l.sort()
gap = []
for i in range(m-1):
  gap.append(l[i+1]-l[i])
gap.sort()
print(sum(gap[:1-n]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
if n >= m:
  print(0)
  exit()
s = set(map(int,input().split()))
l = list(s)
l.sort()
gap = []
for i in range(len(l)-1):
  gap.append(l[i+1]-l[i])
gap.sort()
print(sum(gap[:1-n]) if n!= 1 else sum(gap))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
X = sorted(map(int, input().split()))
D = sorted(abs(x - y) for x, y in zip(X, X[1:]))
print(sum(D[:-(N-1)]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
X = sorted(map(int, input().split()))
D = sorted(abs(x - y) for x, y in zip(X, X[1:]))
if N > 1:
    print(sum(D[:-(N-1)]))
else:
    print(sum(D))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)

if n >= m or m==1:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]
    x_sub = sorted(x_sub)
    print(sum(x_sub[:m-(n-1)]))


Failing test case input:
6 7
-8 -1 0 9 -100 2 17

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)

if n >= m or m==1:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]
    x_sub = sorted(x_sub)
    print(sum(x_sub[:(m-1)-(n-1)]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
if N >= M:
  print(0)
  exit()

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

X = sorted(X)
L = [ X[i] - X[i-1] for i in range(1, M)]
L = sorted(L)



print(sum(L[:-(N-1)]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
if N >= M:
  print(0)
  exit()

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

X = sorted(X)
L = [ X[i] - X[i-1] for i in range(1, M)]
L = sorted(L)



print(sum(L[:M-N]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split(' '))
if N >= M:
    print(0)
else:
    points = sorted(tuple(map(int, input().split(' '))))
    distances = sorted([abs(p1 - p2) for p1, p2 in zip(points, points[1:])])
    print(sum(distances[:-N + 1]))


Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split(' '))
if N >= M:
    print(0)
else:
    points = sorted(tuple(map(int, input().split(' '))))
    distances = sorted([abs(p1 - p2) for p1, p2 in zip(points, points[1:])], reverse=True)
    print(sum(distances[N - 1:]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
NM = [int(x) for x in input().split()]
N = NM[0]
M = NM[1]
X = [int(x) for x in input().split()]
X.sort()
print(X)
LL = 0
if N > M:
    print(LL)
else:
    L = [0] * (M - 1)
    for i in range (0, M - 1):
        L[i] = X[i + 1] - X[i]
    L.sort()
    print(L)
    for i in range(0, M - N):
        LL += L[i]
    print(LL)

Failing test case input:
3 7
-10 -3 0 9 -100 0 17

Expected output:
18


Actual output:
[-100, -10, -3, 0, 0, 9, 17]
[0, 3, 7, 8, 9, 90]
18


Fixed submission (verdict: Accepted):
NM = [int(x) for x in input().split()]
N = NM[0]
M = NM[1]
X = [int(x) for x in input().split()]
X.sort()

LL = 0
if N > M:
    print(LL)
else:
    L = [0] * (M - 1)
    for i in range (0, M - 1):
        L[i] = X[i + 1] - X[i]
    L.sort()
    
    for i in range(0, M - N):
        LL += L[i]
    print(LL)
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int,input().split())
X = list(map(int,input().split()))
if N >= M:
    ans = 0
else:
    X.sort()
    Sa = [0]*(M-1)
    for i in range(M-1):
        Sa[i] = X[i+1] - X[i]
    Sa.sort()
    ans = sum(Sa[:N+1])
print(ans)
    

Failing test case input:
5 7
-8 -1 0 9 -100 2 17

Expected output:
3


Actual output:
117


Fixed submission (verdict: Accepted):
N, M = map(int,input().split())
X = list(map(int,input().split()))
if N >= M:
    ans = 0
else:
    X.sort()
    Sa = [0]*(M-1)
    for i in range(M-1):
        Sa[i] = X[i+1] - X[i]
    Sa.sort()
    ans = sum(Sa[:M-N])
print(ans)

Problem: p03137
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, M = map(int,input().split())
X = list(map(int,input().split()))

ans = sorted([X[x+1] - X[x] for x in range(M-1)])

if N >= M:
    print(0)
else:
    print(sum(ans[:M-N]))

Failing test case input:
3 7
-19 -1 1 7 -140 2 17

Expected output:
18


Actual output:
-124


Fixed submission (verdict: Accepted):
N, M = map(int,input().split())
X = sorted(list(map(int,input().split())))

ans = sorted([X[x+1] - X[x] for x in range(M-1)])

if N >= M:
    print(0)
else:
    print(sum(ans[:M-N]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))

if n >= m:
  print(0)
  exit(0)
  
x.sort()
d=[0]*(m-1)
for i in range(m-1):
  d[i] = x[i + 1] - x[i]
  
d.sort()

print(sum(d[:-n+1]))


Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))

if n >= m:
  print(0)
  exit(0)

x.sort()

if n == 1:
  print(x[-1]-x[0])
  exit(0)

d = [0] * (m - 1)
for i in range(m - 1):
  d[i] = x[i + 1] - x[i]

d.sort()

print(sum(d[:-n + 1]))

Problem: p03137
Buggy submission (Python (3.8.2), verdict: Wrong Answer):



N, M = map(int, input().split())
X = [int(x) for x in input().split()]

def solve():
    if N >= M :
        return 0
    X.sort()
    d = [X[i+1] - X[i] for i in range(M-1)]
    d.sort()
    
    
    return sum(d[0:-(N-1)])
print(solve())

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):



N, M = map(int, input().split())
X = [int(x) for x in input().split()]

def solve():
    if N >= M :
        return 0
    X.sort()
    d = [X[i+1] - X[i] for i in range(M-1)]
    d.sort()
    
    
    return sum(d[0:M-N])
print(solve())
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))

X.sort() 

if N>=M:
  print(0)

intervals = [X[i+1]-X[i] for i in range(M-1)]
intervals.sort()

print(sum(intervals[:(M-N)]))

Failing test case input:
110 1
-45665

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))

X.sort() 

if N>=M:
  print(0)

else:
  intervals = [X[i+1]-X[i] for i in range(M-1)]
  intervals.sort()

  print(sum(intervals[:(M-N)]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int, input().split())
a = sorted(list(map(int ,input().split())), reverse=True)
d = []
for i in range(m-1):
  d += [a[i+1] - a[i]]
d.sort(reverse=True)
print(sum(d[n-1:]))

Failing test case input:
3 7
-19 -1 0 9 -100 2 17

Expected output:
18


Actual output:
-114


Fixed submission (verdict: Accepted):
n,m = map(int, input().split())
a = sorted(list(map(int ,input().split())))
d = []
for i in range(m-1):
  d += [a[i+1] - a[i]]
d.sort(reverse=True)
print(sum(d[n-1:]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

D = []
for i in range(1, M):
    d = X[i] - X[i - 1]
    D.append(d)
D.sort()

D = D[:-1 * (N - 1)]

print(sum(D))


Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

D = []
for i in range(1, M):
    d = X[i] - X[i - 1]
    D.append(d)
D.sort()

if N != 1:
    D = D[:-1 * (N - 1)]

print(sum(D))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
X_list = list(map(int, input().split()))
X_list.sort()
err_list = [X_list[i+1] - X_list[i] for i in range(len(X_list)-1)]
err_list.sort()

print(sum(err_list[:-(N-1)]))


Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
X_list = list(map(int, input().split()))
X_list.sort()
err_list = [X_list[i+1] - X_list[i] for i in range(len(X_list)-1)]
err_list.sort()

if N == 1:
    print(sum(err_list))
else:
    print(sum(err_list[:-(N-1)]))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
d = []
for i in range(len(x)-1):
    d.append(x[i+1]-x[i])
d = sorted(d)
if n==1:
    print(x[-1]-x[0])
elif n>=len(x):
    print(0)
else:
    ans = 0
    for i in range(n-1):
        ans+=d[-i-1]
    print(ans)

Failing test case input:
6 7
-8 -1 0 9 -100 2 17

Expected output:
1


Actual output:
116


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
d = []
for i in range(len(x)-1):
    d.append(x[i+1]-x[i])
d = sorted(d)
if n==1:
    print(x[-1]-x[0])
elif n>=len(x):
    print(0)
else:
    dis = 0
    for i in range(n-1):
        dis+=d[-i-1]
    print(sum(d)-dis)

Problem: p03137
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, M = map(int, input().split())
X = list(map(int, input().split()))
t = sorted(X, reverse=True)
h = [0] * M
for i in range(1, M):
    h[i] = abs(t[i - 1] - t[i])

tmp = sorted(h, reverse=True)
print(sum(tmp))

Failing test case input:
3 7
-8 -1 0 9 -100 2 17

Expected output:
17


Actual output:
117


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
X = list(map(int, input().split()))
t = sorted(X, reverse=True)
h = [0] * M
for i in range(1, M):
    h[i] = abs(t[i - 1] - t[i])

tmp = sorted(h, reverse=True)
print(sum(tmp[N - 1:]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
n, m = map(int, input().split())
X = list(map(int, input().split()))
if n >= m:
  print(0)
  sys.exit()

print(X)
X.sort()
print(X)

L = []
for i in range(m-1):
  L.append(X[i+1] - X[i])
print(L)
L.sort(reverse=True)
print(L)
print((X[m-1]-X[0]) - (sum(L[0:n-1])))


Failing test case input:
2 5
10 12 1 4 11

Expected output:
5


Actual output:
[10, 12, 1, 4, 11]
[1, 4, 10, 11, 12]
[3, 6, 1, 1]
[6, 3, 1, 1]
5


Fixed submission (verdict: Accepted):
import sys
n, m = map(int, input().split())
X = list(map(int, input().split()))
if n >= m:
  print(0)
  sys.exit()


X.sort()


L = []
for i in range(m-1):
  L.append(X[i+1] - X[i])

L.sort(reverse=True)

print((X[m-1]-X[0]) - (sum(L[0:n-1])))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=[]
for i in range(m-1):
  B.append(abs(A[i+1]-A[i]))
B.sort()
if n==1:
  sum(B)
else:
  print(sum(B[:-n+1:]))


Failing test case input:
001 0
-16660

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=[]
for i in range(m-1):
  B.append(abs(A[i+1]-A[i]))
B.sort()
if n==1:
  print(sum(B))

else:
  print(sum(B[:-n+1:]))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


n, m = map(int,input().split())
x = list(map(int,input().split()))

x.sort()

print(x)

aida = [0] * (m-1)
for i in range(1,m):
    aida[i-1] = x[i] - x[i-1]

aida.sort()
aida.reverse()

del aida[:n-1]

print(sum(aida))


Failing test case input:
2 7
-8 -1 0 9 -100 2 17

Expected output:
25


Actual output:
[-100, -8, -1, 0, 2, 9, 17]
25


Fixed submission (verdict: Accepted):




n, m = map(int,input().split())
x = list(map(int,input().split()))

x.sort()

aida = [0] * (m-1)
for i in range(1,m):
    aida[i-1] = x[i] - x[i-1]

aida.sort()
aida.reverse()

del aida[:n-1]

print(sum(aida))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = list(map(int, input().split()))
lst = sorted(set(map(int, input().split())))
print(lst)
dis = []
for i, j in zip(lst, lst[1:]):
    dis += [j - i]
    print(dis)
print(sum(sorted(dis, reverse=True)[n - 1:]))

Failing test case input:
011 1
-26332

Expected output:
0


Actual output:
[-26332]
0


Fixed submission (verdict: Accepted):
n, m = list(map(int, input().split()))
lst = sorted(set(map(int, input().split())))

dis = []
for i, j in zip(lst, lst[1:]):
    dis += [j - i]
    
print(sum(sorted(dis, reverse=True)[n - 1:]))

Problem: p03137
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
Y = []
for i in range(M-1):
    Y.append(X[i+1]-X[i])
Y.sort()
print(sum(Y[:-(N-1)]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
Y = []
if N>=M:
    print(0)
else:
    for i in range(M-1):
        Y.append(X[i+1]-X[i])
    Y=sorted(Y)[::-1]
    print(sum(Y[N-1:]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N,M = list(map(int, input().rstrip().split()))
X_list = list(map(int, input().rstrip().split()))


X_list.sort()

diff_list=[0]
for i in range(1,len(X_list)):
    diff = X_list[i] - X_list[i-1]
    diff_list.append(diff)

diff_list.sort()

if N > M:
    ans = 0
else:
    ex_num = N-1
    ans = sum(diff_list[1:]) - sum( diff_list[-ex_num:] )

print(ans)


Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):


N,M = list(map(int, input().rstrip().split()))
X_list = list(map(int, input().rstrip().split()))


X_list.sort()

diff_list=[0]
for i in range(1,len(X_list)):
    diff = X_list[i] - X_list[i-1]
    diff_list.append(diff)

diff_list.sort()

if N > M:
    ans = 0
elif N==1:
    ans = sum(diff_list[1:])
else:
    ex_num = N-1
    ans = sum(diff_list[1:]) - sum( diff_list[-ex_num:] )

print(ans)
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
Y=[]
for i in range(len(X)-1):
    Y.append(X[i+1]-X[i])
Y.sort()    
Y = Y[:-(N-1)]
print(sum(Y))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N,M=map(int,input().split())    
X=list(map(int,input().split()))
X.sort()
Y=[]
for i in range(len(X)-1):
    Y.append(X[i+1]-X[i])
Y.sort()    
if N!=1:
    Y = Y[:-(N-1)]
    print(sum(Y))
else:
    print(sum(Y))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = (int(i) for i in input().split())
x = list(map(int, input().split()))
x.sort()
out = list(map(lambda x,y: abs(x-y), x[:-1],x[1:]))
out.sort()
print(sum(out[0:-(n-1)]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = (int(i) for i in input().split())
x = list(map(int, input().split()))
if(m <= n):
    print(0)
else:
    x.sort()
    out = list(map(lambda x,y: abs(x-y), x[:-1],x[1:]))
    out.sort()
    if(n==1):
        print(sum(out[0:]))
    else:
        print(sum(out[0:-(n-1)]))

Problem: p03137
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys 
N, M = map(int, input().split())
X = list(map(int, input().split()))

X = sorted(X)

anslis = []


if M <= N:
    print(0)
    sys.exit()


    
for i in range(M-1):
    ans = abs(X[i+1] - X[i])
    anslis.append(ans)
    ans = 0

anslis = sorted(anslis)

print(sum(anslis[0:N+1]))


Failing test case input:
6 7
-8 -1 0 9 -100 2 17

Expected output:
1


Actual output:
117


Fixed submission (verdict: Accepted):
import sys 
N, M = map(int, input().split())
X = list(map(int, input().split()))

X = sorted(X)

anslis = []


if M <= N:
    print(0)
    sys.exit()


    
for i in range(M-1):
    ans = abs(X[i+1] - X[i])
    anslis.append(ans)
    ans = 0

anslis = sorted(anslis)

if N==1:
    print(sum(anslis))
else:
    print(sum(anslis[0:M-N]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())  
X = [int(x) for x in input().split()]  

if N >= M:  
    print(0)
else:  
    X.sort()  
    L = [X[i] - X[i-1] for i in range(1, M)]
    L.sort()
    ans = sum(L[:-N+1])
    print(ans)


Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())  
X = [int(x) for x in input().split()]  

if N >= M:  
    print(0)
else:  
    X.sort()  
    L = [X[i] - X[i-1] for i in range(1, M)]
    L.sort()
    ans = X[-1] - X[0]
    for i in range(1, N):
        ans -= L[-i]
    print(ans)
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

koma_dist = []

for i in range(m-1):
    koma_dist.append(x[i+1]-x[i])

print(sum(sorted(koma_dist)[:-min(n-1,m)]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

koma_dist = []

for i in range(m - 1):
    koma_dist.append(x[i + 1] - x[i])

if n<m:
    print(sum(sorted(koma_dist)[:m-n]))
else:
    print(0)

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
A=list(map(int,input().split()))

B=[]
for i in range(m-1):
  B.append(abs(A[i+1]-A[i]))
B.sort()
print(sum(B[:-n+1:]))


Failing test case input:
3 7
-8 -1 0 9 -100 0 17

Expected output:
16


Actual output:
34


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=[]
for i in range(m-1):
  B.append(abs(A[i+1]-A[i]))
B.sort()
if n==1:
  print(sum(B))

else:
  print(sum(B[:-n+1:]))

Problem: p03137
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M = map(int,input().split())
x_list = list(map(int,input().split()))

if N >= M:
    print(0)
else:
    x_list.sort()

    diff_list = []
    for i in range(M-1):
        diff_list.append(x_list[i+1]-x_list[i])

    diff_list.sort()

    print(sum(diff_list[:-(N-1)]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
x_list = list(map(int,input().split()))

if N >= M:
    print(0)
else:
    x_list.sort()

    diff_list = []
    
    for i in range(M-1):
        diff_list.append(x_list[i+1]-x_list[i])

    diff_list.sort(reverse=True)
    ans = x_list[-1] - x_list[0]
    for i in range(N-1):
        ans -= diff_list[i]
    print(ans)

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
X = sorted([int(i) for i in input().split()])
A = []

for i in range(m - 1):
    A.append(X[i + 1] - X[i])
    
A.sort()
print(sum(A[:-(n - 1)]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
X = sorted([int(i) for i in input().split()])
A = []

for i in range(m - 1):
    A.append(X[i + 1] - X[i])
    
A.sort(reverse = True)
print(sum(A[(n - 1):]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
D = [X[i+1]-X[i] for i in range(M-1)]
D.sort()
print(sum(D[:-N+1]))


Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
D = [X[i+1]-X[i] for i in range(M-1)]
D.sort()
print(sum(D[:-(N-1)]) if N != 1 else sum(D))
Problem: p03137
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
B=[]

if N>=M:
    print(0)
else:
    for i in range(M-1):
        B.append(X[i+1]-X[i])

    B.sort()
    print(sum(B[:-(N-1)]))



Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
B=[]

if N>=M:
    print(0)
else:
    for i in range(M-1):
        B.append(X[i+1]-X[i])

    B.sort()
    print(sum(B[:M-N]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
li = list(map(int, input().split()))

li.sort()

sa = [li[i+1] - li[i] for i in range(len(li)-1)]

sa.sort()

print(sum(sa[:-n+1]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
li = list(map(int, input().split()))
 
li.sort()
move_cost = [li[i+1] - li[i] for i in range(m-1)]
move_cost.sort()
if n > 1:
    move_cost = move_cost[:-n+1]

print(sum(move_cost))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = [int(x) for x in input().split()]

if n >= m:
    print(0)
    exit()

x_list = sorted([int(x) for x in input().split()])
gap_list = sorted([x_list[i] - x_list[i - 1] for i in range(1, m)])
print(sum(gap_list[:-(n - 1)]))


Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = [int(x) for x in input().split()]

if n >= m:
    print(0)
    exit()

x_list = sorted([int(x) for x in input().split()])
gap_list = sorted([x_list[i] - x_list[i - 1] for i in range(1, m)], reverse=True)
print(sum(gap_list[(n - 1):]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

x = []
for i in range(M-1):
    x.append(abs(X[i+1]-X[i]))

x.sort()

print(sum(x[:-(N-1)]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

x = []
for i in range(M-1):
    x.append(abs(X[i+1]-X[i]))

x=sorted(x)[::-1]
print(sum(x[N-1:]))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
l = list(map(int,input().split()))
l = list(sorted(l))

d = []
for i in range(M-1):
    d.append(abs(l[i+1]-l[i]))
d = list(sorted(d))
while N != 1 and len(d) !=0:
    del d[len(d)-1]
    N -= 1
sum = 0
if len(d) != 1:
    for i in range(len(d)):
        sum += d[i]
print(sum)


Failing test case input:
6 7
-8 -1 0 9 -100 2 17

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
l = list(map(int,input().split()))
l = list(sorted(l))

d = []
for i in range(M-1):
    d.append(abs(l[i+1]-l[i]))
d = list(sorted(d))
while N != 1 and len(d) !=0:
    del d[len(d)-1]
    N -= 1
sum = 0
if len(d) >= 1:
    for i in range(len(d)):
        sum += d[i]
print(sum)

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
diffNums = [abs(nums[i+1] - nums[i]) for i in range(M-1)]
diffNums.sort()
print(nums[-1] - nums[0] - sum(diffNums[-(N-1):]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
nums = list(map(int, input().split()))

if M <= N:
    ans = 0
elif N == 1:
    ans = max(nums) - min(nums)
else:
    nums.sort()
    diffNums = [nums[i+1] - nums[i] for i in range(M-1)]
    diffNums.sort()
    ans = sum(diffNums[:-(N-1)])

print(ans)

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int, input().split())
a=sorted(map(int, input().split()))
b=[]
for i in range(1,m):
    b.append(a[i]-a[i-1])
b.sort()
print(sum(b[:-n+1]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n,m=map(int, input().split())
a=sorted(map(int, input().split()))
b=[]
for i in range(1,m):
    b.append(a[i]-a[i-1])
b.sort()
if n>=m:print(0)
elif n==1:print(a[-1]-a[0])
else:print(sum(b[:-n+1]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
d = []
n,m = map(int,input().split())
x = list(sorted(map(int,input().split())))

for i in range(m-1):
    d.append(x[i+1]-x[i])

d = sorted(d)
print(sum(d[0:-(n-1)]))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
x = list(sorted(map(int,input().split())))

d = [ x[i+1]-x[i] for i in range(m-1) ]

d.sort()
print(sum(d[:-(n-1)])) if n-1 > 0 else print(sum(d))
Problem: p03137
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
a = X[0]
d = []
for i in X[1:]:
    d.append(i - a)
    a = i
d.sort()
if N < M:
    print(sum(d[:-N+1]))
else:
    print(0)

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
a = X[0]
d = []
for i in X[1:]:
    d.append(i - a)
    a = i
d.sort()
if N < M:
    print(sum(d[:M - N]))
else:
    print(0)

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
L = list(map(int, input().split()))

L.sort()
dist = [0 for _ in range(M-1)]
for i in range(M-1):
    dist[i] = abs(L[i+1] - L[i])
    
dist.sort()
res = sum(dist[:-N+1])
print(res)

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
L = list(map(int, input().split()))

L.sort()
dist = [0 for _ in range(M-1)]
for i in range(M-1):
    dist[i] = L[i+1] - L[i]
    
dist.sort(reverse=True)
res = sum(dist[N-1:])
print(res)

Problem: p03137
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys




N,M,*X = map(int, open(0).read().split())



if N >= M:
    print(0)
    sys.exit()

X.sort()

ans = []
for i in range(M-1):
    ans.append(abs(X[i+1] - X[i]))

ans.sort()
print(sum(ans[:-(N-1)]))


Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
import sys




N,M,*X = map(int, open(0).read().split())



if N >= M:
    print(0)
    sys.exit()

X.sort()
ans = []
for i in range(M-1):
    ans.append(abs(X[i+1] - X[i]))

ans.sort(reverse=True)
print(X[-1] - X[0] - sum(ans[:N-1]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M= list(map(int, input().split()))
X= list(map(int, input().split()))
X.sort()
div=[]
if N>=M:
    print("0")
else:
    for i in range(M-1):
        div.append(X[i+1]-X[i])
    div.sort()
    print(sum(div[:-(M-N-2)]))

Failing test case input:
2 7
-6 0 0 9 -100 0 17

Expected output:
23


Actual output:
6


Fixed submission (verdict: Accepted):
N,M= list(map(int, input().split()))
X= list(map(int, input().split()))
X.sort()
div=[]
if N>=M:
    print("0")
else:
    for i in range(M-1):
        div.append(X[i+1]-X[i])
    div.sort()
    print(sum(div[:M-N]))
Problem: p03137
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m = map(int,input().split())
x=list(map(int,input().split()))
x.sort()

if n>=m:
  print(0)
else:
  dises=[]
  for i in range(m-1):
    dises.append(x[i+1]-x[i])
  dises.sort()
  dises.reverse()
  print(dises)

  dis=0
  for i in range(n-1):
    dis+=dises[i]

  ans=x[m-1]-x[0]-dis
  print(ans)

Failing test case input:
3 7
-19 -1 1 7 -140 2 17

Expected output:
18


Actual output:
[121, 18, 10, 5, 2, 1]
18


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
x=list(map(int,input().split()))
x.sort()

if n>=m:
  print(0)
else:
  dises=[]
  for i in range(m-1):
    dises.append(x[i+1]-x[i])
  dises.sort()
  dises.reverse()
  

  dis=0
  for i in range(n-1):
    dis+=dises[i]

  ans=x[m-1]-x[0]-dis
  print(ans)

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n,m = map(int,input().split())
xlist = list(map(int,input().split()))

xlist.sort()
ylist=[]

for i in range(1,m):
    ylist.append(xlist[i]-xlist[i-1])

ylist.sort()
a=0
for i in range(1,m-n):
    a+=ylist[i]
print(a)



Failing test case input:
2 5
2 12 1 4 22

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):

n,m = map(int,input().split())
xlist = list(map(int,input().split()))

xlist.sort()
ylist=[]

for i in range(1,m):
    ylist.append(xlist[i]-xlist[i-1])

ylist.sort()
a=0
for i in range(0,m-n):
    a+=ylist[i]
print(a)

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int,input().split())
X = sorted(list(map(int,input().split())))

tmp = sorted([abs(X[i+1] - X[i]) for i in range(M-1)])
if(tmp != []):
  print(sum(tmp) - sum(tmp[N+1:]))
else:
  print(0)

Failing test case input:
2 7
-10 -3 0 9 -5 0 17

Expected output:
18


Actual output:
5


Fixed submission (verdict: Accepted):
N, M = map(int,input().split())
X = sorted(list(map(int,input().split())))

tmp = sorted([X[i+1] - X[i] for i in range(M-1)])
if(tmp != []):
  if(len(tmp) == 1):
    print(*tmp)
  elif(N == 1):
    print(sum(tmp))
  else:
    print(sum(tmp[:-(N-1)]))
else:
  print(0)

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())

X = list(map(int, input().split()))

X.sort()

buff = []

for i in range(M-1):
    buff.append(abs(X[i+1]-X[i]))


buff.sort()
buff = buff[::-1]

for i in range(min(N-1, len(buff))):
    print(buff.pop(0))

print(sum(buff))

Failing test case input:
2 5
2 12 1 4 22

Expected output:
11


Actual output:
10
11


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

X = list(map(int, input().split()))

X.sort()

buff = []

for i in range(M-1):
    buff.append(abs(X[i+1]-X[i]))


buff.sort()
buff = buff[::-1]

for i in range(min(N-1, len(buff))):
    buff.pop(0)

print(sum(buff))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from operator import itemgetter


def r(n, m, xl):
    if len(xl) == 1:
        return 0
    xl.sort()
    min_x = abs(min(xl))
    xl = [x + min_x for x in xl]
    xm = [xl[i+1] - xl[i] for i in range(len(xl)-1)]
    xm.sort()
    return sum(xm[:n+1])


def main():
    input = sys.stdin.readline
    n, m = list(map(int, input().split()))
    xl = list(map(int, input().split()))

    print(r(n, m, xl))


if __name__ == '__main__':
    main()


Failing test case input:
6 7
-8 -1 0 9 -100 2 17

Expected output:
1


Actual output:
117


Fixed submission (verdict: Accepted):
import sys
from operator import itemgetter


def r(n, m, xl):
    if len(xl) == 1:
        return 0
    if n >= m:
        return 0
    xl.sort()
    min_x = abs(min(xl))
    xl = [x + min_x for x in xl]
    xm = [xl[i+1] - xl[i] for i in range(len(xl)-1)]
    xm.sort()
    xxb = xm[:m-n]
    return sum(xxb)


def main():
    input = sys.stdin.readline
    n, m = list(map(int, input().split()))
    xl = list(map(int, input().split()))

    print(r(n, m, xl))


if __name__ == '__main__':
    main()

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
li0 = list(map(int,input().split()))
N,M = li0[0], li0[1]
li = list(map(int,input().split()))

if N>=M:
    ans = 0
else:
    li.sort()
    diff = []
    for i in range(M-1):
        diff.append(li[i+1]-li[i])
    diff.sort()
    ans = sum(diff[:-(N-1)])
print(ans)

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
NM = list(map(int,input().split()))
N,M = NM[0], NM[1]
li = list(map(int,input().split()))

if N>=M:
    ans = 0
else:
    li.sort()
    diff = []
    for i in range(M-1):
        diff.append(li[i+1]-li[i])
    diff.sort()
    if N == 1:
        ans = sum(diff)
    else:
        ans = sum(diff[:-(N-1)])
print(ans)

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
kyori=[]
if n>=m:
    print(0)
    
else:
    for i in range(m-1):
        kyori.append(a[i+1]-a[i])

kyori.sort()
b=sum(kyori[:m-n])
print(b)

Failing test case input:
010 1
-15986

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
kyori=[]
if n>=m:
    print(0)
    
else:
    for i in range(m-1):
        kyori.append(a[i+1]-a[i])
    b=0
    kyori.sort()
    for i in range(m-n):
        b+=kyori[i]
    
    print(b)
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

(N,M) = list(map(int,input().split()))
xlis = list(map(int,input().split()))
if N >= M:
    print("1")
else:
    xlis.sort()
    dist_lis = []
    for i in range(1,len(xlis)):
        dist_lis.append(xlis[i] - xlis[i-1])
    dist_lis.sort()

    for i in range(N-1):
        dist_lis.pop(-1)
    print(sum(dist_lis))


Failing test case input:
110 0
-6893

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):

(N,M) = list(map(int,input().split()))
xlis = list(map(int,input().split()))
if N >= M:
    print("0")
else:
    xlis.sort()
    dist_lis = []
    for i in range(1,len(xlis)):
        dist_lis.append(xlis[i] - xlis[i-1])
    dist_lis.sort()

    for i in range(N-1):
        dist_lis.pop(-1)
    print(sum(dist_lis))

Problem: p03137
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys 
N, M = map(int, input().split())
X = list(map(int, input().split()))

X = sorted(X)

anslis = []


if M <= N:
    print(0)
    sys.exit()


    
for i in range(M-1):
    ans = abs(X[i+1] - X[i])
    anslis.append(ans)
    ans = 0

anslis = sorted(anslis)

print(sum(anslis[0:N-1]))


Failing test case input:
3 7
-10 -3 0 9 -5 0 17

Expected output:
10


Actual output:
2


Fixed submission (verdict: Accepted):
import sys 
N, M = map(int, input().split())
X = list(map(int, input().split()))

X = sorted(X)

anslis = []


if M <= N:
    print(0)
    sys.exit()


    
for i in range(M-1):
    ans = abs(X[i+1] - X[i])
    anslis.append(ans)
    ans = 0

anslis = sorted(anslis)

if N==1:
    print(sum(anslis))
else:
    print(sum(anslis[0:M-N]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
a=[x[i+1]-x[i]for i in range(m-1)]
if m<=n:print(0);exit()
a.sort()
print(sum(a[:m-n+1]))

Failing test case input:
3 7
-8 -1 0 9 -100 2 17

Expected output:
17


Actual output:
25


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
a=[x[i+1]-x[i]for i in range(m-1)]
if m<=n:print(0);exit()
a.sort()
print(sum(a[:m-n]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)

dx = [ x[i+1] - x[i] for i in range(0, len(x)-1) ]
ans = sum(sorted(dx)[:-n+1])
print(ans)

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)

dx = [ x[i+1] - x[i] for i in range(0, len(x)-1) ]
if n >= m:
    ans = 0
else:
    ans = sum(sorted(dx)[:m-n])
print(ans)
Problem: p03137
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m = map(int,input().split())
ls = list(map(int,input().split()))
ls.sort()
for i in range(m-1):
    ls[i] = ls[i+1]-ls[i]
ls.sort()
if n == 1:
    print(sum(ls))
else:
    ls = ls[:-n]
    print(sum(ls))


Failing test case input:
001 0
-16660

Expected output:
0


Actual output:
-16660


Fixed submission (verdict: Accepted):
import sys
n,m = map(int,input().split())
ls = list(map(int,input().split()))
ls.sort()
if n >= m:
    print(0)
    sys.exit()
for i in range(m-1):
    ls[i] = ls[i+1]-ls[i]
del ls[-1]
ls.sort()
if n == 1:
    print(sum(ls))
else:
    ls = ls[:-(n-1)]
    print(sum(ls))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())

X = list(map(int, input().split())) 
X = sorted(X)

diff = []
for i in range(len(X)-1):
    diff.append(X[i+1] - X[i])

diff_sort = sorted(diff)


if M == 1:
    print(0)    
else:
    print(sum(diff_sort[0:N+1]))
print(diff_sort)

Failing test case input:
110 1
-25885

Expected output:
0


Actual output:
0
[]


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

X = list(map(int, input().split())) 
X = sorted(X)


if M <= N:
    print(0)  
    
else:
    diff = []
    for i in range(len(X)-1):
        diff.append(X[i+1] - X[i])
    
    diff_sort = sorted(diff)
    
    print(sum(diff_sort[0:M-N]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M=map(int, input().split())
X=list(map(int, input().split()))
X.sort()
diff = [X[i]-X[i-1]  for i in range(1,M)]
diff.sort()
del diff[-N+1:]
print(sum(diff))

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
N,M=map(int, input().split())
X=list(map(int, input().split()))
X.sort()
diff = [X[i]-X[i-1]  for i in range(1,M)]
diff.sort()
if N != 1:
  del diff[-N+1:]
print(sum(diff))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
alist = list(map(int, input().split()))
alist.sort()
blist = []

if n >= m :
  print(0)
else:
  for i in range(0,m-1):
    blist.append(alist[i+1] - alist[i])
  blist.sort()
  d = -1 * (n-1)
  c = sum(blist[d:])
  b1 = alist[m-1] - alist[0]
  print(b1 - c)

Failing test case input:
1 7
-8 -1 0 9 -100 2 17

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
alist = list(map(int, input().split()))
alist.sort()
blist = []

if n >= m :
  print(0)
elif n == 1:
  print(alist[m-1] - alist[0])
else:
  for i in range(0,m-1):
    blist.append(alist[i+1] - alist[i])
  blist.sort()
  d = -1 * (n-1)
  c = sum(blist[d:])
  b1 = alist[m-1] - alist[0]
  print(b1 - c)