Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
cnt=0
data=[0]*max(a)
while cnt<n-1:
  if a[cnt]==a[cnt+1]:
    data[a[cnt]-1]+=1
    cnt+=2
  else:
    cnt+=1
data.reverse()
h=0
w=0
for i in range(len(data)):
  if data[i]==0:
    continue
  elif data[i]==1:
    if h==0:
      h=len(data)-i
    elif h!=0 and w==0:
      w=len(data)-i
  elif data[i]>=2:
    if h==0:
      h=len(data)-i
    if w==0:
      w=len(data)-i
  if h!=0 and w!=0:
    break
print(h*w)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
A=Counter(a)
s=set(a)
S=sorted(list(s))
S.reverse()
h=0
w=0
for i in S:
  res=A[i]
  if res>=4:
    if h==0:
      h=i
    if w==0:
      w=i
  elif 2<=res<4:
    if w==0:
      w=i
    elif w!=0 and h==0:
      h=i
print(h*w)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
cnt=0
data=[0]*max(a)
while cnt<n-1:
  if a[cnt]==a[cnt+1]:
    data[a[cnt]-1]+=1
    cnt+=2
  else:
    cnt+=1
data.reverse()
h=0
w=0
for i in range(len(data)):
  if data[i]==0:
    continue
  elif data[i]==1:
    if h==0:
      h=len(data)-i
    elif h!=0 and w==0:
      w=len(data)-i
  elif data[i]>=2:
    if h==0:
      h=len(data)-i
    if w==0:
      w=len(data)-i
  if h!=0 and w!=0:
    break
print(h*w)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
A=Counter(a)
s=set(a)
S=sorted(list(s))
S.reverse()
h=0
w=0
for i in S:
  res=A[i]
  if res>=4:
    if h==0:
      h=i
    if w==0:
      w=i
  elif 2<=res<4:
    if w==0:
      w=i
    elif w!=0 and h==0:
      h=i
print(h*w)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
data=[]
cnt=0
for i in range(n):
  if a.count(a[i])>=4:
    data.append(a[i])
    cnt+=1
    if cnt==2:
      break
    data.append(a[i])
    break
  elif 2<=a.count(a[i])<4:
    if a[i] not in data:
      data.append(a[i])
      cnt+=1
    if cnt==2:
      break
if len(data)==0 or len(data)==1:
  print(0)
else:
  print(data[0]*data[1])


Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
A=Counter(a)
s=set(a)
S=sorted(list(s))
S.reverse()
h=0
w=0
for i in S:
  res=A[i]
  if res>=4:
    if h==0:
      h=i
    if w==0:
      w=i
  elif 2<=res<4:
    if w==0:
      w=i
    elif w!=0 and h==0:
      h=i
print(h*w)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
s=set(a)
data=[]
for i in s:
  p=a.count(i)
  if p>=2:
    data.append([i,p//2])
data.sort(reverse=True)
h=0
w=0
for i in data:
  if i[1]>=2:
    if h==0:
      h=i[0]
    if w==0:
      w=i[0]
  else:
    if h==0:
      h=i[0]
    elif h!=0 and w==0:
      w=i[0]
print(h*w)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
A=Counter(a)
s=set(a)
S=sorted(list(s))
S.reverse()
h=0
w=0
for i in S:
  res=A[i]
  if res>=4:
    if h==0:
      h=i
    if w==0:
      w=i
  elif 2<=res<4:
    if w==0:
      w=i
    elif w!=0 and h==0:
      h=i
print(h*w)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
s=set(a)
data=[]
for i in s:
  p=a.count(i)
  if p>=2:
    data.append([i,p//2])
data.sort(reverse=True)
h=0
w=0
for i in data:
  if i[1]>=2:
    if h==0:
      h=i[0]
    if w==0:
      w=i[0]
  else:
    if h==0:
      h=i[0]
    elif h!=0 and w==0:
      w=i[0]
print(h*w)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
A=Counter(a)
s=set(a)
S=sorted(list(s))
S.reverse()
h=0
w=0
for i in S:
  res=A[i]
  if res>=4:
    if h==0:
      h=i
    if w==0:
      w=i
  elif 2<=res<4:
    if w==0:
      w=i
    elif w!=0 and h==0:
      h=i
print(h*w)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
s=set(a)
l=len(s)
data=[0]*(2*l)
t=0
for i in s:
  if a.count(i)>=4:
    if data.count(i)!=2:
      data[t]=i
      t+=1
      data[t]=i
      t+=1
  elif 2<=a.count(i)<4:
    if data.count(i)!=1:
      data[t]=i
      t+=1
data.sort(reverse=True)
print(data[0]*data[1])

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
A=Counter(a)
s=set(a)
S=sorted(list(s))
S.reverse()
h=0
w=0
for i in S:
  res=A[i]
  if res>=4:
    if h==0:
      h=i
    if w==0:
      w=i
  elif 2<=res<4:
    if w==0:
      w=i
    elif w!=0 and h==0:
      h=i
print(h*w)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
data=[]
s=set(a)
for i in s:
  if 2<=a.count(i)<4:
    data.append(i)
  elif 4<=a.count(i):
    data.append(i)
    data.append(i)
data.sort(reverse=True)
if len(data)==0 or len(data)==1:
  print(0)
else:
  print(data[0]*data[1])

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
A=Counter(a)
s=set(a)
S=sorted(list(s))
S.reverse()
h=0
w=0
for i in S:
  res=A[i]
  if res>=4:
    if h==0:
      h=i
    if w==0:
      w=i
  elif 2<=res<4:
    if w==0:
      w=i
    elif w!=0 and h==0:
      h=i
print(h*w)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
data=[]
cnt=0
for i in range(n):
  if a.count(a[i])>=4:
    data.append(a[i])
    cnt+=1
    if cnt==2:
      break
    data.append(a[i])
    break
  elif 2<=a.count(a[i])<4:
    if a[i] not in data:
      data.append(a[i])
      cnt+=1
    if cnt==2:
      break
if len(data)==0 or len(data)==1:
  print(0)
else:
  print(data[0]*data[1])

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
A=Counter(a)
s=set(a)
S=sorted(list(s))
S.reverse()
h=0
w=0
for i in S:
  res=A[i]
  if res>=4:
    if h==0:
      h=i
    if w==0:
      w=i
  elif 2<=res<4:
    if w==0:
      w=i
    elif w!=0 and h==0:
      h=i
print(h*w)