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:
# Author: cr4zjh0bp
# Created: Tue Mar 24 00:01:43 UTC 2020
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)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() 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 Counter

n = ni()
a = na()
c = Counter(a)
m = list(c.items())
f = 0
t1, t2 = 0, 0
m.sort(reverse=True)
for k, v in m:
    if t1 != 0 and t2 != 0:
        break
    if v >= 2:
        if t1 != 0:
            t2 = k
        else:
            t1 = k
        if v >= 4:
            f = k

print(max(f * f, t1 * t2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

from collections import Counter
c = Counter(l)
c = sorted(c.items(), reverse=1)

temp = 0
for i in range(len(c)):
    if c[i][1] >= 2:
        if temp != 0:
            print(temp * c[i][0])
            exit()
        else:
            temp = c[i][0]
    if c[i][1] >= 4:
            print(c[i][0] ** 2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())

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

t.sort()

memo = []
check = 0
for i in range(n-1):
    if t[i] == t[i+1] and i == n-2:
        memo.append(t[i])
    elif t[i] == t[i+1]:
        check += 1
    elif t[i] != t[i+1] and check>0:
        memo.append(t[i])
        check = 0

memo.sort(reverse=True)

if len(memo)>1:
    print(memo[0]*memo[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())

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

s = [x for x in set(t) if t.count(x) > 1]

s.sort(reverse=True)

if len(s)>1:
    print(s[0]*s[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input().strip())
a = list(map(int, input().split()))
reps = []

a.sort()
for i in range(len(a) - 1):
    if a[i] == a[i + 1]:
        reps.append(a[i])
reps = list(set(reps))
reps.sort(reverse=True)
if len(reps) < 2:
    print(0)
else:
    print(reps[0] * reps[1])

Submission status: Wrong Answer

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

print(0)

Submission status: Wrong Answer

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

import collections

L = collections.Counter(a_L)

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

flag = 0
#print(L)
for k,v in L:
    #print(k,v)
    if v >= 2:
        if flag== 0:
            tmp = k
            flag += 1
        elif flag == 1:
            print(tmp*k)
            #print("ans",tmp,k)
            exit()

print(0)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

W = H = 0
for k,v in Counter(A).items():
    if W == 0:
        if v >= 4:
            W = H = k
            break
        elif v >= 2:
            W = k
    elif H == 0:
        if v >= 2:
            H = k
            break

print(H*W)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

W = H = 0
for k,v in Counter(A).items():
    if v > 1:
        if W == 0: W = k
        elif H == 0:
            H = k
            break

print(H*W)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(int)
for i in A:
    d[i] += 1
d = [x for x in d.items() if x[1]>=2]

ans = 0
for i in range(len(d)-1):
    if d[i][1]>=2 and d[i+1][1]>=2 and d[i][0]!=d[i+1][0]:
        ans = max(ans,d[i][0]*d[i+1][0])
    elif d[i][1]>=4 and d[i+1][1]>=4 and d[i][0]==d[i+1][0]:
        ans = max(ans,d[i][0]*d[i+1][0])
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
stics = [int(i) for i in input().split()]

c = Counter(stics)

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

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

Submission status: Wrong Answer

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

from collections import Counter
Aco = Counter(A)

ing = []
ing2 = []
for a in Aco.keys() :
    if Aco[a] >= 2 :
        ing.append(a)
    if Aco[a] >= 4 :
        ing2.append(a)

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

Submission status: Wrong Answer

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

from collections import Counter
Aco = Counter(A)

ing = []
for a in Aco.keys() :
    if Aco[a] >= 2 :
        ing.append(a)

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

l = Counter(lines)

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

if len(l.keys()) <= 1:
  print(0)
else:
  ans_value = list(l.values())
  anss = list(l.keys())
  ans_value.sort()
  anss.sort()
  anss = list(reversed(anss))
  ans_value = list(reversed(ans_value))
  print(anss[0] * anss[1] if ans_value[0] < 4 else anss[0] ** 2)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

l = Counter(lines)

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

if len(l.keys()) <= 1:
  print(0)
else:
  anss = list(l.keys())
  anss.sort()
  anss = list(reversed(anss))
  print(anss[0] * anss[1])

Submission status: Wrong Answer

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

n = int(input())
a = list(map(int, input().split()))
cnt = 0
ans = 1
a.sort(reverse=True)
for i in range(n - 1):
    if cnt == 1 and a[i] != ans or cnt == 0:
        if a[i] == a[i + 1]:
            cnt += 1
            ans *= a[i]
            if cnt == 2:
                print(ans)
                exit()
print(0)

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
A=list(map(int,input().split()))
l=[]
c=collections.Counter(A)
a=[]
values=list(c.values())
key=list(c.keys())
for i in range(len(key)):
    l.append([key[i],values[i]])
#print(l)
x=sorted(l,key=lambda x:x[1],reverse=True)
#print(x)

for i in range(len(x)):
    if x[i][1]>=2:
        a.append(x[i][0])
if len(a)<2:
    print("0")
else:
    a.sort(reverse=True)
    print(a[0]*a[1])

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
A=list(map(int,input().split()))
l=[]
c=collections.Counter(A)
a=[]
values=list(c.values())
key=list(c.keys())
for i in range(len(key)):
    l.append([key[i],values[i]])
x=sorted(l,key=lambda x:x[0],reverse=True)
x.sort(key=lambda x:x[1],reverse=True)
#print(x)

for i in range(len(x)):
    if x[i][1]>=2:
        a.append(x[i][0])
if len(a)<2:
    print("0")
else:
    a.sort(reverse=True)
    print(a[0]*a[1])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
As = [int(a) for a in A]
numbers = sorted(As, reverse=True)
list = []
for z in numbers:
    if z in list:
        pass
    else:
        list.append(z)
kotae = 0
c=1
for a in list:
    kazu = numbers.count(a)
    if kazu >= 4:
        print(a ** 2)
        kotae+=2
        break
    elif kazu >= 2 and kazu < 4:
        kotae+=2
        c*=a
    if kotae==4:
        print(c)
        break
if kotae == 0:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for ai in input().split():
  ai = int(ai)
  if ai not in d:
    d[ai] = 0
  d[ai] += 1

n2 = [k for k in d if d[k] > 1]
n4 = [k for k in d if d[k] > 3]

n2.sort(reverse = True)
n4.sort(reverse = True)

ans = 0

if n4:
  ans = n4[0] ** 2

if len(n2) > 1:
  max(ans, n2[0] * n2[1])

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for ai in input().split():
  ai = int(ai)
  if ai not in d:
    d[ai] = 0
  d[ai] += 1

n2 = [d[k] for k in d if d[k] > 1]
n4 = [d[k] for k in d if d[k] > 3]

n2.sort(reverse = True)
n4.sort(reverse = True)

ans = 0

if n4:
  ans = n4[0] ** 2

if len(n2) > 1:
  max(ans, n2[0] * n2[1])

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    A = list(map(int, input().split()))
    a = sorted(A, reverse=1)
    b = list(set(a))
    c = sorted(b, reverse=1)
    res = []
    for i in c:
        if a.count(i)>=2:
            res.append(i)
        if len(res)==2:
            break
    if len(res)>=2:
        print(res[0]*res[1])
    else:
        print(0)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
c = defaultdict(int)
for x in a:
  c[x] += 1

top, sec = 0,0
for k,v in c.items():
  if v < 2:
    continue
  if k > top:
    sec = top
    top = k
  elif k > sec:
    sec = k

print(top * sec)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
c = defaultdict(int)
for x in a:
  c[x] += 1

top, sec = 0,0
for k,v in c.items():
  if n < 2:
    continue
  if k > top:
    sec = top
    top = k
  elif k > sec:
    sec = k

print(top * sec)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
s = 0; t = 0
B = sorted(B.items(), key=lambda x:x[0], reverse=True)
for i in B:
    if i[1] > 1 and s == 0:
        s = i[0]
    elif i[1] > 1 and t == 0:
        t = i[0]
print(s*t)

Submission status: Wrong Answer

Solution code:
import collections

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

c=collections.Counter(a)

SET=set()
for i,m in c.items():
    if m>=2:
        SET.add(i)
LIST=list(SET)
LIST.sort()

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = []
a.sort(reverse=True)
key = a[0]
i = 1
while True:
    if len(ans) == 2:
        break
    if a[i] == key:
        i += 2
        ans.append(key)
        if i > n-1:
            break
        key = a[i]
    else:
        i += 1
        if i > n-1:
            break
        key = a[i]
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()))
d = {}
for x in a:
    d[x] = d.get(x, 0) + 1
l = []
ans = 0
for num, cnt in sorted(d.items(), key=lambda x: x[0], reverse=True):
    if cnt > 3:
        ans = num ** 2
        print(ans)
        exit()
    elif cnt > 1:
        l.append(num)
        if len(l) == 2:
            ans = l[0] * l[1]
            print(ans)
            exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
d = {}
for x in a:
    d[x] = d.get(x, 0) + 1
d = sorted(d.items(), key=lambda x: x[0], reverse=True)

l = []
ans = 0
for num, cnt in d:
    if cnt > 3:
        ans = num ** 2
        print(ans)
        exit()
    elif cnt > 1:
        l.append(num)
        if len(l) == 2:
            ans = l[0] * l[1]
            print(ans)
            exit()

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
d = {}
for x in a:
    d[x] = d.get(x, 0) + 1
d = sorted(d.items(), key=lambda x: x[0], reverse=True)
d = dict(d)

l = []
ans = 0
for num, cnt in d.items():
    if cnt > 1:
        l.append(num)
        if len(l) == 2:
            ans = l[0] * l[1]
            print(ans)
            exit()
    if cnt > 3:
        ans = num ** 2
        print(ans)
        exit()

print(ans)

Submission status: Wrong Answer

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    from collections import defaultdict
    dd = defaultdict(int)
    
    for i in range(N):
        dd[A[i]]+=1
        
    L=[0,0]
    for k,v in dd.items():
        if v>=2:
            L.append(k)
            
    L.sort()
    print(L[-1]*L[-2])

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
d = {}
for x in a:
    d[x] = d.get(x, 0) + 1
d = sorted(d.items(), key=lambda x: x[0], reverse=True)
d = dict(d)
l = []
ans = 0
for num, cnt in d.items():
    if cnt > 3:
        ans = num ** 2
        print(ans)
        exit()
    elif cnt > 1:
        l.append(num)
        if len(l) == 2:
            ans = l[0] * l[1]
            print(ans)
            exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
d = {}
for x in a:
    d[x] = d.get(x, 0) + 1
d = sorted(d.items(), key=lambda x: x[0], reverse=True)
d = dict(d)
print(d)
l = []
ans = 0
for num, cnt in d.items():
    if cnt > 3:
        ans = num ** 2
        print(ans)
        exit()
    elif cnt > 1:
        l.append(num)
        if len(l) == 2:
            ans = l[0] * l[1]
            print(ans)
            exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    d[i] = d.get(i, 0) + 1
d = sorted(d.items(), key=lambda x:x[0], reverse=True)
d = dict(d)
l =[]
ans = 0
for num, cnt in d.items():
    if cnt >= 4:
        ans = num ** 2
        print(ans)
        exit()
    elif cnt >= 2:
        l.append(num)
        if len(l) == 2:
            ans = l[0] * l[1]
            print(ans)
            exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    d[i] = d.get(i, 0) + 1
d = sorted(d.items(), key=lambda x:x[0], reverse=True)
d = dict(d)
print(d)
l =[]
ans = 0
for num, cnt in d.items():
    if cnt >= 4:
        ans = num ** 2
        print(ans)
        exit()
    elif cnt >= 2:
        l.append(num)
        if len(l) == 2:
            ans = l[0] * l[1]
            print(ans)
            exit()
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    d[i] = d.get(i, 0) + 1
d = sorted(d.items(), key=lambda x:x[0], reverse=True)
d = dict(d)

l =[]
ans = 0
for num, cnt in d.items():
    if cnt >= 4:
        ans = num ** 2
        print(ans)
        exit()
    elif cnt >= 2:
        l.append(num)
        if len(l) == 2:
            ans = l[0] * l[1]
            print(ans)
            exit()
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
b=[]
for i in range(n-1):
    if a[i]==a[i+1]:
        b.append(a[i])
b=sorted(b,reverse=True)
if len(b)<=1:
    print(0)
elif len(b)==2 and b[0]==b[1]:
    print(0)
elif b.count(b[0])>=3:
    print(b[0]*2)
else:
    b=list(set(b))
    b=sorted(b,reverse=True)
    print(b[0]*b[1])

Submission status: Wrong Answer

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

A.sort(reverse=True)
edges = 2
cnt = 1
ans = 1
for i in range(N-1):
    if A[i] == A[i+1]:
        cnt += 1
        continue
    if cnt >= 2:
        edges -= 1
        ans *= A[i]
    if edges == 0:
        break
    cnt = 1
if edges != 0 and cnt >= 2:
    edges -= 1
    ans *= A[N-1]
if edges == 0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys
n = int(input())
a = list(map(int, input().split()))
count_a = list(Counter(a).items())
count_a = sorted(count_a, reverse=True)
result = 1
c = 0
for x, y in count_a:
    if y>=2:
        result *= x
        c += 1
    if c == 2:
        print(result)
        sys.exit()
print(0)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
a = [int(_) for _ in input().split()]
aa = collections.Counter(a).most_common()
aa = sorted(aa, reverse=True)
length = []
cnt = 0
for i in aa:
    if i[1] >= 2:
        length.append(i)
        cnt += 1
        if cnt == 2:
            break
    else:
        pass
if cnt >= 2:
    print(length[0][0] * length[1][0])
elif cnt == 1 and length[0][1] >= 4:
    print(length[0][0] * length[0][0])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
a = [int(_) for _ in input().split()]
aa = collections.Counter(a).most_common()
aa = sorted(aa, reverse=True)
length = []
cnt = 0
for i in aa:
    if i[1] >= 2:
        length.append(i[0])
        cnt += 1
        if cnt == 2:
            break
    else:
        pass
if cnt >= 2:
    print(length[0] * length[1])
elif cnt == 1:
    print(length[0] * length[0])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
a = [int(_) for _ in input().split()]
aa = collections.Counter(a).most_common()
aa = sorted(aa, reverse=True)
length = []
cnt = 0
for i in aa:
    if i[1] >= 2:
        length.append(i[0])
        cnt += 1
        if cnt == 2:
            break
    else:
        pass
if cnt >= 2:
    print(length[0] * length[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def main():
    _ = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    li = [(k, v) for k, v in c.items() if v >= 2]
    if li and li[0][1] >= 4:
        print(li[0][0] * li[0][0])
    elif len(li) <= 1:
        print(0)
    else:
        print(li[0][0] * li[1][0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
list=[]
for i in range(n):
  if l.count(l[i])>=2:
    list.append(l[i])
list.sort()
if len(list)<=1:
  print(0)
else:
  print(list[len(list)-1]*list[len(list)-2])

Submission status: Wrong Answer

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

c=Counter(a)
m=c.most_common()
tmp=[]
for i in range(len(m)):
    if(m[i][1]>=2):
        tmp.append(m[i])
d=sorted(tmp,key=lambda tmp:tmp[1])

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

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
set_a = set(a)
lists = []
print(c)
for i in set_a:
    if int(c[i]) >= 2:
       lists.append(int(i))
    if int(c[i]) >= 4:
        lists.append(int(i))
lists.sort()
lists.reverse()
print(lists)
if len(lists) > 1:
    ans = int(lists[0]) * int(lists[1])
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
set_a = set(a)
lists = []
for i in set_a:
    if int(c[i]) == 2:
        lists.append(i)
    elif int(c[i]) == 3:
        lists.append(i)
    elif int(c[i]) >= 4:
        lists.append(i)
        lists.append(i)

lists.sort()
lists.reverse()
Max = -999999999
if len(lists) > 1:
    for i in range(len(lists)-1):
        ans = int(lists[i]) * int(lists[i+1])
        if ans > Max:
            Max = ans
else:
    Max = 0
print(Max)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
set_a = set(a)
lists = []
for i in set_a:
    if int(c[i]) == 2:
        lists.append(i)
    elif int(c[i]) == 3:
        lists.append(i)
    elif int(c[i]) >= 4:
        lists.append(i)
        lists.append(i)

lists.sort()
lists.reverse()
print(lists)
Max = -999999999
if len(lists) > 1:
    for i in range(len(lists)-1):
        ans = int(lists[i]) * int(lists[i+1])
        if ans > Max:
            Max = ans
else:
    Max = 0
print(Max)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
set_a = set(a)
lists = []
for i in set_a:
    if int(c[i]) >= 2:
       tmp = int(c[i]) // 2
       for j in range(tmp):
           lists.append(i)
lists.sort()
lists.reverse()
Max = 0
if len(lists) > 1:
    for i in range(len(lists)-1):
        ans = int(lists[i]) * int(lists[i+1])
        if ans > Max:
            Max = ans
print(Max)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
set_a = set(a)
lists = []
for i in set_a:
    if int(c[i]) >= 2:
       tmp = int(c[i]) // 2
       for j in range(tmp):
           lists.append(i)
lists.sort()
lists.reverse()
Max = -999999999
if len(lists) > 1:
    for i in range(len(lists)-1):
        ans = int(lists[i]) * int(lists[i+1])
        if ans > Max:
            Max = ans
else:
    Max = 0
print(Max)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
set_a = set(a)
lists = []
for i in set_a:
    if int(c[i]) >= 2:
       tmp = int(c[i]) // 2
       for j in range(tmp):
           lists.append(i)
lists.sort()
lists.reverse()
if len(lists) > 1:
    ans = int(lists[0]) * int(lists[1])
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
set_a = set(a)
lists = []
for i in set_a:
    if int(c[i]) >= 2:
       tmp = int(c[i]) // 2
       for j in range(tmp):
           lists.append(i)
lists.sort()
lists.reverse()
if len(lists) > 0:
    ans = int(lists[0]) * int(lists[1])
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
set_a = set(a)
lists = []
for i in set_a:
    if int(c[i]) >= 2:
        lists.append(i)
lists.sort()
lists.reverse()
if len(lists) > 1:
    ans = int(lists[0]) * int(lists[1])
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
set_a = set(a)
lists = []
for i in set_a:
    if int(c[i]) >= 2:
        lists.append(i)
lists.sort()
lists.reverse()
if len(lists) > 0:
    ans = int(lists[0]) * int(lists[1])
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy


def main():
    sticks = int(input())
    stick_length = list(map(int, input().split()))
    length_count = {}
    for length in stick_length:
        if length in length_count:
            length_count[length] += 1
        else:
            length_count[length] = 1
    for length, count in deepcopy(length_count).items():
        if count < 2:
            del length_count[length]
    answer = 0
    if len(length_count) >= 2:
        length_count = sorted(length_count.items(), key=lambda x: x[0])
        answer = length_count[-1][0] * length_count[-2][0]
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy


def main():
    sticks = int(input())
    stick_length = list(map(int, input().split()))
    length_count = {}
    for length in stick_length:
        if length in length_count:
            length_count[length] += 1
        else:
            length_count[length] = 1
    for length, count in deepcopy(length_count).items():
        if count < 2:
            del length_count[length]
    answer = 0
    if len(length_count) >= 2:
        length_count = sorted(length_count.items(), key=lambda x: x[0])
        answer = length_count[0][0] * length_count[1][0]
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy


def main():
    sticks = int(input())
    stick_length = list(map(int, input().split()))
    length_count = {}
    for length in stick_length:
        if length in length_count:
            length_count[length] += 1
        else:
            length_count[length] = 1
    for length, count in deepcopy(length_count).items():
        if count < 2:
            del length_count[length]
    answer = 0
    if len(length_count) >= 2:
        length_count = sorted(length_count.items(), key=lambda x: x[1])
        answer = length_count[0][0] * length_count[1][0]
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

A_sorted = sorted(A, reverse=True)

counter = 0
edge1 = 0
edge2 = 0
flag = 0
for i in range(len(A_sorted)-1):
    if edge1 == 0 and A_sorted[i] == A_sorted[i+1]:
        edge1 = A_sorted[i]
        flag = 1
    if flag == 1 and A_sorted[i] != edge1 and A_sorted[i] == A_sorted[i+1]:
        edge2 = A_sorted[i]
        break
print(edge1*edge2)

Submission status: Wrong Answer

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

S_A = set(A)
S_A_sorted = sorted(S_A, reverse=True)

count = 0
sum = 1
for i in S_A_sorted:
    if A.count(i) >= 2 and count <2:
        sum = sum * i
        count = count + 1
if count < 2:
    print(0)
else:
    print(sum)

Submission status: Wrong Answer

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

b = list(set(a))
b.sort(reverse=True)

for i in range(len(b)):
    if a.count(b[i])>=4:
        print(b[i]**2)
        exit()
    elif a.count(b[i])>=2:
        while True:
            j=i+1
            if j<len(b) and a.count(b[j])>=2:
                print(b[i]*b[j])
                break
                exit()
            else:
                j+=1
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

cnt = 0
ans = 0
for k, v in sorted(d.items(), key=lambda x: x[0], reverse=True):
    if v >= 4 and cnt == 0:
        ans = k * 2
        break
    elif v >= 2:
        if cnt == 0:
            ans = k
            cnt += 1
        else:
            ans *= k
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)
d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

cnt = 0
ans = 0
for k, v in d.items():
    if v >= 4 and cnt == 0:
        ans = k * 2
        break
    elif v >= 2:
        if cnt == 0:
            ans = k
            cnt += 1
        else:
            ans *= k
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)
d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

cnt = 0
ans = 0
for k, v in d.items():
    if v < 2:
        continue
    if v >= 4 and cnt == 0:
        ans = v * 2
        break
    elif v >= 2:
        if cnt == 0:
            ans = k
            cnt += 1
        else:
            ans *= k
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

line1 = 0
line2 = 0
for k, v in sorted(d.items(), key=lambda x: x[0], reverse=True):
    if v < 2:
        continue
    # すでにソート済みなので上から順番に使うものを選ぶだけ
    if line1 == 0:
        if v == 4:
            line1 = k
            line2 = k
            break
        else:
            line1 = k
    elif line2 <= k <= line1:
        line2 = k
        break
print(line1 * line2)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1
    if d[a[i]] < 2:
        continue

line1 = 0
line2 = 0
for k, v in sorted(d.items(), key=lambda x: x[0], reverse=True):
    if v < 2:
        continue
    if line1 == 0:
        if v == 4:
            line1 = k
            line2 = k
            break
        else:
            line1 = k
    elif line2 <= k <= line1:
        line2 = k
        break
print(line1 * line2)

Submission status: Wrong Answer

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

dic = {}
for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1
#print(dic)
dic = sorted(dic.items(), key=lambda x:x[0])
dic.reverse()
#print(dic)
ans = 0
cnt = 0
for i in range(len(dic)):
    if dic[i][1] >= 4:
        ans = dic[i][0] ** 2
        break
    elif dic[i][1] >= 2:
        if cnt == 0:
            ans = dic[i][0]
            cnt += 1
        else:
            ans = ans * dic[i][0]
            break
print(ans)