Language: C++

https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_f##include<bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
#define next asdnext
#define prev asdprev
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<int MOD = 1000000007>
struct mod_int {
    int val;
    mod_int(long long val_ = 0) : val(val_ >= 0 ? val_ % MOD : (MOD - (-val_) % MOD) % MOD) {}
    bool operator==(const mod_int &rhs) const { return val == rhs.val; }
    bool operator!=(const mod_int &rhs) const { return std::rel_ops::operator!=(*this, rhs); }
    mod_int &operator+=(const mod_int &rhs) {
        if ((val += rhs.val) >= MOD) { val -= MOD; }
        return *this;
    }
    mod_int &operator-=(const mod_int &rhs) {
        if ((val += MOD - rhs.val) >= MOD) { val -= MOD; }
        return *this;
    }
    mod_int &operator*=(const mod_int &rhs) {
        val = (int) ((long long) val * rhs.val % MOD);
        return *this;
    }
    mod_int &operator/=(const mod_int &rhs) { return *this *= rhs.inv(); }
    mod_int operator+() const { return *this; }
    mod_int operator-() const { return mod_int(-val); }
    mod_int operator++() { return *this += 1; }
    mod_int operator--() { return *this -= 1; }
    mod_int operator++(signed) {
        const mod_int ret(*this);
        ++*this;
        return ret;
    }
    mod_int operator--(signed) {
        const mod_int ret(*this);
        --*this;
        return ret;
    }
    mod_int operator+(const mod_int &rhs) const { return mod_int(*this) += rhs; }
    mod_int operator-(const mod_int &rhs) const { return mod_int(*this) -= rhs; }
    mod_int operator*(const mod_int &rhs) const { return mod_int(*this) *= rhs; }
    mod_int operator/(const mod_int &rhs) const { return mod_int(*this) /= rhs; }
    mod_int inv() const {
        int a = MOD, b = val, u = 0, v = 1;
        while (b > 0) {
            int t = a / b;
            std::swap(a -= t * b, b);
            std::swap(u -= t * v, v);
        }
        return mod_int(u);
    }
    mod_int pow(long long n) const {
        if (n < 0) { return pow(-n).inv(); }
        mod_int ret = 1, mul = *this;
        while (n > 0) {
            if (n & 1) { ret *= mul; }
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend std::istream &operator>>(std::istream &is, mod_int &rhs) {
        long long v;
        is >> v;
        rhs = v;
        return is;
    }
    friend std::ostream &operator<<(std::ostream &os, const mod_int &rhs) { return os << rhs.val; }
    struct combination {
        std::vector<mod_int> fact{1, 1}, f_inv{1, 1}, inv{0, 1};
        void calc(int n) {
            while (fact.size() <= n) {
                int i = fact.size();
                fact.push_back(fact[i - 1] * i);
                inv.push_back(-inv[MOD % i] * (MOD / i));
                f_inv.push_back(f_inv[i - 1] * inv[i]);
            }
        }
        mod_int P(int n, int r) { return r < 0 || n < r ? 0 : (calc(n), fact[n] * f_inv[n - r]); }
        mod_int C(int n, int r) { return r < 0 || n < r ? 0 : (calc(n), fact[n] * f_inv[r] * f_inv[n - r]); }
        mod_int H(int n, int r) { return C(n + r - 1, r); }
    };
};

string S;
int N;
using mint=mod_int<998244353>;
mint dp[2200][2200];
signed main() {
    cin >> S;
    N = S.length();
    vint rlim(2 * N), blim(2 * N);
    rep(i, N) {
        if (S[i] == '0') { rlim[i + 1] = rlim[i] + 2, blim[i + 1] = blim[i]; }
        if (S[i] == '1') { rlim[i + 1] = rlim[i] + 1, blim[i + 1] = blim[i] + 1; }
        if (S[i] == '2') { rlim[i + 1] = rlim[i], blim[i + 1] = blim[i] + 2; }
    }
    rep(i, N) { rlim[i + N + 1] = rlim[i + N], blim[i + N + 1] = blim[i + N]; }
    dp[0][0] = 1;
    reps(i, 2 * N) {
        for (int j = 0; j <= 2 * N; j++) {
            if (j > rlim[i] || i - j > blim[i]) { continue; }
            dp[i][j] = dp[i - 1][j];
            if (j != 0) { dp[i][j] += dp[i - 1][j - 1]; }
        }
    }
    cout << dp[2 * N][rlim[2 * N]] << endl;
}

Compiler output:
a.cc:1:1: error: 'https' does not name a type
    1 | https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_f##include<bits/stdc++.h>
      | ^~~~~
a.cc:14:12: error: 'vector' does not name a type
   14 | using vint=vector<int>;
      |            ^~~~~~
a.cc:15:13: error: 'vector' does not name a type
   15 | using vvint=vector<vint>;
      |             ^~~~~~
a.cc:16:12: error: 'pair' does not name a type
   16 | using pint=pair<int, int>;
      |            ^~~~
a.cc:17:13: error: 'vector' does not name a type
   17 | using vpint=vector<pint>;
      |             ^~~~~~
a.cc:18:47: error: 'priority_queue' does not name a type
   18 | template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
      |                                               ^~~~~~~~~~~~~~
a.cc: In function 'long long int gcd(long long int, long long int)':
a.cc:23:17: error: 'swap' was not declared in this scope
   23 |     while (b) { swap(a %= b, b); }
      |                 ^~~~
a.cc: At global scope:
a.cc:41:36: error: 'ostream' does not name a type
   41 | template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
      |                                    ^~~~~~~
a.cc:45:22: error: 'ostream' does not name a type
   45 | template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
      |                      ^~~~~~~
a.cc: In constructor 'setup::setup()':
a.cc:56:9: error: 'cout' was not declared in this scope
   56 |         cout << fixed << setprecision(PREC);
      |         ^~~~
a.cc:56:17: error: 'fixed' was not declared in this scope
   56 |         cout << fixed << setprecision(PREC);
      |                 ^~~~~
a.cc:56:26: error: 'setprecision' was not declared in this scope
   56 |         cout << fixed << setprecision(PREC);
      |                          ^~~~~~~~~~~~
a.cc:57:9: error: 'cerr' was not declared in this scope
   57 |         cerr << fixed << setprecision(PREC);
      |         ^~~~
a.cc: At global scope:
a.cc:117:17: error: 'istream' in namespace 'std' does not name a type
  117 |     friend std::istream &operator>>(std::istream &is, mod_int &rhs) {
      |                 ^~~~~~~
a.cc:1:1: note: 'std::istream' is defined in header '<istream>'; this is probably fixable by adding '#include <istream>'
  +++ |+#include <istream>
    1 | https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_f##include<bits/stdc++.h>
a.cc:123:17: error: 'ostream' in namespace 'std' does not name a type
  123 |     friend std::ostream &operator<<(std::ostream &os, const mod_int &rhs) { return os << rhs.val; }
      |                 ^~~~~~~
a.cc:1:1: note: 'std::ostream' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_f##include<bits/stdc++.h>
a.cc:125:14: error: 'vector' in namespace 'std' does not name a template type
  125 |         std::vector<mod_int> fact{1, 1}, f_inv{1, 1}, inv{0, 1};
      |              ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_f##include<bits/stdc++.h>
a.cc:125:40: error: expected unqualified-id before ',' token
  125 |         std::vector<mod_int> fact{1, 1}, f_inv{1, 1}, inv{0, 1};
      |                                        ^
a.cc:125:53: error: expected unqualified-id before ',' token
  125 |         std::vector<mod_int> fact{1, 1}, f_inv{1, 1}, inv{0, 1};
      |                                                     ^
a.cc: In member function 'bool mod_int<MOD>::operator!=(const mod_int<MOD>&) const':
a.cc:66:61: error: 'std::rel_ops' has not been declared
   66 |     bool operator!=(const mod_int &rhs) const { return std::rel_ops::operator!=(*this, rhs); }
      |                                                             ^~~~~~~
a.cc: In member function 'mod_int<MOD> mod_int<MOD>::inv() const':
a.cc:102:18: error: 'swap' is not a member of 'std'
  102 |             std::swap(a -= t * b, b);
      |                  ^~~~
a.cc:103:18: error: 'swap' is not a member of 'std'
  103 |             std::swap(u -= t * v, v);
      |                  ^~~~
a.cc: In member function 'void mod_int<MOD>::combination::calc(long long int)':
a.cc:127:20: error: 'fact' was not declared in this scope
  127 |             while (fact.size() <= n) {
      |                    ^~~~
a.cc:130:17: error: invalid use of member function 'mod_int<MOD> mod_int<MOD>::inv() const' (did you forget the '()' ?)
  130 |                 inv.push_back(-inv[MOD % i] * (MOD / i));
      |                 ^~~
      |                    ()
a.cc:131:17: error: 'f_inv' was not declared in this scope; did you mean 'inv'?
  131 |                 f_inv.push_back(f_inv[i - 1] * inv[i]);
      |                 ^~~~~
      |                 inv
a.cc: In member function 'mod_int<MOD> mod_int<MOD>::combination::P(long long int, long long int)':
a.cc:134:73: error: 'fact' was not declared in this scope
  134 |         mod_int P(int n, int r) { return r < 0 || n < r ? 0 : (calc(n), fact[n] * f_inv[n - r]); }
      |                                                                         ^~~~
a.cc:134:83: error: 'f_inv' was not declared in this scope; did you mean 'inv'?
  134 |         mod_int P(int n, int r) { return r < 0 || n < r ? 0 : (calc(n), fact[n] * f_inv[n - r]); }
      |                                                                                   ^~~~~
      |                                                                                   inv
a.cc: In member function 'mod_int<MOD> mod_int<MOD>::combination::C(long long int, long long int)':
a.cc:135:73: error: 'fact' was not declared in this scope
  135 |         mod_int C(int n, int r) { return r < 0 || n < r ? 0 : (calc(n), fact[n] * f_inv[r] * f_inv[n - r]); }
      |                                                                         ^~~~
a.cc:135:83: error: 'f_inv' was not declared in this scope; did you mean 'inv'?
  135 |         mod_int C(int n, int r) { return r < 0 || n < r ? 0 : (calc(n), fact[n] * f_inv[r] * f_inv[n - r]); }
      |                                                                                   ^~~~~
      |                                                                                   inv
a.cc: At global scope:
a.cc:140:1: error: 'string' does not name a type
  140 | string S;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:145:5: error: 'cin' was not declared in this scope
  145 |     cin >> S;
      |     ^~~
a.cc:145:12: error: 'S' was not declared in this scope
  145 |     cin >> S;
      |            ^
a.cc:147:5: error: 'vint' was not declared in this scope; did you mean 'mint'?
  147 |     vint rlim(2 * N), blim(2 * N);
      |     ^~~~
      |     mint
a.cc:149:28: error: 'rlim' was not declared in this scope
  149 |         if (S[i] == '0') { rlim[i + 1] = rlim[i] + 2, blim[i + 1] = blim[i]; }
      |                            ^~~~
a.cc:149:55: error: 'blim' was not declared in this scope
  149 |         if (S[i] == '0') { rlim[i + 1] = rlim[i] + 2, blim[i + 1] = blim[i]; }
      |                                                       ^~~~
a.cc:150:28: error: 'rlim' was not declared in this scope
  150 |         if (S[i] == '1') { rlim[i + 1] = rlim[i] + 1, blim[i + 1] = blim[i] + 1; }
      |                            ^~~~
a.cc:150:55: error: 'blim' was not declared in this scope
  150 |         if (S[i] == '1') { rlim[i + 1] = rlim[i] + 1, blim[i + 1] = blim[i] + 1; }
      |                                                       ^~~~
a.cc:151:28: error: 'rlim' was not declared in this scope
  151 |         if (S[i] == '2') { rlim[i + 1] = rlim[i], blim[i + 1] = blim[i] + 2; }
      |                            ^~~~
a.cc:151:51: error: 'blim' was not declared in this scope
  151 |         if (S[i] == '2') { rlim[i + 1] = rlim[i], blim[i + 1] = blim[i] + 2; }
      |                                                   ^~~~
a.cc:153:17: error: 'rlim' was not declared in this scope
  153 |     rep(i, N) { rlim[i + N + 1] = rlim[i + N], blim[i + N + 1] = blim[i + N]; }
      |                 ^~~~
a.cc:153:48: error: 'blim' was not declared in this scope
  153 |     rep(i, N) { rlim[i + N + 1] = rlim[i + N], blim[i + N + 1] = blim[i + N]; }
      |                                                ^~~~
a.cc:157:21: error: 'rlim' was not declared in this scope
  157 |             if (j > rlim[i] || i - j > blim[i]) { continue; }
      |                     ^~~~
a.cc:157:40: error: 'blim' was not declared in this scope
  157 |             if (j > rlim[i] || i - j > blim[i]) { continue; }
      |                                        ^~~~
a.cc:162:5: error: 'cout' was not declared in this scope
  162 |     cout << dp[2 * N][rlim[2 * N]] << endl;
      |     ^~~~
a.cc:162:23: error: 'rlim' was not declared in this scope
  162 |     cout << dp[2 * N][rlim[2 * N]] << endl;
      |                       ^~~~
a.cc:162:39: error: 'endl' was not declared in this scope
  162 |     cout << dp[2 * N][rlim[2 * N]] << endl;
      |                                       ^~~~