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:
import collections

n = int(input())
a = list(map(int, input().split()))
ac = collections.Counter(a)
can = []
for i in ac:
    if ac[i] >= 2:
        can.append((i, ac[i]))
can = sorted(can, reverse=True)
ans = []
for i in can:
    if len(ans) == 2:
        break
    if i[1] >= 4:
        print(i[1] ** 2)
        exit()
    elif i[1] >= 2:
        ans.append(i[0])
if len(ans) == 2:
    print(ans[0] * ans[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
list_a = list(map(int, input().split()))
dict_a = {}
for i in range(n):
    try:
        dict_a[list_a[i]] += 1
    except KeyError:
        dict_a[list_a[i]] = 1
key_list = []
for key,value in dict_a.items():
    if value > 1:
        key_list.append(key)
key_list.sort()
try:
    print(key_list[-1] * key_list[-2])
except IndexError:
    print(0)

Submission status: Wrong Answer

Solution code:
ai = lambda: list(map(int, input().split()))

n = int(input())
a = ai()
from collections import Counter
c = Counter(a)
a = [i for i in c if c[i]>1]
a.sort()
if len(a)>0 and c[a[-1]]>1:
    print(a[-1]**2)
elif len(a)<2:
    print(0)
else:
    print(a[-1]*a[-2])

Submission status: Wrong Answer

Solution code:
ai = lambda: list(map(int, input().split()))

n = int(input())
a = ai()
from collections import Counter
c = Counter(a)
a = [i for i in c if c[i]>1]
a.sort()
if len(a)<2:
    print(0)
else:
    print(a[-1]*a[-2])

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = Counter(map(int, input().split()))
ans = 0
b = [k for k, v in sorted(a.items()) if v >= 2]
for k, v in sorted(a.items(), reverse=True):
    if v >= 4:
        ans = k * k
if len(b) >= 2:
    ans = max(ans, b[-1] * b[-2])
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = Counter(map(int, input().split()))
ans = 0
b = [k for k, v in sorted(a.items()) if v >= 2]
for k, v in sorted(a.items(), reverse=True):
    if v >= 4:
        ans = 2 * k
if len(b) >= 2:
    ans = max(ans, b[-1] * b[-2])
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = Counter(map(int, input().split()))
ans = 0
b = [k for k, v in sorted(a.items()) if v >= 2]
if len(b) >= 2:
    ans = b[-1] * b[-2]
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
d = {}

for x in input().split():
    a = int(x)
    if a not in d:
        d[a] = 0
    d[a] += 1

ret = []
kk = list(d.keys())
kk.sort(reverse=True)
for k in kk:
    if d[k]>=4:
        print(k**2)
        exit()
    if d[k]>=2:
        ret.append(k)
        if len(ret)==2:
            print(ret[0]*ret[1])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
# cook your dish here
n  =  int(input())
a= list(map(int,input().split()))

a.sort()
ass = []
ans  =[]
d = 0

for i in range(n-1):
    if a[i] == a[i+1]:
        ass.append(a[i])
        d += 1
        if d == 3:
            ans.append(a[i])
    else:
        d = 0
ass = list(set(ass))

if ans != []:
    if max(ans)==max(ass):
        print(max(ans)*max(ans))
    else:
        print(ass[len(ass)-1]*ass[len(ass)-2])
else:
    if len(ass) == 0 or len(ass) == 1:
        print(0)
    else:
        print(ass[len(ass)-1]*ass[len(ass)-2])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

from collections import Counter

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

#check = []
lenghts = []

"""
for i in range(N):
    if A[i] not in check or A[i] in lenghts:
        check.append(A[i])
    else:
        lenghts.append(A[i])
"""

for i in range(N):
    if A[i] not in lenghts:
        lenghts.append(A[i])


if len(lenghts)<2:
    print(0)
else:
    l = max(lenghts)
    lenghts.remove(l)
    w = max(lenghts)
    print(l*w)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

check = []
lenghts = []

for i in range(N):
    if A[i] not in check or A[i] in lenghts:
        check.append(A[i])
    else:
        lenghts.append(A[i])


if len(lenghts)<2:
    print(0)
else:
    l = max(lenghts)
    lenghts.remove(l)
    w = max(lenghts)
    print(l*w)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
p = 0
for i in range(n-1,-1, -2):
    if a[i] == a[i-1]:
        if p:
            print(p*a[i])
            exit()
        else:
            p = a[i]

print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from operator import itemgetter

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

c = Counter(a)

d = sorted(list(c.items()), key=itemgetter(0), reverse=True)

a = 0
b = 0
for i in d:
	if i[1] >= 4:
		a = i[0]
		b = i[0]
		break
	elif i[1] >= 2 and a == 0:
		a = i[0]
		continue
	elif i[1] >= 2 and a != 0:
		b = i[0]
		break

print(a * b)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from operator import itemgetter

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

c = Counter(a)

d = sorted(list(c.items()), key=itemgetter(0), reverse=True)

a = 0
b = 0
for i in d:
	if i[1] >= 4:
		a = i[0]
		b = i[0]
		break
	elif i[1] >= 2 and a == 0:
		a = i[0]
	elif i[1] >= 2 and a != 0:
		b = i[0]
		break

print(a * b)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

c = Counter(a)

a = 0
b = 0
for i in list(c.items()):
	if i[1] >= 4:
		a = i[0]
		b = i[0]
		break
	elif i[1] >= 2 and a == 0:
		a = i[0]
	elif i[1] >= 2 and a != 0:
		b = i[0]
		break

print(a * b)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

c = Counter(a)

a = 0
b = 0
for key, value in c.items():
	if value >= 4:
		a = key
		b = key
		break
	elif value >= 2 and a == 0:
		a = key
	elif value >= 2 and a != 0:
		b = key
		break

print(a * b)

Submission status: Wrong Answer

Solution code:
from collections import Counter
input();a=sorted(Counter(map(int,input().split())).most_common())[::-1];c=b=0
for i in range(len(set(a))):
    if b and c:print(c*b);exit()
    if a[i][1]>3 and a[i][0]*c<a[i][0]**2:b=c=a[i][0]
    elif a[i][1]>1:b,c=c,a[i][0]

Submission status: Wrong Answer

Solution code:
from collections import Counter
input();a=sorted(Counter(map(int,input().split())).most_common())[::-1];c=b=0
for i in range(len(set(a))):
    if b and c:break
    if a[i][1]>3 and b*c<a[i][0]**2:b=c=a[i][0]
    elif a[i][1]>1:b,c=c,a[i][0]
print(c*b)

Submission status: Wrong Answer

Solution code:
from collections import Counter
input();a=sorted(Counter(map(int,input().split())).most_common())[::-1];c=b=0
for i in range(len(set(a))):
    if b and c:break
    if a[i][1]>3:b=c=a[i][0]
    if a[i][1]>1:b,c=c,a[i][0]
print(c*b)

Submission status: Wrong Answer

Solution code:
from collections import Counter
input();a=sorted(Counter(map(int,input().split())).most_common())[::-1];c=b=0
for i in range(len(set(a))):
    if b and c:break
    if a[i][1]>3:b=c=a[i][0]
    elif a[i][1]>1:b,c=c,a[i][0]
print(c*b)

Submission status: Wrong Answer

Solution code:
from collections import Counter
input();a=sorted(Counter(map(int,input().split())).most_common())[::-1];c=b=0
for i in range(len(set(a))):
    if a[i][1]>3:b=c=a[i][0]
    elif a[i][1]>1:b,c=c,a[i][0]
    if b and c:break
print(c*b)

Submission status: Wrong Answer

Solution code:
from collections import Counter
input();a=sorted(Counter(map(int,input().split())).most_common())[::-1];c=b=0
for i in range(len(set(a))):
    if a[i][1]>1:b,c=c,a[i][0]
    if b and c:break
print(c*b*(c!=b))

Submission status: Wrong Answer

Solution code:
from collections import Counter
input();a=sorted(Counter(map(int,input().split())).most_common())[::-1];c=b=0
for i in range(len(set(a))):
    if a[i][1]>1:b,c=c,a[i][0]
    if b and c:break
print(c*b)

Submission status: Wrong Answer

Solution code:
input();*a,=sorted(map(int,input().split()));c=b=0
for x in set(a):
    if a.count(x)>1:b,c=c,x
print(c*b)

Submission status: Wrong Answer

Solution code:
from collections import Counter
input();a=sorted(Counter(map(int,input().split())).most_common());c=b=0
for i in range(len(set(a))):
    if a[i][1]>1:b,c=c,a[i][0]
print(c*b)

Submission status: Wrong Answer

Solution code:
from collections import Counter
input();a=Counter(map(int,input().split())).most_common();i=c=b=0
for i in range(len(set(a))):
    if a[i][1]>1:b,c=c,a[i][0]
print(c*b)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())

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

ans = []

for k,v in sorted(A.items(),key=lambda x:x[0],reverse=True):
    if v>=2:
        ans.append(k)
    if len(ans)>=2:
        break
        
print(ans[0]*ans[1] if len(ans)>=2 else 0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
import collections
data=collections.Counter(a)
ans_2=[]
ans_4=[]
for i,j in data.items():
    if 4<=j:
        ans_4.append(i)
    if 2<=j<=3:
        ans_2.append(i)
ans_2.sort()
ans_2.reverse()
ans_4.sort()
ans_4.reverse()
max_4=max_2=mix_24=0
if len(ans_4)!=0 and len(ans_2)==0:
    max_4=ans_4[0]*ans_4[0]
if 2<=len(ans_2):
    max_2=ans_2[0]*ans_2[1]
if len(ans_4)!=0 and len(ans_2)!=0:
    mix_24=ans_2[0]*ans_4[0]
print(max(max_2,max_4,mix_24))

Submission status: Wrong Answer

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

for i in A:
    if A[i]>=2:
        a.append(i)
    if A[i]>=4:
        a.append(i)
print(a[-1]*a[-2])

Submission status: Wrong Answer

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

for i in A:
    if A[i]>=2:
        a.append(i)
    elif A[i]>=4:
        a.append(i)
print(a[-1]*a[-2])

Submission status: Wrong Answer

Solution code:
num  =  input().split()
numA  =  input().split()
num_a = list( map((lambda x:int(x)),numA))

numB = list(set(numA))
numB.sort()

atumari = [numA.count(numB[w]) for w in range(len(numB))]

tyouhoukei = [x+1 for x in range(len(atumari)) if atumari[x] >= 2]
seihoukei  = [x+1 for x in range(len(atumari)) if atumari[x] >= 4]
tyouhoukei.insert(0,0)
seihoukei.insert(0,0)

if (len(tyouhoukei) >= 3) or (len(seihoukei) >= 2):
    if max(tyouhoukei) < max(seihoukei):
        print(max(seihoukei))
    elif len(tyouhoukei) >= 3:
        print(max(tyouhoukei))
    else:
        print(0)
else:
    print(0)

Submission status: Wrong Answer

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

cnt = {}
for a in A:
	if a in cnt:
		cnt[a] += 1
	else:
		cnt[a] = 1

cnt = sorted(cnt.items(), key=lambda x: x[0], reverse=True)

cand2 = []
cand4 = []
for key,value in cnt:
	if value >= 4:
		cand4.append(key)
	elif value >= 2:
		cand2.append(key)
cand4.append(0)
cand2.append(0)
cand2.append(0)

print(max(cand4[0] * cand4[0], cand2[0] * cand2[1]))

Submission status: Wrong Answer

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

cnt = {}
for a in A:
	if a in cnt:
		cnt[a] += 1
	else:
		cnt[a] = 1

cnt = sorted(cnt.items(), key=lambda x: x[0], reverse=True)
side1 = 0
side2 = 0
for key,value in cnt:
	if value >= 4:
		if side1 == 0:
			side1 = key
			side2 = key
			break
	elif value >= 2:
		if side1 == 0:
			side1 = key
		elif side2 == 0:
			side2 = key
			break

print(side1*side2)

Submission status: Wrong Answer

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

cnt = {}
for a in A:
	if a in cnt:
		cnt[a] += 1
	else:
		cnt[a] = 1

cnt = sorted(cnt.items(), key=lambda x: x[0], reverse=True)
side1 = 0
side2 = 0
for key,value in cnt:
	if value >= 2:
		if side1 == 0:
			side1 = key
		elif side2 == 0:
			side2 = key
			break

print(side1*side2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter
import math
N = int(input())

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

cnter = Counter(As)
V = dict()
select = 0

for k, v in cnter.most_common():
    if v>=2:
        V[k] = math.floor(v/2)
#print(V)
tmp = 0
h = 0

if len(V) < 2:
    print(0)
    exit()

for k, v in sorted(V.items(), key=lambda x:-x[0]):
    if v >= 2:
        print(int(k*k))
        exit()
    else:
        if(tmp==1):
            print(int(h*k))
            exit()
        tmp += 1
        h = k

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter

N = int(input())

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

cnter = Counter(As)
V = dict()
select = 0

for k, v in cnter.most_common():
    if v>=2:
        V[k] = v/2
#print(V)
tmp = 0
h = 0

if len(V) < 2:
    print(0)
    exit()

for k, v in sorted(V.items(), key=lambda x:-x[0]):
    if v >= 2:
        print(int(k*k))
        exit()
    else:
        if(tmp==1):
            print(int(h*k))
            exit()
        tmp += 1
        h = k

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

N = int(input())
data = input()
A = data.split(" ")
dict = {}
for i in A:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1

a = 0
b = 0
for i in sorted(dict.items(),key = lambda x:int(x[0])):
    if i[1] >= 2:
        if int(i[0]) >= min(a,b):
            if a >= b:
                b = int(i[0])

            else:
                a = int(i[0])

print(a*b)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

N = int(input())
data = input()
A = data.split(" ")
dict = {}
for i in A:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1

a = 0
b = 0
for i in sorted(dict.items(),key = lambda x:x[1]):
    if i[1] == 2:
        if a == 0:
            a = int(i[0])
            
        else:
            b = int(i[0])

print(a*b)

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))


def main():
    n = int(input())
    a = sorted(readLine_int_list(),reverse=True)
    a.append(-1)
    pair = []
    ans = 0
    t = 1
    
    for i in range(n):
        
        if a[i] == a[i+1]:
            t += 1
        else:
            if t > 1:
                pair.append(a[i])
            t = 1
        
        if t > 3:
            ans = a[i]*a[i+1]
            break

        
        if len(pair) >= 2:
            ans = pair[0] * pair[1]
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))


def main():
    n = int(input())
    a = sorted(readLine_int_list(),reverse=True)

    pair = []
    ans = 0
    t = 1

    for i in range(n-1):
        
        if a[i] == a[i+1]:
            t += 1
        else:
            if t > 1:
                pair.append(a[i])
            t = 1
        
        if t > 3:
            ans = a[i]*a[i+1]
            break
        
        
        if len(pair) >= 2:
            ans = pair[0] * pair[1]
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))


def main():
    n = int(input())
    a = readLine_int_list()
    set_a = sorted(list(set(a)), reverse=True)
    pair = []
    
    ans = 0
    for i in set_a:
        c = a.count(i)
        if c > 3:
            pair.append(i)
            pair.append(i)
        elif c > 1:
            pair.append(i)
            
        if len(pair) == 2:
            ans = pair[0] * pair[1]
            break

    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))
def readLine_int_list_reverse(): return list(map(int, stdin.readline().split())).reverse()


def main():
    n = int(input())
    # a = sorted(readLine_int_list(), reverse=True)
    a = readLine_int_list()
    set_a = sorted(list(set(a)), reverse=True)
    pair = []
    for i in set_a:
        c = a.count(i)
        if c > 1:
            pair.append(i)
        if len(pair) == 2:
            break
    
    if len(pair) > 1:
        print(pair[-1] * pair[-2])
    else:
        print(0)
        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))

def main():
    n = int(input())
    a = sorted(readLine_int_list())
    set_a = list(set(a))
    pair = []
    for i in set_a:
        c = a.count(i)
        if c > 1:
            pair.append(i)

    
    if len(pair) > 1:
        print(pair[-1] * pair[-2])
    else:
        print(0)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
stick_num = input()
area_length_list = list(map(int, input().split()))

# print(area_length_list)

# 要素の中から、2つ以上存在しているものを2組選ぶ。

s = set()
result = []
for x in area_length_list:
	if x in s:
		result.append(x)
	s.add(x)
if result == []:
	print (0)
	sys.exit()
max_value = max(result)
# 1番大きい値の組が4つある場合のみ、正方形をつくる。
max_value_num = area_length_list.count(max_value)
if max_value_num >= 4:
	print(max_value^2)
	sys.exit()

# リストの数が2未満のときは、0を出力　※正方形の場合を除く
if len(result) < 2:
	print(0)
	sys.exit()

# 長方形の面積
for i in range(1, max_value_num):
	result.remove(max_value)
second_max_value = max(result)
print(max_value*second_max_value)

Submission status: Wrong Answer

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

a = sorted(a, reverse = True)
a.append(0)
a.append(0)
a.append(0)
a.append(0)
#print(a)

i = 0
s = 1
cnt=0
while i<n-1 and cnt <2:
    if (a[i]==a[i+1]):
        s*=a[i]
        i+=2
        cnt+=1
    else:
        i+=1
print(s)

Submission status: Wrong Answer

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

sorted(a, reverse = True)
a.append(0)
a.append(0)
a.append(0)
a.append(0)
#print(a)

i = 0
s = 1
cnt=0
while i<n-1 and cnt <2:
    if (a[i]==a[i+1]):
        s*=a[i]
        i+=2
        cnt+=1
    else:
        i+=1
print(s)

Submission status: Wrong Answer

Solution code:
n = int(raw_input())

occ = {}
for i in map(int, raw_input().split()):
    if not i in occ:
        occ[i] = 0

    occ[i] += 1

found = 0
rect = 1

for i in sorted(occ, reverse=True):
    if occ[i] > 1:
        found += 1
        rect *= i

    if found == 2:
        print rect
        break
    
if found < 2:
    print 0

Submission status: Wrong Answer

Solution code:
from collections import OrderedDict
N = int(input())
num = list(map(int,input().split()))
data = {}
for i in range(N):
	a = num[i]  
	if a in data:
		data[a] += 1
	else:
		data[a] = 1
data = OrderedDict(sorted(data.items(), key =lambda x:x[0],reverse = True))
sides = list(data.keys())
sides_num = list(data.values())
def recta(sides,sides_num):
        num = []
        for i in range(len(sides_num)):
            if 4> sides_num[i] >= 2:
                num.append(sides[i])
            elif sides_num[i] >= 4:
                if len(num) == 0:
                    num.append(sides[i])
                    num.append(sides[i])
            if len(num) == 2:
                return(num[0]*num[1])
                break
        return(0)
print(recta(sides,sides_num))

Submission status: Wrong Answer

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

bar_list = {}
for i in a:
	if i in bar_list:
		bar_list[i] += 1
	else:
		bar_list[i] = 1

saved = -1
ans = 0
for k, v in sorted(bar_list.items(), key=lambda x:x[1]):
	if v > 1:
		if saved < 0:
			saved = k
		else:
			ans = saved * k
			break
	else:
		break
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import OrderedDict
N = int(input())
num = list(map(int,input().split()))
data = {}
for i in range(N):
	a = num[i]  
	if a in data:
		data[a] += 1
	else:
		data[a] = 1
data = OrderedDict(sorted(data.items(), key =lambda x:x[0],reverse = True))
sides = list(data.keys())
sides_num = list(data.values())
def recta(sides,sides_num):
        num = []
        for i in range(len(sides_num)):
            if sides_num[i] >= 2:
                num.append(sides[i])
            if len(num) == 2:
                return(num[0]*num[1])
                break
        return(0)
print(recta(sides,sides_num))

Submission status: Wrong Answer

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

counter = Counter(A)
res =[]

for word,cnt in counter.most_common():
    if 4 <= cnt:
        res.append(word)
        res.append(word)
    elif 2 <= cnt:
        res.append(word)

res = sorted(res)[::-1]
if len(res) < 2:
    print("None")
else:
    print(res[0]*res[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
c = 0
for j in range(len(a)-1):
    if(a[j] == a[j+1]):
        del l[0]
        l.append(a[j])
        j += 1
        c += 1
    if(c >= 2 or j == len(a)-2):
        print(l[0] * l[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
c = 0
for j in range(len(a)-1):
    if(c >= 2):
        print(l[0] * l[1])
    if(a[j] == a[j+1]):
        del l[0]
        l.append(a[j])
        j += 1
        c += 1

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
for j in range(len(a)-1):
    if(a[j] == a[j+1]):
        if(l[1] < a[j]):
            del l[0]
            l.append(a[j])
            j += 1

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
for j in range(len(a)-1):
    if(a[j] == a[j+1]):
        del l[0]
        l.append(a[j])
        j += 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a_n=[int(i) for i in input().split()]
import sys

for i in range(N):
    if a_n.count(max(a_n))>=2:
        if a_n.count(max(a_n))>=4:
            print(4*max(a_n))
            sys.exit()
        else:
            a=max(a_n)
            for k in range(a_n.count(max(a_n))):
                a_n.remove(max(a_n))
            break
    else:
        a_n.remove(max(a_n))

if not a_n:
    print(0)
    sys.exit()

for i in range(N):
    if a_n.count(max(a_n))>=2:
        b=max(a_n)
        print(a*b)
        sys.exit()
    else:
        a_n.remove(max(a_n))

print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np

if __name__ == '__main__':
    N = int(input())
    a = input()
    a = a.split(' ')
    a = np.asarray(list(map(int, a)))

    S = 1
    fg = 0

    while fg < 2:
        max = np.max(a)
        where = np.where(a == max)
        if len(where[0]) <= 1:
            a[where] = 0
        else:
            S *= max
            a[where] = 0
            fg += 1

    print(S)

Submission status: Wrong Answer

Solution code:
import numpy as np

if __name__ == '__main__':
    N = int(input())
    a = input()
    a = a.split(' ')
    a = np.asarray(list(map(int, a)))

    fg = 0
    S = 1

    while fg < 2:
        max = np.max(a)
        argmax = np.argmax(a)
        if len(np.where(a == max)[0]) <= 1:
            a[argmax] = 0
        else:
            S *= max
            a[np.where(a == max)] = 0
            fg += 1

    print(S)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys


if __name__=='__main__':
    #xx = np.asarray([ 1,  1,  1,  2,  2,  2,  5, 25, 25,  1,  1])
    #ans max area = 50
    #xx = np.asarray([3, 1, 2, 4, 2, 1])
    #ans  max area = 2
    #xx = np.asarray([1,2,3,4])
    #ans  max area = 0
    xx = np.asarray([3, 3, 3, 3, 4, 4, 4, 5, 5, 5])
    #ans  max area = 20
    yy = np.bincount(xx)

    ii = np.nonzero(yy)[0]

    #find ii.max that has at least 2 occurences

    max_rect_area = 0
    long_side = 0
    short_side = 0
    for jj in reversed(ii):

        if yy[jj] > 4 and max_rect_area == 0:
            max_rect_area = jj*jj
        elif yy[jj] > 1 and long_side==0:
            #store 2 longest sticks
            long_side = jj
        elif yy[jj] >1 and short_side==0:
            short_side = jj
        else:
            print("no rectangle found yet")
            sys.stdout.flush()


        if long_side>0 and short_side>0 and long_side*short_side>max_rect_area:
            max_rect_area = long_side*short_side

    print("max ",max_rect_area)
    sys.stdout.flush()

Submission status: Wrong Answer

Solution code:
def solve(nums):
    left = 0
    right = 0
    for x in set(nums):
        if nums.count(x) != 1:
            if left <= x:
                right = left
                left = x
    print(left * right)


_ = input()
nums = [int(x) for x in input().split(" ")]
solve(nums)

Submission status: Wrong Answer

Solution code:
input()
a = list(sorted(list(map(int, input().split())) + [0, 0, 0, 0], reverse=True))

r = []
for i, _ in enumerate(a[:-1]):
    if sum(a[i:i+2]) is a[i] * 2:
        r.append(a[i])
        a[i+1] = -1
print(r[0] * r[1])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
L = [0 for i in range(max(A) + 1)]
res = []
for a in A:
    L[a] += 1

for i, l in enumerate(L):
    if l > 4:
        res.append(i)
        res.append(i)
        break
    elif l > 2:
        res.append(i)
    else:
        res.append(0)

result = 1
for i in range(2):
    result *= sorted(res, reverse=True)[i]

print(result)

Submission status: Wrong Answer

Solution code:
#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
    elif count>=2:
        if stock:
            ret=stock*bar
            break
        else:
            stock=bar
print(ret)

Submission status: Wrong Answer

Solution code:
#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:
            #print("ret bar bar")
            ret=bar*stock[0]
        else:
            #print("ret bar bar")
            ret=bar*bar
        break
    elif count>=2:
        if bar in stock:
            continue
        stock.append(bar)
        len_stock+=1
        if len_stock==2 :
            #print("ret stock stock")
            ret=stock[0]*stock[1]
            break
print(ret)

Submission status: Wrong Answer

Solution code:
#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)

Submission status: Wrong Answer

Solution code:
#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)

Submission status: Wrong Answer

Solution code:
_=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)

Submission status: Wrong Answer

Solution code:
#ARc081C
import sys

n=int(raw_input())
l=map(int,raw_input().split())
l1=sorted(l,reverse=True)
l2=[]
for i in xrange(n-1):
 if l1[i]==l1[i+1]:
  l2.append(l1[i])
if len(l2)<2:
 print 0
 sys.exit()
ls=list(set(l2))
if l1.count(ls[-1])>3:
 res=ls[-1]**2
else:
 res=ls[-1]*ls[-2]
print res

Submission status: Wrong Answer

Solution code:
#ARc081C
import sys

n=int(raw_input())
l=map(int,raw_input().split())
l1=sorted(l,reverse=True)
l2=[]
for i in xrange(n-1):
 if l1[i]==l1[i+1]:
  l2.append(l1[i])
if len(l2)<2:
 print 0
 sys.exit()
ls=list(set(l2))
if l2.count(ls[-1])>3:
 res=ls[-1]**2
else:
 res=ls[-1]*ls[-2]
print res

Submission status: Wrong Answer

Solution code:
#ARc081C

n=int(raw_input())
l=map(int,raw_input().split())
l1=list(set(l))
l2=[]
l4=[]
for i in xrange(len(l1)):
 if 2<=l.count(l1[i])<4:
  l2.append(l1[i])
 elif l.count(l1[i])>=4:
  l4.append(l1[i])
res=0
if len(l4)==0 and len(l2)<=1:
 res=0
elif len(l4)==0:
 res=l2[-1]*l2[-2]
elif len(l4) and len(l2)==0:
 res=l4[-1]*l4[-1]
elif len(l4) and len(l2)==1:
 res=l4[-1]*l2[-1]
else:
 res=max(l4[-1]*l4[-1],l4[-1]*l2[-1],l2[-1]*l2[-2])
print res

Submission status: Wrong Answer

Solution code:
x = input()
a = []
a = map(int, raw_input().split())
b = []
d = {}
for i in range(len(a)):
    if a[i] in d:
        d[a[i]]+=1
    else:
        d[a[i]] = 1
g = []
for key in d:
    if d[key]>=2:
        b.append(key)

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

Submission status: Wrong Answer

Solution code:
x = input()
a = []
a = map(int, raw_input().split())
b = []
d = {}
for i in range(len(a)):
    if a[i] in d:
        d[a[i]]+=1
    else:
        d[a[i]] = 1
for key in d:
    if d[key]>=2:
        b.append(key)
b.sort()
if len(b)<2:
    print 0
else:
    print b
    print b[len(b)-1]*b[len(b)-2]