Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N;
int A[MAXN];
int cnt[MAXN];
int x1, x2, c1, c2, y1, y2;

int main() {
	register int i;
	scanf("%d", &N);
	for(i = 1; i <= N; ++i)
		scanf("%d", A + i);
	for(i = 1; i <= N; i += 2) {
		++cnt[A[i]];
		if(A[i] != x1 && cnt[A[i]] > cnt[x1])
			x2 = x1, x1 = A[i];
		else
			if(A[i] != x1 && A[i] != x2 && cnt[A[i]] > cnt[x2])
				x2 = A[i];
	}
	c1 = cnt[x1], c2 = cnt[x2];
	memset(cnt, 0, sizeof(cnt));
	for(i = 2; i <= N; i += 2) {
		++cnt[A[i]];
		if(A[i] != y1 && cnt[A[i]] > cnt[y1])
			y2 = y1, y1 = A[i];
		else
			if(A[i] != y1 && A[i] != y2 && cnt[A[i]] > cnt[y2])
				y2 = A[i];
	}
	if(x1 != y1) printf("%d\n", N - c1 - cnt[y1]);
	else if(c2 + cnt[y1] > c1 + cnt[y2]) printf("%d\n", N - c2 - cnt[y1]);
	else printf("%d\n", N - c1 - cnt[y2]);
	return 0;
}

Compiler output:
a.cc:12:21: error: 'int y1' redeclared as different kind of entity
   12 | int x1, x2, c1, c2, y1, y2;
      |                     ^~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/cstdio:41,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
  257 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:15:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 |         register int i;
      |                      ^
a.cc:31:25: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   31 |                 if(A[i] != y1 && cnt[A[i]] > cnt[y1])
      |                    ~~~~~^~~~~
a.cc:31:49: error: invalid types 'int [100010][double(double) noexcept]' for array subscript
   31 |                 if(A[i] != y1 && cnt[A[i]] > cnt[y1])
      |                                                 ^
a.cc:32:30: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
   32 |                         y2 = y1, y1 = A[i];
      |                              ^~
      |                              |
      |                              double (*)(double) noexcept
a.cc:32:37: error: assignment of function 'double y1(double)'
   32 |                         y2 = y1, y1 = A[i];
      |                                  ~~~^~~~~~
a.cc:34:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   34 |                         if(A[i] != y1 && A[i] != y2 && cnt[A[i]] > cnt[y2])
      |                            ~~~~~^~~~~
a.cc:37:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   37 |         if(x1 != y1) printf("%d\n", N - c1 - cnt[y1]);
      |            ~~~^~~~~
a.cc:37:49: error: invalid types 'int [100010][double(double) noexcept]' for array subscript
   37 |         if(x1 != y1) printf("%d\n", N - c1 - cnt[y1]);
      |                                                 ^
a.cc:38:25: error: invalid types 'int [100010][double(double) noexcept]' for array subscript
   38 |         else if(c2 + cnt[y1] > c1 + cnt[y2]) printf("%d\n", N - c2 - cnt[y1]);
      |                         ^
a.cc:38:73: error: invalid types 'int [100010][double(double) noexcept]' for array subscript
   38 |         else if(c2 + cnt[y1] > c1 + cnt[y2]) printf("%d\n", N - c2 - cnt[y1]);
      |                                                                         ^