Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespce std;

int main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  vector<int> odd(5e+1,0),even(5e+1,0);
  for(int i=0;i<n;i+=2) odd[v[i]]++;
  for(int i=1;i<n;i+=2) even[v[i]]++;
  int ido=(int)(max_element(odd.begin(),odd.end())-odd.begin());
  int ide=(int)(max_element(even.begin(),even.end())-even.begin());
  int mo=*max_element(odd.begin(),odd.end());
  int me=*max_element(even.begin(),even.end());
  int ans
  if(ido==ide){
    sort(odd.begin(),odd.end());
    sort(even.begin(),even.end());
    ans=max(mo+*(even.end()-2),me+*(odd.end()-2));
  }
  else{
    ans=mo+me;
  }
  cout<<ans<<endl;
  return 0;
}
    

Compiler output:
a.cc:4:7: error: expected nested-name-specifier before 'namespce'
    4 | using namespce std;
      |       ^~~~~~~~
a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   int n;cin>>n;
      |         ^~~
      |         std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> v(n);
      |   ^~~~~~
a.cc:8:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> v(n);
      |          ^~~
a.cc:9:29: error: 'v' was not declared in this scope
    9 |   for(int i=0;i<n;i++) cin>>v[i];
      |                             ^
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vector<int> odd(5e+1,0),even(5e+1,0);
      |          ^~~
a.cc:11:25: error: 'odd' was not declared in this scope
   11 |   for(int i=0;i<n;i+=2) odd[v[i]]++;
      |                         ^~~
a.cc:11:29: error: 'v' was not declared in this scope
   11 |   for(int i=0;i<n;i+=2) odd[v[i]]++;
      |                             ^
a.cc:12:25: error: 'even' was not declared in this scope
   12 |   for(int i=1;i<n;i+=2) even[v[i]]++;
      |                         ^~~~
a.cc:12:30: error: 'v' was not declared in this scope
   12 |   for(int i=1;i<n;i+=2) even[v[i]]++;
      |                              ^
a.cc:13:29: error: 'odd' was not declared in this scope
   13 |   int ido=(int)(max_element(odd.begin(),odd.end())-odd.begin());
      |                             ^~~
a.cc:13:17: error: 'max_element' was not declared in this scope; did you mean 'std::max_element'?
   13 |   int ido=(int)(max_element(odd.begin(),odd.end())-odd.begin());
      |                 ^~~~~~~~~~~
      |                 std::max_element
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:528:1: note: 'std::max_element' declared here
  528 | max_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~~~
a.cc:14:29: error: 'even' was not declared in this scope
   14 |   int ide=(int)(max_element(even.begin(),even.end())-even.begin());
      |                             ^~~~
a.cc:18:3: error: expected initializer before 'if'
   18 |   if(ido==ide){
      |   ^~
a.cc:23:3: error: 'else' without a previous 'if'
   23 |   else{
      |   ^~~~
a.cc:24:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   24 |     ans=mo+me;
      |     ^~~
      |     abs
a.cc:26:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   26 |   cout<<ans<<endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:26:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   26 |   cout<<ans<<endl;
      |         ^~~
      |         abs
a.cc:26:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   26 |   cout<<ans<<endl;
      |              ^~~~
      |              std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~