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_ls = list(map(int, input().split()))

c = Counter(a_ls)
edges_ls = [0] * 2
for value, count in c.items():
    if count >= 2:
        edges_ls.append(value)
edges_ls.sort()
ans = edges_ls[-1] * edges_ls[-2]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    ac = Counter(a)
    r = 0
    acl = [i for i in ac if ac[i] >= 2]
    if len(acl) <= 1:
        print(r)
        sys.exit()
    i1 = 0
    i2 = 0
    for ei in acl:
        if ac[ei] >= 4:
            if i1 == 0:
                print(int(ei**2))
                sys.exit()
            else:
                print(int(ei * i1))
                sys.exit()
        else:
            if i1 == 0:
                i1 = ei
            else:
                print(int(ei * i1))
                sys.exit()
    #print(int(i1*i2))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    ac = Counter(a)
    r = 0
    acl = [i for i in ac if ac[i] >= 2]
    if len(acl) <= 1:
        print(r)
        sys.exit()
    i1 = 0
    i2 = 0
    for ei in acl:
        if ac[ei] >= 4:
            if i1 == 0:
                print(int(ei**2))
                sys.exit()
            elif i2 == 0:
                i2 = ei
        else:
            if i1 == 0:
                i1 = ei
            elif i2 == 0:
                i2 = ei
    print(int(i1*i2))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

import sys
from collections import Counter
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    ac = Counter(a)

    i1 = 0
    i2 = 0
    for eac in ac:
        if ac[eac] >= 4:
            if i1 == 0:
                print(int(eac**2))
                sys.exit()
            elif i2 == 0:
                i2 = eac
        elif ac[eac] >= 2:
            if i1 == 0:
                i1 = eac
            elif i2 == 0:
                i2 = eac
    print(int(i1*i2))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    ac = Counter(a)
    i1 = 0
    i2 = 0
    for eac in ac:
        if ac[eac] >= 2:
            if i1 == 0:
                i1 = eac
            elif i2 == 0:
                i2 = eac
    print(int(i1*i2))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    ac = Counter(a)
    i1 = 0
    i2 = 0
    for eac in ac:
        if ac[eac] >= 2:
            if i1 == 0:
                i1 = eac
            elif i2 == 0:
                i2 = eac
    if i1 == 0 or i2 == 0:
        print(0)
    else:
        print(i1*i2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# ABC071C

def unique(w):
    d = {}
    for c in w:
        if c in d.keys():
            d[c] += 1
        else:
            d.setdefault(c, 1)
    return d.items()

n = int(input())
a = list(map(int, input().split()))
d = unique(a)
side = []
ans = 0
for key, value in d:
    if value >= 4:
        ans = max(ans, key ** 2)
    elif value >= 2:
        side.append(key)
m = len(side)
if m >= 2:
    for i in range(m-1):
        for j in range(i+1, m):
            ans = max(ans, side[i] * side[j])
print(ans)

Submission status: Wrong Answer

Solution code:
# ABC071C

def unique(w):
    d = {}
    for c in w:
        if c in d.keys():
            d[c] += 1
        else:
            d.setdefault(c, 1)
    return list(d.keys()), list(d.values())

n = int(input())
a = list(map(int, input().split()))
index, count = unique(a)
index = index[::-1]
count = count[::-1]
side = []
ans = 0
for i, a in enumerate(count):
    if a >= 4:
        ans = index[i]**2
        break
    elif a >= 2:
        side.append(index[i])
        if len(side) == 2:
            ans = side[0] * side[1]
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
#n=6
#a=[3, 1, 2, 4, 2, 1]

a.sort(reverse=True)
print(a)

i=0
icnt=0
ai=0
while icnt<=1 and i<=n-2:
    icnt=1
#    print("3",i,a[i],a[i+1])
    while i<=n-2 and a[i]==a[i+1]:
        ai=a[i]
        i+=1
        icnt+=1 
#    print("1",i,icnt,ai)
    i+=1

#print("4",i,icnt,ai)
if icnt>=4:
    print(ai*ai)
elif icnt>=2:
    icnt=0
#    print("5",i)
    while icnt<=1 and i<=n-2:
        icnt=1
#        print("3",i,a[i],a[i+1])
        while i<=n-2 and a[i]==a[i+1] :
            ai2=a[i]
            i+=1
            icnt+=1
#        print("2",i,icnt,ai2)
        i+=1
    if icnt>=2:
        print(ai*ai2)
    else:
        print(0)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(int, input().split()))
a_count = collections.Counter(a)
a_list = list(a_count.items())
a_sorted = sorted(a_list, key=lambda x: x[0], reverse=True)
# print(a_sorted)

for i in range(len(a_sorted)):
    if a_sorted[i][1] >= 4:
        print(a_sorted[i][0]*a_sorted[i][0])
        exit()
    if i != len(a_sorted)-1:
        if a_sorted[i][1] >= 2 and a_sorted[i+1][1] >= 2:
            print(a_sorted[i][0] * a_sorted[i+1][0])
            exit()
print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

i = int(input())
li = list(map(int,input().split()))
c = collections.Counter(li)
li = list(set(li))
li.sort(reverse=True)
ans = 1
x = 0
i = 0

for i in li:
    if c[i] > 1:
        ans *= i
        x += 1
    if x == 2:
        break

if x == 2:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
i = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
ans = 1
x = 0
i = 0

while x < 2:
    y = li.count(li[i])
    if y > 1:
        ans *= li[i]
        x += 1
    i += y
    if i >= len(li) and x < 2: #最後まで見て2つ以上ある数が2つ以上なかったら
        print(0)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
i = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
ans = 1
x = 0
i = 0

while x < 2:
    y = li.count(li[i])
    if y > 1:
        ans *= li[i]
        x += 1
    i += y
    if i == len(li) and x < 2: #最後まで見て2つ以上ある数が2つ以上なかったら
        print(0)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
i = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
ans = 1
x = 0
i = 0

while x < 2:
    y = li.count(li[i])
    if y > 1:
        ans *= li[i]
        x += 1
        i += y
    else:
        i += 1
    if i == len(li) and x < 2:
        print(0)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
i = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
ans = 1
x = 0
i = 0

while x < 2:
    if li.count(li[i]) > 1:
        ans *= li[i]
        x += 1
        i += li.count(li[i])
    else:
        i += 1
    if i == len(li):
        print(0)
        exit()

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
cnt = defaultdict(int)
data = []
for i in range(n):
    cnt[a[i]] += 1
if sum(v >= 2 for v in cnt.values()) < 2:
    print(0)
else:
    for k, v in cnt.items():
        if v >= 2:
            data.append(k)
    data.sort(reverse = True)
    print(data[0] * data[1])

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
count = Counter(A)
keys = list(count.keys())
keys.sort(reverse = True)
a = 0
b = 0
for k in keys:
    if count[k] >= 4:
        a = b = k
        break
    elif count[k] >= 2:
        if a == 0:
            a = k
        else:
            b = k
            break
print(a * b)

Submission status: Wrong Answer

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


d = {}


for i in range(N):
    if A[i] in d:
        d[A[i]] += 1
        continue
    d[A[i]] = 1

d = sorted(d.items(), reverse=True)

a = []

for key, data in d:
    if data>=2:
        a.append(key)

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

Submission status: Wrong Answer

Solution code:
import collections

n=int(input())
a=list(map(int,input().split()))
a=collections.Counter(a)
a=sorted(a.items(),reverse=True)
#print(a)

tm=0

for i in range(n):
    if a[i][1]>=4:
        print(a[i][0]*a[i][0])
        exit()
    elif a[i][1]>=2:
        if tm==0:
            tm=a[i][0]
        else:
            print(tm*a[i][0])
            exit()

print("0")

Submission status: Wrong Answer

Solution code:
import collections

n=int(input())
a=list(map(int,input().split()))
a=collections.Counter(a)
a=sorted(a.items(),reverse=True)
#print(a)

tm=0

for i in range(n):
    if a[i][1]>=2:
        if tm==0:
            tm=a[i][0]
        else:
            print(tm*a[i][0])
            exit()

print("0")

Submission status: Wrong Answer

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

d = {}

for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

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

n.sort(reverse=True)

if len(n) >= 2:
    print(n[0] * n[1])
elif len(n) == 1 and d[n[0]] >= 4:
    print(n[0]**2)
else:
    print(0)

Submission status: Wrong Answer

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

d = {}

for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

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

n.sort(reverse=True)

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

Submission status: Wrong Answer

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

c = Counter(A)
sc = sorted(c.items(), key=lambda x: x[0], reverse=True)
sides = set()
sei = 0
for side, nums in sc:
    if nums >= 4:
        sei = side

    if nums >= 2:
        sides.add(side)

sq = sei*sei
if 1 >= len(sides):
    if sq != 0:
        print(sq)
    else:
        print(0)
else:
    sl = sorted(list(sides), reverse=True)
    print(max(sl[0]*sl[1], sq))

Submission status: Wrong Answer

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

c = Counter(A)
sc = sorted(c.items(), key=lambda x: x[0], reverse=True)
sides = set()
sei = 0
for side, nums in sc:
    if nums >= 4:
        sei = side

    if nums >= 2:
        sides.add(side)

sq = sei*sei
if len(sides) < 1:
    if sei != 0:
        print(sq)
    else:
        print(0)
else:
    sl = sorted(list(sides), reverse=True)
    print(max(sl[0]*sl[1], sq))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = sorted(set(a), reverse=True)
c = []
for i in b:
    if a.count(i) >= 4:
        print(i*i)
        exit(0)
    elif a.count(i) >= 2:
        c.append(i)
        if len(c)==2:
            print(c[0]*c[1])
            exit(0)
print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n, *A = map(int, open(0).read().split())
B = sorted([k for k, v in Counter(A).items() if v >= 2], reverse=1)
if len(B) < 2:
  print(0)
else:
  print(B[0]*B[1])

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
l = sorted(filter(lambda x:x[1] > 1,c.items()),reverse=True)

if len(l) == 0:
  print(0)
else:
  print(l[0][0]*l[1][0])

Submission status: Wrong Answer

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

l = sorted(Counter(A).items(), key=lambda x:x[0],reverse=True)
#print(l)
if l[1][1] < 2:
  print(0)
else:
  print(l[0][0]*l[1][0])

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
A=Counter(A)
S=[]
for i,j in A.items():
  if j>=2:
    S.append(i)

S.sort()

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
A=Counter(A)
S=[]
for i,j in A.items():
  if j>=2:
    S.append(i)
S=list(set(S))
S.sort()

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
D = Counter(A)
res = []
for k, v in D.items():
    if v >= 2:
        res.append(k)
if len(res) < 2:
    print(0)
else:
    res = sorted(res, reverse=True)
    print(res[0] * res[1])

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
ns = list(map(int, input().split()))
dic = Counter(ns)
dic = {key:value for key, value in dic.items() if value>=2}
if len(dic) < 2:
    print(0)
else:
    sorted_dic = sorted(dic.items(), key=lambda x: x[0])
    print(sorted_dic[-1][0] * sorted_dic[-2][0])

Submission status: Wrong Answer

Solution code:
from collections import Counter as C
n,*a=map(int,open(0).read().split())
b=sorted([i[0] for i in C(a).items() if i[1]>1])
print(b[-1]*b[-2] if len(b)>1 else 0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())),reverse = True)
c_ls = []
for i in range(n-1):
  if (a[i] == a[i+1]) and(a[i] not in c_ls):
    c_ls.append(a[i])
    if len(c_ls) == 2:
      print(c_ls[0]*c_ls[1])
      exit()
print(0)

Submission status: Wrong Answer

Solution code:
import collections 
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
b=list(set(a))[::-1]
ans,count=0,0
for i in b:
  if c[i]>3 and ans==0:
    print(i**2)
    exit()
  if c[i]>1:
    ans=ans*i if ans>0 else i
    count+=1
    if count==2:
      print(ans)
      exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import collections 
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
x,y=0,0
b=list(set(a))[::-1]
for i in b:
  if c[i]>3 and x==y==0:
    print(i**2)
    exit()
  if c[i]>1:
    y=i if x>0 and y==0 else y
    x=i if x==0 else x
  if x*y>0:
    print(x*y)
    exit()
print(x*y)

Submission status: Wrong Answer

Solution code:
import collections 
n=int(input())
a=list(map(int,input().split()))
c=collections.Counter(a)
x,y=0,0
b=list(set(a))[::-1]
for i in b:
  if c[i]>3:
    print(i**2)
    exit()
  elif c[i]>1:
    y=i if x>0 and y==0 else y
    x=i if x==0 else x
  if x*y>0:
    print(x*y)
    exit()
print(x*y)

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))
b = list(set(a))
b.sort(reverse=True)
b_dict={}
for i in b:
  b_dict[i]=a.count(i)

h_max=0

for i in b:
  if b_dict[i]>=4:
    print(i**2)
    exit()
  elif b_dict[i]>=2:
    if h_max==0:
      h_max=i
    else:
      print(h_max*i)
      exit()
print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))
pcount=[0]*len(set(a))
b=list(set(a))
b.sort(reverse=True)

for i in range(len(b)):
  pcount[i] = a.count(b[i])

h_max=0
w_max=0
flag =False
for i in range(len(b)):
  if pcount[b.index(max(b))]>=4:
    print(max(b)*max(b))
    exit()
  elif pcount[b.index(max(b))]>=2 and not flag:
    h_max=max(b)
    flag = True
  elif pcount[b.index(max(b))]>=2 and flag:
    w_max=max(b)
    break
  b.remove(max(b))
print(h_max*w_max)

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))
pcount=[0]*len(set(a))
b=list(set(a))
b.sort(reverse=True)

for i in range(len(b)):
  pcount[i] = a.count(b[i])

h_max=0
w_max=0
flag =False
for i in range(len(b)):
  if pcount[b.index(max(b))]>=4:
    print(max(b)*max(b))
    exit()
  elif pcount[b.index(max(b))]>=2 and not flag:
    h_max=max(b)
    flag = True
  elif pcount[b.index(max(b))]>=2 and flag:
    w_max=max(b)
    break
  b.remove(max(b))
  print(b)
print(h_max*w_max)

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))
pcount=[0]*len(set(a))
b=list(set(a))

for i in range(len(b)):
  pcount[i] = a.count(b[i])

h_max=0
w_max=0
flag =False
for i in range(len(b)):
  if pcount[b.index(max(b))]>=4:
    print(max(b)*2)
    exit()
  elif pcount[b.index(max(b))]>=2 and not flag:
    h_max=max(b)
    flag = True
  elif pcount[b.index(max(b))]>=2 and flag:
    w_max=max(b)
    break
  b.remove(max(b))
print(h_max*w_max)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
work = []
for k, v in sorted(counter.items(), key=lambda x:(x[0],x[1]), reverse=True):
    if v >= 2:
        work.append(k)
        if len(work)==2:
            break
if len(work) < 2:
    result = 0
else:
    result = work[0]*work[1]
print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = list(map(int, input().split()))
lst.sort()
count = set()

for i in range(n-1):
    if lst[i]==lst[i+1]:
        count.add(lst[i])
count2 = sorted(count, reverse=True)
count2.append(0)
count2.append(0)
print(count2[0]*count2[1])

Submission status: Wrong Answer

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

a.sort(reverse=True)

i1=-1
lena1=0
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        lena1=a[i+1]
        i1=i
        break
if i1==-1:        
    print(0)
elif i1+1<len(a)-1:        
    lena2=0
    for i in range(i1+1,len(a)-1):
        if a[i]==a[i+1] and a[i]!=lena1:
            lena2=a[i+1]
            break
    print(lena1*lena2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
a = collections.Counter(a)
wh = 0
for i in a.keys():
  if a[i] >= 4:
    print(i ** 2)
    exit()
  elif a[i] >= 2:
    if wh == 0:
      wh = i
    else:
      print(wh * i)
      exit()
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = []
for i in range(n-1):
    if a[i] == a[i+1]:
        ans.append(a[i])
ans1 = set(ans)
ans2 = sorted(ans1, reverse=True)
if len(ans1) == 1 and a.count(ans[0]) >= 4:
    print(ans[0]**2)
elif len(ans1) >= 2:
    print(ans2[0]*ans2[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
cnt=1
li=[]
x=0
for i in range(n-1):
    if a[i+1]==a[i]:
        cnt+=1
    else:
        cnt=1
    if cnt==2:
        li.append(a[i+1])
    if cnt==4:
        x=a[i+1]

if len(li)>=2:
    print(max(li[0]*li[1],x**2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections

n, *a = map(int, open(0).read().split())
c = collections.Counter(a)
length_l = list(c.keys())
length_l.sort(reverse = True)
side1 = 0
ans = 0
for l in length_l:
    cnt = c[l]
    if cnt >= 4:
        ans = l**2
        break
    elif cnt >= 2:
        if side1 != 0:
            ans = side1*l
            break
        else:
            side1 = l
print(ans)

Submission status: Wrong Answer

Solution code:
import collections

n, *a = map(int, open(0).read().split())
c = collections.Counter(a)
length_l = list(c.keys())
length_l.sort(reverse = True)
side1 = 0
ans = 0
for l in length_l:
    cnt = c[l]
    if cnt >= 4:
        if side1 != 0:
            ans = side1*l
            break
        else:
            ans = l*2
            break
        break
    elif cnt >= 2:
        if side1 != 0:
            ans = side1*l
            break
        else:
            side1 = l
print(ans)

Submission status: Wrong Answer

Solution code:
import collections

n, *a = map(int, open(0).read().split())
c = collections.Counter(a)
length_l = list(c.keys())
length_l.sort(reverse = True)
side1 = 0
ans = 0
for l in length_l:
    cnt = c[l]
    if cnt >= 4:
        ans = cnt*2
        break
    elif cnt >= 2:
        if side1 != 0:
            ans = side1*l
            break
        else:
            side1 = l
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter


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

    count = Counter(A)
    count = sorted(count.items(), key=lambda x: (-x[0], x[1]))
    count = [(k, v) for k, v in count if v >= 2]
    if len(count) < 2:
        print(0)
    else:
        print(count[0][0] * count[1][0])


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

import collections
lst=collections.Counter(A).most_common()
lst_larger=[el for el in lst if el[1]>=2]
#print(lst)
#print(lst_larger)
if len(lst_larger) >= 2:
    lst_larger=sorted(lst_larger, key=lambda x:x[0], reverse=True)
    print(lst_larger[0][0]*lst_larger[1][0])
else:
    print(0)

Submission status: Wrong Answer

Solution code:

def main2():
    r = int(input())

    stick = [int(v) for v in input().split()]
    stick = sorted(stick, reverse=True)

    line = []
    tmp = -1
    for i in range(len(stick), 1):
        if tmp == stick[i]:
            line.append(stick[i])
            tmp = -1
        tmp = stick[i]
        if len(line) == 2:
            print(line[0] * line[1])

    print(0)

main2()

Submission status: Wrong Answer

Solution code:
def main2():
    r = int(input())

    stick = [int(v) for v in input().split()]
    stick = sorted(stick, reverse=True)

    line = []
    for i in range(len(stick), 2):
        if stick[i] == stick[i + 1]:
            line.append(stick[i])
        if len(line) == 2:
            print(line[0] * line[1])
            
    print(0)
    
main2()

Submission status: Wrong Answer

Solution code:
r = int(input())

stick = [int(v) for v in input().split()]
stick = sorted(stick, reverse=True)
s_stick = sorted(set(stick), reverse=True)

line = []
for v in s_stick:
    if stick.count(v) >= 4:
        print(v * v)
        exit()
    if stick.count(v) >= 2:
        line.append(v)
        if len(line) == 2:
            print(line[0] * line[1])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
r = int(input())

stick = [int(v) for v in input().split()]
stick = sorted(stick, reverse=True)
s_stick = sorted(set(stick), reverse=True)

line = []
for v in s_stick:
    if stick.count(v) == 4:
        print(v * v)
        exit()
    if stick.count(v) >= 2:
        line.append(v)
        if len(line) == 2:
            print(line[0] * line[1])
            exit()
print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

import collections

C = collections.Counter(A)

D = sorted(list(set(A)))[::-1]

t = 0
s = 0
for i in D:
    if C[i] >= 4:
        print(i ** 2)
        s = 1
        break
    elif C[i] >= 2 and t == 0:
        t = i
    elif C[i] >= 2 and t != 0:
        print(i * t)
        s = 1
        break

if s == 0:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

a = input()
a_list = list(map(int, input().split()))
 
# 要素数の数え上げと取り出し
num_counter = Counter(a_list)
num_keys = sorted(num_counter.keys(), reverse=True)

big = 0
small = 0

for i in num_keys:
  x = num_counter[i]
  if x >= 4:
    if big == 0:
      big = small = i
    elif big != 0 and small == 0:
      small = i
  elif x == 3 or x == 2:
    if big == 0:
      big = i
    elif big != 0 and small == 0:
      small = i
  if big != 0 and small != 0:
    break
print(big, small, big * small)

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
a=map(int,input().split())
b=list(collections.Counter(a).items())
lst=[]
Lst=[]
for i in range(len(b)):
  if b[i][1]>1:
    lst.append(int(b[i][0]))  
    if b[i][1]>3:
      Lst.append(int(b[i][0]))
if len(lst)<2 and len(Lst)==0:
  print(0)
else:
  if len(lst)==1:
    print(Lst[0]**2)
  elif len(Lst)>0:
    lst.sort(reverse=True)
    Lst.sort(reverse=True)
    print(max(lst[0]*lst[1],Lst[0]**2))
  else:
    print(lst[0]*lst[1])

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
a=list(map(int,input().split()))
b=list(collections.Counter(a).items())
lst=[]
Lst=[]
for i in range(len(b)):
  if b[i][1]>1:
    lst.append(int(b[i][0]))  
    if b[i][1]>3:
      Lst.append(int(b[i][0]))
if len(lst)<2 and len(Lst)==0:
  print(0)
else:
  if len(Lst)>0 and len(lst)>1:
    lst.sort(reverse=True)
    Lst.sort(reverse=True)
    print(max(lst[0]*lst[1],Lst[0]**2))
  elif len(Lst)==0:
    print(lst[0]*lst[1])
  elif len(lst)==1:
    print(Lst[0]**2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
dict = {}
b = []
for i in a:
	if i in dict:
		dict[i] += 1
	else:
		dict[i] = 1
	if dict[i] == 2:
		b.append(i)
b.sort(reverse=True)
if len(b) < 2:
	print (0)
else:
	print (b[0] * b[1])

Submission status: Wrong Answer

Solution code:
from collections import Counter
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    cnter = Counter(A)
    cnter_list = list(cnter.items())
    cnter_list.sort(key=lambda x:x[0], reverse=True)

    double_cnt = 0
    ans = 1
    for elem in cnter_list:
        if elem[1] >= 4:
            if double_cnt == 0:
                ans = elem[0] * elem[0]
                double_cnt += 2

        if elem[1] >= 2:
            double_cnt += 1
            ans *= elem[0]
        if double_cnt >= 2:
            break
    else:
        print(0)
        return
    
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    cnter = Counter(A)
    cnter_list = list(cnter.items())
    cnter_list.sort(key=lambda x:x[0], reverse=True)

    double_cnt = 0
    ans = 1
    for elem in cnter_list:
        if elem[1] >= 4:
            if double_cnt == 0:
                ans *= elem[0] * elem[0]
                double_cnt += 2

        if elem[1] >= 2:
            double_cnt += 1
            ans *= elem[0]
        if double_cnt >= 2:
            break
    else:
        print(0)
        return
    
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    cnter = Counter(A)
    cnter_list = list(cnter.items())
    cnter_list.sort(key=lambda x:x[0], reverse=True)

    double_cnt = 0
    ans = 1
    for elem in cnter_list:
        if elem[1] >= 2:
            double_cnt += 1
            ans *= elem[0]
        if double_cnt >= 2:
            break
    else:
        print(0)
        return
    
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

import collections
ans = 0
c = collections.Counter(A)
lis = []
for k,v in c.items():
  if v>=2:
    lis.append(k)
if len(lis)>=2:
  lis.sort()
  ans = lis[-1]*lis[-2]
print(ans)

#print(*ans, sep='\n')

Submission status: Wrong Answer

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

a.sort()
max1, max2 = 0, 0

i = n-1
while i > 0:
    if a[i] == a[i-1]:
        max1 = a[i]
        break
    else:
        i -= 1

c = a.count(max1)
j = i - c
while j > 0:
    if a[j] == a[j-1]:
        max2 = a[j]
        break
    else:
        j -= 1

print(max1 * max2)

Submission status: Wrong Answer

Solution code:
# Author: cr4zjh0bp
# Created: Tue Mar 24 00:01:43 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import Counter

n = ni()
a = na()
c = Counter(a)
m = list(c.items())
m.sort(reverse=True)
xy = [0] * 2
i = 0
flag = False
for k, v in m:
    if v >= 4:
        print(k * k)
        flag = True
        break
    elif v >= 2:
        xy[i] = k
        i += 1
        if i == 2:
            print(xy[0] * xy[1])
            flag = True
            break
if not flag:
    print(0)