Language: C++

#include<bits/stdc++.h>
using namespace std;
map<long long ,int > m ;
int n ;
int main(){
    scanf("%d",&n) ;
    for (int i=0;i<n;i++){
        long long  d ;
        scanf("%lld",&d) ;
        m[d]++ ;
    }
    int co = 0 ;
    long long  area = 1;
    map<int,int> ::reverse_iterator itr ;
    for (itr=m.rbegin();itr!=m.rend() && co!=4;itr++)
    {
        if(itr->second <2)
            continue ;
        else if(itr->second >=2 ){
            if(itr->second >=4 && co ==0 ){
                co = 4;
                area =  pow(itr->first,2) ;
            }
            else{
                area *= itr->first ;
                co +=2 ;
            }
        }
    }
    if(co!=4)
        printf("0");
    else
        printf("%lld",area ) ;
}


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>& std::reverse_iterator<_Iterator>::operator=(const std::reverse_iterator<_Iter>&) [with _Iter = std::_Rb_tree_iterator<std::pair<const long long int, int> >; _Iterator = std::_Rb_tree_iterator<std::pair<const int, int> >]':
a.cc:15:23:   required from here
   15 |     for (itr=m.rbegin();itr!=m.rend() && co!=4;itr++)
      |                       ^
/usr/include/c++/14/bits/stl_iterator.h:229:9: error: no match for 'operator=' (operand types are 'std::_Rb_tree_iterator<std::pair<const int, int> >' and 'const std::_Rb_tree_iterator<std::pair<const long long int, int> >')
  229 |         _GLIBCXX_NOEXCEPT_IF(noexcept(current = __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:252:12: note: candidate: 'constexpr std::_Rb_tree_iterator<std::pair<const int, int> >& std::_Rb_tree_iterator<std::pair<const int, int> >::operator=(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 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> >& std::_Rb_tree_iterator<std::pair<const int, int> >::operator=(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 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>& std::reverse_iterator<_Iterator>::operator=(const std::reverse_iterator<_Iter>&) [with _Iter = std::_Rb_tree_iterator<std::pair<const long long int, int> >; _Iterator = std::_Rb_tree_iterator<std::pair<const int, int> >]':
a.cc:15:23:   required from here
   15 |     for (itr=m.rbegin();itr!=m.rend() && co!=4;itr++)
      |                       ^
/usr/include/c++/14/bits/stl_iterator.h:231:19: error: no match for 'operator=' (operand types are 'std::_Rb_tree_iterator<std::pair<const int, int> >' and 'const std::_Rb_tree_iterator<std::pair<const long long int, int> >')
  231 |           current = __x.current;
      |           ~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:252:12: note: candidate: 'constexpr std::_Rb_tree_iterator<std::pair<const int, int> >& std::_Rb_tree_iterator<std::pair<const int, int> >::operator=(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 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> >& std::_Rb_tree_iterator<std::pair<const int, int> >::operator=(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 long int, int> >' to 'std::_Rb_tree_iterator<std::pair<const int, int> >&&'
/usr/include/c++/14/bits/stl_iterator.h: In instantiation of 'constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&) [with _IteratorL = _Rb_tree_iterator<pair<const int, int> >; _IteratorR = _Rb_tree_iterator<pair<const long long int, int> >]':
a.cc:15:37:   required from here
   15 |     for (itr=m.rbegin();itr!=m.rend() && co!=4;itr++)
      |                                     ^
/usr/include/c++/14/bits/stl_iterator.h:502:25: error: no match for 'operator!=' (operand types are 'std::reverse_iterator<std::_Rb_tree_iterator<std::pair<const int, int> > >::iterator_type' and 'std::reverse_iterator<std::_Rb_tree_iterator<std::pair<const long long int, int> > >::iterator_type')
  502 |     { return __x.base() != __y.base(); }
      |              ~~~~~~~~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1052 |     operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator.h:502:25: note:   'std::reverse_iterator<std::_Rb_tree_iterator<std::pair<const int, int> > >::iterator_type' is not derived from 'const std::pair<_T1, _T2>'
  502 |     { return __x.base() != __y.base(); }
      |              ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  455 |     operator!=(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator.h:502:25: note:   'std::reverse_iterator<std::_Rb_tree_iterator<std::pair<const int, int> > >::iterator_type' is not derived from 'const std::reverse_iterator<_Iterator>'
  502 |     { return __x.base() != __y.base(); }
      |              ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  500 |     operator!=(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator.h:502:25: note:   'std::reverse_iterator<std::_Rb_tree_iterator<std::pair<const int, int> > >::iterator_type' is not derived from 'const std::reverse_iterator<_Iterator>'
  502 |     { return __x.base() != __y.base(); }
      |              ~~~~~~~~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181:
/usr/include/c++/14/bits/regex.h:1132:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
 1132 |     operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1132:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator.h:502:25: note:   'std::reverse_iterator<std::_Rb_tree_iterator<std::pair<const int, int> > >::iterator_type' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  502 |     { return __x.base() != __y.base(); }
      |              ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1212:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
 1212 |     operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1212:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator.h:502:25: note:   'std::reverse_iterator<std::_Rb_tree_iterator<std::pair<const int, int> > >::iterator_type' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
  502 |     { return __x.base() != __y.base(); }
      |              ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1305:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1305 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1305:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator.h:502:25: note:   'std::reverse_iterator<std::_Rb_tree_iterator<std::pair<const int, int> > >::iterator_type' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  502 |     { return __x.base() != __y.base(); }
      |              ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1379:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
 1379 |     operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1379:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator.h:502:25: note:   'std::reverse_iterator<std::_Rb_tree_iterator<std::pair<const long long int, int> > >::iterator_type' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  502 |     { return __x.base() != __y.base(); }
      |              ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1473:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
 1473 |     operator!=(const sub_matc