Language: C++

#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll x[1000];
ll y[1000];
ll z[1000];
ll tm[1000];
ll a[8];
int main() {
  ll n,m;
  cin >> n >> m;
  rep(i, n){
    cin >> x[i] >> y[i] >> z[i];
  }
  rep(i, n)
    tm[i] = x[i] + y[i] + z[i];
  sort(tm, tm + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[0] += tm[i];
  }
  rep(i, n)
    tm[i] = x[i] + y[i] - z[i];
  sort(tm, tm + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[1] += tm[i];
  }
  rep(i, n)
    tm[i] = x[i] - y[i] - z[i];
  sort(tm, tm + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[2] += tm[i];
  }
  rep(i, n)
    tm[i] = x[i] - y[i] + z[i];
  sort(tm, tm + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[3] += tm[i];
  }
  rep(i, n)
    tm[i] = (x[i]*-1) + y[i] + z[i];
  sort(tm, tm + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[4] += tm[i];
  }
  rep(i, n)
    tm[i] = (x[i]*-1) + y[i] - z[i];
  sort(tm, tm + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[5] += tm[i];
  }
  rep(i, n)
    tm[i] = (x[i]*-1) - y[i] + z[i];
  sort(tm, tm + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[6] += tm[i];
  }
  rep(i, n)
    tm[i] = (x[i]*-1) - y[i] - z[i];
  sort(tm, tm + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[7] += tm[i];
  }
  sort(a, a + 8);
  cout << a[7] << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:42:5: error: reference to 'tm' is ambiguous
   42 |     tm[i] = x[i] + y[i] + z[i];
      |     ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:43:8: error: reference to 'tm' is ambiguous
   43 |   sort(tm, tm + n);
      |        ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:43:12: error: reference to 'tm' is ambiguous
   43 |   sort(tm, tm + n);
      |            ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:45:13: error: reference to 'tm' is ambiguous
   45 |     a[0] += tm[i];
      |             ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:48:5: error: reference to 'tm' is ambiguous
   48 |     tm[i] = x[i] + y[i] - z[i];
      |     ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:49:8: error: reference to 'tm' is ambiguous
   49 |   sort(tm, tm + n);
      |        ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:49:12: error: reference to 'tm' is ambiguous
   49 |   sort(tm, tm + n);
      |            ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:51:13: error: reference to 'tm' is ambiguous
   51 |     a[1] += tm[i];
      |             ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:54:5: error: reference to 'tm' is ambiguous
   54 |     tm[i] = x[i] - y[i] - z[i];
      |     ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:55:8: error: reference to 'tm' is ambiguous
   55 |   sort(tm, tm + n);
      |        ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:55:12: error: reference to 'tm' is ambiguous
   55 |   sort(tm, tm + n);
      |            ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:57:13: error: reference to 'tm' is ambiguous
   57 |     a[2] += tm[i];
      |             ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:60:5: error: reference to 'tm' is ambiguous
   60 |     tm[i] = x[i] - y[i] + z[i];
      |     ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:61:8: error: reference to 'tm' is ambiguous
   61 |   sort(tm, tm + n);
      |        ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:61:12: error: reference to 'tm' is ambiguous
   61 |   sort(tm, tm + n);
      |            ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:63:13: error: reference to 'tm' is ambiguous
   63 |     a[3] += tm[i];
      |             ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:66:5: error: reference to 'tm' is ambiguous
   66 |     tm[i] = (x[i]*-1) + y[i] + z[i];
      |     ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:67:8: error: reference to 'tm' is ambiguous
   67 |   sort(tm, tm + n);
      |        ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:67:12: error: reference to 'tm' is ambiguous
   67 |   sort(tm, tm + n);
      |            ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:69:13: error: reference to 'tm' is ambiguous
   69 |     a[4] += tm[i];
      |             ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:72:5: error: reference to 'tm' is ambiguous
   72 |     tm[i] = (x[i]*-1) + y[i] - z[i];
      |     ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:73:8: error: reference to 'tm' is ambiguous
   73 |   sort(tm, tm + n);
      |        ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:73:12: error: reference to 'tm' is ambiguous
   73 |   sort(tm, tm + n);
      |            ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:75:13: error: reference to 'tm' is ambiguous
   75 |     a[5] += tm[i];
      |             ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:78:5: error: reference to 'tm' is ambiguous
   78 |     tm[i] = (x[i]*-1) - y[i] + z[i];
      |     ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:79:8: error: reference to 'tm' is ambiguous
   79 |   sort(tm, tm + n);
      |        ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:79:12: error: reference to 'tm' is ambiguous
   79 |   sort(tm, tm + n);
      |            ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:81:13: error: reference to 'tm' is ambiguous
   81 |     a[6] += tm[i];
      |             ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:84:5: error: reference to 'tm' is ambiguous
   84 |     tm[i] = (x[i]*-1) - y[i] - z[i];
      |     ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:85:8: error: reference to 'tm' is ambiguous
   85 |   sort(tm, tm + n);
      |        ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];
      |    ^~
a.cc:85:12: error: reference to 'tm' is ambiguous
   85 |   sort(tm, tm + n);
      |            ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:33:4: note:                 'll tm [1000]'
   33 | ll tm[1000];