Language: C++

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    ll a[1010];
    ll b[1010];
    ll c[1010];
    f(n){
        cin>>a[i]>>b[i]>>c[i];
    }
    int i,j,k,l;
    ll ans=0;
    F(i,-1,2,1){
        if(i==0) continue;
        F(j,-1,2,1){
            if(j==0) continue;
            F(k,-1,2,1){
                if(k==0) continue;
                debug()<<imie(i) imie(j) imie(k);
                vector<ll> val;
                F(l,0,n,1){
                    ll res=i*a[l]+j*b[l]+k*c[l];
                    val.pb(res);
                }
                debug()<<imie(val);
                sort(all(val));
                reverse(all(val));
                debug()<<imie(val);
                ll tot=0;
                f(m) tot+=val[i];
                ans=max(ans,tot);
            }
        }
    }    
    cout<<ans<<endl;
    return 0;
}


Press ENTER or type command to continue
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    ll a[1010];
    ll b[1010];
    ll c[1010];
    f(n){
        cin>>a[i]>>b[i]>>c[i];
    }
    int i,j,k,l;
    ll ans=0;
    F(i,-1,2,1){
        if(i==0) continue;
        F(j,-1,2,1){
            if(j==0) continue;
            F(k,-1,2,1){
                if(k==0) continue;
                debug()<<imie(i) imie(j) imie(k);
                vector<ll> val;
                F(l,0,n,1){
                    ll res=i*a[l]+j*b[l]+k*c[l];
                    val.pb(res);
                }
                debug()<<imie(val);
                sort(all(val));
                reverse(all(val));
                debug()<<imie(val);
                ll tot=0;
                f(m) tot+=val[i];
                ans=max(ans,tot);
            }
        }
    }    
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:97:1: error: 'Press' does not name a type
   97 | Press ENTER or type command to continue
      | ^~~~~
a.cc:121:14: error: redefinition of 'struct rge<c>'
  121 | sim > struct rge {c b,e;};
      |              ^~~
a.cc:24:14: note: previous definition of 'struct rge<c>'
   24 | sim > struct rge {c b,e;};
      |              ^~~
a.cc:122:14: error: redefinition of 'template<class c> rge<c> range(c, c)'
  122 | sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
      |              ^~~~~
a.cc:25:14: note: 'template<class c> rge<c> range(c, c)' previously declared here
   25 | sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
      |              ^~~~~
a.cc:125:8: error: redefinition of 'struct debug'
  125 | struct debug{
      |        ^~~~~
a.cc:28:8: note: previous definition of 'struct debug'
   28 | struct debug{
      |        ^~~~~
a.cc:153:5: error: redefinition of 'int main()'
  153 | int main(){
      |     ^~~~
a.cc:56:5: note: 'int main()' previously defined here
   56 | int main(){
      |     ^~~~