Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()
x_d = list()

if n > m:
    print(0)
else:
    if m == 1:
        print(0)
    else:
#         for i in range(m-1):
#             x_d.append(x[i+1] - x[i])   
        x_d = list(np.diff(x))

        for i in range(n-1):
            
            x_d.remove(max(x_d))
            

        sumd = sum(x_d)  
        print(sumd)


Fixed submission:
import numpy as np
n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()
x_d = list()

if n > m:
    print(0)
else:
    if m == 1:
        print(0)
    else:
#         for i in range(m-1):
#             x_d.append(x[i+1] - x[i])   
        x_d = list(np.diff(x))

#         for i in range(n-1):
            
#             x_d.remove(max(x_d))
            
        x_d.sort(reverse=True)
#         sumd = sum(x_d)  
        sumd = sum(x_d[n-1:])
        print(sumd)

Buggy python submission (verdict: Time Limit Exceeded):
n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()
x_d = list()

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

        for i in range(n-1):
            
            x_d.remove(max(x_d))
            

        sumd = sum(x_d)  
        print(sumd)


Fixed submission:
import numpy as np
n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()
x_d = list()

if n > m:
    print(0)
else:
    if m == 1:
        print(0)
    else:
#         for i in range(m-1):
#             x_d.append(x[i+1] - x[i])   
        x_d = list(np.diff(x))

#         for i in range(n-1):
            
#             x_d.remove(max(x_d))
            
        x_d.sort(reverse=True)
#         sumd = sum(x_d)  
        sumd = sum(x_d[n-1:])
        print(sumd)

Buggy python submission (verdict: Runtime Error):
import pandas as pd

n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()



if m == 1:
    print(0)
else:
    x_df = pd.Series(x)
    x_d_df = x_df.diff()
    x_d = x_d_df.values.tolist()
    x_d.pop(0)

    for i in range(n-1):
        x_d.remove(max(x_d))
#         print(x_d)
    
    sumd = sum(x_d)  
    print(sumd)

Fixed submission:
import numpy as np
n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()
x_d = list()

if n > m:
    print(0)
else:
    if m == 1:
        print(0)
    else:
#         for i in range(m-1):
#             x_d.append(x[i+1] - x[i])   
        x_d = list(np.diff(x))

#         for i in range(n-1):
            
#             x_d.remove(max(x_d))
            
        x_d.sort(reverse=True)
#         sumd = sum(x_d)  
        sumd = sum(x_d[n-1:])
        print(sumd)

Buggy python submission (verdict: Runtime Error):
n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()
x_d = list()

if m == 1:
    print(0)
else:
    for i in range(m-1):
        x_d.append(x[i+1] - x[i])   
    
    for i in range(n-1):
        x_d.remove(max(x_d))
#         print(x_d)
    
    sumd = sum(x_d)  
    print(sumd)

Fixed submission:
import numpy as np
n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()
x_d = list()

if n > m:
    print(0)
else:
    if m == 1:
        print(0)
    else:
#         for i in range(m-1):
#             x_d.append(x[i+1] - x[i])   
        x_d = list(np.diff(x))

#         for i in range(n-1):
            
#             x_d.remove(max(x_d))
            
        x_d.sort(reverse=True)
#         sumd = sum(x_d)  
        sumd = sum(x_d[n-1:])
        print(sumd)

Buggy python submission (verdict: Runtime Error):
n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()
x_d = list()

if m ==1:
    print(0)
else:
    for i in range(m-1):
        x_d.append(x[i+1] - x[i])

    print(x,x_d)

    for i in range(n-1):
        x_d.remove(max(x_d))
    sumd = sum(x_d)  
    print(sumd)

Fixed submission:
import numpy as np
n,m =map(int, input().split())  #複数数値入力
x=list(map(int, input().split()))  #リスト入力

x.sort()
x_d = list()

if n > m:
    print(0)
else:
    if m == 1:
        print(0)
    else:
#         for i in range(m-1):
#             x_d.append(x[i+1] - x[i])   
        x_d = list(np.diff(x))

#         for i in range(n-1):
            
#             x_d.remove(max(x_d))
            
        x_d.sort(reverse=True)
#         sumd = sum(x_d)  
        sumd = sum(x_d[n-1:])
        print(sumd)