Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  map<int, int> m1, m2;
  int N; cin >> N;
  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    if (i % 2 == 0) m1[a]++;
    else            m2[a]++;
  }

  for (auto [k, v] : m1) {
    total1 += v;
    if (v11 < v) {
      k1 = k;
      v12 = v11;
      v11 = v;
    } else if (v12 < v) {
      v12 = v;
    }
  }
  for (auto [k, v] : m2) {
    total2 += v;
    if (v21 < v) {
      k2 = k;
      v22 = v21;
      v21 = v;
    } else if (v22 < v) {
      v22 = v;
    }
  }

  if (k1 == k2) {
    cout << max((total1 - v11) + (total2 - v22), (total1 - v12) + (total2 - v21)) << endl;
  } else {
    cout << (total1 - v11) + (total2 - v21) << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 'total1' was not declared in this scope
   29 |     total1 += v;
      |     ^~~~~~
a.cc:30:9: error: 'v11' was not declared in this scope
   30 |     if (v11 < v) {
      |         ^~~
a.cc:31:7: error: 'k1' was not declared in this scope; did you mean 'k'?
   31 |       k1 = k;
      |       ^~
      |       k
a.cc:32:7: error: 'v12' was not declared in this scope
   32 |       v12 = v11;
      |       ^~~
a.cc:34:16: error: 'v12' was not declared in this scope
   34 |     } else if (v12 < v) {
      |                ^~~
a.cc:39:5: error: 'total2' was not declared in this scope
   39 |     total2 += v;
      |     ^~~~~~
a.cc:40:9: error: 'v21' was not declared in this scope
   40 |     if (v21 < v) {
      |         ^~~
a.cc:41:7: error: 'k2' was not declared in this scope; did you mean 'k'?
   41 |       k2 = k;
      |       ^~
      |       k
a.cc:42:7: error: 'v22' was not declared in this scope
   42 |       v22 = v21;
      |       ^~~
a.cc:44:16: error: 'v22' was not declared in this scope
   44 |     } else if (v22 < v) {
      |                ^~~
a.cc:49:7: error: 'k1' was not declared in this scope; did you mean 'm1'?
   49 |   if (k1 == k2) {
      |       ^~
      |       m1
a.cc:49:13: error: 'k2' was not declared in this scope; did you mean 'm2'?
   49 |   if (k1 == k2) {
      |             ^~
      |             m2
a.cc:50:18: error: 'total1' was not declared in this scope
   50 |     cout << max((total1 - v11) + (total2 - v22), (total1 - v12) + (total2 - v21)) << endl;
      |                  ^~~~~~
a.cc:50:27: error: 'v11' was not declared in this scope
   50 |     cout << max((total1 - v11) + (total2 - v22), (total1 - v12) + (total2 - v21)) << endl;
      |                           ^~~
a.cc:50:35: error: 'total2' was not declared in this scope
   50 |     cout << max((total1 - v11) + (total2 - v22), (total1 - v12) + (total2 - v21)) << endl;
      |                                   ^~~~~~
a.cc:50:44: error: 'v22' was not declared in this scope
   50 |     cout << max((total1 - v11) + (total2 - v22), (total1 - v12) + (total2 - v21)) << endl;
      |                                            ^~~
a.cc:50:60: error: 'v12' was not declared in this scope
   50 |     cout << max((total1 - v11) + (total2 - v22), (total1 - v12) + (total2 - v21)) << endl;
      |                                                            ^~~
a.cc:50:77: error: 'v21' was not declared in this scope
   50 |     cout << max((total1 - v11) + (total2 - v22), (total1 - v12) + (total2 - v21)) << endl;
      |                                                                             ^~~
a.cc:52:14: error: 'total1' was not declared in this scope
   52 |     cout << (total1 - v11) + (total2 - v21) << endl;
      |              ^~~~~~
a.cc:52:23: error: 'v11' was not declared in this scope
   52 |     cout << (total1 - v11) + (total2 - v21) << endl;
      |                       ^~~
a.cc:52:31: error: 'total2' was not declared in this scope
   52 |     cout << (total1 - v11) + (total2 - v21) << endl;
      |                               ^~~~~~
a.cc:52:40: error: 'v21' was not declared in this scope
   52 |     cout << (total1 - v11) + (total2 - v21) << endl;
      |                                        ^~~