Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
s_list=[]
first=s[0]
last=s[n-1]
state=first
length=1
for i in range(1,n):
    if (state=='0' and s[i]=='0') or (state=='1' and s[i]=='1'):
        state=s[i]
        length=length+1
    else:
        state=s[i]
        s_list.append(length)
        length=1
s_list.append(length)
if first=='0':
    if last=='0':
        number0=(len(s_list)+1)/2
    else:
        number0=len(s_list)/2
else:
    if last=='0':
        number0=len(s_list)/2
    else:
        number0=(len(s_list)-1)/2
if first=='0' and last=='0':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k]
        Max=sum(p_list)
        i=1
        while i+2*k+1<n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
        p_list=s_list[n-2*k:]
        if sum(p_list)>Max:
            Max=sum(p_list)
elif first=='0' and last=='1':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k]
        Max=sum(p_list)
        i=1
        while i+2*k+1<=n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
elif first=='1' and last=='0':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k+1]
        Max=sum(p_list)
        i=2
        while i+2*k+1<n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
        p_list=s_list[n-2*k:]
        if sum(p_list)>Max:
            Max=sum(p_list)
elif first=='1' and last=='1':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k+1]
        Max=sum(p_list)
        i=2
        while i+2*k+1<=n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
print(Max)


Fixed submission:
a,b=map(int,input().split())
print(max(a+b,2*a-1,2*b-1))

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
s_list=[]
first=s[0]
last=s[n-1]
state=first
length=1
for i in range(1,n):
    if (state=='0' and s[i]=='0') or (state=='1' and s[i]=='1'):
        state=s[i]
        length=length+1
    else:
        state=s[i]
        s_list.append(length)
        length=1
s_list.append(length)
if first=='0':
    if last=='0':
        number0=(len(s_list)+1)/2
    else:
        number0=len(s_list)/2
else:
    if last=='0':
        number0=len(s_list)/2
    else:
        number0=(len(s_list)-1)/2
if first=='0' and last=='0':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k]
        Max=sum(p_list)
        i=1
        while i+2*k+1<n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
        p_list=s_list[n-2*k:]
        if sum(p_list)>Max:
            Max=sum(p_list)
elif first=='0' and last=='1':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k]
        Max=sum(p_list)
        i=1
        while i+2*k+1<=n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
elif first=='1' and last=='0':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k+1]
        Max=sum(p_list)
        i=2
        while i+2*k+1<n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
        p_list=s_list[n-2*k:]
        if sum(p_list)>Max:
            Max=sum(p_list)
elif first=='1' and last=='1':
    if number0<=k:
        Max=n
    else:
        p_list=s_list[0:2*k+1]
        Max=sum(p_list)
        i=2
        while i+2*k+1<=n-1:
            p_list=s_list[i:i+2*k+1]
            if sum(p_list)>Max:
                Max=sum(p_list)
            i=i+2
print(Max)


Fixed submission:
a,b=map(int,input().split())
print(max(a+b,2*a-1,2*b-1))