Language: C++

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

ll DP_1[1001][1001], DP_2[1001][1001], DP_3[1001][1001], DP_4[1001][1001], DP_5[1001][1001], DP_6[1001][1001], DP_7[1001][1001], DP_8[1001][1001];
int main() {
    int N, M;
    ll x[1001], y[1001], z[1001];
cin >> N >> M;
    REP(i, N) {
        cin >> x[i+1] >> y[i+1] >> z[i+1];
    }


    for(int i = 1; i < N + 1; i++) {
        for(int j = 1; j < M + 1; j++) {
            DP_1[i][j] = max(DP_1[i - 1][j - 1] + x[z] + y[i] + z[i], DP_1[i - 1][j]);
            DP_2[i][j] = max(DP_2[i - 1][j - 1] - x[i] + y[i] + z[i], DP_2[i - 1][j]);
            DP_3[i][j] = max(DP_3[i - 1][j - 1] + x[i] - y[i] + z[i], DP_3[i - 1][j]);
            DP_4[i][j] = max(DP_4[i - 1][j - 1] - x[i] - y[i] + z[i], DP_4[i - 1][j]);
            DP_5[i][j] = max(DP_5[i - 1][j - 1] + x[i] + y[i] - z[i], DP_5[i - 1][j]);
            DP_6[i][j] = max(DP_6[i - 1][j - 1] - x[i] + y[i] - z[i], DP_6[i - 1][j]);
            DP_7[i][j] = max(DP_7[i - 1][j - 1] + x[i] - y[i] - z[i], DP_7[i - 1][j]);
            DP_8[i][j] = max(DP_8[i - 1][j - 1] - x[i] - y[i] - z[i], DP_8[i - 1][j]);
        }
    }
    ll max_val = DP_1[N][M];
    if(DP_2[N][M] > max_val) max_val = DP_2[N][M];
    if(DP_3[N][M] > max_val) max_val = DP_3[N][M];
    if(DP_4[N][M] > max_val) max_val = DP_4[N][M];
    if(DP_5[N][M] > max_val) max_val = DP_5[N][M];
    if(DP_6[N][M] > max_val) max_val = DP_6[N][M];
    if(DP_7[N][M] > max_val) max_val = DP_7[N][M];
    if(DP_8[N][M] > max_val) max_val = DP_2[N][M];
    cout << max_val;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:84:52: error: invalid types 'll [1001] {aka long long int [1001]}[ll [1001] {aka long long int [1001]}]' for array subscript
   84 |             DP_1[i][j] = max(DP_1[i - 1][j - 1] + x[z] + y[i] + z[i], DP_1[i - 1][j]);
      |                                                    ^