Problem p02918 (python)

Fixed submission:
N,K = map(int,input().split())

s = input()

S = list(s)

num = 0
for i in range(N-1):

    if S[i] == S[i+1]:
        num += 1

print (min(N-1,num + 2*K))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
point=s[0]
count=0
while k!=0 and count!=n-1:
    if s[count]!=point:
        while True:
            if s[count]!=point:
                s[count]=point
                count +=1
                if count==n:break
            else:break
        k -=1
    else:count +=1

print("".join(s))
ans=0
for i in range(n-1):
    if s[i]==s[i+1]:
        ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
point=s[0]
count=0
while k!=0 and count!=n-1:
    if s[count]!=point:
        while True:
            if s[count]!=point:
                s[count]=point
                count +=1
            else:break
        k -=1
    else:count +=1

ans=0
for i in range(n-1):
    if s[i]==s[i+1]:
        ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
point=s[0]
count=0
while k!=0 and count!=n-1:
    if s[count]!=point:
        while True:
            if s[count]!=point:
                s[count]=point
                count +=1
            else:break
        k -=1
    else:count +=1

ans=0
for i in range(n-1,0,-1):
    if s[i]==s[i-1]:
        ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
point=s[0]
count=0
while k!=0:
    if s[count]!=point:
        while True:
            if s[count]!=point:
                s[count]=point
                count +=1
            else:break
        k -=1
    else:count +=1

ans=0
for i in range(n-1,0,-1):
    if s[i]==s[i-1]:
        ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
point=s[0]
count=1
while k!=0:
    if s[count]!=point:
        while True:
            if s[count]!=point:
                s[count]=point
                count +=1
            else:break
        k -=1
    else:count +=1

ans=0
for i in range(n-1,0,-1):
    if s[i]==s[i-1]:
        ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
point=s[0]
count=1
while k!=0:
    if s[count]!=point:
        while 1:
            if s[count]!=point:
                s[count]=point
                count +=1
            else:break
        k -=1
    else:count +=1

ans=0
for i in range(n-1,0,-1):
    if s[i]==s[i-1]:
        ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
point=s[0]
count=1
while k!=0:
    if s[count]!=point:
        while 1:
            if s[count]!=point:
                s[count]=point
                count +=1
            else:break
        k -=1
    else:
        count +=1

ans=0
for i in range(n-1,0,-1):
    if s[i]==s[i-1]:
        ans +=1

print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
point=s[0]
count=1
while k!=0:
    if s[count]!=point:
        while 1:
            if s[count]!=point:
                s[count]=point
                count +=1
            else:break
        k -=1
    else:
        count +=1

ans=0
for i in range(n-1,0,-1):
    if s[i]==s[i-1]:
        ans +=1

print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=list(input())
point=s[0]
count=1
while k!=0:
    if s[count]!=point:
        while 1:
            if s[count]!=point:
                s[count]=point
                count +=1
            elif s[count]==point:break
        k -=1
    else:
        count +=1

ans=0
for i in range(n-1,0,-1):
    if s[i]==s[i-1]:
        ans +=1

print(ans)