Harryxun/stf_run huggingface dataset:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

sys.setrecursionlimit(50000)

def yn(b):
    print("Yes" if b==1 else "No")
    return

class check():
    def __init__(self,n,q):
        readline=sys.stdin.readline
        self.tree=[[] for i in range(n)]
        self.ans=[0]*n
        for i in range(n-1):
            a,b=map(int, readline().rstrip().split())
            a-=1
            b-=1
            self.tree[a].append(b)
            self.tree[b].append(a)
        for i in range(q):
            p,x=map(int, readline().rstrip().split())
            p-=1
            self.ans[p]+=x
    def do(self,root,next):
        if root >= 0:
            self.ans[next]+=self.ans[root]
        for a in self.tree[next]:
            if a==root:
                continue
            self.do(next,a)
    def answer(self):
        print(" ".join(map(str,self.ans)))






def resolve():
    readline=sys.stdin.readline

    n,q=map(int, readline().rstrip().split())
    c=check(n,q)
    c.do(-1,0)
    c.answer()

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

### FIXED CODE ###

### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

sys.setrecursionlimit(50000000)

class check():
    def __init__(self,n,q):
        readline=sys.stdin.readline
        self.tree=[[] for i in range(n)]
        self.ans=[0]*n
        for i in range(n-1):
            a,b=map(int, readline().rstrip().split())
            a-=1
            b-=1
            self.tree[a].append(b)
            self.tree[b].append(a)
        for i in range(q):
            p,x=map(int, readline().rstrip().split())
            p-=1
            self.ans[p]+=x
    def do(self,root,next):
        if root >= 0:
            self.ans[next]+=self.ans[root]
        for a in self.tree[next]:
            if a==root:
                continue
            self.do(next,a)
    def answer(self):
        print(" ".join(map(str,self.ans)))






def resolve():
    readline=sys.stdin.readline

    n,q=map(int, readline().rstrip().split())
    c=check(n,q)
    c.do(-1,0)
    c.answer()

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------
from collections import defaultdict
import math

from math import factorial
# 組み合わせ
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def main():
    num, k_bleu = map(int, input().split())
    red_num = num - k_bleu

    # ans = 0
    mod = 10 ** 9 + 7
    for i in range(k_bleu):
        kaisuu = i + 1
        ans = combinations_count(red_num + 1, kaisuu) * combinations_count(k_bleu - 1, kaisuu - 1)
        ans %= mod
        print(ans)








if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict
import math

from math import factorial
# 組み合わせ
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def main():
    num, k_bleu = map(int, input().split())
    red_num = num - k_bleu

    # ans = 0
    mod = 10 ** 9 + 7
    for i in range(k_bleu):
        kaisuu = i + 1
        if i >= min(k_bleu, red_num + 1):
            print(0)
        else:
            ans = combinations_count(red_num + 1, kaisuu) * combinations_count(k_bleu - 1, kaisuu - 1)
            ans %= mod
            print(ans)








if __name__ == '__main__':
    main()
n=int(input())
h=list(map(int,input.split()))
hm=max(h)
t=1
ans=0
for i in range(hm,-1,-1):
    for j in range(n):
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)


### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
hm=max(h)

ans=0
for i in range(hm,0,-1):
    t=1
    for j in range(n):
        if h[j]>=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)
N = int(input())
A = list(map(int, input().split()))

def up(i,pre):
  if i == len(A) - 1:
    return abs(A[pre] - A[i])
  res1 = res2 = 0
  if i + 2 <=len(A) -1:
    res1 = up(i + 1,i)
    res2 = up(i + 2,i)
   # print(min(abs(A[pre] - A[i]) + res1, abs(A[pre] - A[i]) + res2))
    return min(abs(A[pre] - A[i]) + res1, abs(A[pre] - A[i]) + res2)
  elif  i + 1 <=len(A) -1:
    res1 = up(i + 1,i)
    #print(abs(A[pre] - A[i]) + res1)
    return abs(A[pre] - A[i]) + res1
  
if N>2:
 print(min(up(1,0),up(2,0)))
else:
  print(up(1,0))
    


  


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
dp = [0 for _ in range(len(A))]
dp[0] = 0 
for i in range(1,N):
    if i - 2>=0:
        dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]),dp[i-2] + abs(A[i] - A[i-2]))
    else:
        dp[i] =dp[i-1] + abs(A[i] - A[i-1])

print(dp[len(A)-1])
//不正解

n = int(input())
s = input()
x = int(n/2)

if n%2 != 0:
    print("No")
elif s[:x] == s[x+1:]:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

n = int(input())
s = input()
x = int(n/2)

if n%2 != 0:
    print("No")
elif s[:x] == s[x:]:
    print("Yes")
else:
    print("No")
whatMan = []

N, K = input().split()
for i in range(int(K)):
    wahtMan.extend(input().split())
print(wahtMan)

### FIXED CODE ###

whatMan = []

N, K = input().split()
for i in range(int(K)):
    input()
    whatMan.extend(input().split())
print(int(N) - len(set(whatMan)))
# -*- coding: utf-8 -*-
import math

def make_divisor_list(num,tar):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        i = 2
        while i*i <= num:

            if num % i == 0 and i*i <= num:
                divisor_list.append(i)
                divisor_list.append(num//i)
            i += 1
        divisor_list.append(num)
        return divisor_list
def binary_search_loop(li,tar):
    arry = li
    target = tar

    left = 0
    right = len(arry)

    while left <= right:

        mid = (left + right) // 2
        if arry[mid] ==  target:
            break
        elif arry[mid] > target:
            right = mid
        else:
            left = mid
        if right - left == 1:
            mid += 1
            break

#    print(mid)
    return mid

N,M = map(int,input().split())

li = make_divisor_list(M,M//N)
li = sorted(li)
mid = binary_search_loop(li,M//N)


ans = 0
i = mid
while True:
    if li[i]>=N:
        tmp = M//li[i]
        if tmp >= ans:
            ans = tmp
        else:
            break

    i += 1
print(ans)
# print(li)

# ans = 1
# for l in li[::-1]:
#     if l >= N:
#         ans = max(ans,M//l)
#     if ans >= l:
#         break

# i = 1
# ans = 0
# tmp = 1000000000

# if M%N == 0:
#     ans = max(ans,M//N)
#     print(ans)
#     exit()

# while M//i >= i and N > i and i <= tmp:
#     if M%i == 0:
#         if tmp == 1000000000:
#             tmp = M//i
#         if M//i >= N:
#             ans = max(ans,i)
#     i += 1

#print(ans)


### FIXED CODE ###

N,M = map(int,input().split())
ans = 1
i = 1
while i*i <= M:
    if M%i == 0 and M//N >= i:
        ans = max(ans,i)
        if M //i *N <= M:
            ans = max(ans,M//i)
    i += 1
print(ans)
a,b,c=input().split(,)
print(a,b,c)

### FIXED CODE ###

a,b,c=input().split(',')
print(a,b,c)
T_list = input()
T = list(T_list)
nT = [0]*len(T)
for i in range(len(T)):
    if T[i] != '?':
        nT[i] = T[i]
    else:
        if 0<i:
            if T[i-1] == 'P':
                nT[i] = 'D'
                T[i] = 'D'
            elif T[i+1] == 'D':
                nT[i] = 'P'
                T[i] = 'P'
            elif T[i+1] == '?':
                nT[i] = 'P'
                T[i] = 'P'
            else:
                nT[i] = 'D'
                T[i] = 'D'
nT=''.join(nT)              
print(nT)       


### FIXED CODE ###

T_list = input()
T = list(T_list)
nT = [0]*len(T)
if T[len(T)-1] == '?':
    T[len(T)-1] = 'D'
for i in range(len(T)):
    if T[i] != '?':
        nT[i] = T[i]
    else:
        if 0<i and i<len(T)-1:
            if T[i-1] == 'P':
                nT[i] = 'D'
                T[i] = 'D'
            elif T[i+1] == 'D':
                nT[i] = 'P'
                T[i] = 'P'
            elif T[i+1] == '?':
                nT[i] = 'P'
                T[i] = 'P'
            else:
                nT[i] = 'D'
                T[i] = 'D'
        else:
            if i<len(T)-1:
                if T[i+1] == 'D':
                    nT[i] = 'P'
                    T[i] = 'P'
                elif T[i+1] == '?':
                    nT[i] = 'P'
                    T[i] = 'P'
                else:
                    nT[i] = 'D'
                    T[i] = 'D'
nT=''.join(nT)              
print(nT)
x=int(input())

if s==0:
  print( 1)
elif s==1:
  print( 0)

### FIXED CODE ###

x=int(input())

if x==0:
  print(1)
elif x==1:
  print(0)
from heapq import heappop, heappush
n, m = map(int, input().split())
l = [[] for i in range(n)]
for i in range(n):
    a,b = map(int, input().split())
    c = min(m-a, n)
    if c < 0:
        continue
    heappush(l[c], -b)
heap = []
ans = 0
for i in range(n)[::-1]:
    for b in l[i]:
        heappush(heap, b)
    if heap:
        b = heappop(heap)
        ans += -b
print(ans)

### FIXED CODE ###

from heapq import heappop, heappush
n, m = map(int, input().split())
l = [[] for i in range(n)]
for i in range(n):
    a,b = map(int, input().split())
    c = min(m-a, n-1)
    if c < 0:
        continue
    heappush(l[c], -b)
heap = []
ans = 0
for i in range(n)[::-1]:
    for b in l[i]:
        heappush(heap, b)
    if heap:
        b = heappop(heap)
        ans += -b
print(ans)
N = int(input())
A = list(map(int,input().split()))
sum = 0
for i in range(1, N):
   sum +=A[i-1]
   sum = sum % (10**9 + 7)
   ans += (sum * A[i]) % (10**9 + 7)
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
sum = 0
ans = 0
for i in range(1, N):
   sum +=A[i-1]
   sum = sum % (10**9 + 7)
   ans = ans + (sum * A[i]) % (10**9 + 7)
   ans = ans % (10**9 + 7)
print(ans)
a = map(int, input().split())
print(max(a) - min(a))

### FIXED CODE ###

(*a,)= map(int, input().split(" "))
print(max(a) - min(a))
def trace(i, j, S, col, num_color):
    next_col = 1 - col
    num_color[col] += 1
    S[i][j] = 2
    if S[i-1][j] == next_col:
        trace(i-1, j, S, next_col, num_color)
    if S[i][j-1] == next_col:
        trace(i, j-1, S, next_col, num_color)
    if S[i+1][j] == next_col:
        trace(i+1, j, S, next_col, num_color)
    if S[i][j+1] == next_col:
        trace(i, j+1, S, next_col, num_color)
    return num_color[0] * num_color[1]

def main():
    H, W = map(int, input().split())
    # 黒0，白1，padding2
    S = [[2] * (W+2)]
    for _ in range(H):
        S.append([2] + [0 if s == '#' else 1 for s in input()] + [2])
    S.append([2] * (W+2))
    num_comb = 0
    for i in range(1, H+1):
        for j in range(1, W+1):
            if S[i][j] == 0:
                num_color = [0, 0]
                num_comb += trace(i, j, S, 0, num_color)
    print(num_comb)

main()

### FIXED CODE ###

N = int(input())
H = int(input())
W = int(input())
print((N-H+1) * (N-W+1))
a = [int(c) for c in s]
k=int(input())
strong=0
for some in range(k):
  if a[some]==1:
    strong+=1
  if strong==k-1:
    print(some)
  if a[some]!=1:
    print(some)
    break


### FIXED CODE ###

s=input()
lists=[int(integer)for integer in s] 
nums=int(input())

numbers=0 
strong=0 
#sに位置が初め何個ついているのかをnumbers変数に代入する
#もしｓが1で始まらなかった場合、その初めの文字を出力して終了する
for j in lists:
    if lists[0]!=1:
        break
    else:
        if j==1:
            numbers+=1
        else:
            break
#startで場合分け            
if lists[0]==1:
    if numbers>=nums:
        print(1)
        
    elif numbers<nums:
        print(lists[numbers])
else:
    print(lists[0])
import sys
from io import StringIO
import unittest


n = input()
op_cnt = len(n) - 1  # すき間の個数
for i in range(2**op_cnt):
  op = ['-'] * op_cnt
  for j in range(op_cnt):
    if (i >> j) & 1:
      op[op_cnt-1-j] = '+'
      formula = ''
      for p_n, p_o in zip(n, op + ['']):
        formula += (p_n + p_o)
        if eval(formula) == 7:
          print(formula + '=7')
          break

### FIXED CODE ###

n = input()
op_cnt = len(n) - 1  # すき間の個数
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き

    formula = ""
    for p_n, p_o in zip(n, op + [""]):  # 少々モヤッとする
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break
[x,y]=[for int(input().split())) in range()]

print(min(x,y),max(x,y))

### FIXED CODE ###

while True:
 x,y=sorted ([int(x) for x in input().split()])
 if (x,y)==(0,0):
  break
 print(x,y)
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a,b;
bool f[4];
int main() {
	scanf("%d%d",&a,&b);
	f[a]=f[b]=true;
	if (!f[1]) puts("1");
	else if (!f[2]) puts("2");
	else puts("3");
	return 0;
}

### FIXED CODE ###

a=int(input())
b=int(input())
if a>b:
    c=a
    a=b
    b=c
if a==1 and b==2:
    print(3)
elif a==1 and b==3:
    print(2)
else:
    print(1)
def inpl(): return list(map(int, input().split()))

N, M = inpl()
G = [[0]*(N+1) for _ in range(N+1)]

for _ in range(M):
    a, b = inpl()
    G[a][b] = 1
    G[b][a] = 1

ans = 0
for X in permutations(range(2, N+1)):
    a = 1
    for i in range(N-1):
        b = X[i]
        if G[a][b] == 0:
            break
        a = b
    else:
        ans += 1

print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
from queue import Queue

q = Queue()
N, M = [int(n) for n in input().split()]
graph = {n:[] for n in range(1, N+1)}

for m in range(M):
    a, b = [int(n) for n in input().split()]
    graph[a].append(b)
    graph[b].append(a)

end = 0
for n in range(2, N+1):
    if len(graph[n]) == 1:
        end = n

ok = []
q.put([1, []])

while not q.empty():
    point, past = q.get()
    for d in graph[point]:
        if not d in past:
            if len(past + [point, d]) == N:
                ok.append(past + [point, d])
            else:
                q.put([d, past+[point]])

print(len(ok))
fast_list = list(map(int, input().split())) 
correct_answer_count = 0
bat_answer_count = 0
for i in range(1, fast_list[0] + 1):
    for j in range(1, i+1):
        if not (fast_list[1][i] <= fast_list[1][j]):
            bat_answer_count += 1

    if bat_answer_count == 0:
        correct_answer_count += 1

print(correct_answer_count)    
            
            

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
 
cnt = 0
p_min = p[0]
for i in range(n):
  pi = p[i]
  if pi <= p_min:
    cnt += 1
    p_min = pi
print(cnt)
n, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for i in range(n - 2):
    if a[i] + a[i + 1] > x:
        count += a[i] + a[i + 1] - x
        a[i + 1] = x - a[i]
if a[n - 1] + a[n] > x:
    count += a[n - 1] + a[n] - x
print(int(count))


### FIXED CODE ###

n, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for i in range(n - 1):
    if a[i] + a[i + 1] > x:
        count += a[i] + a[i + 1] - x
        if a[i + 1] >= a[i] + a[i + 1] - x:
            a[i + 1] = x - a[i]
        else:
            a[i + 1] = 0
            a[i] = x
print(int(count))
from bisect import bisect_left
import sys
sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
a = list(map(int, input().split()))
adj = [[] for _ in range(n)]
for _ in range(n-1):
	u, v = map(int, input().split())
	adj[u-1].append(v-1)
	adj[v-1].append(u-1)

INF = 10**6
dp = [INF for _ in range(n)]
ans = [0 for _ in range(n)]

def dfs(x, p):
	ans[x] = bisect_left(dp, INF)
	for v in adj[x]:
		if v == p:
			continue
		ind = bisect_left(dp, a[v])
		pres = dp[ind]
		dp[ind] = a[v]
		dfs(v, x)
		dp[ind] = pres
	return

dp[0] = a[0]
dfs(0, -1)
print(*ans, sep="\n")

### FIXED CODE ###

from bisect import bisect_left
import sys
sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
a = list(map(int, input().split()))
adj = [[] for _ in range(n)]
for _ in range(n-1):
	u, v = map(int, input().split())
	adj[u-1].append(v-1)
	adj[v-1].append(u-1)

INF = 10**10
dp = [INF for _ in range(n)]
ans = [0 for _ in range(n)]

def dfs(x, p):
	ans[x] = bisect_left(dp, INF)
	for v in adj[x]:
		if v == p:
			continue
		ind = bisect_left(dp, a[v])
		pres = dp[ind]
		dp[ind] = a[v]
		dfs(v, x)
		dp[ind] = pres
	return

dp[0] = a[0]
dfs(0, -1)
print(*ans, sep="\n")
N = int(input())

a = N/1.08

a1 = round(a)

a2 = int(a1*1.08)

if a2 == N:
    print(a1)
else:
    print(":(")

### FIXED CODE ###

M1,D1= map(int, input().split())
M2,D2 = map(int, input().split())

if D1 + 1 == D2:
    print(0)
else:
    print(1)
import math

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

ans = a*b/math.gcd(a, b)
print(int(ans))

### FIXED CODE ###

import fractions

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

ans = a*b/fractions.gcd(a, b)
print(int(ans))
N = int(input())
s = []
for i in range(N):
	s.append(input())
c = 0
for j in range(len(s)):
	c += s[i].count("AB")
a = 0
b = 0
for k in range(len(s)):
	if s[i][-1] == "A":
        a += 1
for l in range(len(s)):
	if s[i][0] == "B":
        b += 1
print(c+Math.min(a,b))


### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]
ans = 0
ba = b = a = 0
for s in S:
    ans += s.count('AB')
    if s[0] + s[-1] == 'BA':
        ba += 1
    if s[0] == 'B':
        b += 1
    if s[-1] == 'A':
        a += 1
ans += min(a, b)
if a == b == ba and b:
    ans -= 1
print(ans)
#(N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines()]
N,M=map(int,input().split())
AB=[list(map(int, input().split())) for _ in range(M)]
d={}
g=0
for a,b in AB:
    if a in d:
        d[b] = d[a]
    elif b in d:
        b[a] = d[b]
    else:
        g += 1
        d[a] = d[b] = g
for i in range(1,N+1):
    if not i in d:
        g += 1
print(g - 1)


### FIXED CODE ###

(N,M),*AB=[list(map(int, x.split())) for x in open(0).readlines() if len(x)>1]

class UnionFind:
    def __init__(self, n):
        self.n=n
        self.parents=[-1 for i in range(n)]

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
        if self.parents[rx] > self.parents[ry]:
            rx,ry=ry,rx
        self.parents[rx] = self.parents[ry]
        self.parents[ry] = rx

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i,x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


d=UnionFind(N)
for a,b in AB:
    d.union(a-1,b-1)
print(d.group_count() - 1)
N, M = [int(i) for i in input().split()]

guess_dict = {'100':[], '10':[], '1':[]}


flag = True
for i in range(M):
    s, c = [int(i) for i in input().split()]
    if s == 3:
        guess_dict['1'].append(c)
    elif s == 2:
        guess_dict['10'].append(c)
    elif s == 1:
        guess_dict['100'].append(c)
        
for k, v in guess_dict.items():
    if len(set(v)) > 1:
        flag = False
        
if N == 3:
    if len(guess_dict['100']) == 0:
        guess_dict['100'].append(1)
    if len(guess_dict['10']) == 0:
        guess_dict['10'].append(0)
    if len(guess_dict['1']) == 0:
        guess_dict['1'].append(0)
if N == 2:
    if len(guess_dict['100']) == 0 and len(guess_dict['10']) == 0:
        guess_dict['10'].append(0)
        guess_dict['10'].append(1)
    if len(guess_dict['1']) == 0:
        guess_dict['1'].append(0)
if N == 1:
    if len(guess_dict['100']) == 0 and len(guess_dict['10']) == 0:
        guess_dict['10'].append(0)
        guess_dict['10'].append(0)
    if len(guess_dict['1']) == 0:
        guess_dict['1'].append(0)

guess_num = 0
guess_num += guess_dict['100'][0] * 100
guess_num += guess_dict['10'][0] * 10
guess_num += guess_dict['1'][0]


if len(str(guess_num)) != N:
    flag = False

if flag:
    print(guess_num)
else :
    print('-1')

### FIXED CODE ###

N, M = [int(i) for i in input().split()]
conditions = [[int(i) for i in input().split()] for j in range(M)] 
num = -1
for i in range(10**N):
    flag = True
    for j in range(M):
        s = conditions[j][0]
        c = conditions[j][1]
        if len(str(i)) < s:
            flag = False
            break
        else :
            if int(str(i)[s-1]) == c:
                pass
            else:
                flag = False
                break
    if flag:
        if len(str(i)) == N:
            num = i
            break
        else :
            pass

print(num)
while True:
    s = input()
    if s == "0":
        break
    a = 0
    for i in s:
        a += int(s[i])


### FIXED CODE ###

while True:
    s = input()
    if s == "0":
        break
    a = 0
    for i,j in enumerate(s):
        a += int(s[i])
    print(a)
import itertools
N, M = map(int, input().strip().split())
prev_cakes = []

for _ in range(M - 1):
  prev_cakes.append(tuple(map(int, input().strip().split())))

max_sum = None
for _ in range(N - M + 1):
  cake = tuple(map(int, input().strip().split()))
  for combi_cakes in itertools.combinations(prev_cakes, M - 1):
    print(combi_cakes)
    x = sum([ccake[0] for ccake in combi_cakes]) + cake[0]
    y = sum([ccake[1] for ccake in combi_cakes]) + cake[1]
    z = sum([ccake[2] for ccake in combi_cakes]) + cake[2]
    if max_sum is None or abs(x)+abs(y)+abs(z) > max_sum:
      max_sum = abs(x)+abs(y)+abs(z)
  prev_cakes.append(cake)
print(max_sum)

### FIXED CODE ###

n, m = map(int, input().split())
xyz = [tuple(map(int, input().split())) for _ in range(n)]

s1 = abs(sum(sorted([x+y+z for x, y, z in xyz])[:m]))
s2 = abs(sum(sorted([x+y-z for x, y, z in xyz])[:m]))
s3 = abs(sum(sorted([x-y+z for x, y, z in xyz])[:m]))
s4 = abs(sum(sorted([x-y-z for x, y, z in xyz])[:m]))
s5 = abs(sum(sorted([-x+y+z for x, y, z in xyz])[:m]))
s6 = abs(sum(sorted([-x+y-z for x, y, z in xyz])[:m]))
s7 = abs(sum(sorted([-x-y+z for x, y, z in xyz])[:m]))
s8 = abs(sum(sorted([-x-y-z for x, y, z in xyz])[:m]))

print(max(s1, s2, s3, s4, s5, s6, s7, s8))
inp=input()
nums = [int(x) for x in inp.split(" ")]

def mp(nums):
  n = 1
  for num in nums:
    n *=num
  return n

limit= mp([10]*18)
num = mp(nums)

if n>limit:
  print(-1)
else:
  print(num)

### FIXED CODE ###

inp = input()
inp = input()
 
def mp(nums):
  if 0 in nums:
    print(0)
    return
  n = 1
  limit = 10**18
  for num in nums:
    n *=num
    if n > limit:
      print(-1)
      return
  print(n)
 
mp([int(x) for x in inp.split(" ")])
W,a,b=map(int,input().split())

if a+W<b:
  print(b-(W+a)):
else:
  print(0)

### FIXED CODE ###

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

if a+W<b:
  print(b-(W+a))
elif b+W<a:
  print(a-(W+b))
else:
  print(0)
S = int(input())
S = str(S)
i_list = list(S)
i_list = [int(i) for i in i_list]

if i_list[0] == i_list[1] or i_list[1] == i_list[2] or i_list[2] == i_list[3]:
    print('Bad')
else:
    print('Good')

### FIXED CODE ###

S = input()
i_list = list(S)
i_list = [int(i) for i in i_list]

if i_list[0] == i_list[1] or i_list[1] == i_list[2] or i_list[2] == i_list[3]:
    print('Bad')
else:
    print('Good')
a, p=map(int, input().split())
b=(a/3)+p
if b%2==0:
    print(b/2¥n)
if else:
    print((b-1)/2¥n)

### FIXED CODE ###

a, p=map(int, input().split())
print((a*3+p)//2)
from sys import *
a,b,c = map(int,input.split())
print(c, a, b)


### FIXED CODE ###

from sys import *
a,b,c = map(int,input().split())
print(c, a, b)