Language: C++

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

string s;
int x, y;

unordered_map<int, bool> mp1[8000];
unordered_map<int, bool> used1[8000];
unordered_map<int, bool> mp2[8000];
unordered_map<int, bool> used2[8000];

vector<int> ido[2];

bool dp1(int i, int j){
    if(i == ido[0].size()){
        if(j == x){
            return true;
        }
        return false;
    }

    if(used1[i][j]){
        return mp1[i][j];
    }

    used1[i][j] = true;
    return dp1(i+1, j+ido[0][i]) || dp1(i+1, j-ido[0][i]);
}

bool dp2(int i, int j){
    if(i == ido[1].size()){
        if(j == y){
            return true;
        }
        return false;
    }

    if(used2[i][j]){
        return mp2[i][j];
    }

    used2[i][j] = true;
    return dp2(i+1, j+ido[1][i]) || dp2(i+1, j-ido[1][i]);
}

int main(){
    cin >> s;
    cin >> x >> y;

    int tmp = 0;
    int nakamura = 0;

    for(int i = 0;i < s.size();i++){
        if(s[i] == 'F'){
            tmp++;
        }else{
            ido[nakamura].push_back(tmp);
            nakamura = (nakamura + 1) & 1;
            tmp = 0;
        }
    }

    ido[nakamura].push_back(tmp);

    if(dp1(0, 0) && dp2(0, 0)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}
bash-4.3(luke):~/con
531:{ei1719}$ vim e.cpp
bash-4.3(luke):~/con
532:{ei1719}$ g++ e.cpp
bash-4.3(luke):~/con
533:{ei1719}$ a.out
4
3 3 3 3
No
bash-4.3(luke):~/con
534:{ei1719}$ a.out
FTFFTFFF
4 2
Yes
bash-4.3(luke):~/con
535:{ei1719}$ cat e.cpp
#include <bits/stdc++.h>
using namespace std;

string s;
int x, y;

map<int, bool> mp1[8000];
map<int, bool> used1[8000];
map<int, bool> mp2[8000];
map<int, bool> used2[8000];

vector<int> ido[2];

bool dp1(int i, int j){
    if(i == ido[0].size()){
        if(j == x){
            return true;
        }
        return false;
    }

    if(used1[i][j]){
        return mp1[i][j];
    }

    used1[i][j] = true;
    if(i == 0){
        return mp1[i][j] = dp1(i+1, j+ido[0][i]);
    }else{
        return mp1[i][j] = dp1(i+1, j+ido[0][i]) || dp1(i+1, j-ido[0][i]);
    }
}

bool dp2(int i, int j){
    if(i == ido[1].size()){
        if(j == y){
            return true;
        }
        return false;
    }

    if(used2[i][j]){
        return mp2[i][j];
    }

    used2[i][j] = true;
    return mp2[i][j] = dp2(i+1, j+ido[1][i]) || dp2(i+1, j-ido[1][i]);
}

int main(){
    cin >> s;
    cin >> x >> y;

    int tmp = 0;
    int nakamura = 0;

    for(int i = 0;i < s.size();i++){
        if(s[i] == 'F'){
            tmp++;
        }else{
            ido[nakamura].push_back(tmp);
            nakamura = (nakamura + 1) & 1;
            tmp = 0;
        }
    }

    ido[nakamura].push_back(tmp);

    if(dp1(0, 0) && dp2(0, 0)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Compiler output:
a.cc:73:1: error: 'bash' does not name a type
   73 | bash-4.3(luke):~/con
      | ^~~~
a.cc:74:13: error: '$' does not name a type
   74 | 531:{ei1719}$ vim e.cpp
      |             ^
a.cc:76:13: error: '$' does not name a type
   76 | 532:{ei1719}$ g++ e.cpp
      |             ^
a.cc:78:13: error: '$' does not name a type
   78 | 533:{ei1719}$ a.out
      |             ^
a.cc:83:13: error: '$' does not name a type
   83 | 534:{ei1719}$ a.out
      |             ^
a.cc:88:13: error: '$' does not name a type
   88 | 535:{ei1719}$ cat e.cpp
      |             ^
a.cc:92:8: error: redefinition of 'std::string s'
   92 | string s;
      |        ^
a.cc:4:8: note: 'std::string s' previously declared here
    4 | string s;
      |        ^
a.cc:93:5: error: redefinition of 'int x'
   93 | int x, y;
      |     ^
a.cc:5:5: note: 'int x' previously declared here
    5 | int x, y;
      |     ^
a.cc:93:8: error: redefinition of 'int y'
   93 | int x, y;
      |        ^
a.cc:5:8: note: 'int y' previously declared here
    5 | int x, y;
      |        ^
a.cc:95:16: error: conflicting declaration 'std::map<int, bool> mp1 [8000]'
   95 | map<int, bool> mp1[8000];
      |                ^~~
a.cc:7:26: note: previous declaration as 'std::unordered_map<int, bool> mp1 [8000]'
    7 | unordered_map<int, bool> mp1[8000];
      |                          ^~~
a.cc:96:16: error: conflicting declaration 'std::map<int, bool> used1 [8000]'
   96 | map<int, bool> used1[8000];
      |                ^~~~~
a.cc:8:26: note: previous declaration as 'std::unordered_map<int, bool> used1 [8000]'
    8 | unordered_map<int, bool> used1[8000];
      |                          ^~~~~
a.cc:97:16: error: conflicting declaration 'std::map<int, bool> mp2 [8000]'
   97 | map<int, bool> mp2[8000];
      |                ^~~
a.cc:9:26: note: previous declaration as 'std::unordered_map<int, bool> mp2 [8000]'
    9 | unordered_map<int, bool> mp2[8000];
      |                          ^~~
a.cc:98:16: error: conflicting declaration 'std::map<int, bool> used2 [8000]'
   98 | map<int, bool> used2[8000];
      |                ^~~~~
a.cc:10:26: note: previous declaration as 'std::unordered_map<int, bool> used2 [8000]'
   10 | unordered_map<int, bool> used2[8000];
      |                          ^~~~~
a.cc:100:13: error: redefinition of 'std::vector<int> ido [2]'
  100 | vector<int> ido[2];
      |             ^~~
a.cc:12:13: note: 'std::vector<int> ido [2]' previously declared here
   12 | vector<int> ido[2];
      |             ^~~
a.cc:102:6: error: redefinition of 'bool dp1(int, int)'
  102 | bool dp1(int i, int j){
      |      ^~~
a.cc:14:6: note: 'bool dp1(int, int)' previously defined here
   14 | bool dp1(int i, int j){
      |      ^~~
a.cc:122:6: error: redefinition of 'bool dp2(int, int)'
  122 | bool dp2(int i, int j){
      |      ^~~
a.cc:30:6: note: 'bool dp2(int, int)' previously defined here
   30 | bool dp2(int i, int j){
      |      ^~~
a.cc:138:5: error: redefinition of 'int main()'
  138 | int main(){
      |     ^~~~
a.cc:46:5: note: 'int main()' previously defined here
   46 | int main(){
      |     ^~~~