TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
count = 0
W = 0
H = 0
ans = 0

for i in range(N-1):
    if A[i+1] == A[i]:
        count += 1
        if W == 0:
            if count == 2:
                W = A[i]
                count = 0
        if H == 0:
            if count == 2:
                H = A[i]

print(H * W)

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

C = [0] * 10 ** 9
count = 0
H = 0
W = 0

for i in range(N):
    C[A[i]] += 1

for i in range(N)[::-1]:
    if (C[i] >= 2) and (count == 0):
        H = i
        count += 1
    elif (C[i] >= 2) and (count == 1):
        W = i
        break

print(H * W)

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

A.sort()

wh = [0,0]

tmp = 0
for i in A:
    if i == tmp:
        wh.append(i)
        tmp = 0
    else:
        tmp = i

print(wh[-1] * wh[-2])


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
import collections
A = list(map(int,input().split()))
C = collections.Counter(A)
use = []
for i,val in C.items():
  if val > 4:
    use.append(i)
  if val > 2:
    use.append(i)

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

N = int(input())
import collections
A = list(map(int,input().split()))
C = collections.Counter(A)
use = []
for i,val in C.items():
  if val > 4:
    use.append(i)
  if val > 2:
    use.append(i)
 
use = sorted(use,reverse= True)
if len(use)<2:
  print(0)
else:
  print(use[0]*use[1])

N = int(input())
import collections
A = list(map(int,input().split()))
C = collections.Counter(A)
use = []
for i,val in C.items():
  if val >= 4:
    use.append(i)
  if val >= 2:
    use.append(i)

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
n=int(input())
A=list(map(int,input().split()))
a=collections.Counter(A)
firstnum=0
secondnum=0
firstl=0
secondl=0
for i,j in a.items():
  if i>=firstl and j%2>=0:
    secondnum=firstnum
    firstnum=j
    secondl=firstl
    firstl=i
  elif secondl<=i<firstl and j%2>=0:
    secondnum=j
    secondl=i
print(firstl*secondl)
  


import collections
n=int(input())
A=list(map(int,input().split()))
a=collections.Counter(A)
firstnum=0
secondnum=0
firstl=0
secondl=0
values,counts=zip(*a.most_common())
for i,j in a.items():
  if i>=firstl and j>=2:
    secondnum=firstnum
    firstnum=j
    secondl=firstl
    firstl=i
  elif secondl<=i<firstl and j>=2:
    secondnum=j
    secondl=i
if firstnum>=4:
  print(firstl**2)
else:
  print(firstl*secondl)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections

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

c = collections.Counter(ls)

ls_s = c.most_common()
ls_s.sort(reverse=True)

mul = []

for i in range(len(ls_s)):
    if ls_s[i][1] >= 4:
        if len(mul) == 0:
            print(ls_s[i][0] ** 2)
            break
        elif len(mul) == 1:
            print(ls_s[i][0] * mu;[0])
            break
    elif ls_s[i][1] >= 2:
        mul.append(ls_s[i][0])
    
    if len(mul) >= 2:
        print(mul[0] * mul[1])
        break
    elif i == len(ls_s) - 1:
        print(0)

import collections

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

c = collections.Counter(ls)

ls_s = c.most_common()
ls_s.sort(reverse=True)

mul = []

for i in range(len(ls_s)):
    if ls_s[i][1] >= 4:
        if len(mul) == 0:
            print(ls_s[i][0] ** 2)
            break
        elif len(mul) == 1:
            print(ls_s[i][0] * mul[0])
            break
    elif ls_s[i][1] >= 2:
        mul.append(ls_s[i][0])
    
    if len(mul) >= 2:
        print(mul[0] * mul[1])
        break
    elif i == len(ls_s) - 1:
        print(0)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
N = int(input())
cnt = Counter(map(int, input().split()))

L = sum([[] for a, c in cnt.items()], [])
L.sort()

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


from collections import Counter
N = int(input())
cnt = Counter(map(int, input().split()))

L = sum([[1] for a, c in cnt.items()], [])
L.sort()

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


from collections import Counter
N = int(input())
cnt = Counter(map(int, input().split()))

L = sum([[a] * (c // 2) for a, c in cnt.items()], [])

print(-1)

from collections import Counter
N = int(input())
A = Counter(map(int, input().split()))

S = []
for a, c in A.items():
    S.extend([a] * (c // 2))

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

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

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

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


from collections import Counter

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

B = set(A)
C = sorted(list(B))
A = Counter(A)


ans = 0
keep = 0

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
l = []
for v in set(a):
    x = a.count(v)
    if x >= 2:
        l.append(x)
if len(l) < 2:
    print (0)
    exit()

l.sort()
print (l[0]*l[1])

from collections import Counter

n = int(input())
a = list(map(int,input().split()))
a_count = sorted(Counter(a).items(),reverse=True)
f = False

for k,v in a_count:
    if (4 <= v) and (not f):
        print (k**2)
        exit ()
    elif 2 <= v:
        if f:
            print (x*k)
            exit ()
        else:
            x = k
            f = True
    else:
        pass

print (0)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    sidelist = OrderedDict()

    for aa in a:
        if a.count(aa) >= 2:
            if aa not in sidelist:
                sidelist[aa] = 1
            else:
                sidelist[aa] += 1

    side_a = 0
    side_b = 0

    for s in sidelist:
        if sidelist[s] >= 4 and s > side_a:
            side_a = s
            side_b = s
        elif sidelist[s] >= 2:
            if side_a == 0:
                side_a = s
            elif side_b == 0:
                side_b = s
            elif s > side_a:
                side_b = side_a
                side_a = s
            elif s > side_b:
                side_b = s

    print(side_a*side_b)


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

    A.sort(reverse=True)
    tmp = 0
    bar1 = 0
    bar2 = 0

    for a in A:
        if tmp == 0:
            tmp = a
        elif tmp == a:
            if bar1 > 0:
                bar2 = a
                print(bar1*bar2)
                exit()
            else:
                bar1 = a
                tmp = 0
        elif a < tmp:
            tmp = a

    print(0)


if __name__ == "__main__":
    main()


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
m1,m2=0,0
N=int(input())
A=Counter(list(map(int,input().split())))
key=sorted(A.keys(),reverse=True)
for i in key:
  if A[i]>1 and m1==0:
    m1=A[i]
  if m1!=0 and A[i]>1:
    print(m1*A[i])
    exit()
print(0)

from collections import Counter
m1=0
N=int(input())
A=Counter(list(map(int,input().split())))
key=sorted(A.keys(),reverse=True)
for i in key:
  if A[i]>1 and m1==0:
    m1=i
    if A[i]>3:
      print(i**2)
      exit()
  elif m1!=0 and A[i]>1:
    print(m1*i)
    exit()
print(0)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
n = int(input())
a = list(map(int,input().split()))
c = sorted(collections.Counter(a).items(),reverse = True)

num2=[]
num4=[]

for k in c:
  if k[1]>=4:
    num4.append(k[0])
  if k[1]>=2:
    num2.append(k[0])

if len(num2)>=2 or len(num4)>=1:
  print(max(num2[0]*num2[1],num4[0]**2))
else:
  print(0) 

import collections
n = int(input())
a = list(map(int,input().split()))
c = sorted(collections.Counter(a).items(),reverse = True)

num2 = []
num4 = []
ans = [0]

for k in c:
  if k[1]>=4:
    num4.append(k[0])
  if k[1]>=2:
    num2.append(k[0])

if len(num2)>=2:
  ans.append(num2[0]*num2[1])
if len(num4)>=1:
  ans.append(num4[0]**2)

print(max(ans))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)

max_1 = 0
len_a = len(A)
for i, a in enumerate(A):
    if len_a - i >= 4:
        if A[i] == A[i+1] and A[i+1] == A[i+2] and A[i+2] == A[i+3]:
            if max_1 == 0:
                print(A[i] ** 2)
                exit()
            else:
                print(A[i] * max_1)
                exit()
    if len_a - i >= 2:
        if A[i] == A[i+1]:
            if max_1 == 0:
                max_1 = A[i]
        else:
            if max_1 != A[i]:
                print(A[i] * max_1)
                exit()
print(0)

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

max_1 = 0
len_a = len(A)
for i, a in enumerate(A):
    if len_a - i >= 4:
        if A[i] == A[i+1] and A[i+1] == A[i+2] and A[i+2] == A[i+3]:
            if max_1 == 0:
                print(A[i] ** 2)
                exit()
            else:
                print(A[i] * max_1)
                exit()
    if len_a - i >= 2:
        if A[i] == A[i+1]:
            if max_1 == 0:
                max_1 = A[i]
            else:
                if max_1 != A[i]:
                    print(A[i] * max_1)
                    exit()
print(0)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

from collections import defaultdict

def main():
	d=defaultdict(int)
	
	n=int(input())
	A=list(map(int,input().split()))
	for x in A:
		d[x]+=1
	
	li=[]
	li2=[]
	for k,v in d.items():
		if v>=2:
			li.append(k)
		if v>=4:
			li2.append(k)

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

if __name__ == "__main__":
	main()


import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	n=int(input())
	A=list(map(int,input().split()))
	A.sort(reverse=True)
	ans=0
	cnt=0
	li=[]
	for i in range(n-1):
		if A[i+1]==A[i]:
			cnt+=1
			if cnt==3:
				ans=A[i]**2
				break
			if cnt==1:
				li.append(A[i])
				if len(li)==2:
					ans=li[0]*li[1]
					break
		else:
			cnt=0
	print(ans)
	
	

if __name__ == "__main__":
	main()


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    l = Counter(a)
    tw = []
    fo = []
    for i,j in l.items():
        if j >= 2:
            tw.append(i)
        if j >= 4:
            fo.append(i)

    if len(tw) >= 2 or len(fo) >= 1:
        tw.sort()
        fo.sort()
        return max(tw[-1]*tw[-2], fo[-1]**2)
    else:
        return 0
    

print(solve())


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

    l = Counter(a)
    tw = []
    fo = []
    for i,j in l.items():
        if j >= 2:
            tw.append(i)
        if j >= 4:
            fo.append(i)

    if len(tw) >= 2 or fo:
        tw.sort()
        return max(tw[-1]*tw[-2], fo[-1]**2)
    else:
        return 0
    

print(solve())


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

    l = Counter(a)
    tw = []
    fo = []
    for i,j in l.items():
        if j >= 2:
            tw.append(i)
        if j >= 4:
            fo.append(i)
    ans = 0
    if len(tw) >= 2:
        tw.sort()
        ans = max(ans, tw[-1]*tw[-2])
    if fo:
        fo.sort()
        ans = max(ans, fo[-1]**2)
    
    return ans
    

print(solve())


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

d = defaultdict(int)
n = readInt()
for i in readChars():
	d[i]+=1

d = [i for i in sorted(d.items(), reverse=True) if i[1]>1]

if len(d)==0:
	print(0)
	exit()
elif len(d)==1:
	if d[0][1]>=4:
		continue
	else:
		print(0)
		exit()

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


from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

d = defaultdict(int)
n = readInt()
for i in readChars():
	d[i]+=1

d = [i for i in sorted(d.items(), reverse=True) if i[1]>1]

try:
	if d[0][1]>=4:
		print(int(d[0][0])**2)
	else:
		print(int(d[0][0])*int(d[1][0]))
	exit()
except:
	print(0)

print(0)

from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()

d = Counter(readInts())

d = [i for i in sorted(d.items(), reverse=True) if i[1]>=2]

if len(d)==0:
	print(0)
	exit()
elif len(d)==1:
	if d[0][1]>=4:
		pass
	else:
		print(0)
		exit()
if d[0][1]>=4:
	print(int(d[0][0])**2)
else:
	print(int(d[0][0])*int(d[1][0]))


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
a = na()

a.sort(reverse=True)
l = list()
for key, gr in groupby(a):
    if len(l) == 2:
        print(l[0] * l[1])
        quit()
    num = len(list(gr))
    if num >= 2:
        l.append(key)
    if num >= 4:
        l.append(key)
print(0)


from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
a = na()

a.sort(reverse=True)
l = list()
for key, gr in groupby(a):
    if len(l) == 2:
        print(l[0] * l[1])
        quit()
    num = len(list(gr))
    if num >= 2:
        l.append(key)
    if num >= 4:
        l.apend(key)
print(0)


from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
a = na()

a.sort(reverse=True)
l = list()
for key, gr in groupby(a):
    if len(l) == 2:
        break
    num = len(list(gr))
    if num >= 2:
        l.append(key)
    if num >= 4:
        l.append(key)
print(l[0] * l[1] if len(l) >= 2 else 0)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = input()
b = input()

ans = 3
i = 0
if a[0] != b[0]:
    i += 1
    ans += 3

while i < n-1:
    if a[i]==b[i]:
        if a[i+1]==b[i+1]:
            ans *= 2
        else:
            ans *= 2
            i += 1
    else:
        if a[i+1]==b[i+1]:
            ans *= 1
        else:
            ans *= 3
            i += 1
    i += 1
    ans %= 1000000007
print(ans)


ai = lambda: list(map(int, input().split()))

n = int(input())
a = ai()
from collections import Counter
c = Counter(a)
a = [i for i in c if c[i]>1]
a.sort()
if len(a)>0 and c[a[-1]]>1:
    print(a[-1]**2)
elif len(a)<2:
    print(0)
else:
    print(a[-1]*a[-2])

ai = lambda: list(map(int, input().split()))

n = int(input())
a = ai()
from collections import Counter
c = Counter(a)
a = [i for i in c if c[i]>1]
a.sort()
if len(a)>0 and c[a[-1]]>=4:
    print(a[-1]**2)
elif len(a)<2:
    print(0)
else:
    print(a[-1]*a[-2])

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

input()
arr = Counter(list(map(int,input().split())))
ans = [0,0]
for a in arr:
  print(a)
  if arr[a] > 1:
    ans.append(a)
  if arr[a] > 3:
    ans.append(a)
ans.sort()
print(ans[-1] * ans[-2])

from collections import Counter

input()
arr = Counter(list(map(int,input().split())))
ans = [0,0]
for a in arr:
  print(a)
  if arr[a] > 1:
    ans.append(a)
  
ans.sort()
print(ans[-1] * ans[-2])

from collections import Counter

input()
arr = Counter(input().split())
count = 0
squer = 1
for k, v in sorted(arr.items(), reverse=True):  
  if v >= 4 and count==0:
    squer = int(k)**2
    break
  elif v >= 2:
    squer *= (int(k))
    count += 1
    if count == 2:
      break
  
print(squer if count < 2 else 0)      
  


from collections import Counter

input()
arr = Counter(input().split())
count = 0
squer = 1
for k, v in sorted(arr.items(), reverse=True):  
  if v >= 4 and count==0:
    squer = int(k)**2
    count += 2
    break
  elif v >= 2:
    squer *= (int(k))
    count += 1
    if count == 2:
      break
  
print(squer if count < 2 else 0)      
  


from collections import Counter

input()
arr = Counter(list(map(int,input().split())))
ans = [0,0]
for a in arr:  
  if arr[a] > 1:
    ans.append(a)
  if arr[a] > 3:
    ans.append(a)
ans.sort()
print(ans[-1] * ans[-2])

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
b=sorted(a,reverse=True)
c=set(b)
d=sorted([i for i in c],reverse=True)
flag1=False
flag2=False
for i in d:
    if b.count(i)>=4:
        print(i**2)
        break
        exit()
    elif flag1==False and flag2==False and b.count(i)>=2:
        tmp1=i
        flag1=True
    elif flag1 and flag2==False and b.count(i)>=2:
        tmp2=i
        print(tmp1*tmp2)
        break
        exit()
if  flag2==False:
    print(0)

from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=sorted(a,reverse=True)
d=deque(b)
ans=0
tmp=0
flag1=False
flag2=False
while d:
    if d[0]==tmp and flag1==False:
        flag1=True
        d.popleft()
        h1=tmp
        tmp=0
    elif flag1 and d[0]==tmp:
        h2=tmp
        ans=h1*h2
        break
    elif d[0]!=tmp:
        tmp=d.popleft()
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections

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

f = []
t = []
for i in a:
    if a[i] >= 4:
        f.append(i)
    if a[i] >= 2:
        t.append(i)
fa, ta = 0, 0
f.sort()
t.sort()
if len(f) >= 1:
    fa = f[-1]**2
if len(t) >= 2:
    ta = max(t[-1]*t[-2], t[-1]*f[-1])
else:
    print(0)

import sys
import collections

n = int(input())
a = collections.Counter(list(map(int, sys.stdin.readline().split())))

q = [0, 0]
for v, k in a.items():
    if k >= 4:
        q.append(v)
    if k >= 2:
        q.append(v)
q.sort()
print(q[-1]*q[-2])

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import collections
n = int(input())
alist = list(map(int,input().split()))
adic = collections.Counter(alist)
for k,v in adic.items():
  if v == 1:
    del(adic[k])
sort_adic = sorted(adic.items(), reverse = True, key = lambda x:x[1])
li = list(sort_adic.items())
print(li[0][0]*li[1][0])

import collections
n = int(input())
alist = list(map(int,input().split()))
adic = collections.Counter(alist)
for k,v in adic.items():
  if v == 1:
    del(adic[k])
sort_adic = sorted(adic.items(), reverse = True, key = lambda x:x[1])
li = list(sort_adic.items())
print(li[0][1]*li[1][1])

import collections
n = int(input())
alist = list(int,input().split())
adic = collections.Counter(alist)
for k,v in adic.items():
  if v == 1:
    del(dic[k])
sort_adic = sorted(adic.items(), reverse = True, key = lamda x:x[1])
li = list(sort_adic.items())
print(li[0][1]*li[1][1])

import collections
n = int(input())
alist = list(map(int,input().split()))
adic = collections.Counter(alist)
for k,v in adic.items():
  if v == 1:
    del(adic[k])
sort_adic = sorted(adic.items(), reverse = True, key = lamda x:x[1])
li = list(sort_adic.items())
print(li[0][1]*li[1][1])

import collections
n = int(input())
alist = list(map(int,input().split()))
adic = collections.Counter(alist)
A = [0,0]
for i in adic:
  if adic[i] > 1:
    A.append(i)
  if adic[i] > 3:
    A.append(i)
sortedA = sorted(A)
print(sorted[-1]*sorted[-2])

import collections
n = int(input())
alist = list(int,input().split())
adic = collections.Counter(alist)
for k,v in adic.items():
  if v == 1:
    del(adic[k])
sort_adic = sorted(adic.items(), reverse = True, key = lamda x:x[1])
li = list(sort_adic.items())
print(li[0][1]*li[1][1])

import collections
n = int(input())
alist = list(map(int,input().split()))
adic = collections.Counter(alist)
A = [0,0]
for i in adic:
  if adic[i] > 1:
    A.append(i)
  if adic[i] > 3:
    A.append(i)
sortedA = sorted(A)
print(sortedA[-1]*sortedA[-2])

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
input();a=sorted(Counter(map(int,input().split())).most_common())[::-1];c=b=0
for i in range(len(set(a))):
    if b and c:print(c*b);exit()
    if a[i][1]>3 and a[i][0]*c<a[i][0]**2:b=c=a[i][0]
    elif a[i][1]>1:b,c=c,a[i][0]

from collections import Counter
input();a=sorted(Counter(map(int,input().split())).most_common())[::-1];c=b=0
for i in range(len(set(a))):
    if b and c:break
    if a[i][1]>3 and a[i][0]*c<a[i][0]**2:b=c=a[i][0]
    elif a[i][1]>1:b,c=c,a[i][0]
print(c*b)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collcections import Counter
n=int(input())
l=list(map(int,input().split()))
d=[]
L=Counter(l)
a=L.most_common()
for i in a:
  if a[i][1]>=4:
    d.append(a[i][1])
    d.append(a[i][1])
  elif a[i][1]>=2:
    d.append(a[i][1])
d.sort(reverse=True)
print(d[0]*d[1] if len(d)>=2 else 0)

from collections import Counter
n=int(input())
l=list(map(int,input().split()))
d=[]
L=Counter(l)
a=L.most_common()
for i in range(len(a)):
  if a[i][1]>=4:
    d.append(a[i][0])
    d.append(a[i][0])
  elif a[i][1]>=2:
    d.append(a[i][0])
d.sort(reverse=True)
print(d[0]*d[1] if len(d)>=2 else 0)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import collections
N = int(input())
A=sorted(list(map(int, input().split())))
a = collections.Counter(A)
ans = 0
y = 0
for i in a.keys():
    if a[i] >= 2:
        x = y*i
        y = i
    if a[i] >= 4:
        z = i**2
    ans = max(ans, x, z)
print(ans)

from collections import Counter

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

    
c = Counter(A)


ans = []
for i, j in c.items():
    if j >= 2:
        ans.append[i]

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

import collections
N = int(input())
A = sorted(list(map(int, input().split())))
a = collections.Counter(A)
ans = 0
y = 0
for i in a.keys():
    if a[i] >= 2:
        x = y*i
        y = i
    if a[i] >= 4:
        z = i**2
    ans = max(ans, x, z)
print(ans)

import collections
N = int(input())
A=sorted(list(map(int, input().split())))
a = collections.Counter(A)
ans = 0
y = 0
for i in a.keys():
    if a[i] >= 2:
        x = y*i
        y = i
    if a[i] >= 4:
        z = i**2
    ans = max(ans, x, z)
print(ans)

from collections import Counter

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

    
c = Counter(l)


ans = []
for i, j in c.items():
    if i >= 2:
        ans.append[j]

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

from collections import Counter

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

c = Counter(A)


ans = [0, 0]
for i, j in c.items():
    if j >= 2:
        ans.append(i)
    if j >= 4:
        ans.append(i)

ans.sort()    

print(ans[-1]*ans[-2])

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
count = 0
for j in range(len(a)-1):
    if(count => 2):
        print(l[0] * l[1])
        exit()
    if(a[j] == a[j+1]):
        del l[0]
        l.append(a[j])
        j += 1
        count += 1

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
count = 0
for j in range(len(a)-1):
    if(count => 2):
        print(l[0] * l[1])
        break
    if(a[j] == a[j+1]):
        del l[0]
        l.append(a[j])
        j += 1
        count += 1

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
count = 0
for j in range(len(a)-1):
    if(count => 2):
        print(l[0] * l[1])
    if(a[j] == a[j+1]):
        del l[0]
        l.append(a[j])
        j += 1
        count += 1

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
c = 0
for j in range(len(a)-1):
    if(count => 2):
        print(l[0] * l[1])
    if(a[j] == a[j+1]):
        del l[0]
        l.append(a[j])
        j += 1
        count += 1

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = list()
for i in range(2):
    for j in range(len(a)-1):
        if(a[j] == a[j+1]):
            l.append(a[j])
            break
    if(i == 1):
        l.append(0)
        l.append(0)
print(l[0] * l[1])

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
for j in range(len(a)-1):
    if(a[j] == a[j+1]):
        if(l[1] < a[j]):
            del l[0]
            l.append(a[j])
            j += 1

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

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
c = 0
for j in range(len(a)-1):
    if(c >= 2):
        print(l[0] * l[1])
    if(a[j] == a[j+1]):
        del l[0]
        l.append(a[j])
        j += 1
        c += 1

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
c = 0
for j in range(len(a)-1):
    if(c => 2):
        print(l[0] * l[1])
    if(a[j] == a[j+1]):
        del l[0]
        l.append(a[j])
        j += 1
        c += 1

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
c = 0
for j in range(len(a)-1):
    if(count => 2):
        print(l[0] * l[1])
    if(a[j] == a[j+1]):
        del l[0]
        l.append(a[j])
        j += 1
        c += 1

_ = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
c = 0
i = 0
while(i < len(a)-1):
    if(a[i] == a[i+1]):
        del l[0]
        l.append(a[i])
        i += 1
        c += 1
    if(c >= 2 or i == len(a)-2):
        i = len(a)-1
        print(l[0] * l[1])
    i += 1

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
a = list(map(int, input().split()))

a = sorted(a)
i = len(a) - 1
b = []

while (i >= 1):
	if (a[i] == a[i - 1]):
		b.append(a[i - 1])
		i -= 2

	i -= 1

	if(len(b) == 2):
		break


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

else:
	print(0)

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

a = sorted(a)
i = len(a) - 1
b = []

while (i - 1 >= 0):
	if (a[i] == a[i - 1]):
		b.append(a[i - 1])
		i -= 2

	else:
		i -= 1

	if(len(b) == 2):
		break


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

else:
	print(0)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections

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

tmp  = []
for i in c:
    print(i,c[i])
    if c[i] >= 4:
        tmp += [i]
        break
    elif c[i] >= 2:
        tmp += [i]
    if len(tmp) == 2:
        break
    
if len(tmp) == 2:
    print(tmp[0]*tmp[1])
elif len(tmp) == 1:
    print(tmp[0]*tmp[0])
else:
    print(0)
        

import collections

N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
c = collections.Counter(A)
b = sorted(c,reverse = True)
tmp  = []
for i in b:
    if c[i] >= 4:
        tmp += [i]
        break
    elif c[i] >= 2:
        tmp += [i]
    if len(tmp) == 2:
        break
    
if len(tmp) == 2:
    print(tmp[0]*tmp[1])
elif len(tmp) == 1:
    print(tmp[0]*tmp[0])
else:
    print(0)
        



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
A = Counter([int(_) for _ in stdin.readline().rstrip().split()]).most_common()
A.sort(reverse=True)
if A[0][1] < 2 or A[1][1] < 2:
    print(0)
else:
    print(A[0][0]*A[1][0])

import sys
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
A = Counter([int(_) for _ in stdin.readline().rstrip().split()]).most_common()
B = [t for t in A if t[1] >= 2]
B.sort(reverse=True)
if len(B) < 2:
    print(0)
    sys.exit()
if B[0][1] >= 4:
    print(B[0][0]**2)
else:
    print(B[0][0]*B[1][0])

Verdicts: Wrong Answer

Accepted
Problem: 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.

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

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

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

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




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

n = k()
a = l()

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

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




Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
ac = sorted(list(set(a)))
ans = []
for i in ac[::-1]:
    c = a.count(i)
    if len(ans) == 2:
        print(ans[0] * ans[1])
        exit()
    if not ans and c >= 4:
        print(i ** 2)
        exit()
    if c >= 2:
        ans.append(i)
print(0)

import collections

n = int(input())
a = list(map(int, input().split()))
ac = collections.Counter(a)
quad = [i for i in ac if ac[i] >= 4]
if quad:
    ans = max(quad) ** 2
else:
    ans = 0
twice = sorted([i for i in ac if ac[i] >= 2])
if len(twice) >= 2:
    ans = max(ans, twice[-1] * twice[-2])
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
N = int(input())
Ac = Counter(list(map(int, input().split())))
over2 = [ele for ele in Ac.items() if ele[1]>=2]
if len(over2) == 0:
  print(0)
elif len(over2) == 1:
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
else:
  over2.sort()[::-1]
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
  else:
    print(over2[0][0]*over2[1][0])

from collections import Counter
N = int(input())
Ac = Counter(list(map(int, input().split())))

ans = []
for k in sorted(Ac.keys())[::-1]:
  if len(ans) == 2:
    break
  if Ac[k] >=4:
    if ans:
      ans.append(k)
    else:
      ans.append(k)
      ans.append(k)
  elif Ac[k] >= 2:
    ans.append(k)
if len(ans) == 2:
  print(ans[0]*ans[1])
else:
  print(0)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
l=list(map(int,input().split()))
import collections
c = collections.Counter(l)
ans1=[]
ans2=[]
for x in c.keys():
  if c[x]>1:
    ans1.append(x)
  if c[x]>3:
    ans2.append(x)
ans1.sort()
if len(ans1)<2:
  print(0)
else:
  print(max(ans1[-1]*ans1[-2],max(ans2)**2))

n=int(input())
l=list(map(int,input().split()))
import collections
c = collections.Counter(l)
ans1=[]
ans2=[0]
for x in c.keys():
  if c[x]>1:
    ans1.append(x)
  if c[x]>3:
    ans2.append(x)
ans1.sort()
if len(ans1)<2:
  print(0)
else:
  print(max(ans1[-1]*ans1[-2],max(ans2)**2))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
_, *lst = map(int, input().split())
stick = [i for i, j in Counter(lst).items() if j > 1]
if len(stick) > 1:
  stick.sort()
  print(stick[-1] * stick[-2])
else:
  print(0)
  

from collections import Counter
_, *lst = map(int, open(0).read().split())
c = Counter(lst).items()
stick2 = [i for i, j in c if j > 1]
stick4 = [0] + [i for i, j in c if j > 3]
max4 = max(stick4)
max4 *= max4
if len(stick2) > 1:
  stick2.sort()
  print(max(stick2[-1] * stick2[-2], max4))
else:
  print(max(0, max4))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
n=int(input())
lists=list(map(int,input().split()))
A=dict(collections.Counter(lists))
dictdict=[]
for j in A.keys():
    for _ in range(A[j]//2):
        dictdict.append(j)
A=sorted(A,reverse=True)
print(A[0]*A[1])



import collections
n=int(input())
lists=list(map(int,input().split()))
A=dict(collections.Counter(lists))
dictdict=[]


for j in A.keys():
    for _ in range(A[j]//2):
        dictdict.append(j)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
N=int(input())
A=list(map(int ,input().split()))
D=Counter(A)
#print(D.items())
L=[]
for num, v in D.items():
    if v>=4:
        L.append((num,4))
    elif v>=2:
        L.append((num, 2))

L=sorted(L, reverse=True)
if len(L)==0:
    print(0)
    exit()
elif len(L)==1 and L[0][1]==2:
    print(0)
    exit()
ans=1
for i,t in enumerate(L):
    num,v=t
    if i==0:
        if v==4:
            ans=num*num
            break
        else:
            ans*=num
    elif i==1:
        ans+=num
        break
print(ans)

from collections import Counter
N=int(input())
A=list(map(int ,input().split()))
D=Counter(A)
#print(D.items())
L=[]
for num, v in D.items():
    if v>=4:
        L.append((num,4))
    elif v>=2:
        L.append((num, 2))

L=sorted(L, reverse=True)
if len(L)==0:
    print(0)
    exit()
elif len(L)==1 and L[0][1]==2:
    print(0)
    exit()
ans=1
for i,t in enumerate(L):
    num,v=t
    if i==0:
        if v==4:
            ans=num*num
            break
        else:
            ans*=num
    elif i==1:
        ans*=num
        break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))


def main():
    n = int(input())
    a = sorted(readLine_int_list(),reverse=True)

    pair = []
    ans = 0
    t = 1

    for i in range(n-1):
        
        if a[i] == a[i+1]:
            t += 1
        else:
            if t > 1:
                pair.append(a[i])
            t = 1
        
        if t > 3:
            ans = a[i]*a[i+1]
            break
        
        
        if len(pair) >= 2:
            ans = pair[0] * pair[1]
            break

    print(ans)


if __name__ == '__main__':
    main()


from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))


def main():
    n = int(input())
    a = sorted(readLine_int_list(),reverse=True)
    a.append(-1)
    pair = []
    ans = 0
    t = 1
    
    for i in range(n):
        
        if a[i] == a[i+1]:
            t += 1
        else:
            if t > 1:
                pair.append(a[i])
                if len(pair) == 2:
                    ans = pair[0] * pair[1]
                    break
            t = 1
        
        if t > 3:
            if pair:
                ans = max(a[i-1]*a[i], pair[0]*a[i])
            else:
                ans = a[i]**2
            break

        
        

    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a = int(input())
x = list(map(int, input().split()))
t = x[0]
x.sort()
x = x[::-1]
k = []
for i in range(1,a):
    if t == x[i]:
        k.append(x[i])
    t = x[i]
if len(k)>=2:
    print(k[0]*k[1])
else:print(0)


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

A.sort(reverse=True)

from collections import defaultdict
d = defaultdict(int)
ans = 0
t = 0
for i in A:
    d[i] +=1
    if d[i] == 4:
        print(i**2)
        exit()
    elif d[i]==2 and ans ==0:
        ans +=2
        t = i  
    elif d[i] == 2:
        ans +=2 
    if ans ==4:
        print(t*i)
        exit()

print(0)

Verdicts: Wrong Answer

Accepted