Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;
 
int main() {
    int n,k;
    cin >> n;
    vector<int> u, v;
    for (int i = 0; i < n;i++) {
        cin >> k;
        if (i % 2 == 0) u.push_back(k);
        else v.push_back(k);
    }
    sort(u.begin(), u.end());
    sort(v.begin(), v.end());
    int s1=1, s2=1,s3=1,s4=1 m1=0, m2=0,m3=0,m4=0,d1,d2;
    for (int i = 0; i < v.size() - 1;i++) {
        if (v[i] == v[i + 1]) s1++;
        else s1 = 1;
        if (m1 < s1) {
            m1 = s1;
            d1 = v[i];
        }       
        if (u[i] == u[i + 1]) s2++;
        else s2 = 1;
        if (m2 < s2) {
            m2 = s2;
            d2 = u[i];
        }
    }
    for(int i=0; i<v.size();i++){
      if(v[i]==v[i+1] && v[i]!=d1) s3++;
      else s3=1;
      if(s3>m3) m3=s3;
      if(u[i]==u[i+1] &&u[i]!=d2) s4++;
      else s4=1;
      if(s4>m4) m4=s4;
    }
    if (d1 == d2) cout << n - min(m1 + m4, m2 + m3) << endl;
    else cout << n - m1 - m2 << endl;
}
    
 

Compiler output:
a.cc: In function 'int main()':
a.cc:27:30: error: expected ',' or ';' before 'm1'
   27 |     int s1=1, s2=1,s3=1,s4=1 m1=0, m2=0,m3=0,m4=0,d1,d2;
      |                              ^~
a.cc:31:13: error: 'm1' was not declared in this scope; did you mean 's1'?
   31 |         if (m1 < s1) {
      |             ^~
      |             s1
a.cc:33:13: error: 'd1' was not declared in this scope; did you mean 's1'?
   33 |             d1 = v[i];
      |             ^~
      |             s1
a.cc:37:13: error: 'm2' was not declared in this scope; did you mean 's2'?
   37 |         if (m2 < s2) {
      |             ^~
      |             s2
a.cc:39:13: error: 'd2' was not declared in this scope; did you mean 's2'?
   39 |             d2 = u[i];
      |             ^~
      |             s2
a.cc:43:32: error: 'd1' was not declared in this scope; did you mean 's1'?
   43 |       if(v[i]==v[i+1] && v[i]!=d1) s3++;
      |                                ^~
      |                                s1
a.cc:45:13: error: 'm3' was not declared in this scope; did you mean 's3'?
   45 |       if(s3>m3) m3=s3;
      |             ^~
      |             s3
a.cc:46:31: error: 'd2' was not declared in this scope; did you mean 's2'?
   46 |       if(u[i]==u[i+1] &&u[i]!=d2) s4++;
      |                               ^~
      |                               s2
a.cc:48:13: error: 'm4' was not declared in this scope; did you mean 's4'?
   48 |       if(s4>m4) m4=s4;
      |             ^~
      |             s4
a.cc:50:9: error: 'd1' was not declared in this scope; did you mean 's1'?
   50 |     if (d1 == d2) cout << n - min(m1 + m4, m2 + m3) << endl;
      |         ^~
      |         s1
a.cc:50:15: error: 'd2' was not declared in this scope; did you mean 's2'?
   50 |     if (d1 == d2) cout << n - min(m1 + m4, m2 + m3) << endl;
      |               ^~
      |               s2
a.cc:50:35: error: 'm1' was not declared in this scope; did you mean 's1'?
   50 |     if (d1 == d2) cout << n - min(m1 + m4, m2 + m3) << endl;
      |                                   ^~
      |                                   s1
a.cc:50:40: error: 'm4' was not declared in this scope; did you mean 's4'?
   50 |     if (d1 == d2) cout << n - min(m1 + m4, m2 + m3) << endl;
      |                                        ^~
      |                                        s4
a.cc:50:44: error: 'm2' was not declared in this scope; did you mean 's2'?
   50 |     if (d1 == d2) cout << n - min(m1 + m4, m2 + m3) << endl;
      |                                            ^~
      |                                            s2
a.cc:50:49: error: 'm3' was not declared in this scope; did you mean 's3'?
   50 |     if (d1 == d2) cout << n - min(m1 + m4, m2 + m3) << endl;
      |                                                 ^~
      |                                                 s3
a.cc:51:22: error: 'm1' was not declared in this scope; did you mean 's1'?
   51 |     else cout << n - m1 - m2 << endl;
      |                      ^~
      |                      s1
a.cc:51:27: error: 'm2' was not declared in this scope; did you mean 's2'?
   51 |     else cout << n - m1 - m2 << endl;
      |                           ^~
      |                           s2