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:
def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    area = 0
    u_len = []

    sort_a = sorted(set(a), reverse=True)
    for num in sort_a:
        #print(num)
        c_num = a.count(num)
        if(c_num >= 4):
            area = num**2
            break
        elif(c_num >= 2):
            u_len.append(num)
            if(len(u_len) >= 2):
                area = u_len[0] * u_len[1]
                break
    
    print(area)
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

def search(A):
  B = list(set(A))
  B.sort(reverse=True)
  if len(A)-len(B) < 2: return (0,0)

  a1,a2 = 0,0
  An = np.array(A)
  for n,a in enumerate(B):
    if len(An[An==a])>2:
      a1 = a
      del(A[n:n+2])
      break

  B = list(set(A))
  B.sort(reverse=True)
  if len(A)-len(B) == 0: return (a1,0)

  An = np.array(A)
  for n,a in enumerate(B):
    if len(An[An==a])>2:
      a2 = a
      del(A[n:n+2])
      break
  return (a1,a2)

N = int(input())
A = map(int, input().split())
A = [a for a in A]
A.sort(reverse=True)
a1, a2 = search(A)
if a1 > 0 and a2 > 0: print(a1*a2)
else: print(0)

Submission status: Wrong Answer

Solution code:
import copy 
import numpy as np

def search(A):
  B = list(set(A))
  B.sort(reverse=True)

  if len(A)-len(B) < 2: return (0,0)
  else:
    a1,a2 = 0,0

    An = np.array(A)
    for a in B:
      if len(An[An==a])>2:
        a1 = a
        A.pop(A.index(a))
        A.pop(A.index(a))
        break

    if a1 > 0:
      B = list(set(A))
      B.sort(reverse=True)
      An = np.array(A)
      if len(A)-len(B) == 0: return (a1,0)
      for a in B:
        if len(An[An==a])>2:
          a2 = a
          A.pop(A.index(a))
          A.pop(A.index(a))
          break
  return (a1,a2)

N = int(input())
A = map(int, input().split())
A = [a for a in A]
A.sort(reverse=True)
a1, a2 = search(A)
if a1 > 0 and a2 > 0: print(a1*a2)
else: print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = set(A)
C = list(B)
C.sort(reverse=True)
d = []
e = 0
for i in C:
  if e == 0:
    if A.count(i) >= 4:
      print(i**2)
      break
  elif e == 0 or e == 1:
    if A.count(i) >= 2:
      d.append(i)
      e += 1
      if e == 2:
        break
if len(d):
  print(d[0]*d[1])
else:
  print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
w = 0
h = 0
arr = []
flg = True
arr.append(list(map(int,(input().split()))))
arr = Counter(arr[0])
arr = arr.most_common()
for i in range(len(arr)):
    count = arr[len(arr) - i - 1][1]
    num = arr[len(arr) - i - 1][0]
    if 4 <= count:
        print(num ** 2)
        flg = False
        break
    elif w == 0:
        if 2 <= count:
            w = num
    else:
        if 2 <= count:
            h = num
            print(w * h)
            flg = False
            break
if flg:
    print("0")

Submission status: Wrong Answer

Solution code:
n = input()

a = map(int, raw_input().split())
a.sort(reverse = True)
a.append(0)
tmp = [0]
ct = 0

key = a.pop(0)
for i in range(len(a) - 1):
    if a[i] == a[i + 1]:
        tmp.append(a[i])
        i += 2
        if len(tmp) == 3:
            break

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

Submission status: Wrong Answer

Solution code:
n = input()

a = map(int, raw_input().split())
a.sort(reverse = True)
a.append(0)
tmp = [0]
ct = 0

key = a.pop(0)
for i in range(len(a) - 1):
    if a[i] == a[i + 1]:
        tmp.append(a[i])
        i += 2
        if len(tmp) == 3:
            break

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

Submission status: Wrong Answer

Solution code:
import logging

logging.basicConfig(level=logging.WARNING, format=' %(asctime)s - %(levelname)s - %(message)s')
input()
edge = []
edge = input().split()
e = []
for i in range(len(edge)):
    e.append(int(edge[i]))
    logging.info('e[{}] = {}'.format(i, e[i]))
e.sort()
E = [0, 0]
j = 0
for i in range(len(e) - 1, 0, -1):
    if e[i] == e[i - 1] and not e[i] == E[0]:
        E[j] = e[i]
        logging.info('E[{}] = {}'.format(j, E[j]))
        j += 1
        if E[1]:
            break
print(E[0] * E[1])

Submission status: Wrong Answer

Solution code:
import logging
logging.basicConfig(level=logging.WARNING,format=' %(asctime)s - %(levelname)s - %(message)s')
input()
edge=[]
edge=input().split()
e=[]
for i in range(len(edge)):
    e.append(int(edge[i]))
    logging.info('e[{}] = {}'.format(i,e[i]))
e.sort()
E=[0,0]
j=0
for i in range(len(e)-1,0,-1):
    if e[i]==e[i-1] and not e[i]==E[0]:
        E[j]=e[i]
        logging.info('E[{}] = {}'.format(j,E[j]))
        j+=1
        if E[1]:
            break
print(E[0]*E[1])

Submission status: Wrong Answer

Solution code:

n = int(input().strip())

li = list(map(int,input().strip().split()))

d = {}
res = set()
for i in li:
    d[i] = d.get(i,0)+1
    if(d[i] >= 2):
        res.add(i)

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

Submission status: Wrong Answer

Solution code:
n = input()

a = map(int, raw_input().split())
a.sort(reverse = True)
tmp = [0]
ct = 0

key = a.pop(0)
while len(a) != 1:
    nxt = a.pop(0)
    if key == nxt:
        tmp.append(key)
	ct += 1
        if ct == 2:
            print tmp[1] * tmp[2]
            break
    key = a.pop(0)

if len(tmp) < 2:
    print 0

Submission status: Wrong Answer

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

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

i = 0
check = 0
x = 0
y = 0

while(i<N and check == 0):
    count = A.count(A[i])
    if(count>=4):
        x = A[i]
        y = A[i]
        check = 1
    elif(count>=2):
        if(x == 0):
            x = A[i]
            i = i + count
        else:
            y = A[i]
            check = 1
    else:
        i = i + count

if(check == 0):
    print(check)
else:
    print(x*y)

Submission status: Wrong Answer

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

A=sorted(A,reverse=True)
if(len(A)%2==1):
    A.append(0)
c=0
l=1
t=0
for i in range(0,len(A)-1,2):
    if(c==2):
        break
    elif(A[i]==A[i+1] or t==A[i]):
        c+=1
        l*=A[i]
    t=A[i+1]
if(c==2):
    print(l)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = input().split()
dic = {}
for i in l:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1
l1 = []
l2 = []
len1 = 0
len2 = 0
for i in dic:
    if dic[i] > 1:
        len1 += 1
        l1.append(i)
    if dic[i] % 4 == 0:
        len2 += 1
        l2.append(i)
max1 = 0

l1.sort(reverse=True)
l2.sort(reverse=True)
if len1 > 1:
    max1 = int(l1[0]) * int(l1[1])
if len2 and max1<int(l2[0]) * int(l2[0]):
    max1 = int(l2[0]) * int(l2[0])
if max1:
    print(max1)
else:
    print("0")

Submission status: Wrong Answer

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

for element in a:
    if element in list: pass
    elif a.count(element)>=2:list.append(element)

list.sort()
list.reverse()

num=len(list)
if num==0: ans=0
elif num==1: ans=list[0]**2
else: ans=list[0]*list[1]

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
hen1 = 0
hen2 = 0
hen_list = {}
for i in a:
    if(not i in hen_list):
        hen_list[i] = 0
    hen_list[i] += 1
for k, v in sorted(hen_list.items(), key=lambda x: -x[0]):
    if(v >= 2 and hen1 == 0):
        hen1 = k
    elif(v >= 2 and hen2 == 0):
        hen2 = k
    if(hen2!=0):
        break

print(hen1*hen2)

Submission status: Wrong Answer

Solution code:
n = int(input())
d= [ int(x) for x in input().strip().split(' ')]

two = []
for i in sorted(d)[::-1]:
    if len(two) == 6:
        for ii in two:
            if two.count(ii) == 4:
                
                print(ii**2)
                break
            if two.count(ii) ==3:
                print(two[2] * two[3])
                break
            if two.count(ii) ==2:
                print(two[0] * two[2])
                break
        break

    a = d.count(i)
    if a > 1:
        two.append(i)

print(0)

Submission status: Wrong Answer

Solution code:
import itertools

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

num = dict()

for a in A:
    if a not in num:
        num[a] = 0
    num[a] += 1

m1 = 0
m2 = 0
for a in sorted(num.keys(), reverse=True):
    if num[a] > 2:
        m1 = a
        num[a] = num[a] - 2
        break
for a in sorted(num.keys(), reverse=True):
    if num[a] > 2:
        m2 = a
        num[a] = num[a] - 2
        break
print(m1*m2)

Submission status: Wrong Answer

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

for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]= 1

keys = sorted(d)
l= sorted(keys,reverse=True)
cnt =0
lenght=[]
found = False
for i in l:
    if d[i]>=2 and cnt <2:
        lenght.append(i)
        cnt+=1
        found=True

if cnt==2:
    print(lenght[0]*lenght[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def C_Make_a_Rectangle(lst):
    N = lst[0]
    A = lst[1:]

    if N < 4:
        return 0

    t = set()
    result = list(set([x for x in A if x in t or t.add(x)]))  # 重複する要素の値を抽出

    if len(result) < 2:
        return 0  # 長方形を作りようがない
    else:
        result = sorted(result, reverse=True)
        return result[0] * result[1]

n = int(input())
l = [int(i) for i in input().split()]
x = [n] + l
print(C_Make_a_Rectangle(x))

Submission status: Wrong Answer

Solution code:
num=raw_input()
tmp=map(int, raw_input().split(" "))
tmp.sort()
tmp.reverse()
oldnum=0
arr=[]
flag=0
for i in range(len(tmp)-1):
    if tmp[i]==tmp[i+1] and flag==0:
            arr.append(tmp[i])
            flag=1
    else:
        flag=0
    if len(arr)==2:
        print arr[0]*arr[1]
        break
    try:
        if tmp[i]==tmp[i+1] and tmp[i]==tmp[i+2] and tmp[i]==tmp[i+3]:
            print tmp[i]**2
            break
    except:
        pass

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    mx = 0
    cnt = 0
    d = [0, 0]
    while cnt < 2:
        try:
            mx = max(A)
        except ValueError:
            break
        if A.count(mx) >= 2:
            d[cnt] = mx
            cnt += 1
        while mx in A:
            A.remove(mx)
    print(d[0] * d[1])

Submission status: Wrong Answer

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

for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]= 1

keys = sorted(d)
l= sorted(keys,reverse=True)
cnt =0
lenght=[]
found = False
for i in l:
    if d[i]>=2 and cnt <2:
        lenght.append(i)
        cnt+=1
        found=True

if cnt!=0:
    print(lenght[0]*lenght[1])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
b = []
for key,val in Counter(a).items():
    if val >= 2:
        b.append(key)
        if val >= 4:
            b.append(key)

if len(b)>=2:
    x = b.pop()
    y = b.pop()
    ans = x*y
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
n = input()

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

a.sort()
a.reverse()
f = 1
tmp = [0]
ct = 0

key = a.pop(0)
while len(a) != 1:
    nxt = a.pop(0)
    if key == nxt:
        tmp.append(key)
	ct += 1
        if ct == 2:
            break
    key = a.pop(0)

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

Submission status: Wrong Answer

Solution code:
num=raw_input()
tmp=map(int, raw_input().split(" "))
tmp.sort()
tmp.reverse()
oldnum=0
arr=[]
for i in range(len(tmp)-1):
    if tmp[i]==tmp[i+1]:
            arr.append(tmp[i])
    if len(arr)==2:
        print arr[0]*arr[1]
        break
    try:
        if tmp[i]==tmp[i+1] and tmp[i]==tmp[i+2] and tmp[i]==tmp[i+3]:
            print tmp[i]**2
            break
    except:
        pass

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    area = 0
    u_len = []

    sort_a = sorted(set(a), reverse=True)
    #print(sort_a)
    for num in sort_a:
        c_num = a.count(num)
        if(c_num >= 4):
            area = num**2
            break
        elif(c_num >= 2):
            u_len.append(num)
            if(len(u_len) >= 2):
                area = u_len[0] * u_len[1]
                break
    
    print(area)
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

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

i = 0
check = 0
x = 0
y = 0

while(i<N and check == 0):
    count = A.count(A[i])
    if(count>=4):
        x = A[i]
        y = A[i]
        check = 1
    elif(count>=2):
        if(x == 0):
            x = A[i]
            i = i + count
        else:
            y = A[i]
            check = 1
    else:
        i = i + count

if(check == 0):
    print("0")
else:
    print(x*y)

Submission status: Wrong Answer

Solution code:
num=raw_input()
tmp=map(int, raw_input().split(" "))
tmp.sort()
tmp.reverse()
oldnum=0
arr=[]
for i in range(len(tmp)-1):
    try:
        if tmp[i]==tmp[i+1] and tmp[i]==tmp[i+2] and tmp[i]==tmp[i+3]:
            print tmp[i]**2
            break
    except:
        pass

    if tmp[i]==tmp[i+1]:
            arr.append(tmp[i])
    if len(arr)==2:
        print arr[0]*arr[1]
        break

Submission status: Wrong Answer

Solution code:
def C_Make_a_Rectangle(lst):
    N = lst[0]
    A = lst[1:]

    t = set()
    result = list(set([x for x in A if x in t or t.add(x)]))  # 重複する要素の値を抽出
    if len(result) < 2:
        return 0  # 長方形を作りようがない
    else:
        result = sorted(result, reverse=True)
        return result[0] * result[1]

n = int(input())
l = [int(i) for i in input().split()]
x = [n] + l
print(C_Make_a_Rectangle(x))

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
r = list()
r = map(int,raw_input().split())

from collections import Counter
counter = Counter(r)
c = counter.items()
c.reverse()
memo = list()
l = len(c)
for i,x in enumerate(c):
  if x[1] >= 4:
    memo.append(i)
    if len(memo) == 1:
      print x[0] * x[0]
      break
    if len(memo) == 2:
      print c[memo[0]][0] * x[0]
      break
  if 2 <= x[1] < 4:
    memo.append(i)
    if len(memo) == 2:
      print c[memo[0]][0] * x[0]
      break
  if l == i:
    if len(memo) <2:
      print 0

Submission status: Wrong Answer

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

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

if len(bar) <= 1:
    print(0)
else:
    print(bar[0] * bar[1])

Submission status: Wrong Answer

Solution code:
N = input()
A = input().split()
A.sort()
A.reverse()
li = []

for a in A:
    if A.count(a) > 1:
        li.append(a)
        A.remove(a)
        A.remove(a)
    if len(li) == 2:
        break


if len(li) > 1:
    print( int(li[0]) * int(li[1]) )
else:
    print("0")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
bn = 0
ans = 0
count = 0
i = 0

while(i<n):
    print(a[i],i,ans)
    if bn==a[i]:
        if count == 0:
            ans = a[i]
            if i+1<n:
                bn = a[i+1]
            i += 1
            count +=1
        else:
            ans *= a[i]
            count +=1
            break
    else:
        bn = a[i]
    i +=1

if count>=2:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

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

a = sorted(A, reverse=True)
b = []

i = 0
while i<N-2:
    if ( a[i]==a[i+1] ):
        b+=[a[i]]
        i+=2
    else:
        i+=1
    if (len(b)>=2):
        break

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

Submission status: Wrong Answer

Solution code:
n = input()

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

a.sort()
a.reverse()
f = 1
tmp = [0]
ct = 0

while len(a) != 0:
    nxt = a.pop(0)
    key = a.pop(0)
    if key == nxt:
        tmp.append(key)
	ct += 1
        if ct == 2:
            break

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

Submission status: Wrong Answer

Solution code:
n = input()

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

a.sort()
a.reverse()
f = 1
tmp = [0]
ct = 0

while len(a) != 0:
    nxt = a.pop(0)
    key = a.pop(0)
    if key == nxt:
        tmp.append(key)
	ct += 1
        if ct == 2:
            break
    key = nxt

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    a = sorted(A, reverse=True)
    b = {}
    for i in range(N - 1):
        if a[i] == a[i+1]:
            if a[i] in b.keys():
                b[a[i]] += 1
            else:
                b[a[i]] = 2
    if len(b) < 2:
        ans = 0
    elif b[max(b)] >= 4:
        ans = max(b) * 2
    else:
        c = sorted(b, reverse=True)
        ans = c[0] * c[1]

    print(ans)

main()

Submission status: Wrong Answer

Solution code:
n = input()

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

a.sort()
a.reverse()
f = 1
tmp = [0]
ct = 0

while len(a) != 0:
    if ct == 2:
        break
    nxt = a.pop(0)
    key = a.pop(0)
    if key == nxt:
        tmp.append(key)
	ct += 1
    key = nxt

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    mx = 0
    cnt = 0
    d = [0, 0]
    while cnt < 2:
        try:
            mx = max(A)
        except ValueError:
            break
        if A.count(mx) >= 2:
            d[cnt] = mx
            cnt += 1
        A.remove(mx)
    print(d[0] * d[1])

Submission status: Wrong Answer

Solution code:
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n  = read_line(int)

as_ = [int(col) for col in input().split()]

max_a = -1
max_aa = -1

count = {}

for a in as_:
    if a not in count:
        count[a] = 1
    else:
        count[a] += 1

        if a == max_a:
            pass
        elif a > max_a:
            max_aa = max_a
            max_a = a
        elif a > max_aa:
            max_aa = a
    # print(count, max_a, max_aa)

if max_a > 0 and count[max_a] >= 4:
    exit()

if max_a > 0 and max_aa > 0:
    print(max_a * max_aa)
    exit()

print(0)

Submission status: Wrong Answer

Solution code:
n = input()

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

a.sort()
a.reverse()
tmp = [0]
ct = 0

while len(a) != 0:
    if ct == 2:
	print tmp[1] * tmp[2]
        break
    key = a.pop(0)
    nxt = a.pop(0)
    if key == nxt:
        tmp.append(key)
	ct += 1

if len(tmp) < 2:
    print 0

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, input().split())
A1 = [a for a in A]
A2 = list(set(A1))
A2.reverse()
if len(A1) == len(A2): print(0)
else:
  for n, a in enumerate(A2):
    if a in A1: a1 = A1.pop(A1.index(a))
    if a in A1:
      a1 = A1.pop(A1.index(a))
      A2.pop(n)
      break
    else: a1 = 0
  
  if a1 > 0:
    for n, a in enumerate(A2):
      if a in A1: a2 = A1.pop(A1.index(a))
      if a in A1:
        a2 = A1.pop(A1.index(a))
        break
      else: a2 = 0
  
  if a1 > 0 and a2 > 0: print(a1*a2)
  else: print(0)

Submission status: Wrong Answer

Solution code:
N = input()
A = input().split()
A.sort()
A.reverse()
li = []

for a in A:
    if A.count(a) > 1:
        li.append(a)
        A.remove(a)
        A.remove(a)
    else:
        A.remove(a)
    if len(li) == 2:
        break


if len(li) > 1:
    print( int(li[0]) * int(li[1]) )
else:
    print("0")

Submission status: Wrong Answer

Solution code:
tmp=map(int, raw_input().split(" "))
arr=[]
arr_v=[]
for i in set(tmp):
    if tmp.count(i) > 1:
        arr.append(i)
    if tmp.count(i) > 3:
        arr_v.append(i)

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

Submission status: Wrong Answer

Solution code:
n = input()

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

a.sort()
a.reverse()
f = 1
tmp = [0]
ct = 0

while len(a) != 0:
    if ct == 2:
        break
    key = a.pop(0)
    nxt = a.pop(0)
    if key == nxt:
        tmp.append(key)
	ct += 1

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

Submission status: Wrong Answer

Solution code:
n = input()

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

a.sort()
a.reverse()
f = 1
tmp = [0]

while len(a) != 0:
    key = a.pop(0)
    nxt = a.pop(0)
    if key == nxt:
        tmp.append(key)


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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
cou = 0
que = []
hen = []
i = 0
A.sort()
A.reverse()

while cou < 2:
    num = A[i]
    ans = num in que
    if ans == False:
        if A.count(num) > 1:
            hen.append(num)
            cou += 1
            que.append(num)
    if i == len(A) - 1 and len(hen) < 2:
        print("None")
        break
    i += 1

if len(hen) == 2:
    target = hen[0] * hen[1]
    print(target)

Submission status: Wrong Answer

Solution code:
_ = raw_input()
a = map(int, raw_input().strip().split())
a.sort()
a = a[::-1]
l = 0
b = 0
for x in xrange(len(a)-1):
	if a[x]== a[x+1] and a[x] != l or b:
		if l==0:
			l = a[x]
		else:
			b = a[x]
			print(l*b)
			exit()
print(l*b)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    num = 0
    cnt = 0
    d = [0, 0]
    while cnt < 2:
        try:
            if A.count(A[num]) >= 2:
                d[cnt] = A[num]
                cnt += 1
            num += A.count(A[num])
        except IndexError:
            break
    print(d[0] * d[1])

Submission status: Wrong Answer

Solution code:
#from time import time

#t = time()
n = int(input())
d= [ int(x) for x in input().strip().split(' ')]
#print(d)

occ = []
for i in range(n):
    if d[i] in d[i:] or d[i] in d[:i]:
        occ.append(d[i])
two = []
for i in sorted(occ)[::-1]:
    if len(two) == 2:
        print(two[0]*two[1])
        break
    a = occ.count(i)
    if a > 3:
        print(i**2)
        break
    elif a >1:
        if i not in two:
            two.append(i)
print(0)

Submission status: Wrong Answer

Solution code:
N = input()
A = sorted([int(i) for i in input().split(' ')])
can = []
for i in range(0, len(A), 2):
    if A[i] == A[i + 1]:
        can.append(A[i])

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(input().split())
a.sort(reverse=True)
ans = 0
t = 0
c = 1

for i in range(len(a)-1):
    if a[i] == a[i+1]:
        c = c + 1
        if t == 0:
            t = int(a[i])
        elif t != int(a[i]):
            ans = t * int(a[i])
            break
        elif c == 4:
            ans = t * t
            break
    else:
        c = 1

print(ans)

Submission status: Wrong Answer

Solution code:
# coding=utf-8

def count(list, target):
    l = len(list)
    c = 0
    for i in xrange(1, l + 1):
        if list[-i] == target:
            c += 1
            if c == 4:
                return c
        elif list[-i] < target:
            return c

N = int(raw_input())
A = map(int, raw_input().split())

candidates = []
A.sort()
for i in xrange(1, len(A) + 1):
    if count(A, A[-i]) > 1:
        candidates.append(A[-i])
        if len(candidates) == 4:
            break
if len(candidates) < 4:
    print 0
else:
    print candidates[1] * candidates[3]

Submission status: Wrong Answer

Solution code:
tmp=map(int, raw_input().split(" "))
arr=[]
for i in set(tmp):
    if tmp.count(i) > 1:
        arr.append(i)

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

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
sa = list(set(a))
b = [ i for i in sa if a.count(i)>=2 ]
c = [ i for i in sa if a.count(i)>=4 ]
b=b+c
b.sort(reverse=True)

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

Submission status: Wrong Answer

Solution code:
# coding=utf-8

def count(list, target):
    l = len(list)
    c = 0
    for i in xrange(1, l + 1):
        if list[-i] == target:
            c += 1
            if c == 4:
                return c
        elif list[-i] < target:
            return c

N = int(raw_input())
A = map(int, raw_input().split())

candidates = []
A.sort()
for i in xrange(1, len(A) + 1):
    if count(A, A[-i]) > 1:
        candidates.append(A[-i])
        if len(candidates) == 4:
            break
print candidates
if len(candidates) < 4:
    print 0
else:
    print candidates[1] * candidates[3]

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
d = {}
a = 0
b = 0

for i in range(N):
    if A[i] not in d:
        d[A[i]] = 1
    else:
        d[A[i]] += 1
    if d[A[i]] == 2:
        if A[i] > a:
            b = a
            a = A[i]
        elif A[i] > b:
            b = A[i]

print(a * b)

Submission status: Wrong Answer

Solution code:
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n  = read_line(int)

as_ = [int(col) for col in input().split()]


max_a = -1
max_aa = -1

count = {}

for a in as_:
    if a not in count:
        count[a] = 1
    else:
        count[a] += 1

        if a > max_a:
            max_aa = max_a
            max_a = a
        elif a > max_aa:
            max_aa = a
    # print(count, max_a, max_aa)

if max_a > 0 and count[max_a] >= 4:
    print(max_a * max_a)
    exit()

if max_a > 0 and max_aa > 0:
    print(max_a * max_aa)
    exit()

print(0)

Submission status: Wrong Answer

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

b=sorted(d,reverse=True)


ans1=ans2=0

for i in b:
    x= a.count(i)
    if x >= 4:
        print(x*x)
        exit()
        
    elif x>=2 and x<4 and ans1==0:
        ans1=i
    elif x>=2 and ans1>0:
        ans2=i

    if ans1>0 and ans2>0:
        print(ans1*ans2)
        exit()

print(0)

Submission status: Wrong Answer

Solution code:
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

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

a.sort()

x = 0
y = 0

for i in range(n):
    if a.count(a[-1-i]) >= 4:
        x = a[-1-i]
        y = a[-1-i]
        break
    elif a.count(a[-1-i]) >= 2:
        if x == 0:
            x = a[-1-i]
        elif not x == a[-1-i]:
            y = a[-1-i]
            break

ans = x*y

print ans

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(input().split())
a.sort(reverse=True)
ans = 0
t = 0
c = 0

for i in range(len(a)-1):
    if a[i] == a[i+1]:
        c = c + 1
        if t == 0:
            t = int(a[i])
        elif t != int(a[i]):
            ans = t * int(a[i])
            break
        elif c == 4:
            ans = t * t
            break
    else:
        c = 0

print(ans)

Submission status: Wrong Answer

Solution code:
# coding=utf-8

def count(list , target):
    l = len(list)
    c = 0
    for i in xrange(1, l + 1):
        if list[-i] == target:
            c += 1
            if c == 4:
                return c
        else:
            return c

N = int(raw_input())
A = map(int, raw_input().split())

candidates = []
A.sort()
for i in xrange(1, len(A) + 1):
    if count(A, A[-i]) > 1:
        candidates.append(A[-i])
        if len(candidates) == 4:
            break
if len(candidates) < 4:
    print 0
else:
    print candidates[1] * candidates[3]

Submission status: Wrong Answer

Solution code:
#!/bin/python3

import sys


n = int(input().strip())
ar = list(map(int, input().strip().split(' ')))
ar = sorted(ar,reverse=True)
k = []
se = set(k)
for i in range(len(ar)-1):
    if(ar[i] == ar[i+1]):
        if(ar.count(ar[i])>=4):
            print(ar[i]*ar[i])
            exit(0)
        se.add(ar[i])
    if(len(se)>1):
        break

se = list(se)
if(len(se)<2):
    print("0")
else:
    print(se[0]*se[1])

Submission status: Wrong Answer

Solution code:
N = input()
A = sorted([int(i) for i in input().split(' ')])
can = []
for i in range(len(A) - 2):
    if A[i] == A[i + 1]:
        can.append(A[i])
if len(can) <= 1:
    print(0)
else:
    print(can[len(can) - 1] * can[len(can) - 2])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
longer = 0
shorter = 0

for i in a:
    if longer != 0 and shorter != 0:
        break
    if a.count(i) >= 2:
        if longer == 0:
            longer = i
        elif longer != i :
            shorter = i
        
print(longer*shorter)

Submission status: Wrong Answer

Solution code:
#!/bin/python3

import sys


n = int(input().strip())
ar = list(map(int, input().strip().split(' ')))
ar = sorted(ar,reverse=True)
k = []
se = set(k)
for i in range(len(ar)-1):
    if(ar[i] == ar[i+1]):
        se.add(ar[i])
    if(len(se)>1):
        break

se = list(se)
if(len(se)<2):
    print("0")
else:
    print(se[0]*se[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(input().split())
a.sort(reverse=True)
ans = 0
t = 0

for i in range(len(a)-1):
    if a[i] == a[i+1]:
        if t == 0:
            t = int(a[i])
        elif t != int(a[i]):
            ans = t * int(a[i])
            break

print(ans)

Submission status: Wrong Answer

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

used=set()
used2=set()
for a in A:
    if a in used:
        used2.add(a)
    else:
        used.add(a)
if len(used2)<2:
    print 0
else:
    B=sorted(used2,reverse=True)
    print B[0]*B[1]

Submission status: Wrong Answer

Solution code:
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

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

a.sort()

x = 0
y = 0

for i in range(n):
    if a.count(a[-1-i]) >= 2:
        if x == 0:
            x = a[-1-i]
        elif not x == a[-1-i]:
            y = a[-1-i]
            break

ans = x*y

print ans

Submission status: Wrong Answer

Solution code:
import sys

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

c = None
for a in A:
    if A.count(a) >= 4:
        print(a*a)
        sys.exit()
    elif A.count(a) >= 2:
        if c is not None:
            print(c * a)
            sys.exit()
        c = a
        A.remove(a)
        A.remove(a)
print(0)