Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
l=[]

def detain(n,a,b,c,l):
    
    n,a,b,c=map(int,input().split())
    for i in range(n):
        li=int(input())
        l.append(li)
    return


detain(n,a,b,c,l)
d=[a,b,c]
d.sort()

mpmin=sum(l)*4+len(l)*10
for i in range(4**n):
    k=[]
    kj=i%4
    k.append(kj)
    b=int((i-kj)/4)
    l0=[]
    l1=[]
    l2=[]
    l3=[]
    if kj==0:
        l0.append(l[0])
    elif kj==1:
        l1.append(l[0])
    elif kj==2:
        l2.append(l[0])
    elif kj==3:
        l3.append(l[0])
        
    for j in range(n-1):
        kj=b%4
        k.append(kj)
        b=int((b-kj)/4)
        if kj==0:
            l0.append(l[j+1])
        elif kj==1:
            l1.append(l[j+1])
        elif kj==2:
            l2.append(l[j+1])
        elif kj==3:
            l3.append(l[j+1])
    mp=0
    if len(l0)>=1:
        mp=mp+(len(l0)-1)*10
    if len(l1)>=1:
        mp=mp+(len(l1)-1)*10
    if len(l2)>=1:
        mp=mp+(len(l2)-1)*10
    ls=[]
    ls=[sum(l0),sum(l1),sum(l2)]
    ls.sort()
    mp=mp+abs(d[0]-ls[0])+abs(d[1]-ls[1])+abs(d[2]-ls[2])    
    if mpmin>mp and len(l0)>=1 and len(l1)>=1 and len(l2)>=1:
        mpmin=mp
print(mpmin)        
        

Fixed submission:
l=[]
n,a,b,c=map(int,input().split())
for i in range(n):
    li=int(input())
    l.append(li)

d=[a,b,c]
d.sort()

mpmin=sum(l)*4+len(l)*10+sum(d)
for i in range(4**n):
    k=[]
    kj=i%4
    k.append(kj)
    b=int((i-kj)/4)
    l0=[]
    l1=[]
    l2=[]
    l3=[]
    if kj==0:
        l0.append(l[0])
    elif kj==1:
        l1.append(l[0])
    elif kj==2:
        l2.append(l[0])
    elif kj==3:
        l3.append(l[0])
        
    for j in range(n-1):
        kj=b%4
        k.append(kj)
        b=int((b-kj)/4)
        if kj==0:
            l0.append(l[j+1])
        elif kj==1:
            l1.append(l[j+1])
        elif kj==2:
            l2.append(l[j+1])
        elif kj==3:
            l3.append(l[j+1])
    mp=0
    if len(l0)>=1:
        mp=mp+(len(l0)-1)*10
    if len(l1)>=1:
        mp=mp+(len(l1)-1)*10
    if len(l2)>=1:
        mp=mp+(len(l2)-1)*10
    ls=[]
    ls=[sum(l0),sum(l1),sum(l2)]
    ls.sort()
    mp=mp+abs(d[0]-ls[0])+abs(d[1]-ls[1])+abs(d[2]-ls[2])    
    if mpmin>mp and len(l0)>=1 and len(l1)>=1 and len(l2)>=1:
        mpmin=mp
print(mpmin)
Buggy python submission (verdict: Runtime Error):

import sys

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

if k==0:
    print(sum(a))
    sys.exit()
    
kk=[]
kkk=k
kcnt=0
while kkk>0:
    kk.append(kkk%2)
    kcnt+=1
    kkk=kkk//2
#print(kcnt)    
    
f=[0]*kcnt
for ai in a:
    icnt=0
    while ai>0:
        f[icnt]+=ai%2
        ai=ai//2
        icnt+=1

n2=n//2
smax=0
idx=1
for i in range(len(f)):
    if f[i]>n2:
        smax+=idx*f[i]
    else:
        smax+=idx*(n-f[i])
    idx*=2

print(smax)        

Fixed submission:
import sys

icase=0
if icase==0:
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
elif icase==1:
    n,k=4,9
    a=[7,4,0,3]
elif icase==2:
    n,k=3,7
    a=[1,6,3]
elif icase==3:
    n,k=1,0
    a=[1000000000000]

if k==0:
    print(sum(a))
    sys.exit()
    
kk=[0]*42
kkk=k
kcnt=0
while kkk>0:
    kk[kcnt]=kkk%2
    kcnt+=1
    kkk=kkk//2
    
f=[0]*42
for ai in a:
    icnt=0
    while ai>0:
        f[icnt]+=ai%2
        ai=ai//2
        icnt+=1

n2=n//2+1
fm=[0]*42

flg1=0
flg2=0
for i in range(41,-1,-1):
    if flg1==0 and kk[i]==0:
        fm[i]=0
    if flg1==0 and kk[i]==1:
        flg1=1
    if flg1==0:
        fm[i]=f[i]        
        continue
#  case : flg1=1
    if kk[i]==1 and f[i]>=n2 and flg2==0:
        flg2=1
    if kk[i]==1 or (kk[i]==0 and flg2==1):
        if f[i]<n2:
            fm[i]=n-f[i]
        else:
            fm[i]=f[i]        
    else:
        fm[i]=f[i]        
    
smax=0
idx=1
for i in range(len(fm)):
    smax+=idx*fm[i]
    idx*=2

print(smax)
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[]
y=[]
h=[]

for i in range(n):
    xi,yi,hi=map(int,input().split())
    x.append(xi)
    y.append(yi)
    h.append(hi)

hmax=h[0]
xhmax=x[0]
yhmax=y[0]
ihmax=0

for i in range(n):
    if hmax<h[i]:
        hmax=h[i]
        xhmax=x[i]
        yhmax=y[i]
        ihmax=i
    
for cx in range(101):
    for cy in range(101):
        hh=hmax+abs(xhmax,cx)+abs(yhmax,cy)
        yesno="yes"
        for i in range(n):
            if h[i]!=max(hh-abs(x[i],cx)-abs(y[i],cy),0):
                yesno="no"
                break
        if yesno=="yes":
            print(cx,cy,hh)


Fixed submission:
def abs(x1,x2):
    if x1>x2:
        return x1-x2
    else:
        return x2-x1
    
n=int(input())
x=[]
y=[]
h=[]

for i in range(n):
    xi,yi,hi=map(int,input().split())
    x.append(xi)
    y.append(yi)
    h.append(hi)

hmax=h[0]
xhmax=x[0]
yhmax=y[0]
ihmax=0

for i in range(n):
    if hmax<h[i]:
        hmax=h[i]
        xhmax=x[i]
        yhmax=y[i]
        ihmax=i
    
for cx in range(101):
    for cy in range(101):
        hh=hmax+abs(xhmax,cx)+abs(yhmax,cy)
        yesno="yes"
        for i in range(n):
            if h[i]!=max(hh-abs(x[i],cx)-abs(y[i],cy),0):
                yesno="no"
                break
        if yesno=="yes":
            print(cx,cy,hh)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()

st=[]
for i in range(len(s)):
    st.append([s[i],t[i]])
#print(st)
st.sort()
#print(st)
    
for i in range(len(st)-1):
    if st[len(st)-i-1]==st[len(st)-i-2]:
        del st[len(st)-i-1]
        
#print(st)

yesno="Yes"
for i in range(len(st)-1):
    sj,tj=st[len(st)-i-1]
    sk,tk=st[len(st)-i-2]
    if sj==sk and tj!=tk:
        yesno="No"
        break
    
print(yesno)

Fixed submission:
s=input()
t=input()

st=[]
ts=[]
for i in range(len(s)):
    st.append([s[i],t[i]])
    ts.append([t[i],s[i]])
#print(st)
st.sort()
ts.sort()
#print(st)
    
yesno="Yes"
for i in range(len(st)-1):
    sj,tj=st[len(st)-i-1]
    sk,tk=st[len(st)-i-2]
    if sj==sk and tj!=tk:
        yesno="No"
        break
    tj,sj=ts[len(ts)-i-1]
    tk,sk=ts[len(ts)-i-2]
    if tj==tk and sj!=sk:
        yesno="No"
        break
    
print(yesno)
Buggy python submission (verdict: Runtime Error):

from functools import reduce
from fanctions import gcd
#from math import gcd

n,x0=map(int,input().split())
x=list(map(int,input().split()))

for i in range(n):
    x[i]=abs(x[i]-x0)

print(reduce(gcd, x))
 

Fixed submission:
def gcdf(a):
    a.sort()
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 
    
n,x=map(int,input().split())
xi=list(map(int,input().split()))

for i in range(n):
    if xi[i]>x:
        xi[i]=xi[i]-x
    else:
        xi[i]=x-xi[i]
    
gcdx=gcdf(xi)
print(gcdx)

Buggy python submission (verdict: Runtime Error):

from functools import reduce
from math import gcd

n,x0=map(int,input().split())
x=list(map(int,input().split()))

for i in range(n):
    x[i]=abs(x[i]-x0)

print(reduce(gcd, x))
    

Fixed submission:
def gcdf(a):
    a.sort()
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 
    
n,x=map(int,input().split())
xi=list(map(int,input().split()))

for i in range(n):
    if xi[i]>x:
        xi[i]=xi[i]-x
    else:
        xi[i]=x-xi[i]
    
gcdx=gcdf(xi)
print(gcdx)
Buggy python submission (verdict: Runtime Error):
import math

s=input()
k=int(input())

ss=[]
cont0=0
cont1=0
for i in range(len(s)):
    if s[i]!="1":
        ss.append(int(s[i]))
    else:
        if len(ss)==0:
            cont0=cont0+1
        else:
            cont1=cont1+1
        
k=k-cont0
logk=math.log10(k)
    
n=5000*10000**3

if len(ss)==0:
    print(1)
else:
    logketa=n*math.log10(ss[0])
    if logketa>logk:
        print(ss[0])
    else:
        print(ss[1])

Fixed submission:
import math

s=input()
k=int(input())

ss=[]
cont0=0
cont1=0
for i in range(len(s)):
    if s[i]!="1":
        ss.append(int(s[i]))
    else:
        if len(ss)==0:
            cont0=cont0+1
        else:
            cont1=cont1+1
        
k=k-cont0
    
n=5000*10000**3

if len(ss)==0:
    print(1)
elif k<=0:
    print(1)
else:
    logk=math.log10(k)

    logketa=n*math.log10(ss[0])
    if logketa>logk:
        print(ss[0])
    else:
        print(ss[1])

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

s=input()
k=int(input())

logk=math.log10(k)

ss=[]
for i in range(len(s)):
    if s[i]!="1":
        ss.append(int(s[i]))
    
n=5000*10000**3

logketa=n*math.log10(ss[0])
if logketa>logk:
    print(ss[0])
else:
    print(ss[1])


Fixed submission:
import math

s=input()
k=int(input())

ss=[]
cont0=0
cont1=0
for i in range(len(s)):
    if s[i]!="1":
        ss.append(int(s[i]))
    else:
        if len(ss)==0:
            cont0=cont0+1
        else:
            cont1=cont1+1
        
k=k-cont0
    
n=5000*10000**3

if len(ss)==0:
    print(1)
elif k<=0:
    print(1)
else:
    logk=math.log10(k)

    logketa=n*math.log10(ss[0])
    if logketa>logk:
        print(ss[0])
    else:
        print(ss[1])
Buggy python submission (verdict: Time Limit Exceeded):
n,m,q=map(int,input().split())

lr=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
    li,ri=map(int,input().split())
    lr[li][ri]+=1
    
for i in range(n+1):
    asum=0
    for j in range(n+1):
        asum+=lr[i][j]
        lr[i][j]=asum
            
for i in range(q):
    pi,qi=map(int,input().split())
#    pi-=1
#    qi-=1
    asum=0
    for j in range(pi,qi+1):
#        print("j:",j,"j-1",j-1,"qo:",qi,lr[j][qi]-lr[j][j-1])
        asum+=lr[j][qi]-lr[j][j-1]
    print(asum)


Fixed submission:
n,m,q=map(int,input().split())

lr=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
    li,ri=map(int,input().split())
    lr[li][ri]+=1
    
for i in range(n+1):
    asum=0
    for j in range(n+1):
        asum+=lr[i][j]
        lr[i][j]=asum
            
for i in range(q):
    pi,qi=map(int,input().split())
#    pi-=1
#    qi-=1
    asum=0
    for j in range(pi,qi+1):
#        print("j:",j,"j-1",j-1,"qo:",qi,lr[j][qi]-lr[j][j-1])
        asum+=lr[j][qi]-lr[j][j-1]
    print(asum)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

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

agcd=gcd(a[0],a[1])
alcm=a[0]*a[1]//agcd
for i in range(n-2):
    agcd=gcd(alcm,a[i+2])
    alcm=alcm*a[i+2]//agcd
    
#print(alcm)
    
if 1==1:
    fmax=0
    for i in range(alcm):
        f=0
        for j in range(n):
            f=f+(i%a[j])
        if f>fmax:
            fmax=f
    print(fmax)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))

s=0
for i in range(n):
    s=s+a[i]-1
    
print(s)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split()
if a<=8 and b<=8:
    print("Yay!")
else:
    print(":(")
        

Fixed submission:
a,b=map(int,input().split())
if a<=8 and b<=8:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

n9=9**5
n6=6**6

k9=5+1
k6=6+1
n9=9**k9
smin=n
for i9 in range(n9):
    ii9=i9
    s=0
    m=0
    astr=""
    for ii in range(1,k9+1):
        r9=ii9%9
        ii9=(ii9-r9)//9    
        s=s*9+r9
        m=m+r9
        astr=astr+str(r9)
#    print("i9",i9,"astr",astr,"s",s,"m",m)
    
    nr=n-s
    nr1=nr
#    print("nr",nr,"m",m)
    
    if nr==0:
        snra=m
#        print(nr,m)
    elif nr>0:
        snra=m
        for jj in range(k6,-1,-1):
            nra=nr1//(6**jj)
            nr1=nr1%(6**jj)
            snra=snra+nra
#        print("jj",jj,"nra",nra,"nr1",nr1)
    if smin>snra:
        smin=snra
print(smin)

Fixed submission:
n=int(input())

k9=5
k6=6
n9=9**k9
smin=n
for i9 in range(n9):
    ii9=i9
    s=0
    m=0
    astr=""
    for ii in range(1,k9+2):
        r9=ii9%9
        ii9=(ii9-r9)//9    
        s=s*9+r9
        m=m+r9
        astr=astr+str(r9)
#    print("i9",i9,"astr",astr,"s",s,"m",m)
    
    nr=n-s
    nr1=nr
#    print("nr",nr,"m",m)
    
    if nr==0:
        snra=m
#        print(nr,m)
    elif nr>0:
        snra=m
        for jj in range(k6,-1,-1):
            nra=nr1//(6**jj)
            nr1=nr1%(6**jj)
            snra=snra+nra
#        print("jj",jj,"nra",nra,"nr1",nr1)
    if smin>snra:
        smin=snra
print(smin)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
k=int(input())
#s=list(input())

#t=[]
#for kk in range(k):
#    t.append(s)

t=["zzzzz"]*k

for i in range(len(s)):
    for j in range(i,len(s)):
        sij=s[i:j+1]
        for kk in range(k):
            if t[kk]==sij:
                break
        if t[kk]>sij:
            t[kk]=sij
            t.sort()
        
print(t[k-1])  
#print(t) 

Fixed submission:
s=input()
k=int(input())
#s=list(input())

#t=[]
#for kk in range(k):
#    t.append(s)

t=["zzzzz"]*k

for i in range(len(s)):
    for j in range(i,min(len(s),i+k)):
        sij=s[i:j+1]
        for kk in range(k):
            if t[kk]==sij:
                break
        if t[kk]>sij:
            t[kk]=sij
            t.sort()
        
print(t[k-1])  
#print(t)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
k=int(input())
#s=list(input())

t=[]
d=dict()
di=0
for i in range(len(s)):
    for j in range(i,len(s)):
        if s[i:j+1] not in d:
            di=di+0
            d[s[i:j+1]]=di
            
d_sorted = sorted(d.items(), key=lambda x:x[0])
            
astr=d_sorted[k-1][0]
        
print(astr)   

Fixed submission:
s=input()
k=int(input())
#s=list(input())

#t=[]
#for kk in range(k):
#    t.append(s)

t=["zzzzz"]*k

for i in range(len(s)):
    for j in range(i,min(len(s),i+k)):
        sij=s[i:j+1]
        for kk in range(k):
            if t[kk]==sij:
                break
        if t[kk]>sij:
            t[kk]=sij
            t.sort()
        
print(t[k-1])  
#print(t)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
k=int(input())
#s=list(input())

t=[]
for i in range(len(s)):
    for j in range(i,len(s)):
        t.append(s[i:j+1])
        
t.sort()
t1=t[0]
t2=[t[0]]
kk=0
for i in range(1,len(t)):
    if t1!=t[i]:
        t2.append(t[i])
        t1=t[i]
        kk=kk+1
        if kk==k-1:
            break
        
print(t2[k-1])        

Fixed submission:
s=input()
k=int(input())
#s=list(input())

#t=[]
#for kk in range(k):
#    t.append(s)

t=["zzzzz"]*k

for i in range(len(s)):
    for j in range(i,min(len(s),i+k)):
        sij=s[i:j+1]
        for kk in range(k):
            if t[kk]==sij:
                break
        if t[kk]>sij:
            t[kk]=sij
            t.sort()
        
print(t[k-1])  
#print(t)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
k=int(input())
#s=list(input())

t=[]
for i in range(len(s)):
    for j in range(i,len(s)):
        t.append(s[i:j+1])
        
t.sort()
t1=t[0]
t2=[t[0]]
for i in range(1,len(t)):
    if t1!=t[i]:
        t2.append(t[i])
        t1=t[i]
        
print(t2[k-1])        
        

Fixed submission:
s=input()
k=int(input())
#s=list(input())

#t=[]
#for kk in range(k):
#    t.append(s)

t=["zzzzz"]*k

for i in range(len(s)):
    for j in range(i,min(len(s),i+k)):
        sij=s[i:j+1]
        for kk in range(k):
            if t[kk]==sij:
                break
        if t[kk]>sij:
            t[kk]=sij
            t.sort()
        
print(t[k-1])  
#print(t)
Buggy python submission (verdict: Runtime Error):

from bisect import bisect_left,bisect

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

a.sort()
ai=max(a)


if ai%2==0:
    ai2=ai//2-1
else:
    ai2=ai//2

jj=bisect(a,ai2)

if jj+1<n:
    if abs(a[jj]-ai2)>abs(a[jj+1]-ai2):
        jj2=jj+1
if jj-1>=0:
    if abs(a[jj]-ai2)>abs(a[jj-1]-ai2):
        jj2=jj-1
    
if jj2==n-1:
    jj2=jj2-1
    
aj=a[jj2]

print(ai,aj)



Fixed submission:

from bisect import bisect_left,bisect

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

a.sort()
ai=max(a)


#if ai%2==0:
#    ai2=ai//2+1
#else:
#    ai2=ai//2
ai2=ai/2

jj=bisect(a,ai2)

if jj+1<n:
    if abs(a[jj]-ai2)>abs(a[jj+1]-ai2):
        jj=jj+1
if jj-1>=0:
    if abs(a[jj]-ai2)>abs(a[jj-1]-ai2):
        jj=jj-1
    
if jj==n-1:
    jj=jj-1
    
aj=a[jj]

print(ai,aj)

Buggy python submission (verdict: Runtime Error):

from bisect import bisect_left,bisect

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

a.sort()
ai=max(a)


if ai%2==0:
    ai2=ai//2-1
else:
    ai2=ai//2

jj=bisect(a,ai2)

if abs(a[jj]-ai2)>abs(a[jj-1]-ai2):
    jj=jj+1
    
if jj==n-1:
    jj=jj-1
    
aj=a[jj]

print(ai,aj)


Fixed submission:

from bisect import bisect_left,bisect

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

a.sort()
ai=max(a)


#if ai%2==0:
#    ai2=ai//2+1
#else:
#    ai2=ai//2
ai2=ai/2

jj=bisect(a,ai2)

if jj+1<n:
    if abs(a[jj]-ai2)>abs(a[jj+1]-ai2):
        jj=jj+1
if jj-1>=0:
    if abs(a[jj]-ai2)>abs(a[jj-1]-ai2):
        jj=jj-1
    
if jj==n-1:
    jj=jj-1
    
aj=a[jj]

print(ai,aj)

Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left,bisect

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

a.sort()
ai=max(a)


if ai%2==0:
    ai2=ai//2-1
else:
    ai2=ai//2

jj=bisect(a,ai2)

if abs(a[jj]-ai2)>abs(a[jj+1]-ai2):
    jj=jj+1
    
if jj==n-1:
    jj=jj-1
    
aj=a[jj]

print(ai,aj)


Fixed submission:

from bisect import bisect_left,bisect

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

a.sort()
ai=max(a)


#if ai%2==0:
#    ai2=ai//2+1
#else:
#    ai2=ai//2
ai2=ai/2

jj=bisect(a,ai2)

if jj+1<n:
    if abs(a[jj]-ai2)>abs(a[jj+1]-ai2):
        jj=jj+1
if jj-1>=0:
    if abs(a[jj]-ai2)>abs(a[jj-1]-ai2):
        jj=jj-1
    
if jj==n-1:
    jj=jj-1
    
aj=a[jj]

print(ai,aj)
Buggy python submission (verdict: Time Limit Exceeded):
icase=0
if icase==0:
    a,b,k=map(int,input().split()) 
    ab=[]
    for i in range(a,b+1):
        if i<=a+k-1 or b-k+1<=i:
            print(i)


Fixed submission:
icase=0
if icase==0:
    a,b,k=map(int,input().split()) 
    if a+k-1<b-k+1:
        for i in range(a,a+k):
            print(i)
        for i in range(b-k+1,b+1):
            print(i)
    else:
        for i in range(a,b+1):
            print(i)

Buggy python submission (verdict: Time Limit Exceeded):
icase=0
if icase==0:
    a,b,k=map(int,input().split()) 
    ab=[]
    for i in range(a,b+1):
#        print(i,a+k-1,b-k+1)
        if i<=a+k-1 or b-k+1<=i:
            ab.append(i)
    for i in range(len(ab)):
        print(ab[i])
        


Fixed submission:
icase=0
if icase==0:
    a,b,k=map(int,input().split()) 
    if a+k-1<b-k+1:
        for i in range(a,a+k):
            print(i)
        for i in range(b-k+1,b+1):
            print(i)
    else:
        for i in range(a,b+1):
            print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n,y=map(int,input().split())

yn=""
na=y//10000
nb=y//5000
for a in range(na+1):
    for b in range(nb+1):
        if y==10000*a+5000*b+1000*(n-a-b) and n>=a+b:
            print(a,b,n-a-b)
            yn="YES"
            break
    if yn=="YES":
        break
if yn!="YES":
    print(-1,-1,-1)
        

Fixed submission:
n,y=map(int,input().split())
    
n10max=y//10000
n5max=y//5000

iskip=0
for n10 in range(n10max,-1,-1):
    if n10*10000>y:
        continue
    for n5 in range(min(n-n10,n5max)+1):
        n1=n-n10-n5
        if n10*10000+n5*5000+n1*1000==y and n1>=0:
            print(n10,n5,n-n10-n5)
            iskip=1
            break
        else:
            continue
    if iskip==1:
        break
    else:
        continue
        
if iskip==0:
    print(-1,-1,-1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

a.sort()
amax=a[-1]
amin=a[0]

dn=0
for i in range(amin,amax+1):
    ni=a.count(i)
    if ni>i:
        dn=dn+(ni-i)
    elif ni<i:
        dn=dn+ni

print(dn)        


Fixed submission:
n=int(input())
a=list(map(int,input().split()))

a.sort()
amax=a[-1]
amin=a[0]

s=[]
ai=a[0]
acnt=-1
for i in range(n):
    if a[i]>ai:
        s.append([ai,acnt+1])
        acnt=0
        ai=a[i]
    else:
        acnt=acnt+1
s.append([ai,acnt+1])
        
# print(s)
    
dn=0
for i in range(len(s)):
    ni=s[i][1]
    if ni>s[i][0]:
        dn=dn+(ni-s[i][0])
    elif ni<s[i][0]:
        dn=dn+ni

print(dn)
Buggy python submission (verdict: Runtime Error):

icase=0
if icase==0:
    n=int(input())

    f=[]
    for i in range(n):
        fi=map(int,input().split())
        f.append(fi)
    p=[]
    for i in range(n):
        pi=map(int,input().split())
        p.append(pi)
elif icase==1: 
    n=1
    f=[[1, 1, 0, 1, 0, 0, 0, 1, 0, 1]]
    p=[[3, 4, 5, 6, 7, 8, 9, -2, -3, 4, -2]]
elif icase==2: 
    n=2
    f=[[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]]
    p=[[0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1],
       [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1]]
elif icase==3: 
    n=3
    f=[[1, 1, 1, 1, 1, 1, 0, 0, 1, 1],
       [0, 1, 0, 1, 1, 1, 1, 0, 1, 0],
       [1, 0, 1, 1, 0, 1, 0, 1, 0, 1]]
    p=[[-8, 6, -2, -8, -8, 4, 8, 7, -6, 2, 2],
       [-9, 2, 0, 1, 7, -5, 0, -2, -6, 5, 5],
       [6, -6, 7, -9, 6, -5, 8, 0, -9, -7, -7]]
    
import itertools
sumpmax=-10**11
for i in itertools.product([0,1], repeat=10):
    r=list(i)
    sump=0
    if sum(r)!=0:
        for jj in range(n):
            ci=0
            for j in range(10):
                ci=ci+r[j]*f[jj][j]
            sump=sump+p[jj][ci]
#            print(sump,r)
        sumpmax=max(sump,sumpmax)
print(sumpmax)
        


Fixed submission:
icase=0
if icase==0:
    n=int(input())

    f=[]
    for i in range(n):
        fi=list(map(int,input().split()))
        f.append(fi)
    p=[]
    for i in range(n):
        pi=list(map(int,input().split()))
        p.append(pi)
elif icase==1: 
    n=1
    f=[[1, 1, 0, 1, 0, 0, 0, 1, 0, 1]]
    p=[[3, 4, 5, 6, 7, 8, 9, -2, -3, 4, -2]]
elif icase==2: 
    n=2
    f=[[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]]
    p=[[0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1],
       [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1]]
elif icase==3: 
    n=3
    f=[[1, 1, 1, 1, 1, 1, 0, 0, 1, 1],
       [0, 1, 0, 1, 1, 1, 1, 0, 1, 0],
       [1, 0, 1, 1, 0, 1, 0, 1, 0, 1]]
    p=[[-8, 6, -2, -8, -8, 4, 8, 7, -6, 2, 2],
       [-9, 2, 0, 1, 7, -5, 0, -2, -6, 5, 5],
       [6, -6, 7, -9, 6, -5, 8, 0, -9, -7, -7]]
    
import itertools
sumpmax=-10**11
for i in itertools.product([0,1], repeat=10):
    r=list(i)
    sump=0
    if sum(r)!=0:
        for jj in range(n):
            ci=0
            for j in range(10):
                ci=ci+r[j]*f[jj][j]
            sump=sump+p[jj][ci]
#            print(sump,r)
        sumpmax=max(sump,sumpmax)
print(sumpmax)
Buggy python submission (verdict: Runtime Error):
icase=0
if icase==0:
    x,y,z=map(int,input().split())
    n=x//(y+z)
    if x%(y+z)>=z:
        print(n)
    else:
        print(n-1

Fixed submission:
icase=0
if icase==0:
    x,y,z=map(int,input().split())
    n=x//(y+z)
    if x%(y+z)>=z:
        print(n)
    else:
        print(n-1)