Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lis=[]
ng=[set() for _ in range(n)]

for i in range(m):
    A,B=map(int,input().split())
    lis.append([A,B])
    ng[A].add(B)
    
lis.sort()
now=[]
danger=set()
cu=0
for i in range(1,n):
    now.append(i)
    danger=danger|ng[i]
    if(i+1 in danger):
        cu+=1
        danger=set()
            
print(cu)

Fixed submission:
n,m=map(int,input().split())
ng=[set() for _ in range(n)]

for i in range(m):
    A,B=map(int,input().split())
    ng[A].add(B)
    
now=[]
danger=set()
cu=0
for i in range(1,n):
    now.append(i)
    for j in ng[i]:
        danger.add(j)
    if(i+1 in danger):
        cu+=1
        danger.clear()
            
print(cu)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lis=[]
ng=[set() for _ in range(n)]

for i in range(m):
    A,B=map(int,input().split())
    lis.append([A,B])
    ng[A].add(B)
    
lis.sort()
now=[]
danger=set()
cu=0
for i in range(1,n):
    now.append(i)
    danger=danger|ng[i]
    if(i+1 in danger):
        cu+=1
        danger=set()
            
print(cu)

Fixed submission:
n,m=map(int,input().split())
ng=[set() for _ in range(n)]

for i in range(m):
    A,B=map(int,input().split())
    ng[A].add(B)
    
now=[]
danger=set()
cu=0
for i in range(1,n):
    now.append(i)
    for j in ng[i]:
        danger.add(j)
    if(i+1 in danger):
        cu+=1
        danger.clear()
            
print(cu)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lis=[]
ng=[[] for _ in range(n)]

for i in range(m):
    A,B=map(int,input().split())
    lis.append([A,B])
    ng[A].append(B)
    
lis.sort()
now=[]
cu=0
for i in range(1,n):
    now.append(i)
    for j in now:
        if(i+1 in ng[j]):
            cu+=1
            now=[]
            break
            
print(cu)

Fixed submission:
n,m=map(int,input().split())
ng=[set() for _ in range(n)]

for i in range(m):
    A,B=map(int,input().split())
    ng[A].add(B)
    
now=[]
danger=set()
cu=0
for i in range(1,n):
    now.append(i)
    for j in ng[i]:
        danger.add(j)
    if(i+1 in danger):
        cu+=1
        danger.clear()
            
print(cu)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if(a>8 or b>8):print(":(")
else:print("Yay!")

Fixed submission:
a,b=map(int,input().split())
if(a>8 or b>8):print(":(")
else:print("Yay!")

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if(a>8 or b>8):print(":(")
else:print("Yay!")

Fixed submission:
a,b=map(int,input().split())
if(a>8 or b>8):print(":(")
else:print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
N,C=map(int,input().split())
D=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(N)]
cost=[[0 for _ in range(C)],[0 for _ in range(C)],[0 for _ in range(C)]]
for i in range(N):
    for j in range(N):
        for x in range(C):
            cost[(i+j+2)%3][x]+=D[c[j][i]-1][x]
            

ar=[[cost[0][i],i] for i in range(C)]
br=[[cost[1][i],i] for i in range(C)]
cr=[[cost[2][i],i] for i in range(C)]
sa=sorted(ar)
sb=sorted(br)
sc=sorted(cr)
outp=[]
for i in range(3):
    for j in range(3):
        for k in range(3):
            if(sa[i][1]!=sb[j][1] and sa[i][1]!=sc[k][1] and sb[j][1]!=sc[k][1]):
                outp.append(sa[i][0]+sb[j][0]+sc[k][0])
print(min(outp))

Fixed submission:
N,C=map(int,input().split())
D=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(N)]
cost=[[0 for _ in range(C)],[0 for _ in range(C)],[0 for _ in range(C)]]
for i in range(N):
    for j in range(N):
        for x in range(C):
            cost[(i+j+2)%3][x]+=D[c[j][i]-1][x]
            

ar=[[cost[0][i],i] for i in range(C)]
br=[[cost[1][i],i] for i in range(C)]
cr=[[cost[2][i],i] for i in range(C)]
sa=sorted(ar)
sb=sorted(br)
sc=sorted(cr)
outp=[]
for i in range(3):
    for j in range(3):
        for k in range(3):
            if(sa[i][1]!=sb[j][1] and sa[i][1]!=sc[k][1] and sb[j][1]!=sc[k][1]):
                outp.append(sa[i][0]+sb[j][0]+sc[k][0])
print(min(outp))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
mi=n
for i in range(n):
  l=list(s[:i])
  r=list(s[i+1:])
  mi=min(l.count("W")+r.count("E"),mi)
print(mi)

Fixed submission:
n=int(input())
s=input()
SW=[0]
SE=[0]
for i in range(n):
  if(s[i]=="W"):
    SW.append(SW[-1]+1)
    SE.append(SE[-1])
  else:
    SE.append(SE[-1]+1)
    SW.append(SW[-1])
mi=n
SE.append(SE[-1])
for i in range(n):
  mi=min(SW[i]+SE[-1]-SE[i+1],mi)
print(mi)
Buggy python submission (verdict: Runtime Error):
a=int(input())
if(a<4):print(1)
else:
  ma=1
  for i in range(1,int(sqrt(a))):
    for j in range(2,1000):
      x=i**j
      if(x>a):break
      ma=max(ma,x)
  print(ma)
      

Fixed submission:
a=int(input())
if(a<4):print(1)
else:
  ma=1
  for i in range(1,int(a**0.5)+1):
    for j in range(2,1000):
      x=i**j
      if(x>a):break
      ma=max(ma,x)
  print(ma)
Buggy python submission (verdict: Runtime Error):
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
      
      	int v = 700;
      	for(int i = 0; i < S.length(); i++){
        if(S.charAt(i) == 'o'){
        	v += 100;
        }
      }
      
      System.out.println(v);
    }
}


Fixed submission:
s=input()
v=700
for i in range(3):
  S=s[i]
  if(S=="o"):v+=100
print(v)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter
import random
import numpy as np

n=int(input())
x=np.array(list(map(int,input().split())))
for i in range(n):
    y=np.delete(x,i)
    print(int(np.median(y)))

Fixed submission:
import sys
from collections import Counter
import random
import numpy as np

n=int(input())
x=np.array(list(map(int,input().split())))
z=sorted(x)
cand=[z[n//2-1],z[n//2]]
#print(int(np.median(x)))
dic={}
for i in range(n):
    a=x[i]
    if(a<=cand[0]):print(cand[1])
    else:print(cand[0])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter
import random

n=int(input())
x=list(map(int,input().split()))
xb=x.copy()
y=sorted(x)
c=n//2-1
for i in range(n):
    x=xb.copy()
    a=x.pop(i)
    z=y.copy()
    z.remove(a)
    print(z[c])

Fixed submission:
import sys
from collections import Counter
import random
import numpy as np

n=int(input())
x=np.array(list(map(int,input().split())))
z=sorted(x)
cand=[z[n//2-1],z[n//2]]
#print(int(np.median(x)))
dic={}
for i in range(n):
    a=x[i]
    if(a<=cand[0]):print(cand[1])
    else:print(cand[0])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter
import random

n=int(input())
x=list(map(int,input().split()))
z=x.copy()
c=n//2-1
for i in range(n):
    x=z.copy()
    x.pop(i)
    y=sorted(x)
    #print(y)
    print(y[c])

Fixed submission:
import sys
from collections import Counter
import random
import numpy as np

n=int(input())
x=np.array(list(map(int,input().split())))
z=sorted(x)
cand=[z[n//2-1],z[n//2]]
#print(int(np.median(x)))
dic={}
for i in range(n):
    a=x[i]
    if(a<=cand[0]):print(cand[1])
    else:print(cand[0])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
for i in range(a,b+1):
    if((i-a)<k or (b-i)<k):print(i)

Fixed submission:
a,b,k=map(int,input().split())
for i in range(a,min(b+1,a+k)):
    print(i)
if(a+k<b-k+1):
    for i in range(b-k+1,b+1):print(i)
else:
    for i in range(a+k,b+1):print(i)
Buggy python submission (verdict: Time Limit Exceeded):
x,y=map(int,input().split())
if(x==y):print(-1)
else:
  i=y
  while(1):
    if((x*i)%y!=0):
      print(x*i)
      break
    i+=1


Fixed submission:
x,y=map(int,input().split())
if(x%y==0):print(-1)
else:
  i=y
  while(1):
    if((x*i)%y!=0):
      print(x*i)
      break
    i+=1

Buggy python submission (verdict: Time Limit Exceeded):
x,y=map(int,input().split())
if(x==y):print(-1)
else:
  i=1
  while(1):
    if((x*i)%y!=0):
      print(x*i)
      break
    i+=1


Fixed submission:
x,y=map(int,input().split())
if(x%y==0):print(-1)
else:
  i=y
  while(1):
    if((x*i)%y!=0):
      print(x*i)
      break
    i+=1

Buggy python submission (verdict: Time Limit Exceeded):
x,y=map(int,input().split())
if(x==y):print(-1)
else:
  i=1
  while(1):
    if((x*i)%y!=0):
      print(x*i)
      break

Fixed submission:
x,y=map(int,input().split())
if(x%y==0):print(-1)
else:
  i=y
  while(1):
    if((x*i)%y!=0):
      print(x*i)
      break
    i+=1
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split("/"))
print("2018/"+string(b)+"/"+string(c))


Fixed submission:
a,b,c=map(str,input().split("/"))
print("2018/"+b+"/"+c)

Buggy python submission (verdict: Runtime Error):
a,b,c=map(string,input().split("/"))
print("2018/"+b+"/"+c)

Fixed submission:
a,b,c=map(str,input().split("/"))
print("2018/"+b+"/"+c)
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print((math.ceil((a+b)/2))


Fixed submission:
import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2))
Buggy python submission (verdict: Runtime Error):
import sys

a=input()
b=input()
c=[]
d=[]
for i in range(len(a)):
    c.append(a[i])
for i in range(len(b)):
    d.append(b[i])
c.sort()
d.reverse()
for i in range(len(a)):
    if(c[i]<d[i]):
        print("Yes")
        sys.exit()
if(len(a)<len(b)):
    if(a==b[0:len(a)]):
        print("Yes")
        sys.exit()
print("No")

Fixed submission:
import sys

a=input()
b=input()
c=[]
d=[]
for i in range(len(a)):
    c.append(a[i])
for i in range(len(b)):
    d.append(b[i])
c.sort()
d.sort()
d.reverse()
for i in range(min([len(a),len(b)])):
    if(c[i]<d[i]):
        print("Yes")
        sys.exit()
if(len(a)<len(b)):
    if(a==b[0:len(a)]):
        print("Yes")
        sys.exit()
print("No")

Buggy python submission (verdict: Runtime Error):
import sys

a=input()
b=input()
"""
if(len(a)>len(b)):
    print("Yes")
    sys.exit()
elif(len(a)<len(b)):
    print("No")
    sys.exit()
else:
"""
c=[]
d=[]
for i in range(len(a)):
    c.append(a[i])
for i in range(len(b)):
    d.append(b[i])
c.sort()
d.reverse()
for i in range(len(a)):
    if(c[i]<d[i]):
        print("Yes")
        sys.exit()
print("No")

Fixed submission:
import sys

a=input()
b=input()
c=[]
d=[]
for i in range(len(a)):
    c.append(a[i])
for i in range(len(b)):
    d.append(b[i])
c.sort()
d.sort()
d.reverse()
for i in range(min([len(a),len(b)])):
    if(c[i]<d[i]):
        print("Yes")
        sys.exit()
if(len(a)<len(b)):
    if(a==b[0:len(a)]):
        print("Yes")
        sys.exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
dlt=0
push=0
a.sort()
k=0
while(1):
    i=a[k+push]
    j=a.count(i)
    push+=j
    if(j>i):dlt+=j-i
    elif(i>j):dlt+=j
    if(k+push>=n):break
print(dlt)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
dlt=0
push=0
a.sort()
k=0
while(1):
  i=a[k+push]
  if(i>n):
    dlt+=1
    push+=1
  else:
    j=a.count(i)
    push+=j
    if(j>i):dlt+=j-i
    elif(i>j):dlt+=j
  if(k+push>=n):break
print(dlt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
dlt=0
already=[]
for i in a:
  if(i not in already):
    already.append(i)
    j=a.count(i)
    if(j>i):dlt+=j-i
    elif(i>j):dlt+=j

print(dlt)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
dlt=0
push=0
a.sort()
k=0
while(1):
  i=a[k+push]
  if(i>n):
    dlt+=1
    push+=1
  else:
    j=a.count(i)
    push+=j
    if(j>i):dlt+=j-i
    elif(i>j):dlt+=j
  if(k+push>=n):break
print(dlt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
dlt=0
while(len(a)):
  i=a[0]
  j=a.count(i)
  if(j>i):dlt+=j-i
  elif(i>j):dlt+=j
  for k in range(j):a.remove(i)
print(dlt)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
dlt=0
push=0
a.sort()
k=0
while(1):
  i=a[k+push]
  if(i>n):
    dlt+=1
    push+=1
  else:
    j=a.count(i)
    push+=j
    if(j>i):dlt+=j-i
    elif(i>j):dlt+=j
  if(k+push>=n):break
print(dlt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
dlt=0
while(len(a)):
  i=a[0]
  j=a.count(i)
  if(j>i):dlt+=j-i
  elif(i>j):dlt+=j
  while(i in a):a.remove(i)
print(dlt)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
dlt=0
push=0
a.sort()
k=0
while(1):
  i=a[k+push]
  if(i>n):
    dlt+=1
    push+=1
  else:
    j=a.count(i)
    push+=j
    if(j>i):dlt+=j-i
    elif(i>j):dlt+=j
  if(k+push>=n):break
print(dlt)
Buggy python submission (verdict: Runtime Error):
s=input()
num=0
if (s[0]==1):
  num++
if (s[1]==1):
  num++
if (s[2]==1):
  num++
print(num)

Fixed submission:
s=input()
num=0
if (s[0]=="1"):
  num+=1
if (s[1]=="1"):
  num+=1
if (s[2]=="1"):
  num+=1
print(num)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
kind=[]
count=1
for i in range(len(a)-1):
  if(a[i]==a[i+1]):count+=1
  else:
    kind.append(count)
    count=1
kind.append(count)
kind.sort()
change=0
for i in range(k):change+=kind.pop()
print(n-change)


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
kind=[]
count=1
for i in range(len(a)-1):
  if(a[i]==a[i+1]):count+=1
  else:
    kind.append(count)
    count=1
kind.append(count)
kind.sort()
change=0
for i in range(k):
  if(len(kind)!=0):change+=kind.pop()
print(n-change)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
kind=[]
count=1
for i in range(len(a)-1):
  if(a[i]==a[i+1]):count+=1
  else:
    kind.append(count)
    count=1
kind.append(count)
kind.sort()
change=0
while(len(kind)>k):
  change+=kind.pop(0)
print(change)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
kind=[]
count=1
for i in range(len(a)-1):
  if(a[i]==a[i+1]):count+=1
  else:
    kind.append(count)
    count=1
kind.append(count)
kind.sort()
change=0
for i in range(k):
  if(len(kind)!=0):change+=kind.pop()
print(n-change)
Buggy python submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
if ((N*A)>B):
  print(B)
elif:
  print(N*A)

Fixed submission:
N,A,B=map(int,input().split())
if ((N*A)>B):
  print(B)
else:
  print(N*A)
Buggy python submission (verdict: Runtime Error):
A=input()
B=input()
if(A[0]==B[2]&&A[1]==B[1]&&A[2]=B[0]):
  print("YES")
else:
  print("NO")

Fixed submission:
A=input()
B=input()
if(A[0]==B[2] and A[1]==B[1] and A[2]==B[0]):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
lis=[]
outp=[[0 for i in range(w)] for j in range(h)]
outs=[""]*h
for i in range(h):
    lis.append(input())
for i in range(h):
    for j in range(w):
        if(lis[i][j]=="#"):
            for k in range(-1,2):
                for l in range(-1,2):
                    if(i+k>=0 and i+k<w and j+l>=0 and j+l<h):
                        outp[i+k][j+l]+=1
for i in range(h):
    for j in range(w):
        if(lis[i][j]=="#"):
            outs[i]+="#"
        else:
            outs[i]+=str(outp[i][j])
for i in range(h):
    print(outs[i])

Fixed submission:
h,w=map(int,input().split())
lis=[]
outp=[[0 for i in range(w)] for j in range(h)]
outs=[""]*h
for i in range(h):
    lis.append(input())
for i in range(h):
    for j in range(w):
        if(lis[i][j]=="#"):
            for k in range(-1,2):
                for l in range(-1,2):
                    if(i+k>=0 and i+k<h and j+l>=0 and j+l<w):
                        outp[i+k][j+l]+=1
for i in range(h):
    for j in range(w):
        if(lis[i][j]=="#"):
            outs[i]+="#"
        else:
            outs[i]+=str(outp[i][j])
for i in range(h):
    print(outs[i])
Buggy python submission (verdict: Time Limit Exceeded):
import sys


n=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))
D.sort()
T.sort()
Dd={}
Td={}
Ds=set(D)
Ts=set(T)
for i in Ds:
    Dd[i]=D.count(i)
for i in Ts:
    Td[i]=T.count(i)
for i in Td.keys():
    if(i in Dd):
        if(Td[i]>Dd.get(i)):
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")

Fixed submission:
import sys
from collections import Counter


n=int(input())
Dc=Counter(input().split())
m=int(input())
Tc=Counter(input().split())
for key,val in Tc.items():
    if(val>Dc[key]):
        print("NO")
        sys.exit()
print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
import sys


n=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))
for i in T:
    if(i not in D):
        print("NO")
        sys.exit()
    else:
        D.remove(i)
print("YES")

Fixed submission:
import sys
from collections import Counter


n=int(input())
Dc=Counter(input().split())
m=int(input())
Tc=Counter(input().split())
for key,val in Tc.items():
    if(val>Dc[key]):
        print("NO")
        sys.exit()
print("YES")
Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int,input().split())
maxden = 0
amax = f //(a*100)
for i in range(amax+1):
  waterA = i*100*a
  res = f-waterA
  bmax = res // (b*100)
  for j in range(bmax+1):
    waterB = j*100*b
    waterS =waterA+waterB
    res = f-waterS
    cmax = res // c
    for k in range(cmax+1):
      sugarC = k*c
      res = f-waterS-sugarC
      dmax = res // d
      for l in range(dmax+1):
        sugarD = l*d
        sugarS = sugarC+sugarD
        if(sugarS+waterS==0):break
        den = (sugarS)*100/(sugarS+waterS)
        #if(den>49 and den<50.1):print(res-sugarD,waterA,waterB,sugarC,sugarD,den)
        if(den>maxden and (den/100)<=(e/(100+e))):
          maxden = den
          sugar = sugarS
          water = waterS

print(str(water+sugar)+" "+str(sugar))

Fixed submission:
a,b,c,d,e,f = map(int,input().split())
maxden = 0
amax = f //(a*100)
water=a*100
sugar=0
for i in range(amax+1):
  waterA = i*100*a
  res = f-waterA
  bmax = res // (b*100)
  for j in range(bmax+1):
    waterB = j*100*b
    waterS =waterA+waterB
    res = f-waterS
    cmax = res // c
    for k in range(cmax+1):
      sugarC = k*c
      res = f-waterS-sugarC
      dmax = res // d
      for l in range(dmax+1):
        sugarD = l*d
        sugarS = sugarC+sugarD
        if(sugarS+waterS==0):break
        den = (sugarS)*100/(sugarS+waterS)
        #if(den>49 and den<50.1):print(res-sugarD,waterA,waterB,sugarC,sugarD,den)
        #if(sugarS==146 and waterS==200):print(waterS,sugarS,den,(den*(100+e))/100,e)
        #if(sugarS==582 and waterS==800):print(waterS,sugarS,den,(den*(100+e))/100,e)
        if(den>maxden and (den*(100+e)/100)-e<=10**-5):
          maxden = den
          sugar = sugarS
          water = waterS

print(str(water+sugar)+" "+str(sugar))
#print(maxden)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
outp=[]
for i in range(n):
  outp.append(int(input()))
num=0
for j in list(set(outp)):
  num+=outp.count(j)%2
print(num)


Fixed submission:
n=int(input())
outp=set()
for i in range(n):
  a=int(input())
  if(a in outp):outp.remove(a)
  else:outp.add(a)
print(len(outp))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
outp=[]
for i in range(n):
  a=int(input())
  if(a in outp):outp.remove(a)
  else:outp.append(a)
print(len(outp))

Fixed submission:
n=int(input())
outp=set()
for i in range(n):
  a=int(input())
  if(a in outp):outp.remove(a)
  else:outp.add(a)
print(len(outp))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=set(a)
mx=0
for i in b:
  mx=max(mx,a.count(i-1)+a.count(i+1)+a.count(i))
print(mx)

Fixed submission:
from collections import *
n=int(input())
a=list(map(int,input().split()))
b=set(a)
d=defaultdict(int)
mx=0
for i in a:
  d[i]+=1
for i in b:
  mx=max(mx,d[i-1]+d[i]+d[i+1])
print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import *
n=int(input())
a=list(map(int,input().split()))
#a.sort()
b=sorted(set(a))[::-1]
wid=0
hei=0
for i in b:
  c=a.count(i)
  if(c>3):
    if(hei==0):
      hei,wid=i,i
    elif(wid==0):
      wid=i
    break
  elif(c>1):
    if(hei==0):hei=i
    elif(wid==0):
      wid=i
      break
print(wid*hei)

Fixed submission:
from collections import *
n=int(input())
a=list(map(int,input().split()))
b=sorted(set(a))[::-1]
d=defaultdict(int)
wid=0
hei=0
for i in a:
  d[i]+=1
for i in b:
  if(d[i]>3):
    if(wid==0):wid,hei=i,i
    else:hei=i
    break
  elif(d[i]>1):
    if(wid==0):wid=i
    else:
      hei=i
      break
print(wid*hei)
Buggy python submission (verdict: Runtime Error):
import sys
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
if(n==2):
  mi=abs(a[0]-a[1])
else:
  s1=a[0]
  for i in range(1,len(a)-1):
    s1+=a[i]
    s2=s-s1
    #print(s1,s2)
    mi=min([mi,abs(s1-s2)])
print(mi)


Fixed submission:
import sys
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
if(n==2):
  mi=abs(a[0]-a[1])
else:
  mi=10**15
  s1=a[0]
  for i in range(1,len(a)-1):
    s1+=a[i]
    s2=s-s1
    #print(s1,s2)
    mi=min([mi,abs(s1-s2)])
print(mi)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
mi=10**15
for i in range(1,len(a)):
  s1=sum(a[0:i])
  s2=s-s1
  #print(s1,s2)
  mi=min([mi,abs(s1-s2)])
print(mi)

Fixed submission:
import sys
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
if(n==2):
  mi=abs(a[0]-a[1])
else:
  mi=10**15
  s1=a[0]
  for i in range(1,len(a)-1):
    s1+=a[i]
    s2=s-s1
    #print(s1,s2)
    mi=min([mi,abs(s1-s2)])
print(mi)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in a:
  b.append(i)
  b.reverse()
outp=str(b[0])
for i in range(1,n):outp+=" "+str(b[i])
print(outp)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=a[::-2]
if(n%2==1):c=a[1::2]
else:c=a[::2]
#print(b)
#print(c)
outp=str(b[0])
for i in range(1,len(b)):outp+=" "+str(b[i])
for i in range(len(c)):outp+=" "+str(c[i])
print(outp)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

res=10**9+7
def permutation(n):
  x=1
  for i in range(n):x=(x*(i+1))
  return(x)
n,m=map(int,input().split())
n%=res
m%=res
if(n>m+1 or m>n+1):
  print(0)
elif(n==m):
  p=permutation(n)
  print((2*p*p)%res)
else:
  ma=max(n,m)
  p=permutation(ma)
  p2=p//ma
  print((p*p2)%res)


Fixed submission:
import sys

res=10**9+7
def permutation(n):
  x=1
  for i in range(n):x=(x*(i+1))%res
  return(x%res)
n,m=map(int,input().split())
n%=res
m%=res
if(n>m+1 or m>n+1):
  print(0)
elif(n==m):
  p=permutation(n)
  print((2*p*p)%res)
else:
  mi=min(n,m)
  p=permutation(mi)
  p2=p*max(n,m)
  print((p*p2)%res)
Buggy python submission (verdict: Runtime Error):
import sys
n,k=map(int,input().split())
ab=[[0,0]for i in range(n)]
for i in range(n):
  ab[i][0],ab[i][1]=map(int,input.split())
ab.sort()
x=0
for i in range(n):
  x+=ab[i][1]
  if(x>=k):
    print(ab[i][0])
    sys.exit()
print(ab[-1][0])

Fixed submission:
import sys
n,k=map(int,input().split())
ab=[[0,0]for i in range(n)]
for i in range(n):
  ab[i][0],ab[i][1]=map(int,input().split())
ab.sort()
x=0
for i in range(n):
  x+=ab[i][1]
  if(x>=k):
    print(ab[i][0])
    sys.exit()
print(ab[-1][0])