Buggy python submission (verdict: Time Limit Exceeded):
data = input().split()
N = int(data[0])
K = int(data[1])

TL = list(input())
TLLlist = []
now = TL[0]
nowlist = now
anslist = []

for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLLlist.append(len(nowlist))
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLLlist.append(len(nowlist))

hjm = 0
if TL[0] == "0" :
    anslist.append( sum(TLLlist[:2*K]) )
    hjm = 1
elif TL[0] == "1" :
    anslist.append( sum(TLLlist[:2*K + 1 ]) )
    hjm = 2
for lop in range(hjm,len(TLLlist),2):
    if 2*K +  lop > len(TLLlist):
        break
    anslist.append( sum(TLLlist[lop:2*K + 1 + lop]) )


#print(TLlist)
#print(TLLlist)
#print(anslist)
print(max(anslist))



Fixed submission:
data = input().split()
N = int(data[0])
K = int(data[1])
 
TL = list(input())
TLlist = []
TLLlist = []
now = TL[0]
nowlist = now
anslist = []
 
for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        TLLlist.append(len(nowlist))
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)
TLLlist.append(len(nowlist))
 
 
if TLlist[0][:1] == "0" :
    anslist.append( sum(TLLlist[:2*K]) )
    anslist.append( sum(TLLlist[1:2*K + 2]) )
    for lop in range(3,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
elif TLlist[0][:1] == "1" :
    anslist.append( sum(TLLlist[:2*K + 1 ]) )
    for lop in range(2,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
 
print(max(anslist))

Buggy python submission (verdict: Time Limit Exceeded):
import copy

data = input().split()
N = int(data[0])
K = int(data[1])

TL = list(input())
TLlist = []
TLLlist = []
now = TL[0]
nowlist = now
anslist = []

for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        TLLlist.append(len(nowlist))
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)
TLLlist.append(len(nowlist))


if TLlist[0][:1] == "0" :
    anslist.append( sum(TLLlist[:2*K]) )
    for lop in range(1,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( sum(TLLlist[lop:2*K + 1 + lop]) )
elif TLlist[0][:1] == "1" :
    anslist.append( sum(TLLlist[:2*K + 1 ]) )
    for lop in range(2,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( sum(TLLlist[lop:2*K + 1 + lop]) )


#print(TLlist)
#print(TLLlist)
#print(anslist)
print(max(anslist))



Fixed submission:
data = input().split()
N = int(data[0])
K = int(data[1])
 
TL = list(input())
TLlist = []
TLLlist = []
now = TL[0]
nowlist = now
anslist = []
 
for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        TLLlist.append(len(nowlist))
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)
TLLlist.append(len(nowlist))
 
 
if TLlist[0][:1] == "0" :
    anslist.append( sum(TLLlist[:2*K]) )
    anslist.append( sum(TLLlist[1:2*K + 2]) )
    for lop in range(3,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
elif TLlist[0][:1] == "1" :
    anslist.append( sum(TLLlist[:2*K + 1 ]) )
    for lop in range(2,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
 
print(max(anslist))

Buggy python submission (verdict: Time Limit Exceeded):
import copy

data = input().split()
N = int(data[0])
K = int(data[1])

TL = input()
TL = list(TL)
TLlist = []
now = TL[0]
nowlist = now
inx = []

for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        if nowlist[:1] == "0":
            inx.append(len(TLlist))
        TLlist.append(nowlist)
        nowlist = TL[lop]
        now = TL[lop]
        
    else:
        nowlist += now
if nowlist[:1] == "0":
    inx.append(len(TLlist))
TLlist.append(nowlist)

maxS = 0
cnt = 0
fg = 0
tfg = 0
fg2 = False
loplist = copy.deepcopy(TLlist)

for lop3 in range(len(loplist)):
    for lop2 in inx:
        if fg <= tfg:
            loplist[lop2] = loplist[lop2].replace('0', '1')
            cnt += 1
            if cnt == K:
                fg2 = True
                break
        else:
            tfg += 1
    loplist = "".join(loplist).split("0")
    for lop2 in loplist:
        if maxS < len(lop2):
            maxS = len(lop2)

    loplist = copy.deepcopy(TLlist)
    fg += 1
    cnt = 0
    tfg = 0
    if fg2 == False:
        break
    else:
        fg2 = False
print(maxS)


Fixed submission:
data = input().split()
N = int(data[0])
K = int(data[1])
 
TL = list(input())
TLlist = []
TLLlist = []
now = TL[0]
nowlist = now
anslist = []
 
for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        TLLlist.append(len(nowlist))
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)
TLLlist.append(len(nowlist))
 
 
if TLlist[0][:1] == "0" :
    anslist.append( sum(TLLlist[:2*K]) )
    anslist.append( sum(TLLlist[1:2*K + 2]) )
    for lop in range(3,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
elif TLlist[0][:1] == "1" :
    anslist.append( sum(TLLlist[:2*K + 1 ]) )
    for lop in range(2,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
 
print(max(anslist))

Buggy python submission (verdict: Time Limit Exceeded):
import copy

data = input().split()
N = int(data[0])
K = int(data[1])

TL = input()
TL = list(TL)
TLlist = []
now = TL[0]
nowlist = now

for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)

maxS = 0
cnt = 0
fg = 0
tfg = 0
fg2 = False
loplist = copy.deepcopy(TLlist)

for lop3 in range(len(loplist)):
    for lop2 in range(len(loplist)):
        if loplist[lop2][:1] == "0":
            if fg <= tfg:
                loplist[lop2] = loplist[lop2].replace('0', '1')
                cnt += 1
                if cnt == K:
                    fg2 = True
                    break
            else:
                tfg += 1
    loplist = "".join(loplist).split("0")
    for lop2 in loplist:
        if maxS < len(lop2):
            maxS = len(lop2)

    loplist = copy.deepcopy(TLlist)
    fg += 1
    cnt = 0
    tfg = 0
    if fg2 == False:
        break
    else:
        fg2 = False

print(maxS)


Fixed submission:
data = input().split()
N = int(data[0])
K = int(data[1])
 
TL = list(input())
TLlist = []
TLLlist = []
now = TL[0]
nowlist = now
anslist = []
 
for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        TLLlist.append(len(nowlist))
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)
TLLlist.append(len(nowlist))
 
 
if TLlist[0][:1] == "0" :
    anslist.append( sum(TLLlist[:2*K]) )
    anslist.append( sum(TLLlist[1:2*K + 2]) )
    for lop in range(3,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
elif TLlist[0][:1] == "1" :
    anslist.append( sum(TLLlist[:2*K + 1 ]) )
    for lop in range(2,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
 
print(max(anslist))

Buggy python submission (verdict: Time Limit Exceeded):
import copy

data = input().split()
N = int(data[0])
K = int(data[1])

TL = input()
TL = list(TL)
TLlist = []
now = TL[0]
nowlist = now

for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)

maxS = 0
cnt = 0
fg = 0
tfg = 0
fg2 = False
loplist = copy.deepcopy(TLlist)

for lop3 in range(len(loplist)):
    for lop2 in range(len(loplist)):
        if loplist[lop2][:1] == "0":
            if fg <= tfg:
                num = len(loplist[lop2])
                loplist[lop2] = ""
                for lop3 in range( num ):
                    loplist[lop2] += "1"
                cnt += 1
                if cnt == K:
                    fg2 = True
                    break
            else:
                tfg += 1
    loplist = "".join(loplist).split("0")
    for lop2 in loplist:
        if maxS < len(lop2):
            maxS = len(lop2)

    loplist = copy.deepcopy(TLlist)
    fg += 1
    cnt = 0
    tfg = 0
    if fg2 == False:
        break
    else:
        fg2 = False

print(maxS)


Fixed submission:
data = input().split()
N = int(data[0])
K = int(data[1])
 
TL = list(input())
TLlist = []
TLLlist = []
now = TL[0]
nowlist = now
anslist = []
 
for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        TLLlist.append(len(nowlist))
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)
TLLlist.append(len(nowlist))
 
 
if TLlist[0][:1] == "0" :
    anslist.append( sum(TLLlist[:2*K]) )
    anslist.append( sum(TLLlist[1:2*K + 2]) )
    for lop in range(3,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
elif TLlist[0][:1] == "1" :
    anslist.append( sum(TLLlist[:2*K + 1 ]) )
    for lop in range(2,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
 
print(max(anslist))

Buggy python submission (verdict: Time Limit Exceeded):
import copy

data = input().split()
N = int(data[0])
K = int(data[1])

TL = input()
TL = list(TL)
TLlist = []
now = TL[0]
nowlist = now

for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)

maxS = 0
cnt = 0
fg = 0
tfg = 0
fg2 = False
loplist = copy.deepcopy(TLlist)

for lop3 in range(len(loplist)):
    for lop2 in range(len(loplist)):
        if loplist[lop2][:1] == "0":
            if fg <= tfg:
                num = len(loplist[lop2])
                loplist[lop2] = ""
                for lop3 in range( num ):
                    loplist[lop2] += "1"
                cnt += 1
                if cnt == K:
                    fg2 = True
                    break
            else:
                tfg += 1
    loplist = "".join(loplist).split("0")
    for lop2 in loplist:
        if maxS < len(lop2):
            maxS = len(lop2)

    loplist = copy.deepcopy(TLlist)
    fg += 1
    cnt = 0
    tfg = 0
    if fg2 == False:
        break
    else:
        fg2 == False

print(maxS)


Fixed submission:
data = input().split()
N = int(data[0])
K = int(data[1])
 
TL = list(input())
TLlist = []
TLLlist = []
now = TL[0]
nowlist = now
anslist = []
 
for lop in range(1,len(TL)):
    if not (now == TL[lop]):
        TLlist.append(nowlist)
        TLLlist.append(len(nowlist))
        nowlist = TL[lop]
        now = TL[lop]
    else:
        nowlist += now
TLlist.append(nowlist)
TLLlist.append(len(nowlist))
 
 
if TLlist[0][:1] == "0" :
    anslist.append( sum(TLLlist[:2*K]) )
    anslist.append( sum(TLLlist[1:2*K + 2]) )
    for lop in range(3,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
elif TLlist[0][:1] == "1" :
    anslist.append( sum(TLLlist[:2*K + 1 ]) )
    for lop in range(2,len(TLlist),2):
        if 2*K +  lop > len(TLlist):
            break
        anslist.append( anslist[len(anslist)-1] - sum(TLLlist[lop-2:lop]) + sum(TLLlist[lop + 2*K - 1 : lop + 2*K + 1])  )
 
print(max(anslist))