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:
N = int(input())
A = list(map(int,input().split()))
Acount = {}
q = []

for a in A:
  if a not in Acount:
    Acount[a] = 0
  else:
    Acount[a] += 1
    
for key, val in Acount.items():
  while val >= 2:
    q.append(key)
    val -= 2

q.sort(reverse=True)

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())
    A = sorted(li_input(), reverse=1)
 
    D = collections.defaultdict(lambda: 0)
    E = []

    for a in A:
        D[a] += 1
 
    for d in D.keys():
        for i in range(max(2, D[d] // 2)):
            E.append(d)
            
    if len(E) >= 2:
        E.sort(reverse=True)
        print(E[0] * E[1])
    else:
        print(0)
 
 
main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


# def main():
#     N = int(input())
#     A = li_input()

#     D = collections.defaultdict(lambda: 0)
#     X = [0, 0]
 
#     for a in A:
#         D[a] += 1
 
#     for k, v in D.items():
#         if v >= 2:
#             X.append(k)
#         if v >= 4:
#             X.append(k)
 
#     X.sort(reverse=True)
 
#     print(X[0] * X[1])

def main():
    N = int(input())
    A = sorted(li_input(), reverse=1)
 
    D = collections.defaultdict(lambda: 0)
    X = []

    for a in A:
        D[a] += 1
 
    for d in D.keys():
        if D[d] >= 4:
            X.append(d)
            X.append(d)
            break
 
        if D[d] >= 2:
            X.append(d)
        
 
    if len(X) >= 2:
        X.sort(reverse=True)
        print(X[0] * X[1])
    else:
        print(0)
 
 
main()

Submission status: Wrong Answer

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

ans = []
A = list(sorted(list(A.items()), reverse=True))
for i in range(N):
    if A[i][1] >= 2:
        ans.append(A[i][0])

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 30 10:49:33 2018
ABC071C
@author: maezawa
"""
import collections
n = int(input())
a = list(map(int,input().split()))
acount = collections.Counter(a)
auniq = list(set(a))
auniq.sort(reverse=True)
edge1 = 0
ans = 0
for edge in auniq:
    if acount[edge] >= 4:
        ans = edge*edge
        break
    if acount[edge] >= 2:
        if edge1 == 0:
            edge1 = edge
        else:
            ans = edge1*edge
            break
print(ans)

Submission status: Wrong Answer

Solution code:
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
a = il()
dic = dict()
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
l = []
for i, j in sorted(dic.items())[::-1]:
    if j >= 2:
        l.append(i)
    if len(l) == 2:
        break
print(l[0] * l[1] if l else 0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)
A_dict = defaultdict(lambda:0)
for a in A:
    A_dict[a] += 1
key1 = 0
key2 = 0
for key in A_dict.keys():
    if key2 > 0:
        break

    if A_dict[key] > 3:
        if key1 == 0:
            key1 = key
        if key2 == 0:
            key2 = key
    elif A_dict[key] > 1:
        if key1 > 0:
            key2 = key
        else:
            key1 = key
print(key1*key2)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)
A_dict = defaultdict(lambda:0)
for a in A:
    A_dict[a] += 1
key1 = 0
key2 = 0
for key in A_dict.keys():
    if key2 > 0:
        break

    if A_dict[key] > 3:
        key1 = key
        key2 = key
    elif A_dict[key] > 1:
        if key1 > 0:
            key2 = key
        else:
            key1 = key
print(key1*key2)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]
A_dict = defaultdict(lambda:0)
for a in A:
    A_dict[a] += 1
key1 = 0
key2 = 0
for key in A_dict.keys():
    if key2 > 0:
        break

    if A_dict[key] > 3:
        key1 = key
        key2 = key
    elif A_dict[key] > 1:
        if key1 > 0:
            key2 = key
        else:
            key1 = key
print(key1*key2)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A_list = list(map(int, input().split()))
counter = Counter(A_list)
counter = sorted(counter.items(), key=lambda x: -x[0])

long_side = 0
short_side = 0
choice = 0

for k, v in counter:
    if v % 4 == 0 and choice == 0:
        long_side = k
        short_side = k
        choice = 4

    elif v >= 2:
        if choice == 2:
            short_side = k
            choice = 4
        else:
            long_side = k
            choice = 2

    if choice == 4:
        print(long_side*short_side)
        exit()
print(0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    C = Counter(list(map(int, input().split())))

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
pre = 0
e1, e2 = 0, 0
for a in A:
  if pre == a:
    if e1 == 0:
      e1 = a
    elif e2 == 0:
      e2 == a
    pre = 0
  else:
    pre = a
print(e1 * e2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
pre = 0
e1, e2 = 0, 0
for a in A:
  if pre == a:
    if e1 == 0:
      e1 = a
    elif e2 == 0:
      e2 == a
  else:
    pre = a
print(e1 * e2)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
cnt=sorted(Counter(list(map(int, input().split()))).items(), reverse=True)
print(cnt)
b=[]
for k, v in cnt:
    if v>=4 and b==[]:
        print(k*k)
        exit()
    elif v>=2:
        b.append(k)
        if len(b)==2:
            print(b[0]*b[1])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
A=list(map(int, input().split()))
AX=Counter(A)
b=[]
maxAX=max(AX)
for i in range(maxAX,0,-1):
    if AX[i]>=4:
        if len(b)==0:
            print(i*4)
            exit()
    elif AX[i]>=2:
        b.append(i)
        if len(b)==2:
            print(b[0]*b[1])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
A=list(map(int, input().split()))
AX=Counter(A)
a=[]
b=[]
maxAX=max(AX)
for i in range(maxAX,0,-1):
    if AX[i]>=4:
        a.append(i)
        if len(b)<=1:
            print(a*4)
            exit()
    elif AX[i]>=2:
        b.append(i)
        if len(b)==2:
            print(b[0]*b[1])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
B=list(set(A))
a=[]
for i in reversed(B):
    if A.count(i)>=2:
        a.append(i)
if len(a)>=2:
    print(a[0]*a[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
a = Counter(list(input().split()))
ans = []
for i in sorted(a.items(), key=lambda x: x[0], reverse=True):
    if i[1] >= 4 and ans==[]:
        print(int(i[0]) * int(i[0]))
        exit()
    elif i[1] >= 2:
        ans.append(int(i[0]))
        if len(ans) == 2:
            print(ans[0] * ans[1])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
a = Counter(list(input().split()))
ans = []
for i in sorted(a.items(), key=lambda x: x[0], reverse=True):
    if i[1] >= 4:
        print(int(i[0]) * int(i[0]))
        exit()
    elif i[1] >= 2:
        ans.append(int(i[0]))
        if len(ans) == 2:
            print(ans[0] * ans[1])
            exit()
print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = [int(v) for v in input().split()]

cnt = Counter(a)
cnt = [k for k, v in cnt.items() if v >= 2]
if len(cnt) < 2:
    print(0)
else:
    cnt.sort(reverse=True)
    print(cnt[0] * cnt[1])

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
count=0
rec_list=[]
for i in range (N):
    if A.count(A[i])>=2 and A[i] not in rec_list:
        rec_list.append(A[i])
    if len(rec_list)==2:
        print(rec_list[0]*rec_list[1])
        sys.exit()
print(0)

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N = int(input())
    A = li_input()
    D = collections.defaultdict(lambda: 0)

    e1, e2 = 0, 0

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

    for k, v in D.items():
        if v < 2:
            continue

        if k > e1:
            e2 = e1
            e1 = k
            continue

        if k > e2:
            e2 = k
            continue

    print(e1 * e2)


main()

Submission status: Wrong Answer

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

x=0
y=0
a.sort()
i=len(a)-1
while (i>1):
  if a[i-1]==a[i]:
    x=y
    y=a[i]
    i-=2
  else:
    i-=1
  if x>0:
    break

print(x*y)

Submission status: Wrong Answer

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

count_dct = {}
for input_num in int_list:
    if input_num in count_dct.keys():
        count_dct[input_num] += 1
    else:
        count_dct[input_num] = 1
        
count_sort_list = []
for i, j in count_dct.items():
    if j >= 2:
        count_sort_list.append(i)
    else:
        pass
      
if len(count_sort_list)<2:
    print(0)
else:
    print(sorted(count_sort_list)[-1]*sorted(count_sort_list)[-2])

Submission status: Wrong Answer

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

count_dct = {}
for input_num in int_list:
    if input_num in count_dct.keys():
        count_dct[input_num] += 1
    else:
        count_dct[input_num] = 1
        
count_sort_list = []
for i, j in count_dct.items():
    if j >= 2:
        count_sort_list.append(i)
    else:
        pass
      
if len(count_sort_list)<1:
    print(0)
else:
    print(sorted(count_sort_list)[-1]*sorted(count_sort_list)[-2])

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
a = Counter(map(int, input().split()))
h, w = 0, 0
for k, v in sorted(a.items(), key=lambda x: -x[0]):
    if v >= 4:
        h, w = k, k
        break
    elif v >= 2:
        if not h:
            h = k
        elif not w:
            w = k
            break

print(h * w)

Submission status: Wrong Answer

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

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    a_list.sort(reverse=True)
    a_element = list(set(a_list))
    a_element.sort(reverse=True)

    counter = Counter(a_list)

    xy = []
    for i in a_element:
        if counter[i] >= 2:
            xy.append(i)
        if len(xy) == 2:
            print(xy[0] * xy[1])
            exit()
    print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
l=map(int,input().split())
o=sorted(filter(lambda x:x[1]>=2,Counter(l).items()))

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

Submission status: Wrong Answer

Solution code:

from collections import Counter

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

cntr = Counter(A)

key_list = list(cntr.keys())

key_list.sort(reverse=True)

ans_cand = []
ans = 0
for key in key_list:
    if cntr[key] >= 2:
        ans_cand.append(key)
        
if len(ans_cand) < 2:
    ans = 0
else:
    ans = ans_cand[0] * ans_cand[1]
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = {}

a = [int(x) for x in input().split()]

for i in a :
    if i not in d.keys() :
        d[i] = 1
    else :
        d[i] += 1

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

l1 = -1
l2 = -1

for i in range(N) :
    if s1[i][1] >= 4 :
        l1, l2 = s1[i][0], s1[i][0]
        break
    elif s1[i][1] >= 2 and s1[i][1] <= 3 and l1 == -1 :
        l1 = s1[i][0]
    elif s1[i][1] >= 2 and s1[i][1] <= 3 and l1 != -1 :
        l2 = s1[i][0]
        break
        
if l1 == -1 or l2 == -1 :
    print("0")
else :
    print(l1 * l2)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
a_duplicate = [x for x in set(a) if a.count(x) > 1]

if len(a_duplicate)<=1:
  print(0)
else:
	print(int(sorted(a_duplicate)[-1])*int(sorted(a_duplicate)[-2]))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
d={}
chk=0
for i in a[::-1]:
    print(i)
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    if d[i]==4:
        print(i*i)
        exit()
    if d[i]==2 and chk==1:
        for j in d:
           if i!=j and d[j]>=2:
                print(i*j)
                exit()
    elif d[i]==2:
           chk=1
   
print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
a.sort
d={}
chk=0
for i in a[::-1]:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    if d[i]==4:
        print(i*i)
        exit()
    if d[i]==2 and chk==1:
        for j in d:
           if i!=j and d[j]>=2:
                print(i*j)
                exit()
    elif d[i]==2:
           chk=1
   
print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
ans=1
count=2
for i in range(N):
    if count==0:
        break
    if i%2!=0:
        continue
    if a[i]==a[i+1]:
        ans*=a[i]
        count-=1
if count==0:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

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

import collections

c = collections.Counter(A)
xs = [x for x, n in c.items() if n >= 2]
xs.sort()

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
import collections
k=list(collections.Counter(a).items())
x=[k[i][0] for i in range(len(k)) if 2<=k[i][1]<4]
y=[k[i][0] for i in range(len(k)) if k[i][1]>=4]
x.sort()
y.sort()
if len(x)>1 and len(y)>1:
    print(max(x[-1]*x[-2], y[-1]**2))
elif len(x)>1:
    print(x[-1]*x[-2])
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
import collections
c = collections.Counter(a)
k=list(c.items())
k.sort(key=lambda x:x[1])
if k[-1][1]>1 and k[-2][1]>1:
    x=[k[i][0] for i in range(len(k)) if k[i][1]>1]
    x.sort()
    print(x[-1]*x[-2])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

arr = map(int,raw_input().split())

dic = {}

for i in range(n):
	if dic.has_key(arr[i]):
		dic[arr[i]] += 1
	else :
		dic[arr[i]] = 1

ans = [[k,v] for k, v in dic.items() if v > 1] 

ans = ans[-2:]


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

Submission status: Wrong Answer

Solution code:
n = int(input())

arr = map(int,raw_input().split())

dic = {}

for i in range(n):
	if dic.has_key(arr[i]):
		dic[arr[i]] += 1
	else :
		dic[arr[i]] = 1

ans = [k for k, v in dic.items() if v > 1] 

ans = ans[-2:]

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
input_list = sorted([int(i) for i in input().split()])
inupt_dict = Counter(input_list)
sorted_input_dict = sorted(dict(filter(lambda x:x[1]>1, inupt_dict.items())).items(), key=lambda x: x[0], reverse=True)
result = 1
edge_list = []

if edge_list == []:
    result = 0
else:
    result *= sorted_input_dict[0][0]
    if sorted_input_dict[0][1] > 3:
        result *= sorted_input_dict[0][0]
    else:
        result *= sorted_input_dict[1][0]

print(result)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
input_list = sorted([int(i) for i in input().split()])
inupt_dict = Counter(input_list)
result = 1
edge_list = []

for key, value in inupt_dict.items():
    if value > 1:
        edge_list.append(key)

if edge_list == []:
    result = 0
elif len(edge_list) == 1:
    result = edge_list[0] ** 2
else:
    result *= max(edge_list)
    edge_list.remove(max(edge_list))
    result *= max(edge_list)

print(result)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
input_list = sorted([int(i) for i in input().split()])
inupt_dict = Counter(input_list)
result = 1
edge_list = []

for key, value in inupt_dict.items():
    if value > 1:
        edge_list.append(key)

if edge_list == []:
    result = 0
else:
    result *= max(edge_list)
    edge_list.remove(max(edge_list))
    result *= max(edge_list)

print(result)

Submission status: Wrong Answer

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

# A.sort()
# print(B)

A = list(map(int, input().split()))
A.sort()
A.reverse()
# print(A)

tapu = 0
tapi = 0

i = 0
while i + 1 < N:
    if A[i] is A[i + 1]:
        if tapu == 0:
            tapu = A[i]
            i += 1
        elif tapi == 0:
            tapi = A[i]
            i += 1
        # else:
            # break
    i += 1

ans = tapu * tapi
print(ans)

Submission status: Wrong Answer

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

# A.sort()
# print(B)

A = list(map(int, input().split()))
A.sort()
A.reverse()
# print(A)

tapu = 0
tapi = 0

i = 0
while i + 1 < N:
    if A[i] is A[i + 1]:
        if tapu == 0:
            tapu = A[i]
            i += 1
        elif tapi == 0:
            tapi = A[i]
            i += 1
        else:
            break
    i += 1

ans = tapu * tapi
print(ans)

Submission status: Wrong Answer

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

A.sort(reverse = True)

T = []
for i in range(N-1):
    if i > 0:
        if A[i] == A[i-1]: continue
    if A[i] == A[i+1]:
        T.append(A[i])
    if len(T) >= 2: break

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

Submission status: Wrong Answer

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

S = set(A)

T=[0,0]
for i in S:
    if A.count(i) >= 2:
        T.append(i)
    
T.sort(reverse = True)

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

Submission status: Wrong Answer

Solution code:
def m():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    edge = []
    tmp = 0
    for i in range(N):
        if A[i] == tmp:
            edge.append(tmp)
        else:
            tmp = A[i]
    if len(edge) < 2:
        return 0
    else:
        return edge[-1] * edge[-2]

print(m())

Submission status: Wrong Answer

Solution code:
from collections import Counter as c
 
N = int(input())
A = c(map(int, input().split()))
B = [0,0]

  
for i in A.keys():
    if A[i] >= 2:
        B.append(i)
    elif A[i] >= 4:
        B.append(i)
B.sort()
print(B[-1]*B[-2])

Submission status: Wrong Answer

Solution code:
from collections import Counter as c

N = int(input())
A = c(map(int, input().split()))
B = []
for i in range(2):
  B.append(0)
  
for i in A.keys():
    if A[i] >= 2:
        B.append(i)
    elif A[i] >= 4:
        B.append(i)
B.sort()
print(B[-1]*B[-2])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split(' ')))
rod = {}
for i in A:
    if i in rod:
        rod[i] += 1
    else:
        rod[i] = 1
if len([i for i in rod.values() if i >= 2]) < 2:
    print(0)
else:
    length = [k for k, v in rod.items() if v >= 2]
    length.sort()
    print(length[-2] * length[-1])

Submission status: Wrong Answer

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

C = list(dict(Counter(A)).items())
C.sort(reverse=True)
use = []
ans = 0
for length, num in C:
    if num >= 4:
        ans = max(length**2, ans)
    elif num >= 2:
        use.append(length)

    if len(use) >= 2:
        ans = max(ans, use[-1]*use[-2])

print(ans)

Submission status: Wrong Answer

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

C = list(dict(Counter(A)).items())
C.sort(reverse=True)
use = []
for length, num in C:
    if num >= 4:
        print(length*length)
        exit()
    elif num >= 2:
        use.append(length)

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

Submission status: Wrong Answer

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

C = list(dict(Counter(A)).items())
C.sort(reverse=True)
use = []
for length, num in C:
    if num >= 4:
        print(2*length)
        exit()
    elif num >= 2:
        use.append(length)

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
src = list(map(int,input().split()))
ctr = Counter(src)
a = b = 0
for k,v in sorted(ctr.items(),reverse=True):
    if v == 1: continue
    if not a:
        a = k
        if v >= 4:
            print(a*a)
    elif not b:
        b = k
        print(a*b)
        exit()
print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = sorted(Counter(A).most_common(),reverse=True)
D = []
F = []
for i in range(len(C)):
    x,y = C[i][0],C[i][1]
    if y >= 2:
        D.append(x)
    if y >= 4:
        F.append(x)
E = sorted(D,reverse=True)
G = sorted(F,reverse=True)
if len(E)>=2:
    if len(G)>0:
        if G[0]==E[0]:
            print(G[0]*G[0])
    else:
        print(E[0]*E[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = sorted(Counter(A).most_common(),reverse=True)
D = []
for i in range(len(C)):
    x,y = C[i][0],C[i][1]
    if y >= 2:
        D.append(x)
E = sorted(D,reverse=True)
if len(E)>=2:
    print(E[0]*E[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
src = list(map(int,input().split()))
ctr = Counter(src)
a = b = 0
for k,v in sorted(ctr.items(),reverse=True):
    if v == 1: continue
    if not a:
        a = k
    elif not b:
        b = k
        print(a*b)
        exit()
print(0)

Submission status: Wrong Answer

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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    from collections import Counter

    n = int(input())
    a = Counter(list(map(int, input().split())))
    sorted_a = sorted(a.items(), key=lambda x: (x[0], x[1]), reverse=True)
    candidates = [key for key, value in sorted_a if value >= 2]

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

Submission status: Wrong Answer

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

a.sort(reverse=True)
for i in a:
    a_dic[i] = a_dic.get(i, 0) + 1

h = [0, 0]
for i in range(2):
    for j, k in a_dic.items():
        if k >= 2:
            h[i] = j
            a_dic[j] -= 2
            break

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