Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(){
	long n, a;
	long a[100000];
	vector<long> v;
	memset(a, 0, sizeof(a));

	cin >> n;

	for(int i = 0; i < n ; i++){
		cin >> k;
		a[k-1]++;
	}

	for(int i = 0; i < n ; i++){
		if(a[i]){
			v.push_back(a[i]);
		}
	}	

	sort(v.begin, v.end());

	cout << n - (v[v.size-1] + v[v.size-2]) << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:14: error: conflicting declaration 'long int a [100000]'
    7 |         long a[100000];
      |              ^
a.cc:6:17: note: previous declaration as 'long int a'
    6 |         long n, a;
      |                 ^
a.cc:9:16: error: invalid conversion from 'long int' to 'void*' [-fpermissive]
    9 |         memset(a, 0, sizeof(a));
      |                ^
      |                |
      |                long int
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
a.cc:14:24: error: 'k' was not declared in this scope
   14 |                 cin >> k;
      |                        ^
a.cc:19:21: error: invalid types 'long int[int]' for array subscript
   19 |                 if(a[i]){
      |                     ^
a.cc:20:38: error: invalid types 'long int[int]' for array subscript
   20 |                         v.push_back(a[i]);
      |                                      ^
a.cc:24:13: error: no matching function for call to 'sort(<unresolved overloaded function type>, std::vector<long int>::iterator)'
   24 |         sort(v.begin, v.end());
      |         ~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<long int*, vector<long int> >]'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:32: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |          ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 2 provided
a.cc:26:26: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long int; _Alloc = std::allocator<long int>; size_type = long unsigned int]' (did you forget the '()' ?)
   26 |         cout << n - (v[v.size-1] + v[v.size-2]) << endl;
      |                        ~~^~~~
      |                              ()
a.cc:26:40: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long int; _Alloc = std::allocator<long int>; size_type = long unsigned int]' (did you forget the '()' ?)
   26 |         cout << n - (v[v.size-1] + v[v.size-2]) << endl;
      |                                      ~~^~~~
      |                                            ()