Language: C++

	cin >> n;
	rep(i,n) {
		cin >> a[i];
		(i%2 ? x : y)[a[i]]++;
	}
	each(i,x) {
		if (n/2-i.second<=r) r2 = r, r = n/2-i.second, ri = i.first;
		else if (n/2-i.second<r2) r2 = n/2-i.second;
	}
	each(i,y) {
		if (n/2-i.second<=rr) rr2 = rr, rr = n/2-i.second, rri = i.first;
		else if (n/2-i.second<rr2) rr2 = n/2-i.second;
	}
	int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
	cout << res << endl;
}


Compiler output:
a.cc:1:9: error: 'cin' does not name a type
    1 |         cin >> n;
      |         ^~~
a.cc:2:12: error: expected constructor, destructor, or type conversion before '(' token
    2 |         rep(i,n) {
      |            ^
a.cc:6:13: error: expected constructor, destructor, or type conversion before '(' token
    6 |         each(i,x) {
      |             ^
a.cc:10:13: error: expected constructor, destructor, or type conversion before '(' token
   10 |         each(i,y) {
      |             ^
a.cc:14:20: error: 'ri' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                    ^~
a.cc:14:24: error: 'rri' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                        ^~~
a.cc:14:34: error: 'r' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                                  ^
a.cc:14:40: error: 'rr2' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                                        ^~~
a.cc:14:44: error: 'n' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                                            ^
a.cc:14:36: error: 'min' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                                    ^~~
a.cc:14:54: error: 'n' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                                                      ^
a.cc:14:58: error: 'r2' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                                                          ^~
a.cc:14:50: error: 'min' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                                                  ^~~
a.cc:14:62: error: 'rr' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                                                              ^~
a.cc:14:30: error: 'min' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                              ^~~
a.cc:14:68: error: 'r' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                                                                    ^
a.cc:14:70: error: 'rr' was not declared in this scope
   14 |         int res = (ri==rri ? min(r+min(rr2,n/2), min(n/2,r2)+rr) : r+rr);
      |                                                                      ^~
a.cc:15:9: error: 'cout' does not name a type
   15 |         cout << res << endl;
      |         ^~~~
a.cc:16:1: error: expected declaration before '}' token
   16 | }
      | ^