Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
using static AtCoder.CalcL;
namespace AtCoder
{
    class AC
    {
        //const int MOD = 1000000007;
        const int MOD = 998244353;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dI = { 0, 1, 0, -1 };
        static readonly int[] dJ = { 1, 0, -1, 0 };
        //static List<List<int>> G = new List<List<int>>();
        //static List<List<Edge>>G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            if (S.Count(x => x == 'B') != S.Count(x => x == 'W'))
            {
                Console.WriteLine(0);return;
            }
            long ans = 1;
            int L = 0;
            var md = new Modulo(N + 1);
            for(var i = 0; i < 2 * N; i++)
            {
                if ((S[i] == 'B') ^ (i % 2 == 1)) L++;
                else
                {
                    ans *= Max(0, L);
                    ans %= MOD;
                    L--;
                }
            }
            ans = md.Mul((int)ans, md.Fac(N));
            Console.WriteLine(ans);

            //Console.Out.Flush();
        }
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }

        }
    }
    public class Scanner
    {
        public int[] ReadSplitInt()
        {
            return ConvertAll(Console.ReadLine().Split(), int.Parse);
        }
        public long[] ReadSplitLong()
        {
            return ConvertAll(Console.ReadLine().Split(), long.Parse);
        }
        public double[] ReadSplit_Double()
        {
            return ConvertAll(Console.ReadLine().Split(), double.Parse);
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public void Swap<T>(ref T a, ref T b)
        {
            T keep = a;
            a = b;
            b = keep;
        }

        static public void Display<T>(T[,] array2d, int n, int m)
        {
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                {
                    Console.Write($"{array2d[i, j]} ");
                }
                Console.WriteLine();
            }
        }

        static public long LPow(int a, int b)
        {
            return (long)Pow(a, b);
        }
    }
    static public class CalcI
    {
        public static int Gcd(int a, int b)
        {
            if (a * b == 0) { return Max(a, b); }
            return a % b == 0 ? b : Gcd(b, a % b);
        }
        public static int Lcm(int a, int b)
        {
            int g = Gcd(a, b);
            return a / g * b;
        }
        public static int Ceil(int n, int div)
        {
            return (n + div - 1) / div;
        }
    }
    static public class CalcL
    {
        public static long Gcd(long a, long b)
        {
            if (a * b == 0) { return Max(a, b); }
            return a % b == 0 ? b : Gcd(b, a % b);
        }
        public static long Lcm(long a, long b)
        {
            long g = Gcd(a, b);
            return a / g * b;
        }
        public static long Ceil(long n, long div)
        {
            return (n + div - 1) / div;
        }
    }
    class Modulo
    {
        private const int M = 1000000007;
        //private const int M = 998244353;
        private readonly int[] m_facs;
        public int Mul(int a, int b)
        {
            return (int)(Math.BigMul(a, b) % M);
        }
        public Modulo(int n)
        {
            m_facs = new int[n + 1];
            m_facs[0] = 1;
            for (int i = 1; i <= n; ++i)
            {
                m_facs[i] = Mul(m_facs[i - 1], i);
            }
        }
        public int Fac(int n)
        {
            return m_facs[n];
        }
        public int Pow(int a, int m)
        {
            switch (m)
            {
                case 0:
                    return 1;
                case 1:
                    return a;
                default:
                    int p1 = Pow(a, m / 2);
                    int p2 = Mul(p1, p1);
                    return ((m % 2) == 0) ? p2 : Mul(p2, a);
            }
        }
        public int Div(int a, int b)
        {
            return Mul(a, Pow(b, M - 2));
        }
        public int Ncr(int n, int r)
        {
            if (n < r) { return 0; }
            if (n == r) { return 1; }
            int res = Fac(n);
            res = Div(res, Fac(r));
            res = Div(res, Fac(n - r));
            return res;
        }
        public Modulo() { }
    }
}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.IO;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Text;
      |       ^~~~~~
a.cc:6:7: error: expected nested-name-specifier before 'static'
    6 | using static System.Math;
      |       ^~~~~~
a.cc:7:7: error: expected nested-name-specifier before 'static'
    7 | using static System.Array;
      |       ^~~~~~
a.cc:8:7: error: expected nested-name-specifier before 'static'
    8 | using static AtCoder.Tool;
      |       ^~~~~~
a.cc:9:7: error: expected nested-name-specifier before 'static'
    9 | using static AtCoder.CalcL;
      |       ^~~~~~
a.cc:19:16: error: 'readonly' does not name a type
   19 |         static readonly int[] dI = { 0, 1, 0, -1 };
      |                ^~~~~~~~
a.cc:20:16: error: 'readonly' does not name a type
   20 |         static readonly int[] dJ = { 1, 0, -1, 0 };
      |                ^~~~~~~~
a.cc:24:26: error: 'string' has not been declared
   24 |         static void Main(string[] args)
      |                          ^~~~~~
a.cc:24:35: error: expected ',' or '...' before 'args'
   24 |         static void Main(string[] args)
      |                                   ^~~~
a.cc:56:19: error: expected ':' before 'int'
   56 |             public int from;
      |                   ^~~~
      |                   :
a.cc:58:19: error: expected ':' before 'int'
   58 |             public int to;
      |                   ^~~~
      |                   :
a.cc:59:19: error: expected ':' before 'long'
   59 |             public long dist;
      |                   ^~~~~
      |                   :
a.cc:60:19: error: expected ':' before 'Edge'
   60 |             public Edge(int t, long c)
      |                   ^~~~~
      |                   :
a.cc:66:19: error: expected ':' before 'Edge'
   66 |             public Edge(int f, int t, long c)
      |                   ^~~~~
      |                   :
a.cc:73:10: error: expected ';' after struct definition
   73 |         }
      |          ^
      |          ;
a.cc:74:6: error: expected ';' after class definition
   74 |     }
      |      ^
      |      ;
a.cc:16:25: error: expected primary-expression before 'int'
   16 |         const int INF = int.MaxValue / 2;
      |                         ^~~
a.cc:17:27: error: expected primary-expression before 'long'
   17 |         const long SINF = long.MaxValue / 2;
      |                           ^~~~
a.cc: In static member function 'static void AtCoder::AC::Main(int*)':
a.cc:28:13: error: 'var' was not declared in this scope
   28 |             var cin = new Scanner();
      |             ^~~
a.cc:30:17: error: expected ';' before 'N'
   30 |             var N = int.Parse(Console.ReadLine());
      |                 ^
a.cc:31:17: error: expected ';' before 'S'
   31 |             var S = Console.ReadLine();
      |                 ^
a.cc:32:17: error: 'S' was not declared in this scope
   32 |             if (S.Count(x => x == 'B') != S.Count(x => x == 'W'))
      |                 ^
a.cc:32:25: error: 'x' was not declared in this scope
   32 |             if (S.Count(x => x == 'B') != S.Count(x => x == 'W'))
      |                         ^
a.cc:32:28: error: expected primary-expression before '>' token
   32 |             if (S.Count(x => x == 'B') != S.Count(x => x == 'W'))
      |                            ^
a.cc:32:54: error: expected primary-expression before '>' token
   32 |             if (S.Count(x => x == 'B') != S.Count(x => x == 'W'))
      |                                                      ^
a.cc:34:17: error: 'Console' was not declared in this scope
   34 |                 Console.WriteLine(0);return;
      |                 ^~~~~~~
a.cc:38:17: error: expected ';' before 'md'
   38 |             var md = new Modulo(N + 1);
      |                 ^~
a.cc:39:21: error: expected ';' before 'i'
   39 |             for(var i = 0; i < 2 * N; i++)
      |                     ^
a.cc:39:28: error: 'i' was not declared in this scope
   39 |             for(var i = 0; i < 2 * N; i++)
      |                            ^
a.cc:39:36: error: 'N' was not declared in this scope
   39 |             for(var i = 0; i < 2 * N; i++)
      |                                    ^
a.cc:41:22: error: 'S' was not declared in this scope
   41 |                 if ((S[i] == 'B') ^ (i % 2 == 1)) L++;
      |                      ^
a.cc:44:28: error: 'Max' was not declared in this scope
   44 |                     ans *= Max(0, L);
      |                            ^~~
a.cc:45:28: error: invalid use of member 'AtCoder::AC::MOD' in static member function
   45 |                     ans %= MOD;
      |                            ^~~
a.cc:15:19: note: declared here
   15 |         const int MOD = 998244353;
      |                   ^~~
a.cc:49:19: error: 'md' was not declared in this scope
   49 |             ans = md.Mul((int)ans, md.Fac(N));
      |                   ^~
a.cc:49:43: error: 'N' was not declared in this scope
   49 |             ans = md.Mul((int)ans, md.Fac(N));
      |                                           ^
a.cc:50:13: error: 'Console' was not declared in this scope
   50 |             Console.WriteLine(ans);
      |             ^~~~~~~
a.cc: At global scope:
a.cc:75:5: error: expected unqualified-id before 'public'
   75 |     public class Scanner
      |     ^~~~~~
a.cc:90:5: error: expected unqualified-id before 'public'
   90 |     public static class Tool
      |     ^~~~~~
a.cc:123:12: error: expected unqualified-id before 'public'
  123 |     static public class CalcI
      |            ^~~~~~
a.cc:140:12: error: expected unqualified-id before 'public'
  140 |     static public class CalcL
      |            ^~~~~~
a.cc:159:16: error: expected ':' before 'const'
  159 |         private const int M = 1000000007;
      |                ^~~~~~
      |                :
a.cc:161:16: error: expected ':' before 'readonly'
  161 |         private readonly int[] m_facs;
      |                ^~~~~~~~~
      |                :
a.cc:161:17: error: 'readonly' does not name a type
  161 |         private readonly int[] m_facs;
      |                 ^~~~~~~~
a.cc:162:15: error: expected ':' before 'int'
  162 |         public int Mul(int a, int b)
      |               ^~~~
      |               :
a.cc:166:15: error: expected ':' before 'Modulo'
  166 |         public Modulo(int n)
      |               ^~~~~~~
      |               :
a.cc:175:15: error: expected ':' before 'int'
  175 |         public int Fac(int n)
      |               ^~~~
      |               :
a.cc:179:15: error: expected ':' before 'int'
  179 |         public int Pow(int a, int m)
      |               ^~~~
      |               :
a.cc:193:15: error: expected ':' before 'int'
  193 |         public int Div(int a, int b)
      |               ^~~~
      |               :
a.cc:197:15: error: expected ':' before 'int'
  197 |         public int Ncr(int n, int r)
      |               ^~~~
      |               :
a.cc:206:15: error: expected ':' before 'Modulo'
  206 |         public Modulo() { }
      |               ^~~~~~~
      |               :
a.cc:207:6: error: expected ';' after class definition
  207 |     }
      |      ^
      |      ;
a.cc: In member function 'int AtCoder::Modulo::Mul(int, int)':
a.cc:164:26: error: 'Math' was not declared in this scope
  164 |             return (int)(Math.BigMul(a, b) % M);
      |                          ^~~~
a.cc: In constructor 'AtCoder::Modulo::Modulo(int)':
a.cc:168:13: error: 'm_facs' was not declared in this scope
  168 |             m_facs = new int[n + 1];
      |             ^~~~~~
a.cc: In member function 'int AtCoder::Modulo::Fac(int)':
a.cc:177:20: error: 'm_facs' was not declared in this scope
  177 |             return m_facs[n];
      |                    ^~~~~~