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:
a=list(map(int,input().split()))
from collections import Counter
ac=Counter(a)
v=sorted(ac.items(),reverse=1)
ans=[]
ans1=[]

for i in range(len(ac)):
  if v[i][1]>=2:
    ans.append(v[i][0])
  if v[i][1]>=4:
    ans1.append(v[i][0])
if len(ans)>=2:
  if len(ans1)>=1:
      print(max(ans[0]*ans[1],ans1[0]**2))
  else:
      print(ans[0]*ans[1])
else:
  if len(ans1)>=1:
      print(max(0,ans1[0]**2))
  else:
      print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
ac=Counter(a)
v=sorted(ac.items(),reverse=1)
ans=[]
for i in range(len(ac)):
  if v[i][1]>=2:
    ans.append(v[i][0])
if len(ans)>=2:
  print(ans[0]*ans[1])
else:
  print(0)

Submission status: Wrong Answer

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

set_list = list(set(num_list))

for i in range(len(set_list)):
    num_list.remove(set_list[i])

num_list.sort()

print(num_list)

if len(num_list) >= 3:
    if num_list[-1] == num_list[-3]:
        print(num_list[-1]**2)
    elif num_list[-1] == num_list[-2]:
        print(num_list[-1]*num_list[-3])
    else:
        print(num_list[-1]*num_list[-2])
elif len(num_list) == 2:
    if num_list[-1] == num_list[-2]:
        print(0)
    else:
        print(num_list[-1]*num_list[-2])
else:
    print(0)

Submission status: Wrong Answer

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

set_list = list(set(num_list))

for i in range(len(set_list)):
    num_list.remove(set_list[i])

if len(num_list) >= 3:
    if num_list[-1] == num_list[-3]:
        print(num_list[-1]**2)
    elif num_list[-1] == num_list[-2]:
        print(num_list[-1]*num_list[-3])
    else:
        print(num_list[-1]*num_list[-2])
elif len(num_list) == 2:
    if num_list[-1] == num_list[-2]:
        print(0)
    else:
        print(num_list[-1]*num_list[-2])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# import math
# import statistics
# import itertools
a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
# e1,e2,e3,e4 = map(int,input().split())
f = list(map(int,input().split()))
# g = [int(input()) for _ in range(a)]

f.sort()
ma =[]
count=1
for i in range(len(f)-1):
    if f[i]==f[i+1] and f[i]!=0:
        count+=1
    elif f[i]!=f[i+1] and count>=2 :
        ma.append(f[i])
        count=1
    elif  f[i]!=f[i+1] and count==1 :
        count=1
    else:
        count=1

if count>=2:
    ma.append(f[-1])
if ma==[]:
    print(0)
else:
    print(ma[-1]*ma[-2])

Submission status: Wrong Answer

Solution code:
# import math
# import statistics
# import itertools
a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
# e1,e2,e3,e4 = map(int,input().split())
f = list(map(int,input().split()))
# g = [int(input()) for _ in range(a)]

f.sort()
ma =[]
count=1
for i in range(len(f)-1):
    if f[i]==f[i+1]:
        count+=1
    elif f[i]!=f[i+1] and count>=2:
        ma.append(f[i])
        count=1
    elif  f[i]!=f[i+1] and count==1:
        count=1

if count>=2:
    ma.append(f[-1])
if ma==[]:
    print(0)
else:
    print(ma[-1]*ma[-2])

Submission status: Wrong Answer

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
a = l()
ans = []

a.sort(reverse=True)
b = -1

for i in a:
    if i==b:
        if ans != 0:
            ans *= i
            break
        else:
            ans = i
            b = -1
            continue
    b = i
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
A = A[::-1]
# print(A)

cnt = 1
length = []
for i in range(1, N):
    if A[i] == A[i-1]:
        cnt += 1
        if cnt >= 2:
            length.append(A[i])
            cnt = 0
            if len(length) >= 2:
                break
    if cnt == 0:
        cnt = 1
else:
    length = [0, 0]
print(length[0] * length[1])

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
aa = list(map(int, input().split()))
ca = collections.Counter(aa)
la = sorted([a for a in ca.items()], key = lambda x:x[1])
arr = []
for i in range(len(la)):
  if la[i][1] != 1:
    arr.append(la[i][0])
ans = sorted(arr, reverse = True)
if len(arr) <2:
  print(0)
else:
  print(arr[0] * arr[1])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
h1,h2,w1,w2=0,0,0,0
for i in range(n-3):
  h1,h2,w1,w2=a[i],a[i+1],a[i+2],a[i+3]
  if h1==h2 and w1==w2:
    break
  else:
    h1,h2,w1,w2,=0,0,0,0
print(h1*w1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

B = set(A)
A = Counter(A)

ans = 0
keep = 0

for i in B:
    kazu = A[i]
    if kazu >= 4:
        ans = i**2
        keep = i
    elif kazu >= 2:
        ans = keep * i
        keep = i
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

B = set(A)
A = Counter(A)
print(A)
ans = 0
keep = 0

for i in B:
    kazu = A[i]
    if kazu >= 4:
        ans = i**2
        keep = i
    elif kazu >= 2:
        ans = keep * i
        keep = i
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

B = set(A)
A = Counter(A)

ans = 0
keep = 0

for i in B:
    kazu = A[i]
    if kazu >= 4:
        ans = i**2
        keep = i
    if kazu >= 2:
        ans = keep * i
        keep = i
print(ans)

Submission status: Wrong Answer

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

B = set(A)

ans = 0
keep = 0

for i in B:
    if A.count(i) >= 4:
        ans = i**2
        keep = i
    if A.count(i) >= 2:
        ans = keep * i
        keep = i
print(ans)

Submission status: Wrong Answer

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

A = sorted(A, reverse=True)
B = set(A)

ans = 0
keep = 0

for i in B:
    if A.count(i) >= 4:
        ans = i**2
        keep = i
    if A.count(i) >= 2:
        ans = keep * i
        keep = i
print(ans)

Submission status: Wrong Answer

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

A = sorted(A, reverse=True)
B = set(A)

ans = 0
keep = 0

for i in B:
    if A.count(i) >= 4:
        ans = max(keep * i, i**2)
    elif A.count(i) >= 2:
        ans = keep * i
        keep = i
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
List = list(map(int,input().split()))
dic = defaultdict(int)
for item in List:
  dic[item] += 1
diccopy = dic.copy()
for key in diccopy:
  if diccopy[key] == 1:
    dic.pop(key)
keys = sorted(list(dic.keys()))
if len(keys)==0:
  ans = 0
elif dic[keys[-1]]== 4:
  ans = keys[-1]**2
elif len(keys)==1:
  ans = 0
else:
  if dic[keys[-2]] == 1:
    ans = 0
  else:
    ans = keys[-1]*keys[-2]
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
List = list(map(int,input().split()))
dic = defaultdict(int)
for item in List:
  dic[item] += 1
diccopy = dic.copy()
for key in diccopy:
  if diccopy[key] == 1:
    dic.pop(key)
keys = sorted(list(dic.keys()))
if len(keys)==0:
  ans = 0
elif dic[keys[-1]]== 4:
  ans = keys**2
elif len(keys)==1:
  ans = 0
else:
  if dic[keys[-2]] == 1:
    ans = 0
  else:
    ans = keys[-1]*keys[-2]
print(ans)

Submission status: Wrong Answer

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

d = dict()

for a in A:
    d[a] = d.get(a, 0) + 1

x = [l for l, n in sorted(d.items(), reverse=True, key=lambda x:x[0]) if n >= 2]

try:
    print(x[0]*x[1])
except:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
count_a = Counter(a)
new_a = [i for i in count_a.keys() if count_a[i] >= 2]
#print(new_a)
if len(new_a) < 2:
    print(0)
    exit()
new_a = sorted(new_a, reverse=True)
ans = new_a[0] * new_a[1]
print(ans)

Submission status: Wrong Answer

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

b1 = [i[0] for i in c.items() if i[1] >= 4]
b2 = [i[0] for i in c.items() if 4 >= i[1] >= 2]
b = b1 + b2 + [0,0]

b.sort()
print(b[-1]*b[-2])

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n = I()
    a = LI()
    a.sort()
    gr = itertools.groupby(a)
    lst = []
    for key, group in gr:
        if len(list(group)) >= 2:
            lst.append(key)

    ans = 0
    if len(lst) >= 2:
        ans = lst[-1] * lst[-2]
    print(ans)
main()

Submission status: Wrong Answer

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

A.sort(reverse = True)
a=0
b=0
cnt = 0
for i in range(1,len(A)):
    if A[i]==A[i-1]:
        cnt+=1
    else:
        cnt=1
        
    if cnt==2:
        if a==0:
            a=A[i]
        elif b==0:
            b=A[i]
        cnt=0
        
        if a*b!=0:
            break

print(a*b)

Submission status: Wrong Answer

Solution code:
N=int(input())
*A,=map(int,input().split())
d={}
for a in A:
    d[a] = d.get(a, 0)+1
s=sorted([k for k,v in d.items() if 2<=v], reverse=True)
if len(s)<2:
    print(0)
else:
    print(s[0]*s[1])

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import Counter


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())


n = inint()
A = inintl()

A = Counter(A)
b = []

m = 0

for a in A:
    if A[a] >= 4:
        if a > m:
            m = a
    if A[a] >= 2:
        b.append(a)

b = sorted(b)[::-1]


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

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import Counter


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())


n = inint()
A = inintl()

A = Counter(A)
b = []

for a in A:
    if A[a] >= 2:
        b.append(a)

b.sort()

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import Counter


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())


n = inint()
A = inintl()

A = Counter(A)
b = []

for a in A:
    if A[a] >= 2:
        b.append(a)

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

Submission status: Wrong Answer

Solution code:
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())


n = inint()
A = inintl()

A = sorted(A)[::-1]

for i in range(n-3):
    if A[i] != A[i+1] or A[i+2] != A[i+3]:
        continue
    else:
        print(A[i]*A[i+2])
        exit()

print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
f = [0 if c[k] < 2 else k for k in c.keys()]
f.sort()
[a, b] = f[-2:]
print(a*b)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
s = set(sorted(a))
v = [i for i in s]
v.reverse()
b_1 = 0
b_2 = 0
for i in v:
    n = a.count(i)
    if n >= 2 and b_1 != 0 and b_2 == 0:
        b_2 = i
    if n >= 2 and b_1 == 0:
        b_1 = i
    if n >= 4 and b_2 == 0:
        b_2 = i
print(b_1*b_2)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
s = set(sorted(a))
v = [i for i in s]
v.reverse()
print(v)
b_1 = 0
b_2 = 0
for i in v:
    n = a.count(i)
    if n >= 2 and b_1 != 0 and b_2 == 0:
        b_2 = i
    if n >= 2 and b_1 == 0:
        b_1 = i
    if n >= 4 and b_2 == 0:
        b_2 = i
print(b_1*b_2)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
c = collections.OrderedDict(sorted(c.items(), key=lambda x:x[0],reverse=True))
high=0
low=0
for i,j in zip(c.keys(),c.values()):
    if(j>=4):
        high=i
        low =i
        break
    elif(j>=2):
        if(high==0):
            high=i
        else:
            low=i
            break
print(high*low)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    C = Counter(A)
    can = []
    for c in set(A):
        if C[c] >= 2:
            can.append(c)
    if can:
        can = sorted(can)
        print(can[-1] * can[-2])
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
L=Counter(list(map(int,input().split())))
L1=sorted(list(i[0] for i in L.items() if i[1] >= 2))[::-1]
try:print(L1[0]*L1[1])
except IndexError:print(0)

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    cnt = collections.Counter(A)
    edge = [(k, v) for k, v in cnt.items() if v >= 2]
    edge.sort(reverse=True)

    if len(edge) >= 2:
        ans = edge[0][0] * edge[1][0]
    elif len(edge) == 1 and edge[0][1] >= 4:
        ans = edge[0][0] ** 2
    else:
        ans = 0

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    cnt = collections.Counter(A)
    edge = [k for k, v in cnt.items() if v >= 2]
    edge.sort(reverse=True)

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
from collections import Counter
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  c = Counter(A)
  B = sorted([k for k,v in c.items() if v>=2],reverse=True)
  if len(B)<2:
    return 0
  ans = B[0]*B[1]
  return ans
print(solve())

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

d = Counter(a)
l = []
flag = False
for k,v in list(sorted(d.items()))[::-1]:
  if v >= 4:
    l.append(k)
    l.append(k)
  elif v >= 2:
    l.append(k)
  if len(l) == 2:
    flag = True
    break

    
if flag:
  ans = l[0]*l[1]
else:
  ans = 0


print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

d = Counter(a)
l = []
flag = False
for k,v in list(sorted(d.items()))[::-1]:
  if len(l) == 2:
    flag = True
    break
  if v >= 2:
    l.append(k)

if flag:
  ans = l[0]*l[1]
else:
  ans = 0

print(ans)

Submission status: Wrong Answer

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

c = sorted(collections.Counter(a).items(),reverse = True)

tmp = 0
ans=[]

for k in c:
  if k[1]>=4:
    tmp = max(tmp,k[0]*k[0])
  elif k[1]>=2:
    ans.append(k[0])
  else:
    continue

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

Submission status: Wrong Answer

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

c = sorted(collections.Counter(a).items(),reverse = True)

tmp = 0
ans=[]

for k in c:
  if k[1]==4:
    tmp = max(tmp,k[0]*k[0])
  elif k[1]>=2:
    ans.append(k[0])
  else:
    continue

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

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = list(map(int,input().split()))
B = collections.Counter(A)
C = [0,0]
for i in set(A):
    if B[i] >= 2:
        C.append(i)
C.sort(reverse=True)
print(C[0]*C[1])

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import Counter
def main():
  readline = stdin.readline
  N = int(input())
  A = list((map(int, readline().split())))
  C = Counter(A)
  A = sorted(set(A))
  flag = False
  for a in A[::-1]:
    if flag:
      if C[a] >= 2:
        print(a*b)
        break
      else:
        print(0)
        break
    elif C[a] >= 4:
      print(a*a)
      break
    elif C[a] >= 2:
      b = a
      flag = True
  else:
    print(0)
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

for i in range(len(a)):
  if (x[1]<=a[i][0] or x[0]<=a[i][0]) and a[i][1]>=2:
    if x[0]<x[1]:
      x[0]=a[i][0]
    else:
      x[1]=a[i][0]
print(x[0]*x[1])

Submission status: Wrong Answer

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

for i in range(len(a)):
  if (x[1]<a[i][0] or x[0]<a[i][0]) and a[i][1]>=2:
    if x[0]<x[1]:
      x[0]=a[i][0]
    else:
      x[1]=a[i][0]
print(x[0]*x[1])

Submission status: Wrong Answer

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

for i in range(len(a)):
  if (x[1]<a[i][0] or x[0]<a[i][0]) and a[i][1]>=2:
    x[1]=x[0]
    x[0]=a[i][0]
    if x[0]<x[1]:
      x[0],x[1]=x[1],x[0]
print(x[0]*x[1])

Submission status: Wrong Answer

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

for i in range(len(a)):
  if x[1]<=a[i][0] and a[i][1]>=2:
    x[1]=x[0]
    x[0]=a[i][0]
print(x[0]*x[1])

Submission status: Wrong Answer

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

for i in range(len(a)):
  if x[1]<a[i][0] and a[i][1]>=2:
    x[1]=x[0]
    x[0]=a[i][0]
print(x[0]*x[1])

Submission status: Wrong Answer

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

for i in range(len(a)):
  if x[0]<a[i][0] and a[i][1]>=2:
    x[1]=x[0]
    x[0]=a[i][0]
print(x[0]*x[1])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
w=list(set(A))
b=[]
c=[]

for i in w:
    if A.count(i)>=2 and A.count(i)<4:
        b.append(i)
    elif A.count(i)>=4:
        c.append(i)

b=sorted(b)[::-1]
c=sorted(c)[::-1]

if len(b)<=1 and len(c)==0:
    print(0)
elif len(b)<=1:
    print(c[0]**2)
elif len(c)==0:
    print(b[0]*b[1])
else:
    print(max(c[0]**2,b[0]*b[1]))

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

d = Counter(A)

tmp_2 = []
tmp_4 = []
for k, v in d.items():
    if v >= 4:
        tmp_4.append(k)
    elif v >= 2:
        tmp_2.append(k)

ans = 0
tmp_2.sort()
tmp_4.sort()
if len(tmp_4):
    ans = tmp_4[-1]**2
if len(tmp_2) >= 2:
    ans = max(ans, tmp_2[-1]*tmp_2[-2])
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

d = Counter(A)

tmp_2 = []
tmp_4 = []
for k, v in d.items():
    if v >= 4:
        tmp_4.append(k)
    elif v >= 2:
        tmp_2.append(k)

ans = 0
if len(tmp_4):
    ans = tmp_4[-1]**2
if len(tmp_2) >= 2:
    ans = max(ans, tmp_2[-1]*tmp_2[-2])
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

d = Counter(A)

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

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

set_A = sorted((set(A)), reverse=True)
tmp = 0
for a in set_A:
    if A_dic[a] >= 4:
        print(a * a)
        exit()
    if A_dic[a] >= 2:
        ans = tmp * a
        if ans != 0:
            print(ans)
            exit()
        tmp = a
print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

set_A = sorted((set(A)), reverse=True)
tmp = 0
for a in set_A:
    if A_dic[a] >= 4:
        print(a * a)
        exit()
    if A_dic[a] >= 2:
        ans = tmp * a
        if ans != 0:
            print(ans)
            exit()
        tmp = a

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if A_dic.most_common()[0][0] == 1:
    print(0)
    exit()

set_A = sorted((set(A)), reverse=True)
tmp = 0
for a in set_A:
    if A_dic[a] >= 4:
        print(a * a)
        exit()
    if A_dic[a] >= 2:
        ans = tmp * a
        if ans != 0:
            print(ans)
            exit()
        tmp = a

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
set_A = sorted(tuple(set(A)), reverse=True)

cnt = 0
for a in set_A:
  if A.count(a) >= 4:
    print(a*2)
    exit()
  if A.count(a) >= 2:
    tmp = cnt * a
    if tmp != 0:
      print(tmp)
      exit()
    cnt = a
    
print(0)

Submission status: Wrong Answer

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

set_A = tuple(set(A))
Side_2 = []
Side_4 = []
for a in set_A:
    tmp = A.count(a)
    if (tmp >= 2) and (tmp < 4):
        Side_2.append(a)
    if tmp >= 4:
        Side_4.append(a)

Side_2.sort  
if (len(Side_2) < 2) and not Side_4:
    print(0)
    exit()

if (len(Side_2) >= 2) and not Side_4:
    print(Side_2[-1] * Side_2[-2])
    exit()

Side_4.sort   
if not Side_2 and Side_4:
    print(Side_4[-1] * 2)
    exit()

if (len(Side_2) == 1) and Side_4:
    max2 = Side_2[-1]
    max4 = Side_4[-1]
    if max4 >= max2:
        print(max4 * 2)
        exit()
    else:
        print(max4 * max2)
        exit()

if (len(Side_2) >= 2) and Side_4:
    max2 = Side_2[-1]
    max2_2 = Side_2[-2]
    max4 = Side_4[-1]
    if max4 >= max2:
        print(max4 * 2)
        exit()
    elif (max4 < max2) and (max4 <= max2_2):
        print(max2 * max2_2)
        exit()
    elif (max4 < max2) and (max4 > max2_2):
        print(max2 * max4)
        exit()

Submission status: Wrong Answer

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

set_A = tuple(set(A))
Side_2 = []
Side_4 = []
for a in set_A:
    tmp = A.count(a)
    if (tmp >= 2) and (tmp < 4):
        Side_2.append(a)
    if tmp >= 4:
        Side_4.append(a)
        
if (len(Side_2) < 2) and not Side_4:
    print(0)
    exit()

if not Side_2 and Side_4:
    print(Side_4[-1] * 2)
    exit()

if (len(Side_2) >= 2) and not Side_4:
    print(Side_2[-1] * Side_2[-2])
    exit()

if (len(Side_2) == 1) and Side_4:
    max2 = Side_2[-1]
    max4 = Side_4[-1]
    if max4 >= max2:
        print(max4 * 2)
        exit()
    else:
        print(max4 * max2)
        exit()

if (len(Side_2) >= 2) and Side_4:
    max2 = Side_2[-1]
    max2_2 = Side_2[-2]
    max4 = Side_4[-1]
    if max4 >= max2:
        print(max4 * 2)
        exit()
    elif (max4 < max2) and (max4 <= max2_2):
        print(max2 * max2_2)
        exit()
    elif (max4 < max2) and (max4 > max2_2):
        print(max2 * max4)
        exit()

Submission status: Wrong Answer

Solution code:
from collections import Counter

def solve():
    N = int(input())
    R = map(int, input().split())
    counter = Counter(R)
    rect = []
    ret = 0
    edges = sorted(counter.items(), key=lambda x:-1*x[0])
    for a,b in edges:
        if b >= 4:
            rect = [a,a]
        elif b >= 2:
            rect.append(a)
        
        if len(rect) == 2: 
            ret = rect[0]*rect[1]
            break
            
    print(ret)
    
solve()

Submission status: Wrong Answer

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

kl = list()
for k, v in c:
  if v < 2:
    break
  kl.append(k)
  
kl.sort(reverse=True)
print(0 if not kl else kl[0] * kl[1])

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    import collections
    N = int(input())
    As = [int(item) for item in input().split()]

    cnt = collections.Counter(As)
    cnt = sorted(cnt.items(), reverse=True)
    # print(sorted(cnt.items(), reverse=True))
    edges = []
    lim = 0
    res = 0
    if len(cnt) >=2:
        for i, v in cnt:
            if v >= 4 and i > 0:
                edges.append(i)
                edges.append(i)
                lim += 2
            elif v>=2 and i>0:
                edges.append(i)
                lim += 1

            if lim == 2:
                res = edges[0]*edges[1]
                break
    print(res)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    import collections
    N = int(input())
    As = [int(item) for item in input().split()]

    cnt = collections.Counter(As)
    cnt = sorted(cnt.items(), reverse=True)
    # print(sorted(cnt.items(), reverse=True))
    edges = []
    lim = 0
    res = 0
    if len(cnt) >=2:
        for i, v in cnt:
            if v >= 2 and i > 0:
                edges.append(i)
                lim += 1
                
            if lim == 2:
                res = edges[0]*edges[1]
                break
    print(res)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

counter = Counter(A)
ans = 0
pair = []
for l, count in sorted(counter.items(), reverse=True):
    if count < 2:
        continue
    pair.append(l)
    if len(pair) == 2:
        break
if len(pair) == 2:
    print(pair[0] * pair[1])
else:
    print(0)

Submission status: Wrong Answer

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

cnt = 0
tmp = a[0]
ans = []
for i in range(1,len(a)):
    if tmp == a[i]:
        ans.append(tmp)
    else:
        tmp = a[i]

ans = set(ans)
ans = list(ans)
ans.sort(reverse = True)

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()))
a.sort()

tmp = a[0]
ans = []
for i in range(1,len(a)):
    if tmp == a[i]:
        ans.append(tmp)
    else:
        tmp = a[i]

ans = set(ans)
ans = list(ans)

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

Submission status: Wrong Answer

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

cnt = 0
tmp = a[0]
ans = []
for i in range(1,len(a)):
    if tmp == a[i]:
        ans.append(tmp)
    else:
        tmp = a[i]

ans = set(ans)
ans = list(ans)

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
c = Counter(map(int, input().split()))
c = sorted((e for e in c.items() if e[1] > 1), key=lambda e: -e[1])
if len(c) < 2:
  print(0)
elif c[0][1] >= 4:
  print(c[0][0] ** 2)
else:
  print(c[0][0] * c[1][0])

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
c = Counter(map(int, input().split()))
c = sorted((k for k in c if c[k] > 1), reverse=True)
if len(c) > 1:
  print(c[0] * c[1])
else:
  print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
c = Counter(map(int, input().split()))
c = sorted((k for k in c if c[k] > 1), reverse=True)
if len(c) > 1:
  print(c[0] * c[1])
else:
  print(c)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())

A = list(map(int, input().split()))
stick = defaultdict(int)

for a in A:
  stick[a] += 1

stick = {key: value for key, value in stick.items() if value >= 2}


if len(stick) >= 2:
  len1 = max(stick.keys())
  stick.pop(len1)
  len2 = max(stick.keys())
  print(len1 * len2)
else:
  print(0)