Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
ll dp[1001][1001][2][2][2]; // 0 : +   1 : - 
int main(){
  fill_n(dp[0][0][0][0][0], 1001*1001*2*2*2, -LLINF);
  ll n,m; cin >> n >> m;
  rep(i,n){
    ll x,y,z; cin >> x >> y >> z;
    rep(tm,m)rep(t1,2)rep(t2,2)rep(t3,2){
      dp[i+1][tm][t1][t2][t3] = max(dp[i+1][tm][t1][t2][t3],dp[i][tm][t1][t2][t3]);
      dp[i+1][tm+1][t1][t2][t3] = max(dp[i+1][tm+1][t1][t2][t3], dp[i][tm][t1][t2][t3] + (t1==0?x:-x)+(t2==0?y:-y)+(t3==0?z:-z));
    }
  }
  ll ans = -LLINF;
  rep(a,2)rep(b,2)rep(c,2) ans = max(ans,dp[n][m][a][b][c]);
  cout << ans << endl;
}


Compiler output:
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of '_OI std::fill_n(_OI, _Size, const _Tp&) [with _OI = long long int; _Size = int; _Tp = long long int]':
a.cc:28:9:   required from here
   28 |   fill_n(dp[0][0][0][0][0], 1001*1001*2*2*2, -LLINF);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1184:56: error: no matching function for call to '__iterator_category(long long int&)'
 1184 |                                std::__iterator_category(__first));
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note: candidate: 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&)'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator_base_types.h: In substitution of 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&) [with _Iter = long long int]':
/usr/include/c++/14/bits/stl_algobase.h:1184:35:   required from '_OI std::fill_n(_OI, _Size, const _Tp&) [with _OI = long long int; _Size = int; _Tp = long long int]'
 1184 |                                std::__iterator_category(__first));
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
a.cc:28:9:   required from here
   28 |   fill_n(dp[0][0][0][0][0], 1001*1001*2*2*2, -LLINF);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: error: no type named 'iterator_category' in 'struct std::iterator_traits<long long int>'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~