Harryxun/stf_run huggingface dataset:
h, n = map(int, input().split())
a = input().split()
b = 0
def has_duplicates(seq):
    return len(seq) != len(set(seq))

for i in range(n):
    b += int(a[i])
if (h > b or has_duplicates(a) or len(a) > n ):
    print("No")
else:
    print("Yes")

### FIXED CODE ###

a, b = map(int, input().split())
c = a//b
if (a%b == 0):
    d = c
else :
    d = c+1
print(d)
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def median():
    l = sorted(l)
    if len(l) % 2 == 1:
        return l[len(l) // 2]
    else:
        return (l[len(l) // 2] + l[(len(l) // 2) - 1]) // 2


def main():
    N = int(input().strip())
    X_list = [int(i) for i in input().strip().split()]
    num = 0
    sorted_x = sorted(X_list)

    left = sorted_x[N // 2 - 1]
    right = sorted_x[N // 2 + 1]
    for x in X_list:
        idx = sorted_x.index(x)
        if idx >= N / 2:
            print(right)
        else:
            print(left)


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input().strip())
    X_list = [int(i) for i in input().strip().split()]
    sorted_x = sorted(X_list)

    left = sorted_x[(N // 2)-1]
    right = sorted_x[N // 2]
    for x in X_list:
        if x <= left:
            print(right)
        else:
            print(left)


if __name__ == "__main__":
    main()
S,T = input().split()
A,B = map(int,input().split())
U = input()

if U == S:
    A -= 1
elif U == T:
    B -= 1

print(A,B)

### FIXED CODE ###

S = input()

ans = ""
for i in range(len(S)):
    ans += "x"

print(ans)
from collections import deque

def isPa(w,k,p):
    counter = 0
    s = 0
    n = 1
    wlen = len(w)
    while(True):
        if( sum(w[s:s+n]) >= p):
            s = s+n
            n = 1
            counter += 1
        else:
            n += 1
            if( s+n == len(a)):
                counter += 1
                break
    if(counter > k):
        return False
    else:
        return True
    
def MaxInP(w,k,p):
    maxinp = 0
    tmp = 0
    d = deque(w)
    while(d):
        tmp += d.popleft();
        if(tmp > p):
            if(tmp > maxinp):
                maxinp = tmp
            tmp = 0
    return maxinp

n,k = [int(x) for x in input().split()]
w = []
for i in range(n):
    w.append(int(input()))
    
mean = int(sum(w)/k)
maxinp = MaxInP(w,k,mean)
l = range(mean,maxinp)

if k == 1:
    print(mean)
else:
    minP = mean
    maxP = maxinp
    while(True):
        m = int ((minP + maxP)/2)
        if ( isPa(w,k,m) ):
            maxP = m
        else:
            minP = m
        if (minP+1 == maxP):
            print(maxP)
            break

### FIXED CODE ###

from collections import deque

def isPa(w,k,p):
    tr = 0
    c = 0
    d = deque(w)
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

def MaxInP(w,k,p):
    maxinp = 0
    tmp = 0
    d = deque(w)
    while(d):
        tmp += d.popleft();
        if(tmp > p):
            if(tmp > maxinp):
                maxinp = tmp
            tmp = 0
    return maxinp

n,k = [int(x) for x in input().split()]
w = deque()
for i in range(n):
    w.append(int(input()))
    
mean = int(sum(w)/k)
maxinp = MaxInP(w,k,mean)

if k == 1:
    print(mean)
else:
    minP = mean
    maxP = maxinp
    while(True):
        m = int ((minP + maxP)/2)
        if ( isPa(w,k,m) ):
            maxP = m
        else:
            minP = m
        if (minP+1 == maxP or minP == maxP):
            print(maxP)
            break
def resolve():
    def dfs(a, b, k):
        nonlocal cnt
        seen[a][b] = True
        na = a + 1
        nb = b + 1
        if na <= N and seen[na][b] is False and k >= book_a[na]:
            k -= book_a[na]
            cnt = max(cnt, na + b)
            dfs(na, b, k)
        if nb <= M and seen[a][nb] is False and k >= book_b[nb]:
            k -= book_b[nb]
            cnt = max(cnt, a + nb)
            dfs(a, nb, k)

    N, M, k = map(int, input().split())
    book_a = [int(x) for x in input().split()]
    book_b = [int(x) for x in input().split()]
    book_a.insert(0, 0)
    book_b.insert(0, 0)
    cnt = 0
    seen = [[False] * (M + 1) for _ in range(N + 1)]
    dfs(0, 0, k)
    print(cnt)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

a = int(input())
print(a + a ** 2 + a ** 3)
a=[int(input()) for i in range(5)]
b=int(input())
if a[-1] - a[0] <= b:
  print("Yay!")
 else:
  print(":(")

### FIXED CODE ###

a=[int(input()) for i in range(5)]
b=int(input())
if a[-1] - a[0] <= b:
    print("Yay!")
else:
    print(":(")
import math

X = int(input())
for i in range(X,-1,0):
  sqrt_x = math.sqrt(i)
  if sqrt_x.is_integer():
    print(i)
    return

### FIXED CODE ###

x = int(input())
c = [1]
for i in range(2,32):
	num = 2
	while i**num<=x:
		c.append(i**num)
		num+=1
print(max(c))
n,m = map(int,input().split())
l = [int(x) for x in input().split()]

l.sort()

gap = [l[i]-l[i-1] for i in range(1,len(l))]

gap = gap.sort()

print(sum(gap[:-(m-1)]))

### FIXED CODE ###

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

if(n>=m):
  print('0')
  exit(0)
l.sort()
 
gap = [l[i+1]-l[i] for i in range(m-1)]
 
gap.sort()

print(sum(gap[:m-n]))
S = input()

a = S.find('A')

s1 = S[2:-1]
s_count = s1.count('C')

if a != 0:
  return False

if s_count != 1:
  return False

c = s1.find('C')

y = S[1:c-1]
z = S[c+1:]


if y.islower() and z.islower:
  print('AC')
else:
  print('WA')


### FIXED CODE ###

S = input()
     
a = S.find('A')
c = S.find('C')
     
s1 = S[2:-1]
s_count = s1.count('C')
   
y = S[1:c-1]
z = S[c+1:]

if c == 2:
	y = S[1]   

if a != 0:
	print('WA')

elif s_count != 1:
	print('WA')
     
else:
	if y.islower() and z.islower():
			print('AC')
	else:
		print('WA')
from scipy.sparse import*
N,M,P,*E=map(int,open(0).read().split())
D=csgraph.bellman_ford(csr_matrix(([P-c for c in E[5::3]],(E[3::3],E[4::3])),[N+1]*2),1,1)[N]
print(int([max(-D,0),-1][D>9e9]))

### FIXED CODE ###

(N,M,P),*E=[list(map(int,s.split()))for s in open(0).readlines()]
D=[0]*2+[-9e9]*N
def f():
    for _ in D:
        for (a,b,c)in E:D[b]=max(D[b],D[a]+c-P)
    return D[N]
s=f()
print([max(s,0),-1][s<f()])
n=int(input())
sp_lis=[]
for i in range(n):
    s,p=input().split()
    sp_lis.append([s,100-p,i+1])
for j in range(n):
    print(sorted(sp_lis[j][2]))

### FIXED CODE ###

n=int(input())
sp_lis=[]
for i in range(n):
    s,p=input().split()
    sp_lis.append([s,100-int(p),i+1])
sp_lis.sort()
for j in range(n):
    print(sp_lis[j][2])
n = int(input())
m = int(input())
l1 = []
for i in range (m):
    ai = int(input())
    l1.append(ai)
s = sum(l1)
r = (n - s)
if r >= 0:
    print(r)
else:
    print("-1")

### FIXED CODE ###

n, m = map(int, input().split())
ai = map(int, input().split())
li = map(int, list(ai))
s = sum(li)
r = (n - s)
if r >= 0:
    print(r)
else:
    print("-1")
N=int(input())
A=list(map(int,input().split()))
print(*A[::-2],*A[N%2::2])

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
if n%2:
    print(*l[::-2], end=' ')
    print(*l[1::2])
else:
    print(*l[::-2], end=' ')
    print(*l[0::2])
import numpy as np

N, W = list(map(int, input().split()))
v_list = list()
w_list = list()

for _ in range(N):
    v, w = list(map(int, input().split()))
    v_list.append(v)
    w_list.append(w)

sum_v_table = np.zeros([N+1, W+1], int)

for i in range(1, N+1):
    item = v_list[i-1], w_list[i-1]
    for w in range(1, W+1):
        if item[1] > w:
            sum_v_table[i, w] = sum_v_table[i-1, w]
            continue
        sum_v_table[i, w] = max(sum_v_table[i-1, w], sum_v_table[i-1, w-item[1]] + item[0])

max_sum_v = sum_v_table[N, W]

print(max_sum_v)

### FIXED CODE ###

N, W = list(map(int, input().split()))
v_list = list()
w_list = list()

for _ in range(N):
    v, w = list(map(int, input().split()))
    v_list.append(v)
    w_list.append(w)

sum_v_table = [[0]*(W+1) for _ in range(N+1)]

for i in range(1, N+1):
    item = v_list[i-1], w_list[i-1]
    for w in range(1, W+1):
        if item[1] > w:
            sum_v_table[i][w] = sum_v_table[i-1][w]
            continue
        sum_v_table[i][w] = max(sum_v_table[i-1][w], sum_v_table[i-1][w-item[1]] + item[0])

max_sum_v = sum_v_table[N][W]

print(max_sum_v)
a = list(input().split(" "))
b = list(input().split(" "))
oyu = []
for i in b:
    oyu[int(i):int(i)+int(a[1])] = [1] * int(a[1])
sum(oyu)

### FIXED CODE ###

a = list(input().split(" "))
b = list(input().split(" "))
t = 0
for k, i in enumerate(b):
    if k < len(b)-1:
        if int(i)+int(a[1]) > int(b[k+1]):
            t += int(b[k+1]) - int(b[k])
        else:
            t += int(a[1])
    else:
        t += int(a[1])
print(t)
A, B = input.split()
A = int(A)
B = int(B*100)
print(int(A*B/100))

### FIXED CODE ###

A, B = map(int,input().split())
print(A*B)
N,M = map(int,input().split())
flag = [False]*(10**5+10)
plu = 1
for i in range(1,N+1):
  if M==0:
    break
  if flag[i] or flag[i+plu]:
    continue
  else:
    flag[i]=True
    flag[i+plu]=True
    print(i,i+plu)
    plu+=1
    M-=1

### FIXED CODE ###

N,M = map(int,input().split())
start = 1
end = M
while True:
  if start>=end:
    break
  print(start,end)
  start+=1
  end-=1
  
start = M+1
end = 2*M+1
while True:
  if start>=end:
    break
  print(start,end)
  start = start+1
  end = end-1
s = input()
s = list(s.replace("BC", "D"))
pos = 0
str_len = len(s)
count = 0
seq_a = 0
seq_d = 0

while pos < str_len:
    if s[pos] == "A":
        while pos < str_len and s[pos] == "A":
            seq_a += 1
            pos += 1
        if s[pos] == "D":
            while pos < str_len and s[pos] == "D":
                seq_d += 1
                pos += 1
            count += seq_a * seq_d
            if pos < str_len and s[pos] != "A":
                seq_a = 0
            seq_d = 0
        else:
            pos += 1
            seq_a = 0
    else:
        pos += 1
        seq_a = 0

print(count)


### FIXED CODE ###

s = input()
pos = 0
str_len = len(s)
count = 0
seq_a = 0
seq_bc = 0

while pos < str_len:
    if s[pos] == "A":
        while pos < str_len and s[pos] == "A":
            seq_a += 1
            pos += 1
        if pos + 1 < str_len and s[pos] == "B" and s[pos+1] == "C":
            while pos < str_len and s[pos] == "B" and pos + 1 < str_len and s[pos+1] == "C":
                seq_bc += 1
                pos += 2
            count += seq_a * seq_bc
            if pos < str_len and s[pos] != "A":
                seq_a = 0
            seq_bc = 0
        else:
            pos += 1
            seq_a = 0
    else:
        pos += 1
        seq_a = 0

print(count)
[A, B, X] = list(map(int, input().split()))
keta = list(range(1, 17, 1))
retun_N = []
for d in keta:
  max_x = (X - B * d) / A
  max_x = int(max_x)
  max_ket = len(str(max_x))
  if max_ket == d:
    retun_N.append(max_x)
if len(retun_N) != 0:
  print(retun_N[-1])
else:
  print("0")

### FIXED CODE ###

S = str(input())
Week = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
for i, day in enumerate(Week):
  if day == S:
    until = 7 - i
    print(until)
  else:
    pass
N, X = map(lambda x: int(x), input().split())[:2]
L = map(lambda x: int(x), input().split())
D = 0
count = 0
for l in L:
  if D <= X:
      count += 1
  D += int(l)
print(count)

### FIXED CODE ###

N, X = map(int, input().split())
L = map(int, input().split())
D = 0
count = 1
for i, l in enumerate(L):
  D += l
  if D <= X:
      count += 1
print(count)
x = int(input())
y = [int(i) for i in input().split()]
y.sort(reverse=True)
a = 0
b = 0
for i in range(1, x+1):
    if(i%2) != 0:
        a += y[i-1]
    else:
        b += y[i-1]
print(a-b)

### FIXED CODE ###

print('Yes' if int(input())%500<=int(input()) else 'No')
N = int(input())
s = [list(input()) for _ in range(N)]
S = []
for i in range(N):
    S.append("".join(sorted(s[i])))
print(S)

cnt = 0
for i in range(N):
    cnt += S.count(S[i]) - 1
print(int(cnt / 2))


### FIXED CODE ###

A, B = map(int, input().split())
print(max(A+B, A-B, A*B))
N = int(input())
v = [int(_) for _ in input().split()]

import numpy as np

# v = [2, 2, 4]
# N = len(v)

A = np.zeros((N, N))
for i in range(N):
    # A[(i - 1) % N][i] = 1
    A[i][(i - 1) % N] = 1 / 2
    A[i][i] = 1 / 2

# print(A)
# print(np.linalg.inv(A))
ans = np.dot(np.linalg.inv(A), v)
ans = [int(x) for x in ans]
print(ans)

### FIXED CODE ###

import sys
import numpy as np
def input():
    return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    a = [int(e) for e in input().split()]

    x = [0 for _ in range(n)]
    x[0] = sum(a) - (sum(a[1:n:2]) * 2)
    for i in range(2, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    x[1] = sum(a) - (sum(a[2:n:2]) * 2)
    for i in range(3, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    print(*x)
main()
import heapq
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
if sum(a_list)<sum(b_list):
    print(-1)
else:
    diff_list = [a_list[i]-b_list[i] for i in range(n)]
    posi_heap=heapq.heapify([])
    cnt,diff_sum = 0,0
    for diff in diff_list:
        if diff<0:
            cnt+=1
            diff_sum+=diff
        elif diff>0:
            heapq.heappush(posi_heap,-1*diff)
    diff_sum*=(-1)
    i=0
    while diff_sum>0:
        diff_sum+=heapq.heappop(posi_heap)
        i+=1
    print(i+cnt)

### FIXED CODE ###

n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
if sum(a_list)<sum(b_list):
    print(-1)
else:
    diff_list = [a_list[i]-b_list[i] for i in range(n)]
    posi_list=[]
    cnt,diff_sum = 0,0
    for diff in diff_list:
        if diff<0:
            cnt+=1
            diff_sum+=diff
        elif diff>0:
            posi_list.append(diff)
    diff_sum*=(-1)
    posi_list.sort(reverse=True)
    i,S=0,0
    while S<diff_sum:
        S+=posi_list[i]
        i+=1
    print(i+cnt)
nums=[]
for i in range(6):
  nums.append(int(input()))
s = "Yay!"
for i in nums:
  if abs(i - nums[i:]):
    s = ":("
print(s)

  

### FIXED CODE ###

nums = []
for i in range(5):
    nums.append(int(input()))
k = int(input())
s = "Yay!"
for i in range(5):
    for m in range(5 - i):
        a = nums[i]
        if abs(a - nums[m]) > k:
             s = ":("
             break
print(s)
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A.sort()
BC.sort(key = lambda x:(-x[1]))

i_a = 0
i_bc = 0
while i_a < N:
    if i_bc == M:
        break
    for j in range(BC[i_bc][0]):
        if i_a + j > N:
            i_a = N
            continue
        if A[i_a + j] >= BC[i_bc][1]:
            i_a = N
        else:
            A[i_a + j] = BC[i_bc][1]
    i_a += BC[i_bc][0]
    i_bc += 1

print(sum(A))


### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A.sort()
BC.sort(key = lambda x:(-x[1]))

i_a = 0
i_bc = 0
while i_a < N:
    if i_bc == M:
        break
    for j in range(BC[i_bc][0]):
        if i_a + j >= N:
            i_a = N
            continue
        if A[i_a + j] >= BC[i_bc][1]:
            i_a = N
        else:
            A[i_a + j] = BC[i_bc][1]
    i_a += BC[i_bc][0]
    i_bc += 1

print(sum(A))
def get_quad(n, p):
    return 0
        
def sieve():
    n = 10000001
    p = [1] * n
    p[0] = p[1] = 0
    
    for i in range(int(n ** 0.5)):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p
import sys
f = sys.stdin

prime = sieve()
while True:
    ni = int(f.readline())
    if ni == 0:
        break

### FIXED CODE ###

def get_quad(n, p):
    if n < 19:
        return 13
    n = (n + 1) // 10 * 10 - 1
    for ni in range(n,0,-10):
        if p[ni] and p[ni - 2] and p[ni - 6] and p[ni - 8]:
            return ni
        
def sieve():
    n = 10000001
    p = [1] * n
    p[0] = p[1] = 0
    
    for i in range(int(n ** 0.5)):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p

import sys
f = sys.stdin

prime = sieve()
while True:
    n = f.readline().strip()
    if not n.isdigit():
        continue
    n = int(n)
    if n == 0:
        break
    print(get_quad(n, prime))
# 13-Structured_Program_II-Spreadsheet.py

# ??¨?¨????
# ??¨?¨??????????????°???????????????°???????????????????????????
# ??¨????????°r??¨?????°c???r ?? c ???????´????????????¨?????????????????§???
# ????????¨??????????¨?????????\????????°????????¨???????????????????????°?????????????????????????????????

# Input
# ???????????????r??¨c????????????????????§?????????????????????
# ?¶????r??????????????????c????????´??°????????????????????§?????????????????????

# Output
# (r+1) ?? (c+1) ?????°????????¨???????????????????????????
# ???????????£???????????´??°????????????????????§????????£??????????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??¨??????????¨????????????\??????????????????

# Constraints
# 1 ??? r, c ??? 100
# 0 ??? ????´? ??? 100
# Sample Input
# 4 5
# 1 1 3 4 5
# 2 2 2 4 5
# 3 3 0 1 1
# 2 3 4 4 6
# Sample Output
# 1 1 3 4 5 14
# 2 2 2 4 5 15
# 3 3 0 1 1 8
# 2 3 4 4 6 19
# 8 9 9 13 17 56

from numpy import * 
# import numpy as np

# r,c = map( int,input().split() )

# data = np.zeros((r,c))

# for i in range(r):
# 	data[i] = np.array( input().split() )

# data=data.astype("int")
# print("data",data)

# for i in range( r ):
# 	for j in range(c):
# 		print("{0} ".format(data[i][j]), end="")
# 	print( np.sum(data[i]) )

# for j in range(c):
# 	print("{0} ".format( np.sum(data, axis=0)[j] ), end="" )

# print( np.sum(data) )

### FIXED CODE ###

# 12-Structured_Program_II-How_many_ways.py

# ????????????????????°
# 1 ?????? n ?????§?????°?????????????????????????????§???????????°?????????????????????????¨???? x ??¨??????
# ????????????????????°????±???????????????°?????????????????????????????????
# ????????°???1 ?????? 5 ?????§?????°???????????????????????§????????????????¨???? 9 ??¨???????????????????????????

# 1 + 3 + 5 = 9
# 2 + 3 + 4 = 9
# ??????????????????????????????

# Input
# ?????°??????????????????????????\?????¨???????????????????????????
# ???????????????????????§??????????????§??????????????? n???x ??? 1 ???????????????????????????

# n???x ?????¨?????? 0 ?????¨?????\?????????????????¨????????????
# n ??? 3 ??\??? 100?????\?????¨????????????

# Output
# ????????????????????????????????????????????????????????°????????????????????????????????????

# Sample Input
# 5 9
# 0 0
# Sample Output
# 2

result = []
n=[]
x=[]

while 1:
	temp = input().split() 
	if temp[0]=="0" and temp[1]=="0":
		break;
	else:
		n.append( int( temp[0] ))
		x.append( int( temp[1] ))

for i in range( len(n) ):
	count =0
	for n1 in range(1,n[i]+1-2):
		for n2 in range(n1+1, n[i]+1-1):
			for n3 in range(n2+1, n[i]+1):
				sum = n1+n2+n3
				if sum == x[i]:
					count+=1
	result.append(count)

for i in range( len(result) ):
	print(result[i])
	# if i == len(result)-1:
	# 	print(result[i])
	# else:
	# 	print("{0} ".format(result[i]), end="")
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]

v = 0
last = [-1 for _ in range(26)]

for d in range(D):
    last[t[d]-1] = d
    v += s[d][t[d]-1]
    for j in range(26):
        v -= c[j]*(d-last[j])
    print(v)


### FIXED CODE ###

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

max_c = 0
index_c = 0

for i, C in enumerate(c):
    if C > max_c:
        index_c = i
        max_c = C

for d in range(D):
    print(index_c+1)
# -*- coding:utf-8 -*-
import math
import sys

def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False

def sieve(n):
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in range(0,n) if s[i] and i > 1]

n = int(input())
p = sieve(n)
arr = [0]*len(p)
n = math.factorial(n)

for i in range(len(p)):
    flag = 1
    k = p[i]
    while flag:
        if n%k == 0:
            k = k*p[i]
            arr[i] += 1
        else:
            flag = 0

x = 1
for i in range(len(arr)):
    if arr[i] != 0:
        x *= (arr[i]+1)
if ( n = 6):
    print(4)
else:
    print(x%(10**9+7))

### FIXED CODE ###

n = int(input())

arr = [0] * (n+1)

for i in range(1,n+1):
    x = []
    while i % 2 == 0:
        x.append(2)
        i = i // 2
    f = 3
    while f * f <= i:
        if i % f == 0:
            x.append(f)
            i = i // f
        else:
            f += 2
    if i != 1:
        x.append(i)

    for k in range(len(x)):
        arr[x[k]] += 1

ans = 1
for i in range(len(arr)):
    ans *= (arr[i] + 1)
print(ans % (10**9 + 7))
import functools  # Python3 
N,M = map(int,input().split())
x, y, z = [0] * N, [0] * N, [0] * N
for i in range(N):
	x[i], y[i], z[i] = map(int,input().split())

ppp = sorted([ x[i]+y[i]+z[i] for i in range(N)])[-M:]
pmp = sorted([ x[i]-y[i]+z[i] for i in range(N)])[-M:]
ppm = sorted([ x[i]+y[i]-z[i] for i in range(N)])[-M:]
pmm = sorted([ x[i]-y[i]-z[i] for i in range(N)])[-M:]
mpp = sorted([-x[i]+y[i]+z[i] for i in range(N)])[-M:]
mpm = sorted([-x[i]+y[i]-z[i] for i in range(N)])[-M:]
mmp = sorted([-x[i]-y[i]+z[i] for i in range(N)])[-M:]
mmm = sorted([-x[i]-y[i]-z[i] for i in range(N)])[-M:]

MAX = 0
for lis in [ppp,pmp,ppm,pmm,mpp,mpm,mmp,mmm]:
	cur = functools.reduce(lambda x,y: x+y,lis)
		MAX = cur
print(MAX)




### FIXED CODE ###

import functools  # Python3 
N,M = map(int,input().split())
x, y, z = [0] * N, [0] * N, [0] * N
for i in range(N):
	x[i], y[i], z[i] = map(int,input().split())

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

ppp = functools.reduce(lambda x,y: x+y,sorted([ x[i]+y[i]+z[i] for i in range(N)])[-M:])
pmp = functools.reduce(lambda x,y: x+y,sorted([ x[i]-y[i]+z[i] for i in range(N)])[-M:])
ppm = functools.reduce(lambda x,y: x+y,sorted([ x[i]+y[i]-z[i] for i in range(N)])[-M:])
pmm = functools.reduce(lambda x,y: x+y,sorted([ x[i]-y[i]-z[i] for i in range(N)])[-M:])
mpp = functools.reduce(lambda x,y: x+y,sorted([-x[i]+y[i]+z[i] for i in range(N)])[-M:])
mpm = functools.reduce(lambda x,y: x+y,sorted([-x[i]+y[i]-z[i] for i in range(N)])[-M:])
mmp = functools.reduce(lambda x,y: x+y,sorted([-x[i]-y[i]+z[i] for i in range(N)])[-M:])
mmm = functools.reduce(lambda x,y: x+y,sorted([-x[i]-y[i]-z[i] for i in range(N)])[-M:])

MAX = 0
for lis in [ppp,pmp,ppm,pmm,mpp,mpm,mmp,mmm]:
	if lis  > MAX:
		MAX = lis
print(MAX)
a = input()
print(a/3)

### FIXED CODE ###

a = int(input())
b = int(a / 3)
print(b)
# coding:utf-8

import math

n, y = map(int, input().split())

dist_list = [abs(x-y) for x in map(int, input().split())]

if n == 1:
    d = dist_list[0]
elif n >= 2:
    for i in reversed(range(n-1)):
        if i == n-2:
            d = math.gcd(dist_list[i], dist_list[i-1])
        else:
            d = math.gcd(dist_list[i-1], d)    

print(d)

### FIXED CODE ###

# coding:utf-8

from fractions import gcd 

n, y = map(int, input().split())

dist_list = [abs(x-y) for x in map(int, input().split())]

if n == 1:
    d = dist_list[0]
else:
    d = gcd(dist_list[1], dist_list[0])
    for i in range(n-2):
        d = gcd(d, dist_list[i+1])

print(d)
s = input()
print(s[0] + str(len(s) - 2) + s[-1]))

### FIXED CODE ###

s = input()
print(s[0] + str(len(s) - 2) + s[-1])
import sympy
n = int(input())
cnt = 0
for i in range(1, n+1):
  l = sympy.divisors(i)
  if (i % 2 != 0) and (len(l) == 8):
    cnt += 1
print(cnt)

### FIXED CODE ###

n = int(input())
cnt = 0
def sympy(num):
  l = []
  for i in range(1, num+1):
    for j in range(1, num+1):
      if (i % 2 != 0) and (i*j == num):
        l.append(i)
  return l
for i in range(1, n+1):
  l = sympy(i)
  if (i % 2 != 0) and (len(l) == 8):
    cnt += 1
print(cnt)