Language: C++

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    int x, y;
    cin >> s >> x >> y;

    vector<int> v;
    vector<int> h;

    bool b = true;
    int c = 0;
    REP(i, sz(s)) {
        if (s[i] == 'T') {
            if (c != 0) {
                if (b) h.push_back(c);
                else v.push_back(c);
            }
            b = !b;
            c = 0;
        } else {
            c++;
        }
    }
    if (c != 0) {
        if (b) h.push_back(c);
        else v.push_back(c);
    }

    vector<vector<bool>> hdp(sz(h) + 1, vector<bool>(20001, false));
    hdp[0][10000] = true;
    REP(i, sz(h)) {
        REP(j, 20001) {
            if (j - h[i] >= 0) hdp[i + 1][j] = hdp[i + 1][j] || hdp[i][j - h[i]];
            if (j + h[i] < 20001) hdp[i + 1][j] = hdp[i + 1][j] || hdp[i][j + h[i]];
        }
    }
    if (!hdp[sz(h)][x + 10000]) {
        cout << "No" << EOL;
        return;
    }

    vector<vector<bool>> vdp(sz(v) + 1, vector<bool>(20001, false));
    vdp[0][10000] = true;
    REP(i, sz(v)) {
        REP(j, 20001) {
            if (j - v[i] >= 0) vdp[i + 1][j] = vdp[i + 1][j] || vdp[i][j - v[i]];
            if (j + v[i] < 20001) vdp[i + 1][j] = vdp[i + 1][j] || vdp[i][j + v[i]];
        }
    }
    if (!vdp[sz(v)][y + 10000]) {
        cout << "No" << EOL;
        return;
    }

    cout << "Yes" << EOL;
}
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    int x, y;
    cin >> s >> x >> y;

    vector<int> v;
    vector<int> h;

    bool b = true;
    int c = 0;
    REP(i, sz(s)) {
        if (s[i] == 'T') {
            if (c != 0) {
                if (b) h.push_back(c);
                else v.push_back(c);
            }
            b = !b;
            c = 0;
        } else {
            c++;
        }
    }
    if (c != 0) {
        if (b) h.push_back(c);
        else v.push_back(c);
    }

    vector<vector<bool>> hdp(sz(h) + 1, vector<bool>(20001, false));
    hdp[0][10000] = true;
    REP(i, sz(h)) {
        REP(j, 20001) {
            if (j - h[i] >= 0) hdp[i + 1][j] = hdp[i + 1][j] || hdp[i][j - h[i]];
            if (j + h[i] < 20001) hdp[i + 1][j] = hdp[i + 1][j] || hdp[i][j + h[i]];
        }
    }
    if (!hdp[sz(h)][x + 10000]) {
        cout << "No" << EOL;
        return;
    }

    vector<vector<bool>> vdp(sz(v) + 1, vector<bool>(20001, false));
    vdp[0][10000] = true;
    REP(i, sz(v)) {
        REP(j, 20001) {
            if (j - v[i] >= 0) vdp[i + 1][j] = vdp[i + 1][j] || vdp[i][j - v[i]];
            if (j + v[i] < 20001) vdp[i + 1][j] = vdp[i + 1][j] || vdp[i][j + v[i]];
        }
    }
    if (!vdp[sz(v)][y + 10000]) {
        cout << "No" << EOL;
        return;
    }

    cout << "Yes" << EOL;
}
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    int x, y;
    cin >> s >> x >> y;

    vector<int> v;
    vector<int> h;

    bool b = true;
    int c = 0;
    REP(i, sz(s)) {
        if (s[i] == 'T') {
            if (c != 0) {
                if (b) h.push_back(c);
                else v.push_back(c);
            }
            b = !b;
            c = 0;
        } else {
            c++;
        }
    }
    if (c != 0) {
        if (b) h.push_back(c);
        else v.push_back(c);
    }

    vector<vector<bool>> hdp(sz(h) + 1, vector<bool>(20001, false));
    hdp[0][10000] = true;
    REP(i, sz(h)) {
        REP(j, 20001) {
            if (j - h[i] >= 0) hdp[i + 1][j] = hdp[i + 1][j] || hdp[i][j - h[i]];
            if (j + h[i] < 20001) hdp[i + 1][j] = hdp[i + 1][j] || hdp[i][j + h[i]];
        }
    }
    if (!hdp[sz(h)][x + 10000]) {
        cout << "No" << EOL;
        return;
    }

    vector<vector<bool>> vdp(sz(v) + 1, vector<bool>(20001, false));
    vdp[0][10000] = true;
    REP(i, sz(v)) {
        REP(j, 20001) {
            if (j - v[i] >= 0) vdp[i + 1][j] = vdp[i + 1][j] || vdp[i][j - v[i]];
            if (j + v[i] < 20001) vdp[i + 1][j] = vdp[i + 1][j] || vdp[i][j + v[i]];
        }
    }
    if (!vdp[sz(v)][y + 10000]) {
        cout << "No" << EOL;
        return;
    }

    cout << "Yes" << EOL;
}


Compiler output:
a.cc:95:31: error: redefinition of 'template<class T> bool chmin(T&, T)'
   95 | template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:12:31: note: 'template<class T> bool chmin(T&, T)' previously declared here
   12 | template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:96:31: error: redefinition of 'template<class T> bool chmax(T&, T)'
   96 | template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:13:31: note: 'template<class T> bool chmax(T&, T)' previously declared here
   13 | template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:97:11: error: redefinition of 'const int MOD'
   97 | const int MOD = 1000000007;
      |           ^~~
a.cc:14:11: note: 'const int MOD' previously defined here
   14 | const int MOD = 1000000007;
      |           ^~~
a.cc:98:11: error: redefinition of 'const int INF'
   98 | const int INF = 1000000001;
      |           ^~~
a.cc:15:11: note: 'const int INF' previously defined here
   15 | const int INF = 1000000001;
      |           ^~~
a.cc:99:10: error: redefinition of 'const ll LINF'
   99 | const ll LINF = 1000000001000000001LL;
      |          ^~~~
a.cc:16:10: note: 'const ll LINF' previously defined here
   16 | const ll LINF = 1000000001000000001LL;
      |          ^~~~
a.cc:100:12: error: redefinition of 'const char EOL'
  100 | const char EOL = '\n';
      |            ^~~
a.cc:17:12: note: 'const char EOL' previously defined here
   17 | const char EOL = '\n';
      |            ^~~
a.cc:104:5: error: redefinition of 'int main()'
  104 | int main() {
      |     ^~~~
a.cc:21:5: note: 'int main()' previously defined here
   21 | int main() {
      |     ^~~~
a.cc:112:6: error: redefinition of 'void solve()'
  112 | void solve() {
      |      ^~~~~
a.cc:29:6: note: 'void solve()' previously defined here
   29 | void solve() {
      |      ^~~~~
a.cc:178:31: error: redefinition of 'template<class T> bool chmin(T&, T)'
  178 | template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:12:31: note: 'template<class T> bool chmin(T&, T)' previously declared here
   12 | template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:179:31: error: redefinition of 'template<class T> bool chmax(T&, T)'
  179 | template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:13:31: note: 'template<class T> bool chmax(T&, T)' previously declared here
   13 | template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:180:11: error: redefinition of 'const int MOD'
  180 | const int MOD = 1000000007;
      |           ^~~
a.cc:14:11: note: 'const int MOD' previously defined here
   14 | const int MOD = 1000000007;
      |           ^~~
a.cc:181:11: error: redefinition of 'const int INF'
  181 | const int INF = 1000000001;
      |           ^~~
a.cc:15:11: note: 'const int INF' previously defined here
   15 | const int INF = 1000000001;
      |           ^~~
a.cc:182:10: error: redefinition of 'const ll LINF'
  182 | const ll LINF = 1000000001000000001LL;
      |          ^~~~
a.cc:16:10: note: 'const ll LINF' previously defined here
   16 | const ll LINF = 1000000001000000001LL;
      |          ^~~~
a.cc:183:12: error: redefinition of 'const char EOL'
  183 | const char EOL = '\n';
      |            ^~~
a.cc:17:12: note: 'const char EOL' previously defined here
   17 | const char EOL = '\n';
      |            ^~~
a.cc:187:5: error: redefinition of 'int main()'
  187 | int main() {
      |     ^~~~
a.cc:21:5: note: 'int main()' previously defined here
   21 | int main() {
      |     ^~~~
a.cc:195:6: error: redefinition of 'void solve()'
  195 | void solve() {
      |      ^~~~~
a.cc:29:6: note: 'void solve()' previously defined here
   29 | void solve() {
      |      ^~~~~