Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points = sorted(points)
koma = [points[i+1] - points[i] for i in range(M-1)]
sum_ = 0
for i in range(M-N):
  sum_ += min(koma)
  koma.remove(min(koma))
print(sum_)

Fixed submission:
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
if N > M:
  print(0)
else:
  points.sort()
  koma = [points[i+1] - points[i] for i in range(M-1)]
  koma.sort()
  print(sum(koma[:M-N]))

Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points = sorted(points)
koma = [points[i+1] - points[i] for i in range(M-1)]
sum_ = 0
for i in range(M-N):
  sum_ += min(koma)
  koma.remove(min(koma))
print(sum_)

Fixed submission:
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
if N > M:
  print(0)
else:
  points.sort()
  koma = [points[i+1] - points[i] for i in range(M-1)]
  koma.sort()
  print(sum(koma[:M-N]))

Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
sum_ = 0
for i in range(M-N):
  sum_ += min(koma)
  koma.remove(min(koma))
print(sum_)



Fixed submission:
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
if N > M:
  print(0)
else:
  points.sort()
  koma = [points[i+1] - points[i] for i in range(M-1)]
  koma.sort()
  print(sum(koma[:M-N]))

Buggy python submission (verdict: Runtime Error):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
for _ in range(N-1):
  koma.remove(max(koma))
print(sum(koma))

Fixed submission:
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
if N > M:
  print(0)
else:
  points.sort()
  koma = [points[i+1] - points[i] for i in range(M-1)]
  koma.sort()
  print(sum(koma[:M-N]))

Buggy python submission (verdict: Runtime Error):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
sum_ = sum(koma)
for i in range(N-1):
  sum_ -= max(koma)
  koma.remove(max(koma))
print(sum_)

Fixed submission:
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
if N > M:
  print(0)
else:
  points.sort()
  koma = [points[i+1] - points[i] for i in range(M-1)]
  koma.sort()
  print(sum(koma[:M-N]))

Buggy python submission (verdict: Runtime Error):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
for i in range(N-1):
  koma.remove(max(koma))
print(sum(koma))

Fixed submission:
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
if N > M:
  print(0)
else:
  points.sort()
  koma = [points[i+1] - points[i] for i in range(M-1)]
  koma.sort()
  print(sum(koma[:M-N]))

Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
sum_ = 0
for i in range(M-N):
  sum_ += min(koma)
  koma.remove(min(koma))
print(sum_)

Fixed submission:
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
if N > M:
  print(0)
else:
  points.sort()
  koma = [points[i+1] - points[i] for i in range(M-1)]
  koma.sort()
  print(sum(koma[:M-N]))