Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  vector<tuple<int64_t,int64_t,int64_t>>A(N);
  for(int i=0;i<N;i++){
  int64_t x,y,z;
    cin>>x>>y>>z;
    tuple<int64_t,int64_tint64_t>t(x,y,z);
    A.at(i)=t;
   }int64_t ans=0;
  for(int bit=0;bit<(1<<3);i++){
  vector<int64_t>B(N);
    for(int i=0;i<N;i++){
      tuple t=A.at(i);
      int64_t x=get<0>(t);
      int64_t y=get<1>(t);
      int64_t z=get<2>(t);
      int64_t b=x+y+z;
    for(int j=0;j<3;j++){
  if(bit&(1<<j))
    b-=2*get<j>(t);
  } B.at(i)=b;
    } sort(B.begin(),B.end());
    reverse(B.begin(),B.end());
    int64_t pos=0;
    for(int k=0;k<M;k++)
      pos+=B.at(k);
    if(ans<pos)
      ans=pos;
  }cout<<ans<<endl;
     return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:19: error: 'int64_tint64_t' was not declared in this scope; did you mean 'int_fast64_t'?
   10 |     tuple<int64_t,int64_tint64_t>t(x,y,z);
      |                   ^~~~~~~~~~~~~~
      |                   int_fast64_t
a.cc:10:33: error: template argument 2 is invalid
   10 |     tuple<int64_t,int64_tint64_t>t(x,y,z);
      |                                 ^
a.cc:10:41: error: expression list treated as compound expression in initializer [-fpermissive]
   10 |     tuple<int64_t,int64_tint64_t>t(x,y,z);
      |                                         ^
a.cc:11:13: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<long int, long int, long int> >, std::tuple<long int, long int, long int> >::value_type' {aka 'std::tuple<long int, long int, long int>'} and 'int')
   11 |     A.at(i)=t;
      |             ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/tuple:1930:9: note: candidate: 'template<class ... _UElements> std::__enable_if_t<((bool)__assignable<const _UElements& ...>()), std::tuple< <template-parameter-1-1> >&> std::tuple< <template-parameter-1-1> >::operator=(const std::tuple<_Args1 ...>&) [with _UElements = {_UElements ...}; _Elements = {long int, long int, long int}]'
 1930 |         operator=(const tuple<_UElements...>& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:1930:9: note:   template argument deduction/substitution failed:
a.cc:11:13: note:   mismatched types 'const std::tuple<_UTypes ...>' and 'int'
   11 |     A.at(i)=t;
      |             ^
/usr/include/c++/14/tuple:1940:9: note: candidate: 'template<class ... _UElements> std::__enable_if_t<((bool)__assignable<_UElements ...>()), std::tuple< <template-parameter-1-1> >&> std::tuple< <template-parameter-1-1> >::operator=(std::tuple<_Args1 ...>&&) [with _UElements = {_UElements ...}; _Elements = {long int, long int, long int}]'
 1940 |         operator=(tuple<_UElements...>&& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:1940:9: note:   template argument deduction/substitution failed:
a.cc:11:13: note:   mismatched types 'std::tuple<_UTypes ...>' and 'int'
   11 |     A.at(i)=t;
      |             ^
/usr/include/c++/14/tuple:1907:7: note: candidate: 'std::tuple< <template-parameter-1-1> >& std::tuple< <template-parameter-1-1> >::operator=(std::__conditional_t<((bool)__assignable<const _Elements& ...>()), const std::tuple< <template-parameter-1-1> >&, const std::__nonesuch&>) [with _Elements = {long int, long int, long int}; std::__conditional_t<((bool)__assignable<const _Elements& ...>()), const std::tuple< <template-parameter-1-1> >&, const std::__nonesuch&> = const std::tuple<long int, long int, long int>&]'
 1907 |       operator=(__conditional_t<__assignable<const _Elements&...>(),
      |       ^~~~~~~~
/usr/include/c++/14/tuple:1909:52: note:   no known conversion for argument 1 from 'int' to 'std::__conditional_t<true, const std::tuple<long int, long int, long int>&, const std::__nonesuch&>' {aka 'const std::tuple<long int, long int, long int>&'}
 1907 |       operator=(__conditional_t<__assignable<const _Elements&...>(),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1908 |                                 const tuple&,
      |                                 ~~~~~~~~~~~~~       
 1909 |                                 const __nonesuch&> __in)
      |                                 ~~~~~~~~~~~~~~~~~~~^~~~
/usr/include/c++/14/tuple:1918:7: note: candidate: 'std::tuple< <template-parameter-1-1> >& std::tuple< <template-parameter-1-1> >::operator=(std::__conditional_t<((bool)__assignable<_Elements ...>()), std::tuple< <template-parameter-1-1> >&&, std::__nonesuch&&>) [with _Elements = {long int, long int, long int}; std::__conditional_t<((bool)__assignable<_Elements ...>()), std::tuple< <template-parameter-1-1> >&&, std::__nonesuch&&> = std::tuple<long int, long int, long int>&&]'
 1918 |       operator=(__conditional_t<__assignable<_Elements...>(),
      |       ^~~~~~~~
/usr/include/c++/14/tuple:1920:47: note:   no known conversion for argument 1 from 'int' to 'std::__conditional_t<true, std::tuple<long int, long int, long int>&&, std::__nonesuch&&>' {aka 'std::tuple<long int, long int, long int>&&'}
 1918 |       operator=(__conditional_t<__assignable<_Elements...>(),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1919 |                                 tuple&&,
      |                                 ~~~~~~~~       
 1920 |                                 __nonesuch&&> __in)
      |                                 ~~~~~~~~~~~~~~^~~~
a.cc:13:28: error: 'i' was not declared in this scope
   13 |   for(int bit=0;bit<(1<<3);i++){
      |                            ^
a.cc:23:16: error: no matching function for call to 'get<j>(std::tuple<long int, long int, long int>&)'
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
 1250 |     get(pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note:   template argument deduction/substitution failed:
a.cc:23:16: error: the value of 'j' is not usable in a constant expression
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
a.cc:21:13: note: 'int j' is not const
   21 |     for(int j=0;j<3;j++){
      |             ^
a.cc:23:16: note: in template argument for type 'long unsigned int'
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
 1255 |     get(pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note:   template argument deduction/substitution failed:
a.cc:23:16: error: the value of 'j' is not usable in a constant expression
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
a.cc:21:13: note: 'int j' is not const
   21 |     for(int j=0;j<3;j++){
      |             ^
a.cc:23:16: note: in template argument for type 'long unsigned int'
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
 1260 |     get(const pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note:   template argument deduction/substitution failed:
a.cc:23:16: error: the value of 'j' is not usable in a constant expression
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
a.cc:21:13: note: 'int j' is not const
   21 |     for(int j=0;j<3;j++){
      |             ^
a.cc:23:16: note: in template argument for type 'long unsigned int'
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
 1265 |     get(const pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note:   template argument deduction/substitution failed:
a.cc:23:16: error: the value of 'j' is not usable in a constant expression
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
a.cc:21:13: note: 'int j' is not const
   21 |     for(int j=0;j<3;j++){
      |             ^
a.cc:23:16: note: in template argument for type 'long unsigned int'
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
 2445 |     get(tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2445:5: note:   template argument deduction/substitution failed:
a.cc:23:16: error: the value of 'j' is not usable in a constant expression
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
a.cc:21:13: note: 'int j' is not const
   21 |     for(int j=0;j<3;j++){
      |             ^
a.cc:23:16: note: in template argument for type 'long unsigned int'
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
 2451 |     get(const tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2451:5: note:   template argument deduction/substitution failed:
a.cc:23:16: error: the value of 'j' is not usable in a constant expression
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
a.cc:21:13: note: 'int j' is not const
   21 |     for(int j=0;j<3;j++){
      |             ^
a.cc:23:16: note: in template argument for type 'long unsigned int'
   23 |     b-=2*get<j>(t);
      |          ~~~~~~^~~
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
 2457 |     get(tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2457:5: note:   template argument deduction/substitution failed:
a.cc:23:16: error: the value of 'j' is not