Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2000000000;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	map<int,int,greater<int>()>A;
	rep(i, N) {
		int a;cin >> a;
		A[a]++;
	}
	int ans = 0;
	for (auto p : A) {
		if (p.second >= 4) {
			chmax(ans, p.first* p.first);
		}
	}
	int x = 0;int cnt = 0;
	for (auto p : A) {
		if (cnt == 0&&p.second>=2) {
			x = p.first;
			++cnt;
			continue;
		}
		if (p.second >= 2) {
			chmax(ans, p.first* x);
			x = p.first;
		}
	}
	cout << ans << "\n";
	return 0;
}


Compiler output:
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'struct std::_Rb_tree_key_compare<std::greater<int>()>':
/usr/include/c++/14/bits/stl_tree.h:658:9:   required from 'struct 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> > >::_Rb_tree_impl<std::greater<int>(), false>'
  658 |         struct _Rb_tree_impl
      |                ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:704:31:   required from 'class 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> > >'
  704 |       _Rb_tree_impl<_Compare> _M_impl;
      |                               ^~~~~~~
/usr/include/c++/14/bits/stl_map.h:158:17:   required from 'class std::map<int, int, std::greater<int>()>'
  158 |       _Rep_type _M_t;
      |                 ^~~~
a.cc:32:29:   required from here
   32 |         map<int,int,greater<int>()>A;
      |                                    ^
/usr/include/c++/14/bits/stl_tree.h:140:33: error: data member 'std::_Rb_tree_key_compare<std::greater<int>()>::_M_key_compare' invalidly declared function type
  140 |       _Key_compare              _M_key_compare;
      |                                 ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'class 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> > >':
/usr/include/c++/14/bits/stl_map.h:158:17:   required from 'class std::map<int, int, std::greater<int>()>'
  158 |       _Rep_type _M_t;
      |                 ^~~~
a.cc:32:29:   required from here
   32 |         map<int,int,greater<int>()>A;
      |                                    ^
/usr/include/c++/14/bits/stl_tree.h:989:7: error: function returning a function
  989 |       key_comp() const
      |       ^~~~~~~~
In file included from /usr/include/c++/14/map:63:
/usr/include/c++/14/bits/stl_map.h: In instantiation of 'class std::map<int, int, std::greater<int>()>':
a.cc:32:29:   required from here
   32 |         map<int,int,greater<int>()>A;
      |                                    ^
/usr/include/c++/14/bits/stl_map.h:1191:7: error: function returning a function
 1191 |       key_comp() const
      |       ^~~~~~~~