Language: C++

#include <iostream>
#include <map>
#define ll long long
using namespace std;

void solve(){
  int n; cin >> n;
  map<int, int, greater<int>> mp;
  for(int i = 0; i < n; i++){
    int tmp; cin >> tmp;
    mp[tmp]++;
  }
  for(auto p :mp){
    if(p.second < 2) mp.erase(p); 
  }
  ll ans;
  map<int,int>::iterator itr = mp.begin();
  if(*itr.second >= 4) ans = *itr.second * *itr.second;
  else {
	int a = itr.second;
    itr++;
    int b = itr.second;
    ans = a * b;
  }
  cout << ans << endl;
}

int main(){
  solve();
  return 0; 
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:14:30: error: no matching function for call to 'std::map<int, int, std::greater<int> >::erase(std::pair<const int, int>&)'
   14 |     if(p.second < 2) mp.erase(p);
      |                      ~~~~~~~~^~~
In file included from /usr/include/c++/14/map:63,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_map.h:1080:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::erase(const_iterator) [with _Key = int; _Tp = int; _Compare = std::greater<int>; _Alloc = std::allocator<std::pair<const int, int> >; iterator = std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::greater<int>, std::allocator<std::pair<const int, int> > >::iterator; const_iterator = std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::greater<int>, std::allocator<std::pair<const int, int> > >::const_iterator]'
 1080 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_map.h:1080:28: note:   no known conversion for argument 1 from 'std::pair<const int, int>' to 'std::map<int, int, std::greater<int> >::const_iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::greater<int>, std::allocator<std::pair<const int, int> > >::const_iterator'}
 1080 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1086:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::erase(iterator) [with _Key = int; _Tp = int; _Compare = std::greater<int>; _Alloc = std::allocator<std::pair<const int, int> >; iterator = std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::greater<int>, std::allocator<std::pair<const int, int> > >::iterator]'
 1086 |       erase(iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_map.h:1086:22: note:   no known conversion for argument 1 from 'std::pair<const int, int>' to 'std::map<int, int, std::greater<int> >::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::greater<int>, std::allocator<std::pair<const int, int> > >::iterator'}
 1086 |       erase(iterator __position)
      |             ~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1117:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::erase(const key_type&) [with _Key = int; _Tp = int; _Compare = std::greater<int>; _Alloc = std::allocator<std::pair<const int, int> >; size_type = long unsigned int; key_type = int]'
 1117 |       erase(const key_type& __x)
      |       ^~~~~
/usr/include/c++/14/bits/stl_map.h:1117:29: note:   no known conversion for argument 1 from 'std::pair<const int, int>' to 'const std::map<int, int, std::greater<int> >::key_type&' {aka 'const int&'}
 1117 |       erase(const key_type& __x)
      |             ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:1137:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::erase(const_iterator, const_iterator) [with _Key = int; _Tp = int; _Compare = std::greater<int>; _Alloc = std::allocator<std::pair<const int, int> >; iterator = std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::greater<int>, std::allocator<std::pair<const int, int> > >::iterator; const_iterator = std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::greater<int>, std::allocator<std::pair<const int, int> > >::const_iterator]'
 1137 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_map.h:1137:7: note:   candidate expects 2 arguments, 1 provided
a.cc:18:11: error: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} has no member named 'second'
   18 |   if(*itr.second >= 4) ans = *itr.second * *itr.second;
      |           ^~~~~~
a.cc:18:35: error: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} has no member named 'second'
   18 |   if(*itr.second >= 4) ans = *itr.second * *itr.second;
      |                                   ^~~~~~
a.cc:18:49: error: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} has no member named 'second'
   18 |   if(*itr.second >= 4) ans = *itr.second * *itr.second;
      |                                                 ^~~~~~
a.cc:20:21: error: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} has no member named 'second'
   20 |         int a = itr.second;
      |                     ^~~~~~
a.cc:22:17: error: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} has no member named 'second'
   22 |     int b = itr.second;
      |                 ^~~~~~