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:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
from collections import Counter
d=Counter(a)
dd=[0,0]
for i,j in d.items():
  if j>1 and dd[0]<i:
     dd.pop(0)
     dd.append(i)
print(dd[0]*dd[1])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n=int(input())
data=sorted(map(int,input().split()))
bar=sorted(set(data),reverse=True)
a,b=0,0
for n in bar:
    if (data.count(n)>=4):
        a,b=n,n
        break
    if (data.count(n)>=2):
        if a==0:
            a=n
        else:
            b=n
            break
print(a*b)

Submission status: Wrong Answer

Solution code:
print('<入力>')
N = input('棒の本数:N = ')
a = input('棒の長さ:')
A = a.split(' ')

nagasa = []
kazu = []


for i in range(int(N)):
    flag = 0

    for j in nagasa:
        if A[i] == j:
            flag = 1
            break
    if flag == 1:
        continue

    x = A.count(A[i])
    if int(x) >= 2:
        if int(x) % 2 == 0:
            y = int(int(x) / 2)
            nagasa.append(A[i])
            kazu.append(y)
        elif int(x) % 2 == 1:
            z = int(int(x) - 1)
            y = int(int(z) / 2)
            nagasa.append(A[i])
            kazu.append(y)


dai1 = 0
dai2 = 0

if len(nagasa) == 0:
    menseki = 0

elif len(nagasa) == 1:
    if kazu[0] == 1:
        menseki = 0
    else:
        menseki = int(int(nagasa[0]) * int(nagasa[0]))

else:
    for i in range(len(nagasa)):
        if int(dai1) <= int(nagasa[i]):
            dai1 = nagasa[i]
            v = i
    nagasa.remove(dai1)
    for j in range(len(nagasa)):
        if int(dai2) <= int(nagasa[j]):
            dai2 = nagasa[j]

    if int(kazu[v]) > 1:
        menseki = int(int(dai1) * int(dai1))
    elif int(kazu[v]) == 1:
        menseki = int(int(dai1) * int(dai2))


print('<出力>')
print(menseki)

Submission status: Wrong Answer

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

l = list(set(ai))
l.reverse()

m1 = 0
m2 = 0
for x in l:
    if(ai.count(x) >= 4):
        if m1 > 0:
            m2 = x
        else:
            m1 = m2 = x
        break
    elif(2 <= ai.count(x) < 4):
        if m1:
            m2 = x
            break
        else:
            m1 = x

print(m1*m2)

Submission status: Wrong Answer

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

l = list(set(ai))
l.reverse

m1 = 0
m2 = 0
for x in l:
    if(ai.count(x) >= 4):
        if m1 > 0:
            m2 = x
        else:
            m1 = m2 = x
        break
    elif(2 <= ai.count(x) < 4):
        if m1:
            m2 = x
            break
        else:
            m1 = x

print(m1*m2)

Submission status: Wrong Answer

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

ai.sort()
l = []
tmp = -1
for x in ai:
    if(tmp != x):
        l.append(x)
        tmp = x
l.reverse()

#dic = {x : ai.count(x) for x in ai}

m1 = 0
m2 = 0
for x in l:
    if(ai.count(x) >= 4):
        m1 = m2 = x
        break
    elif(2 <= ai.count(x) < 4):
        if m1:
            m2 = x
            break
        else:
            m1 = x
            continue

print(m1*m2)

Submission status: Wrong Answer

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

ai.sort()
l = []
tmp = -1
for x in ai:
    if(tmp != x):
        l.append(x)
        tmp = x
l.reverse()

#dic = {x : ai.count(x) for x in ai}



m1 = 0
m2 = 0
for x in l:
    if(ai.count(x) >= 4):
        m1 = m2 = x
    elif(2 <= ai.count(x) < 4):
        if m1:
            m2 = x
            break
        else:
            m1 = x
            continue
    


# for x in l:
#     tmp = dic[x]
#     if(tmp >= 4):
#         m1 = m2 = x
#         break
#     if(2 <= tmp < 4):
#         if m1:
#             m2 = x
#             break
#         else :
#             m1 = x

print(m1*m2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
edge = set()
h = 0
w = 0

for i in range(N):
    if A[i] in edge:
        if A[i] > h:
            h,w = A[i],h
        elif A[i] == h:
            continue
        elif A[i] >= w:
            w = A[i]
    else:
        edge.add(A[i])

print(h*w)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
edge = set()
h = 0
w = 0

for i in range(N):
    if A[i] in edge:
        if A[i] > h:
            h,w = A[i],h
        elif A[i] == h:
            continue
        elif A[i] > w:
            w = A[i]
    else:
        edge.add(A[i])

print(h*w)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
edge = set()
h = 0
w = 0

for i in range(N):
    if A[i] in edge:
        if A[i] >= h:
            h = A[i]
        elif A[i] > w:
            w = A[i]
    else:
        edge.add(A[i])

print(h*w)

Submission status: Wrong Answer

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

for i in range(0, N, 2):
    if len(l) == 2:
        break
    if A[i] == A[i + 1]:
        if A.count(i) >= 4:
            if len(l) == 1:
                l[1] = A[i]
            elif len(l) == 0:
                l[0] = A[i]
                l[1] = A[i]
        l.append(A[i])

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

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
l = []

for i in range(0, N, 2):
    if len(l) == 2:
        break
    if A[i] == A[i + 1] and not A[i] == 0:
        l.append(A[i])

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

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
l = []

for i in range(0, N - 1, 2):
    if len(l) >= 2:
        break
    if A[i] == A[i + 1] and not A[i] == 0:
        l.append(A[i])

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

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
A = list(map(int, input().split()))
w = 0
h = 0
done = False
for i in sorted(A,reverse=True):
    if A.count(i) >= 4:
        print(i * i)
        sys.exit()
    elif i == w:
        continue
    elif A.count(i) >= 2 and i >= 1:
        if w == 0:
            w = i
        else:
            h = i
            print(w * h)
            done = True
            break

if not done:
    print('0')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
w = 0
h = 0
done = False
for i in sorted(A,reverse=True):
    if A.count(i) >= 4:
        print(i * i)
        break
    elif i == w:
        continue
    elif A.count(i) >= 2 and i >= 1:
        if w == 0:
            w = i
        else:
            h = i
            print(w * h)
            done = True
            break

if not done:
    print('0')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse =True)
w = 0
done = False
for i in A:
    if A.count(i) >= 4:
        print(i * i)
        done = True
        break
    elif A.count(i) >= 2 and i >= 1:
        if w == 0:
            w = i
        elif not i == w:
            h = i
            done = True
            print(w * h)
            break

if not done:
    print('0')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse =True)
w = 0
done = False
for i in A:
    if A.count(i) >= 4:
        print(i * i)
        break
    elif A.count(i) >= 2 and i >= 1:
        if w == 0:
            w = i
        elif not i == w:
            h = i
            done = True
            break

if done:
    print(w * h)
else:
    print('0')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse =True)
width = 0
height = 0
found = False
for i in A:
    if A.count(i) >= 4:
        width = i
        height = i
        break
    elif A.count(i) >= 2:
        if width == 0:
            width = i
        elif not i == width:
            height = i
            found = True
            break

if found:
    print(width * height)
else:
    print('0')

Submission status: Wrong Answer

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

for i in A:
    if A.count(i) >= 4:
        width = i
        height = i
        count += 1
        break
    elif A.count(i) >= 2 and count == 0:
        width = i
        count += 1
    elif A.count(i) >= 2 and not i == width:
        height = i
        break

if count:
    print(width * height)
else:
    print('0')

Submission status: Wrong Answer

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

for i in A:
    if A.count(i) >= 4:
        width = i
        height = i
        count += 1
        break
    elif A.count(i) >= 2 and count == 0:
        width = i
        count += 1
    elif A.count(i) >= 2 and not i == width and count == 1:
        height = i
        break

if count:
    print(width * height)
else:
    print('0')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse =True)
width = 0
height = 0
count = 0
for i in A:
    if A.count(i) >= 4:
        height = i
        width = i
        count += 1
        break  
    elif A.count(i) >= 2 and count == 0:
        height = i
        count += 1
    elif A.count(i) >= 2 and not i == height:
        width = i
        break

if count == 1:
    print(width * height)
else:
    print('0')

Submission status: Wrong Answer

Solution code:

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

    if len(list) < 2:
        return list
    
    pivot = list[0]
    less = [item for item in list[1:] if item <= pivot]
    greater = [item for item in list[1:] if item > pivot]

    return quickSort(less) + [pivot] + quickSort(greater)

def findRect(list):
    nums = quickSort(list)
    nums.reverse()
    count = 0
    first = 0
    second = 0
    for index, num in enumerate(nums):

        if index + 1 >= len(nums):
            continue
        elif nums[index] == nums[index + 1] and nums[index] >= 1:
            count += 1
            if count == 1:
                first = nums[index]
            elif count == 2:
                second = nums[index]
                print(first * second)
                return
    if count < 2:
        print("0")

findRect(N)

Submission status: Wrong Answer

Solution code:
N=int(input())
c=[]
a=list(map(int, input().split()))
s=sorted(set(a), reverse=True)

for i in s:
    if a.count(i) >=2:
        c.append(i)

if len(c) <= 1:
    print("0")
else:
    print(c[0]*c[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
list1 = list(map(int,input().split()))
list2 = set()
list1.sort()
list1.reverse()
a,b = 0,0
for i in list1:
	if i in list2:
		if i >= a:
			a = i
		else:
			b = i
			break
	else:
		list2.add(i)
print('{0}'.format(a*b))

Submission status: Wrong Answer

Solution code:
n = int(input())
lst1 = list(map(int, input().split()))
lst1.sort()
lst2 = set()
a, b = 0, 0

for i in lst1:
    if i>b:
        if i in lst2:
            lst2.remove(i)
            if i>a:
                b = a
                a = i
        else:
            lst2.add(i)
print(a*b)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst1 = list(map(int, input().split()))
lst1.sort()
lst2 = set()
a, b = 0, 0

for i in lst1:
    if i>b:
        if i in lst2:
            if i in lst2:
                if i>a:
                    b = a
                    a = i
        else:
            lst2.add(i)
print(a*b)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst1 = list(map(int, input().split()))
lst1.sort()
lst2 = set()
a, b = 0, 0

for i in lst1:
    if i in lst2:
        if i in lst2:
            if i>a:
                b = a
                a = i
    else:
        lst2.add(i)
print(a*b)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst1 = list(map(int, input().split()))
lst1.sort()
lst1.reverse()
lst2 = set(lst1)
S = 1
c = 0

for i in lst1:
        if i in lst2:
            lst2.remove(i)
            S *= i
            c += 1
        if c == 2:
            print(S)
            break
if c != 2:
    print("0")

Submission status: Wrong Answer

Solution code:
n = int(input())
S = 1
lst1 = list(map(int, input().split()))
lst2 = sorted(set(lst1), key=lst1.index)
for i in range(len(lst2)):
    lst1.remove(lst2[i])
lst1 = list(set(lst1))
lst1.sort()
lst1.reverse()

if len(lst1) <= 1:
    print("0")
else:
    S = lst1[0] * lst1[1]
    print(S)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = 1
lst1 = list(map(int, input().split()))
lst2 = sorted(set(lst1), key=lst1.index)
for i in range(len(lst2)):
    lst1.remove(lst2[i])
lst1.sort()
lst1.reverse()

if len(lst1) <= 1:
    print("0")
else:
    S = lst1[0] * lst1[1]
    print(S)

Submission status: Wrong Answer

Solution code:
import functools
def overlup(lis):
    r = []
    def func(x, y):
        if x == y and x not in r:
            r.append(x)
        return y
    functools.reduce(func, lis)
    return r

n = int(input())
S = 1
lst1 = list(map(int, input().split()))
lst1.sort()
lst2 = overlup(lst1)
lst2.sort()
lst2.reverse()

if len(lst2) <= 1:
    print("0")
else:
    S = lst2[0] * lst2[1]
    print(S)

Submission status: Wrong Answer

Solution code:
import functools
def overlup(lis):
    r = []
    def func(x, y):
        if x == y and x not in r:
            r.append(x)
        return y
    functools.reduce(func, lis)
    return r

n = int(input())
S = 1
lst1 = list(map(int, input().split()))
lst2 = overlup(lst1)
lst2.sort()
lst2.reverse()

if len(lst2) <= 1:
    print("0")
else:
    S = lst2[0] * lst2[1]
    print(S)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = 1
c = 0
lst = list(map(int, input().split()))
lst2 = list(set(lst))
lst2.sort()
lst2.reverse()

lar = len(lst2)
for i in range(lar):
    if lst.count(lst2[i]) >= 2:
        S *= lst2[i]
        c += 1
    if c == 2:
        break
if c == 2:
    print(S)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = 1
c = 0
lst = list(map(int, input().split()))
lst.sort()
lst.reverse()
lst2 = list(set(lst))

lar = len(lst2)
for i in range(lar):
    if lst.count(lst2[i]) >= 2:
        S *= lst2[i]
        c += 1
    if c == 2:
        break
if c == 2:
    print(S)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
input()
param_list = sorted([int(v) for v in input().split(" ")], reverse=True)
result = 0
duplicate_param = 0
count = 1

for v in param_list:
  if v == duplicate_param:
    if count == 1:
      result = v
      duplicate_param = 0
    else:
      result *= v
      print(result)
      break
    count += 1
  else:
    duplicate_param = v

Submission status: Wrong Answer

Solution code:
input()
param_list = sorted([int(v) for v in input().split(" ")], reverse=True)
result = 0
duplicate_param = 0
count = 1
print(param_list)

for v in param_list:
  if v == duplicate_param:
    if count == 1:
      result = v
      duplicate_param = 0
    else:
      result *= v
      print(result)
      break
    count += 1
  else:
    duplicate_param = v

Submission status: Wrong Answer

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

def main():
    x = None
    y = None
    n = int(input())
    rods = [int(x) for x in input().split(' ')]

    candidates = []
    for r in Counter(rods).most_common():
        if r[1] >= 2:
            candidates.append(r[0])
        else:
            break

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

A.sort()

for i in range(N - 1):
    if A[i] == A[i + 1]:
        A[i + 1] = 0
    else:
        A[i] = 0

A.sort()
A.reverse()
print(A[0] * A[1])

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
a_new=[]
b=[]
c=[]
for x in a:
    if x not in b:
        b.append(x)
    else:
        a_new.append(x)
a_new=list(set(a_new))
a_new.sort
a_new=a_new[::-1]
if len(a_new)<2:
    s=0
    print(s)
else:
    s=a_new[0]*a_new[1]
    print(s)

Submission status: Wrong Answer

Solution code:
import collections
dump = input()
inp = list(map(int,input().split()))
A = collections.Counter(inp)
t_A = sorted([el[0] for el in A.items() if el[1] > 1])
if len(t_A) >= 2:
  print(t_A[-2]*t_A[-1])
else:
  print(0)

Submission status: Wrong Answer

Solution code:
def solve(): # 071C - Make a Rectangle
    n = int(input())
    sides = list(map(int, input().split(" ")))
    check_dual = {}
    possible_sides = []

    for i in sides:
        if i in check_dual:
            check_dual[i] += 1
        else:
            check_dual[i] = 1

    for k, v in check_dual.items():
        if v >=4:
            possible_sides.append(k)
            possible_sides.append(k)
        elif v == 2 or v == 3:
            possible_sides.append(k)

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

Submission status: Wrong Answer

Solution code:
def solve(): # 071C - Make a Rectangle
    n = int(input())
    sides = list(map(int, input().split(" ")))
    check_dual = {}
    possible_sides = []

    for i in sides:
        if i in check_dual:
            check_dual[i] += 1
        else:
            check_dual[i] = 1

    for k, v in check_dual.items():
        if v >= 2:
            possible_sides.append(k)

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


solve()

Submission status: Wrong Answer

Solution code:
def solve(): # 071C - Make a Rectangle
    n = int(input())
    sides = list(map(int, input().split(" ")))
    check_dual = {}
    possible_sides = []

    for i in sides:
        if i in check_dual:
            check_dual[i] += 1
        else:
            check_dual[i] = 1

    tmp_square = 0
    for k, v in check_dual.items():
        if v >= 4 and k > tmp_square:
            tmp_square = k
        elif v == 2 or v == 3:
            possible_sides.append(k)
        else:
            pass

    possible_sides.sort(reverse=True)
    if tmp_square == 0 and len(possible_sides) < 2:
        print(0)
    elif tmp_square != 0 and len(possible_sides) == 0:
        print(tmp_square ** 2)
    elif tmp_square != 0 and len(possible_sides) == 1:
        print(max(tmp_square ** 2, tmp_square * possible_sides[0]))
    else:
        print(max(tmp_square ** 2, possible_sides[0] * possible_sides[1]))


solve()

Submission status: Wrong Answer

Solution code:
def solve(): # 071C - Make a Rectangle
    n = int(input())
    sides = list(map(int, input().split(" ")))
    check_dual = {}
    possible_sides = []

    for i in sides:
        if i in check_dual:
            check_dual[i] += 1
        else:
            check_dual[i] = 1

    tmp_square = 0
    for k, v in check_dual.items():
        if v >= 4 and k > tmp_square:
            tmp_square = k
        elif v == 2 or v == 3:
            possible_sides.append(k)
        else:
            pass

    possible_sides.sort(reverse=True)
    if tmp_square == 0 and len(possible_sides) < 2:
        print(0)
    elif tmp_square != 0 and len(possible_sides) < 2:
        print(tmp_square ** 2)
    else:
        print(max(possible_sides[0] * possible_sides[1],
                  tmp_square ** 2))


solve()

Submission status: Wrong Answer

Solution code:
import sys
N = raw_input()
items = raw_input().split()
res = dict()
for i in items[:int(N)]:
    i = int(i)
    if res.get(i) is None:
        res[i] = 1
    else:
        res[i] = 2
long2 = [0,0]
for i, num in res.iteritems():
    if num < 2:
        continue
    if i > long2[0]:
        long2 = [i, long2[0]]
    elif i > long2[1]:
        long2[1] = i
print long2[0] * long2[1]

Submission status: Wrong Answer

Solution code:
import sys
N = raw_input()
items = raw_input().split()
res = dict()
for i in items:
    i = int(i)
    if res.get(i) is None:
        res[i] = 1
    else:
        res[i] = 2
long2 = [0,0]
for i, num in res.iteritems():
    if num < 2:
        continue
    if i > long2[0]:
        long2 = [i, long2[0]]
    elif i > long2[1]:
        long2[1] = i
print long2[0] * long2[1]

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

pairs = sorted([k for k, v in Counter(A).items() if v >= 2], reverse = True)

if len(pairs)<2:
  print(0)
else:
  print(pairs[0]*pairs[1])

Submission status: Wrong Answer

Solution code:
#! /bin/python
# coding:utf-8

N = input()
A = map(int, raw_input().split())
dep = []

for i in A:
	if i not in dep:
		dep.append(i)

dep.sort()
dep.reverse()

if (len(dep) < 2):
	print "None"
else:
	print dep[0] * dep[1]

Submission status: Wrong Answer

Solution code:
#! /bin/python
# coding:utf-8

N = input()
A = map(int, raw_input().split())
s = set()
dep = []

for i in A:
	if i in s:
		dep.append(i)
	s.add(i)

dep.sort()
dep.reverse()

if (len(dep) < 2):
	print 0
else:
	print dep[0] * dep[1]

Submission status: Wrong Answer

Solution code:
#! /bin/python
# coding:utf-8

N = input()
A = map(int, raw_input().split())
s = set()
dep = []

for i in A:
	if i in s:
		dep.append(i)
	s.add(i)

dep.sort()
dep.reverse()

if (len(dep)  < 2):
	print "None"
else:
	print dep[0] * dep[1]

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A_counter = Counter(A).most_common()
A_counter.sort(reverse = True)

ans = []

for i, cnt in Counter(A).items():
    if cnt >= 2:
        ans.append(i)
        if len(ans) == 2:
            print(ans[0] * ans[1])
            break
    
    if cnt >= 4:
        print(i**2)
        break
    
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
ans = []

for i, cnt in Counter(A).items():
  
    if cnt >= 2:
        ans.append(i)
        if len(ans) == 2:
            print(ans[0] * ans[1])
            break
    
    if cnt >= 4:
        print(i**2)
        break
    
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
ans = []

for i, cnt in Counter(A).items():
    
    if cnt >= 2:
        ans.append(i)
        if len(ans) == 2:
            print(ans[0] * ans[1])
            break
    
    if cnt >= 4:
        print(i**2)
        break
    
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
two = []
four = []

for i, cnt in Counter(A).items():
    if cnt >= 4:
        four.append(i)
    if cnt >= 2:
        two.append(i)
    if len(two) >= 2:
        break

if two:
    if four:
        print(max(two[0]*two[1], four[0]*four[0]))
    else:
        print(two[0]*two[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
even = []

for i, cnt in Counter(A).items():
    if cnt >= 2:
        even.append(i)
    if len(even) == 2:
        break
    
if even:
    print(even[0] * even[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
c = Counter(map(int, input().split()))
h = w = 0
for k, v in c.items():
    if v >= 2 and k > h:
        w = h
        h = k
        if v >= 4:
            w = k
print(h * w)

Submission status: Wrong Answer

Solution code:

from collections import Counter

N = int(input())
sticks = list(map(int , input().split()))
ans = []

sticks_counter = Counter(sticks).most_common()
sticks_counter.sort(reverse = True)

for s in sticks_counter:
    
    if s[1] >= 4:
        print(s[0]**2)
        break
        
    elif s[1] >=2:
        ans.append(s[0])
        if len(ans) == 2:
            print(ans[0]*ans[1])
            break
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
sticks = list(map(int , input().split()))
ans = []

sticks_counter = Counter(sticks).most_common()
sticks_counter.sort(key = lambda x:x[1])

for s in sticks_counter:
    
    if s[1] >= 4:
        print(s[0]**2)
        break
        
    elif s[1] >=2:
        ans.append(s[0])
        if len(ans) == 2:
            print(ans[0]*ans[1])
            break
else:
    print(0)

Submission status: Wrong Answer

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

ans=[]
tmp=0
flag=True
for el in a:
    if len(ans)==2: break
    if el != tmp: tmp=el; flag=True
    else:
        if flag: ans.append(el); tmp=el; flag=False

try: ans=ans[0]*ans[1]
except: ans=0
print(ans)

Submission status: Wrong Answer

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

ans=[]
tmp=0
flag=True
for el in a:
    if len(ans)==2: break
    if el != tmp: tmp=el; flag=True
    else:
        if flag: ans.append(el); tmp=el; flag=False

try: ans=ans[0]*ans[1]
except: ans=0
print(ans)

Submission status: Wrong Answer

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

memo=[]
h=0; w=0
for el in a:
    if el in memo: pass
    else:
        num=a.count(el)
        if num>=4 and h==0: h=w=el
        elif num>=2 and h==0: h=el
        elif num>=2 and w==0: w=el

ans=h*w
print(ans)

Submission status: Wrong Answer

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

h=0; w=0
for el in pure:
    num=a.count(el)
    if num>=4 and h==0: h=w=el
    elif num>=2 and h==0: h=el
    elif num>=2 and w==0: w=el

ans=h*w
print(ans)

Submission status: Wrong Answer

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

B = []
C = []
D = []

for a in A:
    if a in B:
        C[B.index(a)] += 1
    else:
        B.append(a)
        C.append(1)

I = len(B)

for i in range(I):
    D.append([B[i], C[i]])

D = sorted(D, reverse=True)

i = 0
while i < I:
    x = D[i][0]
    d = D[i][1]
    if d > 1:
        if d > 3:
            print(x*2)
            exit()
        else:
            while i < I:
                i += 1
                y = D[i][0]
                d = D[i][1]
                if d > 1:
                    print(x*y)
                    exit()
    else:
        i += 1

print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
A.sort()
A.reverse()
li = []
count = 0
 
for i in range(N-1):
    if (i+count == N-1):
        break
    if A[i+count] == A[i+1+count]:
        li.append(A[i+count])
        count += 1
    if len(li) == 2:
        break
 
 
if len(li) > 1:
    print( int(li[0]) * int(li[1]) )
else:
    print("0")

Submission status: Wrong Answer

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

h=[]
count=0
f=0
for i in a:
 if f==i:
  h.append(i)
  count+=1
 else:
   f=i
   if count==2:
       break 
if count==2:
 print(h[0]*h[1])
else:
 print(0)

Submission status: Wrong Answer

Solution code:
N=input()
A=[int(x) for x in input().split()]
from collections import defaultdict
d=defaultdict(int)
for i in A:
    d[i]+=1
hen=[0,0]
for i in d.items():
    if i[1]>=2:
        hen.append(i[0])
hen=sorted(hen,reverse=True)
print(hen[0]*hen[1])

Submission status: Wrong Answer

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


count=0
ans=[]
flag=0
for i in range(1,n):
    if a[i]==a[i-1] and flag==1:
        flag=0


    elif a[i]==a[i-1] and flag==0:
        count += 1
        ans.append(a[i])
        flag=1

    elif a[i] != a[i-1]:
        flag=0

    if count==2:
        print(ans[0]*ans[1])
        break


print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())),
         reverse=True)
ans=[]
p=-1
cnt=0
flag =False
for index,i in enumerate(a):
    if p!=i:
        if cnt>=4:
            print(p*p)
            flag=True
            break
        if cnt>=2:
            ans.append(p)
            if len(ans)==2:
                print(ans[0]*ans[1])
                flag=True
                break
        p=i
        cnt=1
    else:
        cnt+=1
if not flag:
    if cnt>=4:
            print(p*p)
            flag=True
           
    elif cnt>=2:
            ans.append(p)
            if len(ans)==2:
                print(ans[0]*ans[1])
                flag=True
       
if not flag:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(raw_input().strip())
A=map(int,raw_input().split())

A.sort()
Auni=list(set(A))
Auni.reverse()

num=[]
for i in Auni:
    num.append(A.count(i))

edge=[0,0]
for j in range(2):
    for i in range(len(num)):
        if num[i]>=2:
            num[i]=num[i]-2
            edge[j]=Auni[i]
            break
print edge[0]*edge[1]

Submission status: Wrong Answer

Solution code:
n = int(input())
tmp = raw_input()

As = [int(a) for a in tmp.split()]

dic = {}
maxes = [0, 0]
for a in As:
    if a not in dic:
        dic[a] = 0
    dic[a] += 1
    if dic[a] % 2 == 0:
        if maxes[0] < a:
            maxes[1] = a
        elif maxes[1] < a:
                maxes[1] = a

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

# sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    a = read_int_list()
    a.sort()
    c = Counter(a)
    l = set()
    for i in a:
        if c[i] >= 2:
            l.add(i)
    l = list(l)

    res = 0
    if len(l) >= 1:
        m = l[-1]
        if c[m] >= 4:
            res = m * m
        else:
            if len(l) >= 2:
                p = l[-2]
                res = m * p
    print(res)


main()