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 = list(map(int,input().split()))
Ac = Counter(A)
flag = False
a = 0
b = 0
for k,v in Ac.items():
    if v < 2:
        continue
    elif v >= 4:
        if flag:
            b = k
            break
        else:
            a = k
            b = k
            break
    else:
        if flag:
            b = k
            break
        else:
            a = k
            flag = True
print(a*b)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
ls = list(map(int, input().split()))

c = collections.Counter(ls)

ls_s = c.most_common()
ls_s.sort(reverse=True)

mul = []

for i in range(len(ls_s)):
    if ls_s[i][1] >= 4:
        print(ls_s[i][0] ** 2)
        break
    elif ls_s[i][1] >= 2:
        mul.append(ls_s[i][0])
    
    if len(mul) >= 2:
        print(mul[0] * mul[1])
        break
    elif i == len(ls_s) - 1:
        print(0)

Submission status: Wrong Answer

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

ls.sort(reverse=True)
mul = []

cnt = 1

for i in range(n - 1):
    if ls[i] == ls[i + 1]:
        cnt += 1
        if i == n - 2:
            mul.append(ls[i])
    elif ls[i] != ls[i + 1] and cnt >= 4:
        print(ls[i] ** 2)
        break
    elif ls[i] != ls[i + 1] and cnt >= 2:
        mul.append(ls[i])
        cnt = 1
    
    if len(mul) >= 2:
        print(mul[0] * mul[1])
        break
    elif i == n - 2 and cnt >= 4:
        print(ls[i] ** 2)
    elif i == n - 2 and len(mul) < 2:
        print(0)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
ct = Counter(a_ls)
ct = [(i, j) for i, j in sorted(ct.items(), key=lambda x:x[0], reverse=True) if j > 1]
if len(ct) < 2:
    print(0)
else:
    print(ct[0][0] * ct[1][0])

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
A=Counter(sorted(list(map(int,input().split()))))
A=[i for i in A if A[i]>=2]
A.sort(reverse=True)
try:
    if len(A[0])>=4:
        print(A[0]**2)
    else:
        print(A[0]*A[1])
except:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
A=Counter(sorted(list(map(int,input().split()))))
A=[i for i in A if A[i]>=2]
A.sort(reverse=True)
try:
    print(A[0]*A[1])
except:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
A = Counter(A).most_common()
A = sorted(A)[::-1]
cnt = 0
l = []
ans = [0]
for i, v in A:
  if v >= 4:
    ans.append(i*i)
  if 2<=v:
    cnt += 1
    l.append(i)
    if cnt == 2:
      ans.append(l[0]*l[1])
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
A = Counter(A).most_common()
A = sorted(A)[::-1]
cnt = 0
l = []
for i, v in A:
  if v >= 4:
    print(i*i)
    exit()
  elif 2<=v<=4:
    cnt += 1
    l.append(i)
    if cnt == 2:
      print(l[0]*l[1])
      exit()
print(0)

Submission status: Wrong Answer

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

d = dict()
for a in A:
    d[a] = d.get(a, 0) + 1

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

ans = sorted(ans)
if len(ans) >= 2:
    print(ans[-2]*ans[-1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(int, input().split()))
s = collections.Counter(a)
c = []
for i in s.keys():
	if s[i] >= 2:
		c.append(i)
c.sort(reverse=  True)
if len(c) < 2:
	print (0)
else:
	print (c[0]*c[1])

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
lists=list(map(int,input().split()))
A=dict(collections.Counter(lists))
dictdict=[]
for j in A.keys():
    for _ in range(A[j]//2):
        dictdict.append(j)
A=sorted(A,reverse=True)
print(A[0]*A[1])

Submission status: Wrong Answer

Solution code:
N = int(input())

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

d = {}
for i in range(N):
    if A[i] not in d:
        d[A[i]] = 0
    d[A[i]] += 1


ans = {0}
s1 = [k for k, v in d.items() if v >= 4]
if len(s1) > 0: ans.add(s1[-1] ** 2)

s2 = [k for k, v in d.items() if v >= 2]
if len(s2) > 1:
    s2.sort()
    ans.add(s2[-1] * s2[-2])

print(max(ans))

Submission status: Wrong Answer

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

import collections

c = collections.Counter(a)
cs = sorted(c.items(), key=lambda x:x[0],reverse=True)
a=[0,0]
f=0
sq=0
for i in cs:
    if sq == 0 and i[1] >= 4:
        sq=i[1]**2
    if i[1] >= 2:
        a[f]=i[0]
        f+=1
    if f >= 2:
        break
print(max(sq,a[0]*a[1]))

Submission status: Wrong Answer

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

import collections

c = collections.Counter(a)
cs = sorted(c.items(), key=lambda x:x[0],reverse=True)
a=[0,0]
f=0
for i in cs:
    if i[1] > 1:
        a[f]=i[0]
        f+=1
    if f >= 2:
        break
print(a[0]*a[1])

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main(n: int, a: list):
    c = sorted(Counter(a).items(), reverse=True)

    x_y = []

    for l, m in c:
        if m >= 4:
            print(m ** 2)
            return

        if m >= 2:
            x_y.append(l)

        if len(x_y) == 2:
            print(x_y[0] * x_y[1])
            return

    if len(x_y) != 2:
        print(0)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main(n: int, a: list):
    c = sorted(Counter(a).items(), reverse=True)

    x_y = []

    for l, m in c:
        if m >= 4:
            print(m ** m)
            return

        if m >= 2:
            x_y.append(l)

        if len(x_y) == 2:
            print(x_y[0] * x_y[1])
            return

    if len(x_y) != 2:
        print(0)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main(n: int, a: list):
    c = sorted(Counter(a).items(), reverse=True)

    x_y = []

    for l, m in c:
        if len(x_y) == 0 and m >= 4:
            print(m ** m)
            return
        if m >= 2:
            x_y.append(l)

        if len(x_y) == 2:
            print(x_y[0] * x_y[1])
            return

    print(0)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main(n: int, a: list):
    c = sorted(Counter(a).items(), reverse=True)

    x_y = []

    for l, m in c:
        if m >= 4:
            print(m ** m)
            return
        if m >= 2:
            x_y.append(l)

        if len(x_y) == 2:
            print(x_y[0] * x_y[1])
            return

    print(0)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main(n: int, a: list):
    c = sorted(Counter(a).items(), reverse=True)

    x_y = []

    for l, m in c:
        if m >= 4:
            print(m**m)
            return
        if m >= 2:
            x_y.append(l)

        if len(x_y) == 2:
            print(x_y[0] * x_y[1])
            return

    print(0)

Submission status: Wrong Answer

Solution code:
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
def list_count(my_list):
    dic={} #辞書型の宣言
    for num in my_list:
        if num in dic: #もしnumがkeyとして辞書にあれば
            dic[num]+=1 #valueに+1
        else: #なければ
            dic[num]=1 #dicにnumというkeyを追加し、対応するvalueを1とする
    return dic
dic=list_count(a)
ans=1
cnt=0
for i in dic.keys():
    while dic[i]>=2:
        ans*=i
        dic[i]-=2
        cnt+=1
        if cnt==2:
            print(ans)
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
x=0
y=a[0]
i=1
ans=1
while x<2 and i<n-1:
    if y==a[i]:
        ans*=y
        y=a[i+1]
        i+=2
        x+=1
    else:
        y=a[i]
        i+=1
if x<2:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

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

l2 = sorted([i for i in set(l) if l.count(i) >1],reverse = True)

print(l2[0]*l2[1] if l2 else 0)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    s = set()
    for x in range(N-1):
        if A.count(A[x]) == 4:
            print(A[x]*A[x])
            exit()
        if A[x] == A[x+1]:
            s.add(A[x])
        if len(s) == 2:
            s = list(s)
            print(s[0]*s[1])
            exit()

    print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    s = set()
    for x in range(N-1):
        if A[x] == A[x+1]:
            s.add(A[x])
        if len(s) == 2:
            s = list(s)
            print(s[0]*s[1])
            exit()

    print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#import math
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    #x,y = map(int,input().split())	x=1,y=2
    #a = input().split()	a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))	a=[1,2,3,4,5,...,n]
    #li = input().split('T')	FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    n=int(input())
    a = list(map(int,input().split()))
    x={}
    for i in range(n):
        if a[i] not in x:
            x[a[i]]=1
        else:
            x[a[i]]+=1
    y=[]
    for i in x:
        if x[i]>=2:
            y.append(i)
    y.sort(reverse=True)
    if len(y)>=2:
        print(y[0]*y[1])
    else:
        print(0)

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
A = sorted(list(map(int, input().split())))
up2_max = 0
up2_2nd = 0
up4_max = 0

#print(A)

from bisect import bisect_left, bisect_right
B = sorted(list(set(A)), reverse=True)
for cand in B:
  num = bisect_right(A, cand) - bisect_left(A, cand)
  if num >= 4:
    up4_max = cand
    break
for i, cand in enumerate(B):
  num = bisect_right(A, cand) - bisect_left(A, cand)
#  print(cand, num, bisect_right(A, cand), bisect_left(A, cand))
  if num >= 2:
    up2_max = cand
    break
#print()
for j in range(i+1, n-i):
  num = bisect_right(A, B[j]) - bisect_left(A, B[j])
#  print(B[j], num)
  if num >= 2:
    up2_2nd = B[j]
    break
    
#print()
#print(up2_max, up2_2nd, up4_max)
print(max(up4_max**2, up2_max * up2_2nd))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
up2_max = 0
up2_2nd = 0
up4_max = 0

for cand in list(set(A)):
  num = A.count(cand)
  if num >= 2  and  cand > up2_max:
    up2_max, up2_2nd = cand, up2_max
  elif num >= 4:
    up4_max = cand
print(max(up2_max * up2_2nd, up4_max**2))

Submission status: Wrong Answer

Solution code:
n= int(input())
a= list(map(int, input().split()))
from collections import Counter
c= Counter(a).most_common()
c.sort(key=lambda x: x[0],reverse=True)
tate=0
kouho=0
sei=0
chou=0
for i in c:
    if sei==0 and i[1]>=4:
        if tate:
            sei=i[0]*tate
    elif chou==0 and i[1]>=2:
        if tate:
            yoko=i[0]
            chou=yoko*tate
        else:
            tate=i[0]
print(max(chou,sei))

Submission status: Wrong Answer

Solution code:
n= int(input())
a= list(map(int, input().split()))
from collections import Counter
c= Counter(a).most_common()
c.sort(key=lambda x: x[0],reverse=True)
tate=0
kouho=0
sei=0
chou=0
for i in c:
    if sei==0 and i[1]>=4:
        sei=i[0]**2
    elif chou==0 and i[1]>=2:
        if tate:
            yoko=i[0]
            chou=yoko*tate
        else:
            tate=i[0]
print(max(chou,sei))

Submission status: Wrong Answer

Solution code:
n= int(input())
a= list(map(int, input().split()))
from collections import Counter
c= Counter(a).most_common()
c.sort(key=lambda x: x[0],reverse=True)
tate=0
kouho=0
for i in c:
    if i[1]>=4:
        print(i[0]**2)
        exit(0)
    elif i[1]>=2:
        if tate:
            yoko=i[0]
            print(tate*yoko)
            exit(0)
        else:
            tate=i[0]
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
flag1 = 1
flag2 = 0
w = 0
h = 0
for i in range(0,n-1,2):
    flag2 = 1
    if a[i] == a[i+1] and flag1:
        w = a[i]
        flag1 = 0
        flag2 = 0
    if a[i] == a[i+1] and flag2:
        h = a[i]
        break
if w == 0:
    ans = 0
elif h == 0:
    if a[-1] == a[-2]:
        h = a[-1]
        ans = int(h*w)
else:
    ans = int(h*w)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
flag1 = 1
flag2 = 0
w = 0
h = 0
for i in range(0,n-1,2):
    flag2 = 1
    if a[i] == a[i+1] and flag1:
        w = a[i]
        flag1 = 0
        flag2 = 0
    if a[i] == a[i+1] and flag2:
        h = a[i]
        break
if w == 0 or h == 0:
    ans = 0
else:
    ans = int(h*w)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter(a)
    c = [[k, v] for k, v in c.items() if v > 1]
    if len(c) < 2:
        print(0)
        return
    if c[-1][1] >= 4:
        print(c[-1][0] ** 2)
    else:
        print(c[-1][0] * c[-2][0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections 

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

A=collections.Counter(A)
A=list(A.items())
A.sort(reverse=True)
#print(A)

x,y=0,0
for a in A:
  if x and a[1]>=2:
    y=a[0]
    break
  if a[1]>=2:
    x=a[0]
#print(x,y)
print(x*y)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

flag = False
ans = 0
for k in sorted(A.keys(), reverse=True):
    if A[k] >= 2:
        if not flag:
            ans = k
            flag = True
        else:
            print(ans * k)
            exit()
else:
    print(0)

Submission status: Wrong Answer

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

A.sort(reverse=True)

cnt=1
r=[]
for i in range(1,N):
    if A[i-1]==A[i]:
        cnt+=1
    else:
        if cnt>=4:
            print(A[i-1]*A[i-1])
            exit()
        elif cnt>=2:
            r.append(A[i-1])
            if len(r)==2:
                print(r[0]*r[1])
                exit()
            cnt=1
        else:
            cnt=1
if cnt>=2:
    r.append(A[i-1])
    if len(r)==2:
        print(r[0]*r[1])
        exit()

print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
ans = [key for key, value in sorted(counter.items(), key=lambda x: x[0]) if value >= 2]
if len(ans) >= 2:
    print(ans[-1] * ans[-2])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
ans = [key for key, value in counter.items() if value >= 2]
if len(ans) >= 2:
    print(ans[-1] * ans[-2])
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


dic = collections.defaultdict(int)

for x in A:
    dic[x] += 1

dic = list(dic.items())
dic = [x for x in dic if x[1] >= 2]
dic = sorted(dic, reverse=True, key=lambda x: x[0])

if len(dic) >= 2:
    print(dic[0][0] * dic[1][0])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
h,w=0,0
a=sorted(Counter([int(i) for i in input().split()]).most_common(),reverse=1)
#print(a)
for i in range(len(a)):
    if a[i][1]>=4:
        print(a[i][0]**2)
        exit()
    elif a[i][1]>=2:
        if h==0:
            h=a[i][0]
        else:
            w=a[i][0]
            break
print(h*w)

Submission status: Wrong Answer

Solution code:
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
h,w=0,0
a=sorted(Counter([int(i) for i in input().split()]).most_common(),reverse=1)+[(0,0)]
#print(a)
for i in range(len(a)-1):
    if a[i][1]>=4:
        print(a[i][0]**2)
        exit()
    elif a[i][1]>=2:
        if h==0:
            h=a[i][0]
        else:
            print(h*a[i][0])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
h,w=0,0
a=sorted(Counter([int(i) for i in input().split()]).most_common(),reverse=1)+[(0,0)]
print(a)
for i in range(len(a)-1):
    if a[i][1]>=4:
        print(a[i][0]**2)
        exit()
    elif a[i][1]>=2:
        if h==0:
            h=a[i][0]
        else:
            print(h*a[i][0])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
a=sorted(Counter([int(i) for i in input().split()]).most_common(),reverse=1)+[(0,0)]
for i in range(len(a)-1):
    if a[i][1]>=4:
        print(a[i][0]**2)
        exit()
    elif a[i][1]>=2:
        if a[i+1][1]>=2:
            print(a[i][0]*a[i+1][0])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = collections.Counter(list(map(int, input().split()))).most_common()
a = sorted(a, reverse=True)
t = 0
for i, v in a:
    if v >= 4:
        print(i * i)
        exit()
    elif v >= 2:
        if t == 0:
            t = i
        else:
            print(t * i)
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = collections.Counter(list(map(int, input().split()))).most_common()
a = sorted(a, reverse=True)
t = 0
for i, v in a:
    if v >= 2:
        if t == 0:
            t = i
        else:
            print(t * i)
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n=int(input())
a=[-int(item) for item in input().split()]
c = [item for item in list(collections.Counter(a).items()) if item[1]>1]

#print(c)

if len(c)==0:
  print(0)
  exit()
if sum([item[1] for item in c])<4:
  print(0)
  exit()

x=heapq.heappop(c)
if c!=[]:
  y=heapq.heappop(c)
else:
  y=(0,0)

if x[1]>=4:
  print(x[0]*x[0])
else:
  print(x[0]*y[0])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n=int(input())
a=[-int(item) for item in input().split()]
c = [item for item in list(collections.Counter(a).items()) if item[1]>1]

print(c)

if len(c)==0:
  print(0)
  exit()
if sum([item[1] for item in c])<4:
  print(0)
  exit()

x=heapq.heappop(c)
if c!=[]:
  y=heapq.heappop(c)
else:
  y=(0,0)

if x[1]>=4:
  print(x[0]*x[0])
else:
  print(x[0]*y[0])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n=int(input())
a=[-int(item) for item in input().split()]
c = [item for item in list(collections.Counter(a).items()) if item[1]>1]
if c==[]:
  print(0)
  exit()
#print(c)
x=heapq.heappop(c)
y=heapq.heappop(c)
kouho=[]
if x[1]>=4:
  print(x[0]*x[0])
else:
  print(x[0]*y[0])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n=int(input())
a=[-int(item) for item in input().split()]
c = [item for item in list(collections.Counter(a).items()) if item[1]>1]
if c==[]:
  print(0)
  exit()
#print(c)
x=heapq.heappop(c)[0]
y=heapq.heappop(c)[0]
print(x*y)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
cnt=0
d=[]
i=0
while i<n-1:
	if a[i]==a[i+1]:
		cnt+=1
	else:
		cnt=0
	if cnt==1:
		d.append(a[i])
	elif cnt==3:
		d.append(a[i])
		d.append(a[i-2])
	if len(d)==2:
		print(d[0]*d[1])
		exit()
	i+=1
print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
cnt=0
d=[]
i=0
while i<n-1:
	if a[i]==a[i+1]:
		cnt+=1
	if cnt==1:
		d.append(a[i])
	elif cnt==3:
		d.append(a[i])
		d.append(a[i-2])
	if a[i]!=a[i+1]:
		cnt=0
	if len(d)==2:
		print(d[0]*d[1])
		exit()
	i+=1

print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#ARC081C
import copy
import sys
import math

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

hoge.sort()

count=0
h=0
w=0
i=0
while(1):
#for i in range(0,n-1):
	if(i<n-1):
		if(hoge[n-1-i]==hoge[n-2-i]):
			if(count==0):
				h=hoge[n-1-i]
				count+=1
				i+=2
			else:
				w=hoge[n-1-i]
				break
		i+=1
	else:
		break
print(w*h)

#print(hoge)

Submission status: Wrong Answer

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

max_1 = 0
len_a = len(A)
for i, a in enumerate(A):
    if len_a - i >= 4:
        if A[i] == A[i+1] and A[i+1] == A[i+2] and A[i+2] == A[i+3]:
            if max_1 == 0:
                print(A[i] ** 2)
                exit()
            else:
                print(A[i] * max_1)
                exit()
    if len_a - i >= 2:
        if A[i] == A[i+1]:
            if max_1 == 0:
                max_1 = A[i]
        else:
            if max_1 != A[i]:
                print(A[i] * max_1)
                exit()
print(0)

Submission status: Wrong Answer

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

num = []
cnt = 1
for i in range(N):
    if i == 0:
        cnt = 1
    else:
        if A[i-1] == A[i]:
            cnt += 1
            if i == N-1:
                num.append([A[i-1],cnt])
        else:
            if cnt > 1:
                num.append([A[i-1],cnt])
                cnt = 1
#print(num)
a = 0
b = 0
if len(num) == 0:
    pass
elif len(num) == 1:
    if num[-1][1] >= 4:
        a = num[0][0]
        b = a
else:
    if num[-1][1] >= 4:
        a = num[0][0]
        b = a
    else:
        a = num[-1][0]
        b = num[-2][0]
print(a*b)

Submission status: Wrong Answer

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

num = []
cnt = 1
for i in range(N):
    if i == 0:
        cnt = 1
    else:
        if A[i-1] == A[i]:
            cnt += 1
            if i == N-1:
                num.append([A[i-1],cnt])
        else:
            if cnt > 1:
                num.append([A[i-1],cnt])
                cnt = 1
#print(num)
a = 0
b = 0
if len(num) < 2:
    pass
else:
    if num[-1][1] >= 4:
        a = num[0][0]
        b = a
    else:
        a = num[-1][0]
        b = num[-2][0]
print(a*b)

Submission status: Wrong Answer

Solution code:
# 逆順ソートして辞書にして大きい順に2つ以上ある数値を2つとるか4つ以上ある数値をとればおしまい
# atcoderのPytnon3バージョンが時代錯誤すぎて辞書順の順番を保持しない老害仕様だったので6WAくらい喰らった
# 方針を変えて二回ループして全探索することにした

n = int(input())
arr = list(map(int, input().split()))
h = {}
for a in arr:
    if a in h:
        h[a] += 1
    else:
        h[a] = 1
x, y = 0, 0
tmp_ans = 0
for k, v in h.items():
    if 4 <= v:
        tmp_ans = max(tmp_ans, k * k)

for k, v in h.items():
    if 2 <= v:
        if x == 0 and y == 0:
            x = k
        elif x != 0 and y == 0:
            x, y = min(x, k), max(x, k)
        else:
            if y < k:
                x, y = y, k
    tmp_ans = max(tmp_ans, x * y)

print(tmp_ans)

Submission status: Wrong Answer

Solution code:
# 逆順ソートして辞書にして大きい順に2つ以上ある数値を2つとるか4つ以上ある数値をとればおしまい
# atcoderのPytnon3バージョンが時代錯誤すぎて辞書順の順番を保持しない老害仕様だったので6WAくらい喰らった
# 方針を変えて二回ループして全探索することにした

n = int(input())
arr = list(map(int, input().split()))
h = {}
for a in arr:
    if a in h:
        h[a] += 1
    else:
        h[a] = 1
x, y = 0, 0
tmp_ans = 0
for k, v in h.items():
    if 4 <= v:
        tmp_ans = max(tmp_ans, k * k)

for k, v in h.items():
    if 2 <= v:
        if x == 0 and y == 0:
            x = k
        elif x != 0 and y == 0:
            x, y = min(x, k), max(x, k)
        else:
            if y < k:
                x, y = y, k
        tmp_ans = max(tmp_ans, x * y)

print(tmp_ans)

Submission status: Wrong Answer

Solution code:
# 逆順ソートして辞書にして大きい順に2つ以上ある数値を2つとるか4つ以上ある数値をとればおしまい
# atcoderのPytnon3バージョンが時代錯誤すぎて辞書順の順番を保持しない老害仕様だったので6WAくらい喰らった
# 方針を変えて二回ループして全探索することにした

n = int(input())
arr = list(map(int, input().split()))
h = {}
for a in arr:
    if a in h:
        h[a] += 1
    else:
        h[a] = 1
x, y = 0, 0
tmp_ans = 0
for k, v in h.items():
    if 4 <= v:
        tmp_ans = max(tmp_ans, k * k)

for k, v in h.items():
    if 2 <= v:
        if x == 0 and y == 0:
            x = k
        elif x != 0 and y == 0:
            x, y = min(x, k), max(x, k)
            tmp_ans = max(tmp_ans, x * y)
        else:
            if y < k:
                x, y = y, k
                tmp_ans = max(tmp_ans, x * y)

print(tmp_ans)

Submission status: Wrong Answer

Solution code:
# 逆順ソートして辞書にして大きい順に2つ以上ある数値を2つとるか4つ以上ある数値をとればおしまい
# atcoderのPytnon3バージョンが時代錯誤すぎて辞書順の順番を保持しない老害仕様だったので6WAくらい喰らった

n = int(input())
arr = list(map(int, input().split()))
h = {}
for a in arr:
    if a in h:
        h[a] += 1
    else:
        h[a] = 1
x, y = 0, 0
h = sorted(h.items(), key=lambda x: x[0], reverse=True)
for k, v in h:
    if v >= 4 and k * k > x * y:
        x, y = k, k
    elif v >= 2:
        if x == 0:
            x = k
        elif y == 0:
            y = k
print(x * y)

Submission status: Wrong Answer

Solution code:
# 逆順ソートして辞書にして大きい順に2つ以上ある数値を2つとるか4つ以上ある数値をとればおしまい
# atcoderのPytnon3バージョンが時代錯誤すぎて辞書順の順番を保持しない老害仕様だったので6WAくらい喰らった

n = int(input())
arr = sorted(list(map(int, input().split())), reverse=True)
h = {}
for a in arr:
    if a in h:
        h[a] += 1
    else:
        h[a] = 1
x, y = 0, 0
h = sorted(h.items(), key=lambda x: x[0], reverse=True)
for k, v in h:
    if v >= 4 and k * k > x * y:
        x, y = k, k
    if v >= 2:
        if x == 0:
            x = k
        elif y == 0:
            y = k
print(x * y)

Submission status: Wrong Answer

Solution code:
# 逆順ソートして辞書にして大きい順に2つ以上ある数値を2つとるか4つ以上ある数値をとればおしまい
# atcoderのPytnon3バージョンが時代錯誤すぎて辞書順の順番を保持しない老害仕様だったので5WAくらい喰らった

n = int(input())
arr = sorted(list(map(int, input().split())), reverse=True)
h = {}
for a in arr:
    if a in h:
        h[a] += 1
    else:
        h[a] = 1
x, y = 0, 0
sorted(h.items(), key=lambda x: x[0])
for k, v in h.items():
    if v >= 4 and k * k > x * y:
        x, y = k, k
    if v >= 2:
        if x == 0:
            x = k
        elif y == 0:
            y = k
print(x * y)

Submission status: Wrong Answer

Solution code:
# ソートして辞書にして大きい順に2つ以上ある数を見つければおしまい
n = int(input())
arr = sorted(list(map(int, input().split())), reverse=True)
h = {}
for a in arr:
    if a in h:
        h[a] += 1
    else:
        h[a] = 1
x, y = 0, 0
for k, v in h.items():
    if v >= 4 and k * k > x * y:
        x, y = k, k
    if v >= 2:
        if x == 0:
            x = k
        elif y == 0:
            y = k
print(x * y)

Submission status: Wrong Answer

Solution code:
# ソートして辞書にして大きい順に2つ以上ある数を見つければおしまい
n = int(input())
arr = sorted(list(map(int, input().split())), reverse=True)
h = {}
for a in arr:
    if a in h:
        h[a] += 1
    else:
        h[a] = 1
x, y = 0, 0
for k, v in h.items():
    if v >= 4:
        x, y = k, k
    if v >= 2:
        if x == 0:
            x = k
        elif y == 0:
            y = k
print(x * y)

Submission status: Wrong Answer

Solution code:
# ソートして辞書にして大きい順に2つ以上ある数を見つければおしまい
# ??????????????? これ通らないのバグでは
n = int(input())
arr = sorted(list(map(int, input().split())), reverse=True)
h = {}
for a in arr:
    if a in h:
        h[a] += 1
    else:
        h[a] = 1
x, y = 0, 0
for k, v in h.items():
    if v >= 2:
        if x == 0:
            x = k
        elif y == 0:
            y = k
print(x * y)

Submission status: Wrong Answer

Solution code:
# ソートして辞書にして大きい順に2つ以上ある数を見つければおしまい
n = int(input())
arr = sorted(list(map(int, input().split())), reverse=True)
h = {}
for a in arr:
    if a in h:
        h[a] += 1
    else:
        h[a] = 1
ans = 0
x, y = 0, 0
for k, v in h.items():
    if v >= 2:
        if x == 0:
            x = k
        elif y == 0:
            y = k
print(x * y)