Buggy python submission (verdict: Runtime Error):
n = int(input())
c = input()
cl = list(c)
wi = 0
wnum=0
ri = n-1
rnum=0
br=0
bw=0
for i in range(n):
    while(cl[wi] == "R" and bw==0):
        wi+=1
        if(wi >= n-1):
            bw=1
            break
    if(cl[wi] == "W"):
        wnum+=1
    wi+=1
    if(wi >= n-1):
        wi=0
        bw=1
    while(cl[ri] == "W" and br==0):
        ri-=1
        if(ri <= 0):
            br=1
            break
    if(cl[ri] == "R"):
        rnum+=1
    ri-=1
    if(ri <= 0):
        ri=n-1
        br=1
    if(ri < wi):
        res1 = i+1
    if(br*bw==1):
        break
print(min(res1, rnum, wnum))

Fixed submission:
n = int(input())
c = input()
cl = list(c)
wi = 0
wnum=0
ri = n-1
rnum=0
br=0
bw=0
res1 = n
break1 = 0
for i in range(n):
    while(cl[wi] == "R" and bw==0):
        wi+=1
        if(wi >= n-1):
            bw=1
            break
    if(cl[wi] == "W"):
        wnum+=1
    while(cl[ri] == "W" and br==0):
        ri-=1
        if(ri <= 0):
            br=1
            break
    if(cl[ri] == "R"):
        rnum+=1
    if(ri < wi and break1 == 0):
        res1 = i
        break1 = 1
    wi+=1
    if(wi >= n-1):
        wi=0
        bw=1
    ri-=1
    if(ri <= 0):
        ri=n-1
        br=1

    if(br*bw==1):
        break
print(min(res1, rnum, wnum))

Buggy python submission (verdict: Runtime Error):
n = int(input())
c = input()
cl = list(c)
wi = 0
wnum=0
ri = n-1
rnum=0
br=0
bw=0
for i in range(n):
    while(cl[wi] == "R" and bw==0):
        wi+=1
        if(wi >= n-1):
            bw=1
            break
    if(cl[wi] == "W"):
        wnum+=1
    wi+=1
    if(wi >= n-1):
        wi=0
        bw=1
    while(cl[ri] == "W" and br==0):
        ri-=1
        if(ri <= 0):
            br=1
            break
    if(cl[ri] == "R"):
        rnum+=1
    ri-=1
    if(ri <= 0):
        ri=n-1
        br=1
    #print(wi, ri)
    if(ri < wi):
        res1 = i+1
    if(br*bw==1):
        break
print(min(res1, rnum, wnum))

Fixed submission:
n = int(input())
c = input()
cl = list(c)
wi = 0
wnum=0
ri = n-1
rnum=0
br=0
bw=0
res1 = n
break1 = 0
for i in range(n):
    while(cl[wi] == "R" and bw==0):
        wi+=1
        if(wi >= n-1):
            bw=1
            break
    if(cl[wi] == "W"):
        wnum+=1
    while(cl[ri] == "W" and br==0):
        ri-=1
        if(ri <= 0):
            br=1
            break
    if(cl[ri] == "R"):
        rnum+=1
    if(ri < wi and break1 == 0):
        res1 = i
        break1 = 1
    wi+=1
    if(wi >= n-1):
        wi=0
        bw=1
    ri-=1
    if(ri <= 0):
        ri=n-1
        br=1

    if(br*bw==1):
        break
print(min(res1, rnum, wnum))

Buggy python submission (verdict: Runtime Error):
n = int(input())
c = input()
cl = list(c)
wi = 0
wnum=0
ri = n-1
rnum=0
for i in range(n):
    br=0
    bw=0
    while(cl[wi] == "R" and br==0):
        wi+=1
        if(wi >= n-1):
            br=1
            break
    if(cl[wi] == "W"):
        wnum+=1
    wi+=1
    if(wi >= n-1):
        wi=0
        br=1
    while(cl[ri] == "W" and bw==0):
        ri-=1
        if(ri <= 0):
            bw=1
            break
    if(cl[ri] == "R"):
        rnum+=1
    ri-=1
    if(ri <= 0):
        ri=n-1
        bw=1
    #print(wi, ri)
    if(ri < wi):
        res1 = i+1
    if(br*bw==1):
        break
print(min(res1, rnum, wnum))

Fixed submission:
n = int(input())
c = input()
cl = list(c)
wi = 0
wnum=0
ri = n-1
rnum=0
br=0
bw=0
res1 = n
break1 = 0
for i in range(n):
    while(cl[wi] == "R" and bw==0):
        wi+=1
        if(wi >= n-1):
            bw=1
            break
    if(cl[wi] == "W"):
        wnum+=1
    while(cl[ri] == "W" and br==0):
        ri-=1
        if(ri <= 0):
            br=1
            break
    if(cl[ri] == "R"):
        rnum+=1
    if(ri < wi and break1 == 0):
        res1 = i
        break1 = 1
    wi+=1
    if(wi >= n-1):
        wi=0
        bw=1
    ri-=1
    if(ri <= 0):
        ri=n-1
        br=1

    if(br*bw==1):
        break
print(min(res1, rnum, wnum))