Harryxun/stf_run huggingface dataset:
import heapq
def E():
    X, Y, A, B, C = map(int, input().split())
    reds = []
    heapq.heapify(reds)
    for n in input().split():
        heapq.heappush(reds, int(n))
    greens = []
    heapq.heapify(greens)
    for n in input().split():
        heapq.heappush(greens, int(n))
    colorless = []
    heapq.heapify(colorless)
    for n in input().split():
        heapq.heappush(colorless, -int(n))
    
    redx = heapq.nlargest(X, reds)
    greeny = heapq.nlargest(Y, greens)
    colorless_val = 0
    while True:
        if not colorless:
            break
        cur = abs(heapq.heappop(colorless))
        if cur > redx[-1]:
            if redx[-1] > greeny[-1]:
                greeny.pop()
            else:
                redx.pop()
            colorless_val += cur
        elif cur > greeny[-1]:
            if greeny[-1] > redx[-1]:
                redx.pop()
            else:
                greeny.pop()
            colorless_val += cur
        else:
            break
    print(sum(redx)+sum(greeny)+colorless_val)

E()

### FIXED CODE ###

import heapq
def E():
    X, Y, A, B, C = map(int, input().split())
    reds = []
    heapq.heapify(reds)
    for n in input().split():
        heapq.heappush(reds, int(n))
    greens = []
    heapq.heapify(greens)
    for n in input().split():
        heapq.heappush(greens, int(n))
    colorless = []
    heapq.heapify(colorless)
    for n in input().split():
        heapq.heappush(colorless, -int(n))
    
    redx = heapq.nlargest(X, reds)
    greeny = heapq.nlargest(Y, greens)
    colorless_val = 0
    while True:
        if not colorless:
            break
        cur = abs(heapq.heappop(colorless))
        if redx and cur > redx[-1]:
            if greeny and redx[-1] > greeny[-1]:
                greeny.pop()
            else:
                redx.pop()
            colorless_val += cur
        elif greeny and cur > greeny[-1]:
            if redx and greeny[-1] > redx[-1]:
                redx.pop()
            else:
                greeny.pop()
            colorless_val += cur
        else:
            break
    print(sum(redx)+sum(greeny)+colorless_val)

E()
a,b=map(int,input().sprit())
if(a+b==3):
  print("3")
elif(a+b==4):
  print("2")
else:
  print("1")


### FIXED CODE ###

a=int(input())
b=int(input())
if(a+b==3):
  print("3")
elif(a+b==4):
  print("2")
else:
  print("1")
import numpy as np

def main():
  n=int(input())
  s=np.array([ord(i) for i in input()])
  dp=np.zeros((n,n),dtype=int)
  for i in range(n-1):
    for j in range(i+1,n):
      if s[i]==s[j]:
        dp[i,j]=min(j-i, dp[i-1,j-1]+1)
  print(np.amax(dp))
        

if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  n=int(input())
  s=input()
  dp=[[0]*(n+1) for i in range(n+1)]
  for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
      if s[i]==s[j]:
        dp[i][j]=dp[i+1][j+1]+1
  #for i in dp:
  #  print(i)
  
  ans=0
  for i in range(n-1):
    for j in range(i+1,n):
      ans=max(ans,min(j-i,dp[i][j]))
  print(ans)      
        

if __name__=='__main__':
  main()
import math
x1,y1,x2,y2 = map(int,input().split())
D = math.sqrt((x2-x1)**2 + (y2-y1)**2)
print(D)

### FIXED CODE ###

import math
 
x1,y1,x2,y2=list(map(float,input().split()))
 
print(math.sqrt((x2-x1)**2+(y2-y1)**2))
x,y=map(int,input().split())

if (x+y)%3!=0:print(0)
else:
    n,m=y//3,y//3
    p = 10**9+7
    N = 2+10**6+10  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用
    for i in range(2, N+1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    print(cmb(n+m,n,p))

### FIXED CODE ###

def cmb(n, r, p):
    if r<0 or n<r:
        return 0
    r=min(r, n-r)
    return fact[n]*factinv[r]*factinv[n-r]%p

mod=10**9+7
MAXN=2*10**6+10
fact=[1, 1]
factinv=[1, 1]
inv=[0, 1]

for i in range(2, MAXN+1):
    fact.append((fact[-1]*i)%mod)
    inv.append(-inv[mod%i]*(mod//i)%mod)
    factinv.append((factinv[-1]*inv[-1])%mod)

x,y=map(int, input().split())
res=0
if (x+y)%3==0:
    m=(2*x-y)//3
    n=(2*y-x)//3
    res=cmb(m+n,m,mod)
print(res)
N,K = map(int,input().split())
h= list(map(int,input().split()))
count=0

for i in range(N)
    if h[i]>=K
        count+=1
print(count)

### FIXED CODE ###

N,K = map(int,input().split())
h= list(map(int,input().split()))
count=0

for i in range(N):
    if h[i]>=K:
        count+=1
print(count)
s = input()
w = int(input())

ans = ''
for i in range(0, len(s), w):
    ans += s[i]
print(ans)


### FIXED CODE ###

s = input()

if len(s) == 2:
    print(s)
else:
    print(s[::-1])
#43b
s = list(input())
ans =''

for i in s:
    if i =='0' or i =='1':
        a+=i
    else:
        #最後の一つをスライス
        a = a[:-1]
print(a)

### FIXED CODE ###

#43b
s = list(input())
a =''

for i in s:
    if i =='0' or i =='1':
        a = a+i
    else:
        #最後の一つをスライス
        a = a[:-1]
print(a)
n, k = map(int, input().strip().split())

print(min(n % k, k % n))


### FIXED CODE ###

n, k = map(int, input().strip().split())

min_n = 1000000000000000000000000000
for i in range(1000):
    if n > k:
        n %= k
    n = abs(n - k)
    min_n = min(min_n, n)

print(min_n)
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A)
B = sorted(B)
C = sorted(C)

# for this we will use binary search.
import bisect as bis

for i in range (0, N):
	BSC[i] = N-bis.bisect_right(C, B[i])

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A)
B = sorted(B)
C = sorted(C)

# for this we will use binary search.
import bisect as bis

BSC = [0]*N
ASB = [0]*N

for i in range (0, N):
	BSC[i] = N-bis.bisect_right(C, B[i])

for i in range (0, N):
	ASB[i] = bis.bisect_right(B, A[i])
    
for i in range (1, N):
	BSC[N-1-i] += BSC[N-i]

count = 0
for i in range (0, N):
	if ASB[i] ==N:
		continue
	else:
		count+=BSC[ASB[i]]

print(count)
S=input()

result = []
for c in list(S):
   if c == 'B' and len(result)>0:
     result.pop(-1)
   elif c== 'B':
     result = ""
   else :
     result.append(c)

print("".join(result))


### FIXED CODE ###

S=input()

result = []
for c in list(S):
   if c == 'B' and len(result)>0:
     result.pop(-1)
   elif c== 'B':
     result = []
   else :
     result.append(c)

print("".join(result))
from fractions import Fraction
N, = map(int, input().split())
d = dict()
X = []
cc = 0
for _ in range(N):
    a, b = map(int, input().split())
    if a == 0 and b==0:
        cc += 1
        continue
    f = Fraction(a, b)
    if f not in d:
        d[f] = 0
    d[f] += 1
    X.append((a, b))

vs = dict()
cs = []
for a, b in X:
    f1 = Fraction(a, b)
    f2 = Fraction(b, -a)
    if f2 not in d:
        d[f2] = 0
#        cs.append(d[f1])
#        continue
    if f1 in vs or f2 in vs:
        continue
    vs[f1] = (d[f1], d[f2])
mod = 10**9+7

tmp = []
r = 1
#print(pow(2, sum(cs),mod))
r2 = 1
for k in vs:
    a, b = vs[k]
#    print((pow(2, a, mod), pow(2, b, mod)))
    r = r * (pow(2, a, mod) + pow(2, b, mod)-1) % mod
#    r2 = r2 * (pow(2, a-1, mod) + pow(2, b-1, mod)+2) % mod

print(r-1+cc)
#print(len(vs))
#print(r2)
#print(r2*pow(2, sum(cs),mod)+1)


### FIXED CODE ###

from math import gcd
def to_standard_form(a, b):
    if a == 0:
        return (0, 1)
    g = gcd(a, b)
    a //= g
    b //= g
    if a < 0:
        return (-a, -b)
    return (a, b)

N, = map(int, input().split())
d = dict()
X = []
cc = 0
for _ in range(N):
    a, b = map(int, input().split())
    if a == 0 and b==0:
        cc += 1
        continue
    f = to_standard_form(a, b)
    if f not in d:
        d[f] = 0
    d[f] += 1
    X.append(f)

vs = dict()
for a, b in X:
    f1 = (a, b)
    f2 = to_standard_form(-b, a)
    if f2 not in d:
        d[f2] = 0
    if f1 in vs or f2 in vs:
        continue
    vs[f1] = (d[f1], d[f2])

mod = 10**9+7
r = 1
for k in vs:
    a, b = vs[k]
    r = r * (pow(2, a, mod) + pow(2, b, mod)-1) % mod
print((r-1+cc)%mod)
n = input() 
v = list(map(int, input().split())) 
c = list(map(int, input().split())) 
otoku = []

for i in range(n):
  otoku.append(v[i] - c[i])

res = 0
for j in range(n):
  if otoku[j] > 0:
    res += otoku[j]
    
print(res)

### FIXED CODE ###

n = int(input(), 10) 
v = list(map(int, input().split())) 
c = list(map(int, input().split())) 
otoku = []
 
for i in range(n):
  otoku.append(v[i] - c[i])
 
res = 0
for j in range(n):
  if otoku[j] > 0:
    res += otoku[j]
    
print(res)
import sys

argv = sys.argv
x = int(argv[1])
y = int(args[2])
print x*y,
print 2*x+2*y,

### FIXED CODE ###

num = map(int, raw_input().split())
print num[0]*num[1], 2*(num[0] + num[1])
stations = input()
s = stations.split()

if (s[0] == s[1] == s[2]):
    print('No')
elif (s[0] != s[1] != s[2]):
    print('No')
else:
    print('Yes')
     

### FIXED CODE ###

s = input()

if (s[0] == s[2]) and (s[0] != s[1]):
    print('Yes')
elif (s[1] == s[2]) and (s[0] != s[2]):
    print('Yes')
elif (s[0] == s[1]) and (s[0] != s[2]):
    print('Yes')
else:
    print('No')
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n, m = [int(i) for i in input().split()]
print(combinations_count(n,2)+combinations_count(m,2))

### FIXED CODE ###

import math

def combinations_count(n, r):
    if n<r:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n, m = [int(i) for i in input().split()]
print(combinations_count(n,2)+combinations_count(m,2))
N,W = map(int,input().split())

items = [tuple(map(int,input().split())) for i in range(N)]

from collections import defaultdict
dp = defaultdict(int) # w -> v
dp[0] = 0

for w,v in items:
  for tw,tv in list(dp.items()):
    if tw+w <= W:
      dp[tw+w] = max(tv+v, dp[tw+w])

print(max(dp.values()))

### FIXED CODE ###

f=lambda:map(int,input().split())
N,T=f()
q=list(f())
print(T+sum(min(q[i+1]-q[i],T) for i in range(N-1)))
import numpy as np

while True:
    try:
        l = list(map(int, input().split()))
        S = l[0]
        p = np.zeros(S)
        M = l[1]
        i = 0
        N = M

        while True:
            if N == M and i != 0:
                ans = i % S - 1
                if ans < 0:
                    ans = S + ans
                print(ans)
                break

            if N == 0:
                N = p[i % S]
                p[i % S] = 0
                i += 1

            else:
                N -= 1
                p[i % S] += 1
                i += 1

    except:
        break;


### FIXED CODE ###

while True:
    l = list(map(int, input().split()))
    S = l[0]
    p = [0 for i in range(S)]
    M = l[1]
    i = 0
    N = M
    if M == 0 and S == 0:
        break

    while True:
        if p[i] == M:
            print(i)
            break

        if N == 0:
            N = p[i]
            p[i] = 0
            i += 1
            i %= S

        else:
            N -= 1
            p[i] += 1
            i += 1
            i %= S
N = list(map(int, input().split()))
print((N/3)**3)

### FIXED CODE ###

N = int(input())
print((N/3)**3)
N = int(input())
uvw = []
for i in range(N-1):
    u,v,w = map(int,input().split())
    uvw.append([u,v,w])

uvw = np.array(uvw)
uvw = uvw[np.argsort(uvw[:,0])]

# 初期の木の根とランクを設定（初めはみんな根なのでpar[i]=i）
par = [0 for i in range(N)]
dist = [0 for i in range(N)]
rank = [0 for i in range(N)]
for n in range(N):
    par[n] = n

# 木の根を探索する関数
# 根が自身でない場合は再帰的にたどる
# x,yが同じ集合に属するかの判定はroot(par[x])==root(par[y])か否か
def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

# 繋げる操作を指定された時に動かす関数
def unite(u,v,w):
    x = par[u]
    y = par[v]
    # rankが高い方に低い方を繋げる
    if rank[x] < rank[y]:
        par[x] = y
        dist[u] += w+dist[v]
    else:
        par[y] = x
        dist[v] += w+dist[u]
        # 同じだった場合xのランクが一つ増える扱いになる
        if rank[x] == rank[y]:
            rank[x] += 1

# 実際にクエリを受け取って動かす
for i in range(N-1):
    u,v,w = uvw[i,0],uvw[i,1],uvw[i,2]
    u = u-1
    v = v-1
    unite(u,v,w)

for i in range(N):
    if dist[i] % 2 == 0:
        print(0)
    else:
        print(1)


### FIXED CODE ###

N = int(input())
connect_list = [[] for i in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    u -= 1
    v -= 1 
    connect_list[u].append([v,w])
    connect_list[v].append([u,w])

d = [0]+[-1 for i in range(N-1)]
stack = []
stack.append(0)
while len(stack) != 0:
    s = stack.pop()
    for x,w in connect_list[s]:
        if d[x] == -1:
            d[x] = d[s] + w
            stack.append(x)

for i in range(N):
    print(d[i]%2)
import sys

def main():
    N = int(input())
    D = map(lambda i: int(i), input().split(' '))
    answer = 1
    ary = [0] * (N - 1)

    for d in D:
        ary[d] = ary[d] + 1

    # 続いてなかったらNG
    zero = False
    for i in range(len(ary)):
        if ary[i] != 0 and zero is True:
            print(0)
            sys.exit()
        if ary[i] == 0 and zero is False:
            zero = True
            
    for i in range(len(ary)):
        if i == 0:
            if ary[i] != 1:
                print(0)
                sys.exit()
        else:
            answer = (answer * (ary[i - 1] ** ary[i])) % 998244353
    print(answer)

main()


### FIXED CODE ###

import sys

def main():
    N = int(input())
    D = list(map(lambda i: int(i), input().split(' ')))
    # N = 100000
    # D = [0]
    # for i in range(1, N):
    #     D.append(i)

    if D[0] != 0:
        print(0)
        sys.exit()

    ary = [0] * N
    for d in D:
        ary[d] = ary[d] + 1

    # 続いてなかったらNG
    zero = False
    for i in range(len(ary)):
        if ary[i] != 0 and zero is True:
            print(0)
            sys.exit()
        if ary[i] == 0 and zero is False:
            zero = True

    # 距離0は頂点1だけ
    if ary[0] != 1:
        print(0)
        sys.exit()

    answer = 1
    for i in range(1, len(ary)):
        for j in range(ary[i]):
            answer = (answer * ary[i - 1]) % 998244353
    print(answer)

main()
n, m = [int(x) for x in input().split(" ")]

c = []
d = []
for i in range(n):
	a = [int(x) for x in input().split(" ")]
	if i == 0:
        c = a[- a[0] + 1:]
    else:
        b = a[- a[0]:]
        for ce in c:
            if ce in b:
                 d.append(ce)
        c = d
        d = []

print(len(c))
        

### FIXED CODE ###

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

c = []
d = []
for i in range(n):
    a = [int(x) for x in input().split(" ")]
    if i == 0:
        c = a[- a[0]:]
    else:
        b = a[- a[0]:]
        for ce in c:
            if ce in b:
                 d.append(ce)
        c = d
        d = []

print(len(c))
start = time.time()
K, S = map(int, input().split())

K+=1

count=0
for i in range(K):
    for j in range(0, K-i):
        tmp = S - (i + j)
        if tmp>=0 and tmp<=K:
            count+=1
#             print(i,j,tmp)

print(count)

end = time.time()
print(end-start)

### FIXED CODE ###

# N^2
K, S = map(int, input().split())

K+=1

count=0
for i in range(K):
    for j in range(0, K):
        tmp = S - (i + j)
        if tmp>=0 and tmp<K:
            count+=1
#             print(i,j,tmp)

print(count)
#include <bits/stdc++.h>

using namespace std;

bool check_STR(string cad, int n)
{
    for (int i = 0, j = n - 1; i < n/2; i++, j--)
        if (cad[i] != cad[j])
            return false;
    return true;
}
int main()
{
    string cad, cad_S, cad_E; cin >> cad;
    int n = cad.size();
    cad_S = cad.substr(0, (n - 1)/ 2);
    cad_E = cad.substr((n+3)/2 - 1);
    if (check_STR(cad, n) && check_STR(cad_S, cad_S.size()) && check_STR(cad_E, cad_E.size()))
        puts("Yes");
    else
        puts("No");
 
}

### FIXED CODE ###

def check(s):
    i, j = 0, len(s) - 1
    while i < j:
        if s[i] != s[j]:
            return False
        i += 1; j -= 1
    return True
s = input()
n = len(s)
n_S = s[0:(n - 1)//2]
n_E = s[(n+3)//2 - 1::]

if check(s) and check(n_S) and check(n_E):
    print('Yes')
else:
    print('No')
N = int(input())
W = [int(i) for i in input().split()]
calc(N, W)
def calc(n, w):
    min_sub = 100000
    N = n
    num = w
    for i in range(1,N):
        S1 = num[:i]
        S2 = num[i:]
        sub = abs(sum(S1)-sum(S2))
        if min_sub > sub:
            min_sub = sub
    print(min_sub)

### FIXED CODE ###

N = int(input())
W = [int(i) for i in input().split()]
a = []
for i in range(N - 1):
    a.append(abs(sum(W[:i+1]) - sum(W[i+1:])))

print(min(a))
import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.array(a)
a = a[a%2==0]

for i in range(n):
    if a[i]%3 != 0 and a[i]%5 != 0:
        return print("APPROVED")

return print("DENIED")

### FIXED CODE ###

import numpy as np
import sys

n = int(input())
a = list(map(int, input().split()))
a = np.array(a)
a = a[a%2==0]

for i, j  in enumerate(a):
    if j%3 != 0 and j%5 != 0:
        print("DENIED")
        sys.exit()

print("APPROVED")
a, b = map(int, input().split())
c = 6 - a- b
print(c)

### FIXED CODE ###

A = int(input())
B = int(input())
 
print(6-A-B)
h, w, m = map(int, input().split())
boms = [[] for i in range(m)]
Hs = [0] * m
Ws = [0] * m
for i in range(m):
  _h, _w = map(int, input().split())
  boms[i] = [_h-1, _w-1]
  Hs[_h - 1] += 1
  Ws[_w - 1] += 1
Hmax = max(Hs)
Hcount = Hs.count(Hmax)
Wmax = max(Ws)
Wcount = Ws.count(Wmax)
Hindexs = [0] * Hcount
Windexs = [0] * Wcount
hcount = 0
wcount = 0
for i in range(m):
  if Hs[i] == Hmax:
    Hindexs[hcount] = i
    hcount += 1
  if Ws[i] == Wmax:
    Windexs[wcount] = i
    wcount += 1
count = 0
for bom in boms:
  if (bom[0] in Hindexs) and (bom[1] in Windexs):
    count += 1
if count == len(Hindexs) * len(Windexs):
  print(Hmax + Wmax - 1)
else:
  print(Hmax + Wmax)

### FIXED CODE ###

h, w, m = map(int, input().split())
boms = set()
Hs = [0] * h
Ws = [0] * w
for i in range(m):
  _h, _w = map(int, input().split())
  boms.add((_h - 1, _w - 1))
  Hs[_h - 1] += 1
  Ws[_w - 1] += 1
Hmax = max(Hs)
Hcount = Hs.count(Hmax)
Wmax = max(Ws)
Wcount = Ws.count(Wmax)
Hindexs = [0] * Hcount
Windexs = [0] * Wcount
hcount = 0
wcount = 0
for i in range(h):
  if Hs[i] == Hmax:
    Hindexs[hcount] = i
    hcount += 1
for i in range(w):
  if Ws[i] == Wmax:
    Windexs[wcount] = i
    wcount += 1
if m < len(Hindexs) * len(Windexs):
  print(Hmax + Wmax)
  exit()
for hindex in Hindexs:
  for windex in Windexs:
    if (hindex,windex) not in boms: 
      print(Hmax + Wmax)
      exit()
print(Hmax + Wmax -1)
# (d1+d2)/2 == n1, (d2+d3)/2 == n2... が矛盾なくなるようにする
# にぶたんを使う

n = int(input())
dum = list(map(int, input().split()))
count = 0
l, r = 0, (10 ** 9 + 1000000) // 2

while True:
    mid = (l + r) // 2
    # print(l, r, mid)
    rain = [0 for _ in range(n)]
    rain[0] += mid * 2
    for i in range(1, n):
        next_amount = (dum[i - 1] - (rain[i - 1] // 2)) * 2
        if next_amount < 0:
            break
        rain[i] += next_amount
    # print(rain)

    if dum[-1] == (rain[-1] + rain[0]) // 2:
        rain = list(map(str, rain))
        print(" ".join(rain))
        exit()
    if (rain[0] + rain[-1]) // 2 < dum[-1]:
        # 最初に決めたやつが小さすぎた
        # print("{} は小さすぎた".format(rain[0]))
        l = mid + 1
    else:
        # 最初に決めたやつが大きすぎた
        # print("{} は大きすぎた".format(rain[0]))
        r = mid

    # セーフティネット 必要ないけど
    if count > 50:
        t = 5 / 0
        break
    count += 1

"""
7
110 50 53 50 11 36 88

11
38 7 15 15 9 31 23 1 5 55 81
"""


### FIXED CODE ###

# (d1+d2)/2 == n1, (d2+d3)/2 == n2... が矛盾なくなるようにする
# にぶたんを使う
# なんかしらんけど3問駄目だな...

n = int(input())
dum = list(map(int, input().split()))
count = 0
l, r = 0, (10 ** 10) // 2

while l < r:
    mid = (l + r) // 2
    # print(l, r, mid)
    rain = [0 for _ in range(n)]
    rain[0] += mid * 2
    for i in range(1, n):
        next_amount = (dum[i - 1] - (rain[i - 1] // 2)) * 2
        rain[i] += next_amount
    # print(rain)

    if dum[-1] == (rain[-1] + rain[0]) // 2:
        rain = list(map(str, rain))
        print(" ".join(rain))
        exit()
    if (rain[0] + rain[-1]) // 2 < dum[-1]:
        # 最初に決めたやつが小さすぎた
        # print("{} は小さすぎた".format(rain[0]))
        l = mid + 1
    else:
        # 最初に決めたやつが大きすぎた
        # print("{} は大きすぎた".format(rain[0]))
        r = mid

    # セーフティネット 必要ないけど
    if count > 50:
        t = 5 / 0
        break
    count += 1

"""
7
110 50 53 50 11 36 88

11
38 7 15 15 9 31 23 1 5 55 81
"""
nandm = input().split()
numlist = input().split()
N = int(nandm[0])
M = int(nandm[1])
if N >= M:
    print(0)
else:
    intlist = [int(num) for num in numlist]
    intlist.sort()
    subtract = [intlist[i + 1] - intlist[i] for i in range(len(intlist) - 1)]
    subtract.sort()
    print(sum(subtract[:(M - N)]))

### FIXED CODE ###

lis = input().split()
print(int(lis[0])/int(lis[1]))
p=print
b=0
for e in iter(input,'0 0'):
 if b:p()
 b=f=1;s,t=map(int,e.split())
 for y in range(s,t+1):
  if(y%4==0)*(y%100)or y%400==0:p(y);f=0
 if u:p('NA')


### FIXED CODE ###

p=print
b=1
for e in iter(input,'0 0'):
 b or p()
 b=f=0;s,t=map(int,e.split())
 for y in range(s,t+1):
  if(y%4==0)*(y%100)or y%400==0:p(y);f=1
 f or p('NA')
import math
N = int(input())
W = list(int(input()))
w_sort = sorted(W)
if N%2 == 0:
    tmp = N/2 + 1
    s1 = sum(w_sort[:tmp])
    s2 = sum(w_sort[tmp:])
    print(math.floor(abs(s1-s2)))
else:
    tmp = N//2
    s1 = sum(w_sort[:tmp])
    s2 = sum(w_sort[tmp:])
    print(math.floor(abs(s1-s2)))


### FIXED CODE ###

import math
N = int(input())
W = list(map(int, input().split()))
allw = sum(W)
tmp = []
for j in range(N):
    tmp.append(abs(sum(W[:j])-sum(W[j:])))
print(min(tmp))
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

s = input()


def search(s):
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            return i+1, i+2
        if s[i] == s[i+2]:
            return i+1, i+3
    return -1, -1


if __name__ == "__main__":
    a, b = search(s)
    if a == -1:
        print("-1 -1")
    else:
        print(a, end="")
        print(' ', end="")
        print(b, end="")


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

s = input()


def search(s):
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            return i+1, i+2
        if len(s) > i+2 and s[i] == s[i+2]:
            return i+1, i+3
    return -1, -1


if __name__ == "__main__":
    a, b = search(s)
    if a == -1:
        print("-1 -1")
    else:
        print(a, end="")
        print(' ', end="")
        print(b, end="")
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7
N,Q = I()
graph = [-1]*N
roots = [[] for _ in range(N)]
for i in range(N-1):
    a,b = I()
    graph[b-1] = a-1
def dfs(a):
    if a == 0:
        return
    b = graph[a]
    roots[b].append(i)
    dfs(b)
for i in range(N):
    dfs(i)
counter = [0]*N
for i in range(Q):
  p,x = I()
  r = roots[p-1]
  counter[p-1] += x
  if r:
      for j in r:
          counter[j] += x
print(c*)

### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7
N,Q = I()
edge = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = I()
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
ans = [0]*N
for _ in range(Q):
    p,x = I()
    ans[p-1] += x
que = [0]
visited = {0}
while que:
    p = []
    for i in que:
        for j in edge[i]:
            if j in visited:
                continue
            visited.add(j)
            ans[j] += ans[i]
            p.append(j)
    que = p
print(*ans)