Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    int a;
    map<long, int> A;
    for(int i = 0; i < n; i++){
        cin >> a;
        A[a]++;
    }
    long w=0,h=0;
    for(map<int, int> :: reverse_iterator it = A.rbegin(), e = A.rend(); it != e; ++it){

        if(it->second >= 4){
            if(w != 0) {h = it->first;}
            else{w = h = it->first;}
            break;
        }else if(it->second >= 2){
            if(w == 0) w = it->first;
            else{h = it->first; break;}
        }
    }

    cout << w * h <<endl;
}

Compiler output:
In file included from /usr/include/c++/14/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h: In instantiation of 'constexpr std::reverse_iterator<_Iterator>::reverse_iterator(const std::reverse_iterator<_Iter>&) [with _Iter = std::_Rb_tree_iterator<std::pair<const long int, int> >; _Iterator = std::_Rb_tree_iterator<std::pair<const int, int> >]':
a.cc:12:57:   required from here
   12 |     for(map<int, int> :: reverse_iterator it = A.rbegin(), e = A.rend(); it != e; ++it){
      |                                                         ^
/usr/include/c++/14/bits/stl_iterator.h:216:9: error: no matching function for call to 'std::_Rb_tree_iterator<std::pair<const int, int> >::_Rb_tree_iterator(const std::_Rb_tree_iterator<std::pair<const long int, int> >&)'
  216 |         _GLIBCXX_NOEXCEPT_IF(noexcept(_Iterator(__x.current)))
      |         ^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:269:7: note: candidate: 'std::_Rb_tree_iterator<_Tp>::_Rb_tree_iterator(_Base_ptr) [with _Tp = std::pair<const int, int>; _Base_ptr = std::_Rb_tree_node_base*]'
  269 |       _Rb_tree_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:269:35: note:   no known conversion for argument 1 from 'const std::_Rb_tree_iterator<std::pair<const long int, int> >' to 'std::_Rb_tree_iterator<std::pair<const int, int> >::_Base_ptr' {aka 'std::_Rb_tree_node_base*'}
  269 |       _Rb_tree_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT
      |                         ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_tree.h:265:7: note: candidate: 'std::_Rb_tree_iterator<_Tp>::_Rb_tree_iterator() [with _Tp = std::pair<const int, int>]'
  265 |       _Rb_tree_iterator() _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:265:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_tree.h:252:12: note: candidate: 'constexpr std::_Rb_tree_iterator<std::pair<const int, int> >::_Rb_tree_iterator(const std::_Rb_tree_iterator<std::pair<const int, int> >&)'
  252 |     struct _Rb_tree_iterator
      |            ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:252:12: note:   no known conversion for argument 1 from 'const std::_Rb_tree_iterator<std::pair<const long int, int> >' to 'const std::_Rb_tree_iterator<std::pair<const int, int> >&'
/usr/include/c++/14/bits/stl_tree.h:252:12: note: candidate: 'constexpr std::_Rb_tree_iterator<std::pair<const int, int> >::_Rb_tree_iterator(std::_Rb_tree_iterator<std::pair<const int, int> >&&)'
/usr/include/c++/14/bits/stl_tree.h:252:12: note:   no known conversion for argument 1 from 'const std::_Rb_tree_iterator<std::pair<const long int, int> >' to 'std::_Rb_tree_iterator<std::pair<const int, int> >&&'
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_iterator.h: In instantiation of 'constexpr std::reverse_iterator<_Iterator>::reverse_iterator(const std::reverse_iterator<_Iter>&) [with _Iter = std::_Rb_tree_iterator<std::pair<const long int, int> >; _Iterator = std::_Rb_tree_iterator<std::pair<const int, int> >]':
a.cc:12:57:   required from here
   12 |     for(map<int, int> :: reverse_iterator it = A.rbegin(), e = A.rend(); it != e; ++it){
      |                                                         ^
/usr/include/c++/14/bits/stl_iterator.h:217:11: error: no matching function for call to 'std::_Rb_tree_iterator<std::pair<const int, int> >::_Rb_tree_iterator(const std::_Rb_tree_iterator<std::pair<const long int, int> >&)'
  217 |         : current(__x.current)
      |           ^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:269:7: note: candidate: 'std::_Rb_tree_iterator<_Tp>::_Rb_tree_iterator(_Base_ptr) [with _Tp = std::pair<const int, int>; _Base_ptr = std::_Rb_tree_node_base*]'
  269 |       _Rb_tree_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:269:35: note:   no known conversion for argument 1 from 'const std::_Rb_tree_iterator<std::pair<const long int, int> >' to 'std::_Rb_tree_iterator<std::pair<const int, int> >::_Base_ptr' {aka 'std::_Rb_tree_node_base*'}
  269 |       _Rb_tree_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT
      |                         ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_tree.h:265:7: note: candidate: 'std::_Rb_tree_iterator<_Tp>::_Rb_tree_iterator() [with _Tp = std::pair<const int, int>]'
  265 |       _Rb_tree_iterator() _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:265:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_tree.h:252:12: note: candidate: 'constexpr std::_Rb_tree_iterator<std::pair<const int, int> >::_Rb_tree_iterator(const std::_Rb_tree_iterator<std::pair<const int, int> >&)'
  252 |     struct _Rb_tree_iterator
      |            ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:252:12: note:   no known conversion for argument 1 from 'const std::_Rb_tree_iterator<std::pair<const long int, int> >' to 'const std::_Rb_tree_iterator<std::pair<const int, int> >&'
/usr/include/c++/14/bits/stl_tree.h:252:12: note: candidate: 'constexpr std::_Rb_tree_iterator<std::pair<const int, int> >::_Rb_tree_iterator(std::_Rb_tree_iterator<std::pair<const int, int> >&&)'
/usr/include/c++/14/bits/stl_tree.h:252:12: note:   no known conversion for argument 1 from 'const std::_Rb_tree_iterator<std::pair<const long int, int> >' to 'std::_Rb_tree_iterator<std::pair<const int, int> >&&'