Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
s = input()
dp = [-1 for _i in range(n+1)]
dp[0] = 0
for i in range(1, n+1):
    if i <= m:
        if s[i]=="0":
            dp[i] = 0
        continue
    for j in range(max(0,i-m), i):
        if s[j]=="0" and dp[j] >= 0:
            dp[i] = j
            break


if dp[n] >= 0:
    r = []
    p = n
    while p > 0:
        nex = dp[p]
        r.append(p-nex)
        p = nex
    print(*r[::-1])
else:
    print(-1)

Fixed submission:
n, m = map(int, input().split())
s = input()
dp = [-1 for _i in range(n+1)]
dp[0] = 0
f = 0
from collections import deque
q = deque([0])
c = 0
for i in range(1, n+1):
    if s[i]=="0":
        c = 0
        while i-f > m:
            f = q.popleft()
        dp[i] = f
        q.append(i)
    else:
        c += 1
        if c >= m:
            break

if dp[n] >= 0:
    r = []
    p = n
    while p > 0:
        nex = dp[p]
        r.append(p-nex)
        p = nex
    print(*r[::-1])
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
s = input()
dp = [-1 for _i in range(n+1)]
dp[0] = 0
for i in range(1, n+1):
    if i <= m:
        if s[i]=="0":
            dp[i] = 0
        continue
    for j in range(i-1, max(0,i-m)-1, -1):
        if s[j]=="0" and dp[j] >= 0:
            dp[i] = j


if dp[n] >= 0:
    r = []
    p = n
    while p > 0:
        nex = dp[p]
        r.append(p-nex)
        p = nex
    print(*r[::-1])
else:
    print(-1)

Fixed submission:
n, m = map(int, input().split())
s = input()
dp = [-1 for _i in range(n+1)]
dp[0] = 0
f = 0
from collections import deque
q = deque([0])
c = 0
for i in range(1, n+1):
    if s[i]=="0":
        c = 0
        while i-f > m:
            f = q.popleft()
        dp[i] = f
        q.append(i)
    else:
        c += 1
        if c >= m:
            break

if dp[n] >= 0:
    r = []
    p = n
    while p > 0:
        nex = dp[p]
        r.append(p-nex)
        p = nex
    print(*r[::-1])
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
s = input()
dp = [[-1, float("inf")] for _i in range(n+1)]
dp[0] = [0,0]
for i in range(1, n+1):
    if i <= m:
        if s[i]=="0":
            dp[i] = [0, 1]
        continue
    for j in range(max(0,i-m), i):
        if s[j]=="0" and dp[j][0] >= 0:
            if dp[i][1] > dp[j][1]+1:
                dp[i][0] = j
                dp[i][1] = dp[j][1] + 1 
            elif dp[i][1] == dp[j][1]+1:
                dp[i][0] = min(dp[i][0], j)

if dp[n][0] >= 0:
    r = []
    p = n
    while p > 0:
        nex = dp[p][0]
        r.append(p-nex)
        p = nex
    print(*r[::-1])
else:
    print(-1)

Fixed submission:
n, m = map(int, input().split())
s = input()
dp = [-1 for _i in range(n+1)]
dp[0] = 0
f = 0
from collections import deque
q = deque([0])
c = 0
for i in range(1, n+1):
    if s[i]=="0":
        c = 0
        while i-f > m:
            f = q.popleft()
        dp[i] = f
        q.append(i)
    else:
        c += 1
        if c >= m:
            break

if dp[n] >= 0:
    r = []
    p = n
    while p > 0:
        nex = dp[p]
        r.append(p-nex)
        p = nex
    print(*r[::-1])
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
s = input()
dp = [[-1, float("inf")] for _i in range(n+1)]
dp[0] = [0,0]
for i in range(1, n+1):
    for j in range(max(0,i-m), i):
        if s[j]=="0" and dp[j][0] >= 0:
            if dp[i][1] > dp[j][1]+1:
                dp[i][0] = j
                dp[i][1] = dp[j][1] + 1 
            elif dp[i][1] == dp[j][1]+1:
                dp[i][0] = min(dp[i][0], j)
if dp[n][0] >= 0:
    r = []
    p = n
    while p > 0:
        nex = dp[p][0]
        r.append(p-nex)
        p = nex
    print(*r[::-1])
else:
    print(-1)

Fixed submission:
n, m = map(int, input().split())
s = input()
dp = [-1 for _i in range(n+1)]
dp[0] = 0
f = 0
from collections import deque
q = deque([0])
c = 0
for i in range(1, n+1):
    if s[i]=="0":
        c = 0
        while i-f > m:
            f = q.popleft()
        dp[i] = f
        q.append(i)
    else:
        c += 1
        if c >= m:
            break

if dp[n] >= 0:
    r = []
    p = n
    while p > 0:
        nex = dp[p]
        r.append(p-nex)
        p = nex
    print(*r[::-1])
else:
    print(-1)