Buggy python submission (verdict: Runtime Error):
#coding:utf-8
import itertools
import numpy as np

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]
cakeList = np.array(cakeList)
numList = [i for i in range(N)]


maxv = 0
if M < N/2:
    combi = list(itertools.combinations(numList,M))
    for indexs in combi:
        cakes = [cakeList[i] for i in indexs]
        cakes = np.array(cakes)
        total = [abs(np.sum(cakes[:,i])) for i in range(3)]
        total = sum(total)
        maxv = max(total,maxv)
    print(maxv)


else:
    M = N - M
    combi = list(itertools.combinations(numList,M))
    BDP = [np.sum(cakeList[:,i]) for i in range(3)]
    for indexs in combi:
        cakes = [cakeList[i] for i in indexs]
        cakes = np.array(cakes)
        total = [abs(BDP[i] - np.sum(cakes[:,i])) for i in range(3)]
        total = sum(total)
        maxv = max(maxv,total)
    print(maxv)


Fixed submission:
#coding:utf-8
import itertools
import numpy as np
from copy import deepcopy

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]
cakeList = np.array(cakeList)


n = 3
oneList = [None for i in range(n)]
value = []
def maker(dep):
    if dep >= n:
        oneList_copy = deepcopy(oneList)
        value.append(oneList_copy)
        return
    oneList[dep] = 1
    maker(dep+1)
    oneList[dep] = -1
    maker(dep+1)

maker(0)


allvalue = []  
for cake in cakeList:
    value8 = [np.dot(v,cake) for v in value]
    allvalue.append(value8)
    
allvalue = np.array(allvalue)

maxList = []
for i in range(2**n):
    row = list(allvalue[:,i])
    row.sort(reverse=True)
    maxv = sum(row[:M])
    maxList.append(maxv)
maxv = max(maxList)
print(maxv)

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
import itertools
import numpy as np

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]
cakeList = np.array(cakeList)
numList = [i for i in range(N)]


if M < N/2:
    combi = list(itertools.combinations(numList,M))
    totalList = []
    for indexs in combi:
        cakes = [cakeList[i] for i in indexs]
        cakes = np.array(cakes)
        total = [abs(np.sum(cakes[:,i])) for i in range(3)]
        total = sum(total)
        totalList.append(total)
    print(max(totalList))


else:
    M = N - M
    combi = list(itertools.combinations(numList,M))
    BDP = [np.sum(cakeList[:,i]) for i in range(3)]
    totalList = []
    for indexs in combi:
        cakes = [cakeList[i] for i in indexs]
        cakes = np.array(cakes)
        total = [abs(BDP[i] - np.sum(cakes[:,i])) for i in range(3)]
        total = sum(total)
        totalList.append(total)
    print(max(totalList))


Fixed submission:
#coding:utf-8
import itertools
import numpy as np
from copy import deepcopy

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]
cakeList = np.array(cakeList)


n = 3
oneList = [None for i in range(n)]
value = []
def maker(dep):
    if dep >= n:
        oneList_copy = deepcopy(oneList)
        value.append(oneList_copy)
        return
    oneList[dep] = 1
    maker(dep+1)
    oneList[dep] = -1
    maker(dep+1)

maker(0)


allvalue = []  
for cake in cakeList:
    value8 = [np.dot(v,cake) for v in value]
    allvalue.append(value8)
    
allvalue = np.array(allvalue)

maxList = []
for i in range(2**n):
    row = list(allvalue[:,i])
    row.sort(reverse=True)
    maxv = sum(row[:M])
    maxList.append(maxv)
maxv = max(maxList)
print(maxv)

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
import itertools
import numpy as np

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]

numList = [i for i in range(N)]
combi = list(itertools.combinations(numList,M))


totalList = []
for indexs in combi:
    cakes = [cakeList[i] for i in indexs]
    cakes = np.array(cakes)
    total = [abs(np.sum(cakes[:,i])) for i in range(3)]
    total = sum(total)
    totalList.append(total)


print(max(totalList))


Fixed submission:
#coding:utf-8
import itertools
import numpy as np
from copy import deepcopy

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]
cakeList = np.array(cakeList)


n = 3
oneList = [None for i in range(n)]
value = []
def maker(dep):
    if dep >= n:
        oneList_copy = deepcopy(oneList)
        value.append(oneList_copy)
        return
    oneList[dep] = 1
    maker(dep+1)
    oneList[dep] = -1
    maker(dep+1)

maker(0)


allvalue = []  
for cake in cakeList:
    value8 = [np.dot(v,cake) for v in value]
    allvalue.append(value8)
    
allvalue = np.array(allvalue)

maxList = []
for i in range(2**n):
    row = list(allvalue[:,i])
    row.sort(reverse=True)
    maxv = sum(row[:M])
    maxList.append(maxv)
maxv = max(maxList)
print(maxv)

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
import itertools
import numpy as np

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]

numList = [i for i in range(N)]
combi = list(itertools.combinations(numList,M))


totalList = []
for indexs in combi:
    cakes = [cakeList[i] for i in indexs]
    cakes = np.array(cakes)
    total = [abs(np.sum(cakes[:,i])) for i in range(3)]
    total = sum(total)
    totalList.append(total)


print(max(totalList))


Fixed submission:
#coding:utf-8
import itertools
import numpy as np
from copy import deepcopy

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]
cakeList = np.array(cakeList)


n = 3
oneList = [None for i in range(n)]
value = []
def maker(dep):
    if dep >= n:
        oneList_copy = deepcopy(oneList)
        value.append(oneList_copy)
        return
    oneList[dep] = 1
    maker(dep+1)
    oneList[dep] = -1
    maker(dep+1)

maker(0)


allvalue = []  
for cake in cakeList:
    value8 = [np.dot(v,cake) for v in value]
    allvalue.append(value8)
    
allvalue = np.array(allvalue)

maxList = []
for i in range(2**n):
    row = list(allvalue[:,i])
    row.sort(reverse=True)
    maxv = sum(row[:M])
    maxList.append(maxv)
maxv = max(maxList)
print(maxv)