Buggy python submission (verdict: Runtime Error):
#input
N, M = map(int, input().split())
x = []
y = []
z = []
for i in range(N):
    x_temp, y_temp, z_temp = map(int, input().split())
    x.append(x_temp)
    y.append(y_temp)
    z.append(z_temp)

#output
#+++
a1 = [p+q+r for p, q, r in zip(x, y, z)]
a1.sort(reverse = True)
b1 = np.sum(a1[:M])

#++-
a2 = [p+q-r for p, q, r in zip(x, y, z)]
a2.sort(reverse = True)
b2 = np.sum(a2[:M])

#+-+
a3 = [p-q+r for p, q, r in zip(x, y, z)]
a3.sort(reverse = True)
b3 = np.sum(a3[:M])

#-++
a4 = [-p+q+r for p, q, r in zip(x, y, z)]
a4.sort(reverse = True)
b4 = np.sum(a4[:M])

#+--
a5 = [p-q-r for p, q, r in zip(x, y, z)]
a5.sort(reverse = True)
b5 = np.sum(a5[:M])

#-+-
a6 = [-p+q-r for p, q, r in zip(x, y, z)]
a6.sort(reverse = True)
b6 = np.sum(a6[:M])

#--+
a7 = [-p-q+r for p, q, r in zip(x, y, z)]
a7.sort(reverse = True)
b7 = np.sum(a7[:M])

#---
a8 = [-p-q-r for p, q, r in zip(x, y, z)]
a8.sort(reverse = True)
b8 = np.sum(a8[:M])

print(max(b1, b2, b3, b4, b5, b6, b7, b8))

Fixed submission:
#input
N, M = map(int, input().split())
x = []
y = []
z = []
for i in range(N):
    x_temp, y_temp, z_temp = map(int, input().split())
    x.append(x_temp)
    y.append(y_temp)
    z.append(z_temp)

#output
#+++
a1 = [p+q+r for p, q, r in zip(x, y, z)]
a1.sort(reverse = True)
b1 = sum(a1[:M])

#++-
a2 = [p+q-r for p, q, r in zip(x, y, z)]
a2.sort(reverse = True)
b2 = sum(a2[:M])

#+-+
a3 = [p-q+r for p, q, r in zip(x, y, z)]
a3.sort(reverse = True)
b3 = sum(a3[:M])

#-++
a4 = [-p+q+r for p, q, r in zip(x, y, z)]
a4.sort(reverse = True)
b4 = sum(a4[:M])

#+--
a5 = [p-q-r for p, q, r in zip(x, y, z)]
a5.sort(reverse = True)
b5 = sum(a5[:M])

#-+-
a6 = [-p+q-r for p, q, r in zip(x, y, z)]
a6.sort(reverse = True)
b6 = sum(a6[:M])

#--+
a7 = [-p-q+r for p, q, r in zip(x, y, z)]
a7.sort(reverse = True)
b7 = sum(a7[:M])

#---
a8 = [-p-q-r for p, q, r in zip(x, y, z)]
a8.sort(reverse = True)
b8 = sum(a8[:M])

print(max(b1, b2, b3, b4, b5, b6, b7, b8))

Buggy python submission (verdict: Runtime Error):
#input
N, M = map(int, input().split())
x = []
y = []
z = []
for i in range(N):
    x_temp, y_temp, z_temp = map(int, input().split())
    x.append(x_temp)
    y.append(y_temp)
    z.append(z_temp)

#output
#+++
a1 = [p+q+r for p, q, r in zip(x, y, z)]
a1 = sorted(a1, reverse = True)
b1 = np.sum(a1[:M])

#++-
a2 = [p+q-r for p, q, r in zip(x, y, z)]
a2 = sorted(a2, reverse = True)
b2 = np.sum(a2[:M])

#+-+
a3 = [p-q+r for p, q, r in zip(x, y, z)]
a3 = sorted(a3, reverse = True)
b3 = np.sum(a3[:M])

#-++
a4 = [-p+q+r for p, q, r in zip(x, y, z)]
a4 = sorted(a4, reverse = True)
b4 = np.sum(a4[:M])

#+--
a5 = [p-q-r for p, q, r in zip(x, y, z)]
a5 = sorted(a5, reverse = True)
b5 = np.sum(a5[:M])

#-+-
a6 = [-p+q-r for p, q, r in zip(x, y, z)]
a6 = sorted(a6, reverse = True)
b6 = np.sum(a6[:M])

#--+
a7 = [-p-q+r for p, q, r in zip(x, y, z)]
a7 = sorted(a7, reverse = True)
b7 = np.sum(a7[:M])

#---
a8 = [-p-q-r for p, q, r in zip(x, y, z)]
a8 = sorted(a8, reverse = True)
b8 = np.sum(a8[:M])

print(max(b1, b2, b3, b4, b5, b6, b7, b8))

Fixed submission:
#input
N, M = map(int, input().split())
x = []
y = []
z = []
for i in range(N):
    x_temp, y_temp, z_temp = map(int, input().split())
    x.append(x_temp)
    y.append(y_temp)
    z.append(z_temp)

#output
#+++
a1 = [p+q+r for p, q, r in zip(x, y, z)]
a1.sort(reverse = True)
b1 = sum(a1[:M])

#++-
a2 = [p+q-r for p, q, r in zip(x, y, z)]
a2.sort(reverse = True)
b2 = sum(a2[:M])

#+-+
a3 = [p-q+r for p, q, r in zip(x, y, z)]
a3.sort(reverse = True)
b3 = sum(a3[:M])

#-++
a4 = [-p+q+r for p, q, r in zip(x, y, z)]
a4.sort(reverse = True)
b4 = sum(a4[:M])

#+--
a5 = [p-q-r for p, q, r in zip(x, y, z)]
a5.sort(reverse = True)
b5 = sum(a5[:M])

#-+-
a6 = [-p+q-r for p, q, r in zip(x, y, z)]
a6.sort(reverse = True)
b6 = sum(a6[:M])

#--+
a7 = [-p-q+r for p, q, r in zip(x, y, z)]
a7.sort(reverse = True)
b7 = sum(a7[:M])

#---
a8 = [-p-q-r for p, q, r in zip(x, y, z)]
a8.sort(reverse = True)
b8 = sum(a8[:M])

print(max(b1, b2, b3, b4, b5, b6, b7, b8))