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

now = 1
cnt = 0
x = []

for i in range(n):
    if sss[i] == str(now):
        cnt += 1
    else:
        x.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    x.append(cnt)
if len(x) % 2 == 0:
    x.append(0)

Add = 2 * k + 1
ans = 0

for i in range(len(x))[::2]:
    tmp = 0
    left = i
    right = min(i + Add, len(x))
    for j in range(left, right):
        tmp += x[j]
    ans = max(tmp, ans)

print(ans)

Fixed submission:
n,k = map(int,input().split())
sss = input()

cnt = 0
state = sss[0]
x = []
if sss[0] == "0":
    x.append(0)
for s in sss:
    if s == state:
        cnt += 1
    else:
        state = s
        x.append(cnt)
        cnt = 1
x.append(cnt)
if sss[-1] == "0":
    x.append(0)
#11101010110011
#1:3 1 1 2 2
#0: 1 1 1 2

#1
#1

y = [0]
for i in range(len(x)):
    y.append(y[i] + x[i])
#:0,1,2,3,4,5,6 7, 8 ,9
#:0,3,4,5,6,7,8,10,12,14

#0,1

z = []
for i in range(k*2+1,len(y))[::2]:
    z.append(y[i] - y[i - (k*2+1)])
#print(x)
#print(y)
#print(z)
if len(x) <= k*2-1:
    print(sum(x))
else:
    print(max(z))

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

now = 1
cnt = 0
x = []

for i in range(n):
    if sss[i] == str(now):
        cnt += 1
    else:
        x.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    x.append(cnt)
if len(x) % 2 == 0:
    x.append(0)

Add = 2 * k + 1
ans = 0

for i in range(len(x))[::2]:
    tmp = 0
    left = i
    right = min(i + Add, len(x))
    for j in range(left, right + 1):
        tmp += x[j]
    ans = max(tmp, ans)

print(ans)

Fixed submission:
n,k = map(int,input().split())
sss = input()

cnt = 0
state = sss[0]
x = []
if sss[0] == "0":
    x.append(0)
for s in sss:
    if s == state:
        cnt += 1
    else:
        state = s
        x.append(cnt)
        cnt = 1
x.append(cnt)
if sss[-1] == "0":
    x.append(0)
#11101010110011
#1:3 1 1 2 2
#0: 1 1 1 2

#1
#1

y = [0]
for i in range(len(x)):
    y.append(y[i] + x[i])
#:0,1,2,3,4,5,6 7, 8 ,9
#:0,3,4,5,6,7,8,10,12,14

#0,1

z = []
for i in range(k*2+1,len(y))[::2]:
    z.append(y[i] - y[i - (k*2+1)])
#print(x)
#print(y)
#print(z)
if len(x) <= k*2-1:
    print(sum(x))
else:
    print(max(z))

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = str(input())
S = list(S)


if N/2 < K:
    ans = N
else:
    cnt = 0
    state = S[0]
    X = []
    if S[0] == "0":
        X.append(0)
    for i in S:
        if i == state:
            cnt += 1
        else:
            state = i
            X.append(cnt)
            cnt = 1
    X.append(cnt)

    #print(X)
    #print(len(X)-K)

    Y = []
    for i in range(0,len(X)-(K*2+1)+1,2):
        tmp = 0
        for j in range(i,i+(K*2+1)):
            tmp += X[j]
        Y.append(tmp)
    
    #print(Y)

    ans = max(Y)

print(ans)

Fixed submission:
n,k = map(int,input().split())
sss = input()

cnt = 0
state = sss[0]
x = []
if sss[0] == "0":
    x.append(0)
for s in sss:
    if s == state:
        cnt += 1
    else:
        state = s
        x.append(cnt)
        cnt = 1
x.append(cnt)
if sss[-1] == "0":
    x.append(0)
#11101010110011
#1:3 1 1 2 2
#0: 1 1 1 2

#1
#1

y = [0]
for i in range(len(x)):
    y.append(y[i] + x[i])
#:0,1,2,3,4,5,6 7, 8 ,9
#:0,3,4,5,6,7,8,10,12,14

#0,1

z = []
for i in range(k*2+1,len(y))[::2]:
    z.append(y[i] - y[i - (k*2+1)])
#print(x)
#print(y)
#print(z)
if len(x) <= k*2-1:
    print(sum(x))
else:
    print(max(z))