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 = sorted(list(map(int, input().split())))
a = collections.Counter(A)
ans = [0, 0]
for i in a.keys():
    if a[i] >= 2:
        ans.append(i)
    if a[i] >= 4:
        ans.append(i)
print(ans[-1]*ans[-2])

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A=sorted(list(map(int, input().split())))
a = collections.Counter(A)
ans=[0]+[0]
for i in a.keys():
    if a[i] >= 2:
        ans.append(i)
print(ans[-1]*ans[-2])

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import collections

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
c = collections.Counter(a)
mul = 0
ans = 1
for x,count in c.items():
    if count >= 4:
        ans *(x**2)
        mul = 2
    elif count >= 2:
        ans *= x
        mul += 1
    if mul >= 2:
        break
ans = 0 if mul==0 else ans
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import collections

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
c = collections.Counter(a)
mul = 0
ans = 1
for x,count in c.items():
    if count >= 2:
        ans *= x
        mul += 1
    if mul >= 2:
        break
ans = 0 if mul==0 else ans
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
import collections
A = list(map(int,input().split()))
C = collections.Counter(A)
use = []
for i,val in C.items():
  if val > 4:
    use.append(i)
  if val > 2:
    use.append(i)
 
use = sorted(use,reverse= True)
if len(use)<2:
  print(0)
else:
  print(use[0]*use[1])

Submission status: Wrong Answer

Solution code:
N = int(input())
import collections
A = list(map(int,input().split()))
C = collections.Counter(A)
use = []
for i,val in C.items():
  if val > 4:
    use.append(i)
  if val > 2:
    use.append(i)

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

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
ans = 0
cnt = 0
w = -1

for i in A:
  if cnt > 2:
    break
  if A.count(i)>3 and ans<i**2:
    ans = i**2
    break
  elif A.count(i)<4 and A.count(i)>1:
    if ans == 0:
      ans = 1
    if w != i:
      ans *= i
      w = i
      cnt+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
ans = 0
cnt = 0
w = 0
for i in A:
  if cnt > 2:
    break
  if A.count(i)>3 and ans<i**2:
    ans = i**2
    break
  elif A.count(i)<3 and A.count(i)>1:
    if ans == 0:
      ans = 1
    if w != i:
      ans *= i
      w = i
    cnt+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
def main():

    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    set_a = set(a)
    a = []
    a = list(set_a)
    a.sort(reverse=True)
    select = 0
    ans = 1
    for i, aa in enumerate(a):
        if cnt[aa] >= 4:
            print(aa * aa)
            return
        if cnt[aa] >= 2:
            select += 1
            ans *= aa
        if select == 2:
            print(ans)
            return
    print(0)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
def main():

    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    set_a = set(a)
    a = []
    a = list(set_a)
    a.sort(reverse=True)
    select = 0
    ans = 1
    for i, aa in enumerate(a):
        if cnt[aa] >= 2:
            select += 1
            ans *= aa
        if select == 2:
            print(ans)
            return
    print(0)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = []
for i in range(len(a)):
  if A.count(a[i]) < 2: continue
  if A.count(a[i]) >= 4:
    ans += [a[i], a[i]]
    break
  else:
    ans.append(a[i])
    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()))
A.sort(reverse=True)
scount=1
flg=0
ans=1
for i in range(1,N):
    if A[i]==A[i-1]:
        scount+=1
        if i==N-1 and scount>=2 and flg==1:
            flg=2
            ans*=A[i-1]
        if i==N-1 and scount>=4 and flg==0:
            flg=2
            ans=A[i-1]**2
    else:
        if scount>=4:
            flg=2
            ans=A[i-1]**2
            break
        elif scount>=2:
            if flg==0:
                flg=1
                ans*=A[i-1]
            elif flg==1:
                flg=2
                ans*=A[i-1]
                break
        scount=1

print(ans if flg==2 else 0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
A = sorted(A, reverse=True)
d = defaultdict(int)
tmp = A[0]
for i in range(1, N):
  d[A[i]] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
d = sorted(d, key=lambda x:x[0], reverse=True)
a = []
for key, val in d:
  if 2 <= val <= 3:
    a.append(key)
  elif val >= 4:
    a.append(key)
    a.append(key)
  if len(a) >= 2:
    print(a[0]*a[1])
    exit()
if len(a) < 2:
  print(0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
A = sorted(A, reverse=True)
d = defaultdict(int)
tmp = A[0]
for i in range(1, N):
  d[A[i]] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
d = sorted(d, key=lambda x:x[0], reverse=True)
a = []
for key, val in d:
  if 2 <= val <= 3:
    a.append(key)
  elif val >= 4:
    a.append(key)
    a.append(key)
  if len(a) >= 2:
    print(a[0]*a[1])
    exit()
if len(a) == 0:
  print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
scount=1
flg=0
ans=1
for i in range(1,N):
    if A[i]==A[i-1]:
        scount+=1
        if i==N-1 and scount>=2 and flg==1:
            flg=2
            ans*=A[i-1]
    else:
        if scount>=2:
            if flg==0:
                flg=1
                ans*=A[i-1]
            elif flg==1:
                flg=2
                ans*=A[i-1]
                break
        scount=1

print(ans if flg==2 else 0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
A = sorted(A, reverse=True)
d = defaultdict(int)
tmp = A[0]
for i in range(1, N):
  d[A[i]] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
d = sorted(d, key=lambda x:x[0], reverse=True)
a = []
for key, val in d:
  if 2 <= val <= 3:
    a.append(key)
  elif val >= 4:
    a.append(key)
    a.append(key)
  if len(a) == 2:
    print(a[0]*a[1])
    exit()
if len(a) == 0:
  print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
scount=1
flg=0
ans=1
for i in range(1,N):
    if A[i-1]==A[i]:
        scount+=1
    else:
        if scount>=2:
            if flg==0:
                flg=1
                ans*=A[i-1]
            elif flg==1:
                flg=2
                ans*=A[i-1]
                break
        scount=1

if scount>=2 and flg==1:
    flg=2
    ans*=A[N-2]

print(ans if flg==2 else 0)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

c = Counter(A)
c = sorted(c.items(), key=lambda x:x[0], reverse=True)
d = []
for a in c:
    # print(a)
    if a[1] >= 2:
        d.append(a)
# print(d)
d = sorted(d, key=lambda x:x[0], reverse=True)
squ = 0
for y in d:
    # print(y)
    if y[1] == 4:
        squ = (y[0] ** 2)
    
    break
ans = squ

if len(d) >= 2:
    
    
# if len(d) >= 2:
    ans = (max(d[0][0] * d[1][0], ans))


print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
bar = dict()
for i in range(n):
    if a[i] not in bar:
        bar[a[i]] = 0
    bar[a[i]] += 1
l_bar = list(bar.items())
l_bar.sort(reverse=True)
cnt = 0
hen1 = 0
hen2 = 0
for i in range(len(l_bar)):
    if l_bar[i][1] >= 2:
        if cnt == 0:
            cnt += 1
            hen1 = l_bar[i][0]
        elif cnt == 1:
            cnt += 1
            hen2 = l_bar[i][0]
    if cnt == 2:
        print(hen1*hen2)
        exit()
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
from collections import Counter
from operator import itemgetter
C = Counter(A)
e = []
for k,v in C.items():
    if v >= 2: e.append(k)
e.sort(reverse=True)
if len(e) >= 2:
    print(e[0]*e[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
from collections import Counter
from operator import itemgetter
C = Counter(A)
Cs = sorted(C.items(), key=itemgetter(0), reverse=True)
e = []
for k,v in Cs:
    if v >= 2:
        e.append(k)
        if len(e) >= 2: break
if len(e) >= 2:
    print(e[0]*e[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

c = Counter(A)
c = sorted(c.items(), key=lambda x:x[0], reverse=True)
d = []
for a in c:
    if a[1] >= 2:
        d.append(a)
d = sorted(d, key=lambda x:x[0], reverse=True)
if len(d) >= 2:
    print(d[0][0] * d[1][0])
else:
    print(0)

Submission status: Wrong Answer

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

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
#-----

count_A_dic={}
for size in A_list:
    count_A_dic.setdefault(size,0)
    count_A_dic[size] += 1

length = sorted(set(A_list),reverse=True)

side=[]
for l in length:
    if count_A_dic[l] >= 4:
        side = [l,l]
        break
    elif count_A_dic[l] >= 2 and len(side) < 2:
        side.append(l)
    
    if len(side) == 2:
        break

print( side[0] * side[1] if len(side)==2 else 0 )

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = sorted([(k,v) for k,v in C.items() if v>=2], key = lambda x:-x[0])[:2]

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
a_count = sorted(Counter(a).items(),reverse=True)
f = False

for k,v in a_count:
    if 4 <= v and not f:
        print (k**2)
        exit ()
    elif 2 <= v and v <= 3:
        if f:
            print (x*k)
            exit ()
        else:
            x = k
            f = True
    else:
        pass

print (0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
a_count = sorted(Counter(a).items(),reverse=True)
f = False
for k,v in a_count:
    if v >= 4:
        print (k**2)
        exit ()
    elif 2 <= v and v <= 3:
        if f:
            print (x*k)
            exit ()
        else:
            x = k
            f = True
    else:
        pass
print (0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
a_count = sorted(Counter(a).items(),reverse=True)
f = False
for k,v in a_count:
    if v >= 4:
        print (k*2)
        exit ()
    elif 2 <= v and v <= 3:
        if f:
            print (x*k)
            exit (0)
        else:
            x = k
            f = True
    else:
        pass
print (0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
a_count = sorted(Counter(a).items(),reverse=True)
f = False
for k,v in a_count:
    if v >= 4:
        print (v*2)
        exit ()
    elif 2 <= v and v <= 3:
        if f:
            print (x*k)
            exit (0)
        else:
            x = k
            f = True
    else:
        pass
print (0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a_set = sorted(set(a),reverse=True)
isH = False
isW = False
for v in a_set:
    x = a.count(v)
    if 4 <= x :
        print (v*2)
        exit ()
    elif 2 <= x and x <= 3:
        if not isH:
            h = v
            isH = True
        elif not isW:
            print (h*v)
            exit ()
print (0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
l = []
for v in set(a):
    x = a.count(v)
    if x >= 2:
        l.append(v)
if len(l) < 2:
    print (0)
    exit()

l.sort(reverse=True)
print (l[0]*l[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
l = []
for v in set(a):
    x = a.count(v)
    if x >= 2:
        l.append(x)
if len(l) < 2:
    print (0)
    exit()

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

Submission status: Wrong Answer

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

A = list(reversed(sorted(A)))

i = 0
t = 0
ans = 0
for _ in range(n):
    B = A[i:i+4]
    if B.count(B[0]) == 4:
        print(B[0] * B[0])
        ans = 1
        break
    elif B.count(B[0]) >= 2 and t == 0:
        i += B.count(B[0])
        t = B[0]
    elif B.count(B[0]) >= 2:
        ans = 1
        print(B[0] * t)
        break
    else:
        i += 1
    if i >= n:
        break

if ans == 0:
    print(0)

Submission status: Wrong Answer

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

A = list(reversed(sorted(A)))

i = 0
t = 0
ans = 0
for _ in range(n):
    B = A[i:i+4]
    if B.count(B[0]) >= 4:
        print(B[0] * B[0])
        ans = 1
        break
    elif B.count(B[0]) >= 2 and t == 0:
        i += B.count(B[0])
        t = B[0]
    elif B.count(B[0]) >= 2:
        ans = 1
        print(B[0] * t)
        break
    else:
        i += 1

if ans == 0:
    print(0)

Submission status: Wrong Answer

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

A = list(reversed(sorted(A)))

i = 0
t = 0
ans = 0
for _ in range(n):
    B = A[i:i+4]
    if B.count(B[0]) % 4 == 0:
        print(B[0] * B[0])
        ans = 1
        break
    elif B.count(B[0]) >= 2 and t == 0:
        i += B.count(B[0])
        t = B[0]
    elif B.count(B[0]) >= 2:
        ans = 1
        print(B[0] * t)
        break
    else:
        i += 1

if ans == 0:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  a = list(input_list())
  ac = collections.Counter(sorted(a))
  aa = []
  for v, count in ac.items():
    if count >= 2:
      aa.append(v)
      
  sa = sorted(aa, reverse=True)
  if len(sa) < 2:
    print(0)
  else:
    print(sa[0]*sa[1])
    
  
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

Submission status: Wrong Answer

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

from collections import Counter

d=Counter(a)
d=d.most_common()
ans = [i for i,j in d if j>=2]

if len(ans) <2:
    if d[0][1] >= 4:
        print(d[0][0]**2)
    else:
        print(0)
else:
    ans.sort()
    print(ans[-1]*ans[-2])

Submission status: Wrong Answer

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

from collections import Counter

d=Counter(a)

ans = [i for i,j in d.most_common() if j>=2]

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
a.append(0)
cnt=1
l1,l2=0,0
for i in range(n):
    if a[i]==a[i+1]:
        cnt+=1
    else:
        if cnt>=4:
            l1=a[i]
            l2=a[i]
            break
        elif cnt>=2:
            if l1==0:
                l1=a[i]
                cnt=1
            else:
                l2=a[i]
                break
print(l1*l2)

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

from collections import defaultdict

def main():
	d=defaultdict(int)
	
	n=int(input())
	A=list(map(int,input().split()))
	for x in A:
		d[x]+=1
	
	li=[]
	for k,v in d.items():
		if v>=2:
			li.append(k)
	
	li.sort(reverse=True)
	
	if len(li)<=1:
		print(0)
	else:
		print(li[0]*li[1])
	

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    sidelist = dict()

    for aa in a:
        if aa not in sidelist:
            sidelist[aa] = 1
        else:
            sidelist[aa] += 1

    side_a = 0
    side_b = 0

    for s in sidelist:
        if sidelist[s] >= 4 and s > side_a:
            side_a = s
            side_b = s
        elif sidelist[s] >= 2:
            if side_a == 0:
                side_a = s
            elif side_b == 0:
                side_b = s
            elif s > side_a:
                side_b = side_a
                side_a = s
            elif s > side_b:
                side_b = s

    print(side_a*side_b)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
cnt={}
K=list(set(A))
K.sort()
for k in K:
  cnt[k]=0
for a in A:
  cnt[a]+=1
E=[]
for k in K:
  if cnt[k]>=2:
    if cnt[k]==4:
      E.append(k)
    E.append(k)
E.sort()
# print(E)
if len(E)>=2:
  print(E[-1]*E[-2])
else:
  print(0)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
a = na()

a.sort(reverse=True)
l = list()
for key, gr in groupby(a):
    if len(l) == 2:
        print(l[0] * l[1])
        quit()
    num = len(list(gr))
    if num >= 2:
        l.append(key)
    if num >= 4:
        l.append(key)
print(0)

Submission status: Wrong Answer

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

table=collections.defaultdict(int)
for x in A:
  table[x]+=1
ans=0
v=0
h=0
for x in table:
  ans=max(ans,v*h)
  if table[x]>1:
    v=max(h,v)
    h=max(h,x)
    if table[x]>3:
      v=max(h,v)
      h=max(h,x)
print(h*v)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

list.sort(a, reverse = True)
#print(a)

i = 0
tmp = []
while True:
    if a[i] == a[i + 1]:
        tmp.append(a[i])
        i += 1
    else:
        i += 1
    if i == n - 1:
        break

tmp2 = list(set(tmp))
list.sort(tmp2, reverse = True)
#print(tmp2)
#print(tmp)
if len(tmp2) >= 2:
    print(tmp2[0] * tmp2[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
ans = []
for k in sorted(cnt.keys(), reverse=True):
    if len(ans) == 2:
        break
    if cnt[k] >= 4:
        ans.append(k)
        ans.append(k)
    elif cnt[k] >= 2:
        ans.append(k)
if len(ans) != 2:
    print(0)
else:
    print(ans[0] * ans[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
b = list(set(a))
b.sort(reverse=True)
l = len(b)
c = [0 for _ in range(l)]
prei = b[0]
j = 0
for i in a:
    if i != prei:
        j += 1
    c[j] += 1
    prei = i
x = []
for i in range(l):
    if c[i] >= 2:
        x.append(b[i])
if len(x) >= 2:
    print(x[0] * x[1])
else:
    print(0)

Submission status: Wrong Answer

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

from collections import Counter

Acnt = Counter(A)

ans = [-1] * 2
for key,cnt in Acnt.items():
    if cnt >= 2:
        tmp = min(ans)
        if key > tmp:
            ans[ans.index(tmp)] = key

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

Submission status: Wrong Answer

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

table=collections.defaultdict(int)
for x in A:
  table[x]+=1
table=list(table.items())
table=[x[0] for x in table if x[1]>1]
table.append(0)
table.append(0)
table.sort(reverse=True)
print(table[0]*table[1])

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    if c.most_common()[0][1] < 2 or c.most_common()[1][1] < 2:
        return print(0)
    d = [i[0] for i in c.items() if i[1] >= 2]
    d.sort()
    print(d[-1] * d[-2])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, = map(int, input().split())
X = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
ccs = []
for x in X:
    d[x] += 1
    if d[x] == 2:
        ccs.append(x)
ccs.sort()
if len(ccs) > 1:
    print(ccs[-1]*ccs[-2])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = sorted(list(map(int,input().split())))[::-1]
s = set()
for k in range(1,N):
    if a[k-1] == a[k]:
        s.add(a[k])
if len(s) < 2:
    print(0)
else:
    s = sorted(list(s))
    print(s[-1]*s[-2])

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

c = Counter(A)
hen = [key for key, val in c.items() if val > 1]

l = max(hen) if hen else 0
if l != 0:
    hen.remove(l)
    s = max(hen) if hen else 0
else:
    s = 0

print(l * s)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
 
from collections import Counter
c = Counter(A)
 
mul = []
for k, v in c.items():
    if v >= 2:
        mul.append(k)
    elif v >= 4:
        mul.append(k)
        mul.append(k)
mul.sort()
if len(mul) < 2:
    print(0)
else:
    print(mul[-1]*mul[-2])

Submission status: Wrong Answer

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

from collections import Counter
c = Counter(A)

multi = sorted([k for k, v in c.items() if v >= 2], reverse=True)
if len(multi) < 2:
    print(0)
else:
    print(multi[0]*multi[1])

Submission status: Wrong Answer

Solution code:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from collections import defaultdict

N = ni()
a = na()

d = defaultdict(int)
for i in range(N):
    d[a[i]] += 1

h, w = [0] * 2
for i, j in d.items():
    if j >= 4:
        h = max(h, i)
        w = max(h, i)
    elif j >= 2:
        if h < w:
            h = max(h, i)
        else:
            w = max(w, i)

print(h * w)

Submission status: Wrong Answer

Solution code:
def examC():
    N = I()
    A = LI()
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    a = [0,0]
    for key,i in d.items():
        if i>=2:
            if a[1]<key:
                a = [a[1],key]
            elif a[0]<key:
                a = [key,a[1]]
    ans = a[0]*a[1]
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Submission status: Wrong Answer

Solution code:
import heapq
n=int(input())
s=set()
q=[0,0]
for a in map(int,input().split()):
  if a>q[0]:
    heapq.heapreplace(q,a)
print(q[0]*q[1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
X = Counter()
for i in range(0, N):
    X[A[i]] += 1
width = 0
height = 0
for x, y in sorted(X.most_common(), reverse=True):
    if y >= 4:
        width = x
        height = x
        break
    elif y >= 2:
        if width != 0:
            height = x
            break
        else:
            width = x
print(height*width)

Submission status: Wrong Answer

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

c = collections.Counter(a).most_common()
c.reverse()
first=0
second=0
for tmp in c:
    if tmp[1] >=4 and first==0 and second==0:
        first=tmp[0]
        second=tmp[0]
        break
    if tmp[1] >=2:
        if first==0:
            first=tmp[0]
        else:
            second=tmp[0]
            break
print(first*second)

Submission status: Wrong Answer

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

c = collections.Counter(a).most_common()
c.reverse()

first=0
second=0
for tmp in c:
    if tmp[1] >=4 and first*second==0:
        first=tmp[0]
        second=tmp[0]
        break
    if tmp[1] >=2:
        if first==0:
            first=tmp[0]
        else:
            second=tmp[0]
            break
print(first*second)

Submission status: Wrong Answer

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

c = collections.Counter(a).most_common()
c.reverse()

first=0
second=0
for tmp in c:
    if tmp[1] >=4:
        first=tmp[0]
        second=tmp[0]
        break
    if tmp[1] >=2:
        if first==0:
            first=tmp[0]
        else:
            second=tmp[0]
            break
print(first*second)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
A=Counter(list(map(int,input().split())))
x=[0,0]
for a in A:
    if A[a]>1: x.append(a)
#    if A[a]>3: x.append(a)
x.sort()
print(x[-1]*x[-2])

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = map(int, input().split())
A_count = dict(collections.Counter(A))
A_countsort = sorted(A_count, reverse=True)
# print(A_countsort)
hen_list = []
for key in A_countsort:
    if A_count[key] >= 2:
        hen_list.append(key)
if len(hen_list) >= 2:
    print(hen_list[0]*hen_list[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
p = A[0]
ok = -1
v = []
for i in range(N):
    if len(v) == 2:
        break
    if ok == 1:
        v.append(A[i-1])
        ok = -1
    if A[i] == p:
        ok += 1
    else:
        p = A[i]
        ok = 0
if len(v) <=1:
    print(0)
else:
    print(v[0]*v[1])

Submission status: Wrong Answer

Solution code:
# ARC081c
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    from collections import Counter
    import heapq

    n = int(input())

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

    b = []
    heapq.heapify(b)
    ln = 0
    cou = 0
    for i in a:
        if ln != i:
            ln = i
            cou = 0
        cou += 1
        if cou > 1:
            heapq.heappush(b, i)
            cou = 0
    try:
        print(heapq.heappop(b)*heapq.heappop(b))
    except:
        print(0)


if __name__ == '__main__':
    main()