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

data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)

current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data), 2):
    if (start + 2*k-1) < len(data): 
        diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
        current_sum += diff

        if current_sum > ret:
            ret = current_sum
    else:
        break
print(ret)

Fixed submission:
n, k = list(map(int, input().split()))
s = input()
 
data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)
data.append(0)
 
current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data)-k-2, 2):
    if start + 2*k >= len(data):
        break
    diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
    current_sum += diff
 
#     print(start, val)
    if current_sum > ret:
        ret = current_sum
print(ret)

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

data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)

current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data), 2):
    if (start + 2*k-1) < len(data): 
        diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
        current_sum += diff

    #     print(start, val)
        if current_sum > ret:
            ret = current_sum
    else:
        break
print(ret)

Fixed submission:
n, k = list(map(int, input().split()))
s = input()
 
data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)
data.append(0)
 
current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data)-k-2, 2):
    if start + 2*k >= len(data):
        break
    diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
    current_sum += diff
 
#     print(start, val)
    if current_sum > ret:
        ret = current_sum
print(ret)

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

data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)
data.append(0)

current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data)-k-2, 2):
    diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
    current_sum += diff

#     print(start, val)
    if current_sum > ret:
        ret = current_sum
print(ret)

Fixed submission:
n, k = list(map(int, input().split()))
s = input()
 
data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)
data.append(0)
 
current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data)-k-2, 2):
    if start + 2*k >= len(data):
        break
    diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
    current_sum += diff
 
#     print(start, val)
    if current_sum > ret:
        ret = current_sum
print(ret)

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

data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)
data.append(0)

current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data)-k-2, 2):
    diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
    current_sum += diff

#     print(start, val)
    if current_sum > ret:
        ret = current_sum
print(ret)

Fixed submission:
n, k = list(map(int, input().split()))
s = input()
 
data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)
data.append(0)
 
current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data)-k-2, 2):
    if start + 2*k >= len(data):
        break
    diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
    current_sum += diff
 
#     print(start, val)
    if current_sum > ret:
        ret = current_sum
print(ret)

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

data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)

ret = sum(data[0:0 + 2*k+1])
for start in range(0, len(data)-k, 2):
    val = sum(data[start:start + 2*k+1])
#     print(start, val)
    if val > ret:
        ret = val
print(ret)

Fixed submission:
n, k = list(map(int, input().split()))
s = input()
 
data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)
data.append(0)
 
current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data)-k-2, 2):
    if start + 2*k >= len(data):
        break
    diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
    current_sum += diff
 
#     print(start, val)
    if current_sum > ret:
        ret = current_sum
print(ret)