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, c = int(input()), collections.Counter(sorted(list(map(int,input().split()))))
ck, cv, match, ans = list(c.keys()), list(c.values()), [], 0
for i in range(len(c)):
    if cv[i] >= 2:
        match.append(ck[i])
ans = match[-1]*match[-2] if len(match) >= 2 else 0
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

A = list(map(int, input().split()))
a = 0
A.sort()
for i in range(1, n):
    if(A.count(A[n - i]) >= 4):
        a = A[n - i]
        break
b = -1
c = 1
k = 0

for i in range(1, n):
    if(3 >= A.count(A[n - i]) >=2 and b!= A[n - i]):
        b = A[n - i]
        k+=1
        c*=b
        
    if(k==2):
        break

if(k!=2 and a==0):
    print(0)
else:
    print(max(a*a, c))

Submission status: Wrong Answer

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

s=0
t=0
prev=-1
c=0
for a in A:
    if prev==a:
        c+=1
    else:
        prev=a
        c=1
    if c==2:
        if s==0:
            s=a
        elif t==0:
            t=a
        else:
            break
print(s*t)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
p=Counter(a)
c=0
d=0
for a,b in p.items():
    if b>3:
        if c<a:
            c=a
        if d<a:
            d=a
    elif b>1:
        if c==0:
            c=a
        else:
            if d>c:
                c=a
            else:
                d=a
print(c*d)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
p=Counter(a)
c=0
d=0
for a,b in p.items():
    if b>3:
        if c>a:
            c=a
        if d>a:
            d=a
    elif b>1:
        if c==0:
            c=a
        else:
            if d>c:
                c=a
            else:
                d=a
print(c*d)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
p=Counter(a)
c=0
d=0
for a,b in p.items():
    if b>3:
        c=a
        d=a
    elif b>1:
        if c==0:
            c=a
        else:
            if d>0:
                c=d
                d=a
            else:
                d=a
print(c*d)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
C=Counter(A)
cnt2=[]
cnt4=[]
for k,v in C.items():
    if v>=4:
        cnt4.append(k)
    elif v>=2:
        cnt2.append(k)
ans=0
if len(cnt4)!=0:
    S_4=max(cnt4)**2
    ans=S_4
if len(cnt2)>=2:
    cnt2=sorted(cnt2,reverse=True)
    S_2=cnt2[0]*cnt2[1]
    ans=max(ans,S_2)
print(ans)

Submission status: Wrong Answer

Solution code:
#長方形ができるかの判定を行いながら、長方形の面積を求める
N=int(input()) 
A=list(map(int,input().split()))
A.sort 
max1=0
max2=0
if A[0]==A[1]:
        a=max1
        max1=A[0]
        max2=a     
for i in range(2,len(A)-1): 
    if A[i]==A[i+1] and (A[i]!=A[i-1] or  A[i]==A[i-1]==A[i-2]):
        a=max1
        max1=A[i]
        max2=a 
print(max1*max2)

Submission status: Wrong Answer

Solution code:
#長方形ができるかの判定を行いながら、長方形の面積を求める
N=int(input()) 
A=list(map(int,input().split()))
A.sort 
max1=0
max2=0
for i in range(0,len(A)-1): 
    if A[i]==A[i+1] and (A[i]!=A[i-1] or  A[i]==A[i-1]==A[i-2]):
        a=max1
        max1=A[i]
        max2=a 
print(max1*max2)

Submission status: Wrong Answer

Solution code:
#長方形ができるかの判定を行いながら、長方形の面積を求める
N=int(input()) 
A=list(map(int,input().split()))
A.sort 
max1=0
max2=0
max3=0
for i in range(0,len(A)-1): 
    if A[i]==A[i+1]:
        a=max1
        b=max2
        max1=A[i]
        max2=a
        max3=b
print(max1*max3)

Submission status: Wrong Answer

Solution code:
#長方形ができるかの判定を行いながら、長方形の面積を求める
N=int(input()) 
A=list(map(int,input().split()))
A.sort 
max1=0
max2=0
max3=0
max4=0
for i in range(0,len(A)): 
    if A.count(A[i])>=2: 
        a=max1
        b=max2
        c=max3
        max1=A[i]
        max2=a
        max3=b
        max4=c
print(max1*max4)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = list(map(int,input().split()))
a = collections.Counter(A)
alist = a.most_common()
alen = len(a)
alist.sort(reverse=True)
kari = 0
flag = 0
for i in range(alen):
    if alist[i][1] >= 4:
        print(alist[i][0]*alist[i][0])
        flag = 1
        break
    elif alist[i][1] >= 2:
        if kari > 0:
            print(kari*alist[i][0])
            flag = 1
            break
        else:
            kari = alist[i][0]
    else:
        pass
if flag == 0:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)

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

b.sort(reverse=True)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
b = set()
now = float("inf")

for k in a:
        if k == now:
            b.add(k)
        if len(b) == 2:
            b = list(b)
            print(b[0]*b[1])
            break
        now = k
else:
    print(0)

Submission status: Wrong Answer

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

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

m1 = 0
m2 = 0
for k in list(d.keys())[::-1]:
    if d[k] >= 2 and m1 == 0:
        m1 = k
    elif d[k] >= 2 and m1 != 0:
        m2 = k
        break


if m1 != 0:
    if d[m1] >= 4:
        print(m1*m1)
    else:
        print(m1*m2)
else:
    print(0)

Submission status: Wrong Answer

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

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

m1 = 0
m2 = 0
for k in list(d.keys())[::-1]:
    if d[k] >= 2 and m1 == 0:
        m1 = k
    elif d[k] >= 2 and m1 != 0:
        m2 = k
        break


if m1 != 0:
    if d[m1] >= 4:
        print(m1*m1)
    else:
        print(m1*m2)
else:
    print(0)

Submission status: Wrong Answer

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

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

#d = sorted(dct.items(),key=lambda x:-x[0])
m1 = 0
m2 = 0
for k in list(d.keys())[::-1]:
    if d[k] >= 2 and m1 == 0:
        m1 = k
    elif d[k] >= 2 and m1 != 0:
        m2 = k

    if m2 != 0:
        print(m1*m2)
        exit()

print(0)

Submission status: Wrong Answer

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

    import collections
    count = collections.Counter(a)

    valid = {k:v for k, v in count.items() if v >= 2}

    # print(valid)

    if len(valid) < 2:
        return 0

    m = sorted(valid.keys(), reverse=True)
    a, b = m[0], m[1]

    return a*b


def main():
    print(solve())


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

nums = [0]*N
for x in X:
  num = A.count(x)
  if(num >= 2):
    nums.append(x)
nums.sort(reverse = True)
print(nums[0]*nums[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
a = a[::-1]
s = set(a)
s = list(s)
s = s[::-1]
t = list()
for i in range(len(s)):
    if a.count(s[i]) >= 4 and len(t) == 0:
        print(s[i]**2)
        exit()
    elif a.count(s[i]) >= 2:
        t.append(s[i])
        if len(t) >= 2:
            print(t[0]*t[1])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
a = a[::-1]
s = set(a)
s = list(s)
t = list()
for i in range(len(s)):
    if a.count(s[i]) >= 4 and len(t) == 0:
        print(s[i]**2)
        exit()
    elif a.count(s[i]) >= 2:
        t.append(s[i])
        if len(t) >= 2:
            print(t[0]*t[1])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
a = a[::-1]
s = set(a)
s = list(s)
t = list()
for i in range(len(s)):
    if a.count(s[i]) >= 4 and len(t) == 0:
        print(s[i]**2)
        exit()
    elif a.count(s[i]) >= 2:
        t.append(s[i])
        if len(t) >= 2:
            print(t[0]*t[1])
            exit()

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
maxval1, maxval2 = 0, 0
for k, v in c.items():
    if v >= 2:
        if k > maxval1:
            maxval1, maxval2 = k, maxval1
        elif k > maxval2:
            maxval2 = k
        else:
            pass
print(maxval1 * maxval2)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
tmp = 0
for k, v in sorted(c.items(), key=lambda x:-x[0]):
    if v >= 2:
        if tmp:
            print(k * tmp)
            break
        else:
            tmp = k
else:
    print(0)

Submission status: Wrong Answer

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

res = A[0]
cnt = 1
use = []
for i in range(1, N):
    if A[i] == res:
        cnt += 1
    else:
        cnt = 1
        res = A[i]

    print(i, A[i], cnt, use)

    if cnt >= 2:
        use.append(A[i])
        cnt -= 2

    if len(use) >= 2:
        break

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

Submission status: Wrong Answer

Solution code:
import collections as cl

N = int(input())
sticks = [int(i) for i in input().split()]

sticks.sort(reverse=True)

w = 0
h = 0

for k,v in sorted(cl.Counter(sticks).items(), key=lambda x: x[0], reverse=True):
    if (v < 2) :
        continue
    
    if (v >= 4) :
        # 4本以上あれば正方形が作れる
        w = k
        h = k
        break
    
    if (v >= 2) :
        if (w == 0) :
            w = k
        else :
            h = k
            break


print(w*h)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
switch = 1
ans = []

for i in range(n-1):
    if switch == 1:
        if A[i] == A[i+1]:
            ans.append(A[i])
            switch = 0
    if switch == 0:
        switch = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]

import collections
 
c=collections.Counter(a)
l=c.most_common()

from operator import itemgetter

l.sort(key=itemgetter(0))   
l.reverse()

ans=[]
for i,j in l:
    if j>=2:
        ans.append(int(i))
        if len(ans)==2:
            break

if len(ans)<2:
    ans.append(0)
    ans.append(0)
print(ans[0]*ans[1])

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = sorted(list(map(int,input().split())))
b = {}
for i in arr:
  if i not in b:
      b[i] = 1
  else:
      b[i] += 1
h = 0
w = 0
b1 = sorted(b)[::-1]
for i in b1:
    if b[i] >= 4:
        if h < i:
            h = i
            w = i
            break
        else:
            w = i
            break
    elif b[i] >= 2:
        if h == 0:
            h = i
        else:
            w = i
        
print(h*w)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = sorted(list(map(int,input().split())))
b = {}
for i in arr:
  if i not in b:
      b[i] = 1
  else:
      b[i] += 1
h = 0
w = 0
b1 = sorted(b)[::-1]
for i in b1:
  if b[i] >= 4 and h*w < i**2:
      h = i
      w = i
  elif b[i] >= 2:
      if w > h and h*w <= i*w:
          h = i
      elif h*w <= i*h:
          w = i
print(h*w)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = sorted(list(map(int,input().split())))
b = {}
for i in arr[::-1]:
    if i not in b:
        b[i] = 1
    else:
        b[i] += 1
h = 0
w = 0
for i in b:
    if b[i] >= 4:
        h = i
        w = i
        break
    elif b[i] >= 2:
        if h == 0:
            h = i
        else:
            w = i
            break
print(h*w)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = sorted(list(map(int,input().split())))
b = {}
for i in arr:
    if i not in b:
        b[i] = 1
    else:
        b[i] += 1
h = 0
w = 0
for i in b:
    if b[i] >= 4 and h*w < i**2:
        h = i
        w = i
    elif b[i] >= 2:
        if w > h:
            h = i
        else:
            w = i
print(h*w)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = sorted(list(map(int,input().split())))
b = {}
for i in arr:
    if i not in b:
        b[i] = 1
    else:
        b[i] += 1
h = 0
w = 0
for i in b:
    if b[i] >= 4 and h*w < i**2:
        h = i
        w = i
    elif b[i] >= 2:
        if w*i > h*i:
            h = i
        else:
            w = i
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = sorted(list(map(int,input().split())))
b = {}
for i in arr:
    if i not in b:
        b[i] = 1
    else:
        b[i] += 1
h = 0
w = 0
for i in b:
    if b[i] >= 4 and h*w < i**2:
        h = i
        w = i
    elif b[i] >= 2:
        if w*i > h*i:
            h = i
        else:
            w = i
print(h*w)

Submission status: Wrong Answer

Solution code:
def abc071_c():
    from collections import Counter
    _ = int(input())
    a = list(map(int, input().split()))
    a_count = Counter(a)
    ans = 1

    if len(a_count) == 1:
        print(a[0] ** 2)
    elif a_count.most_common()[1][1] < 2:
        print(0)
    else:
        tmp = 0
        for v in sorted(set(a), reverse=True):
            if tmp == 2:
                break
            if a_count[v] >= 2:
                ans *= v
                tmp += 1
        print(ans)


abc071_c()

Submission status: Wrong Answer

Solution code:
def abc071_c():
    from collections import Counter
    _ = int(input())
    a = list(map(int, input().split()))
    a_count = Counter(a)
    a_common = a_count.most_common()
    ans = 1
    tmp = 0

    if a_common[1][1] < 2:
        print(0)
    else:
        for v in sorted(set(a), reverse=True):
            if tmp == 2:
                break
            if a_count[v] >= 2:
                ans *= v
                tmp += 1
        print(ans)


abc071_c()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
X = sorted(list(set(A)), reverse = True)
d = {}
for x in X:
  c = A.count(x)
  d[x] = c
a, b = 0, 0
for k, v in sorted(d.items()):
  if(v >= 4 and a == 0 and b == 0):
    a, b = k, k
    break
  if(c >= 2):
    if(a == 0):
      a = k
    else:
      b = k
      break
print(a * b)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
X = list(set(A))
d = {}
for x in X:
  c = A.count(x)
  if(c >= 2):
    d[x] = c
if(len(d) > 0):
  ans = 1
  for k in list(d.keys())[-2:]:
    ans *= k
  print(ans)
else:
  print(0)

Submission status: Wrong Answer

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

A.sort(reverse=True)
x = 0
y = 0
prev = 0
for e in A:
    if e == prev and e != x:
        if x == 0:
            x = e
        elif y == 0:
            y = e
        else:
            break
    prev = e
print(x*y)

Submission status: Wrong Answer

Solution code:
from collections import Counter

input()
c = sorted(Counter([int(i) for i in input().split()]).items(), key=lambda x: x[0], reverse=True)
a, b = 0,0
for i in c:
    key = i[0]
    count = i[1]
    if count >= 4:
        a, b = key, key
        break
    if count >= 2:
        if not a:
            a = key
        else:
            b = key
            break

print(a*b)

Submission status: Wrong Answer

Solution code:
from collections import Counter

input()
c = sorted(Counter([int(i) for i in input().split()]).items(), key=lambda x: x[0], reverse=True)
a, b = 0,0
for i in c:
    key = i[0]
    count = i[1]
    if count >= 2:
        if not a:
            a = key
        else:
            b = key
            break

print(a*b)

Submission status: Wrong Answer

Solution code:
from collections import Counter

input()
c = sorted(Counter([int(i) for i in input().split()]).items(), key=lambda x: x[0], reverse=True)
print(c)
a, b = 0,0
for i in c:
    key = i[0]
    count = i[1]
    if count >= 2:
        if not a:
            a = key
        else:
            b = key
            break

print(a*b)

Submission status: Wrong Answer

Solution code:
from collections import Counter
input()
c = sorted(Counter([int(i) for i in input().split()]).most_common(), key=lambda x: x[0], reverse=True)
a, b = 0,0
for i in c:
    key = i[0]
    count = i[1]
    if count >= 2:
        if not a:
            a = key
        else:
            b = key
            break

print(a*b)

Submission status: Wrong Answer

Solution code:
from collections import Counter

input()
c = list(reversed(Counter([int(i) for i in input().split()]).most_common()))
a, b = 0,0
for i in c:
    key = i[0]
    count = i[1]
    if count >= 2:
        if not a:
            a = key
        else:
            b = key
            break

print(a*b)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
j=[];x=-2
for i in range(1,n-1):
  if a[i]==a[i+1] and x!=i:
    j.append(a[i])
    x=i+1
  if len(j)>=2:
    break
j.append(0)
j.append(0)
print(j[0]*j[1])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
j=[];x=-2
for i in range(1,n-1):
  if a[i]==a[i+1] and x!=i+1:
    j.append(a[i])
    x=i+1
  if len(j)>=2:
    break
if len(j)<2:
  j.append(0)
  j.append(0)
print(j[0]*j[1])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(set(a))
b.sort()
b.reverse()
x=0;y=0
for i in range(len(b)):
  if x==0 and a.count(b[i])>=2:
    x=b[i]
  elif x!=0 and y==0 and a.count(b[i])>=2:
    y=b[i]
  if x*y!=0:
    break
print(x*y)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=list(set(a))
b.sort()
b.reverse()
x=0;y=0
for i in range(len(b)):
  if x==0 and a.count(b[i])>=2:
    x=b[i]
  elif y==0 and a.count(b[i])>=2:
    y=b[i]
  elif x*y==0:
    break
print(x*y)

Submission status: Wrong Answer

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

b = []
for key, item in a.items():
    if item >= 2:
        b.append((key, item))

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

b.sort(key=lambda x: -x[0])
print(b[0][0]*b[1][0])

Submission status: Wrong Answer

Solution code:
input()
a=[int(i) for i in input().split()]
sorted(a,reverse=True)
tyo=0
tan=0
tb=0
for i in range(len(a)-1):
  if tb==1:
    tb=0
  else:
    if a[i]==a[i+1] and tyo==0:
      tyo=a[i]
      tb=1
    else:
      tan=a[i]
      break
print(tyo+tan)

Submission status: Wrong Answer

Solution code:
import collections

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

stick_num = collections.Counter(A)
flag = True
ans = 0
for i in sorted(stick_num, reverse=True):
    if stick_num[i] >= 4:
        ans = i * i
        break
    elif stick_num[i] >= 2:
        if flag:
            a = i
            flag = False
        else:
            ans = a * i
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import collections

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

stick_num = collections.Counter(A)
flag = True
ans = 0
for i in sorted(stick_num, reverse=True):
    if stick_num[i] % 4 == 0:
        ans = i * i
        break
    elif stick_num[i] >= 2:
        if flag:
            a = i
            flag = False
        else:
            ans = a * i
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import collections

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

stick_num = collections.Counter(A)
flag = True
ans = 0
for i in sorted(stick_num, reverse=True):
    if stick_num[i] % 4 == 0:
        ans = i * i
    elif stick_num[i] >= 2:
        if flag:
            a = i
            flag = False
        else:
            ans = a * i
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import collections

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

stick_num = collections.Counter(A)
flag = True
ans = 0
for i in sorted(stick_num, reverse=True):
    if stick_num[i] % 4 == 0:
        ans = i * i
    elif stick_num[i] % 2 >= 0:
        if flag:
            a = i
            flag = False
        else:
            ans = a * i
            break

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
num_list = list(map(int,input().split()))
no_dup = set(num_list)
sorted_dup = sorted(no_dup,reverse=True)
ans = 1
cnt = 0

for n in sorted_dup:
    total = num_list.count(n)
    if total >= 4:
        ans = n*n
        cnt = 2
    elif total >= 2:
        ans *= n
        cnt += 1
    if cnt == 2:
        break

if cnt == 0:
    print(0)
else:    
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
num_list = list(map(int,input().split()))
no_dup = set(num_list)
sorted_dup = sorted(no_dup,reverse=True)
ans = 1
cnt = 0

for n in sorted_dup:
    if num_list.count(n) >= 2:
        ans *= n
        cnt += 1
    if cnt == 2:
        break

if cnt == 0:
    print(0)
else:    
    print(ans)

Submission status: Wrong Answer

Solution code:
import collections

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

con = collections.Counter(A).most_common()
ans = 0

for a, b in sorted(con, reverse= True):
    if b >= 4:
        print(a**2)
        break
    elif b >= 2 and ans == 0:
        ans = a
    elif b >= 2:
        print(ans*a)
        break
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
aa = sorted(set(a), reverse = True)
ans = 0
for i in aa:
  if a.count(i) >= 4 and ans==0:
    print(i**2)
    break
  elif a.count(i) >= 2 and ans==0:
    ans = i
  elif a.count(i) >= 2 and ans != 0:
    print(i*ans)
    break

Submission status: Wrong Answer

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

A.sort(reverse=True)

ans = []
i = 0
while i < N-2:
    if A[i] == A[i+1]:
        ans.append(A[i])
        i += 1
    if len(ans) == 2: break
    i += 1

if len(ans) in (0,1): print(0)
else: print(ans[0]*ans[1])

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=Counter(a).most_common()
b.reverse()
s=0
t=0
for len in b:
    if s==0 and len[1]>=4:
        print(len[0]**2)
        exit()
    elif s==0 and len[1]>=2:
        s=len[0]
    elif s!=0 and len[1]>=2:
        print(s*len[0])
        exit()
print(0)

Submission status: Wrong Answer

Solution code:
import collections

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

Submission status: Wrong Answer

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
br = sorted(set(ar))
cr = []
dr = []
for b in br:
    if ar.count(b) >= 4:
        cr.append(b)
    elif ar.count(b) >= 2:
        dr.append(b)
if len(cr) >= 1:
    mc = max(cr) ** 2
else:
    mc = 0
if len(dr) >= 2:
    er = sorted(dr,reverse=True)
    md = er[0] * er[1]
else:
    md = 0
print(max(mc,md))

Submission status: Wrong Answer

Solution code:
# encoding: utf-8
N = int(input())
A = list(map(int, input().split()))

A.sort()

view = -1
lengths = []
cnt = 0
for Ai in reversed(A):
    if Ai > view:
        view = Ai
        cnt = 0
    cnt += 1
    if cnt >= 2:
        lengths.append(Ai)
        cnt = 0
    if len(lengths) > 1: break

print(lengths[-1] * lengths[-2] if len(lengths) > 1 else 0)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
for i in range(n-1):
    if a[i]==a[i+1]:
        a[i+1]==0
    else:
        a[i]=0
a.sort(reverse=True)
print(a[0]*a[1])

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=set(a)
c=list(b)
c.sort(reverse=True)
ans=1
cnt=0
if len(b)==n:
    print(0)
    sys.exit()
for i in range(len(b)):
    if a.count(c[i])>=2:
        cnt+=1
        ans*=c[i]
    if cnt>=2:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=set(a)
c=list(b)
c.sort(reverse=True)
ans=1
cnt=0
for i in range(len(b)):
    if a.count(c[i])>=2:
        cnt+=1
        ans*=c[i]
    if cnt>=2:
        break
print(ans)

Submission status: Wrong Answer

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

import collections
A_c=collections.Counter(A)

print(A_c)
keys = [k for k, v in A_c.items() if v >= 2]

keys.sort()

if len(keys) < 2:
	ans = 0
elif A_c.get(keys[len(keys)-1]) >= 4:
	ans = keys[len(keys)-1] * keys[len(keys)-1] 
else:
	ans = keys[len(keys)-1] * keys[len(keys)-2]

print(ans)

Submission status: Wrong Answer

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

import collections
A_c=collections.Counter(A)


keys = [k for k, v in A_c.items() if v >= 2]

keys.sort()
if len(keys) < 2:
	ans = 0

else:
	ans = keys[len(keys)-1] * keys[len(keys)-2]

print(ans)

Submission status: Wrong Answer

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

import collections
A_c=collections.Counter(A)

print(A_c)
keys = [k for k, v in A_c.items() if v >= 2]

keys.sort()
if len(keys) < 2:
	ans = 0

else:
	ans = keys[len(keys)-1] * keys[len(keys)-2]

print(ans)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter(A)
count = count.most_common()
count.sort()
count.reverse()
ans = []
for i in range(len(count)):
    if count[i][1] >= 2:
        ans.append(count[i][0])
        if len(ans) == 2:
            break
if len(ans) < 2:
    print(0)
else:
    print(ans[0] * ans[1])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
m = {}
targets = []
for a in A:
    m.setdefault(a, 0)
    m[a] += 1
    if m[a] == 2:
        targets.append(a)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
bars = {}
for i in a:
    if i in bars:
        bars[i] += 1
    else:
        bars[i] = 1
bars = sorted(bars.items(), key=lambda x: -x[0])

ans1 = 0
ans2 = 0
for i in bars:
    if i[1] >= 2:
        if ans1 == 0:
            ans1 = i[0]
        else:
            ans2 = i[0]
            break
print(ans1 * ans2)

Submission status: Wrong Answer

Solution code:
def 解():
    iN = int(input())
    m2_2 = 0 #複数あるものの二つ目
    m2 = 0 #複数あるもので最大
    m3 = 0 #3個あるもので最大
    m4 = 0 #4個あるもので最大
    d = set()
    for a in [int(_) for _ in input().split()]:
        if a in d:
            if  m2 < a :
                m2_2 = m2
                m2 = a
            elif m2 == a :
                if m3 < a :
                    m3 = a
                elif m3 == a:
                    if m4 < a:
                        m4 = a
        else:
            d.add(a)
    print(max(m2*m2_2,m4**2))
解()

Submission status: Wrong Answer

Solution code:
def 解():
    iN = int(input())
    aA = sorted([int(_) for _ in input().split()])[::-1]
    d = {}
    iC = 0
    for a in aA:
        if a in d:
            if iC and iC != a :
                print(iC * a)
                exit()
            else:
                iC = a
        else:
            d[a] = 1
    print(0)
解()

Submission status: Wrong Answer

Solution code:
N = int(input())
L = list(map(int, input().split()))
L.sort()
a = [0,0]
count = 0
for i in range(N):
    count += 1
    if i == N-1:
        if count >= 2:
            a.append(L[i])
        count = 0
    elif L[i] != L[i+1]:
        if count >= 2:
            a.append(L[i])
        count = 0
            
print(a[-1]*a[-2])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools

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

dict1 = {}
for A in An:
    if A in dict1:
        dict1[A] += 1
    else:
        dict1[A] = 1

h,w = 0,0
for k,v in sorted(dict1.items(), key=lambda x: -x[0]):
    if v >= 4:
        h,w = k,k
        break
    if v < 2:
        continue
    if h == 0:
        h = k
        continue
    if w == 0:
        w = k
        break
print(h*w)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools

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

dict1 = {}
for A in An:
    if A in dict1:
        dict1[A] += 1
    else:
        dict1[A] = 1

h,w = 0,0
for k,v in sorted(dict1.items(), key=lambda x: -x[0]):
    if v < 2:
        continue
    if h == 0:
        h = k
        continue
    if w == 0:
        w = k
        break
print(h*w)

Submission status: Wrong Answer

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

set_a = set()
condi = set()
for ai in a:
    if ai in set_a:
        condi.add(ai)
    else:
        set_a.add(ai)

condi = sorted(condi, reverse=True)
if len(condi)<2:
    print(0)
else:
    print(condi[0]*condi[1])

Submission status: Wrong Answer

Solution code:
import math
import collections
N = int(input())
A = []
A = map(int, input().split())
c = collections.Counter(A)
aaa = []
for i in (reversed(sorted(A))):
    #print(i)
    #print(">>",c[i])
    #print()
    if c[i] > 1:
        c[i]-=2
        aaa.append(i)
    if len(aaa) == 2:
        break
if len(aaa) < 2:
    print(0)
else:
    print(aaa[0]*aaa[1])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
Acount = {}
q = []
 
for a in A:
  if a not in Acount:
    Acount[a] = 0
  else:
    Acount[a] += 1
    
for key, val in Acount.items():
  if val >= 2:
    q.append(key)
    
  if val >= 4:
    q.append(key)
 
q.sort(reverse=True)
 
if len(q) < 2:
  print(0)
else:
  print(q[0]*q[1])