Buggy python submission (verdict: Runtime Error):
N,K=[int(i) for i in input().split()]
S=input()
cur=0
line=[]

for i in range(len(S)):
	if i==0:
		if S[0]=="0":
			line.append(0)
		line.append(1)
	else:
		if S[i-1]!=S[i]:
			line.append(1)
		else:
			line[-1]+=1
c=0
for i in range(len(line)):

	if i==0:
		if 2*K+1<=len(line):
			s=sum(line[i:2*K+1])
			c=s
		else:
			s=sum(line[i:])
			c=s
	elif i%2==0:
		if i+2*K<=len(line):
			s=s-line[i-2]-line[i-1]+line[i+2*K-1]+line[i+2*K]
			c=max(c,s)
		else:
			c=max(c,sum(line[i:]))
			break
print(c)

Fixed submission:
N,K=[int(i) for i in input().split()]
S=input()
cur=0
line=[]

for i in range(len(S)):
	if i==0:
		if S[0]=="0":
			line.append(0)
		line.append(1)
	else:
		if S[i-1]!=S[i]:
			line.append(1)
		else:
			line[-1]+=1
c=0
for i in range(len(line)):

	if i==0:
		if i+2*K+1<=len(line):
			s=sum(line[i:2*K+1])
			c=s
		else:
			s=sum(line[i:])
			c=s
	elif i%2==0:
		if i+2*K+1<=len(line):
			s=s-line[i-2]-line[i-1]+line[i+2*K-1]+line[i+2*K]
			c=max(c,s)
		else:
			c=max(c,sum(line[i:]))
			break
print(c)

Buggy python submission (verdict: Runtime Error):
N,K=[int(i) for i in input().split()]
S=input()
cur=0
line=[]

for i in range(len(S)):
	if i==0:
		if S[0]=="0":
			line.append(0)
		line.append(1)
	else:
		if S[i-1]!=S[i]:
			line.append(1)
		else:
			line[-1]+=1
c=0
for i in range(len(line)):

	if i==0:
		if 2*K+1<=len(line):
			s=sum(line[i:2*K+1])
			c=s
		else:
			s=sum(line[i:])
			c=S
	elif i%2==0:
		if i+2*K+1<=len(line):
			s=s-line[i-2]-line[i-1]+line[i+2*K-1]+line[i+2*K]
			c=max(c,s)
		else:
			c=max(c,sum(line[i:]))
			break
print(c)

Fixed submission:
N,K=[int(i) for i in input().split()]
S=input()
cur=0
line=[]

for i in range(len(S)):
	if i==0:
		if S[0]=="0":
			line.append(0)
		line.append(1)
	else:
		if S[i-1]!=S[i]:
			line.append(1)
		else:
			line[-1]+=1
c=0
for i in range(len(line)):

	if i==0:
		if i+2*K+1<=len(line):
			s=sum(line[i:2*K+1])
			c=s
		else:
			s=sum(line[i:])
			c=s
	elif i%2==0:
		if i+2*K+1<=len(line):
			s=s-line[i-2]-line[i-1]+line[i+2*K-1]+line[i+2*K]
			c=max(c,s)
		else:
			c=max(c,sum(line[i:]))
			break
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,K=[int(i) for i in input().split()]
S=input()
linelist=[1]
for i in range(1,len(S)):
	if S[i-1]!=S[i]:
		linelist.append(1)
	else:
		linelist[-1]+=1
c=0
line=np.array(linelist)
if S[0]=="0":
	for i,num in enumerate(line):
		if i%2==0:
			if i+2*K<=len(line):
				c=max(c,np.sum(line[i:i+2*K]))
			else:
				c=max(c,np.sum(line[i:]))
				break
		else:
			if i+2*K+1<=len(line):
				c=max(c,np.sum(line[i:i+2*K+1]))
			else:
				c=max(c,np.sum(line[i:]))
				break
else:
	for i,num in enumerate(line):
		if i%2==1:
			if i+2*K<=len(line):
				c=max(c,np.sum(line[i:i+2*K]))
			else:
				c=max(c,np.sum(line[i:]))
				break
		else:
			if i+2*K+1<=len(line):
				c=max(c,np.sum(line[i:i+2*K+1]))
			else:
				c=max(c,np.sum(line[i:]))
				break
print(c)

Fixed submission:
N,K=[int(i) for i in input().split()]
S=input()
cur=0
line=[]

for i in range(len(S)):
	if i==0:
		if S[0]=="0":
			line.append(0)
		line.append(1)
	else:
		if S[i-1]!=S[i]:
			line.append(1)
		else:
			line[-1]+=1
c=0
for i in range(len(line)):

	if i==0:
		if i+2*K+1<=len(line):
			s=sum(line[i:2*K+1])
			c=s
		else:
			s=sum(line[i:])
			c=s
	elif i%2==0:
		if i+2*K+1<=len(line):
			s=s-line[i-2]-line[i-1]+line[i+2*K-1]+line[i+2*K]
			c=max(c,s)
		else:
			c=max(c,sum(line[i:]))
			break
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=[int(i) for i in input().split()]
S=input()
cur=0
line=[]
for i in range(len(S)):
	if i==0:
		line.insert(0,1)
	else:
		if S[i-1]!=S[i]:
			line.append(1)
		else:
			line[-1]+=1
c=0
if S[0]=="0":
	for i,num in enumerate(line):
		if i%2==0:
			if i+2*K<=len(line):
				c=max(c,sum(line[i:i+2*K]))
			else:
				c=max(c,sum(line[i:]))
				break
		else:
			if i+2*K+1<=len(line):
				c=max(c,sum(line[i:i+2*K+1]))
			else:
				c=max(c,sum(line[i:]))
				break
else:
	for i,num in enumerate(line):
		if i%2==1:
			if i+2*K<=len(line):
				c=max(c,sum(line[i:i+2*K]))
			else:
				c=max(c,sum(line[i:]))
				break
		else:
			if i+2*K+1<=len(line):
				c=max(c,sum(line[i:i+2*K+1]))
			else:
				c=max(c,sum(line[i:]))
				break
print(c)

Fixed submission:
N,K=[int(i) for i in input().split()]
S=input()
cur=0
line=[]

for i in range(len(S)):
	if i==0:
		if S[0]=="0":
			line.append(0)
		line.append(1)
	else:
		if S[i-1]!=S[i]:
			line.append(1)
		else:
			line[-1]+=1
c=0
for i in range(len(line)):

	if i==0:
		if i+2*K+1<=len(line):
			s=sum(line[i:2*K+1])
			c=s
		else:
			s=sum(line[i:])
			c=s
	elif i%2==0:
		if i+2*K+1<=len(line):
			s=s-line[i-2]-line[i-1]+line[i+2*K-1]+line[i+2*K]
			c=max(c,s)
		else:
			c=max(c,sum(line[i:]))
			break
print(c)