Buggy python submission (verdict: Runtime Error):
from queue import deque
def main():
    R, W = "R", "W"
    N = int(input())
    C = input()

    counter = dict()
    for c in C:
        counter[c] = counter.get(c, 0) + 1
    r = counter[R] 

    _counter = dict()
    for c in C[r:]:
        _counter[c] = _counter.get(c, 0) + 1
    _r = _counter.get(R, 0)

    ans = _r
    print(ans)
if __name__ == '__main__':
    main()


Fixed submission:
from queue import deque
def main():
    R, W = "R", "W"
    N = int(input())
    C = input()

    counter = dict()
    for c in C:
        counter[c] = counter.get(c, 0) + 1
    r = counter.get(R, 0)

    _counter = dict()
    for c in C[r:]:
        _counter[c] = _counter.get(c, 0) + 1
    _r = _counter.get(R, 0)

    ans = _r
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
    for c in C[r:]:
        _counter[c] = _counter.get(c, 0) + 1
    _r = _counter.get(R, 0)

    ans = _r
    print(ans)
if __name__ == '__main__':
    main()


Fixed submission:
from queue import deque
def main():
    R, W = "R", "W"
    N = int(input())
    C = input()

    counter = dict()
    for c in C:
        counter[c] = counter.get(c, 0) + 1
    r = counter.get(R, 0)

    _counter = dict()
    for c in C[r:]:
        _counter[c] = _counter.get(c, 0) + 1
    _r = _counter.get(R, 0)

    ans = _r
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
from queue import deque
def main():
    R, W = "R", "W"
    N = int(input())
    C = input()

    counter = dict()
    for c in C:
        counter[c] = counter.get(c, 0) + 1
    r = counter[R] 

    _counter = dict()
    for c in C[r:]:
        _counter[c] = _counter.get(c, 0) + 1
    _r = _counter[R]

    ans = _r
    print(ans)
if __name__ == '__main__':
    main()


Fixed submission:
from queue import deque
def main():
    R, W = "R", "W"
    N = int(input())
    C = input()

    counter = dict()
    for c in C:
        counter[c] = counter.get(c, 0) + 1
    r = counter.get(R, 0)

    _counter = dict()
    for c in C[r:]:
        _counter[c] = _counter.get(c, 0) + 1
    _r = _counter.get(R, 0)

    ans = _r
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from queue import deque
def main():
    R, W = "R", "W"
    N = int(input())
    _C = input()
    C = deque(_C)

    count = 0
    while True:
        i = len(C) -1
        while C[i] != R:
            i -= 1
            if i < 0:
                break
        j = 0
        while C[j] != W:
            j +=1
            if j >= len(C):
                break
        if  i < j:
            break
        C[i], C[j] = C[j], C[i]
        count += 1
    
    print(count)
if __name__ == '__main__':
    main()


Fixed submission:
from queue import deque
def main():
    R, W = "R", "W"
    N = int(input())
    C = input()

    counter = dict()
    for c in C:
        counter[c] = counter.get(c, 0) + 1
    r = counter.get(R, 0)

    _counter = dict()
    for c in C[r:]:
        _counter[c] = _counter.get(c, 0) + 1
    _r = _counter.get(R, 0)

    ans = _r
    print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
from queue import deque
def main():
    R, W = "R", "W"
    N = int(input())
    _C = input()
    C = deque(_C)

    count = 0
    while True:
        i = len(C) -1
        while C[i] != R:
            i -= 1
        j = 0
        while C[j] != W:
            j +=1
            if j >= len(C):
                break
        if  i < j:
            break
        C[i], C[j] = C[j], C[i]
        count += 1
    
    print(count)
if __name__ == '__main__':
    main()


Fixed submission:
from queue import deque
def main():
    R, W = "R", "W"
    N = int(input())
    C = input()

    counter = dict()
    for c in C:
        counter[c] = counter.get(c, 0) + 1
    r = counter.get(R, 0)

    _counter = dict()
    for c in C[r:]:
        _counter[c] = _counter.get(c, 0) + 1
    _r = _counter.get(R, 0)

    ans = _r
    print(ans)
if __name__ == '__main__':
    main()