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: Runtime Error

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 G[0]==E[0]:
        print(G[0]*G[0])
    else:
        print(E[0]*E[1])
else:
    print(0)

Submission status: Runtime Error

Solution code:
def test():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    a.reverse()
    s=list(set(a))
    s.sort()
    s.reverse()
    ans=[]
    v=0
    for i in s:
        if 4<=a.count(i):
            return i*i
        elif 2<=a.count(i)<=3:
            ans.append(i)
            return ans[0]*ans[1]
    return 0
t=test()
print(t)

Submission status: Runtime Error

Solution code:
def test():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    a.reverse()
    s=list(set(a))
    s.sort()
    s.reverse()
    ans=[]
    v=0
    for i in s:
        if 4<=a.count(i):
            v="i"
        elif 2<=a.count(i)<=3:
            ans.append(i)
        if v or 2<=len(ans):
            return max(int(v)*int(v),ans[0]*ans[1])
    return 0
t=test()
print(t)

Submission status: Runtime Error

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

A.sort(reverse = True)
U = []
for i in range(N-1):
  if A[i] == A[i+1]:
    U.append(A[i])
    A[i] = -1
    A[i+1] = -1
  if len(U) >= 2:
    break
print(U[0] * U[1])

Submission status: Runtime Error

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

ai.sort()
l = list(set(ai)).reverse

m1 = 0
m2 = 0
for x in l:
    if(ai.count(x) >= 4):
        if m1 > 0:
            m2 = x
        else:
            m1 = m2 = x
        break
    elif(2 <= ai.count(x) < 4):
        if m1:
            m2 = x
            break
        else:
            m1 = x

print(m1*m2)

Submission status: Runtime Error

Solution code:
import itertools

def findsq(a,b,c,d):
    if a == b and c == d:
        return a*c
    elif a == c and b == d:
        return a*b
    elif a == d and b == c:
        return a*b
    else: 
        return 0

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    ans = []
    for l in list(itertools.combinations(A,4)):
        x = findsq(l[0], l[1], l[2], l[3])
        if x != 0:
            ans.append(x)
    print(max(ans))

Submission status: Runtime Error

Solution code:
def findsq(a,b,c,d):
    if a == b and c == d:
        return 1
    elif a == c and b == d:
        return 1
    elif a == d and b == c:
        return 1
    else: 
        return 0

if __name__ == '__main__':
    N = int(input())
    A = map(int, input().split())
    ans = 0
    for i in range(N-3):
        for j in range(i, N-2):
            for k in range(j, N-1):
                for l in range(k, N):
                    if findsq(A[i], A[j], A[k], A[l]) == 1:
                        ans += 1
    print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse =True)
width = 0
height = 0
found = False
for i in A:
    if A.count(i) >= 4:
        width = i
        height = i
        count += 1
        break
    elif A.count(i) >= 2:
        if width == 0:
            width = i
        elif not i == width:
            height = i
            found = True
            break

if found:
    print(width * height)
else:
    print('0')

Submission status: Runtime Error

Solution code:
n = int(input())
num_l=sorted(map(int,input().split()),reverse=True)
s=sorted(set(num_l),reverse=True)
res=[]
for i in num_l:
    if len(res) == 2:
        print(res[0]*res[1])
        break
    if d[i] >= 2:
        d[i]-=2
        res.append(i)
    else:
        pass
else:print(0)

Submission status: Runtime Error

Solution code:
from collections import Counter
N=int(input())
a=list(map(int, input().split()))
h = w = 0
 
for i, cnt in Counter(a).items:
    if cnt >= 2 and i > w:
        if i > h:
            if cnt >= 4:
                h = i
                w = i
            else:
                w = h
                h = i
        else:
            w = i
            
print(w * h)

Submission status: Runtime Error

Solution code:
from collections import Counter
N=int(input())
c=[]
a=list(map(int, input().split()))
s=sorted(set(a), reverse=True)
 
for i, cnt in Counter(a).items:
    if cnt >= 2 and i > w:
        if i > h:
            if cnt >= 4:
                h = i
                w = i
            else:
                w = h
                h = i
        else:
            w = i
            
print(w * h)

Submission status: Runtime Error

Solution code:
def solve(): # 071C - Make a Rectangle
    n = int(input())
    sides = list(map(int, input().split(" ")))
    check_dual = {}
    possible_sides = []

    for i in sides:
        if i in check_dual:
            check_dual[i] += 1
        else:
            check_dual[i] = 1

    tmp_square = 0
    for k, v in check_dual.items():
        if v >= 4 and k > tmp_square:
            tmp_square = k
        elif v == 2 or v == 3:
            possible_sides.append(k)
        else:
            pass

    possible_sides.sort(reverse=True)
    if tmp_square == 0 and len(possible_sides) < 2:
        print(0)
    else:
        print(max(possible_sides[0] * possible_sides[1],
                  tmp_square ** 2))


solve()

Submission status: Runtime Error

Solution code:
#! /bin/python
# coding:utf-8

N = input()
A = map(int, raw_input().split())
s = set()
dep = []

for i in A:
	if i in s:
		dep.append(i)
	s.add(i)

dep.sort()
dep.reverse()

if (len(dep)  2):
	print "None"
else:
	print dep[0] * dep[1]

Submission status: Runtime Error

Solution code:
from collections import Counter

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

ans = []

for i, cnt in A_counter.items():
    if cnt >= 2:
        ans.append(i)
        if len(ans) == 2:
            print(ans[0] * ans[1])
            break
    
    if cnt >= 4:
        print(i**2)
        break
    
else:
    print(0)

Submission status: Runtime Error

Solution code:
from collections import Counter

N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
two = []
four = []

for i, cnt in Counter(A).items():
    if cnt >= 4:
        four.append(i)
    if 4 > cnt >= 2:
        two.append(i)
    if len(two) >= 2:
        break

if two:
    if four:
        print(max(two[0]*two[1], four[0]*four[0]))
    else:
        print(two[0]*two[1])
else:
    if four:
        print(four[0]* four[0])
    else:
        print(0)

Submission status: Runtime Error

Solution code:
from collections import Counter

N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
two = []
four = []

for i, cnt in Counter(A).items():
    if cnt >= 4:
        four.append(i)
    if 4 > cnt >= 2:
        two.append(i)
    if len(two) >= 2:
        break

if two:
    if four:
        print(max(two[0]*two[1], four[0]*four[0]))
    else:
        print(two[0]*two[1])
else:
    print(0)

Submission status: Runtime Error

Solution code:
from collections import Counter

N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
two = []
four = []

for i, cnt in Counter(A).items():
    if cnt >= 4:
        four.append(i)
    if cnt >= 2:
        two.append(i)
    if len(two) >= 2:
        break

print(max(two[0] * two[1], four[0] * four[0]))

Submission status: Runtime Error

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

N = int(input())
A = map(int,input().split())
A = set(A)
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 and x==0):
        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: Runtime Error

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


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

for i in range(len(B)):
    b = B[i]
    n = A.count(b)
    if n >= 2:
        if n >= 4:
            print(b*b)
            exit()
        elif:
            C = B[i+1:]
            for c in C:
                if  A.count(c) >= 2:
                    print(b*c)
                    exit()

print(0)

Submission status: Runtime Error

Solution code:
    N = int(input())
    A = list(map(int, input().split(' ')))
     
    B = []
    C = []
    D = []
     
    for a in A:
        if a in B:
            C[B.index(a)] += 1
        else:
            B.append(a)
            C.append(1)
     
    I = len(B)
     
    for i in range(I):
        D.append([B[i], C[i]])
     
    D = sorted(D, reverse=True)
     
    i = 0
    while i < I:
        x = D[i][0]
        d = D[i][1]
        if d > 1:
            if d > 3:
                print(x**2)
                exit()
            else:
                while i < I:
                    i += 1
                    y = D[i][0]
                    d = D[i][1]
                    if d > 1:
                        print(x*y)
                        exit()
        else:
            i += 1
     
    print(0)

Submission status: Runtime Error

Solution code:
N = input()
A = input().split()
A.sort()
A.reverse()
li = []
 
for i in range(N-1):
    if A[i] == A[i+1]:
        a = int(A[i])
        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: Runtime Error

Solution code:
N = input()
A = input().split()
A.sort()
A.reverse()
li = []
 
for i in range(N-1):
    if A[i] == A[i+1]:
        li.append(A[i])
        A.remove(A[i])
        A.remove(A[i])
    if len(li) == 2:
        break
 
 
if len(li) > 1:
    print( int(li[0]) * int(li[1]) )
else:
    print("0")

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter

# sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    a = read_int_list()
    a.sort()
    c = Counter(a)
    l = set()
    for i in a:
        if c[i] >= 2:
            l.add(i)
    l = list(l)
    l.sort()

    res = 0
    if len(l) >= 1:
        m = l[-1]
        if c[m] >= 4:
            res = m * m
        else:
            if len(l) >= 2:
                p = l[-2]
                res = m * p
    print(res)
import sys
from collections import Counter

# sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    a = read_int_list()
    a.sort()
    c = Counter(a)
    l = set()
    for i in a:
        if c[i] >= 2:
            l.add(i)
    l = list(l)
    l.sort()

    res = 0
    if len(l) >= 1:
        m = l[-1]
        if c[m] >= 4:
            res = m * m
        else:
            if len(l) >= 2:
                p = l[-2]
                res = m * p
    print(res)


main()


main()

Submission status: Runtime Error

Solution code:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
c_dict = Counter(A)
B = []
C = []

for k, v in c_dict.items():
    if v >= 4:
        B.append(k)
    elif v >= 2:
        C.append(k)
B.sort(reverse=True)
C.sort(reverse=True)
print(B[0])
print(C[0])

if len(B) < 1 and len(C) < 2:
    print(0)
elif len(B) < 1 and len(C) >= 2:
    print((C[0]*C[1]))
elif len(B) >= 1 and len(C) == 1:
    print(max(B[0] ** 2), (B[0] * C[0]))
elif len(B) >= 1 and len(C) >= 2:
    C = (B[0] ** 2)
    D = (B[0] * C[0])
    E = (C[0] * C[1])
    print(max(C, D, E))

Submission status: Runtime Error

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


B = list(set(A))

while B:
    b = max(B)
    if A.count(b) >= 4:
        print(b**2)
        exit()
    elif A.count(b) >=2:
        B.remove(b)
        while B:
            c = max(B)
            if  A.count(c) >= 2:
                print(b*c)
                exit()
            else:
                B.remove(c)
    else:
        B.remove(c)

print(0)

Submission status: Runtime Error

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

R=[]

for i in range(N):
    if A.count(A[i])>=2:
        R.append(A[i])
        
if R==[]:
    print('0')
    
else:
    R.sort(reverse=True)
    
if R.count(R[0])>=4:
        print(R[0]*R[0])

else:
    b = sorted(set(R), key=lambda x: R.index(x))
    list(b)
    b.sort(reverse=True)
print(b[0]*b[1])

Submission status: Runtime Error

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


while not len(A) == 0:
    a = max(A)
    if A.count(a) >= 4:
        print(a**2)
        exit()
    elif A.count(a) >=2:
        while a in A:A.remove(a)
        while not len(A) == 0:
            a2 = max(A)
            if  A.count(a2) >= 2:
                print(a*a2)
                exit()
            else:
                while a2 in A:A.remove(a)
    else:
        while a in A:A.remove(a)

print(0)

Submission status: Runtime Error

Solution code:

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

def quicksort(x):
    if x==[]: return []

    smallerSorted = quicksort([a for a in x[1:] if a <= x[0]])
    biggerSorted = quicksort([a for a in x[1:] if a > x[0]])

    return(smallerSorted+[x[0]]+biggerSorted)


y = quicksort(x)
width=[0,0]
height=[0,0]


for i in range(0,len(y)-1):
    if (y[len(y)-1-i]==y[len(y)-2-i] and width[0]==0):
        width[0]=y[len(y)-1-i]
        width[1]=len(y)-1-i
        continue
    if (width!=0 and y[len(y)-1-i]==y[len(y)-2-i]):
        if(len(y)-1-i==width[1]-1):
            continue
        height[0]=y[len(y)-1-i]
        break



print('{0}'.format(int(width[0])*int(height[0])))



quit()

Submission status: Runtime Error

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:
            break
    key = a.pop(0)

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

Submission status: Runtime Error

Solution code:
N = input()
A = input().split()
B = []
C = []
D = []
E = []
for i in A:
    if i not in B:
        B.append(i)
    elif i not in C:
        C.append(i)
    elif i not in D:
        D.append(i)
    elif i not in E:
        E.append(i)
F = list(map(int,C))
G = list(map(int,E))
F.sort(reverse = True)
G.sort(reverse = True)
print(max(G[0]**2,G[0]*F[0],F[0]*F[1],0))

Submission status: Runtime Error

Solution code:
N = input()
A = input().split()
B = []
C = []
D = []
E = []
for i in A:
    if i not in B:
        B.append(i)
    elif i not in C:
        C.append(i)
    elif i not in D:
        D.append(i)
    elif i not in E:
        E.append(i)
F = list(map(int,C))
G = list(map(int,E))
F.sort(reverse = True)
G.sort(reverse = True)
if G or len(F) >= 2:
    print(max(G[0]**2,G[0]*F[0],F[0]*F[1]))
else:
    print(0)

Submission status: Runtime Error

Solution code:
maxi=1000000001
int(input())
l=[int(x) for x in input().split()]
arr=[0]*maxi
for i in l:
	arr[i]+=1
max1=0
max2=-1
sqr=0
for i in range(maxi):
	if arr[i]>=2:
		if i > max1:
			max1=i
		if arr[i]>=4:
			sol=i**2
			if sqr < sol :
				sqr=sol
for i in range(maxi):
	if arr[i]>=2:
		if i > max2 and i < max1:
			max2=i

rec=max1 * max2
if rec > sqr:
	print(rec)
else:
	print(sqr)

Submission status: Runtime Error

Solution code:
n=int(input())
a=map(int, input().split())
a=sorted(a)[::-1]
n=int(myinput)
myinput="3 3 3 3 4 4 4 5 5 5"
a=map(int, myinput.split())
a=sorted(a)[::-1]

Submission status: Runtime Error

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

sei=[]
cho=[]



for i in s:
    x= a.count(i)
    
    if x >= 4:
        sei.append(i)
    elif x >= 2:
        cho.append(i)

cho2=sorted(cho,reverse=True)


        
if sei==[] and len(cho)<2:        
    print(0)
    exit()
else:
    print(max(max(sei)**2,cho2[0]*cho2[1],max(sei)*cho2[0]))

Submission status: Runtime Error

Solution code:
n = input()

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

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

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

if len(tmp) < 2:
    print 0

Submission status: Runtime Error

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

def solve(i):
    if len(que) == 2:
        return True
    num = A[i]
    check = num in que
    if A.count(num) > 1 and check == False:
        que.append(num)
    if i == N - 1:
        return False
    else:
        return solve(i+1)

a = solve(0)
if a == True:
    ans = que[0] * que[1]
    print(ans)
else:
    print(0)

Submission status: Runtime Error

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) != 0:
    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: Runtime Error

Solution code:
N = input()
A = list(map(int,input().split()))
B = []
C = []
D = []
E = []
for i in A:
    if i not in B:
        B.append(i)
    elif i not in C:
        C.append(i)
    elif i not in D:
        D.append(i)
    elif i not in E:
        E.append(i)
    else:
        continue
C.sort(reverse = True)
E.sort(reverse = True)
if E or len(C) >= 2:
    print(max(E[0]**2,E[0]*C[0],C[0]*C[1]))
else:
    print(0)

Submission status: Runtime Error

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

sei=[]
cho=[]



for i in s:
    x= a.count(i)
    
    if x >= 4:
        sei.append(i)
    elif x >= 2:
        cho.append(i)

cho2=sorted(cho,reverse=True)
        
if sei==[] and len(cho)<2:        
    print(0)
    exit()
else:
    print(max(max(sei)**2,cho2[0]*cho2[1],max(sei)*cho2[0]))

Submission status: Runtime Error

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) != 0:
    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: Runtime Error

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: Runtime Error

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

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

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

while(i<=N and check == 0):
    count = A.count(A[i])
    print(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: Runtime Error

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: Runtime Error

Solution code:
edge=[]
edge=input().split()
e=[]
for i in range(len(edge)):
    e.append(int[edge])
e.sort()
E=[0,0]
j=0
for i in range(len(e)-1,-1,-1):
    if e[i]==e[i-1]:
        E[j]=e[i]
        j+=1
        for k in range(i,-1,-1):
            if e[i]==E[j]:
                del e[i]
            else:
                break
        if E[1]:
            break
print(E[0]*E[1])

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int N;
  int A[100000];
  cin >> N;
  for(int i = 0; i < N; i++)
    cin >> A[i];

}

Submission status: Runtime Error

Solution code:
N = input()
A = input().split()
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) > 1:
    x = int(max(li))
    li.remove(x)
    y = int(max(li))
    print( x * y )
else:
    print("0")

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split(' ')))
A = sorted(A)
A = A[::-1]

first_second_biggest_numpairs = []

flag = False
for i in range(N):
    if flag == True:
        flag = False
        continue
    if i < N:
        if A[i] == A[i + 1]:
            if len(first_second_biggest_numpairs) >= 2:
                first_second_biggest_numpairs.append(A[i])
                flag = True
            else:
                break
            
if len(first_second_biggest_numpairs) == 2:
    print(str(first_second_biggest_numpairs[0] * first_second_biggest_numpairs[1]))
else:
    print("0")

Submission status: Runtime Error

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

counter = {}

for i in l:
    if i in counter:
        counter[i] = counter[i] + 1
    else:
        counter[i] = 1

a = None
b = None
for k in sorted(counter.keys(), reverse=True):
    if counter[k] >= 4 and a == None and b == None:
        a , b = k
    elif counter[k] >= 2 and a == None:
        a = k
    elif counter[k] >= 2 and a != None:
        b = k
    if (a != None and b != None):
        break

if (a != None and b!= None):
    print(a * b)
else:
    print('0')

Submission status: Runtime Error

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
for i in range(0,len(A)+1,2):
    if(c==2):
        break
    elif(A[i]==A[i+1]):
        c+=1
        l*=A[i]
if(c==2):
    print(l)
else:
    print(int(0))

Submission status: Runtime Error

Solution code:
N = int(input())

def quicksort_reverse(lst):
    if len(lst) < 2:
        return lst
    else:
        less = []
        more = []
        pivot = lst[0]
        for i in range(1,len(lst)):
            if lst[i] < pivot:
                less.append(lst[i])
            else:
                more.append(lst[i])
        return quicksort_reverse(more) + [pivot] + quicksort_reverse(less)

arr = list(map(int,input().split()))
arr = quicksort_reverse(arr)

to_multiply = []
while len(to_multiply) < 2 and len(arr) > 1:
    if arr[0] == arr[1]:
        to_multiply.append(arr[0])
    arr = arr[2:]
if len(to_multiply) == 2:
    print(to_multiply[0] * to_multiply[1])
else:
    print("0")

Submission status: Runtime Error

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

last_num = 0
first_second_biggest_numpairs = []
for i in range(N):
    if A[i] == last_num:
        if len(first_second_biggest_numpairs) >= 2:
            break
        first_second_biggest_numpairs.append(A[i])
    last_num = A[i]

if len(first_second_biggest_numpairs) == 2:
    print(str(first_second_biggest_numpairs[0] * first_second_biggest_numpairs[1]))

print("0")

Submission status: Runtime Error

Solution code:
n = input()
bars = map(int,raw_input().split(' '))
bars.sort()
h1_cand=0
h2_cand=0
h1=0
h2=0
for i in range(n):
  m = n-1-i
  if h1 > 0:
    if h2_cand == bars[m]:
      h2 = h2_cand
      break
    else
      h2_cand = bars[m]
  else:
	if h1_cand == bars[m]:
    	h1 = h1_cand
    	h1_cand = 0
  	else:
    	h1_cand = bars[m]

print h1*h2