Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,k=map(int, input().split())
a=list(map(int, input().split()))
a2=[0]
for i in a:
    a2.append(a2[-1]+i)
c=dict()
for i in range(n+1):
    for j in range(i,n+1):
        if j>i:
            c[a2[j]-a2[i]]=c.get(a2[j]-a2[i],0)+1
keys=list(c.keys())
keys.sort()
keys2=[bin(i).split('b')[1] for i in keys]
maxb=len(keys2[-1])
keys2=[i.zfill(maxb) for i in keys2]
bin_list=[]
for i in keys2:
    bin_list.append(list(map(int,list(i))))
bin_list=np.array(bin_list)
for i,j in enumerate(keys):
    bin_list[i]=bin_list[i]*c[j]
bin_list
ans=0
l=0
while l<maxb:
    if bin_list[:,l].sum()>=k:
        ans+=2**(maxb-l-1)
        bin_list=bin_list[bin_list[:,l]>0]
    l+=1
print(ans)

Fixed submission:
n,k=map(int, input().split())
a=list(map(int, input().split()))
a2=[0]
for i in a:a2.append(a2[-1]+i)
c=[]
for i in range(0,n+1):
    for j in range(i+1,n+1):c.append(a2[j]-a2[i])

ans=0
for i in range(40,-1,-1):
    n2=2**i
    c2=[i for i in c if i&n2==n2]
    if len(c2)>=k:
        ans+=n2
        c=c2
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,k=map(int, input().split())
a=list(map(int, input().split()))
a2=[0]
for i in a:
    a2.append(a2[-1]+i)
c=dict()
for i in range(n+1):
    for j in range(i,n+1):
        if j>i:
            c[a2[j]-a2[i]]=c.get(a2[j]-a2[i],0)+1
keys=list(c.keys())
keys.sort()
keys2=[bin(i).split('b')[1] for i in keys]
maxb=len(kyes2[-1])
keys2=[i.zfill(maxb) for i in keys2]
bin_list=[]
for i in keys2:
    bin_list.append(list(map(int,list(i))))
bin_list=np.array(bin_list)
for i,j in enumerate(keys):
    bin_list[i]=bin_list[i]*c[j]
bin_list
ans=0
l=0
while l<maxb:
    if bin_list[:,l].sum()>=k:
        ans+=2**(maxb-l-1)
        bin_list=bin_list[bin_list[:,l]>0]
    l+=1
print(ans)

Fixed submission:
n,k=map(int, input().split())
a=list(map(int, input().split()))
a2=[0]
for i in a:a2.append(a2[-1]+i)
c=[]
for i in range(0,n+1):
    for j in range(i+1,n+1):c.append(a2[j]-a2[i])

ans=0
for i in range(40,-1,-1):
    n2=2**i
    c2=[i for i in c if i&n2==n2]
    if len(c2)>=k:
        ans+=n2
        c=c2
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(-x[2],x[0]+x[1]))
if n==1:
    print(a[0][0],a[0][1],a[0][2])
else:
    for i in range(101):
        for j in range(101):
            ansh=[0]*(n+2)
            for k,(x,y,h) in enumerate(a):
                ansh[k]=h+abs(i-x)+abs(j-y)
                if h==0:ansh[k]=min([ansh[k],max(ansh[:k])])
            if len(set(ansh))==2:
                print(i,j,ansh[1])

Fixed submission:
n=int(input())
if n==1:print('Hello World')
else:
    print(int(input())+int(input()))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(-x[2],x[0]+x[1]))
if n==1:
    print(a[0][0],a[0][1],a[0][2])
else:
    for i in range(101):
        for j in range(101):
            ansh=[0]*(n+2)
            for k,(x,y,h) in enumerate(a):
                ansh[k]=h+abs(i-x)+abs(j-y)
                if h==0:ansh[k]=min[ans[k],max(ansh[:k])]
            if len(set(ansh))==2:
                print(i,j,ansh[1])

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(-x[2],x[0]+x[1]))
for i in range(101):
    for j in range(101):
        ansh=[0]*n
        for k,(x,y,h) in enumerate(a):
            ansh[k]=h+abs(i-x)+abs(j-y)
            if h==0:ansh[k]=min([ansh[k],max(ansh[:k])])
        if len(set(ansh))==1:
             print(i,j,ansh[1])
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int, input().split())
a=1
b=0
while b==0:
    for i in range(m,1,-1):
        if m%i==0 and m>=(i*n):
            a*=i
            m=m//i
            break
    else:b=1
print(a)

Fixed submission:
n,m=map(int, input().split())
a=1
b=0
while b==0:
    for i in range(int(m**0.5)*10,1,-1):
        if m%i==0 and m>=(i*n):
            a*=i
            m=m//i
            break
    else:b=1
print(a)
Buggy python submission (verdict: Runtime Error):
n,x=map(int, input().split())
a=list(map(int, input().split()))
mina=min(a)
a=[i-mina for i in a]+[x-mina]
f=max(a)
for i in a:
    if i!=0:
        f=fractions.gcd(f,i)
print(f)

Fixed submission:
import fractions, math
n,x=map(int, input().split())
a=list(map(int, input().split()))
mina=min(a+[x])
a=[i-mina for i in a]+[x-mina]
f=max(a)
for i in a:
    if i!=0:
        f=fractions.gcd(f,i)
print(f)
Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
a.sort()
end=n
ans=0
for i in range(m):
    if a[i][0]>=end:
        ans+=1
        end=n
    end=min(a[i][1],end)
    count+=1
    #print(end,ans)
print(ans+1)

Fixed submission:
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
a.sort()
end=n
ans=0
for i in range(m):
    if a[i][0]>=end:
        ans+=1
        end=n
    end=min(a[i][1],end)
print(ans+1)
Buggy python submission (verdict: Runtime Error):
s=input()
w=int(input())
for i in range(len(s)//w+1):
    print(s[i*w],end='')

Fixed submission:
s=input()
w=int(input())
for i in range((len(s)-1)//w+1):
    print(s[i*w],end='')
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=list(map(int, input().split()))
print(max(a)-min(b))

Fixed submission:
a=int(input())
b=list(map(int, input().split()))
print(max(b)-min(b))
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,b=map(int, input().split())
c=list(range(1,15))
c2=[sum(c[:i+1]) for i in range(len(c))]
d=b-a
print(c2[d-2]-a)

Fixed submission:
a,b=map(int, input().split())
c=list(range(1,1000))
c2=[sum(c[:i+1]) for i in range(len(c))]
d=b-a
print(c2[d-2]-a)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
a=[]
for i in s:
    if i=='W': a.append(1)
    else: a.append(-1)
a2=[-1*i for i in a]
suma=[sum(a[i+1:]) for i in range(len(a))]
suma2=[sum(a2[:i]) for i in range(len(a))]
#print(a,a2)
count=0
for i in range(len(a)):
    d=suma[i]+suma2[i]
    if count<d:count=d
    #print(sum(a[i+1:]),sum(a2[:i]),d)
print((n-1-count)//2)

Fixed submission:
n=int(input())
s=input()
a=[]
for i in s:
    if i=='W': a.append(1)
    else: a.append(-1)
a2=[-1*i for i in a]
suma=[sum(a)-a[0]]
for i in range(len(a)-1):
    suma.append(-a[i+1]+suma[i])
suma2=[0]
for i in range(len(a2)-1):
    suma2.append(suma2[i]+a2[i])
#print(a,a2)
count=0
for i in range(len(a)):
    d=suma[i]+suma2[i]
    if count<d:count=d
    #print(sum(a[i+1:]),sum(a2[:i]),d)
print((n-1-count)//2)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
a=[]
for i in s:
    if i=='W': a.append(1)
    else: a.append(-1)
a2=[-1*i for i in a]
#print(a,a2)
count=0
for i in range(len(a)):
    d=sum(a[i+1:])+sum(a2[:i])
    if count<d:count=d
    #print(sum(a[i+1:]),sum(a2[:i]),d)
print((n-1-count)//2)

Fixed submission:
n=int(input())
s=input()
a=[]
for i in s:
    if i=='W': a.append(1)
    else: a.append(-1)
a2=[-1*i for i in a]
suma=[sum(a)-a[0]]
for i in range(len(a)-1):
    suma.append(-a[i+1]+suma[i])
suma2=[0]
for i in range(len(a2)-1):
    suma2.append(suma2[i]+a2[i])
#print(a,a2)
count=0
for i in range(len(a)):
    d=suma[i]+suma2[i]
    if count<d:count=d
    #print(sum(a[i+1:]),sum(a2[:i]),d)
print((n-1-count)//2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
     a.append([int(input()),i+1])
a=sorted(a,key=lambda x:x[0])

ans=0
count=0
bef=0
for i,j in a:
    if j>bef:
        count+=1
        ans=max(ans,count)
    else:
        count=1
    bef=j
print(n-ans)

Fixed submission:
a,b,c,k=map(int,input().split())
if abs(a-b)>10**18: print('Unfair')
else:
    if k%2 ==0:
        print(a-b)
    else:print(b-a)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k=map(int,input().split())
for i in range(k):
    a,b,c=b+c,a+c,a+b
if a-b>10**18: print('Unfair')
else: print(a-b)

Fixed submission:
a,b,c,k=map(int,input().split())
if abs(a-b)>10**18: print('Unfair')
else:
    if k%2 ==0:
        print(a-b)
    else:print(b-a)
Buggy python submission (verdict: Runtime Error):
import copy

n,m=map(int, input().split())
p=list(map(int, input().split()))
q=list()
for i in range(m):
    q.append(set(map(int, input().split())))
count=0
while count!=5000:
    a=q.pop()
    for j in q:
        if len(j&a) != 0:
            j |=a
            count=0
            break
    else:q=[a]+q
    if count>len(q): break
    count+=1

q2=copy.copy(set(p))
for i in q:
    q2 -= i
    
count2=len([i for i in q2 if i==p[i-1]])

for i in q:
    r=list()
    for j in list(i):
        r.append(p[j-1])
    #print(i,r)
    count2 += len(i&set(r))
print(count2)

Fixed submission:
s=input()
k=int(input())
s1=list(s)
s2=[s[i:i+2] for i in range(len(s)-1)]
s3=[s[i:i+3] for i in range(len(s)-2)]
s4=[s[i:i+4] for i in range(len(s)-3)]
s5=[s[i:i+5] for i in range(len(s)-4)]
sall=sorted(list(set(s1+s2+s3+s4+s5)))
print(sall[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
import copy

n,m=map(int, input().split())
p=list(map(int, input().split()))
q=list()
for i in range(m):
    q.append(set(map(int, input().split())))
count=0
while count!=5000:
    a=q.pop()
    for j in q:
        if len(j&a) != 0:
            j |=a
            count=0
            break
    else:q=[a]+q
    if count>len(q): break
    count+=1

q2=copy.copy(set(p))
for i in q:
    q2 -= i
    
count2=len([i for i in q2 if i==p[i-1]])

for i in q:
    r=list()
    for j in list(i):
        r.append(p[j-1])
    #print(i,r)
    count2 += len(i&set(r))
print(count2)

Fixed submission:
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

n,m=map(int, input().split())
p=list(map(int, input().split()))
uf1=UnionFind(n)
for i in range(m):
    a,b=map(int, input().split())
    uf1.union(a-1,b-1)
count=0
for i in range(n):
    if uf1.is_same(i,p[i]-1):count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
n,c=map(int,input().split())
x=[0]
v=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append(a)
    v.append(b)
x1=[x[i+1]-x[i] for i in range(len(x)-1)]
x2=[c-x[-1]]+x1[:0:-1]
#print(x1,x2)
h=[0]
t=[0]
for i,j in zip(x2,reversed(v)):
    h.append(h[-1]+j+-i)
hm=[max(h[:-i]) for i in range(1,len(h))]+[0]
#print(h,hm)
m=0
for k,(i,j) in enumerate(zip(x1,v)):
    t.append(t[-1]+j-i)
    #print(m,t[-1],i)
    m=max(m,t[-1]+hm[k])
print(m)

Fixed submission:
a,b,c,x,y=map(int, input().split())

if x>=y :l=min(x,y)*2*c+(x-y)*a
else: l=l=min(x,y)*2*c+(y-x)*b

print(min(a*x+b*y, l, max(x,y)*2*c))

Buggy python submission (verdict: Runtime Error):
n,c=map(int,input().split())
x=[0]
v=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append(a)
    v.append(b)

x1=[x[i+1]-x[i] for i in range(len(x)-1)]
x2=[c-x[-1]]+x1[:0:-1]
print(x1,x2)
h=[0]
t=[0]
for i,j in zip(x2,reversed(v)):
    h.append(h[-1]+j+-i)
hm=[max(h[:-i]) for i in range(1,len(h))]+[0]
print(h,hm)
m=0
for k,(i,j) in enumerate(zip(x1,v)):
    t.append(t[-1]+j-i)
    print(m,t[-1],i)
    m=max(m,t[-1]+hm[k])
print(m)

Fixed submission:
a,b,c,x,y=map(int, input().split())

if x>=y :l=min(x,y)*2*c+(x-y)*a
else: l=l=min(x,y)*2*c+(y-x)*b

print(min(a*x+b*y, l, max(x,y)*2*c))
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
for _ in range(n):
    a,b=map(int,input().split())
    c=int(math.sqrt(a*b))
    if c<2 :
        print('0')
    elif (math.sqrt(a*b)==c and a!=b:
        print(2*c-3)
    elif c*(c+1)<a*b:
        print(2*c-1)
    else:
        print(2*c-2)

Fixed submission:
import math
n=int(input())
for _ in range(n):
    a,b=map(int,input().split())
    c=int(math.sqrt(a*b))
    if c*(c+1)<a*b: print(2*c-1)
    elif a*b==c*c and a!=b:  print(2*c-3)
    else:  print(2*c-2)

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
for _ in range(n):
    a,b=map(int,input().split())
    c=int(math.sqrt(a*b))
    if c<2 :
        print('0')
    elif a==1 or b==1:
        print(2c-3)
    elif c*(c+1)<a*b:
        print(2c-1)
    else:
        print(2c-2)

Fixed submission:
import math
n=int(input())
for _ in range(n):
    a,b=map(int,input().split())
    c=int(math.sqrt(a*b))
    if c*(c+1)<a*b: print(2*c-1)
    elif a*b==c*c and a!=b:  print(2*c-3)
    else:  print(2*c-2)
Buggy python submission (verdict: Runtime Error):
s=list(input())
al=[chr(ord('a') + i) for i in range(26)]
al=[i for i in al if i not in s]
if al:
    print(''.join(s)+al[0])
    exit()
for i in range(25,0,-1):
    if s[i-1]<s[i]:
        a=[j for j in s[i:] if s[i]>j]
        s=s[:i-1]+[sorted(a)[0]]
        print(''.join(s))
        exit()
else:print(-1)

Fixed submission:
s=list(input())
al=[chr(ord('a') + i) for i in range(26)]
al=[i for i in al if i not in s]
if al:
    print(''.join(s)+al[0])
    exit()
for i in range(25,0,-1):
    if s[i-1]<s[i]:
        a=[j for j in s[i-1:] if s[i-1]<j]
        s=s[:i-1]+[sorted(a)[0]]
        print(''.join(s))
        break
        exit()
else:print(-1)

Buggy python submission (verdict: Runtime Error):
s=list(input())
al=[chr(ord('a') + i) for i in range(26)]
al=[i for i in al if i not in s]
if al:
    print(''.join(s)+al[0])
    #exit()
for i in range(25,0,-1):
    if s[i-1]<s[i]:
        s=s[:i-1]+[s[-1]]
        print(''.join(s))
        exit()
else:print(-1)

Fixed submission:
s=list(input())
al=[chr(ord('a') + i) for i in range(26)]
al=[i for i in al if i not in s]
if al:
    print(''.join(s)+al[0])
    exit()
for i in range(25,0,-1):
    if s[i-1]<s[i]:
        a=[j for j in s[i-1:] if s[i-1]<j]
        s=s[:i-1]+[sorted(a)[0]]
        print(''.join(s))
        break
        exit()
else:print(-1)

Buggy python submission (verdict: Runtime Error):
s=list(input())
al=[chr(ord('a') + i) for i in range(26)]
al=[i for i in al if i not in s]
if al:
    print(s+al[0])
    exit()
for i in range(25,0,-1):
    if s[i-1]<s[i]:
        s=s[:i-1]+[s[-1]]
        print(''.join(s))
        exit()
else:print(-1)

Fixed submission:
s=list(input())
al=[chr(ord('a') + i) for i in range(26)]
al=[i for i in al if i not in s]
if al:
    print(''.join(s)+al[0])
    exit()
for i in range(25,0,-1):
    if s[i-1]<s[i]:
        a=[j for j in s[i-1:] if s[i-1]<j]
        s=s[:i-1]+[sorted(a)[0]]
        print(''.join(s))
        break
        exit()
else:print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
for i in range(len(a)):
    a1=a.copy()
    a1.pop(i)
    c=[0]+a1+[0]
    b=[]
    for i in range(len(c)-1):
        b.append(abs(c[i]-c[i+1]))
    print(sum(b))

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
b=[]
c=[0]+a+[0]
for i in range(len(c)-1):
    b.append(c[i+1]-c[i])
sumb=sum([abs(i) for i in b])
 
for i in range(n):
    print(sumb-abs(b[i])-abs(b[i+1])+abs(b[i]+b[i+1]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    b.append(list(map(int,input().split())))
an=sorted(a, key=lambda x:-x[1])
bn=sorted(b)#, key=lambda x:(x[0],x[1]))
count=0
for i in range(len(bn)):
    for j in range(len(an)):
#        print(an[j],bn[i])
        if bn[i][0]>an[j][0] and bn[i][1]>an[j][1]:
            count+=1
            an.pop(j)
            break
 
print(count)

Fixed submission:
a,b,c=map(int, input().split())
if a+b>=c:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    b.append(list(map(int,input().split())))
an=sorted(a, key=lambda x:(x[0],-x[1]),reverse=True)
bn=sorted(b, key=lambda x:(x[0],-x[1]),reverse=True)
count=0
for i in range(len(bn)):
    for j in range(len(an)):
#        print(an[j],bn[i])
        if bn[i][0]>an[j][0] and bn[i][1]>an[j][1]:
            count+=1
            an.pop(j)
            break
 
print(count)

Fixed submission:
a,b,c=map(int, input().split())
if a+b>=c:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    b.append(list(map(int,input().split())))
an=sorted(a, key=lambda x:(x[0],-x[1]),reverse=True)
bn=sorted(b, key=lambda x:(x[0],-x[1]),reverse=True)
count=0
for i in range(len(bn)):
    for j in range(len(an)):
#        print(an[j],bn[i])
        if bn[i][0]>an[j][0] and bn[i][1]>an[j][1]:
            count+=1
            an.pop(j)
            break
 
print(count)

Fixed submission:
a,b,c=map(int, input().split())
if a+b>=c:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a=['#'*(w+2)]
for i in range(h):
    b='#'+input()+'#'
    a.append(b)
a.append('#'*(w+2))
#print(a)

from collections import Counter

n=[(1,1)]
route={(1,1):0}
p=[[1,0],[0,1],[-1,0],[0,-1]]
count=1
while route.get((h,w),0)==0 and count != 10000:
    n2=[]
    #print(n,route)
    for i in n:
        for j in p:
            np=(i[0]+j[0],i[1]+j[1])
            if a[np[0]][np[1]]=='.' and route.get(np,-1)==-1:
                n2.append(np)
                if route.get(np,1000)>count:
                    route[np]=count
    n=n2
    #print(n,route)
    count+=1

    
a2=[]
for i in a:
    for j in range(len(i)):
        a2.append(i[j])
con=Counter(a2)


if count==10000:
    print('-1')
else:
    print(con['.']-route[(h,w)]-1)

Fixed submission:
h, w =map(int, input().split())

a=['#'*(w+2)]
for i in range(h):
    b='#'+input()+'#'
    a.append(b)
a.append('#'*(w+2))
#print(a)

from collections import Counter

n=[(1,1)]
route={(1,1):0}
p=[[1,0],[0,1],[-1,0],[0,-1]]
count=1
while route.get((h,w),0)==0 and count != 10000:
    n2=[]
    #print(n,route)
    for i in n:
        for j in p:
            np=(i[0]+j[0],i[1]+j[1])
            if a[np[0]][np[1]]=='.' and route.get(np,-1)==-1:
                n2.append(np)
                if route.get(np,1000)>count:
                    route[np]=count
    n=n2
    #print(n,route)
    count+=1

    
a2=[]
for i in a:
    for j in range(len(i)):
        a2.append(i[j])
con=Counter(a2)


if count==10000:
    print('-1')
else:
    print(con['.']-route[(h,w)]-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = 10**5
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes={i for i in primes if (i+1)//2 in primes}
q=int(input())
for i in range(q):
    a,b=map(int, input().split())
    print(len(set(range(a,b+1))&primes))

Fixed submission:
import bisect
n = 10**5
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=[i for i in primes if (i+1)//2 in primes]
q=int(input())
for i in range(q):
    a,b=map(int, input().split())
    print(bisect.bisect_right(primes, b)-bisect.bisect_left(primes, a))
Buggy python submission (verdict: Time Limit Exceeded):
def C_Good_Sequence():
    N=int(input())
    a=list(map(int, input().split()))
    b=set(a)
    b=list(b)
    count=0
    ans=0 
    c=[]
    
    for i in b:
        for j in range(N):
            if a[j]==i:
                count += 1
        c.append(count)
        count=0

    for i in range(len(b)):
        if c[i]<b[i]:
            ans += c[i]
        elif c[i] >b[i]:
            ans += c[i]-b[i]
    print(ans)
   
C_Good_Sequence()

Fixed submission:
def C_Good_Sequence():
    N=int(input())
    a=list(map(int, input().split()))
    count={}
    ans=0
    
    for num in a:
        count[num]= count.get(num,0)+1

    for num in count:
        if num > count[num]:
            ans += count[num]
        elif num < count[num]:
            ans += count[num]-num
    
    print(ans)
   
C_Good_Sequence()

Buggy python submission (verdict: Time Limit Exceeded):
def C_Good_Sequence():
    N=int(input())
    a=list(map(int, input().split()))
    b=set(a)
    count=0
    ans=0
    
    for i in b:
        for j in range(N):
            if a[j]==i:
                count += 1
        if count<i:
            ans += count
        elif count >i:
            ans += count-i
        count=0
    print(ans)
   
C_Good_Sequence()

Fixed submission:
def C_Good_Sequence():
    N=int(input())
    a=list(map(int, input().split()))
    count={}
    ans=0
    
    for num in a:
        count[num]= count.get(num,0)+1

    for num in count:
        if num > count[num]:
            ans += count[num]
        elif num < count[num]:
            ans += count[num]-num
    
    print(ans)
   
C_Good_Sequence()
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
x,y=map(int, input().split())
h=[(1,0),(0,1),(-1,0),(0,-1)]
nh=0
p={(0,0,0)}
for k in s:
    np=set()
    for i,j,ho in p:
        if k=='F':
            np.add((i+h[ho][0],j+h[ho][1],ho))
        else:
            np.add((i,j,(ho+1)%4))
            np.add((i,j,(ho+3)%4))
    p=np
ans='No'
for i,j,ho in p:
    if i==x and j==y:ans='Yes'
print(ans)

Fixed submission:
s=input()
x,y=map(int, input().split())
sl=[len(i) for i in s.split('T')]
a,b={0:1},{0:1}
for i in sl[2::2]:
    if i==0:continue
    a2={}
    for j in a.keys():
        a2[j+i]=1
        a2[j-i]=1
    a=a2
for i in sl[1::2]:
    if i==0:continue
    b2={}
    for j in b.keys():
        b2[j+i]=1
        b2[j-i]=1
    b=b2
if x-sl[0] in a and y in b:print('Yes')
else:print('No')
Buggy python submission (verdict: Runtime Error):
from itertools import product
al=list(product([0,1],repeat=10))
n=int(input())
a=[list(map(int, input().split())) for i in range(n)]
p=[list(map(int, input().split())) for i in range(n)]
ans-100000000000
for i in al:
    if sum(i)==0:continue
    q=0
    for j in range(n):
        count=0
        for k in range(10):
            if a[j][k]==1 and i[k]==1:
                count+=1
        q+=p[j][count]
    ans=max(ans,q)
print(ans)

Fixed submission:
from itertools import product
al=list(product([0,1],repeat=10))
n=int(input())
a=[list(map(int, input().split())) for i in range(n)]
p=[list(map(int, input().split())) for i in range(n)]
ans=-100000000000
for i in al:
    if sum(i)==0:continue
    q=0
    for j in range(n):
        count=0
        for k in range(10):
            if a[j][k]==1 and i[k]==1:
                count+=1
        q+=p[j][count]
    ans=max(ans,q)
print(ans)
Buggy python submission (verdict: Runtime Error):
if len(a)==1: print(abs(a[-1]-w))
elif abs(a[-2]-a[-1])>abs(a[-1]-w):
    print(abs(a[-2]-a[-1]))
else: print(abs(a[-1]-w))

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

if len(a)==1: print(abs(a[-1]-w))
elif abs(a[-2]-a[-1])>abs(a[-1]-w):
    print(abs(a[-2]-a[-1]))
else: print(abs(a[-1]-w))
Buggy python submission (verdict: Runtime Error):
import numpy as np
h,w=map(int, input().split())
a=[list(input()) for i in range(h)]
a=np.array(a)
for i in range(h):
    for j in range(w):
        if a[i][j]=='.':
            a[i][j]=sum(sum(a[max(i-1,0):min(i+2,w),max(j-1,0):min(j+2,w)]=='#'))
for i in a:
    print(''.join(i))

Fixed submission:
import numpy as np
h,w=map(int, input().split())
a=[list(input()) for i in range(h)]
a=np.array(a)
for i in range(h):
    for j in range(w):
        if a[i][j]=='.':
            b=a[max(i-1,0):min(i+2,h),max(j-1,0):min(j+2,w)].flatten()
            a[i][j]=sum(b=='#')
for i in a:
    print(''.join(i))