qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
a,b = input().split(" ")
if int(b)%int(a)==0:
  print(int(a)+int(b)
else:
  print(int(b)-int(a))

# Fixed code:
a,b = input().split(" ")
print(int(a)+int(b)) if int(b)%int(a)==0 else print(int(b)-int(a))
# Buggy code:
data = input().split()
A = data[0]
B = data[1]
if (B % A) == 0 :
    ANS = A+B
else:
    ANS = B - A
print(ANS)

# Fixed code:
data = input().split()
A = int(data[0])
B = int(data[1])
C = B%A
if C == 0 :
    ANS = A+B
else:
    ANS = B - A
print(ANS)
# Buggy code:
inputData = input().split(' ')
ans = 0

if int(inputData[1]) % input(inputData[0]) ==0:
    ans = int(inputData[0]) + int(inputData[1])
else:
    ans = int(inputData[1]) - int(inputData[0])
print(ans)

# Fixed code:
inputData = input().split(' ')
ans = 0

if int(inputData[1]) % int(inputData[0]) ==0:
    ans = int(inputData[0]) + int(inputData[1])
else:
    ans = int(inputData[1]) - int(inputData[0])
print(ans)
# Buggy code:

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

if a % b == 0:
    print(a+b)
else:
    print(b-a)


# Fixed code:
a,b = map(int, input().split())
if b % a == 0:
    print(a + b)
else:
    print(b - a)
# Buggy code:
a, b = map(int,input().split())
if b%a == 0:
  print(a+b)
else:
  print(a-b)

# Fixed code:
a, b = map(lambda x : int(x), input().split())

if (b % a == 0):
    print(a+b)
else:
    print(b-a)
# Buggy code:
A, B = map(int, input().split())

if A % B == 0:
    print(A + B)
else:
    print(B - A)
    

# Fixed code:
A,B = map(int,input().split())

if B % A == 0:
    print(A+B)
else:
    print(B-A)
# Buggy code:
a, b = map(int, input().split())
print(a+b if a%b == 0 else a-b)

# Fixed code:
a, b = map(int, input().split())

print(a+b if b % a == 0 else b-a)
# Buggy code:
A, B = map(int,input().split())
if(B%A == 0):
  print(A+B)
else:
  print(A-B)

# Fixed code:
A, B = map(int,input().split())
if(B%A == 0):
  print(A + B)
else:
  print(B - A)
# Buggy code:
n,k=map(int,input().split())
print(n+k if n%k ==0 else k-n)

# Fixed code:
n,k=map(int,input().split())
print(n+k if k%n ==0 else k-n)
# Buggy code:
a, b = map(int, input().split())
if b%a == 0:
  print(a+b)
 else:
  print(b-a)

# Fixed code:
a, b = map(int, input().split(' '))
if b % a == 0:
    print(a + b)
else:
    print(b - a)
# Buggy code:
a, b = map(int, input().split())
if b % a == 0:
  print(a + b)
else
  print(b - a) 



# Fixed code:
a,b=map(int,input().split())
if b%a:
    print(b-a)
else:
    print(a+b)
# Buggy code:
A,B = map(int, input().split())
print(B/A)
if B%A == 0:
    print(A+B)
else:
    print(B-A)

# Fixed code:
A, B = map(int,input().split())

if (B%A == 0):
  print(A+B)
else:
  print(B-A)
# Buggy code:
A,B = map(int, input().split())
if B % A = 0:
 print(A+B)
else:
 print(B-A)

# Fixed code:
A,B=map(int,input().split(' '))

if B % A == 0:
	print(A+B)
else:
	print(B-A)
# Buggy code:
import numpy as np
n,m = map(int,input().split())
if b%a == 0:
    print(b+a)
else:
    print(b-a)

# Fixed code:
import numpy as np
a,b = map(int,input().split())
if b%a == 0:
    print(b+a)
else:
    print(b-a)
# Buggy code:
a, b = map(int, input().split())

print(a + b if b % a == 0 else a - b)

# Fixed code:
a, b= map(int, input().split())

if b%a==0:
    print(a+b)
else:
    print(b-a)
# Buggy code:
a,b = map(int,input().split())
print(a+b if a%b==0 else b-a)

# Fixed code:
a,b = map(int,input().split())
print(a+b if (b%a)==0 else b-a)
# Buggy code:
a, b = map(int, input().split())

if a % b == 0:
  print(a + b)
else:
  print(b - a)
  

# Fixed code:
a,b=map(int,input().split())
if b%a==0:
  print(a+b)
else:
  print(b-a)
# Buggy code:
a,b=[int(x) for x in input().split()]
if a%b==0:
    print(a+b)
else:
    print(b-a)


# Fixed code:
a, b = [int(i) for i in input().split()]

if b % a == 0:
  print(a + b)
else:
  print(b - a)
# Buggy code:
A,B = map(int,input().split())
C = A%B
if (C == 0):
  print(A+B)
else:
  print(A-B)

# Fixed code:
A,B = map(int,input().split())

if B % A == 0:
  print(A + B)
else:
  print(B - A)
# Buggy code:
a,b = map(int,input().split())
if a%b == 0:
    print(a+b)
else:
    print(b-a)

# Fixed code:
a, b = map(int,input().split())

if b % a==0:
    print(a+b)
else:
    print(b-a)
# Buggy code:
A, B = map(int, input().split())

if A % B == 0:
	print(A + B)
else:
	print(B-A)


# Fixed code:
A,B = map(int,input().split())

if B%A == 0:
    ans = A+B
else:
    ans = B - A

print(ans)
# Buggy code:
A, B = list(map(int,input().split()))
if B%A ==0 :
	print(A+B)
else:
	print(A-B)

# Fixed code:
A,B = map(int,input().split())

if int(B % A) == 0:
    print(A+B)
else:
    print(B-A)
# Buggy code:
a,b = map(int,input().split())
if a % b == 0:
    print(a + b)
else:
    print(a -b)

# Fixed code:
a, b = map(int, input().strip().split())

if b % a == 0:
  print(b + a)
else:
  print(b - a)
# Buggy code:
s,m=map(int,input().split())
l=[]
for _ in range(s):
  n=[]
  n=list(map(int,input().split()))
  n.pop(0)
  l=l+n
m=dict()
for i in n:
  if i in m:
    m[i]+=1
  else:
    m[i]=1
cnt=0
for j in m:
  if m[j]==s:
    cnt+=1
print(cnt)
  

# Fixed code:
s,m=map(int,input().split())
l=[]
for _ in range(s):
  n=[]
  n=list(map(int,input().split()))
  n.pop(0)
  l=l+n
m=dict()
for i in l:
  if i in m:
    m[i]+=1
  else:
    m[i]=1
cnt=0
for j in m:
  if m[j]==s:
    cnt+=1
print(cnt)
# Buggy code:
import numpy as np
N, M = input().split()
hito = []
for i in range(int(N)):
    hito.append(input().split())

for i in range(int(N)):
    hito[i] = list(map(int, hito[i]))

hikaku = np.arange(1,int(M)+1)
for i in range(int(N)):
    hikaku = list(set(hikaku) & set(hito[i]))
    
print(len(hikaku))


# Fixed code:
import numpy as np
N, M = input().split()
hito = []
for i in range(int(N)):
    hito.append(input().split())

for i in range(int(N)):
    hito[i] = list(map(int, hito[i]))

for i in range(int(N)):
    hito[i].pop(0)

hikaku = np.arange(1,int(M)+1)
for i in range(int(N)):
    hikaku = list(set(hikaku) & set(hito[i]))



print(len(hikaku))
# Buggy code:
n, m = map(int,input().split())
data = [list(map(int,input().split())) for _ in range(m)]

s = None
for d in data:
  if s is None:
    s = set(d[1:])
  else:
    s = s & set(d[1:])
print(len(s))

# Fixed code:
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(n)]
s = None
for d in data:
    if s is None:
        s = set(d[1:])
    else:
        s = s & set(d[1:])
print(len(s))
# Buggy code:
n, m = map(int, input().split())
ans = [0] * m

for _ in range(n):
    a = list(map(int, input().split()))
    for i in a[1:]:
        ans[i] += 1

print(ans.count(n))


# Fixed code:
n, m = map(int, input().split())
ans = [0] * m
for _ in range(n):
    a = list(map(int, input().split()))
    
    for i in a[1:]:
        ans[i-1] += 1

print(ans.count(n))
# Buggy code:
N,M=map(int,input().split())
data = [input().split() for i in range(N)] 
# print(len(data))
result=[]
for j in range(N):
    result=result+data[j][1:]
# print(result)
ans=[x for x in result if result.count(x) == N]
print(len(ans))

# Fixed code:
N,M=map(int,input().split())
data = [input().split() for i in range(N)] 
result=[]
for j in range(N):
    result=result+data[j][1:]
result=[int(s) for s in result]
ans=[x for x in result if result.count(x) == N]
print(int(len(ans)/N))
# Buggy code:
a, b = map(int, input().split())
c = []
for i in range(a):
  *s, = map(int, input().split())
  c += s[1:]
count=[]
e = c[:]
d=list(set(c))

for i in d:
  if e.count(i) == a:
    count.append(i)
    
print(len(count))
print(e,d)

# Fixed code:
a, b = map(int, input().split())
c = []
for i in range(a):
  *s, = map(int, input().split())
  c += s[1:]
count=[]
e = c[:]
d=list(set(c))

for i in d:
  if e.count(i) == a:
    count.append(i)
    
print(len(count))
# Buggy code:
N,M = map(int, input().split())
foods = [0]*M
for i in range(N):
    tmp = list(map(int, input().split()))
    for f in tmp[1:]:
        foods[f-1] += 1

cnt = 0
for i in range(1,N+1):
    if foods[i-1]==N:
        cnt += 1
print(cnt)


# Fixed code:
N,M = map(int, input().split())
foods = [0]*M
for i in range(N):
    tmp = list(map(int, input().split()))
    for f in tmp[1:]:
        foods[f-1] += 1
cnt = 0
for i in range(1,M+1):
    if foods[i-1]==N:
        cnt += 1
print(cnt)
# Buggy code:
n,m=map(int,input().split(" ")) 
S=set(range(1,m+1))
for i in range(n):
    K, *A = map(int, input().split(" "))　
    S &=set(A) 
print(len(S))

# Fixed code:
n,m=map(int,input().split(" "))
S=set(range(1,m+1))
for i in range(n):
    K, *A = map(int, input().split(" "))
    S &=set(A)
print(len(S))
# Buggy code:
N, M = map(int, input().split())
print(N, M)

def main():
    cnts = [0]*M
    ans = 0

    for i in range(N):
        A = list(map(int, input().split()))[1:]
        for a in A:
            cnts[a-1] += 1

    for cnt in cnts:
        if cnt == N:
            ans += 1
    return ans


if __name__ == '__main__':
    print(main())


# Fixed code:
N, M = map(int, input().split())

def main():
    cnts = [0]*M
    ans = 0

    for i in range(N):
        A = list(map(int, input().split()))[1:]
        for a in A:
            cnts[a-1] += 1

    for cnt in cnts:
        if cnt == N:
            ans += 1
    return ans


if __name__ == '__main__':
    print(main())
# Buggy code:
# -*- coding: utf-8 -*-

n,m = map(int,input().split() )
b = [0]*m
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(1, len(a)):
		print(j)
		b[a[j]-1] += 1
ans = b.count(n)
print(ans)



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

n,m = map(int,input().split() )
b = [0]*m
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(1, len(a)):
		b[a[j]-1] += 1
ans = b.count(n)
print(ans)
# Buggy code:
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))

b = [x[1:] for x in a ]

c = []
for j in range(30):
    for k in range(n):
        if j in b[k]:
            c.append(j)

d = [x for x in set(c) if c.count(x) == n]
print(len(d))

# Fixed code:
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))

b = [x[1:] for x in a ]

c = []
for j in range(1,31):
    for k in range(n):
        if j in b[k]:
            c.append(j)

d = [x for x in set(c) if c.count(x) == n]

print(len(d))
# Buggy code:
n,m=list(map(int,input().split()))
a=set(input()[1:])
for i in range(n-1):
  b=set(input()[1:])
  a=set(a&b)
print(len(a)-1)


# Fixed code:
n,m=list(map(int,input().split()))
a=set(input().split()[1:])
for i in range(n-1):
  b=set(input().split()[1:])
  a=set(a&b)
print(len(a))
# Buggy code:
n,m=map(int,input().split())
a=[]
ans=0
for i in range(n):
    for j in map(int,input().split()):
        a.append(j)

for k in range(m):
    if a.count(k) == m:
        ans+=1
print(ans)
    

    

# Fixed code:
n,m=map(int,input().split())
a=[]
ans=0
for i in range(n):
    ii=0
    for j in map(int,input().split()):
        if ii > 0:
        	a.append(j)
        ii+=1
#print(a)
 
for k in range(1,m+1):
    if a.count(k) == n:
        ans+=1
print(ans)
# Buggy code:
n,m  = list(map(int, input().split()))
k = list(list(map(int, input().split())) for _ in range(n))
c = 0
f = 0
for i in range(m):
    for j in range(n):
        if not i in k[j]:
            f == 1

    if f == 0:
        c += 1

print(c)

# Fixed code:
n,m  = list(map(int, input().split()))
k = list(list(map(int, input().split())) for _ in range(n))
c = 0

for i in range(m):
    f = 0
    for j in range(n):
        if not i+1 in k[j][1:]:
            f = 1
            #print(i+1)
            #print(k[j][1:])
    if f == 0:
        c += 1

print(c)
# Buggy code:
N,M = map(int,input().split())
array2 = [0 for i in range(M+1)]
for i in range(N):
  array = list(map(int,input().split()))
  array.pop[0]
  for j in array:
    array2[j] += 1
c = 0
for k in array2:
  if k == N:
    c += 1
print(c)
  

# Fixed code:
N,M = map(int,input().split())
array2 = [0 for i in range(M+1)]
for i in range(N):
  array = list(map(int,input().split()))
  array.pop(0)
  for j in array:
    array2[j] += 1
c = 0
for k in array2:
  if k == N:
    c += 1
print(c)
# Buggy code:
N, M = map(int, input().split())
foods = [0]*(M)

for i in range(N):
  person = list(map(int, input().split()))
  for j in range(M):
    if j in person:
      foods[j] += 1
ans = 0
for i in range(M):
  if foods[i] == N:
    ans += 1
print(ans)

# Fixed code:
N, M = map(int, input().split())
foods = [0]*(M+1)

for i in range(N):
  person = list(map(int, input().split()))
  for j in range(1,M+1):
    if j in person[1:]:
      foods[j] += 1
ans = 0
for i in range(1,M+1):
  if foods[i] == N:
    ans += 1
print(ans)
# Buggy code:


def main():
    A,B = map(int,input().split())
    
    originalList = set(list(map(int,input().split()))[1:])
    print(originalList)
    for i in range(A-1):
        list1=set(list(map(int,input().split()))[1:])
        print(list1)
        print(type(list1))
        originalList = originalList & list1
        print(originalList)
        print(type(originalList))

    print(len(originalList))










if __name__== "__main__":
    main() 

# Fixed code:


def main():
    A,B = map(int,input().split())
    
    originalList = set(list(map(int,input().split()))[1:])
    for i in range(A-1):
        list1=set(list(map(int,input().split()))[1:])
        originalList = originalList & list1

    print(len(originalList))


if __name__== "__main__":
    main()
# Buggy code:
N,M=map(int,input().split())
KA=[]
for i in range(N):
    KA.append(list(map(int,input().split())))
A=[]
for i in range(N):
    for j in range(1,len(KA[i])):
        A.append(KA[i][j])
a=0
for i in range(M):
    if A.count(i)==N:
        a+=1
print(a)

# Fixed code:
N,M=map(int,input().split())
KA=[]
A=[]
a=0
for i in range(N):
    KA.append(list(map(int,input().split())))
for i in range(N):
    KA[i].remove(KA[i][0])
for i in range(N):
    for j in range(len(KA[i])):
        A.append(KA[i][j])
for i in range(1,M+1):
    if N==A.count(i):
        a+=1
print(a)
# Buggy code:
n = int(input())
k = 0
alist = []
while k < n :
  a = list(map(int,input().split()))
  alist.append(a)
  k += 1
#
for blist in alist :
  b = blist[0]
  blist.remove(b)
#
anslist = []
ans = 0
i_roop = len(alist[0])
while i_roop >= 0 :
  if i_roop == 0 :
    break
  else:
    c = min(alist[0])
    for j in range(1,n) :
      if c in alist[j] :
        anslist.append("OK")
        if j == n-1 :
          if len(anslist) == n-1 :
            ans += 1
      else:
        if j == n-1 :
          if len(anslist) == n-1 :
            ans += 1
        break
    alist[0].remove(c)
  anslist = []
  i_roop += -1

print(ans)

# Fixed code:
n,m = map(int,input().split())
k = 0
alist = []
while k < n :
  a = list(map(int,input().split()))
  alist.append(a)
  k += 1
#
if n == 1 :
  print(len(alist[0])-1)
else:
  for blist in alist :
    b = blist[0]
    blist.remove(b)
#
  anslist = []
  ans = 0
  i_roop = len(alist[0])
  while i_roop >= 0 :
    if i_roop == 0 :
      break
    else:
      c = min(alist[0])
      for j in range(1,n) :
        if c in alist[j] :
          anslist.append("OK")
          if j == n-1 :
            if len(anslist) == n-1 :
              ans += 1
        else:
          if j == n-1 :
            if len(anslist) == n-1 :
              ans += 1
          break
      alist[0].remove(c)
    anslist = []
    i_roop += -1

if n != 1 :
  print(ans)
# Buggy code:
n, m = map(int, input().split())
a = set(input().split()[1:])
for i in range(n - 1):
    a &= set(reads()[1:])
print(len(a))

# Fixed code:
n, m = map(int, input().split())
a = set(input().split()[1:])
for i in range(n - 1):
    a &= set(input().split()[1:])
print(len(a))
# Buggy code:
N,M = map(int,input().split())
num = []
for i in range(N):
    num.append(list(map(int,input().split()[1:])))
count = 0
for j in range(1,M+1):
    if all(j in num[i] for i in range(N)):
        count += 1
print(count)   
print(num)

# Fixed code:
N,M = map(int,input().split())
num = []
for i in range(N):
    num.append(list(map(int,input().split()[1:])))
count = 0
for j in range(1,M+1):
    if all(j in num[i] for i in range(N)):
        count += 1
print(count)
# Buggy code:
n,m = [int(i) for i in input().split()]

common = list(range(1,m+1))
for i in range(n):
  like = [int(i) for i in input().split()][1:]
  for j in common:
    if j not in like:
      common.remove(j)

print(len(common))
  


# Fixed code:
import copy

n,m = [int(i) for i in input().split()]

common = list(range(1,m+1))
for i in range(n):
  like = [int(i) for i in input().split()][1:]
  for j in common[::-1]:
    if j not in like:
      common.remove(j)
  
print(len(common))
# Buggy code:
n, m = map(int, input().split())
all = {int(i) for i in range(1, i + 1)}
for _ in range(n):
    k, *i_th = map(int, input().split())
    all &= set(list(i_th))
print(len(all))

# Fixed code:
n, m = map(int, input().split())
all = {int(i) for i in range(1, m + 1)}
for _ in range(n):
    k, *i_th = map(int, input().split())
    all &= set(i_th)
print(len(all))
# Buggy code:
n, m = list(map(int, input().split()))
se = set(range(1, m + 1))
for _ in range(n):
    x = set(map(int, input().split()))
    se -= x

print(len(se))


# Fixed code:
n, m = list(map(int, input().split()))
se = set(range(1, m + 1))
for _ in range(n):
    x = se - set(list(map(int, input().split()))[1:])
    se -= x

print(len(se))
# Buggy code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.pop(0)
for _ in range(N-1):
    B=list(map(int,input().split()))
    for num in A[1:]:
        if num not in B:
            A.remove(num)

print(len(A))

# Fixed code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.pop(0)

if N>1:
    for _ in range(N-1):
        B=list(map(int,input().split()))
        B.pop(0)
        A=[num for num in A if num in B]

print(len(A))
# Buggy code:
#ABC-118-B
N, M = map(int, input().split())
memo = [0]*(M+1)

for _ in range(N):
    Ki, *A = map(int, input().split())
    for item in A:
        memo[int(item)] += 1

ans = 0
for i in range(1, M):
    if memo[i] == N:
        ans += 1
        
print(ans)

# Fixed code:
#ABC-118-B
N, M = map(int, input().split())
memo = [0]*(M+1)

for _ in range(N):
    Ki, *A = map(int, input().split())
    for item in A:
        memo[int(item)] += 1

ans = 0
for i in range(1, M+1):
    if memo[i] == N:
        ans += 1

print(ans)
# Buggy code:
import itertools
n,m=map(int,input().split())
a=[]
for i in range(0,n):
  a.append(list(map(int,input().split())))
  del a[i][0]
a=list(itertools.chain.from_iterable(a))
count=0
for i in range(0,m):
  if a.count(i)==n
  count=count+1
print(count)

# Fixed code:
import itertools
n,m=map(int,input().split())
a=[]
for i in range(0,n):
  a.append(list(map(int,input().split())))
  del a[i][0]
a=list(itertools.chain.from_iterable(a))
count=0
for i in range(0,m):
  if a.count(i+1)==n:
    count=count+1
print(count)
# Buggy code:
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  for saj in sa:
    aj = int(saj)
    flg[aj - 1] += 1

suma = 0
for sumaj in range(flg):
  if sumaj == n:
    suma += 1
print(suma)

# Fixed code:
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  if len(sa) > 1:
    for saj in sa[1:]:
      aj = int(saj)
      flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)
# Buggy code:
lst = []
n,m = map(int, input().split())
for i in range(n):
  k = list(map(int,input().split()))
  lst = lst + k[1:]
a = 0
for i in range(m):
  if lst.count(i) == n:
    a += 1
print(a)

# Fixed code:
lst = []
n,m = map(int, input().split())
for i in range(n):
  k = list(map(int, input().split()))
  lst = lst + k[1:]
a = 0
for i in range(1, m+1):
  if lst.count(i) == n:
    a += 1
print(a)
# Buggy code:
N, M = map(int, input().split())
check = [0] * M
for i in range(N):
    a = [int(i - 1) for i in input().split()]
    a = a[1:]
    for j in check:
        check[j] += 1
    

ans = 0
for i in check:
    if i == N:
        ans += 1
print(ans)

# Fixed code:
N, M = map(int, input().split())
check = [0] * M
for i in range(N):
    a = [int(i) - 1 for i in input().split()]
    a = a[1:]
    for j in a:
        check[j] += 1


ans = 0
for i in check:
    if i == N:
        ans += 1
print(ans)
# Buggy code:
# -*- coding: utf-8 -*-
#ABC116C
import sys

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
m=hoge[1]

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

hoge.sort()
#print(hoge)
x=[]
sum=0
for i in range(0,m-1):
	x.append(hoge[i+1]-hoge[i])
	sum+=hoge[i+1]-hoge[i]
x.sort(reverse=True)

#print(x)

sc=0
for i in range(0,n-1):
	sc+=x[i]

print(sum-sc)



# Fixed code:
# -*- coding: utf-8 -*-
#ABC116C
import sys

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
m=hoge[1]

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

hoge.sort()
#print(hoge)
x=[]
sum=0
for i in range(0,m-1):
	x.append(hoge[i+1]-hoge[i])
	sum+=hoge[i+1]-hoge[i]
x.sort(reverse=True)

#print(x)

sc=0
for i in range(0,min(n-1,len(x))):
	sc+=x[i]

print(sum-sc)
# Buggy code:
N,M = map(int,input().split())
x = sorted(list(map(int,input().split())))

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

distance = [0]*(M-1)
distance[0] = x[1]-x[0]
for i in range(0,M-1):
	distance[i] = x[i+1]-x[i]

distance_sorted = sorted(distance)
print(distance_sorted)
ans = 0
for i in range(0,M-N):
	ans += distance_sorted[i]

print(ans)




# Fixed code:
N,M = map(int,input().split())
x = sorted(list(map(int,input().split())))

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

distance = [0]*(M-1)
distance[0] = x[1]-x[0]
for i in range(0,M-1):
	distance[i] = x[i+1]-x[i]

distance_sorted = sorted(distance)
ans = 0
for i in range(0,M-N):
	ans += distance_sorted[i]

print(ans)
# Buggy code:
N, M = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
if M-1-N <= 0:
    pass
else:
    X.sort()
    dist = [X[i+1]-X[i] for i in range(M-1)]
    dist.sort()
    for i in range(M-1-N):
        ans += dist[i]
print(ans)

# Fixed code:
N, M = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
if (M-1)-(N-1) <= 0:
    pass
else:
    X.sort()
    dist = [X[i+1]-X[i] for i in range(M-1)]
    dist.sort()
    for i in range((M-1)-(N-1)):
        ans += dist[i]
print(ans)
# Buggy code:
n,m,*x = map(int,open(0).read().split())
x.sort()
a = sorted([x[i+1]-x[i] for i in range(m-1)],reverse=True)
ans = x[-1]-x[0]
for i in range(n-1):
  ans -= a[i]
print(ans)

# Fixed code:
n,m,*x = map(int,open(0).read().split())
x.sort()
if n >= m:
  print(0)
  exit()
a = sorted([x[i+1]-x[i] for i in range(m-1)],reverse=True)
ans = x[-1]-x[0]
for i in range(n-1):
  ans -= a[i]
print(ans)
# Buggy code:
n, m = map(int, input().split())
x = list(map(int, input().split()))
cnt = 0
if n > m:
    print(0)
    exit()
x.sort()
L = []
print(x)
for i in range(m - 1):
    print(i)
    L.append(x[i + 1] - x[i])
L.sort()
L.reverse()
print(L)
for i in range(n-1):
    L.pop(0)
print(sum(L))


# Fixed code:
n, m = map(int, input().split())
x = list(map(int, input().split()))
cnt = 0
if n > m:
    print(0)
    exit()
x.sort()
L = []
for i in range(m - 1):
    L.append(x[i + 1] - x[i])
L.sort()
L.reverse()
for i in range(n-1):
    L.pop(0)
print(sum(L))
# Buggy code:
n,m = map(int,input().split())
x = list(map(int, input().split()))
x_new = sorted(x)
intervals = [0]*(m-1)
for i in range(m-1):
  intervals[i] = abs(x_new[i+1] - x_new[i])
c = sorted(intervals, reverse=True)
s = 0
for j in range(n-1):
  s += c[j]
 
min = sum(intervals) - s
print(min)

# Fixed code:
n,m = map(int,input().split())
x = list(map(int, input().split()))
x_new = sorted(x)
intervals = [0]*(m-1)
for i in range(m-1):
  intervals[i] = abs(x_new[i+1] - x_new[i])
c = sorted(intervals, reverse=True)
s = 0
if n < m:
    for j in range(n-1):
        s += c[j]
    min = sum(intervals) - s
    print(min)
else:
    print(0)
# Buggy code:
n,m = map(int, input().split())
arr = list(map(int, input().split()))

if n >= m:
    print(0)

else:
    arr.sort()

    diff = [arr[i+1] - arr[i] for i in range(m-1)]
    diff.sort()

    print(sum(arr[0:m-n]))

# Fixed code:
n,m = map(int, input().split())
arr = list(map(int, input().split()))

if n >= m:
    print(0)

else:
    arr.sort()

    diff = [arr[i+1] - arr[i] for i in range(m-1)]
    diff.sort()

    print(sum(diff[0:m-n]))