Problem:
Score : 500 points

Problem Statement

A robot is put at the origin in a two-dimensional plane.
Initially, the robot is facing in the positive x-axis direction.

This robot will be given an instruction sequence s.
s consists of the following two kinds of letters, and will be executed in order from front to back.

F : Move in the current direction by distance 1.

T : Turn 90 degrees, either clockwise or counterclockwise.

The objective of the robot is to be at coordinates (x, y) after all the instructions are executed.
Determine whether this objective is achievable.

Constraints

s consists of F and T.

1 \leq |s| \leq 8 000

x and y are integers.

|x|, |y| \leq |s|

Input

Input is given from Standard Input in the following format:

s
x y

Output

If the objective is achievable, print Yes; if it is not, print No.

Sample Input 1

FTFFTFFF
4 2

Sample Output 1

Yes

The objective can be achieved by, for example, turning counterclockwise in the first T and turning clockwise in the second T.

Sample Input 2

FTFFTFFF
-2 -2

Sample Output 2

Yes

The objective can be achieved by, for example, turning clockwise in the first T and turning clockwise in the second T.

Sample Input 3

FF
1 0

Sample Output 3

No

Sample Input 4

TF
1 0

Sample Output 4

No

Sample Input 5

FFTTFF
0 0

Sample Output 5

Yes

The objective can be achieved by, for example, turning counterclockwise in the first T and turning counterclockwise in the second T.

Sample Input 6

TTTT
1 0

Sample Output 6

No

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        s: Chars,
        x: isize,
        y: isize,
    }
    let n = s.len();
    let mut x_states = vec![vec![false; 2 * n + 1]; n + 1];
    x_states[0][n] = true;
    let mut y_states = vec![vec![false; 2 * n + 1]; n + 1];
    y_states[0][n] = true;

    let mut t_count = 0;
    for i in 1..=n {
        if s[i - 1] == 'F' {
            if t_count % 2 == 0 {
                for j in 1..2 * n {
                    if x_states[i - 1][j] {
                        if t_count > 0 {
                            x_states[i][j - 1] = true;
                        }
                        x_states[i][j + 1] = true;
                    }
                }
                for j in 0..=2 * n {
                    y_states[i][j] = y_states[i - 1][j];
                }
            } else {
                for j in 1..2 * n {
                    if y_states[i - 1][j] {
                        y_states[i][j - 1] = true;
                        y_states[i][j + 1] = true;
                    }
                }
                for j in 0..=2 * n {
                    x_states[i][j] = x_states[i - 1][j];
                }
            }
        } else {
            for j in 0..=2 * n {
                x_states[i][j] = x_states[i - 1][j];
                y_states[i][j] = y_states[i - 1][j];
            }
            t_count += 1;
        }
    }

    // for i in 1..=n {
    //     eprintln!("{:?}", x_states[i]);
    //     eprintln!("{:?}", y_states[i]);
    //     eprintln!("");
    // }

    let x = n as isize + x;
    let y = n as isize + y;
    if x_states[n][x as usize] && y_states[n][y as usize] {
        println!("Yes");
    } else {
        println!("No");
    }
}
*/

fn main() {
    let exe = "/tmp/bin6144AF31";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";