Language: C++

#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;

    long x[N];
    long y[N];
    long z[N];

    long PPP[N];
    long MPP[N];
    long PMP[N];
    long PPM[N];
    long MMP[N];
    long MPM[N];
    long PMM[N];
    long MMM[N];

    for(int i = 0;i<N;i++){
        cin >> x[i] >> y[i] >> z[i];
        PPP[i] =      x[i] + y[i] + z[i];
        MPP[i] = (-1)*x[i] + y[i] + z[i];
        PMP[i] =      x[i] - y[i] + z[i];
        PPM[i] =      x[i] + y[i] - z[i];
        MMP[i] = (-1)*x[i] - y[i] + z[i];
        MPM[i] = (-1)*x[i] + y[i] - z[i];
        PMM[i] =      x[i] - y[i] - z[i];
        MMM[i] = (-1)*x[i] - y[i] - z[i];
    }

    sort(PPP.rbegin(),PPP.rend());
    sort(MPP.rbegin(),MPP.rend());
    sort(PMP.rbegin(),PMP.rend());
    sort(PPM.rbegin(),PPM.rend());
    sort(MMP.rbegin(),MMP.rend());
    sort(MPM.rbegin(),MPM.rend());
    sort(PMM.rbegin(),PMM.rend());
    sort(MMM.rbegin(),MMM.rend());

    long Max1 = 0;
    long Max2 = 0;
    long Max3 = 0;
    long Max4 = 0;
    long Max5 = 0;
    long Max6 = 0;
    long Max7 = 0;
    long Max8 = 0;

    for(int i = 0;i<M;i++){
        Max1 = Max1 + PPP[i];
        Max2 = Max2 + MPP[i];
        Max3 = Max3 + PMP[i];
        Max4 = Max4 + PPM[i];
        Max5 = Max5 + MMP[i];
        Max6 = Max6 + MPM[i];
        Max7 = Max7 + PMM[i];
        Max8 = Max8 + MMM[i];
    }

    long ans = max(Max1,max(Max2,max(Max3,max(Max4,max(Max5,max(Max6,max(Max7,Max8)))))));

    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:14: error: request for member 'rbegin' in 'PPP', which is of non-class type 'long int [N]'
   41 |     sort(PPP.rbegin(),PPP.rend());
      |              ^~~~~~
a.cc:41:27: error: request for member 'rend' in 'PPP', which is of non-class type 'long int [N]'
   41 |     sort(PPP.rbegin(),PPP.rend());
      |                           ^~~~
a.cc:42:14: error: request for member 'rbegin' in 'MPP', which is of non-class type 'long int [N]'
   42 |     sort(MPP.rbegin(),MPP.rend());
      |              ^~~~~~
a.cc:42:27: error: request for member 'rend' in 'MPP', which is of non-class type 'long int [N]'
   42 |     sort(MPP.rbegin(),MPP.rend());
      |                           ^~~~
a.cc:43:14: error: request for member 'rbegin' in 'PMP', which is of non-class type 'long int [N]'
   43 |     sort(PMP.rbegin(),PMP.rend());
      |              ^~~~~~
a.cc:43:27: error: request for member 'rend' in 'PMP', which is of non-class type 'long int [N]'
   43 |     sort(PMP.rbegin(),PMP.rend());
      |                           ^~~~
a.cc:44:14: error: request for member 'rbegin' in 'PPM', which is of non-class type 'long int [N]'
   44 |     sort(PPM.rbegin(),PPM.rend());
      |              ^~~~~~
a.cc:44:27: error: request for member 'rend' in 'PPM', which is of non-class type 'long int [N]'
   44 |     sort(PPM.rbegin(),PPM.rend());
      |                           ^~~~
a.cc:45:14: error: request for member 'rbegin' in 'MMP', which is of non-class type 'long int [N]'
   45 |     sort(MMP.rbegin(),MMP.rend());
      |              ^~~~~~
a.cc:45:27: error: request for member 'rend' in 'MMP', which is of non-class type 'long int [N]'
   45 |     sort(MMP.rbegin(),MMP.rend());
      |                           ^~~~
a.cc:46:14: error: request for member 'rbegin' in 'MPM', which is of non-class type 'long int [N]'
   46 |     sort(MPM.rbegin(),MPM.rend());
      |              ^~~~~~
a.cc:46:27: error: request for member 'rend' in 'MPM', which is of non-class type 'long int [N]'
   46 |     sort(MPM.rbegin(),MPM.rend());
      |                           ^~~~
a.cc:47:14: error: request for member 'rbegin' in 'PMM', which is of non-class type 'long int [N]'
   47 |     sort(PMM.rbegin(),PMM.rend());
      |              ^~~~~~
a.cc:47:27: error: request for member 'rend' in 'PMM', which is of non-class type 'long int [N]'
   47 |     sort(PMM.rbegin(),PMM.rend());
      |                           ^~~~
a.cc:48:14: error: request for member 'rbegin' in 'MMM', which is of non-class type 'long int [N]'
   48 |     sort(MMM.rbegin(),MMM.rend());
      |              ^~~~~~
a.cc:48:27: error: request for member 'rend' in 'MMM', which is of non-class type 'long int [N]'
   48 |     sort(MMM.rbegin(),MMM.rend());
      |                           ^~~~