peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()
 
ok_count = 0
ok_fcount = 0
for i in range(N):
  if S[i] == 'a':
    if ok_count < A+B:
      print('Yes')
      ok_count +=1
      
    else:
      print('No')
      
  elif S[i] == 'b':
    if ok_count < A+B and ok_fcount < B:
      print('Yes')
      ok_count+=1
      ok_fcount+=1
      
    else:
      print('No')
      
  else:
    print('No')
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)

b1 = [i[0] for i in c.items() if i[1] >= 4]
b2 = [i[0] for i in c.items() if 4 >= i[1] >= 2]
b = b1 + b2 + [0,0]

b.sort()
print(b[-1]*b[-2])
# Judge status: Wrong Answer
a, b, c = map(str, input().split())

print(a[0], "")
print(b[0], "")
print(c[0])
# Judge status: Accepted
import collections

n = int(input())
base = input().split()
x = []
for i in base:
    x.append(int(i))
#x.sort(reverse = False)
c = collections.Counter(x)
for i in range(1,n):
    print(c[i])
print(0)
# Judge status: Wrong Answer
N = int(input())
A = [int(input()) for _ in range(N)]
cnt = 0
for i in range(N):
    cnt += A[i]//2
    A[i] = A[i]%2
for i in range(1,N-1):
    if A[i-1]+A[i]==2:
        cnt += 1
        A[i]=0
print(cnt)
# Judge status: Wrong Answer
A = input()
B = int(input())
C = ""
for i in range(B):
    D = input().split()
    if D[0] == "1":
        A,C = C,A
    else:
        if D[1] == "1":
            A += D[2]
        else:
            C += D[2]
A = A[::-1]
print(A+C)
# Judge status: Wrong Answer
n, m = map(int, input().split())


def make_divisors(num):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    return divisors

div = make_divisors(num=m)
div.sort()
ans = 0
for x in div:
    if x*n <= m:
        ans = max(ans, x)
print(ans)
# Judge status: Wrong Answer
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

m = {'p': s, 'r': p, 's': r}

dp = [''] * n
a = 0
for i in range(k):
    a += m[t[i]]
    
for i in range(k, n):
    if t[i] != dp[i-k]:
        a += m[t[i]]
        dp[i] = t[i]

print(a)
# Judge status: Accepted
A,B,C=map(int,input().split())
ans=0

if A%2!=0 or B%2!=0 or C%2!=0:
      pass
elif A==B and B==C:
  ans=-1
else:
  while True:
    if A%2!=0 or B%2!=0 or C%2!=0:
      break

    A,B,C=B/2+C/2,A/2+C/2,A/2+B/2
    ans+=1

print(ans)
# Judge status: Wrong Answer
n=int(input())
arr=list(map(int,input().split()))
ans=sum(arr)
if n==0:
  if arr[0]==0:
    print(-1)
  else:
    print(1)
  exit()
maxs=[0]*n
maxs[0]=1
if arr[0]>=1:
  print(-1)
  exit()
for i in range(1,n):
  maxs[i]=2*maxs[i-1]-arr[i]
  if i<=30 and arr[i]>=2**i:
    print(-1)
    exit()
maxs[n-1]=min(maxs[n-1],arr[n])
tmp=arr[n]
for i in range(n-2,-1,-1):
  tmp+=arr[i+1]
  maxs[i]=min(maxs[i],tmp)
ans+=sum(maxs)
print(ans)
# Judge status: Wrong Answer
S = list(map(int, input().split()))
S.sort()
if S.sort()==[5,5,7]:
  print("YES")
else: print("NO")
# Judge status: Accepted
import math
import sys

N = int(input())

ans = []
if N == 0:
  print(0)
  sys.exit()

while(N != 0):
  m = N % (-2)
  if m == -1:
    m = 1
  ans.insert(0, str(m))
  N = math.ceil(N / (-2))

print("".join(ans))
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[27]:


N,M = map(int, input().split())
xy = []
b = [1]*N
p = [False]*N
p[0] = True
for _ in range(M):
    x,y = map(int, input().split())
    b[x-1] -= 1
    b[y-1] += 1
    if p[x-1]:
        p[y-1] = True
    if b[x-1] == 0:
        p[x-1] = False


# In[28]:


ans = 0
for j in p:
    if j:
        ans += 1
print(ans)


# In[ ]:
# Judge status: Wrong Answer
l = list(map(int,input().split()))
n, k = l[0], l[1]
a = list(map(int,input().split()))

for i in range(k, n):
    if a[i] > a[i-3]:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
x = int(input())

for val in range(x, x**2) :
	if ((2** val) % val) == 2 :
		print (val)
		break
	else :
		continue
# Judge status: Wrong Answer
n = int(input())
a = [int(input()) for i in range(n)]
num = 0
s = 0
for h in a:
    if s == 0:
        num += h//2
        s = h%2
    else:
        if h == 0:
            s = 0
        else:
            num += 1 + (h-1)//2
            s = (h-2)%2
print(num)
# Judge status: Wrong Answer
n=int(input())
from math import floor,sqrt
sqset=set()
for i in range(1,101):
  sqset.add(i**2)
def func(m):
  r=0
  for x in range(1,floor(sqrt(m))+1):
    for y in range(1,floor(sqrt(m))+1):
      a=x+y
      b=x**2+y**2+x*y-m
      d=a**2-4*b
      if d in sqset:
        if (sqrt(d)-a)>0 and (sqrt(d)-a)%2==0:
          r+=1
  return r
for i in range(1,n+1):
  print(func(i))
# Judge status: Accepted
A,B,C=map(int,input().split())
print(min(A+B,B+C,C+A))
# Judge status: Accepted
N,C,K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

if C == 1:
    print(N)
    exit()

ans = 1
time = -1
for i,t in enumerate(T):
    if time < 0:
        cnt, time = 1, t + K
    elif t <= time:
        cnt += 1
    else:
        ans += 1
        cnt, time = 1, t + K
    
    if cnt == C:
        time = -1
        ans += 1

print(ans)
# Judge status: Accepted
n = int(input())
ans = ""
if n == 0:
    print(0)
    exit(0)
while n != 0:
    if n%(-2) == -1:
        ans += "1"
    else:
        ans += "0"
    n //= 2
    n *= -1
print(ans[::-1])
# Judge status: Accepted
a, b, c = map(int, input().split())

T = c - a - b
if T < 0:
    print('No')
elif T**2 > 4 * a * b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
s = []
alp='abcdefghijklmnopqrstuvwxyz'
con = []
for i in range(n):
    s =input()
    for j in range(26):
        con.append(s.count(alp[j]))
    

ans = ''

for i in range(26):
    num = []
    for j in range(n):
        num.append(int(con[i+j*26]))
    ans += alp[i] * min(num)
print(ans)
# Judge status: Wrong Answer
from fractions import gcd

N = int(input())
T = [int(input()) for _ in range(N)]

r = T[0]
for i in range(1, N):
    r = gcd(r, T[i])

R = [t // r for t in T]
R.sort(reverse=True)
ans = r
for i in range(N):
    if ans % R[i] != 0:
        ans *= R[i]

print(ans)
# Judge status: Accepted
#AGC031 A Colorful Subsequence
# Answer
N = int(input())
S = input()
alpha = [0]*26
mod = 10**9+7

for n in S:
    num = ord(n)-97
    alpha[num] += 1
    
ans = 1
for i in range(26):
    ans *= (alpha[i]+1)

ans %= mod
print(ans-1)
# Judge status: Accepted
n=int(input())
c=0
for i in range(n):
	a,b=map(int, input().split())
	if a==b:
		c+=1
		if c==3:
			print("Yes")
			exit()
	else:
		c=0
print("No")
# Judge status: Accepted
A,B,C=map(int,input().split())
if A+B<C:
  print("No")
else:
  print("Yes")
# Judge status: Wrong Answer
n = input()
m = input().split()
judge = ""
for i, e in enumerate(m):
    if int(e)%2 == 0:
        if int(e)%3==0 or int(e)%5==0:
            judge = "APPROVED"
        else:
            judge = "DENIED"
            break
print(judge)
# Judge status: Accepted
s=input()
if s[0]==s[1]==s[2]:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n = int(input())
for i in range(1, 10):
    for j in range(1, 10):
        if i*j == n:
            print("Yes")
            exit()
print("No")
# Judge status: Wrong Answer
r = int(input())
print(int(r**2 * 3.14 / 1**2 * 3.14))
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
ans=2**n-1
x=1
y=1
i=0
while a:
	i+=1
	x*=(n-i+1)
	y*=i
	a=a-1
ans1=x/y
x=1
y=1
i=0
while b:
	i+=1
	x*=(n-i+1)
	y*=i
	b=b-1
ans2=x/y
ans=ans-ans1-ans2
ans%=100000007
print(ans)
# Judge status: Accepted
a = input()
if a[2] == a[3] and a[4] == a[5]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s=input()
if s[-1]=="s":
    print(s+"es")
else :
    print(s+"s")
# Judge status: Wrong Answer
n = int(input())
ss = []
for i in range(n):
    s = list(input())
    s.sort()
    ss.append(s)
ans = []
ans = ss[0]
for i in range(n):
    for j in ans:
        if ss[i].count(j) < ans.count(j):
            ans.remove(j)
for i in range(n):
    for j in ans:
        if ss[i].count(j) < ans.count(j):
            ans.remove(j)
print(" ".join(ans))
# Judge status: Accepted
from collections import Counter
N = int(input())
a = [int(input()) for i in range(N)]

c = Counter(a)

#偶数回表れていれば消えている、奇数回であれば紙に掛かれている状態
ans = 0
for n, count in c.items():
  if count % 2 == 1:
    ans += 1

print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
x = 0
y = 0
for i in range(N):
    if A[i]>B[i]:
        x += A[i]-B[i]
    else:
        y += (B[i]-A[i])//2
if y>=x:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = str(input())

n = len(s)
cnt = 0
for i in range(n):
    if s[i] == '7':
        cnt = 1
        break

if cnt == 1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a, b = map(int, input().split())
c = a + b
if c >= 24:
    print(c - 24)
else:
    print(c)
# Judge status: Wrong Answer
A,B = map(int,input().split())

if 1<= A*B <= 81:
  print(A*B)
else:
  print(-1)
# Judge status: Wrong Answer
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
count = 0
for i in range(N):
    b = B[i]
    cind = bisect.bisect_left(C,b)
    aind = bisect.bisect_right(A,b)
    count+=(N-cind)*aind
print(count)
# Judge status: Accepted
n = int(input())

b = range(1, n)

a = b[::2]
print(1 - (len(a) / n))
# Judge status: Wrong Answer
n, t = map(int, input().split())

max_cost = 10 ** 9

for _ in range(n):
  c, tt = map(int, input().split())
  if tt <= t:
    max_cost = max(max_cost, c)
    
print(max_cost)
# Judge status: Accepted
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
x, y = map(int, input().split())
if x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N, M = map(int, input().split())

dic_1 = dict()
for i in range(N):
    a, b = map(int, input().split())
    dic_1[a] = b

dic_2 = sorted(dic_1.items())

cost = 0
cnt = 0
flg = False
for key, value in dic_2:
    for i in range(value):
        cost += key
        cnt += 1
        
        if cnt == M:
            flg = True
            break
    
    if flg:
        break

print(cost)
# Judge status: Accepted
N = int(input())

for x in range(N+1):
    if int(x*1.08) == N:
        print(x)
        break
else:
    print(':(')
# Judge status: Accepted
def main():
  count = 0
  for i in range(1,int(input())+1):
    if i % 3 == 0:
      continue
    if i % 5 == 0:
      continue
    count += i
  return count
    
print(main())
# Judge status: Accepted
def main():
    from heapq import heappush, heappop

    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())

    h = []
    for _ in range(N):
        a, b = map(int, input().split())
        heappush(h, (a, b))

    while h:
        a, b = heappop(h)
        K -= b
        if K <= 0:
            print(a)
            return


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N,M=map(int,input().split())

if N==1 and M==1:
    print(0)
elif N == 1:
    print(M*(M-1)/2)
elif M == 1:
    print(N*(N-1)/2)
else:
    print(int((M*(M-1)+N*(N-1))/2))
# Judge status: Wrong Answer
N,Y=map(int,input().split(' '))
for i in range(N+1):
    for j in range(N-i+1):
        if i*1000+j*5000+10000*(N-i-j) == Y:
            print(i,j,N-i-j)
            exit()
print(-1,-1,-1)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if a-b==b-c:
    ans="Yes"
else:
    ans="No"
print(ans)
# Judge status: Wrong Answer
a = input().split()
set(a)
print(len(a))
# Judge status: Accepted
from bisect import bisect_right, bisect_left
N=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
a.sort()
c.sort()
ans=0
for i in range(N):
  s=b[i]
  k=bisect_left(a,s)*(N-bisect_right(c,s))
  ans+=k
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
# 157c
n, m = map(int, input().split())
s = []
c = []
for _ in range(m):
  _s, _c = input().split()
  s.append(int(_s))
  c.append(_c)

ret = -1
for i in range(1000):
  x = str(i)
  if len(x) != n:
    continue
  isOk = True
  for _s, _c in zip(s, c):
    #if len(x) < _s or x[_s - 1] != _c:
    if x[_s - 1] != _c:
      isOk = False
      break
  if isOk:
    ret = i
    break
print(ret)
# Judge status: Accepted
n, x, y = map(int,input().split())
dist = [0] * n
x -= 1
y -= 1
for i in range(n):
  for j in range(i+1, n):
    dist[min(j-i, abs(x-i)+abs(y-j)+1, abs(y-i)+abs(x-j)+1)] += 1
for d in dist[1:]:
  print(d)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
sa = set(a)
print("Yes") if len(a) == len(sa) else print("No")
# Judge status: Wrong Answer
S = input()
N = int(input())

for i in S:
    if i != "1":
        print(i)
        quit()

print(1)
# Judge status: Accepted
N, M, K = map(int, input().split())
ans = "No"
for i in range(N+1):
    for j in range(M+1):
        if i*(M-j) + j*(N-i) == K:
            ans = "Yes"
            break
print(ans)
# Judge status: Wrong Answer
n,k = map(int,input().split())
d = input().split()
for i in range(n,10000):
    for j in range(k):
        for l in range(len(str(i))):
            if str(i)[l] == str(d)[j]:
                break
        else:
            continue
        break
    else:
        print(i)
        break
# Judge status: Wrong Answer
n=(int)(input())
a=list(map(int, input().split(" ")))
for i in range(len(a) - 1):
  if a[i] > a[i + 1] + 1:
    print("No")
    break
else:
  print("Yes")
# Judge status: Wrong Answer
n,k=map(int,input().split())
l=list(map(int,input().split()))

for i in range(k,n):
  if l[i] > l[i-1]:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
import collections

N = int(input())
A = list(map(int, input().split()))
ans = 0
p_list = []
m_list = []
for i in range(N):
    p_list.append(i + A[i])
    m_list.append(i - A[i])
p_c = collections.Counter(p_list)
m_c = collections.Counter(m_list)

for i in range(N):
    ans += p_c[i - A[i]]
    ans += m_c[i + A[i]]
print(ans//2)
# Judge status: Accepted
S = list(input())

if S[len(S)-1] != 's':
  S.append('s')
else:
  S.append('es')

print(''.join(S))
# Judge status: Accepted
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
between = [x[i] - x[i-1] - 1 for i in range(1,m)]
between.sort(reverse=True)
print(max(0, (x[-1] - x[0] + 1) - sum(between[:n-1]) - n))
# Judge status: Accepted
n=int(input())
print(800*n-(n//15)*200)
# Judge status: Accepted
a,b = map(int, input().split())

if a >= 13:
    print(b)
elif 6 <= a and a <= 12:
    print(b//2)
else:
    print(0)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

p, m = 0, 0
for i in range(N):
  if a[i]-b[i] > 0:
    p += a[i]-b[i]
  else:
    m += b[i]-a[i]
    
if 2*p <= m:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
#!/usr/bin/env python3

N = int(input())
A = [int(i) for i in input().split()]

rate = [400,800,1200,1600,2000,2400,2800,3200]
R = [False]*len(rate)
red_plus = 0

for a in A:
    if a >= rate[-1]:
        red_plus += 1
    else:
        for i,r in enumerate(rate):
            if a < r:
                R[i] = True
                break
    
if R.count(True) == 0:
    print(1, R.count(True)+red_plus)
else:
    print(R.count(True), R.count(True)+red_plus)
# Judge status: Accepted
import sys
str_N = input()
N = int(str_N)

if not ( 1 <= N <= 10**5 ): sys.exit()

count = 0
for I in range(1,N+1):
    if len(str(I)) % 2 == 1: count += 1
print(count)
# Judge status: Accepted
from functools import reduce
from fractions import gcd
n, x = map(int, input().split())
X = [abs(x-int(i)) for i in input().split()]
print(reduce(gcd, X))
# Judge status: Accepted
from collections import Counter

bag = Counter()

N  = int(input())

word_s = []
word_t = []

for i in range(N):
    bag[input()] += 1

M  = int(input())
for i in range(M):
    bag[input()] -= 1

max = sorted(bag.items(), key=lambda item: item[1], reverse=True)[0][1]

if max > 0:
    print(max)
else:
    print(0)
# Judge status: Accepted
def solve():
    ret = 1
    cur_num = X
    while cur_num * 2 <= Y:
        cur_num *= 2
        ret += 1
    print(ret)

if __name__ == "__main__":
    X, Y = map(int, input().split())
    solve()
# Judge status: Wrong Answer
import collections
s=list(input())
t=list(input())
svalues, scounts = zip(*collections.Counter(s).most_common())
tvalues, tcounts = zip(*collections.Counter(t).most_common())
if len(set(s))==len(set(t)):
    if scounts==tcounts:print('Yes')
else:print('No')
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))

ans = 0
stp = 0
for i in range(1, n):
    if h[i] <= h[i-1]:
        stp += 1
        ans = max(ans, stp)
    else:
        stp = 0
print(ans)
# Judge status: Accepted
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
B = list(map(int,input().split()))

A = [0]*N
A[0] = B[0]
for i in range(N-1):
    A[i+1] = B[i]
    if A[i] > B[i]:
        A[i] = B[i]

print(sum(A))
# Judge status: Accepted
def GCD(x, y):
    if y == 0:
        return x
    return GCD(y, x % y)


N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(set(A))

check = set()
for a in A:
    cnt = 0
    while a % 2 == 0:
        cnt += 1
        a //= 2
    check.add(cnt)

if len(check) > 1:
    print(0)
    exit()

LCM = 1
for a in A:
    gcd = GCD(LCM, a // 2)
    LCM = LCM * (a // 2) // gcd

ans = (M - LCM) // (2 * LCM) + 1
print(ans)
# Judge status: Accepted
X = int(input())
a = X // 500
X %= 500
print(1000 * a + 5 * (X // 5))
# Judge status: Wrong Answer
n,d=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
cnt=0

for i in range(n):
  for i2 in range(i+1,n):
    distance = 0
    for j in range(d):
      distance+=(abs(l[i][j])-abs(l[i2][j]))**2
    
    if (distance**0.5).is_integer():
      cnt+=1
      
print(cnt)
# Judge status: Accepted
n, m = map(int, input().split())
n, m = min(n, m), max(n, m)
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m - 2)
else:
    print((m - 2) * (n - 2))
# Judge status: Accepted
import collections

n = int(input())
a = list(map(int, input().split()))
d = collections.Counter(a)

ans = 0
for key, values in d.items():
    if key < values:
        ans += values - key
    elif key > values:
        ans += values
print(ans)
# Judge status: Accepted
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
max_node = [0] * (N+1)
for i in range(N-1,-1,-1):
    max_node[i] = max_node[i+1]+A[i+1]


ans = 1
node = 1
for i in range(N+1):
    node -= A[i]
    if (i < N and node <= 0) or node < 0:
        print(-1)
        exit(0)
    node = min(node*2,max_node[i])
    ans += node
print(ans)
# Judge status: Wrong Answer
X, Y = map(int, input().split())

a, b = divmod(2*X-Y, 3)
c, d = divmod(2*Y-X, 3) 
if not b==d==0:
  print(0)
else:
  m, n = 1, 1
  mod = 10**9+7
  for i in range(1, min(a, c)+1):
    m = (m * (a+c-i+1)) % mod
    n = (n * i) % mod
  ans = (m * pow(n, mod-2, mod)) % mod
  print(ans)
# Judge status: Accepted
a,b = map(int, input().split())
if (a%2 == 0 and b%2 == 0) or (a%2 != 0 and b%2 != 0):
  print((a+b)//2)
else:
  print('IMPOSSIBLE')
# Judge status: Accepted
#ABC-112-B
N, T = map(int, input().split())
ans = 1001
for _ in range(N):
    ci, ti = map(int, input().split())
    if ti <= T:
        ans = min(ans, ci)
        
if ans == 1001:
    print("TLE")
else:
    print(ans)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
x = a[0]
y = sum(a)-a[0]
res = abs(x-y)
for i in range(1,N-1):
    x += a[i]
    y -= a[i]
    if abs(x-y) < res:
        res = abs(x-y)
print(res)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
if n < 3:
    print(0)
else:
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
              if a[i] + a[j] > a[k] and len(set([a[i],a[j],a[k]])) == 3:
                    ans += 1
print(ans)
# Judge status: Wrong Answer
X = list(map(int, input().split()))
A = []
B=[]
C=[]
for _ in range(X[2]):
    A.append(int(input()))
for _ in range(X[0]):
    B.append(X[1]-X[2])
for i in range(0,X[2]):
    B[A[i]-1]=B[A[i]-1]+1
for j in range(0,X[0]):
    if B[j]>0:
        C.append("Yes")
    else:
        C.append("No")
print(C)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    counter = 0
    X = input().strip()
    stack = list()
    for s in X:
        if len(stack) < 1:
            stack.append(s)
        elif stack[-1] == "S" and s == "T" and counter < (10 ^ 10000) + 1:
            stack.pop()
            counter += 1
        else:
            stack.append(s)
    return len(stack)


if __name__ == "__main__":
    print(main())
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
l.sort()
lmax=l[-1]
lsum=sum(l[:n-1])
if lmax<lsum:print("Yes")
else:print("No")
# Judge status: Accepted
l, r, d = map(int, input().split())
ans = 0
for i in range(l, r + 1):
  if i % d == 0:
    ans += 1
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())

if M == N:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
x=list(map(int,input().split()))
a=0
b=0
for i in range(n//2):
  a+=max(x)
  x.remove(max(x))
  b+=max(x)
  x.remove(max(x))

if n%2:
  a+=x[0]
dif=a-b
print(dif)
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
if n == 0 and a[0] == 1:
    print(1)
    exit()
b = []
i = 0
for j in reversed(a):
    i += j
    b.append(i)
b.reverse()
ans = 1
if a[0] != 0:
    print(-1)
    exit()
i = 1
for j, k in zip(a[1:], b[1:]):
    if j > i*2:
        print(-1)
        exit()
    i = min(k, i * 2) - j
    ans += i + j
    if i < 0:
        print(-1)
        exit()
print(ans)
# Judge status: Accepted
import sys

S_ = input()
T = input()

ans = 'UNRESTORABLE'
if len(S_) < len(T):
    print(ans)
    sys.exit()

S = []
for i in range(len(S_) - len(T) + 1):
    for j in range(len(T)):
        if S_[i + j] == '?' or S_[i + j] == T[j]:
            continue
        else: break
    else:
        tmp = S_[0:i] + T + S_[i + len(T):len(S_)]
        S.append(tmp.replace('?', 'a'))

if len(S) > 0:
    sort = sorted(S)
    ans = sort[0]

print(ans)
# Judge status: Accepted
import sys

input = sys.stdin.readline


def solve():
    s, w = map(int, input().split())
    if w >= s:
        return 'unsafe'
    else:
        return 'safe'


if __name__ == '__main__':
    answer = solve()
    print(answer)
# Judge status: Accepted
a, b = map(int, input().split())
def gcd(a,b):
   while b != 0:
      a, b = b, a%b
   return a
def lcm(a,b):
   return a*b/gcd(a,b)
print(int(lcm(a,b)))
# Judge status: Wrong Answer

N = int(input())
input_line = input()
Line = input_line.split()
Line1 = [int(s) for s in Line]
input_line = input()
Line = input_line.split()
Line2 = [int(s) for s in Line]

print(Line1)
print(Line2)

point = 9999
max_candy = 0

for i in range(N):
    on_candy = sum(Line1[0:i+1]) + sum(Line2[i:N])
    # print(sum(Line1[0:i+1]),sum(Line2[i:N]))
    if max_candy < on_candy:
        max_candy = on_candy
        point = i
        
print(max_candy)
# Judge status: Accepted
n = int(input())
d = list(map(int, input().split()))
d.sort()

print(d[int(n/2)] - d[int(n/2 - 1)])
# Judge status: Wrong Answer
import sys
from collections import Counter

inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()

cnt = 0

if not ("N" in s and "S" in s):
    cnt += 1
if not ("E" in s and "W" in s):
    cnt += 1

print("Yes") if cnt != 2 else print("No")