Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(5e4); // TODO : change value as per problem
const ll MOD = 1e9+7;
bool dp[N][N];
bool dp2[N][N];
ll get(ll x){
	return x + 10000;
}

void solve(){
	string s;
	cin >> s;
	int x,y;
	cin >> x >> y;
	int idx=sz(s);
	int wow = 0;
	for(int i =0;i < sz(s);i++){
		if(s[i] == 'T') {idx = i;break;}
		wow++;
	}
	vll a,b;
	bool ok = false;
	ll c = 0;
	for(int i = idx+1;i<sz(s);i++){
		// cout << s[i] << " " << ok<< endl;
		if(s[i] == 'T'){
			if(ok) a.pb(c);
			else b.pb(c);
			ok ^= true;
			c = 0;
		}
		else{
			c++;
		}
	}
	if(c != 0){
			if(ok) a.pb(c);
			else b.pb(c);
	}
	ll n = sz(a);
	ll m = sz(b);
	// for(int i =0 ;i<n;i++) cout << a[i] << " ";
	// cout << "\n";
	// for(int i = 0;i<m;i++) cout << b[i] << " ";
	// cout << "\n";
	dp[0][get(wow)] = true;
	// dp[index][sum] 
	int sum = 8000;
	
	for(int i =1;i<=n;i++){
		for(int j = -sum;j<=sum;j++){
			dp[i][get(j)] |= dp[i-1][get(j+a[i-1])];
			 dp[i][get(j)] |= dp[i-1][get(j-a[i-1])];
		}
	}
	dp2[0][get(0)] = true;
	// dp2[1][get(-b[0])] = true;
	// dp2[1][get(b[0])] = true;
	for(int i =1;i<=m;i++){
		for(int j = -sum;j<=sum;j++){
			dp2[i][get(j)] |= dp2[i-1][get(j+b[i-1])];
			dp2[i][get(j)] |= dp2[i-1][get(j-b[i-1])];
		}
	}

	if(dp[n][get(x)] && dp2[m][get(y)])
		cout << "Yes\n";
	else 
		cout << "No\n";
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}


Compiler output:
/tmp/ccsVtA5v.o: in function `solve()':
a.cc:(.text+0x3e8): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/ccsVtA5v.o
a.cc:(.text+0x451): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/ccsVtA5v.o
a.cc:(.text+0x479): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/ccsVtA5v.o
a.cc:(.text+0x49e): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/ccsVtA5v.o
a.cc:(.text+0x4eb): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/ccsVtA5v.o
a.cc:(.text+0x513): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/ccsVtA5v.o
a.cc:(.text+0x538): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/ccsVtA5v.o
a.cc:(.text+0x5b5): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/ccsVtA5v.o
collect2: error: ld returned 1 exit status