Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc082/tasks/arc087_b

"""
import sys
from sys import stdin
input = stdin.readline


def check_x(forwards):
    n = sum(forwards[::2])      #  x軸方向への最大移動量
    dpx = [False] * (n * 2 + 1) #  真ん中を0として、±両方向のdp領域を確保
    dpx[forwards[0] + n] = True #  最初は0からプラス方向に移動

    for f in forwards[2::2]:
        if f == 0:
            continue
        n_move = dpx[f:] + [False]*f
        p_move = [False]*f + dpx[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpx = t
    return dpx, n


def check_y(forwards):
    n = sum(forwards[1::2])
    dpy = [False] * (n * 2 + 1)
    dpy[n] = True

    for f in forwards[1::2]:
        if f == 0:
            continue
        n_move = dpy[f:] + [False]*f
        p_move = [False]*f + dpy[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpy = t
    return dpy, n


def solve(s, gx, gy):
    forwards = [len(x) for x in s.split('T')] #  進む歩数情報の数字に変換
    dpx, zx = check_x(forwards)
    dpy, zy = check_y(forwards)

    if zx < gx:
        return 'No'
    if zy < gy:
        return 'No'
    if dpx[gx + zx] is True and dpy[gy + zy] is True:
        return 'Yes'
    else:
        return 'No'


def main(args):
    s = input().strip()
    gx, gy = map(int, input().split())
    ans = solve(s, gx, gy)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Fixed submission:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc082/tasks/arc087_b

"""
import sys
from sys import stdin
input = stdin.readline


def check_x(forwards):
    n = sum(forwards[::2])      #  x軸方向への最大移動量
    dpx = [False] * (n * 2 + 1) #  真ん中を0として、±両方向のdp領域を確保
    dpx[forwards[0] + n] = True #  最初は0からプラス方向に移動

    for f in forwards[2::2]:
        if f == 0:
            continue
        n_move = dpx[f:] + [False]*f
        p_move = [False]*f + dpx[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpx = t
    return dpx, n


def check_y(forwards):
    n = sum(forwards[1::2])
    dpy = [False] * (n * 2 + 1)
    dpy[n] = True

    for f in forwards[1::2]:
        if f == 0:
            continue
        n_move = dpy[f:] + [False]*f
        p_move = [False]*f + dpy[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpy = t
    return dpy, n


def solve(s, gx, gy):
    forwards = [len(x) for x in s.split('T')] #  進む歩数情報の数字に変換
    dpx, zx = check_x(forwards)
    dpy, zy = check_y(forwards)

    if zx < abs(gx):
        return 'No'
    if zy < abs(gy):
        return 'No'
    if dpx[gx + zx] is True and dpy[gy + zy] is True:
        return 'Yes'
    else:
        return 'No'


def main(args):
    s = input().strip()
    gx, gy = map(int, input().split())
    # s = 'F'
    # gx, gy = -1, 0
    ans = solve(s, gx, gy)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc082/tasks/arc087_b

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def check_x(forwards):
    n = sum(forwards[::2])
    dpx = [False] * (n * 2 + 1)
    dpx[forwards[0] + n] = True

    for f in forwards[2::2]:
        if f == 0:
            continue
        n_move = dpx[f:] + [False]*f
        p_move = [False]*f + dpx[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpx = t
    return dpx, n


def check_y(forwards):
    n = sum(forwards[1::2])
    dpy = [False] * (n * 2 + 1)
    dpy[n] = True

    for f in forwards[1::2]:
        if f == 0:
            continue
        n_move = dpy[f:] + [False]*f
        p_move = [False]*f + dpy[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpy = t
    return dpy, n


def solve(s, gx, gy):
    n = len(s)
    forwards = [len(x) for x in s.split('T')]

    dpx, zx = check_x(forwards)
    dpy, zy = check_y(forwards)

    if len(dpy)-1 < gy or len(dpx)-1 < gx:
        return 'No'
    elif dpy[gy + zy] is True and dpx[gx + zx] is True:
        return 'Yes'
    else:
        return 'No'


def main(args):
    s = input().strip()
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FTFTFTTFTTTFFTFFTFFTFFTTFTTTFTFFFFTFFFFFTTFFTFFFTTFFFTFFTFTFFFTFFTTFTFFFTFFTFFFTFFFFFTFFTFTTFFFFFFFTFTFTFFFTFFFTFFFFFFTFTFFFTFFTFFFFFFFTFTFTTFTTFFTTFTFTFFFFTFFFFTFFFTFTFTFFTFTFFFTFFFTFTFFFFFTFFTFTFTFTFFFFTTTFFFTTFFTFFFTTFFFTFTFFFFFTFFFFTFTFTTFFFFFTFTFFFFFFFTFFFFFFTFTTFFFTFFFFFFFFTFFTFFFFTFFTFFTFFFFTFFFFFFTFTFFFTTTFFFTTFFTTTTTFFFTFFTTFFFTTFFFFTFFFTFFTTFFTFFFFFTFTFTTTTFTTFTTTFTFFFFTTFTTFFFTFFFFTTTTTFFTFFFTFTFTFTTFTFTFTFFFFFFTTFFTFFFFFFFFTFTFFTFTTFTFFTTFTFTTTFFTTTTFFTFFFFFFFTTFFTFFFFFFTTTTFFFFFFFFTFTFFFFFTTFTFFFFTTFFFFTTFTTFFTFTTFFTFTFFTFFFTTFFTFFTFTFTTFTTFFFTTFTFTFTFFFTTFTTFTTFFFTFFFFFTFFFFFFFTFTFFFTTFFFTTFTTFTFFFFFFFFFFTFFFTTFTTTTFFTFFFFFTFTTFTFTFFFFTFTFFFFFFFTFFTTTTFTFFTFFFFFFFTTFTFFTFFFFFTFFFFFFTFFFFTFFTFFTTFTFTTFFTFFFTFTFTFFFFFFTTTFFTTTFFTFFTFTTTFTFFTFFTFFFFTFTFFTTFTTTTFTTFTFTTFFFFFFTFTFTFFFFFTTFFFFFFTTFFFFFTFFFTFTFTTTFFFTFFTFTFFFFFFTFFFTFF'
    # s = 'FTFFTFFF'
    # gx, gy = 4, 2
    ans = solve(s, gx, gy)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Fixed submission:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc082/tasks/arc087_b

"""
import sys
from sys import stdin
input = stdin.readline


def check_x(forwards):
    n = sum(forwards[::2])      #  x軸方向への最大移動量
    dpx = [False] * (n * 2 + 1) #  真ん中を0として、±両方向のdp領域を確保
    dpx[forwards[0] + n] = True #  最初は0からプラス方向に移動

    for f in forwards[2::2]:
        if f == 0:
            continue
        n_move = dpx[f:] + [False]*f
        p_move = [False]*f + dpx[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpx = t
    return dpx, n


def check_y(forwards):
    n = sum(forwards[1::2])
    dpy = [False] * (n * 2 + 1)
    dpy[n] = True

    for f in forwards[1::2]:
        if f == 0:
            continue
        n_move = dpy[f:] + [False]*f
        p_move = [False]*f + dpy[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpy = t
    return dpy, n


def solve(s, gx, gy):
    forwards = [len(x) for x in s.split('T')] #  進む歩数情報の数字に変換
    dpx, zx = check_x(forwards)
    dpy, zy = check_y(forwards)

    if zx < abs(gx):
        return 'No'
    if zy < abs(gy):
        return 'No'
    if dpx[gx + zx] is True and dpy[gy + zy] is True:
        return 'Yes'
    else:
        return 'No'


def main(args):
    s = input().strip()
    gx, gy = map(int, input().split())
    # s = 'F'
    # gx, gy = -1, 0
    ans = solve(s, gx, gy)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc082/tasks/arc087_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s, gx, gy):
    n = len(s)
    forwards = [len(x) for x in s.split('T')]

    H = len(forwards)
    dpx = [False] * (n * 2 + 2)
    dpy = [False] * (n * 2 + 2)
    dpx[n + forwards[0]] = True
    dpy[n] = True

    for f in forwards[2::2]:
        if f == 0:
            continue
        n_move = dpx[f:] + [False] * f
        p_move = [False] * f + dpx[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpx = t

    for f in forwards[1::2]:
        if f == 0:
            continue
        n_move = dpy[f:] + [False] * f
        p_move = [False] * f + dpy[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpy = t

    if dpy[gy + n] is True and dpx[gx + n] is True:
        return 'Yes'
    else:
        return 'No'


def main(args):
    s = input().strip()
    gx, gy = map(int, input().split())
    # s = 'FTFFTFFFT'
    # gx, gy = 4, 2
    ans = solve(s, gx, gy)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Fixed submission:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc082/tasks/arc087_b

"""
import sys
from sys import stdin
input = stdin.readline


def check_x(forwards):
    n = sum(forwards[::2])      #  x軸方向への最大移動量
    dpx = [False] * (n * 2 + 1) #  真ん中を0として、±両方向のdp領域を確保
    dpx[forwards[0] + n] = True #  最初は0からプラス方向に移動

    for f in forwards[2::2]:
        if f == 0:
            continue
        n_move = dpx[f:] + [False]*f
        p_move = [False]*f + dpx[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpx = t
    return dpx, n


def check_y(forwards):
    n = sum(forwards[1::2])
    dpy = [False] * (n * 2 + 1)
    dpy[n] = True

    for f in forwards[1::2]:
        if f == 0:
            continue
        n_move = dpy[f:] + [False]*f
        p_move = [False]*f + dpy[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpy = t
    return dpy, n


def solve(s, gx, gy):
    forwards = [len(x) for x in s.split('T')] #  進む歩数情報の数字に変換
    dpx, zx = check_x(forwards)
    dpy, zy = check_y(forwards)

    if zx < abs(gx):
        return 'No'
    if zy < abs(gy):
        return 'No'
    if dpx[gx + zx] is True and dpy[gy + zy] is True:
        return 'Yes'
    else:
        return 'No'


def main(args):
    s = input().strip()
    gx, gy = map(int, input().split())
    # s = 'F'
    # gx, gy = -1, 0
    ans = solve(s, gx, gy)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc082/tasks/arc087_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s, gx, gy):
    n = len(s)
    forwards = [len(x) for x in s.split('T')]

    H = len(forwards)
    dpx = [False] * (n * 2 + 2)
    dpy = [False] * (n * 2 + 2)
    dpx[n + forwards[0]] = True
    dpy[n] = True

    for f in forwards[2::2]:
        if f == 0:
            continue
        t = [False] * (n * 2 + 2)
        for i in range(n*2 + 1):
            if dpx[i] is True:
                n_move = i - f
                p_move = i + f
                t[n_move] = True
                t[p_move] = True
        dpx = t

    for f in forwards[1::2]:
        if f == 0:
            continue
        t = [False] * (n * 2 + 2)
        for i in range(n * 2 + 1):
            if dpy[i] is True:
                n_move = i - f
                p_move = i + f
                t[n_move] = True
                t[p_move] = True
        dpy = t

    if dpy[gy + n] is True and dpx[gx + n] is True:
        return 'Yes'
    else:
        return 'No'


def main(args):
    s = input().strip()
    gx, gy = map(int, input().split())
    # s = 'FTFFTFFFT'
    # gx, gy = 4, 2

    ans = solve(s, gx, gy)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Fixed submission:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc082/tasks/arc087_b

"""
import sys
from sys import stdin
input = stdin.readline


def check_x(forwards):
    n = sum(forwards[::2])      #  x軸方向への最大移動量
    dpx = [False] * (n * 2 + 1) #  真ん中を0として、±両方向のdp領域を確保
    dpx[forwards[0] + n] = True #  最初は0からプラス方向に移動

    for f in forwards[2::2]:
        if f == 0:
            continue
        n_move = dpx[f:] + [False]*f
        p_move = [False]*f + dpx[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpx = t
    return dpx, n


def check_y(forwards):
    n = sum(forwards[1::2])
    dpy = [False] * (n * 2 + 1)
    dpy[n] = True

    for f in forwards[1::2]:
        if f == 0:
            continue
        n_move = dpy[f:] + [False]*f
        p_move = [False]*f + dpy[:-f]
        t = [a or b for a, b in zip(n_move, p_move)]
        dpy = t
    return dpy, n


def solve(s, gx, gy):
    forwards = [len(x) for x in s.split('T')] #  進む歩数情報の数字に変換
    dpx, zx = check_x(forwards)
    dpy, zy = check_y(forwards)

    if zx < abs(gx):
        return 'No'
    if zy < abs(gy):
        return 'No'
    if dpx[gx + zx] is True and dpy[gy + zy] is True:
        return 'Yes'
    else:
        return 'No'


def main(args):
    s = input().strip()
    gx, gy = map(int, input().split())
    # s = 'F'
    # gx, gy = -1, 0
    ans = solve(s, gx, gy)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])