Buggy python submission (verdict: Time Limit Exceeded):
#13:27
s = input()
l = len(s)
s = 'F' + s
x,y = map(int,input().split())
raw = [1]
for i in range(1,l+1):
  if s[i-1:i+1] == 'FF':
    raw[-1] += 1
  elif s[i-1:i+1] == 'TF':
    raw.append(1)
  if s[i-1:i+1] == 'TT':
    raw.append(0)
l2 = len(raw)
a = []
b = []
for i in range(l2):
  if i == 0:
    x -= raw[i]-1
  elif i % 2 == 0:
    a.append(raw[i])
  else:
    b.append(raw[i])
#print(raw)
#print(a,x)
#print(b,y)
now = [0 for _ in range(16001)]
now[8000] = 1
l = len(a)
for j in range(l):
  last = now
  now = [0 for _ in range(16001)]
  for i in range(16001):
    if last[i] == 1:
      now[i+a[j]] = 1
      now[i-a[j]] = 1
if now[8000+x] == 0:
  print('No')
  exit()
now = [0 for _ in range(16001)]
now[8000] = 1
l = len(b)
for j in range(l):
  last = now
  now = [0 for _ in range(16001)]
  for i in range(16001):
    if last[i] == 1:
      now[i+b[j]] = 1
      now[i-b[j]] = 1
if now[8000+y] == 1:
  print('Yes')
else:
  print('No')

Fixed submission:
s = input()
l = len(s)
s = 'F' + s
x,y = map(int,input().split())
raw = [1]
for i in range(1,l+1):
  if s[i] == 'F':
    if s[i-1] == 'F':
      raw[-1] += 1
    else:
      raw.append(1)
  if s[i] == 'T':
    if s[i-1] == 'T':
      raw.append(0)
l2 = len(raw)
a = []
b = []
for i in range(l2):
  if i == 0:
    x -= raw[i]-1
  elif i % 2 == 0:
    a.append(raw[i])
  else:
    b.append(raw[i])
#print(raw)
#print(a,x)
#print(b,y)
nowa = {0}
for aa in a:
  lasta = nowa
  nowa = set()
  for aaa in lasta:
    nowa.add(aaa+aa)
    nowa.add(aaa-aa)
nowb = {0}
for bb in b:
  lastb = nowb
  nowb = set()
  for bbb in lastb:
    nowb.add(bbb+bb)
    nowb.add(bbb-bb)
#print(nowa,nowb)
#print(x,y)
if x in nowa and y in nowb:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Time Limit Exceeded):
#13:27
s = input()
l = len(s)
s = 'F' + s
x,y = map(int,input().split())
raw = [1]
for i in range(1,l+1):
  if s[i-1:i+1] == 'FF':
    raw[-1] += 1
  elif s[i-1:i+1] == 'TF':
    raw.append(1)
  if s[i-1:i+1] == 'TT':
    raw.append(0)
l2 = len(raw)
a = []
b = []
for i in range(l2):
  if i == 0:
    x -= raw[i]-1
  elif i % 2 == 0:
    a.append(raw[i])
  else:
    b.append(raw[i])
#print(raw)
#print(a,x)
#print(b,y)
now = [0 for _ in range(16001)]
now[8000] = 1
for aa in a:
  last = now
  now = [0 for _ in range(16001)]
  for i in range(16001):
    if last[i] == 1:
      now[i+aa] = 1
      now[i-aa] = 1
if now[8000+x] == 0:
  print('No')
  exit()
now = [0 for _ in range(16001)]
now[8000] = 1
for bb in b:
  last = now
  now = [0 for _ in range(16001)]
  for i in range(16001):
    if last[i] == 1:
      now[i+bb] = 1
      now[i-bb] = 1
if now[8000+y] == 1:
  print('Yes')
else:
  print('No')

Fixed submission:
s = input()
l = len(s)
s = 'F' + s
x,y = map(int,input().split())
raw = [1]
for i in range(1,l+1):
  if s[i] == 'F':
    if s[i-1] == 'F':
      raw[-1] += 1
    else:
      raw.append(1)
  if s[i] == 'T':
    if s[i-1] == 'T':
      raw.append(0)
l2 = len(raw)
a = []
b = []
for i in range(l2):
  if i == 0:
    x -= raw[i]-1
  elif i % 2 == 0:
    a.append(raw[i])
  else:
    b.append(raw[i])
#print(raw)
#print(a,x)
#print(b,y)
nowa = {0}
for aa in a:
  lasta = nowa
  nowa = set()
  for aaa in lasta:
    nowa.add(aaa+aa)
    nowa.add(aaa-aa)
nowb = {0}
for bb in b:
  lastb = nowb
  nowb = set()
  for bbb in lastb:
    nowb.add(bbb+bb)
    nowb.add(bbb-bb)
#print(nowa,nowb)
#print(x,y)
if x in nowa and y in nowb:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Time Limit Exceeded):
#13:27
s = input()
l = len(s)
s = 'F' + s
x,y = map(int,input().split())
raw = [1]
for i in range(1,l+1):
  if s[i] == 'F':
    if s[i-1] == 'F':
      raw[-1] += 1
    else:
      raw.append(1)
  if s[i] == 'T':
    if s[i-1] == 'T':
      raw.append(0)
l2 = len(raw)
a = []
b = []
for i in range(l2):
  if i == 0:
    x -= raw[i]-1
  elif i % 2 == 0:
    a.append(raw[i])
  else:
    b.append(raw[i])
#print(raw)
#print(a,x)
#print(b,y)
nowa = [0 for _ in range(16001)]
nowa[8000] = 1
for aa in a:
  lasta = nowa
  nowa = [0 for _ in range(16001)]
  for i in range(16001):
    if lasta[i] == 1:
      nowa[i+aa] = 1
      nowa[i-aa] = 1
nowb = [0 for _ in range(16001)]
nowb[8000] = 1
for bb in b:
  lastb = nowb
  nowb = [0 for _ in range(16001)]
  for i in range(16001):
    if lastb[i] == 1:
      nowb[i+bb] = 1
      nowb[i-bb] = 1
if nowa[8000+x] * nowb[8000+y] == 1:
  print('Yes')
else:
  print('No')

Fixed submission:
s = input()
l = len(s)
s = 'F' + s
x,y = map(int,input().split())
raw = [1]
for i in range(1,l+1):
  if s[i] == 'F':
    if s[i-1] == 'F':
      raw[-1] += 1
    else:
      raw.append(1)
  if s[i] == 'T':
    if s[i-1] == 'T':
      raw.append(0)
l2 = len(raw)
a = []
b = []
for i in range(l2):
  if i == 0:
    x -= raw[i]-1
  elif i % 2 == 0:
    a.append(raw[i])
  else:
    b.append(raw[i])
#print(raw)
#print(a,x)
#print(b,y)
nowa = {0}
for aa in a:
  lasta = nowa
  nowa = set()
  for aaa in lasta:
    nowa.add(aaa+aa)
    nowa.add(aaa-aa)
nowb = {0}
for bb in b:
  lastb = nowb
  nowb = set()
  for bbb in lastb:
    nowb.add(bbb+bb)
    nowb.add(bbb-bb)
#print(nowa,nowb)
#print(x,y)
if x in nowa and y in nowb:
  print('Yes')
else:
  print('No')