Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    s_list = list(input())
    mod = 10 ** 9 + 7

    if s_list[0] == "W" or s_list[-1] == "W":
        print(0)
        return

    from math import factorial

    l_counter = 0
    res = 1

    for i in range(2 * n):
        s = s_list[i]
        if i % 2 == 0:
            s = "W" if s == "B" else "B"

        if s == "W":
            l_counter += 1
        else:
            res *= l_counter
            l_counter -= 1
            if l_counter < 0:
                print(0)
                return

    if l_counter != 0:
        print(0)
    else:
        print(res * factorial(n) % mod)
        
resolve()

Fixed submission:
import math
n = int(input())
s = [0 if i == "W" else 1 for i in list(input())]
cnt = 0
c = 1
for i in range(n * 2):
    if (s[i] + cnt) % 2 != 0:
        cnt += 1
    else:
        c = (c * (cnt if cnt != 0 else 1)) % (10 ** 9 + 7)
        cnt -= 1
    if cnt < 0:
        print(0)
        exit()
if cnt != 0:
    print(0)
else:
    print((c * math.factorial(n)) % (10 ** 9 + 7))

Buggy python submission (verdict: Runtime Error):
n = int(input())
s_list = list(input())
mod = 10 ** 9 + 7

if s_list[0] == "W" or s_list[-1] == "W":
    print(0)
    return

from math import factorial

l_counter = 0
res = 1

for i in range(2 * n):
    s = s_list[i]
    if i % 2 == 0:
        s = "W" if s == "B" else "B"

    if s == "W":
        l_counter += 1
    else:
        res *= l_counter
        l_counter -= 1
        if l_counter < 0:
            print(0)
            return

if l_counter != 0:
    print(0)
else:
    print(res * factorial(n) % mod)

Fixed submission:
import math
n = int(input())
s = [0 if i == "W" else 1 for i in list(input())]
cnt = 0
c = 1
for i in range(n * 2):
    if (s[i] + cnt) % 2 != 0:
        cnt += 1
    else:
        c = (c * (cnt if cnt != 0 else 1)) % (10 ** 9 + 7)
        cnt -= 1
    if cnt < 0:
        print(0)
        exit()
if cnt != 0:
    print(0)
else:
    print((c * math.factorial(n)) % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    s_list = list(input())
    mod = 10 ** 9 + 7

    from math import factorial

    l_counter = 0
    res = 1

    for i in range(2 * n):
        s = s_list[i]
        if i % 2 == 0:
            s = "W" if s == "B" else "B"

        if s == "W":
            l_counter += 1
        else:
            res *= l_counter
            l_counter -= 1
            if l_counter < 0:
                print(0)
                return

    if l_counter != 0:
        print(0)
    else:
        print(res * factorial(n) % mod)
        
resolve()

Fixed submission:
import math
n = int(input())
s = [0 if i == "W" else 1 for i in list(input())]
cnt = 0
c = 1
for i in range(n * 2):
    if (s[i] + cnt) % 2 != 0:
        cnt += 1
    else:
        c = (c * (cnt if cnt != 0 else 1)) % (10 ** 9 + 7)
        cnt -= 1
    if cnt < 0:
        print(0)
        exit()
if cnt != 0:
    print(0)
else:
    print((c * math.factorial(n)) % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = list(input())
mod = 10 ** 9 + 7

from math import factorial

l_counter = 0
pair_counter = 0
res = 1

for i in range(2 * n):
    s = s_list[i]
    if i % 2 == 0:
        s = "W" if s == "B" else "B"

    if s == "W":
        l_counter += 1
    else:
        pair_counter += 1
        res *= l_counter
        l_counter -= 1

if pair_counter != n:
    print(0)
else:
    print(res * factorial(n) % mod)

Fixed submission:
import math
n = int(input())
s = [0 if i == "W" else 1 for i in list(input())]
cnt = 0
c = 1
for i in range(n * 2):
    if (s[i] + cnt) % 2 != 0:
        cnt += 1
    else:
        c = (c * (cnt if cnt != 0 else 1)) % (10 ** 9 + 7)
        cnt -= 1
    if cnt < 0:
        print(0)
        exit()
if cnt != 0:
    print(0)
else:
    print((c * math.factorial(n)) % (10 ** 9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = list(input())
mod = 10 ** 9 + 7

from math import factorial

for i in range(n):
    s_list[i * 2] = "B" if s_list[i * 2] == "W" else "W"

l_counter = 0
pair_counter = 0
res = 1
for s in s_list:
    if s == "W":
        l_counter += 1
    else:
        pair_counter += 1
        res *= l_counter
        l_counter -= 1

if pair_counter != n:
    print(0)
else:
    print(res * factorial(n) % mod)

Fixed submission:
import math
n = int(input())
s = [0 if i == "W" else 1 for i in list(input())]
cnt = 0
c = 1
for i in range(n * 2):
    if (s[i] + cnt) % 2 != 0:
        cnt += 1
    else:
        c = (c * (cnt if cnt != 0 else 1)) % (10 ** 9 + 7)
        cnt -= 1
    if cnt < 0:
        print(0)
        exit()
if cnt != 0:
    print(0)
else:
    print((c * math.factorial(n)) % (10 ** 9 + 7))