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

if M <= N:
  print(0)
else:
  xs = sorted(XS)
  ds = list(map(lambda a,b: b-a, xs, xs[1:]))
  print(sum(sorted(ds)[:-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()]
XS = [int(i) for i in input().split()]

if M <= N:
  print(0)
else:
  xs = sorted(XS)
  ds = list(map(lambda a,b: b-a, xs, xs[1:]))
  print(sum(sorted(ds)[:M-N]))

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

x = map(int, input().split(' '))

if not M >= N:
    print(0)
    exit()

x_list = sorted(x)

distance_list = []

for i in range(0, M-1):
    distance = x_list[i+1] - x_list[i]
    distance_list.append(distance)

result = sum(sorted(distance_list)[N::-1])
print(result)
 

Failing test case input:
2 7
-18 -3 0 9 -5 0 15

Expected output:
20


Actual output:
5


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

x = map(int, input().split(' '))

if not M >= N:
    print(0)
    exit()

x_list = sorted(x)

distance_list = []

for i in range(0, M-1):
    distance = x_list[i+1] - x_list[i]
    distance_list.append(distance)

result = sum(sorted(distance_list)[::-1][N-1:])
print(result)

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)

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

A = sorted(A)
print(sum(A[:n+1]))

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

Expected output:
27


Actual output:
11


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

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

X = sorted(X)

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

A = sorted(A)

if n == 1:
    print(sum(A))
else:
    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()


if m == n:
    print(0)





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



diff_list.sort()



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







Failing test case input:
000 0
-166022

Expected output:
0


Actual output:
0
0


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









x.sort()








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



diff_list.sort()



if n-1>0:
    print(sum(diff_list[:-(n-1)]))
else:
    print(sum(diff_list))
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)
    exit()
z=[]
for i in range(1,m):
    z.append(x[i]-x[i-1])
z.sort()
print(x[m-1]-x[0]-sum(z[-(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()
if n>=m:
    print(0)
    exit()
z=[]
for i in range(1,m):
    z.append(x[i]-x[i-1])
z.sort()
if n==1:
    print(x[m-1]-x[0])
else:
    print(x[m-1]-x[0]-sum(z[-(n-1):]))

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


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m = nm()
    X = nl()
    if n >= m:
        print(0)
    else:
        X = sorted(X)
        D = [X[i + 1] - X[i] for i in range(m - 1)]
        D = sorted(D)
        print(sum(D[:-n + 1]))


if __name__ == '__main__':
    main()


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


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m = nm()
    X = nl()
    if n >= m:
        print(0)
    else:
        X = sorted(X)
        D = [X[i + 1] - X[i] for i in range(m - 1)]
        D = sorted(D, reverse=True)
        print(sum(D[n - 1:]))


if __name__ == '__main__':
    main()

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

input = sys.stdin.readlines()
N, M = map(int, input[0].strip().split(' '))
Xs = list(map(int, input[1].strip().split(' ')))
s = sorted(Xs)
gaps = [s[i+1]-s[i] for i in range(len(s)-1)]
sgaps = sorted(gaps)
if N>M:
    print(0)
else:
    print(sum(sgaps[:-(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

input = sys.stdin.readlines()
N, M = map(int, input[0].strip().split(' '))
Xs = list(map(int, input[1].strip().split(' ')))
s = sorted(Xs)
gaps = [s[i+1]-s[i] for i in range(len(s)-1)]
sgaps = sorted(gaps)
if N>=M:
    print(0)
else:
    print(sum(sgaps[:(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())))

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

ans = x[m-1]-x[0]
x = sorted([x[i] - x[i - 1] for i in range(1,m)])

print(ans - 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())))

if n >= m:
    print(0)
else:
    ans = x[m-1]-x[0]
    x = sorted([x[i] - x[i - 1] for i in range(1, m)])
    print(ans - sum(x[m-n:]))

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

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

Expected output:
11


Actual output:
20


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

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()
diff_list = [x_list[i] - x_list[i-1] for i in range(1, len(x_list))]
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()))

x_list.sort()
diff_list = [x_list[i] - x_list[i-1] for i in range(1, m)]
diff_list.sort()
if m-n < 0:
    nokori = 0
else:
    nokori = m - n
print(sum(diff_list[:nokori]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = []
for i in range(m-1):
    b.append(a[i+1]-a[i])
b = sorted(b)
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(list(map(int, input().split())))
b = []
for i in range(m-1):
    b.append(a[i+1]-a[i])
b = sorted(b)
print(sum(b) if n == 1 else sum(b[:-(n-1)]))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=list(map(int,input().split(" ")))
list_x=list(map(int,input().split(" ")))

list_x.sort()
list_d=[]

if m<=n:
    print(0)
else:
    i=0
    while i<=m-2:
        list_d.append(list_x[i+1]-list_x[i])
        i+=1
    list_d.sort()
    print(sum(list_d[0:m-n:1]))
    print(list_d)

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

Expected output:
8


Actual output:
8
[1, 1, 2, 4, 18, 121]


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

list_x.sort()
list_d=[]

if m<=n:
    print(0)
else:
    i=0
    while i<=m-2:
        list_d.append(list_x[i+1]-list_x[i])
        i+=1
    list_d.sort()
    print(sum(list_d[0:m-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 = list(sorted(x))

y = [x[i] - x[i - 1] for i in range(1, M)]
y = list(sorted(y))
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 = list(sorted(x))

y = [x[i] - x[i - 1] for i in range(1, M)]
y = list(sorted(y))

ans = 0
for i in range(M - N):
    ans += y[i]
print(ans)

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

def solve(N,M,Xs):
    if N >= M:
        return 0

    Ds = [abs(Xs[i]-Xs[i+1]) for i in range(len(Xs)-1)] 

    Ds.sort()
    
    

    return sum(Ds[0:len(Ds)-(math.ceil(N/2))])

def main():
    N, M = map(int, input().split())
    Xs = list(map(int, input().split()))
    Xs.sort()
    print(solve(N,M,Xs))


if __name__ == '__main__':
    main()

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

Expected output:
117


Actual output:
25


Fixed submission (verdict: Accepted):
import math

def solve(N,M,Xs):
    if N >= M:
        return 0

    Ds = [abs(Xs[i]-Xs[i+1]) for i in range(len(Xs)-1)] 

    Ds.sort()
    
    

    
    ntake = N-1

    return sum(Ds[0:len(Ds)-ntake])

def main():
    N, M = map(int, input().split())
    Xs = list(map(int, input().split()))
    Xs.sort()
    print(solve(N,M,Xs))


if __name__ == '__main__':
    main()

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

if m <= n:
    print(0)
else:
    lis2 = [0]
    for i in range(m-1):
        lis2.append(int(abs(lis[i+1] - lis[i])))
    lis2.sort()
    lis2.reverse()
    del lis2[0:(m - n - 2)]
    print(sum(lis2))

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 = map(int,input().split())
lis = list(map(int, input().split()))
lis.sort()

if m <= n:
    print(0)
else:
    lis2 = [0]
    for i in range(m-1):
        lis2.append(int(abs(lis[i+1] - lis[i])))
    lis2.sort()
    lis2.reverse()
    del lis2[0:(n-1)]
    print(sum(lis2))
Problem: p03137
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))

    if m <= n:
        print(0)
        return

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

    sort_d = sorted(d)
    del sort_d[n+1:]

    print(sum(sort_d))
    return


if __name__ == '__main__':
    main()




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

Expected output:
25


Actual output:
10


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

    if m <= n:
        print(0)
        return

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

    d.sort()

    print(sum(d[0:(m-n)]))
    return


if __name__ == '__main__':
    main()

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

N, M = map(int, input().split())
if N >= M:
    print(0)
    sys.exit(0)

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

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

distance_list.sort()
print(sum(distance_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):
import sys

N, M = map(int, input().split())
if N >= M:
    print(0)
    sys.exit(0)

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

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

distance_list.sort(reverse=True)
print(X[-1] - X[0] - sum(distance_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())))
if n >= m:
    print(0)
else:
    d = [0]*(m-1)
    for i in range(m-1):
        d[i] = x[i+1] - x[i]
    d.sort(reverse=True)
    if m%2 == 0:
        e = m-n-1
    else:
        e = m-n-2
    print(sum(d) - sum(d[0:e]))

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 = sorted(list( map(int,input().split())))
if n >= m:
    print(0)
else:
    d = [0]*(m-1)
    for i in range(m-1):
        d[i] = x[i+1] - x[i]
    d.sort()
    print(sum(d[0:m-n]))

Problem: p03137
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, m = map(int, input().split())
x = list(map(int, input().split()))
d = []
if n >= m:
    print(0)

else:
    x.sort()
    for i in range(m - 1):
        d.append(abs(x[i] - x[i + 1]))
    d.sort()
    print(sum(d[:n+1]))


Failing test case input:
4 7
-23 -1 1 7 -140 1 0

Expected output:
2


Actual output:
30


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
x = list(map(int, input().split()))
d = []
if n >= m:
    print(0)

else:
    x.sort()
    for i in range(m-1):
        d.append(abs(x[i] - x[i + 1]))
    d.sort()
    print(sum(d[:m-n]))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



N,M = [int(x) for x in input().split()]
xls = [int(x) for x in input().split()]
dls = [xls[i+1]-xls[i] for i in range(M-1)]
if N >= M:
    ans = 0
else:
    dls.sort()
    ans = sum(dls[0:M-N])

print(ans)

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

Expected output:
14


Actual output:
10


Fixed submission (verdict: Accepted):



N,M = [int(x) for x in input().split()]
xls = [int(x) for x in input().split()]
xls.sort()
dls = [xls[i+1]-xls[i] for i in range(M-1)]
if N >= M:
    ans = 0
else:
    dls.sort()
    ans = sum(dls[0:M-N])

print(ans)

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


n, m = input().split()
xs_str = input().split()
xs = list(map(int, xs_str))
xs.sort()

ys = []
for x1, x2 in zip(xs[0:-1], xs[1:]):
    ys.append(abs(x2 - x1))
ys.sort()

out = sum(ys[0:-(int(n)-1)])
print(out)

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()))
xs_str = input().split()
xs = list(map(int, xs_str))
xs.sort()
 
ys = []
for x1, x2 in zip(xs[0:-1], xs[1:]):
    ys.append(abs(x2 - x1))
ys.sort()

for i in range(n - 1):
    if ys == []:
        break
    else:
        ys.pop()
print(sum(ys))

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

for i in range(m-1):
  D.append(X[i+1]-X[i])
  
print(sum(sorted(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 = []

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

print(sum(sorted(D)[::-1][n-1:]))

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()])
diff_x = [x[i + 1] - x[i] for i in range(m - 1)]
if n >= m:
    print(0)
else:
    print((x[m - 1] - x[0]) - sum(diff_x))

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())
x = sorted([int(i) for i in input().split()])
diff_x = [x[i + 1] - x[i] for i in range(m - 1)]
diff_x.sort(reverse=True)
if n >= m:
    print(0)
else:
    print((x[m - 1] - x[0]) - sum(diff_x[0:n - 1]))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.sort()

c = []
if len(b) != 1:
  for i in range(len(b) - 1):
    c.append(b[i+1] - b[i])

if len(b) == 1:
  print(1)
  
    
else:  
  for j in range(min(a[0] - 1,a[1])):
    for k in range(len(c)):
      if c[k] == max(c):
        c[k] = 0

  print(sum(c))


Failing test case input:
010 1
-49749

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):


a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.sort()

c = []
if len(b) != 1:
  for i in range(len(b) - 1):
    c.append(b[i+1] - b[i])

if len(b) == 1:
  print(0)
  
    
else:  
  c.sort()
  for j in range(min(a[0] - 1,a[1])):
    c[len(c)- 1 - j] = 0
  print(sum(c))

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 = [X[i+1]-X[i] for i in range(M-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 = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
Y = [X[i+1]-X[i] for i in range(M-1)]
Y.sort()


if N == 1:
    print(sum(Y))
else:
    print(sum(Y[:-N+1]))

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()

subs = []
for i in range(M-1):
    subs.append(X[i+1]-X[i])
subs.sort()
print(sum(subs[:-(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()

subs = []
for i in range(M-1):
    subs.append(X[i+1]-X[i])
subs.sort()
if N == 1:
    print(sum(subs))
    exit()
print(sum(subs[:-(N-1)]))

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

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n, m = na()
li = na()
list.sort(li)
ls = []
for i in range(len(li)-1):
    ls.append(li[i+1]-li[i])
if len(ls) < n - 1:
    print(0)
else:
    for j in range(n - 1):
        if len(ls) > 0:
            ls.remove(max(ls))
print(sum(ls))

Failing test case input:
010 1
-20588

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n, m = na()
li = na()
ls = []
list.sort(li)
for i in range(len(li) - 1):
    ls.append(li[i + 1] - li[i])
ls = sorted(ls, reverse=True)
print(sum(ls[n-1:]))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = input().split()
N = int(N)
M = int(M)
X = list(map(int, input().split(" ")))

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

L = sorted(L)
if N >= M:
    print(0)
else:
    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 = input().split()
N = int(N)
M = int(M)
X = list(map(int, input().split(" ")))

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

L = sorted(L)
if N >= M:
    print(0)
elif N == 1:
    print(sum(L))
else:
    print(sum(L[:-N+1]))

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()
dif = [ X[i+1] - X[i] for i in range(M-1) ]
dif.sort()
print(dif)
add = max(0,M - N)
print(sum(dif[:add]))

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

Expected output:
14


Actual output:
[0, 2, 2, 3, 7, 23]
14


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

X.sort()
dif = [ X[i+1] - X[i] for i in range(M-1) ]
dif.sort()
add = max(0,M - N)
print(sum(dif[:add]))

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()])
if n>=m:
    print(0)
else:
    r=[]
    for i in range(m-1):
        r.append(x[i+1]-x[i])
    r.sort()
    print(sum(r[:-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()])
if n>=m:
    print(0)
else:
    r=[]
    for i in range(m-1):
        r.append(x[i+1]-x[i])
    r.sort()
    if n!=1:
        print(sum(r[:-n+1]))
    else:
        print(sum(r))

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

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()))
dis = []
if N >= M:
    print(0)
else:
    X.sort()
    for i in range(M-1):
        dis.append(abs(X[i+1] - X[i]))
    dis.sort(reverse=True)
    ans = max(X) - min(X) - sum(dis[:N-1])
    print(ans)
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = list(map(int, input().split()))
X = sorted(list(map(int, input().split())))

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

path_cnt = sorted([abs(X[i] - X[i + 1]) for i in range(M - 1)])

print(sum(path_cnt[:-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 = sorted(list(map(int, input().split())))

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

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

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve(n, x_list, m):
    if n >= m:
        return 0

    
    x_list.sort()

    
    diff_list = []
    for key in range(m - 1):
        diff = x_list[key + 1] - x_list[key]
        diff_list.append(diff)

    
    diff_list.sort()

    return sum(diff_list[:-n+1])


def main():
    n, m = map(int, input().split())
    x_list = list(map(int, input().split()))

    ans = solve(n, x_list, m)
    print(ans)


main()


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

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
def solve(n, m, x_list):
    if n >= m:
        return 0

    
    x_list.sort()

    
    diff_list = []
    for key in range(m - 1):
        diff = x_list[key + 1] - x_list[key]
        diff_list.append(diff)

    
    diff_list.sort(reverse=True)

    return sum(diff_list[n-1:])


def main():
    n, m = map(int, input().split())
    x_list = list(map(int, input().split()))

    ans = solve(n, m, x_list)
    print(ans)


main()

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()
s = [0] * M
for i in range(M - 1):
    s[i] = X[i + 1] - X[i]
s.sort()
print(sum(s[:-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()
s = [0] * (M - 1)
for i in range(M - 1):
    s[i] = X[i + 1] - X[i]
s.sort()
print(sum(s[:-N + 1]) if N != 1 else sum(s))

Problem: p03137
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):


def solve():

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

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

    X.sort()
    L = []
    for i in range(M-1):
        
        L.append(X[i+1]-X[i])
    L.sort()
    print(L)
    
    print(sum(L[:M-N]))


if __name__ == "__main__":
    solve()


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

Expected output:
117


Actual output:
[1, 2, 7, 7, 8, 92]
117


Fixed submission (verdict: Accepted):


def solve():

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

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

    X.sort()
    L = []
    for i in range(M-1):
        
        L.append(X[i+1]-X[i])
    L.sort()
    
    print(sum(L[:M-N]))


if __name__ == "__main__":
    solve()
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:
    print(0)
else:
    X.sort()
    Y = [X[i+1]-X[i] for i in range(M-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 = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
Y = [X[i+1]-X[i] for i in range(M-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):
n, m = [int(x) for x in input().split(' ')]
x = sorted([int(x) for x in input().split(' ')])

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

print(sorted([x[i] - x[i-1] for i in range(1, m)]))
diff = sum(sorted([abs(x[i] - x[i-1]) for i in range(1, m)])[:-n+1])
print(diff)


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

Expected output:
19


Actual output:
[2, 3, 7, 7, 9, 90]
19


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

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

diff = sorted([abs(x[i] - x[i-1]) for i in range(1, m)])
for i in range(n-1):
    diff.pop()

print(sum(diff))

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 = [nums[i+1] - nums[i] for i in range(M-1)]
diffNums.sort()
print(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 (PyPy3 (2.4.0), verdict: Wrong Answer):
N, M=map(int, input().split())
X=sorted(list(map(int, input().split())))
d=sorted([X[i]-X[i-1] for i in range(1, M)])
if N>=M:
  print(0)
else:
  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(list(map(int, input().split())))
d=sorted([X[i]-X[i-1] for i in range(1, M)])
if N>=M:
  print(0)
else:
  print(sum(d[:(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()))
if N >= M:
    print(0)
else:
    X.sort()
    new_list = []
    for j in range(1, M):
        new_list.append(abs(X[j] - X[j-1]))
    new_list.sort()
    print(sum(new_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(map(int, input().split()))
if N >= M:
    print(0)
else:
    X.sort()
    new_list = []
    for j in range(1, M):
        new_list.append(abs(X[j] - X[j-1]))
    new_list.sort()
    new_list.reverse()
    
    for i in range(M-N):
        new_list.pop()
    ans=(max(X)-min(X))-sum(new_list)
    
    print(ans)

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

if N > M:
    print(0)
    exit()

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

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 = input().split()
N = int(N)
M = int(M)
X = list(map(int, input().split(" ")))

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

L = sorted(L)
if N >= M:
    print(0)
elif N == 1:
    print(sum(L))
else:
    print(sum(L[:-N+1]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
N,M = list(map(int,input().split(" ")))
X = list(map(int,input().split(" ")))
X.sort()
diffs = []

if N >= M:
    print(0)
else:
    for i,x in enumerate(X[1:]):
        diff = abs(x-X[i])
        diffs.append(diff)
    diffs.sort()
    

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


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

Expected output:
117


Actual output:
1


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

if N >= M:
    print(0)
else:
    for i,x in enumerate(X[1:]):
        diff = abs(x-X[i])
        diffs.append(diff)
    diffs.sort()
    

    if N == 1:
        print(sum(diffs))
    else:
        print(sum(diffs[:-(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 = sorted(l)
le = []
if n >= m:
    print(0)
else:
    for i in range(m - 1):
        le.append(l[i + 1] - l[i])
    le = sorted(le)
    print(sum(le[:-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())
l = list(map(int, input().split()))
l = sorted(l)
le = []
if n >= m:
    print(0)
else:
    for i in range(m - 1):
        le.append(l[i + 1] - l[i])
    le = sorted(le)
    if n == 1:
        print(sum(le))
    else:
        print(sum(le[:-n+1]))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input().split()
m=int(n[1])
n=int(n[0])
x = list(map(int, input().split()))
x.sort()
gaplist=[]
for i in range(m-1):
    gaplist.append(x[i+1]-x[i])
gaplist.sort()
del gaplist[(n-1)*-1:]
print(sum(gaplist))

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

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
n = input().split()
m=int(n[1])
n=int(n[0])
x = list(map(int, input().split()))
x.sort()
gaplist=[]
for i in range(m-1):
    gaplist.append(x[i+1]-x[i])
gaplist.sort()
if n>1:
    del gaplist[(n-1)*-1:]
print(sum(gaplist))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
a_list = [int(i) for i in input().split()]
if (n > m):
    ans = 0
a_list = sorted(a_list)
b_list = [(a_list[i+1] - a_list[i]) for i in range(len(a_list)-1)]
b_list = sorted(b_list)
ans = sum(b_list[:-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())
a_list = [int(i) for i in input().split()]
if (n >= m):
    ans = 0
else:
    a_list = sorted(a_list)
    b_list = [(a_list[i+1] - a_list[i]) for i in range(len(a_list)-1)]
    b_list = sorted(b_list)
    ans = sum(b_list[0:(m-n)])
print(ans)

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
N,M = list(map(int,input().split(" ")))
X = list(map(int,input().split(" ")))
X.sort()
diffs = [0]

for i,x in enumerate(X[1:]):
    diff = abs(x-X[i])
    diffs.append(diff)
diffs.sort()

print(sum(diffs[:-(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 math
N,M = list(map(int,input().split(" ")))
X = list(map(int,input().split(" ")))
X.sort()
diffs = []

if N >= M:
    print(0)
else:
    for i,x in enumerate(X[1:]):
        diff = abs(x-X[i])
        diffs.append(diff)
    diffs.sort()
    

    if N == 1:
        print(sum(diffs))
    else:
        print(sum(diffs[:-(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()))
ans = 0
diff = []
 
X.sort()
 
for i in range(M-1):
  dif = X[i+1] -X[i]
  diff.append(dif)
  
diff.sort()

if (N < M):
  for n in range(N):
    diff.pop(-1)
 
  for i in range(len(diff)):
    ans += diff[i]

  print(ans)
else:
  print(ans)

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

Expected output:
18


Actual output:
8


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
diff = []
 
X.sort()
 
if (N < M): 
    for i in range(M-1):
        dif = X[i+1] - X[i]
        diff.append(dif)
    
    diff.sort()
    
    for i in range(M-N):
        ans += diff[i]
    
    
   
    
    
print(ans)
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  g = [int(a) for a in input().split()]
  g = sorted(g)
  L = g[:-1]
  R = g[1:]
  sub = [b - a for a, b in zip(L, R)]
  sub = sorted(sub)
  ans = sum(sub[:-(N-1)])
  print(ans)


if __name__ == '__main__':
  main()

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

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  ans = 0
  if N < M:
    g = [int(a) for a in input().split()]
    g = sorted(g)
    L = g[:-1]
    R = g[1:]
    sub = [b - a for a, b in zip(L, R)]
    sub = sorted(sub)
    ans = sum(sub[:(M-N)])
  print(ans)


if __name__ == '__main__':
  main()

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m, *x = map(int, open(0).read().split())
x.sort()
lst = [j - i for i, j in zip(x, x[1:])]
lst.sort()
s = sum(lst[:-n+1])
print(s)

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, *x = map(int, open(0).read().split())
if n >= m:
  print(0)
  quit()
x = sorted(set(x))
lst = [j - i for i, j in zip(x, x[1:])]
lst.sort(reverse=1)
s = sum(lst[n - 1:])
print(s)

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_list = []
for i in range(m-1):
    diff = x[i+1] - x[i]
    diff_list.append(diff)



diff_list.sort()



print(sum(diff_list[:-(max(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(map(int, input().split()))









x.sort()








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



diff_list.sort()



if n-1>0:
    print(sum(diff_list[:-(n-1)]))
else:
    print(sum(diff_list))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(map(int, input().split()))
print(s)
t = list(map(int, input().split()))
print(t)

if(s[0] >= s[1]):
  print(0)
else:
  t.sort()
  u=[]
  for i in range(s[1]-1):
    u.append(t[i+1]-t[i])
  u.sort()
  print(u)  
  total=0
  for i in range(s[1]-s[0]):
    total+=u[i]
  print(total)

Failing test case input:
011 1
-27998

Expected output:
0


Actual output:
[11, 1]
[-27998]
0


Fixed submission (verdict: Accepted):
s = list(map(int, input().split()))
t = list(map(int, input().split()))

if(s[0] >= s[1]):
  print(0)
else:
  t.sort()
  u=[]
  for i in range(s[1]-1):
    u.append(t[i+1]-t[i])
  u.sort()
  total=0
  for i in range(s[1]-s[0]):
    total+=u[i]
  print(total)
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())
lst = sorted([int(x) for x in input().split()])
lst2 = []
for x in range(1, len(lst)):
    lst2.append(lst[x] - lst[x - 1])

lst3 = sorted(lst2)
n = len(lst3) - N - 1
print(sum(lst3[:-n]))

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 = map(int, input().split())
lst = sorted([int(x) for x in input().split()])
lst2 = []
for x in range(1, len(lst)):
    lst2.append(lst[x] - lst[x - 1])

lst2.sort()
if N >= M:
    print(0)
else:
    print(sum(lst2[: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())))

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:
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())))

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 (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_diff = [x[i]-x[i-1] for i in range(1,m)]
x_diff.sort()
if n >= m:
  print(0)
else:
  del x_diff[-n+1:]
  print(sum(x_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()
x_diff = [x[i]-x[i-1] for i in range(1,m)]
x_diff.sort(reverse = True)
if n >= m:
  print(0)
else:
  del x_diff[:n-1]
  print(sum(x_diff))

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

x.sort()
dist_l = [0] * (m-1)

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

dist_l.sort()
print(sum(dist_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())
x = list(map(int,input().split()))

x.sort()
dist_l = [0] * (m-1)

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

dist_l.sort()
print(sum(dist_l[:-(n-1)]) if n !=1 else sum(dist_l))
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 = []
ans = 0
for i in range(m-1):
  a.append(x[i+1]-x[i])
if n >= m:
  print(0)
else:
  for i in range(m-n):
    ans += a[i]
  print(ans)


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

Expected output:
7


Actual output:
11


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

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=list(map(int,input().split()))
x=sorted(list(map(int,input().split())))
y=[0]*(m-1)
for i in range(m-1):
  y[i]=x[i+1]-x[i]
y=sorted(y)
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=list(map(int,input().split()))
x=sorted(list(map(int,input().split())))
y=[0]*(m-1)
for i in range(m-1):
  y[i]=x[i+1]-x[i]
y=sorted(y)
if n==1:
  print(sum(y))
else:
  print(sum(y[:-(n-1)]))

Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    X = [int(x) for x in 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]))










if __name__ == '__main__':
    main()



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


def main():
    N, M = [int(x) for x in input().split()]
    X = [int(x) for x in input().split()]
    X.sort()
    Y = []
    for i in range(M - 1):
        Y.append(X[i + 1] - X[i])
    Y.sort()

    i = 0
    while Y and i < N - 1:
        i += 1
        Y.pop()
    print(sum(Y))










if __name__ == '__main__':
    main()

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


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 = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
b = [a[i+1] - a[i] for i in range(len(a) - 1)]
b.sort()
if n == 1:
  print(sum(b))
elif len(b) <= n-1:
  print(0)
else:
  print(sum(b[0:-n+1]))
Problem: p03137
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n, m, *x = map(int, open(0).read().split())
    if n >= m:
        print(0)
        return
    x.sort()
    a = [x[i + 1] - x[i] for i in range(m - 1)]
    a.sort()
    ans = sum(a) - sum(a[-n+1:])
    print(ans)

if __name__ == '__main__':
    main()


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

Expected output:
117


Actual output:
0


Fixed submission (verdict: Accepted):
def main():
    n, m, *x = map(int, open(0).read().split())
    if n >= m:
        print(0)
        return
    x.sort()
    a = [x[i + 1] - x[i] for i in range(m - 1)]
    a.sort()
    if n == 1:
        print(sum(a))
        return
    ans = sum(a) - sum(a[-n+1:])
    print(ans)

if __name__ == '__main__':
    main()

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)

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

ans = X[M-1] - X[0]

diffs = [X[i+1] - X[i] for i in range(M-1)]
diffs = sorted(diffs)
diffs = diffs[-(N-1):]

print(ans - sum(diffs))

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()

if N >= M:
    print(0)
    exit()
diffs = [X[i+1] - X[i] for i in range(M-1)]
diffs.sort()
print(sum(diffs[: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()

sa = []
for i in range(len(x)-1):
    sa.append(x[i+1] - x[i])
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())
x=list(map(int,input().split()))
x.sort()

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

sa = []
for i in range(len(x)-1):
    sa.append(x[i+1] - x[i])
sa.sort()
sa.reverse()
ans = sum(sa)
for i in range(n-1):
    ans -= sa[i]
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()))

xSort = sorted(x)

dif = [0] * (m - 1)
for i in range(m - 1):
    dif[i] = xSort[i + 1] - xSort[i]
ans = sum(dif)

if (n == 1 or m == 1):
    print(ans)
else:
    tar = len(dif) - n
    difSort = sorted(dif)
    difS_2 = difSort[:tar]
    ans = sum(difS_2)
    print(ans)










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

Expected output:
12


Actual output:
4


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

xSort = sorted(x)

dif = [0] * (m - 1)
for i in range(m - 1):
    dif[i] = xSort[i + 1] - xSort[i]
ans = sum(dif)

if (n == 1 or m == 1):
    print(ans)

elif (n >= m):
    print('0')
else:
    tar = len(dif) - n + 1
    difSort = sorted(dif)
    difS_2 = difSort[:tar]
    ans = sum(difS_2)
    print(ans)
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()
else:
    difference = []
    x.sort()
 
    for i in range(m-1):
        difference.append(x[i+1]-x[i])
 
    difference.sort()
 
    print(sum(difference[:n-1]))


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

Expected output:
12


Actual output:
2


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

if n >= m:
    print(0)
    exit()
else:
    difference = []
    x.sort()
 
    for i in range(m-1):
        difference.append(x[i+1]-x[i])
 
    difference.sort()
 
    print(sum(difference[: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()))
if n >= m:
    print(0)
else:
    x.sort()
    y = []
    for i in range(len(x)-1):
        y.append(x[i+1]-x[i])
    y.sort()
    print(y)
    number = 0
    for i in range(len(y)-n+1):
        number = number + y[i]
        print(number)
    print(number)


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

Expected output:
18


Actual output:
[1, 2, 7, 8, 18, 81]
1
3
10
18
18


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

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


X.sort()
if N>=M: 
    print(0)
    sys.exit()
dif = [X[i+1]-X[i] for i in range(M-1)]
dif = sorted(dif)[:-N+2]
print(sum(dif))

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

Expected output:
19

Actual output:
27


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


X.sort()
if N>=M: 
    print(0)
    sys.exit()
dif = [X[i+1]-X[i] for i in range(M-1)]
if N==1: print(sum(dif))
else: print(sum(sorted(dif)[:-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)

if n>=m:
    print(0)
else:
    delta=[0]*(m-1)
    for i in range(m-1):
        delta[i]=x[i+1]-x[i]
    delta_s=sorted(delta)
    ans=sum(delta_s[:-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)

if n>=m:
    print(0)
elif n==1:
    ans=max(x)-min(x)
    print(ans)
else:
    delta=[0]*(m-1)
    for i in range(m-1):
        delta[i]=x[i+1]-x[i]
    delta_s=sorted(delta)
    ans=sum(delta_s[:-n+1])
    print(ans)