Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
s = str(input())

one = list(map(len, s.replace('0', ' ').split()))
zero = list(map(len, s.replace('1', ' ').split()))
if s[0] == '0':
    one.insert(0, 0)
if s[-1] == '0':
    one.append(0)
    
ans = 0
for i in range(len(zero)):
    length = sum(one[i:i+k+1]) + sum(zero[i:i+k])
    ans = max(ans, length)
    
    if i+k > len(zero):
        break
    
if s.count('1') == len(s):
    print(len(s))
else:
    print(ans)

Fixed submission:
import numpy as np

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

arr0 = np.array(list(map(len, s.split('1'))))
arr0 = arr0[arr0!=0]

arr1 = np.array(list(map(len, s.split('0'))))
arr1 = arr1[arr1!=0]


ans = 0

if s[0] == '0':
    for i in range(len(arr0)):
        
        if i == 0:
            length = arr0[i:i+k].sum() + arr1[i:i+k].sum()
        else:
            length = arr0[i:i+k].sum() + arr1[i-1:i+k].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        
else:        
    for i in range(len(arr0)):
        
        
        length = arr0[i:i+k].sum() + arr1[i:i+k+1].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        

if len(s) == s.count('1'):
    print(len(s))
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
s = str(input())

one = list(map(len, s.replace('0', ' ').split()))
zero = list(map(len, s.replace('1', ' ').split()))
if s[0] == '0':
    one.insert(0, 0)
if s[-1] == '0':
    one.append(0)
    
ans = 0
for i in range(len(zero)):
    length = sum(one[i:i+k+1]) + sum(zero[i:i+k])
    ans = max(ans, length)

if s.count('1') == len(s):
    print(len(s))
else:
    print(ans)

Fixed submission:
import numpy as np

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

arr0 = np.array(list(map(len, s.split('1'))))
arr0 = arr0[arr0!=0]

arr1 = np.array(list(map(len, s.split('0'))))
arr1 = arr1[arr1!=0]


ans = 0

if s[0] == '0':
    for i in range(len(arr0)):
        
        if i == 0:
            length = arr0[i:i+k].sum() + arr1[i:i+k].sum()
        else:
            length = arr0[i:i+k].sum() + arr1[i-1:i+k].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        
else:        
    for i in range(len(arr0)):
        
        
        length = arr0[i:i+k].sum() + arr1[i:i+k+1].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        

if len(s) == s.count('1'):
    print(len(s))
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
s = str(input())

now = 1
cnt = 0
li = []

# 1-0-1-0-1-0-..... を準備
for i in range(n):
    if s[i] == str(now):
        cnt += 1
    else:
        li.append(cnt)
        now = 1 - now
        cnt = 1
        
if len(li)%2 == 0:
    li.append(cnt)

ans = -1
for i in range(n):
    left = 2*i
    right = 2*i + 2*k + 1
    length = sum(li[left:right])
    ans = max(ans, length)
    
    if end >= len(li):
        break

print(ans)

Fixed submission:
import numpy as np

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

arr0 = np.array(list(map(len, s.split('1'))))
arr0 = arr0[arr0!=0]

arr1 = np.array(list(map(len, s.split('0'))))
arr1 = arr1[arr1!=0]


ans = 0

if s[0] == '0':
    for i in range(len(arr0)):
        
        if i == 0:
            length = arr0[i:i+k].sum() + arr1[i:i+k].sum()
        else:
            length = arr0[i:i+k].sum() + arr1[i-1:i+k].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        
else:        
    for i in range(len(arr0)):
        
        
        length = arr0[i:i+k].sum() + arr1[i:i+k+1].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        

if len(s) == s.count('1'):
    print(len(s))
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

arr0 = np.array(list(map(len, s.split('1'))))
arr0 = arr0[arr0!=0]

arr1 = np.array(list(map(len, s.split('0'))))
arr1 = arr1[arr1!=0]


ans = 0

if s[0] == '0':
    for i in range(len(arr0)):
        
        if i == 0:
            length = arr0[i:i+k].sum() + arr1[i:i+k].sum()
        else:
            length = arr0[i:i+k].sum() + arr1[i-1:i+k].sum()
        ans = max(ans, length)
        
else:        
    for i in range(len(arr0)):
        length = arr0[i:i+k].sum() + arr1[i:i+k+1].sum()
        ans = max(ans, length)
        

if len(s) == s.count('1'):
    print(len(s))
else:
    print(ans)

Fixed submission:
import numpy as np

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

arr0 = np.array(list(map(len, s.split('1'))))
arr0 = arr0[arr0!=0]

arr1 = np.array(list(map(len, s.split('0'))))
arr1 = arr1[arr1!=0]


ans = 0

if s[0] == '0':
    for i in range(len(arr0)):
        
        if i == 0:
            length = arr0[i:i+k].sum() + arr1[i:i+k].sum()
        else:
            length = arr0[i:i+k].sum() + arr1[i-1:i+k].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        
else:        
    for i in range(len(arr0)):
        
        
        length = arr0[i:i+k].sum() + arr1[i:i+k+1].sum()
        ans = max(ans, length)
        
        if i+k > len(arr0):
            break
        
        

if len(s) == s.count('1'):
    print(len(s))
else:
    print(ans)