Problem:


Score : 300 points

Problem Statement

We have N sticks with negligible thickness.
The length of the i-th stick is A_i.

Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.
Find the maximum possible area of the rectangle.

Constraints

4 \leq N \leq 10^5

1 \leq A_i \leq 10^9

A_i is an integer.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the maximum possible area of the rectangle.
If no rectangle can be formed, print 0.

Sample Input 1

6
3 1 2 4 2 1

Sample Output 1

2

1 \times 2 rectangle can be formed.

Sample Input 2

4
1 2 3 4

Sample Output 2

0

No rectangle can be formed.

Sample Input 3

10
3 3 3 3 4 4 4 5 5 5

Sample Output 3

20



Sample input:
6
3 1 2 4 2 1


Sample output:
2

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = Counter(list(map(int,input().split()))).most_common()
B = list(filter(lambda x : x[1] > 1, A))
l = len(B)
if l >= 2:
    print(B[l-1][0]*B[l-2][0])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=list(map(int, input().split()))
b=Counter(a)
c=[0,0]
for i in b.keys():
    if b[i]>=2:
        c.append(i)
c.sort()
print(c[-1]*c[-2])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

a_sort = list(reversed(list(sorted(a))))
b = {}

for i in range(len(a_sort)):
    if a_sort[i] in b.keys():
        b[a_sort[i]] = b[a_sort[i]]+ 1
    else:
        b.update({a_sort[i]:1})


counta = 0
countb = 0

cc = {}
for key,value in b.items():
    if value > 1 :
        cc.update({key:value})
        
if len(cc) > 1:
    for key,value in cc.items():
        if value > 3 and counta ==0 and countb == 0 :
            counta = key
            countb = key
            break
        elif counta ==0 and countb == 0 :
            counta = key
        elif counta != 0 and countb == 0:
            countb = key
            
print(counta * countb)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

a_sort = list(reversed(list(sorted(a))))
b = {}

for i in range(len(a_sort)):
    if a_sort[i] in b.keys():
        b[a_sort[i]] = b[a_sort[i]]+ 1
    else:
        b.update({a_sort[i]:1})


counta = 0
countb = 0

cc = {}
for key,value in b.items():
    if value > 1 :
        cc.update({key:value})
        
if len(cc) > 1:
    for key,value in cc.items():
        if value > 3 and counta ==0 and countb == 0 :
            counta = key
            countb = key
            break
        elif counta ==0 and countb == 0 :
            counta = key
        elif countb == 0:
            countb = key
            
print(counta * countb)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

a_sort = list(reversed(list(sorted(a))))
b = {}

for i in range(len(a_sort)):
    if a_sort[i] in b.keys():
        b[a_sort[i]] = b[a_sort[i]]+ 1
    else:
        b.update({a_sort[i]:1})


counta = 0
countb = 0

cc = {}
for key,value in b.items():
    if value > 3 and counta ==0 and countb == 0:
        counta = counta + key
        countb = countb + key
        break
    elif value > 1 and counta == 0 and countb == 0:
        counta = counta + key
    elif value > 1 and countb == 0:
        countb = countb + key
print(counta * countb)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

a_sort = list(reversed(list(sorted(a))))
b = {}

for i in range(len(a_sort)):
    if a_sort[i] in b.keys():
        b[a_sort[i]] = b[a_sort[i]]+ 1
    else:
        b.update({a_sort[i]:1})


counta = 0
countb = 0

cc = {}
for key,value in b.items():
    if value > 3 and counta ==0:
        counta = counta + key
        countb = countb + key
        break
    elif value > 1 and counta == 0:
        counta = counta + key
    elif value > 1 and countb == 0:
        countb = countb + key
print(counta * countb)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
hold = [0, 0]
x = 0
while x < n:
    count_a = a.count(a[x])
    if count_a >= 2:
        if hold[0]==0:
            hold[0]=a[x]
        else:
            hold[1]=a[x]
            break
        x += count_a-1
    x += 1
print(hold[0]*hold[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
aa = list(reversed(list(sorted(a))))

aad = {}
for i in aa:
    if i in aad.keys():
        aad[i] = aad[i] + 1
    else:
        aad.update({i:1})

m4 = 0
p = 0
q = 0
for k ,l in aad.items():
    if l > 3:
        m4 = m4 + l
        del(aad[k])
        break
        
for k ,l in aad.items():
    if l > 1:
        p = p + k
        del(aad[k])
        break

for k ,l in aad.items():
    if l > 1:
        q = q + k
        del(aad[k])
        break
if m4 > 0:
    print(m4 * m4)
else:
    print(p * q)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
aa = list(reversed(list(sorted(a))))

aad = {}
for i in aa:
    if i in aad.keys():
        aad[i] = aad[i] + 1
    else:
        aad.update({i:1})

m4 = 0
p = 0
q = 0
for k ,l in aad.items():
    if l > 3:
        m4 = m4 + l
        del(aad[k])
        break
        
for k ,l in aad.items():
    if l > 1:
        p = p + l
        del(aad[k])
        break

for k ,l in aad.items():
    if l > 1:
        q = q + l
        del(aad[k])
        break
if m4 > 0:
    print(m4 * m4)
else:
    print(p * q)

Submission status: Wrong Answer

Solution code:
N=int(input())
d,t={},[]
for i in list(map(int,input().split())):
    d[i]=d.get(i,0)+1
d=sorted(list(d.items()))
for j in range(len(d)):
    k=len(d)-j-1
    if d[k][1]>3:
        if len(t)==0:
            print((d[k][1])**2)
            exit()
    if d[k][1]>1:
        t.append(d[k][0])
        if len(t)==2:
            print(t[0]*t[1])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
d,t={},[]
for i in list(map(int,input().split())):
    d[i]=d.get(i,0)+1
d=sorted(list(d.items()))
for j in range(len(d)):
    k=len(d)-j-1
    if d[k][1]>1:
        t.append(d[k][0])
        if len(t)==2:
            print(t[0]*t[1])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# hello worldと表示する
N=int(input())
d,t={},[]
for i in list(map(int,input().split())):
    d[i]=d.get(i,0)+1
d=sorted(list(d.items()))
for j in range(len(d)):
    k=len(d)-j-1
    if d[k][1]>1:
        t.append(d[k][0])
        if len(t)==2:
            print(t[0]*t[1])
            exit()
print("0")

Submission status: Wrong Answer

Solution code:
N=int(input())
d,t={},[]
for i in list(map(int,input().split())):
    d[i]=d.get(i,0)+1
d=list(d.items())
for j in range(len(d)):
    k=len(d)-j-1
    if d[k][1]>1:
        t.append(d[k][0])
        if len(t)==2:
            print(t[0]*t[1])
            exit()
print("0")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
s = defaultdict(int)
for v in a: s[v]+=1
edge = []
for v in s.items():
    if v[1] > 1: edge.append(v[0])
(edge).sort()
if len(edge)>1:
    print(edge[-1]*edge[-2])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
arr01=arr_data[1]

hash01={}

for v in arr01:
    
    cnt=hash01.setdefault(int(v),0)+1
    
    hash01[int(v)]=cnt
    
#print(hash01)  

menseki01=None
menseki02=None

a=None
b=None

for k, v in sorted(hash01.items(), reverse=True):
    
#    print(k,v)
    
    if(v>=2  and a is None):
    
    
#        print("--chk01")
        a=k
        
    elif(v>=2 and a is not None and b is None):
    
#        print("--chk02")
        b=k
        menseki02=a*b
    elif(v>=4 and menseki01 is None):
        
        menseki01=k*k
        
#print(menseki01,menseki02,a,b)        
if menseki01 is None and menseki02 is None:
     
     print(0)


elif menseki01 is None and menseki02 is not None:

     print(menseki02)

elif menseki01 is not None and menseki02 is None:
     
    
     print(menseki01)

elif menseki01 is not None and menseki02 is not None:
     
    
    if menseki01 <= menseki02:

        print(menseki02)
        
    else:
        print(menseki01)

Submission status: Wrong Answer

Solution code:
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
arr01=arr_data[1]

hash01={}

for v in arr01:
    
    cnt=hash01.setdefault(int(v),0)+1
    
    hash01[int(v)]=cnt
    
  

menseki01=None
menseki02=None

a=None
b=None

for k, v in sorted(hash01.items(), reverse=True):
    
    if(v>=2 and v<=3 and a is None):
    
        a=k
        
    elif(v>=2 and v<=3 and a is not None and b is None):
    
        b=k
        menseki02=a*b
    elif(v>=4 and menseki01 is None):
        
        menseki01=k*k
        
        
if menseki01 is None and menseki02 is None:
     
     print(0)


elif menseki01 is None and menseki02 is not None:

     print(menseki02)

elif menseki01 is not None and menseki02 is None:
     
    
     print(menseki01)

elif menseki01 is not None and menseki02 is not None:
     
    
    if menseki01 <= menseki02:

        print(menseki02)
        
    else:
        print(menseki01)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = [int(s) for s in input().split()]

count = Counter(A)

S = list([(k, v) for k, v in count.items() if v >= 2])

S.sort(reverse=True, key=lambda x:(x[0], x[1]))

ans = 0
if len(S) >= 1 and S[0][1] >= 4:
    ans = S[0][0] ** 2
elif len(S) >= 2 and S[0][1] >= 2 and S[1][1] >= 2:
    ans = S[0][1] * S[0][1]

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = [int(s) for s in input().split()]

count = Counter(A)

S = list([k for k, v in count.items() if v >= 2])

if len(S) >= 2:
    S.sort(reverse=True)
    print(S[0] * S[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = [int(i) for i in input().split()]
a.sort
a = a[::-1]
x,answer = collections.Counter(a),[]
while a != []:
	if x[a[0]]>=4 and len(answer)==0:
		answer = [a[0],a[0]]
		break
	elif x[a[0]]>=2:
		answer.append(a[0])
		if len(answer)==2:
			break
	a = a[x[a[0]]:]
if len(answer)==2:
	print(answer[0]*answer[1])
else:
	print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
Data_list=input().split()
num=0
Rect=[0,0]
for i in range(N):
    Data_list[i]=int(Data_list[i])
for i in range(N):
    maxdata=max(Data_list)
    if maxdata==0:break
    count=Data_list.count(maxdata)
    if count>=4:
        Rect[0]=Rect[1]=maxdata
        break
    if count>1:
        Rect[num]=maxdata
        num+=1
        if num==2:break
    for j in range(count):
        Data_list[Data_list.index(maxdata)]=0
print(Rect[0]*Rect[1])

Submission status: Wrong Answer

Solution code:

N=int(input())
Data_list=input().split()
num=0
Rect=[0,0]
for i in range(N):
    Data_list[i]=int(Data_list[i])
for i in range(N):
    maxdata=max(Data_list)
    if maxdata==0:break
    count=Data_list.count(maxdata)
    if count>1:
        Rect[num]=maxdata
        num+=1
        if num==2:break
    for j in range(count):
        Data_list[Data_list.index(maxdata)]=0
print(Rect[0]*Rect[1])

Submission status: Wrong Answer

Solution code:

N=int(input())
Data_list=input().split()
num=0
Rect=[0,0]
for i in range(N):
    Data_list[i]=int(Data_list[i])
for i in range(N):
    mindata=min(Data_list)
    if mindata==10**9+1:break
    count=Data_list.count(mindata)
    if count>1:
        Rect[num]=mindata
        num+=1
        if num==2:break
    for j in range(count):
        Data_list[Data_list.index(mindata)]=10**9+1
print(Rect[0]*Rect[1])

Submission status: Wrong Answer

Solution code:
N=input()
Data_list=input().split()
length=len(Data_list)
num=0
Rect=[0,0]
for i in range(length):
    Data_list[i]=int(Data_list[i])
for i in range(length):
    count=Data_list.count(min(Data_list))
    if count>1:
        Rect[num]=min(Data_list)
        num+=1
        if num==2:break
    for j in range(count):
        Data_list[Data_list.index(min(Data_list))]=10**9+1
print(Rect[0]*Rect[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
li = set()
lis = set()
l = list(map(int,input().split()))
for i in range(n):
    if l[i] not in li:
        li.add(l[i])
    else:
        if l[i] not in lis:
            lis.add(l[i])
            li.remove(l[i])
if len(lis) < 2:
    print("0")
else:
    s = max(lis)
    lis.remove(s)
    print(s * max(lis))

Submission status: Wrong Answer

Solution code:
n = int(input())
li = set()
lis = set()
l = list(map(int,input().split()))
for i in range(n):
    if l[i] not in li:
        li.add(l[i])
    else:
        if l[i] not in lis:
            lis.add(l[i])
if len(lis) < 2:
    print("0")
else:
    s = max(lis)
    lis.remove(s)
    print(s * max(lis))

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
j = Counter(list(map(int, input().split())))
l = r = 0
for m, b in sorted(list(j.items()), key=lambda x: -x[0]):
    if b > 1 and (not l or not r):
        if not l:
            l = m
        elif not r:
            r = m
print(l * r)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
import collections
data=collections.Counter(a)
a=[]
a_4=[]
for i,j in data.items():
    if 2<=j<4:
        a.append(i)
    elif 4<=j:
        a_4.append(i)
x=y=z=0
a.sort()
a.reverse()
a_4.sort()
a_4.reverse()
if len(a_4)==0 and len(a)<=1:
    print(0)
    exit()
if 2<=len(a):
    x=a[0]*a[1]
elif len(a_4)!=0:
    y=a_4[0]*a_4[0]
elif len(a)!=0 and len(a_4)!=0:
    z=a[0]*a_4[0]
print(max(x,y,z))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
import collections
data=collections.Counter(a)
a=[]
a_4=[]
for i,j in data.items():
    if 2<=j<4:
        a.append(i)
    elif 4<=j:
        a_4.append(i)
x=y=z=0
a.sort()
a.reverse()
a_4.sort()
a_4.reverse()
if len(a)==0 and len(a_4)==0:
    print(0)
    exit()
if 2<=len(a):
    x=a[0]*a[1]
elif len(a_4)!=0:
    y=a_4[0]*a_4[0]
elif len(a)!=0 and len(a_4)!=0:
    z=a[0]*a_4[0]
print(max(x,y,z))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
import collections
data=collections.Counter(a)
a=[]
a_4=[]
for i,j in data.items():
    if 2<=j<4:
        a.append(i)
    elif 4<=j:
        a_4.append(i)
x=y=z=0
a.sort()
a.reverse()
a_4.sort()
a_4.reverse()
if 2<=len(a):
    x=a[0]*a[1]
elif len(a_4)!=0:
    y=a_4[0]*a_4[0]
elif len(a)!=0 and len(a_4)!=0:
    z=a[0]*a_4[0]
print(max(x,y,z))

Submission status: Wrong Answer

Solution code:
from collections import  Counter
n =int(input())
a = [int(i) for i in input().split()]
c = Counter(a)
num = []

for k,v in c.items():
    if v >= 2:
        num.append(k)

if len(num) <=1:
    print(0)
else:
    k = sorted(num,reverse=True)
    l = k[0]
    s = k[1]
    print(l*s)

Submission status: Wrong Answer

Solution code:
import collections
import sys
N = int(input())
A = map(int,input().split(" "))
count_input = collections.Counter(A)
del count_input[" "]
judge = True
m1 = 0
m2 = 0
count = 0
temp_max=0
for k,v in sorted(count_input.items(),reverse = True):#,reverse = True
    print(k)
    if temp_max<=k:
        temp_max=k
    # if m1 < int(k) and int(v) >= 2:
        # m2 = m1
        # m1 = int(k)
    if int(v) >= 4 and temp_max<=k:
        print(k**2)
        sys.exit()
    elif int(v) >= 2:
        m2 = m1
        m1 = int(k)
        count += 1
        if count ==2:
            print(m1*m2)
            sys.exit()
print("0")

Submission status: Wrong Answer

Solution code:
import collections
import sys
N = int(input())
A = map(int,input().split(" "))
count_input = collections.Counter(A)
del count_input[" "]
judge = True
m1 = 0
m2 = 0
count = 0
for k,v in sorted(count_input.items(),reverse = True):#,reverse = True
    # if m1 < int(k) and int(v) >= 2:
        # m2 = m1
        # m1 = int(k)
    if int(v) >= 4:
        print(k**2)
        sys.exit()
    elif int(v) >= 2:
        m2 = m1
        m1 = int(k)
        count += 1
        if count ==2:
            print(m1*m2)
            sys.exit()
print("0")

Submission status: Wrong Answer

Solution code:
import collections
import sys
N = int(input())
A = map(int,input().split(" "))
count_input = collections.Counter(A)
del count_input[" "]
judge = True
m1 = 0
m2 = 0
count = 0
for k,v in sorted(count_input.items(),reverse = True):#,reverse = True
    # if m1 < int(k) and int(v) >= 2:
        # m2 = m1
        # m1 = int(k)
    if int(v) >= 2:
        m2 = m1
        m1 = int(k)
        count += 1
        if count ==2:
            print(m1*m2)
            sys.exit()
print("0")

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = map(int,input().split(" "))
count_input = collections.Counter(A)
del count_input[" "]
judge = True
m1 = 0
m2 = 0

for k,v in sorted(count_input.items()):#,reverse = True
    if m1 < int(k) and int(v) >= 2:
        m2 = m1
        m1 = int(k)
print(m1*m2)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = input()

count_input= collections.Counter(A)
del count_input[" "]
a = []
judge = True
m1 = 0
m2 = 0
for k,v in sorted(count_input.items()):
    if m1 < int(k) and int(v) >= 2:
        m2 = m1
        m1 = int(k)
print(m1*m2)

Submission status: Wrong Answer

Solution code:
import collections
import sys
N = int(input())
A = input()

count_input= collections.Counter(A)
del count_input[" "]
count_value = list(count_input.values())
count_key = list(count_input.keys())
a = []
judge = True
for i in range(len(count_value)-1,0,-1):
    if count_value[i] >= 2:
        a.append(count_key[i])
    if len(a) == 2:
        print(int(a[0])*int(a[1]))
        sys.exit()
print("0")

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = input()

count_input= collections.Counter(A)
del count_input[" "]
count_value = list(count_input.values())
count_key = list(count_input.keys())
a = []
judge = True
for i in range(len(count_value)-1,0,-1):
    if count_value[i] >= 2:
        a.append(count_key[i])
    if len(a) == 2:
        print(int(a[0])*int(a[1]))
        judge = False
if judge:
    print("0")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
two_i=[]
four_i=[]
for i,j in data.items():
    if 4<=j:
        four_i.append(i)
    elif 2<=j:
        two_i.append(i)
two_i.sort()
four_i.sort()
two_i.reverse()
four_i.reverse()
if len(four_i)==0:
    four_i.append(0)
if len(two_i)<=1:
    two_i.append(0)
    two_i.append(0)
four_area=four_i[0]*four_i[0]
two_area=two_i[0]*two_i[1]
print(max(four_area,two_area))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
two_i=[]
four_i=[]
for i,j in data.items():
    if 2<=j<=3:
        two_i.append(i)
    elif 4<=j:
        four_i.append(i)
two_i.sort()
four_i.sort()
two_i.reverse()
four_i.reverse()
if len(four_i)==0:
    four_i.append(0)
if len(two_i)<=1:
    two_i.append(0)
    two_i.append(0)
four_area=four_i[0]*four_i[0]
two_area=two_i[0]*two_i[1]
print(max(four_area,two_area))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
two_i=[]
four_i=[]
for i,j in data.items():
    if 2<=j<=3:
        two_i.append(i)
    elif 4<=j:
        four_i.append(i)
two_i.sort()
four_i.sort()
two_i.reverse()
four_i.reverse()
if len(four_i)==0:
    four_i.append(0)
if len(two_i)<=1:
    two_i.append(0)
    two_i.append(0)
four_area=four_i[0]*2
two_area=two_i[0]*two_i[1]
print(max(four_area,two_area))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
two_i=[]
four_i=[]
for i,j in data.items():
    if 2<=j<=3:
        two_i.append(i)
    elif 4<=j:
        four_i.append(i)
two_i.sort()
four_i.sort()
if len(four_i)==0:
    four_i.append(0)
if len(two_i)<=1:
    two_i.append(0)
    two_i.append(0)
four_area=four_i[0]*2
two_area=two_i[0]*two_i[1]
print(max(four_area,two_area))

Submission status: Wrong Answer

Solution code:
def test():
    n=int(input())
    a=list(map(int,input().split()))
    from collections import Counter
    data=Counter(a)
    ans=[]
    for i,j in data.items():
        if 4<=j:
            return i*i
        elif 2<=j<4:
            ans.append(i)
            if 2<=len(ans):
                return ans[0]*ans[1]
    return 0
t=test()
print(t)

Submission status: Wrong Answer

Solution code:
def test():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    a.reverse()
    s=list(set(a))
    s.sort()
    s.reverse()
    ans=[]
    for i in s:
        if 4<=a.count(i):
            return i*i
        elif 2<=a.count(i)<=3:
            ans.append(i)
            if 2<=len(ans):
                return ans[0]*ans[1]
    return 0
t=test()
print(t)

Submission status: Wrong Answer

Solution code:
def test():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    a.reverse()
    s=list(set(a))
    s.sort()
    s.reverse()
    ans=[]
    for i in s:
        if 4<=a.count(i):
            print(i*i)
        elif 2<=a.count(i)<=3:
            ans.append(i)
            if 2<=len(ans):
                return ans[0]*ans[1]
    return 0
t=test()
print(t)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
ans=[]
for i,j in data.items():
    if 2<=j:
        ans.append(i)
        if 2<=j and j%2==0:
            ans.append(i)
ans.sort()
ans.reverse()
if 2<=len(ans):
    print(ans[0]*ans[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
ans=[]
for i,j in data.items():
    if 2<=j:
        ans.append(i)
        if j%2==0:
            ans.append(i)
ans.sort()
ans.reverse()
if 2<=len(ans):
    print(ans[0]*ans[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
ans=[]
v=[]
for i,j in data.items():
    if 2<=j<=3:
        ans.append(i)
    elif 4<=j:
        v.append(i)
ans.sort()
ans.reverse()
if 2<=len(ans):
    print(ans[0]*ans[1])
elif 1<=len(v):
    print(v[0]*v[0])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
ans=[]
for i,j in data.items():
    if 2<=j:
        ans.append(i)
ans.sort()
ans.reverse()
if 2<=len(ans):
    print(ans[0]*ans[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
dic = {}

for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1

a, b = 0, 0

for k,v in sorted(dic.items(), key=lambda x : x[1]):
    if a==0:
        if 4 <= v:
            a, b = k, k
            break
        elif 2 <= v:
            a = k
    elif 2 <= v:
        b = k
        break

if not a==0 or not b==0:
    print(a*b)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
dic = {}

for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1

a, b = 0, 0

for k,v in sorted(dic.items(), key=lambda x : x[1]):
    if a==0:
        if 2 <= v:
            a = k
        elif 4 <= v:
            a, b = k, k
            break
    elif 2 <= v:
        b = k
        break

if not a==0 or not b==0:
    print(a*b)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
dic = {}

for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1

a, b = 0, 0

for k,v in sorted(dic.items(), key=lambda x : x[1]):
    if a==0:
        if 2 <= v:
            a = k
        elif 4 <= v:
            a, b = k, k
            break
    elif 2 <= v:
        b = k
        break

if not a==0 and not b==0:
    print(a*b)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

d = {}
for e in A:
    if e not in d:
        d[e] = 1
    else:
        d[e] = d[e] + 1
print(d)
edges = []
for k, v in d.items():
    if v >= 4:
        edges.append(k)
        edges.append(k)
    elif v >= 2:
        edges.append(k)

if len(edges) <= 1:
    print(0)
else:
    edges.sort()
    print(edges[-1] * edges[-2])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

d = {}
for e in A:
    if e not in d:
        d[e] = 1
    else:
        d[e] = d[e] + 1

edges = []
for k, v in d.items():
    if v >= 4:
        edges.append(k)
        edges.append(k)
    elif v >= 2:
        edges.append(k)

if len(edges) <= 1:
    print(0)
else:
    print(edges[-1] * edges[-2])

Submission status: Wrong Answer

Solution code:

input()
xs = map(int, input().split())

d = dict()
for x in xs:
    if x in d.keys():
        d[x] += 1
    else:
        d[x] = 1

res = 0
for x, c1 in d.items():
    if c1 >= 4:
        if res < x * x: res = x * x

v = sorted(list(map(lambda s: s[0], (filter(lambda x: x[1] >= 2, d.items())))), reverse=True)

if len(v) >= 2:
    res = v[0] * v[1]

"""
    for y, c2 in d.items():
        if x != y and c1 >= 2 and c2 >= 2:
            if res < x * y: res = x * y
"""


print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = list(map(int,input().split()))
lis.sort()
a = lis[0];fir=0;sec=0;torf=False
for i in range(N-1):
    if torf:
        torf = False
    elif a == lis[i-1]:
        if a > fir:
            sec = fir
            fir = a
            torf = True
        elif a > sec:
            sec = a
            torf = True
    a = lis[i+1]

print(fir*sec)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split(' ')))
A.sort()
A.reverse()
a=0
b=0
for i in range(N):
    if A.count(A[i])>=4:
        print(int(A[i])**2)
        break
    elif A.count(A[i])>=2 and a==0:
        a=int(A[i])
        continue
    elif A.count(A[i])>=2 and a!=A[i]:
        b=int(A[i])
        print(a*b)
        break
    else:
        continue
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split(' ')))
A.sort()
A.reverse()
a=0
b=0
print(A)
print(A.count(4))
for i in range(N):
    if A.count(A[i])>=4:
        print(int(A[i])**2)
        break
    elif A.count(A[i])>=2 and a==0:
        a=int(A[i])
        continue
    elif A.count(A[i])>=2 and a!=A[i]:
        b=int(A[i])
        print(a*b)
        break
    else:
        continue
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split(' ')))
A.sort()
A.reverse()
a=0
b=0

for i in range(N):
    print()
    if A.count(A[i])>=4:
        print(int(A[i])**2)
        break
    elif A.count(A[i])>=2 and a==0:
        a=int(A[i])
        continue
    elif A.count(A[i])>=2 and a!=0:
        b=int(A[i])
        print(a*b)
        break
    else:
        continue
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(str, input().split(' ')))
A.sort()
A.reverse()
a=0
b=0

for i in range(N):
    if A.count(A[i])>=4:
        print(int(A[i])**2)
        break
    elif A.count(A[i])>=2 and a==0:
        a=int(A[i])
        continue
    elif A.count(A[i])>=2 and a!=0:
        b=int(A[i])
        print(a*b)
        break
    else:
        continue
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(str, input().split(' ')))
A.sort()
A.reverse()
a=0
b=0

for i in range(N):
    if A.count(A[i])>=4:
        print(int(A[i])**2)
        break
    elif A.count(A[i])>=2 and a==0:
        a=int(A[i])
        continue
    elif A.count(A[i])>=2 and a!=0:
        b=int(A[i])
        print(a*b)
    else:
        continue

Submission status: Wrong Answer

Solution code:
n = int(input())
sticks = list(map(int, input().split()))
sticks.sort()
sticks.reverse()


def find(sticks):
  previous = True
  edge = []
  for i in range(n):
    if len(edge) == 2:
      return edge[0] * edge[1]
    elif previous:
      previous = False
      continue
    else:
      if not i+1 >= n:
        if sticks[i] == sticks[i+1]:
          edge.append(sticks[i])
          previous = True
  return 0

print(find(sticks))

Submission status: Wrong Answer

Solution code:
n = int(input())
sticks = list(map(int, input().split()))
sticks.sort()
sticks.reverse()
def find(list):
  f = 0
  s = 0
  for i in range(0, n, 2):
    if sticks[i] == sticks[i+1]:
      if f == 0:
        f = sticks[i]
      else:
        s = sticks[i]
    if f and s:
      return f * s
  
  if not f or not s:
    return 0
print(find(sticks))

Submission status: Wrong Answer

Solution code:
n = int(input())
sticks = list(map(int, input().split()))
f = 0
s = 0
multi = set(sticks)

for i in multi:
  if i > f:
    f, s = i , f

print(f * s)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
d = dict(collections.Counter(A))

tmp = 0
for i, j in d.items():
    if j >=4 and tmp == 0:
        print(i * i)
        break
    elif j >=2 and tmp !=0:
        print(i * tmp)
        break
    elif j >=2 and tmp == 0:
        tmp = i

print("0")

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
d = dict(collections.Counter(A))

tmp = 0
for i, j in d.items():
    if j >=4 and tmp == 0:
        print(i * i)
        break
    elif j >=2 and tmp !=0:
        print(i * tmp)
        break
    elif j >=2 and tmp == 0:
        tmp = i

Submission status: Wrong Answer

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
from collections import Counter
d=Counter(a)
dd=[0,0]
for i,j in d.items():
  if j>1 and dd[0]<i:
     dd.pop(0)
     dd.append(i)
  if j>3 and dd[0]<i:
     dd.pop(0)
     dd.append(i)

print(dd[0]*dd[1])