Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>    
#include <cstring>
#include <array>
#include <cctype>
#include <string.h>
#include <vector>
#include <limits.h>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cassert>
#include <algorithm>
#include <functional>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <stdio.h>
#include <bitset>
using namespace std;
#define PI 3.14159265359
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const int INF = 1<<29;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n,m;
ll x[1001],y[1001],z[1001];

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

	cin >> n >> m;

	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i] >> z[i];
	}

	ll dp[1001];

	int ans=0;

	for(int i=0;i<8;i++){
		int a=(i&1)?-1:1;
		int b=(i&2)?-1:1;
		int c=(i&4)?-1:1;

		for(int i=0;i<n;i++){
			dp[i]=a*x[i]+b*y[i]+c*z[i];
		}
		sort(dp,dp+n);
		reverse(dp,dp+n);
		ll cc=0;

		for(int i=0;i<m;i++)
			cc+=dp[i];
		ans=max(ans,cc);
	}

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:24: error: no matching function for call to 'max(int&, ll&)'
   74 |                 ans=max(ans,cc);
      |                     ~~~^~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:74:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   74 |                 ans=max(ans,cc);
      |                     ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:18:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:74:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |                 ans=max(ans,cc);
      |                     ~~~^~~~~~~~