Language: C++

#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
ll b1,b2,b3,b4,b5,b6,b7,b8;

int main(){
    int N, M;
    cin >> N >> M;
    vector<ll> x(N);
    vector<ll> y(N);
    vector<ll> z(N);
    
    vector<ll> a1(N);
    vector<ll> a2(N);
    vector<ll> a3(N);
    vector<ll> a4(N);
    vector<ll> a5(N);
    vector<ll> a6(N);
    vector<ll> a7(N);
    vector<ll> a8(N);
    for(int i = 0; i < N; i++){
        a1.at(i) = x[i] + y[i] + z[i];
        a2.at(i) = x[i] + y[i] - z[i];
        a3.at(i) = x[i] - y[i] + z[i];
        a4.at(i) = x[i] - y[i] - z[i];
        a5.at(i) = -x[i] + y[i] + z[i];
        a6.at(i) = -x[i] + y[i] - z[i];
        a7.at(i) = -x[i] - y[i] + z[i];
        a8.at(i) = -x[i] - y[i] - z[i];
    }
    sort(a1.begin(), a1.end());
    reverse(a1.begin(), a1.end());
    
    sort(a2.begin(), a2.end());
    reverse(a2.begin(), a2.end());
    
    sort(a3.begin(), a3.end());
    reverse(a3.begin(), a3.end());
    
    sort(a4.begin(), a4.end());
    reverse(a4.begin(), a4.end());
    
    sort(a5.begin(), a5.end());
    reverse(a5.begin(), a5.end());
    
    sort(a6.begin(), a6.end());
    reverse(a6.begin(), a6.end());
    
    sort(a7.begin(), a7.end());
    reverse(a7.begin(), a7.end());
    
    sort(a8.begin(), a8.end());
    reverse(a8.begin(), a8.end());
    
    
    for(int i = 0; i < M; i++){
        b1 += a1[i];
        b2 += a2[i];
        b3 += a3[i];
        b4 += a4[i];
        b5 += a5[i];
        b6 += a6[i];
        b7 += a7[i];
        b8 += a8[i];
    }
    ll a = max(b1, b2);
    ll a = max(ans, b3);
    ll a = max(ans, b4);
    ll a = max(ans, b5);
    ll a = max(ans, b6);
    ll a = max(ans, b7);
    ll a = max(ans, b8);
    cout << a << endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:78:8: error: redeclaration of 'll a'
   78 |     ll a = max(ans, b3);
      |        ^
a.cc:77:8: note: 'll a' previously declared here
   77 |     ll a = max(b1, b2);
      |        ^
a.cc:78:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   78 |     ll a = max(ans, b3);
      |                ^~~
      |                abs
a.cc:79:8: error: redeclaration of 'll a'
   79 |     ll a = max(ans, b4);
      |        ^
a.cc:77:8: note: 'll a' previously declared here
   77 |     ll a = max(b1, b2);
      |        ^
a.cc:80:8: error: redeclaration of 'll a'
   80 |     ll a = max(ans, b5);
      |        ^
a.cc:77:8: note: 'll a' previously declared here
   77 |     ll a = max(b1, b2);
      |        ^
a.cc:81:8: error: redeclaration of 'll a'
   81 |     ll a = max(ans, b6);
      |        ^
a.cc:77:8: note: 'll a' previously declared here
   77 |     ll a = max(b1, b2);
      |        ^
a.cc:82:8: error: redeclaration of 'll a'
   82 |     ll a = max(ans, b7);
      |        ^
a.cc:77:8: note: 'll a' previously declared here
   77 |     ll a = max(b1, b2);
      |        ^
a.cc:83:8: error: redeclaration of 'll a'
   83 |     ll a = max(ans, b8);
      |        ^
a.cc:77:8: note: 'll a' previously declared here
   77 |     ll a = max(b1, b2);
      |        ^