Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03290 (python)

Fixed submission:
from itertools import product


def solve(string):
    d, g, *pc = map(int, string.split())
    g //= 100
    p = [_p for _p in pc[::2]]
    c = [_c // 100 for _c in pc[1::2]]
    ans = 1000
    for f in product([True, False], repeat=d):
        sums = sum([(i + 1) * _p + _c for i, (_f, _p, _c) in enumerate(zip(f, p, c)) if _f])
        counts = sum([_p for _f, _p in zip(f, p) if _f])
        if g <= sums:
            ans = min(ans, counts)
            continue
        indices = [i + 1 for i, _f in enumerate(f) if not _f]
        for i in range(1, p[indices[-1]-1]):
            if sums + indices[-1] * i >= g:
                ans = min(ans, counts + i)
                break
    return str(ans)


if __name__ == '__main__':
    n, g = map(int, input().split())
    print(solve('{} {}\n'.format(n, g) + '\n'.join([input() for _ in range(n)])))

Buggy submission (verdict: Runtime Error):
from itertools import product
from math import ceil


def solve(string):
    d, g, *pc = map(int, string.split())
    g //= 100
    p = [_p for _p in pc[::2]]
    c = [_c // 100 for _c in pc[1::2]]
    ans = 1000
    for f in product([True, False], repeat=d):
        sums = sum([(i + 1) * _p + _c for i, (_f, _p, _c) in enumerate(zip(f, p, c)) if _f])
        counts = sum([_p for _f, _p in zip(f, p) if _f])
        if g <= sums:
            ans = min(ans, counts)
            continue

        indices = [i + 1 for i, _f in enumerate(f) if not _f]
        tmp = ceil((g - sums) / indices[-1])
        if tmp < p[indices[-1]]:
            ans = min(ans, counts + tmp)
    return str(ans)


if __name__ == '__main__':
    n, g = map(int, input().split())
    print(solve('{} {}\n'.format(n, g) + '\n'.join([input() for _ in range(n)])))

Buggy submission (verdict: Runtime Error):
from math import ceil


def solve(string):
    d, g, *pc = map(int, string.split())
    g //= 100
    p = [_p for _p in pc[::2]]
    c = [_c // 100 for _c in pc[1::2]]
    ans = []
    eff_comp = [((_p * (i + 1) + _c) / _p, i + 1, _p, _c) for i, (_p, _c) in enumerate(zip(p, c))]
    eff_incomp = [(i + 1, i + 1, _p - 1, 0) for i, (_p, _c) in enumerate(zip(p, c))]

    eff = sorted(eff_comp + eff_incomp, reverse=True)
    tmp = 0
    used = []
    for _e, _i, _p, _c in eff:
        if _i in used:
            continue
        if _e * _p < g:
            g -= _i * _p + _c
            tmp += _p
            used.append(_i)
            continue
        if _c == 0:
            ans.append(tmp + (ceil(g / _e)))
        else:
            ans.append(tmp + _p)
    return str(min(ans))


if __name__ == '__main__':
    n, g = map(int, input().split())
    print(solve('{} {}\n'.format(n, g) + '\n'.join([input() for _ in range(n)])))
    print(solve(input()))
Problem p03294 (python)

Fixed submission:
def solve(string):
    n, *a = map(int, string.split())
    return str(sum(a) - n)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Buggy submission (verdict: Runtime Error):
def solve(string):
    n, *a = map(int, string.split())
    return str(sum(a) - n)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))
Problem p03308 (python)

Fixed submission:
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    return str(abs(a[0] - a[-1]))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))

Buggy submission (verdict: Runtime Error):
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    return str(abs(a[0] - a[-1]))


if __name__ == '__main__':
    print(solve([input(), input()]))

Buggy submission (verdict: Runtime Error):
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    return str(abs(a[0] - a[-1]))


if __name__ == '__main__':
    print(solve(input()))
Problem p03310 (python)

Fixed submission:
def solve(string):
    n, *a = map(int, string.split())
    l, c, r = 1, 2, 3
    sll, slr, srl, srr = sum(a[:l]), sum(a[l:c]), sum(a[c:r]), sum(a[r:])
    ans = max(sll, slr, srl, srr) - min(sll, slr, srl, srr)
    while c < n - 1:
        d = abs(sll - slr)
        dn = abs(sll + 2 * a[l] - slr)
        while dn < d:
            sll, slr = sll + a[l], slr - a[l]
            l += 1
            d = abs(sll - slr)
            dn = abs(sll + 2 * a[l] - slr)
        d = abs(srl - srr)
        dn = abs(srl + 2 * a[r] - srr)
        while dn < d:
            srl, srr = srl + a[r], srr - a[r]
            r += 1
            d = abs(srl - srr)
            dn = abs(srl + 2 * a[r] - srr)
        ans = min(ans, max(sll, slr, srl, srr) - min(sll, slr, srl, srr))
        slr += a[c]
        srl -= a[c]
        c += 1
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Buggy submission (verdict: Runtime Error):
def solve(string):
    n, *a = map(int, string.split())
    l, c, r = 1, 2, 3
    sll, slr, srl, srr = sum(a[r:]), sum(a[c:r]), sum(a[l:c]), sum(a[:l])
    ans = max(sll, slr, srl, srr) - min(sll, slr, srl, srr)
    while c < n - 1:
        d = abs(sll - slr)
        dn = abs(sll + 2 * a[l] - slr)
        while dn < d:
            sll, slr = sll + a[l], slr - a[l]
            l += 1
            d = abs(sll - slr)
            dn = abs(sll + 2 * a[l] - slr)
        d = abs(srl - srr)
        dn = abs(srl + 2 * a[r] - srr)
        while dn < d:
            srl, srr = srl + a[r], srr - a[r]
            r += 1
            d = abs(srl - srr)
            dn = abs(srl + 2 * a[r] - srr)
        ans = min(ans, max(sll, slr, srl, srr) - min(sll, slr, srl, srr))
        slr += a[c]
        srl -= a[c]
        c += 1
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
Problem p03323 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

a = int(input())
b = int(input())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

a = int(input())

b = int(input())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(" :(")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

a = int(input())

b = int(input())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(" :(")
Problem p03339 (python)

Fixed submission:
def solve(string):
    n, s = string.split()
    n = int(n)
    es = {i for i, _s in enumerate(s) if _s == "E"}
    num_e = len(es)
    num_w = n - num_e
    count_e = 0
    count_w = 0

    ans = n
    for i, _s in enumerate(s):
        tmp = [count_e, count_w]
        if i in es:
            count_e += 1
        else:
            count_w += 1
        tmp += [num_e - count_e, num_w - count_w]
        ans = min(ans, tmp[1] + tmp[2])
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Buggy submission (verdict: Runtime Error):
def solve(string):
    n, s = string.split()
    n = int(n)
    num_e = len(s.count("E"))
    count_e = 0
    count_w = 0
    ans = n
    for _s in s:
        tmp = count_w
        if _s == "E":
            count_e += 1
        else:
            count_w += 1
        tmp += num_e - count_e
        ans = min(ans, tmp)
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
Problem p03353 (python)

Fixed submission:
from collections import Counter


def solve(string):
    s, k = string.split()
    """
    g = []
    for i in range(len(s)):
        for j in range(i + 1, len(s) + 1):
            g.append(s[i:j])
    g = sorted(set(g))
    return g[int(k)-1]
    """
    k = int(k)
    count = Counter(s)
    chars = sorted(set(s))
    for t in range(min(3, len(chars))):
        tmp = []
        i = s.index(chars[t])
        tmp.append(s[i:i + 5])
        if count[chars[t]] > 1:
            for _ in range(count[chars[t]] - 1):
                i = s.index(chars[t], i + 1)
                tmp.append(s[i:i + 5])
        g = []
        for p in tmp:
            for j in range(1, len(p) + 1):
                g.append(p[:j])
        g = sorted(set(g))
        if len(g) < k:
            k -= len(g)
            continue
        return g[k - 1]


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Buggy submission (verdict: Runtime Error):
def solve(string):
    s, k = string.split()
    g = []
    for i in range(len(s)):
        for j in range(i + 1, len(s) + 1):
            g.append(s[i:j])
    g = sorted(set(g))
    return g[int(k)-1]


if __name__ == '__main__':
    print(solve(input()))
Problem p03385 (python)

Fixed submission:
s = input()
if s.find("a") >= 0 and s.find("b") >= 0 and s.find("c") >= 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
def solve(string):
    return "Yes" if s.find("a") >= 0 and s.find("b") >= 0 and s.find("c") >= 0 "No"


if __name__ == '__main__':
    print(solve(input()))
Problem p03399 (python)

Fixed submission:
a = int(input().strip())
b = int(input().strip())
c = int(input().strip())
d = int(input().strip())
print(min(a, b) + min(c, d))

Buggy submission (verdict: Runtime Error):
def solve(string):
    a, b, c, d = map(int, string.split())
    return str(min(a, b) + min(c, d))


if __name__ == '__main__':
    n = 4
    print(solve('n'.join([input() for _ in range(n)])))
Problem p03401 (python)

Fixed submission:
n = int(input().strip())
a = list(map(int, input().strip().split(" ")))
a.append(0)
a.insert(0, 0)
s = [abs(j - i) for i, j in zip(a, a[1:])]
base = sum(s)
for i in range(1, n + 1):
    if min(a[i - 1], a[i + 1]) <= a[i] <= max(a[i - 1], a[i + 1]):
        print(base)
    elif max(a[i - 1], a[i + 1]) < a[i]:
        print(base - 2 * abs(a[i] - max(a[i - 1], a[i + 1])))
    else:
        print(base - 2 * abs(a[i] - min(a[i - 1], a[i + 1])))

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().strip().split(" ")))
a.append(0)
a.insert(0, 0)
s = [abs(j - i) for i, j in zip(a, a[1:])]
base = sum(s)
for i in range(1, n + 1):
    if min(a[i - 1], a[i + 1]) <= a[i] <= max(a[i - 1], a[i + 1]):
        print(base)
    elif max(a[i - 1], a[i + 1]) < a[i]:
        print(base - 2*abs(a[i] - max(a[i - 1], a[i + 1])))
    else:
        print(base - 2*abs(a[i] - min(a[i - 1], a[i + 1])))
Problem p03424 (python)

Fixed submission:
n = input().strip()
s = set(input().strip().split(" "))
if len(s) == 3:
    print("Three")
else:
    print("Four")

Buggy submission (verdict: Runtime Error):
n = input().strip()
s = set(input().strip().split(" "))
if len(s) == 3:
    print("Three")
else:
    print("Four"
Problem p03425 (python)

Fixed submission:
n = int(input().strip())
s = [input().strip() for _ in range(n)]
num_m = len([True for _s in s if _s[0] == "M"])
num_a = len([True for _s in s if _s[0] == "A"])
num_r = len([True for _s in s if _s[0] == "R"])
num_c = len([True for _s in s if _s[0] == "C"])
num_h = len([True for _s in s if _s[0] == "H"])
print(num_m * num_a * num_r + num_m * num_a * num_c + num_m * num_a * num_h + num_m * num_r * num_c
      + num_m * num_r * num_h + num_m * num_c * num_h + num_a * num_r * num_c +
      num_a * num_r * num_h + num_a * num_c * num_h + num_r * num_c * num_h)

Buggy submission (verdict: Runtime Error):
n = int(input().strip())
s = [input().strip() for _ in range(n)]
num = [0 for _ in range(5)]
num[0] = len([True for _s in s if _s[0] == "M"])
num[1] = len([True for _s in s if _s[0] == "A"])
num[2] = len([True for _s in s if _s[0] == "R"])
num[3] = len([True for _s in s if _s[0] == "C"])
num[4] = len([True for _s in s if _s[0] == "H"])
ans = 0
for i in range(5):
    for j in range(i, 5):
        for k in range(j, 5):
            ans += num[i] * num[j] * num[k]
print(ans

Buggy submission (verdict: Runtime Error):
n = int(input().strip())
s = [input().strip() for _ in range(n)]
num_m = len([True for _s in s if _s[0] == "M"])
num_a = len([True for _s in s if _s[0] == "A"])
num_r = len([True for _s in s if _s[0] == "R"])
num_c = len([True for _s in s if _s[0] == "C"])
num_h = len([True for _s in s if _s[0] == "H"])
print(num_m * num_a * num_r + num_m * num_a * num_c + num_m * num_a * num_h + num_m * num_r * num_c
      + num_m * num_r * num_h + num_m * num_c * num_h + num_a * num_r * num_c +
      num_a * num_r * num_h + num_a * num_c * num_h + num_r * num_c * num_h
Problem p03435 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

c11, c12, c13 = map(int, input().strip().split(" "))
c21, c22, c23 = map(int, input().strip().split(" "))
c31, c32, c33 = map(int, input().strip().split(" "))
if c11 - c12 == c21 - c22 == c31 - c32 and c12 - c13 == c22 - c23 == c32 - c33 and c13 - c11 == c23 - c21 == c33 - c31 and c11 - c21 == c12 - c22 == c13 - c23 and c21 - c31 == c22 - c32 == c23 - c33 and c31 - c11 == c32 - c12 == c33 - c13:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
def solve(string):
    c11, c12, c13, c21, c22, c23, c31, c32, c33 = map(int, string.split())
    check = c11 - c12 == c21 - c22 == c31 - c32 and c12 - c13 == c22 - c23 == c32 - c33 and c13 - c11 == c23 - c21 == c33 - c31 and c11 - c21 == c12 - c22 == c13 - c23 and c21 - c31 == c22 - c32 == c23 - c33 and c31 - c11 == c32 - c12 == c33 - c13
    return "Yes" if check else "No"


if __name__ == '__main__':
    n = 3
    print(solve('\n'.join([input() for _ in range(n)])))
    print(solve(input()))
Problem p03448 (python)

Fixed submission:
#!/usr/bin/env python3
# coding=utf-8

import sys

a = int(sys.stdin.readline().strip())
b = int(sys.stdin.readline().strip())
c = int(sys.stdin.readline().strip())
x = int(sys.stdin.readline().strip())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
def solve(string):
    a, b, c, x = map(int, string.split())
    ans = 0
    for i in range(a + 1):
        for j in range(b + 1):
            for k in range(c + 1):
                if 500 * i + 100 * j + 50 * k == x:
                    ans += 1
    return str(ans)


if __name__ == '__main__':
    print(solve(input()))
Problem p03455 (python)

Fixed submission:
#!/usr/bin/env python3
# coding=utf-8

import sys

a, b = map(int, sys.stdin.readline().strip().split(" "))

if a % 2 == 1 and b % 2 == 1:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# coding=utf-8

import sys

import numpy as np

n, k = map(int, sys.stdin.readline().strip().split(" "))
xyc = [l.strip().split(" ") for l in sys.stdin.readlines()]
xy = [tuple((int(_x), int(_y) if _c == "W" else int(_y) + k)) for (_x, _y, _c) in xyc]
xy = [tuple((_x % (2 * k), _y % (2 * k))) for (_x, _y) in xy]

ans = np.zeros((n, 2 * k, 2 * k), dtype=np.uint8)
for _x, _y in xy:
    check = np.zeros((n, 2 * k, 2 * k), dtype=np.uint8)
    check[_x:_x + k] = 1
    if _x > k:
        check[:_x - k] = 1
    check[:, _y:_y + k] = 1 - check[:, _y:_y + k]
    if _y > k:
        check[:, :_y - k] = 1 - check[:, :_y - k]
    check = 1 - check
    ans += check
print(np.max(ans))
Problem p03457 (python)

Fixed submission:
#!/usr/bin/env python3
# coding=utf-8

import sys

n = int(sys.stdin.readline().strip())

txy = [tuple(map(int, l.strip().split(" "))) for l in sys.stdin.readlines()]
check_txy = [abs(_x) + abs(_y) <= _t and (_t + _x + _y) % 2 == 0 for (_t, _x, _y) in txy]
if all(check_txy):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# coding=utf-8

import sys

n = int(sys.stdin.readline().strip())

txy = [(0,0,0)]+[tuple(map(int, l.strip().split(" "))) for l in sys.stdin.readlines()]
check_txy = [abs(_x - _xp) + abs(_y -_ yp) <= _t - _tp and (_t + _x + _y) % 2 == 0 for (_t, _x, _y), (_tp, _xp, _yp) in zip(txy[1:], txy)]
if all(check_txy):
    print("Yes")
else:
    print("No")
Problem p03472 (python)

Fixed submission:
#!/usr/bin/env python3
# coding=utf-8

import sys
import math
import numpy as np
n, h = map(int, sys.stdin.readline().strip().split(" "))
a = []
b = []
for _ in range(n):
    _a, _b = map(int, sys.stdin.readline().strip().split(" "))
    a.append(_a)
    b.append(_b)
max_a = max(a)
cnt = 0
b = np.asarray(sorted(b))
b = b[b > max_a]
while h > 0 and len(b) > 0:
    cnt += 1
    h -= b[-1]
    b = b[:-1]
if h > 0:
    cnt += math.ceil(h / max_a)
print(cnt)

Buggy submission (verdict: Runtime Error):
from math import ceil


def solve(string):
    n, h, * ab = map(int, string.split())
    max_a = max(ab[::2])
    cnt = 0
    b = sorted([b for b in ab[1::2] if b > max_a], reverse=True)
    if sum(b) < h:
        cnt = len(b) + ceil((h-sum(b)) / max_a)
    else:
        for _b in b:
            cnt += 1
            h -= _b
            if h <= 0:
                break
    return str(cnt)


if __name__ == '__main__':
    print(solve(input()))
Problem p03474 (python)

Fixed submission:
#!/usr/bin/env python3
# coding=utf-8

import sys
import re

a, b = sys.stdin.readline().strip().split(" ")
s = sys.stdin.readline().strip()
a = int(a)
b = int(b)
m = re.match(r'(\d+)(-)(\d+)', s)
if m is None:
    print("No")
else:
    if len(m.group(1)) == a and m.group(2) == "-" and len(m.group(3)) == b:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
def solve(string):
    a, b, s = string.split()
    a = int(a)
    return "Yes" if s[a] == "-" and (s[:a] + s[a + 1:]).isdigit() else "No"


if __name__ == '__main__':
    print(solve(input()))
Problem p03475 (python)

Fixed submission:
#!/usr/bin/env python3

import math
import sys

n = int(sys.stdin.readline().strip())
f_list = []
for _ in range(n - 1):
    c, s, f = sys.stdin.readline().strip().split(" ")
    c = int(c)
    s = int(s)
    f = int(f)
    f_list = [c + math.ceil((max(_f, s)) / f) * f for _f in f_list]
    f_list.append(c + s)
f_list.append(0)
for _f in f_list:
    print(_f)

Buggy submission (verdict: Runtime Error):
from math import ceil


def solve(string):
    pass
    n, *csf = map(int, string.split())
    f_list = []
    for c, s, f in csf:
        f_list = [c + ceil((max(_f, s)) / f) * f for _f in f_list]
        f_list.append(c + s)
    f_list.append(0)
    return "\n".join([str(_f) for _f in f_list])


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n - 1)])))
Problem p03479 (python)

Fixed submission:
#!/usr/bin/env python3
# coding=utf-8

import sys

x, y = sys.stdin.readline().split(" ")

x = int(x)
y = int(y)
ans = 0
while x <= y:
    ans += 1
    x *= 2
print(ans)

Buggy submission (verdict: Runtime Error):
from math import floor, log2


def solve(string):
    x, y = map(int, string.split())
    return str(floor(log2(y) - log2(x)) + 1)


if __name__ == '__main__':
    print(solve(input()))
Problem p03488 (python)

Fixed submission:
#!/usr/bin/env python3
# coding=utf-8

import sys

s = sys.stdin.readline().strip().split("T")
x, y = sys.stdin.readline().strip().split(" ")
x = int(x)
y = int(y)
move_all = [len(_s) for _s in s]
pos_x = set([move_all[0]])
pos_y = set([0])
move_x = move_all[2::2] or None
move_y = move_all[1::2] or None
if move_x:
    for move in move_x:
        pos_x = {_x + move for _x in pos_x} | {_x - move for _x in pos_x}
if move_y:
    for move in move_y:
        pos_y = {_y + move for _y in pos_y} | {_y - move for _y in pos_y}
if x in pos_x and y in pos_y:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# coding=utf-8

import sys


def become_a(a, start, numbers):
    if numbers is None:
        return a == start
    if len(numbers) == 1:
        return a == start + numbers[0] or a == start - numbers[0]
    return become_a(a, start + numbers[0], numbers[1:]) or become_a(a, start - numbers[0],
                                                                    numbers[1:])


s = sys.stdin.readline().strip().split("T")
x, y = sys.stdin.readline().strip().split(" ")
x = int(x)
y = int(y)
move_all = [len(_s) for _s in s]
move_x = move_all[::2]
move_y = move_all[1::2] or None
if become_a(x, move_x[0], move_x[1:] or None) and become_a(y, 0, move_y):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# coding=utf-8

import sys
import numpy as np


def culc_pos(x, y, commands, pos=np.matrix([0, 0]), d=np.matrix([1, 0])):
    if len(commands) == 1:
        if not commands[0]:
            pos = pos + d
        return pos[0, 0] == x and pos[0, 1] == y
    if commands[0]:
        ccw = np.matrix([[0, -1], [1, 0]])
        cw = np.matrix([[0, 1], [-1, 0]])
        d1 = d * ccw
        d2 = d * cw
        return culc_pos(x, y, commands[1:], pos, d1) or culc_pos(x, y, commands[1:], pos, d2)
    else:
        pos = pos + d
        return culc_pos(x, y, commands[1:], pos, d)


s = sys.stdin.readline().strip()
x, y = sys.stdin.readline().strip().split(" ")
x = int(x)
y = int(y)
s_list = [_s == "T" for _s in list(s)]
if culc_pos(x, y, s_list):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# coding=utf-8

import sys
import numpy as np


def culc_pos(x, y, commands, pos=np.matrix([0, 0]), d=np.matrix([1, 0])):
    if len(commands) == 1:
        if commands[0]:
            return pos[0, 0] == x and pos[0, 1] == y
        else:
            pos = pos + d
            return pos[0, 0] == x and pos[0, 1] == y
    if commands[0]:
        ccw = np.matrix([[0, -1], [1, 0]])
        cw = np.matrix([[0, 1], [-1, 0]])
        d1 = d * ccw
        d2 = d * cw
        return culc_pos(x, y, commands[1:], pos, d1) or culc_pos(x, y, commands[1:], pos, d2)
    else:
        pos = pos+d
        return culc_pos(x, y, commands[1:], pos, d)


s = sys.stdin.readline().strip()
x, y = sys.stdin.readline().strip().split(" ")
x = int(x)
y = int(y)
s_list = [_s == "T" for _s in list(s)]
if culc_pos(x, y, s_list):
    print("Yes")
else:
    print("No")