Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    N, M = mis()
    S = input()

    @lru_cache(maxsize=None)
    def rec(n):
        if n < 0 or S[n] == '1':
            return None, INF
        elif n == 0:
            return None, 0
        min_i = None
        min_v = INF
        for i in range(max(n-M, 0), n):
            _, v = rec(i)
            if min_v > v:
                min_v = v
                min_i = i
        return min_i, min_v

    flag, _ = rec(N)
    if flag is None:
        print(-1)
    else:
        ans = []
        pos = N
        while pos != 0:
            prev_pos, _ = rec(pos)
            ans.append(pos - prev_pos)
            pos = prev_pos
        ans.reverse()
        print(*ans, sep=' ')



main()


Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    N, M = mis()
    S = input()

    ans = []
    r = N
    l = max(r - M, 0)
    while r > 0:
        for i in range(l, r):
            if S[i] == '0':
                ans.append(r - i)
                r = i
                l = max(r - M, 0)
                break
        else:
            print(-1)
            return
    ans.reverse()
    print(*ans, sep=' ')


main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    N, M = mis()
    S = input()

    @lru_cache(maxsize=None)
    def rec(n):
        if n < 0 or S[n] == '1':
            return None, INF
        elif n == 0:
            return None, 0
        min_i = None
        min_v = INF
        for i in range(n-M, n):
            _, v = rec(i)
            if min_v > v:
                min_v = v
                min_i = i
        return min_i, min_v

    flag, _ = rec(N)
    if flag is None:
        print(-1)
    else:
        ans = []
        pos = N
        while pos != 0:
            prev_pos, _ = rec(pos)
            ans.append(pos - prev_pos)
            pos = prev_pos
        ans.reverse()
        print(*ans, sep=' ')



main()


Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    N, M = mis()
    S = input()

    ans = []
    r = N
    l = max(r - M, 0)
    while r > 0:
        for i in range(l, r):
            if S[i] == '0':
                ans.append(r - i)
                r = i
                l = max(r - M, 0)
                break
        else:
            print(-1)
            return
    ans.reverse()
    print(*ans, sep=' ')


main()