Buggy python submission (verdict: Time Limit Exceeded):
a = []

n,k = map(int, input().split())
for x in range(k):
  a.append(0)
q = input()

p = 0
c = 0
mx = 0

for i in range(n-1):
  c = c+1  
  if q[i] == q[i+1]:
    lalala = 1

  elif (int(q[i]) == 1) & (int(q[i+1]) == 0) :
    
    for x in a:
      p = p + x
    if mx < p+c:
      mx = p+c
    p = 0
    
  elif (int(q[i]) == 0) & (int(q[i+1]) == 1):
    a.append(c)
    a.pop(0)
    c = 0
for x in a:
  p = p + x
if int(q[n-1]) == 1:
  if mx < p+c+1:
    mx = p+c+1
else:
  p=0
  a.pop(0)
  for x in a:
    p = p + x
  if mx < p+c+1:
    mx = p+c+1
  


print(mx)

Fixed submission:
a = []

n,k = map(int, input().split())
for x in range(k+1):
  a.append(0)
q = input()

p = 0
c = 0
mx = 0

for i in range(n-1):
  p = p+1
  c = c+1  
  if q[i] == q[i+1]:
    lalala = 1

  elif (int(q[i]) == 1) & (int(q[i+1]) == 0) :
    p = p-a[0]
    if p > mx:
      mx = p
    
  elif (int(q[i]) == 0) & (int(q[i+1]) == 1):
    a.pop(0)
    a.append(c)
    c = 0

if int(q[n-1]) == 1:
  if p+1- a[0]> mx:
    mx = p +1 - a[0]
else:
  if p+1 -a[1] > mx:
    mx = p  -a[1] +1
  
  


print(mx)

Buggy python submission (verdict: Time Limit Exceeded):
a = []

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

for i in range(k):
  a.append(0)
q = input()


if int(q[0]) == 1:
  a.append(0)

c = 0
mx = 0

for i in range(n-1):
  c = c+1  
  if q[i] == q[i+1]:
    lalala = 1

  elif (int(q[i]) == 1) & (int(q[i+1]) == 0):
    for x in range(k+1):
      a[x] = a[x]+c
    c = 0
    if mx < a[0]:
      mx = a[0]
    a.pop(0)
    
  elif (int(q[i]) == 0) & (int(q[i+1]) == 1):
    for x in range(k):
      a[x] = a[x]+c
    c = 0
    a.append(0)

a[0] = a[0]+c+1
if mx < a[0]:
  mx = a[0]


print(mx)

Fixed submission:
a = []

n,k = map(int, input().split())
for x in range(k+1):
  a.append(0)
q = input()

p = 0
c = 0
mx = 0

for i in range(n-1):
  p = p+1
  c = c+1  
  if q[i] == q[i+1]:
    lalala = 1

  elif (int(q[i]) == 1) & (int(q[i+1]) == 0) :
    p = p-a[0]
    if p > mx:
      mx = p
    
  elif (int(q[i]) == 0) & (int(q[i+1]) == 1):
    a.pop(0)
    a.append(c)
    c = 0

if int(q[n-1]) == 1:
  if p+1- a[0]> mx:
    mx = p +1 - a[0]
else:
  if p+1 -a[1] > mx:
    mx = p  -a[1] +1
  
  


print(mx)

Buggy python submission (verdict: Runtime Error):
a = []

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

for i in range(k):
  a.append(0)

q = input()


if a[0] = 1:
  a.append(0)

c = 0
mx = 0

for i in range(n-1):
  c = c+1  
  if q[i] == q[i+1]:
    lalala = 1

  if q[i] = 1 & q[i+1] = 0:
    for x in range(n+1):
      a[x] = a[x]+c
    c = 0
    if mx < a[0]:
      mx = a[0]
    pop(a[0])
    
  if q[i] = 0 & q[i+1] = 1:
    for x in range(n):
      a[x] = a[x]+c
    c = 0
    a.append(0)

for x in range(n):
  a[0] = a[0]+c+1
  if mx < a[0]:
    mx = a[0]
  pop(a[0])
 

if q[n-1] = 1:
  a[0] = a[0]+c+1
  if mx < a[0]:
    mx = a[0]
  pop(a[0])


print(mx)

Fixed submission:
a = []

n,k = map(int, input().split())
for x in range(k+1):
  a.append(0)
q = input()

p = 0
c = 0
mx = 0

for i in range(n-1):
  p = p+1
  c = c+1  
  if q[i] == q[i+1]:
    lalala = 1

  elif (int(q[i]) == 1) & (int(q[i+1]) == 0) :
    p = p-a[0]
    if p > mx:
      mx = p
    
  elif (int(q[i]) == 0) & (int(q[i+1]) == 1):
    a.pop(0)
    a.append(c)
    c = 0

if int(q[n-1]) == 1:
  if p+1- a[0]> mx:
    mx = p +1 - a[0]
else:
  if p+1 -a[1] > mx:
    mx = p  -a[1] +1
  
  


print(mx)