stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



typedef long long int ll;

typedef tree< ll, null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



const ll mod = 1e9 + 7;



int main()

{

  ios_base::sync_with_stdio(false);

  cout.tie(0);cin.tie(0);



  string s;

  cin >> s;

  ll n = s.length();

  vector < ll > dp1(2019, 0), dp2(2019, 0);

  dp1[s[0] - '0'] = 1;

  ll ans = 0;

  for(int i = 1; i < n; i++){

    ll num = s[i] - '0';

    dp2[num] = 1;

    for(int j = 0; j < 2019; j++){

      dp2[(10 * j + num) % 2019] += dp1[j];

    }

    ans += dp2[0];

    dp1 = dp2;

    dp2.assign(2019, 0);

  }



  cout << ans << '\n';

}


// Faster C++ solution for the same problem (measured speedup: 1.1892584481811848x):
#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



typedef long long int ll;

typedef tree< ll, null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



ll mod;



ll pwr(ll a, ll b){

  ll res = 1;

  while(b > 0){

    if(b & 1) res = (res * a) % mod;

    a = (a * a) % mod;

    b >>= 1;

  }

  return res;

}



int main()

{

  ios_base::sync_with_stdio(false);

  cout.tie(0);cin.tie(0);



  string s;

  cin >> s;

  ll n = s.length();



  mod = 2019;



  vector < ll > dp(2019, 0);

  ll x = 0, ans = 0;

  dp[0] = 1;

  for(int i = 0; i < n; i++){

    x = (x * 10 + (s[i] - '0')) % 2019;

    ll val = x * pwr(10, n - i - 1);

    val %= 2019;

    ans += dp[val];

    dp[val]++;

  }



  cout << ans << endl;

}
// Slower C++ solution:
#include <iostream>

#include <string>

#include <vector>



using namespace std;



int main(void) {

    string S;

    cin >> S;



    int64_t ans = 0;

    vector<int64_t> v0(2019), v1(2019);

    for(int i=0; i<S.size(); i++) {

        for(int j=0; j<2019; j++) {

            v1[(10*j + S[i] - '0')%2019] += v0[j];

        }

        v1[S[i] - '0']++;

        ans += v1[0];

        swap(v0, v1);

        fill(v1.begin(), v1.end(), 0);

    }



    cout << ans << endl;

    // vector<int[2019]> v(S.size()+1);

    // for(int i=0; i<S.size(); i++) {

    //     for(int j=0; j<2019; j++) {

    //         v[i+1][(j*10 + S[i] - '0')%2019] += v[i][j];

    //     }

    //     v[i+1][S[i] - '0']++;

    // }



    // int64_t ans = 0;

    // for(int i=0; i<=S.size(); i++) {

    //     ans += v[i][0];

    // }



    // cout << ans << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.1143148455685743x):
#include <iostream>

#include <string>

#include <algorithm>

#include <map>



using namespace std;



template< typename T >

T mod_pow(T x, T n, const T &p) {

  T ret = 1;

  while(n > 0) {

    if(n & 1) (ret *= x) %= p;

    (x *= x) %= p;

    n >>= 1;

  }

  return ret;

}



int main(void) {

    string S;

    cin >> S;



    map<int,int> mp;

    reverse(S.begin(), S.end());

    int t = 0;

    for(int i=0; i<S.size(); i++) {

        t += (S[i]-'0') * mod_pow(10, i, 2019);

        t %= 2019;

        mp[t]++;

    }



    int ans = 0;

    for(auto [key, val]: mp) {

        ans += val*(val-1)/2;

    }



    cout << ans + mp[0] << endl;

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string>

#include <vector>



using namespace std;



int main(void) {

    string S;

    cin >> S;



    int64_t ans = 0;

    vector<int64_t> v0(2019), v1(2019);

    for(int i=0; i<S.size(); i++) {

        for(int j=0; j<2019; j++) {

            v1[(10*j + S[i] - '0')%2019] += v0[j];

        }

        v1[S[i] - '0']++;

        ans += v1[0];

        swap(v0, v1);

        fill(v1.begin(), v1.end(), 0);

    }



    cout << ans << endl;

    // vector<int[2019]> v(S.size()+1);

    // for(int i=0; i<S.size(); i++) {

    //     for(int j=0; j<2019; j++) {

    //         v[i+1][(j*10 + S[i] - '0')%2019] += v[i][j];

    //     }

    //     v[i+1][S[i] - '0']++;

    // }



    // int64_t ans = 0;

    // for(int i=0; i<=S.size(); i++) {

    //     ans += v[i][0];

    // }



    // cout << ans << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.115996973609835x):
#include <iostream>

#include <string>

#include <vector>



using namespace std;



int main(void) {

    string S;

    cin >> S;



    int N = S.size();

    int P = 2019;

    vector<int> v(P);



    int t = 0;

    int ten = 1;

    for(int i=0; i<N; i++) {

        t += (S[N-1-i]-'0') * ten;

        ten *= 10;

        t %= P;

        ten %= P;

        v[t]++;

    }



    int ans = 0;

    for(auto e: v) {

        ans += e*(e-1)/2;

    }



    cout << ans + v[0] << endl;

    return 0;

}
// Slower C++ solution:


#include<vector>

#include<iostream>

#include<algorithm>

using namespace std;

bool Sort(long long a, long long b)

{

	return a > b;

}

int main()

{

	int num;

	while (cin >> num)

	{

		vector<long long> arr(num);

		for (int i = 0; i < num; i++)

			cin >> arr[i];

		sort(arr.begin(), arr.end(), Sort);



		long long a = 0, b = 0, temp = arr[0];

		for (int i = 1; i < num; i++)

		{

			if (temp == arr[i])

			{

				if (a < arr[i])

				{

					a = arr[i];

				}

				else if (b < arr[i])

				{

					b = arr[i];

				}

				temp = -1;

			}

			else temp = arr[i];

		}

		cout << a*b << endl;

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.27728579626722x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int a[1000000];

int main()

{

    int n;

    while (~scanf("%d",&n))

    {

        for(int i=0; i<n; i++)

        {

            int te;

            scanf("%d",&a[i]);

        }

        if(n<4)

        {

            printf("0\n");

            continue;

        }

        sort(a,a+n);

        int c=0;

        int flag=0;

        int k[3];

        for(int i=n-2; i>=0; i--)

        {

            if(a[i+1]==a[i])

            {

                k[c]=a[i];

                i--;

                c++;

            }

            if(c==2)

            {

                break;

            }

            if(i==0)

            {

                printf("0\n");

                flag=1;

                break;

            }

        }

        if(!flag)

        {

            long long r;

            r=k[0]*k[1];

            printf("%lld\n",r);

//            printf("%d×%d rectangle can be formed.\n",k[1],k[0]);

        }

    }

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define ll long long

#define maxn 100005

using namespace std;

ll n;

ll a[maxn];

bool compare(ll x,ll y)

{

    return x>y;

}

int main()

{

    while(~scanf("%lld",&n))

    {

        ll i;

        for(i=0;i<n;i++)

            scanf("%lld",&a[i]);

        sort(a,a+n,compare);

        ll b[3];int step=0;

        b[0]=0;b[1]=0;b[2]=0;

        for(i=0;i<n-1;i++)

        {

            if(a[i]==a[i+1])

            {

                b[++step]=a[i];

                i++;

                if(step==2) break;

            }

        }

        printf("%lld\n",b[1]*b[2]);

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.1507837556768035x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int a[1000000];

int main()

{

    int n;

    while (~scanf("%d",&n))

    {

        for(int i=0; i<n; i++)

        {

            int te;

            scanf("%d",&a[i]);

        }

        if(n<4)

        {

            printf("0\n");

            continue;

        }

        sort(a,a+n);

        int c=0;

        int flag=0;

        int k[3];

        for(int i=n-2; i>=0; i--)

        {

            if(a[i+1]==a[i])

            {

                k[c]=a[i];

                i--;

                c++;

            }

            if(c==2)

            {

                break;

            }

            if(i==0)

            {

                printf("0\n");

                flag=1;

                break;

            }

        }

        if(!flag)

        {

            long long r;

            r=k[0]*k[1];

            printf("%lld\n",r);

//            printf("%d×%d rectangle can be formed.\n",k[1],k[0]);

        }

    }

}
// Slower C++ solution:
#include <cstdio>

#include <map>

#include <algorithm>

using namespace std;

typedef long long ll;

int main()

{

	int n;

	while (~scanf("%d", &n))

	{

		map<ll, int> m;

		ll x, pre = -1, maxn = -1, squ = -1;

		for (int i = 0; i < n; i++)

		{

			scanf("%lld", &x);

			m[x]++;

		}

		for (map<ll,int>::iterator it = m.begin(); it!=m.end(); it++)

		{

			if (it->second>1&&it->first>maxn)

			{

				pre = maxn;

				maxn=it->first;

			}

			if (it->second>3&&it->first>squ) squ = it->first;

		}

		ll rec = maxn*pre, squre = squ*squ;

		if ((~maxn||~pre)||~squ) printf("%lld\n", rec>squre?rec:squre);

		else printf("0\n");

	}

}


// Faster C++ solution for the same problem (measured speedup: 4.842193951486641x):
#include<stdio.h>

#include<string.h>

#include<stdlib.h>

#include<algorithm>

#include<math.h>

#define maxn 100005

const double INF=0xfffff;

using namespace std;

long long num[maxn];

int main()

{

  int n;

  long long flag1,flag2,flag3;

  int flag;

  while(scanf("%d",&n)!=EOF)

  {

  	flag1=-1;

  	flag2=-1;

  	flag=0;

    for(int i=0;i<n;i++)

    scanf("%d",&num[i]);

    sort(num,num+n);

    for(int i=n-2;i>=0;i--)

    {

    	if(num[i]==num[i+1]&&flag1==-1)

    		{

    			flag1=num[i];

    			flag2=i;

    		}

    	else if(num[i]==num[i+1]&&i<flag2-1)

    		{

    			flag=1;

    			flag3=num[i];

    			break;

    		}

    		

    }

    if(flag==0)

    	printf("0\n");

    	else

    		printf("%lld\n",flag1*flag3);

  }

   return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <algorithm>

#include <string>

#include <map>

#include <cmath>

#include <queue>

#include <numeric>

#include <climits>

#include <iterator>

#include <iomanip>

#include <stack>

#include <bitset>

#include <functional>

using namespace std;

const constexpr int INF = 1e9;

//typedef std::pair<std::string,double> P;



typedef long long ll;

typedef vector<int> VI;



#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)

#define REP(i, n) FOR(i, 0, n)



//グラフの隣接リスト

VI g[200010];

//頂点の入次数を管理

int h[100010];

ll N;



int a[200010];

ll sum[200010];

signed main(void) {

    cin >> N;

    REP(i, N) cin >> a[i];

    sort(a, a+N);

    vector<int> v;

    for(int i=N-1; i>=1; --i){

        if(v.size()==2) break;

        if(a[i]==a[i-1]) {

            v.push_back(a[i]);

            --i;

        }

    }

    if(v.size()==2) cout << (long long)v[0]*v[1] << endl;

    else cout << 0 << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 6.46506292487489x):
#include<iostream>

#include <vector>

#include <algorithm>

#include <string>

using namespace std;



int main(){

    int N; cin >> N;

    vector<int> v;

    int cnt4=0, cnt2=0;

    for(int i=0; i<N; ++i){

        int a; cin >> a;

        v.push_back(a);

    }

    sort(v.rbegin(), v.rend());

    long long ans=0;

    int cnt=0;

    for(int i=0; i<N-1; ++i){

        if(v[i]==v[i+1]){

            if(ans==0) ans =1;

            ans *= v[i];

            cnt++;

            i+=1;

        }

        if(cnt==2) break;

    }

    cout << ans << endl;

    

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<algorithm>

using namespace std;

int f[1000000];

int main(){

//	freopen("j.txt","r",stdin);

	int n;

	cin>>n;

	memset(f,0,sizeof(f));

	for (int i=1;i<=n;i++)

		cin>>f[i];

	sort(f+1,f+1+n);

	int flag=0,max1=0,max2=0;

	for (int i=n-1;i>=1;i--)

		if (f[i]==f[i+1] && !flag){

			max1=f[i];

			flag=1;

		} else if (f[i]==f[i+1] && flag){

			if (f[i]==f[i-1] && f[i]==max1) {

				max2=f[i];

				break;

			}

				else if (f[i]!=max1){

					max2=f[i];

					break;

				} 

		}

    long long s;

	s=(long long)max1*(long long)max2;

	//cout<<max1<<" "<<max2<<endl;

	cout<<s<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 4.963334750566507x):
    #include <map>

    #include <set>

    #include <cmath>

    #include <queue>

    #include <stack>

    #include <cstdio>

    #include <string>

    #include <vector>

    #include <cstdlib>

    #include <cstring>

    #include <sstream>

    #include <iostream>

    #include <algorithm>

    #include <functional>

    using namespace std;

    #define MX 100000

    #define ll long long

    bool cmd(ll a,ll b){

    	return a>b;

    }

    int main(){

    	ll	 N,A[110000];

    	cin>>N;

    	for(int i=0;i<N;i++){

    		scanf("%d",&A[i]);

    	}

    	sort(A,A+N,cmd);

    	int flag=0;

    	int n=0;

    	ll tp1,tp2,sum;

    	for(int i=0;i<N;i++){

    		if(A[i]==A[i+1])

    		{

    			i++;

    			n++;

    			if(n==1)

    			tp1=A[i];

    			else{

    				sum=tp1*A[i];

    				cout<<sum;

    				return 0;

    			}

    		}

    	}

    	cout<<"0";

    	return 0;

    }
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<algorithm>

using namespace std;

int f[1000000];

int main(){

//	freopen("j.txt","r",stdin);

	int n;

	cin>>n;

	memset(f,0,sizeof(f));

	for (int i=1;i<=n;i++)

		cin>>f[i];

	sort(f+1,f+1+n);

	int flag=0,max1=0,max2=0;

	for (int i=n-1;i>=1;i--)

		if (f[i]==f[i+1] && !flag){

			max1=f[i];

			flag=1;

		} else if (f[i]==f[i+1] && flag){

			if (f[i]==f[i-1] && f[i]==max1) {

				max2=f[i];

				break;

			}

				else if (f[i]!=max1){

					max2=f[i];

					break;

				} 

		}

    long long s;

	s=(long long)max1*(long long)max2;

	//cout<<max1<<" "<<max2<<endl;

	cout<<s<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.008333370025626x):
#include <iostream>

#include <cstring>

#include <algorithm>

#include <cstdio>

#include <set>

#include <vector>

using namespace std;

int main()

{

    int n;

    while(scanf("%d",&n)!=EOF)

    {

        set<int>st;

        vector<int>v;

        for(int i=0;i<n;i++)

        {

           int a;

           cin>>a;

           if(st.count(a))

           {

               st.erase(a);

               v.push_back(a);

           }

           else

           {

               st.insert(a);

           }

        }



        sort(v.begin(),v.end());



        if(v.size()<2)

        {

            printf("0\n");

        }

        else

        {

            int num=(int)v.size();

            printf("%lld\n",1ll*(v[num-1]) *(v[num-2]));

        }

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<algorithm>

using namespace std;

int f[1000000];

int main(){

//	freopen("j.txt","r",stdin);

	int n;

	cin>>n;

	memset(f,0,sizeof(f));

	for (int i=1;i<=n;i++)

		cin>>f[i];

	sort(f+1,f+1+n);

	int flag=0,max1=0,max2=0;

	for (int i=n-1;i>=1;i--)

		if (f[i]==f[i+1] && !flag){

			max1=f[i];

			flag=1;

		} else if (f[i]==f[i+1] && flag){

			if (f[i]==f[i-1] && f[i]==max1) {

				max2=f[i];

				break;

			}

				else if (f[i]!=max1){

					max2=f[i];

					break;

				} 

		}

    long long s;

	s=(long long)max1*(long long)max2;

	//cout<<max1<<" "<<max2<<endl;

	cout<<s<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.077840552241676x):
#include <bits/stdc++.h>

#define N 100020

#define ll long long

using namespace std;

inline ll read(){

	ll x=0,f=1;char ch=getchar();

	while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());

	while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();

	return f?x:-x;

}

map<ll, bool> mp;

std::vector<ll> res;

int main(int argc, char const *argv[]) {

	int n = read();

	for (int i = 1; i <= n; i++) {

		ll x = read();

		if (mp[x]) res.push_back(x), mp[x] = 0;

		else mp[x] = 1;

	}

	sort(res.begin(), res.end());

	if (res.size() < 2) return puts("0")&0;

	else cout << res[res.size()-1] * res[res.size()-2] << endl;

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<algorithm>

using namespace std;

int f[1000000];

int main(){

//	freopen("j.txt","r",stdin);

	int n;

	cin>>n;

	memset(f,0,sizeof(f));

	for (int i=1;i<=n;i++)

		cin>>f[i];

	sort(f+1,f+1+n);

	int flag=0,max1=0,max2=0;

	for (int i=n-1;i>=1;i--)

		if (f[i]==f[i+1] && !flag){

			max1=f[i];

			flag=1;

		} else if (f[i]==f[i+1] && flag){

			if (f[i]==f[i-1] && f[i]==max1) {

				max2=f[i];

				break;

			}

				else if (f[i]!=max1){

					max2=f[i];

					break;

				} 

		}

    long long s;

	s=(long long)max1*(long long)max2;

	//cout<<max1<<" "<<max2<<endl;

	cout<<s<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.166305723063856x):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

#define For(i,j,k)	for(int i=j;i<=k;++i)

#define Dow(i,j,k)	for(int i=k;i>=j;--i)

#define ll long long

#define inf 1e8

using namespace std;

inline ll read()

{

	ll t=0,f=1;char c=getchar();

	while(c<'0'||c>'9'){if(c=='-')	c=getchar();}

	while(c>='0'&&c<='9')	t=t*10+c-48,c=getchar();

	return t*f;

}

int n,a[200001],mx1,mx2;

int main()

{

	n=read();

	For(i,1,n)	a[i]=read();

	sort(a+1,a+n+1);

	Dow(i,1,n)	if(a[i]==a[i-1])	{mx1=i;break;}

	Dow(i,1,mx1-2)if(a[i]==a[i-1])	{mx2=i;break;}

	printf("%lld",(ll)a[mx1]*a[mx2]);

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<algorithm>

using namespace std;

int f[1000000];

int main(){

//	freopen("j.txt","r",stdin);

	int n;

	cin>>n;

	memset(f,0,sizeof(f));

	for (int i=1;i<=n;i++)

		cin>>f[i];

	sort(f+1,f+1+n);

	int flag=0,max1=0,max2=0;

	for (int i=n-1;i>=1;i--)

		if (f[i]==f[i+1] && !flag){

			max1=f[i];

			flag=1;

		} else if (f[i]==f[i+1] && flag){

			if (f[i]==f[i-1] && f[i]==max1) {

				max2=f[i];

				break;

			}

				else if (f[i]!=max1){

					max2=f[i];

					break;

				} 

		}

    long long s;

	s=(long long)max1*(long long)max2;

	//cout<<max1<<" "<<max2<<endl;

	cout<<s<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.0672891284143375x):
#include<bits/stdc++.h>

using namespace std;

set<int> s;

int x,n;

vector<int> q;

int main()

{

	cin>>n;

	for (int i=1;i<=n;++i)

	{

		cin>>x;

		if (s.count(x))

		{

			s.erase(x);

			q.push_back(x);

		}

		else

			s.insert(x);

	}

	sort(q.rbegin(),q.rend());

	if (q.size()>=2)

		cout<<(long long)q[0]*q[1];

	else

		cout<<0;

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<algorithm>

using namespace std;

int f[1000000];

int main(){

//	freopen("j.txt","r",stdin);

	int n;

	cin>>n;

	memset(f,0,sizeof(f));

	for (int i=1;i<=n;i++)

		cin>>f[i];

	sort(f+1,f+1+n);

	int flag=0,max1=0,max2=0;

	for (int i=n-1;i>=1;i--)

		if (f[i]==f[i+1] && !flag){

			max1=f[i];

			flag=1;

		} else if (f[i]==f[i+1] && flag){

			if (f[i]==f[i-1] && f[i]==max1) {

				max2=f[i];

				break;

			}

				else if (f[i]!=max1){

					max2=f[i];

					break;

				} 

		}

    long long s;

	s=(long long)max1*(long long)max2;

	//cout<<max1<<" "<<max2<<endl;

	cout<<s<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 27.016630618567568x):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define N 100005

#define mod 1000000007

#define rep(i,j,k) for (ll i=j;i<=k;++i)

#define per(i,j,k) for (ll i=j;i>=k;--i)

using namespace std;

inline ll read(){

	char ch=getchar(); ll x=0,f=1;

	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }

	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }

	return x*f;

}

ll n,tot,ans1,ans2,a[N];

int main(){

	n=read();

	rep(i,1,n) a[i]=read();

	sort(a+1,a+1+n);

	for (ll l=1,r=1;l<=n;l=++r){

		while (a[l]==a[r+1]) ++r;

		if (r-l+1>=2) ans2=ans1,ans1=a[l];

		if (r-l+1>=4) ans2=ans1,ans1=a[l];

	}

	printf("%lld",ans1*ans2);

}
// Slower C++ solution:
    #include <map>

    #include <set>

    #include <cmath>

    #include <queue>

    #include <stack>

    #include <cstdio>

    #include <string>

    #include <vector>

    #include <cstdlib>

    #include <cstring>

    #include <sstream>

    #include <iostream>

    #include <algorithm>

    #include <functional>

    using namespace std;

    #define MX 100000

    #define ll long long

    bool cmd(ll a,ll b){

    	return a>b;

    }

    int main(){

    	ll	 N,A[110000];

    	cin>>N;

    	for(int i=0;i<N;i++){

    		scanf("%d",&A[i]);

    	}

    	sort(A,A+N,cmd);

    	int flag=0;

    	int n=0;

    	ll tp1,tp2,sum;

    	for(int i=0;i<N;i++){

    		if(A[i]==A[i+1])

    		{

    			i++;

    			n++;

    			if(n==1)

    			tp1=A[i];

    			else{

    				sum=tp1*A[i];

    				cout<<sum;

    				return 0;

    			}

    		}

    	}

    	cout<<"0";

    	return 0;

    }

// Faster C++ solution for the same problem (measured speedup: 5.443241686546315x):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define N 100005

#define mod 1000000007

#define rep(i,j,k) for (ll i=j;i<=k;++i)

#define per(i,j,k) for (ll i=j;i>=k;--i)

using namespace std;

inline ll read(){

	char ch=getchar(); ll x=0,f=1;

	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }

	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }

	return x*f;

}

ll n,tot,ans1,ans2,a[N];

int main(){

	n=read();

	rep(i,1,n) a[i]=read();

	sort(a+1,a+1+n);

	for (ll l=1,r=1;l<=n;l=++r){

		while (a[l]==a[r+1]) ++r;

		if (r-l+1>=2) ans2=ans1,ans1=a[l];

		if (r-l+1>=4) ans2=ans1,ans1=a[l];

	}

	printf("%lld",ans1*ans2);

}
// Slower C++ solution:
#include <iostream>

#include <cstring>

#include <algorithm>

#include <cstdio>

#include <set>

#include <vector>

using namespace std;

int main()

{

    int n;

    while(scanf("%d",&n)!=EOF)

    {

        set<int>st;

        vector<int>v;

        for(int i=0;i<n;i++)

        {

           int a;

           cin>>a;

           if(st.count(a))

           {

               st.erase(a);

               v.push_back(a);

           }

           else

           {

               st.insert(a);

           }

        }



        sort(v.begin(),v.end());



        if(v.size()<2)

        {

            printf("0\n");

        }

        else

        {

            int num=(int)v.size();

            printf("%lld\n",1ll*(v[num-1]) *(v[num-2]));

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.3943355249192075x):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define N 100005

#define mod 1000000007

#define rep(i,j,k) for (ll i=j;i<=k;++i)

#define per(i,j,k) for (ll i=j;i>=k;--i)

using namespace std;

inline ll read(){

	char ch=getchar(); ll x=0,f=1;

	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }

	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }

	return x*f;

}

ll n,tot,ans1,ans2,a[N];

int main(){

	n=read();

	rep(i,1,n) a[i]=read();

	sort(a+1,a+1+n);

	for (ll l=1,r=1;l<=n;l=++r){

		while (a[l]==a[r+1]) ++r;

		if (r-l+1>=2) ans2=ans1,ans1=a[l];

		if (r-l+1>=4) ans2=ans1,ans1=a[l];

	}

	printf("%lld",ans1*ans2);

}