Problem: 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.

Submission attempts (in order):
_=input()
bars=[i for i in map(int,input().split())]
bars.sort(reverse=True)
stock=[]
ret=0
for bar in bars:
    count=bars.count(bar)
    if count>=4:
        ret=bar*bar
        break
    elif count>=2:
        stock.append(bar)
        if len(stock)==2:
            ret=stock[0]*stock[1]
            break
print(ret)

#coding utf-8
_=input()
bars=[i for i in map(int,input().split())]
bars.sort(reverse=True)
stock=[]
ret=0
for bar in bars:
    count=bars.count(bar)
    if count>=4:
        if len(stock)!=0:
            ret=bar*stock[0]
        else:
            ret=bar*bar
        break
    elif count>=2:
        stock.append(bar)
        if len(stock)==2:
            ret=stock[0]*stock[1]
            break
print(ret)

#coding utf-8
import numpy as np
_=input()
bars=[i for i in map(int,input().split())]
np_data=np.array(bars)
bars.sort(reverse=True)

stock=[]
len_stock=0
ret=0
_old=-1
for bar in bars:
    if bar==_old:
        continue
    _old=bar
    count=len(np.where(bar))
    if count>=4:
        if len_stock!=0 and  bar not in stock:
            
            ret=bar*stock[0]
        else:
            
            ret=bar*bar
        break
    elif count>=2:
        if bar in stock:
            continue
        stock.append(bar)
        len_stock+=1
        if len_stock==2 :
            
            ret=stock[0]*stock[1]
            break
print(ret)

#coding utf-8
_=input()
bars=[i for i in map(int,input().split())]
bars.sort(reverse=True)
stock=[]
ret=0
_old=-1
for bar in bars:
    if bar=_old:
        continue
    _old=bar
    count=bars.count(bar)
    if count>=4:
        if len(stock)!=0 and  bar not in stock:
            
            ret=bar*stock[0]
        else:
            
            ret=bar*bar
        break
    elif count>=2:
        if bar in stock:
            continue
        stock.append(bar)
        if len(stock)==2 :
            
            ret=stock[0]*stock[1]
            break
print(ret)

#coding utf-8
_=input()
bars=[i for i in map(int,input().split())]
bars.sort(reverse=True)
stock=[]
ret=0
for bar in bars:
    count=bars.count(bar)
    if count>=4:
        if len(stock)!=0 and bar not in stock:
            ret=bar*stock[0]
        else:
            ret=bar*bar
        break
    elif count>=2:
        stock.append(bar)
        if len(stock)==2:
            ret=stock[0]*stock[1]
            break
print(ret)

#coding utf-8
import collections
_=input()
bars=[i for i in map(int,input().split())]
data=sorted(collections.Counter(bars).items(),key= lambda x: -x[0] )
stock=0
ret=0
for bar ,count in data:
    if count>=4:
        if stock:
            ret=stock*bar
            break
        else:
            ret=bar*bar
            break
    elif count>=2:
        if stock:
            ret=stock*bar
            break
        else:
            stock=bar
print(ret)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted