Harryxun/stf_run huggingface dataset:
s = input()
x, y = map(int, input().split())
m = list(map(len, s.split('T')))
# 最初は右に行くしかない
dp_x = {m[0]}
for i in m[2::2]:
    new_dp = set()
    for v in dp_x:
        new_dp += {v + i, v - i}
    dp_x = new_dp

dp_y = {0}
for i in m[1::2]:
    new_dp = set()
    for v in dp_y:
        new_dp += {v + i, v - i}
    dp_y = new_dp

print('Yes' if x in dp_x and y in dp_y else 'No')

print(dp_x)
print(dp_y)

### FIXED CODE ###

s = input()
x, y = map(int, input().split())
m = list(map(len, s.split('T')))
# 最初は右に行くしかない
dp_x = {m[0]}
for i in m[2::2]:
    new_dp = set()
    for v in dp_x:
        new_dp |= {v + i, v - i}
    dp_x = new_dp

dp_y = {0}
for i in m[1::2]:
    new_dp = set()
    for v in dp_y:
        new_dp |= {v + i, v - i}
    dp_y = new_dp

print('Yes' if x in dp_x and y in dp_y else 'No')
s=input()
t=input()
if s==t.remove(t[len(t)-1]):
  print('Yes')
else:
  print('No')


### FIXED CODE ###

s=input()
t=input()
if s==t[:len(t)-1]:
  print('Yes')
else:
  print('No')
A, op, B = map(int,input().split())
if op == '+':
    print(A+B)
else:
    print(A-B)


### FIXED CODE ###

A, op, B = input().split()
if op == '+':
    print(int(A)+int(B))
else:
    print(int(A)-int(B))
print input()**3


### FIXED CODE ###

# python3 では input()は文字列として処理される。

x = int(input())
print(x**3)
a,b,k = list(map( int, input().split()))
x = list(range(a,b+1))
x = sorted(list(set(x[:k])|set(x[-k:])))
for i in x:
  print(i)

### FIXED CODE ###

a,b,k=map(int,input().split())
l=range(a,b+1)
ans=sorted(set(l[:k])|set(l[-k:]))
for i in ans:
    print(i)
from math import factorial

N = int(input())
S = list(''.join(sorted(str(input()))) for _ in range(N))
unique_S = list(set(S))

ans = 0
for s in unique_S:
    n = S.count(s)
    if n > 1:
        ans += factorial(n) / factorial(2) / factorial(n - 2)
print(int(ans))


### FIXED CODE ###

N = int(input())
S = list(''.join(sorted(str(input()))) for _ in range(N))

dic = {}
ans = 0

for s in S:
    if not s in dic:
        dic[s] = 1
    else:
        ans += dic[s]
        dic[s] += 1
print(ans)
N, K = map(int, input().split())
P    = list(map(int, input().split()))

q = sum(P[:K])
m = q

for k in range(K):
    if k > 0:
        q = q - P[k-1] + P[K-1+k]
    if m < q:
        m = q

print((m+K)/2)


### FIXED CODE ###

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

q = sum(P[:K])
m = q

for k in range(N-K+1):
    if k > 0:
        q = q - P[k-1] + P[K-1+k]
    if m < q:
        m = q

print((m+K)/2)
s=input()
for i in range(len(s)):
  if s[i]==`A`:
    a=i
    break
for i in reversed(range(len(s))):
  if s[i]==`Z`:
    b=i
    break
print(b-a)

### FIXED CODE ###

s=input()
for i in range(len(s)):
  if s[i]=="A":
    a=i
    break
for i in reversed(range(len(s))):
  if s[i]=="Z":
    b=i
    break
print(b-a+1)
N = int(input())
def fract(n):
    if n == 1:
        return n
    return n * fract(n-1)
res = fract(N) % 1000000007
print(res)

### FIXED CODE ###

N = int(input())
fact = 1
for integer in range(1,N+1):
    fact = fact * integer % 1000000007
print(fact)
n=int(input())
l=list(map(int,input().split()))
s=1
for i in range(1,n):
  if l[i]>=max(l[0:i]):
    s=s+1
print(s)

### FIXED CODE ###

a,b = input().split()
M,m=max(int(a),int(b)),min(int(a),int(b))
if M==m:
  print(2*M)
else:
  print(2*M-1)
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V <= W:
    print("NO")
    exit()

s = V - W
if D < s * T:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V <= W:
    print("NO")
    exit()

d = abs(A - B)
s = V - W

if d <= s * T:
    print("YES")
else:
    print("NO")
X,Y,Z,K = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
     
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
     
li = []
for i in range(len(a)):
    for j in range(len(b)):
        li.append(a[i]+b[j])
    
li.sort(reverse = True)
     
li1 = []
for i in range(len(li)):
    for j in range(len(c)):
        li1.append(li[i]+c[j])
        if j > k:
          break
li1.sort(reverse = True)
n = 1
while n < K+1:
    print(li1[n-1])
    n += 1

### FIXED CODE ###

li = list(int(input()) for i in range(5))
#print(li)
k = int(input())

li1 = [(x - y) for x in li for y in li if x>y]
#print(li1)
if all(li1[i]<=k for i in range(len(li1))):
    print("Yay!")
else:
    print(":(")
Masu = []
def access(x,y):
    if x < 0 or y < 0:
        return
    Masu[y][x] += 1

for i in range(10):
    Masu.append([0,0,0,0,0,0,0,0,0,0])
kosu = 0
komax = 0
while True:
    try:
        
        x,y,s = map(int,input().split(","))
        if s == 1:
            for j in range(3):
                access(y +1 - j,x)
            access(y,x - 1)
            access(y,x + 1)

        elif s == 2:
            for k in range(3):
                for l in range(3):
                    access(y + 1 - k,x + 1 -l)
        elif s == 3:
            for k in range(3):
                for l in range(3):
                    access(y + 1 - k,x + 1 -l)
            access(y - 2,x)
            access(y + 2,x)
            access(y,x + 2)
            access(y,x - 2)
               
    except (EOFError,ValueError):
        for i in range(10):
            kosu += Masu[i].count(0)
        for j in range(10):
            if komax < max(Masu[j]):
                komax = max(Masu[j])
        print(kosu)
        print(komax)
        break

### FIXED CODE ###

Masu = []
def access(x,y):
    if x < 0 or y < 0 or x > 9 or y > 9:
        return
    Masu[y][x] += 1

for i in range(10):
    Masu.append([0,0,0,0,0,0,0,0,0,0])
kosu = 0
komax = 0
while True:
    try:
        
        x,y,s = map(int,input().split(","))
        if s == 1:
            for j in range(3):
                access(y +1 - j,x)
            access(y,x - 1)
            access(y,x + 1)

        elif s == 2:
            for k in range(3):
                for l in range(3):
                    access(y + 1 - k,x + 1 -l)
        elif s == 3:
            for k in range(3):
                for l in range(3):
                    access(y + 1 - k,x + 1 -l)
            access(y - 2,x)
            access(y + 2,x)
            access(y,x + 2)
            access(y,x - 2)
               
    except (EOFError,ValueError):
        for i in range(10):
            kosu += Masu[i].count(0)
        for j in range(10):
            if komax < max(Masu[j]):
                komax = max(Masu[j])
        print(kosu)
        print(komax)
        break
N=int(input())
xy=[[] for in range(N)]
for _ in range(N):
    A = int(input())
    for __ in range(A):
        x, y = map(int, input().split())
        xy[_].append((x-1,y))

ans = 0
for p in range(1<<N):
    h = []
    judge = True
    for i in range(N):
        h.append(p&1)
        p>>=1
    for i in range(N):
        for x, y in xy[i]:
            if h[i] and y != h[x]:
                judge = False
                break
        if not judge: break
    if not judge: continue
    ans = max(ans,sum(h))

print(ans)


### FIXED CODE ###

N = int(input())
A = []
for _ in range(N):
    a = int(input())
    xy = []
    for __ in range(a):
        xy.append(tuple(map(int,input().split())))
    A.append(xy)

ok = []
for i in range(2**N):
    v = [0] * (N+1)
    n = i
    for j in range(1, N+1):
        v[j] = n % 2
        n >>= 1
    for k, xys in enumerate(A):
        if v[k+1] == 1:
            for xy in xys:
                if xy[1] != v[xy[0]]:
                    break
            else:
                continue
            break
    else:
        ok.append(v)

ans = 0
for a in ok:
    ans = max(ans,sum(a))
print(ans)
obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
val_list = [-1 * item for item in list(map(int, obj))]

heapify(val_list)

for _ in range(M):
    val = (-1) * ((heappop(val_list) * (-1)) // 2)
    heappush(val_list, val)

print(-1 * sum(val_list))


### FIXED CODE ###

from heapq import heappush, heappop, heapify

obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
val_list = [-1 * item for item in list(map(int, obj))]

heapify(val_list)

for _ in range(M):
    val = (-1) * ((heappop(val_list) * (-1)) // 2)
    heappush(val_list, val)

print(-1 * sum(val_list))
s = input()
s_list = list(str)
 
if str_list[0] == str_list[2]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

str = input()
str_list = list(str)
 
if str_list[0] != str_list[1]:
  print("Yes")
elif str_list[1] != str_list[2]:
  print("Yes")
else:
  print("No")
import sys, math, bisect

N, M= map(int, sys.stdin.readline().split())
AB = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)]

edge =[[] for _ in range(N)]
for ab in AB:
    bisect.insort(edge[ab[0]-1], (ab[1]-1))
    bisect.insort(edge[ab[1]-1], (ab[0]-1))
    
#print(edge)
sys.setrecursionlimit(100000)


def dfs(now, cnt =1, before=-1):#before:一つ前に通ったノード
    #if before==-1:
        #print(now)
    for c in edge[now]: #c:子
        if not c ==before: #無限ループを防ぐ
            #print(c)
            if c==0:
                L.append(cnt)
                break
            else:
                dfs(c, cnt+1, now) #再帰

ans = []
for i in range(1, N):
    L = []
    dfs(i)
    ans.append(min(L))
print('Yes')
for a in ans:
    print(a)

### FIXED CODE ###

#168D
def main():
    import sys
    
    N, M =map(int, sys.stdin.readline().split())
    AB = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)]
    
    edge = [[] for _ in range(N)]
    for ab in AB:
        edge[ab[0]-1] += [ab[1]-1]
        edge[ab[1]-1] += [ab[0]-1]
    
    #print(edge)
    
    L = [-1 for i in range(N)] #道標(親p)を調べる
    
    #p:親 c:子
    def bfs(p):
        from collections import deque
        queue = deque([p])
        L[p] =0
        while queue:
            p = queue.popleft()
            for c in edge[p]:
                if L[c]==-1: #-1のとき未開
                    #print(c)
                    L[c] = p+1 #道標(どこから来たか)
                    #L[c] = L[now]+1 #階層の深さ
                    queue.append(c)
        
    
    bfs(0)
    print('Yes')
    for i in L[1:]:
        print(i)


if __name__=='__main__':
    main()
A = int(input())
B = int(input())
if A >=10 or B >=10:
  print ("-1")
else:
  print (A*B)

### FIXED CODE ###

A, B = list(map(int,input().split()))
if A >=10 or B >=10:
  print ("-1")
else:
  print (A*B)
import fractions

A, B, C, D = map(int, input().split())

count = B - A + 1
lcd_of_CD = C * D // math.gcd(C, D)

count -= B // C
count += (A - 1) // C
count -= B // D
count += (A - 1) // D
count += B // lcd_of_CD
count -= (A - 1) // lcd_of_CD

print(count)

### FIXED CODE ###

S = input()

for i in range(len(S) - 1):
    if S[i] == S[i+1]:
        print('Bad')
        exit()
print('Good')
b = input()

if b=='A':
  print "T"
if b=='c':
  print "G"
if b=='G':
  print "C"
if b=='T':
  print "A"

### FIXED CODE ###

b = input()

if b=='A':
  print ('T')
if b=='C':
  print ('G')
if b=='G':
  print ('C')
if b=='T':
  print ('A')
A, B, C = map(int, input().split())
if A <= C <= B:
  print(“Yes”)
else:
  print(“No”)

### FIXED CODE ###

A, B, C = map(int, input().split())
if A <= C <= B:
   print("Yes")
else:
   print("No")
s = input()
if len(s)<26:
  for i in al:
    if i not in s:
      print(s+i)
      break
else:
  if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
  else:
    k = []
    for i in range(25, 0, -1):
      k.append(s[i])
      if s[i-1] < s[i]:
        for j in sorted(k):
          if j > s[i-1]:
            print(s[:i-1] + j)
            exit()

### FIXED CODE ###

al = "abcdefghijklmnopqrstuvwxyz"
s = input()
if len(s)<26:
  for i in al:
    if i not in s:
      print(s+i)
      break
else:
  if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
  else:
    k = []
    for i in range(25, 0, -1):
      k.append(s[i])
      if s[i-1] < s[i]:
        for j in sorted(k):
          if j > s[i-1]:
            print(s[:i-1] + j)
            exit()
import sys
sys.setrecursionlimit(10**4)

N = int(input())
h = list(map(int,input().split()))

memo = [-1]*N

def func(i):
  # メモのロード
  if memo[i]!=-1:
    return memo[i]
  # 初期値の部分
  if i==0:
    return 0
  elif i==1: 
    return abs(h[1]-h[0])
  # 二択の部分
  a = func(i-1)+abs(h[i]-h[i-1])
  b = func(i-2)+abs(h[i]-h[i-2])
  memo[i] = min(a,b) # メモのセーブ
  return memo[i]

print(func(N-1))


### FIXED CODE ###


N = int(input())
h = list(map(int,input().split()))
#print(h)

dp = [0]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for n in range(2,N):
	step1 = abs(h[n]-h[n-1])+dp[n-1]
	step2 = abs(h[n]-h[n-2])+dp[n-2]
	dp[n] =  min(step1,step2)

ans = dp[N-1]
print(ans)
a, b = map(int, input().split())
d = b - a

def memorize(f):
	table = {}
	def func(*args):
		if not args in table:
			table[args] = f(*args)
		return table[args]
	return func

@memorize
def s(n):
	if n <= 1:
		return 1
	else:
		return s(n-1)+n
print(s(d-1)-a)

### FIXED CODE ###

a, b = map(int, input().split())
d = b - a
print(int((d*(d+1)/2)-b))
n,t=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(n)]

dp=[[0]*(t) for i in range(n)]
x=[[0]*(t) for j in range(n)]
s.sort()


p=s[-1]
del(s[-1])


for i in range(n-1):
    for j in range(t):

        if j-s[i][0]>=0:
            dp[i+1][j]=max(dp[i][j],dp[i][j-s[i][0]]+s[i][1])
            if dp[i+1][j]>dp[i][j]:
                x[i+1][j]=str(x[i][j-s[i][0]])+str(i)
            else:
                x[i+1][j]=x[i][j]

        else:
            dp[i+1][j]=dp[i][j]
            x[i+1][j]=x[i][j]
count=0

v=[]
for i in x[n-1][-1]:
    count+=1
    if count==1:
        continue
    v.append(int(i))


ans=p[1]
k=0
l=len(v)
for i in range(n-1):
    if v[k]==i:
        if k<l-1:
            k+=1
        continue


    ans=max(ans,s[i][1])



print(dp[n-1][-1]+ans)




         


        




### FIXED CODE ###

n,t=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(n)]

dp=[[0]*(t) for i in range(n+1)]
s.sort()


for i in range(n):
    for j in range(t):
        if j-s[i][0]>=0:
            dp[i+1][j]=max(dp[i][j],dp[i][j-s[i][0]]+s[i][1])

        else:
            dp[i+1][j]=dp[i][j]

ans=0
for i in range(n):
    ans=max(ans,dp[i][t-1]+s[i][1])

print(ans)
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
a = na()

a.sort(reverse=True)
l = list()
for key, gr in groupby(a):
    if len(l) == 2:
        print(l[0] * l[1])
        quit()
    num = len(list(gr))
    if num >= 2:
        l.append(key)
    if num >= 4:
        l.apend(key)
print(0)


### FIXED CODE ###

from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
a = na()

a.sort(reverse=True)
l = list()
for key, gr in groupby(a):
    if len(l) == 2:
        break
    num = len(list(gr))
    if num >= 2:
        l.append(key)
    if num >= 4:
        l.append(key)
print(l[0] * l[1] if len(l) >= 2 else 0)
while True:
    a, b = map(int, raw_input().strip().split())
    if a == 0 and b == 0:
        break
    print a + b,


### FIXED CODE ###

def get(num):
    n=0
    is_prime=[0]*300050
    for i in range(0,num+1):
        is_prime[i]=True
    is_prime[0]=is_prime[1]=False
    for i in range(2,num+1):
        if(is_prime[i]):
            n+=1
            for j in range(2*i,num+1,i):
                is_prime[j]=False
    return n

while True:
    a=map(int,raw_input().strip().split())
    b=a[0]
    if(b==0):
        break
    p=get(2*b)-get(b)

#        p=0
#        for i in range(b+1,2*b+1):
#            if(judge(i)):
#                p+=1
    print(p)
input()
stones = tuple(map(int, input().split()))

tracker = {}
def min_cost(remaining_stones):
    if len(remaining_stones) == 1:
        return 0
    if len(remaining_stones) == 2:
        return abs(remaining_stones[0] - remaining_stones[1])
    
    jump_1 = remaining_stones[1:]
    if jump_1 not in tracker:
        tracker[jump_1] = min_cost(jump_1)
    jump_2 = remaining_stones[2:]
    if jump_2 not in tracker:
        tracker[jump_2] = min_cost(jump_2)

    score_1 = abs(remaining_stones[0] - remaining_stones[1]) + tracker[jump_1]
    score_2 = abs(remaining_stones[0] - remaining_stones[2]) + tracker[jump_2]
    return min(score_1, score_2)


print(min_cost(stones))

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
n = int(input())
stones = list(map(int, input().split()))
stones.reverse()

bottum_up = [-1 for i in range(n)]
bottum_up[0] = 0
bottum_up[1] = abs(stones[0] - stones[1])

for i in range(2,len(stones)):
    score_1 = abs(stones[i] - stones[i-1]) + bottum_up[i-1]
    score_2 = abs(stones[i] - stones[i-2]) + bottum_up[i-2] 
    bottum_up[i] = min(score_1, score_2)

print(bottum_up[-1])
N,K=map(int, input().split())
L=list(map(int, input().split()))
L.sort(reverse=True)
print(sum(L[0,K]))

### FIXED CODE ###

N,K=map(int, input().split())
L=list(map(int, input().split()))
L.sort(reverse=True)
print(sum(L[0:K]))
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))

    p.sort()
    y = 0

    for i in range(n):
        if p[i] <= x:
            y = i
            if i != n-1 and x < p[i+1]:
                break 

    i = 0
    while 1 == 1:
        if 0 <= y - i and x - i != p[y - i]:
            print(x - i)
            break
        if x + i != p[y + i]:
            print(x + i)
            break
        i = i + 1

### FIXED CODE ###

x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))

    p.sort()
    y = 0

    for i in range(n):
        if p[i] <= x:
            y = i
            if i != n-1 and x < p[i+1]:
                break 

    i = 0
    while 1 == 1:
        if y - i < 0:
            print(p[0] - 1)
            break
        elif x - i != p[y - i]:
            print(x - i)
            break
        if n <= y + i:
            print(p[n - 1] + 1)
            break
        elif x + i != p[y + i]:
            print(x + i)
            break
        i = i + 1
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
sys.setrecursionlimit(5000)

N, M = input_nums()

G = {}
for i in range(N):
    G[i] = []

for i in range(M):
    x, y = input_nums()
    x -= 1
    y -= 1
    G[x].append(y)

dp = [-1 for _ in range(N+1)]

def rec(v: int):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for nv in G[v]:
        res = max(res, rec(nv) + 1)
    dp[v] = res
    return res

res = 0
for v in range(N):
    res = max(res, rec(v))
print(res)

### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
sys.setrecursionlimit(10**6)

N, M = input_nums()

G = {}
for i in range(N):
    G[i] = []

for i in range(M):
    x, y = input_nums()
    x -= 1
    y -= 1
    G[x].append(y)

dp = [-1 for _ in range(N+1)]

def rec(v: int):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for nv in G[v]:
        res = max(res, rec(nv) + 1)
    dp[v] = res
    return res

res = 0
for v in range(N):
    res = max(res, rec(v))
print(res)
import heapq
n= int(input())
a=[int(i) for i in input().split()]
heap1=[]
heap2=[]
a_max=[]
b_max=[]
s=0
for i in range(n):
    heapq.heappush(heap1, a[i])
    s+=a[i]
a_max.append(s)
for i in range(n):
    heapq.heappush(heap1,a[n+i])
    mini=heapq.heappop(heap1)
    s=s+a[n+i]-mini
    a_max.append(s)
s=0
for i in range(n):
    heapq.heappush(heap2,-a[2*n+i])
    s=s-a[2*n+i]
b_max.append(s)    
for i in range(n):
    heapq.heappush(heap2,-a[2*n-1-i])
    mini=heapq.heappop(heap2)
    s=s-a[2*n-1-i]-mini
    b_max.append(s)
ans=a_max[2]+b_max[-3]
for i in range(n):
    res=a_max[i]+b_max[-(i+1)]
    ans=max(ans, res)
print(ans)

### FIXED CODE ###

import heapq
n= int(input())
a=[int(i) for i in input().split()]
heap1=[]
heap2=[]
a_max=[]
b_max=[]
s=0
for i in range(n):
    heapq.heappush(heap1, a[i])
    s+=a[i]
a_max.append(s)
for i in range(n):
    heapq.heappush(heap1,a[n+i])
    mini=heapq.heappop(heap1)
    s=s+a[n+i]-mini
    a_max.append(s)
s=0
for i in range(n):
    heapq.heappush(heap2,-a[2*n+i])
    s=s-a[2*n+i]
b_max.append(s)    
for i in range(n):
    heapq.heappush(heap2,-a[2*n-1-i])
    mini=heapq.heappop(heap2)
    s=s-a[2*n-1-i]-mini
    b_max.append(s)
ans=a_max[0]+b_max[len(b_max)-1]
for i in range(n+1):
    res=a_max[i]+b_max[-(i+1)]
    ans=max(ans, res)
print(ans)
max1=[]
ok1=[0]

n,m=map(int,raw_input().split())

while n>0 and m>0:
    ok=0
    ie=0
    list=map(int,raw_input().split())
    if list[0]<m:
        max=list[0]
    for j in range(len(list)-1):
        for k in range(1,len(list)):
            tmp=0
            tmp=list[j]+list[k]
            if tmp>max and tmp<=m:
                max=tmp
                ok=1
    max1.insert(ie,max)
    n,m=map(int,raw_input().split())
    ie+=1
    if ok==1:
        ok1.insert(ie,1)
print(ok1)
for i in range(len(max1)-1,-1,-1):
    if ok1[i]==1:
        print(max1[i])
    else:
        print("NONE")




### FIXED CODE ###

A=[0 for i in range(2)]
A=input().split()
n=int(A[0])
m=int(A[1])
max=[]
k=0

while n>0 and m>0:
    B=[0 for i in range(n)]
    B=input().split()
    for i in range(n):
        B[i]=int(B[i])
    max1=0
    for i in range(n):
        for j in range(i+1,n):  
            x=0 
            x=B[i]+B[j]
            if max1<x and x<=m:
                max1=x
    max.append(max1)
    A=input().split()
    n=int(A[0])
    m=int(A[1])
    k+=1
for i in range(k):
    if max[i]>0:
        print(max[i])
    else:
        print("NONE")
#include <iostream>
using namespace std;

int main(void){
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  cout << ((A1 + A2 + A3 >= 22) ? "bust" : "win") << endl;
  return 0;
}

### FIXED CODE ###

A1, A2, A3 = map(int, input().split(" "))
print('bust' if A1 + A2 + A3 > 21 else 'win')
import math
n, m = input().split()
x = decimal(n)
y = dicimal(m)
ans = math.floor(x*y)
print(ans)


### FIXED CODE ###

import math
from decimal import Decimal
n, m = input().split()
x = Decimal(n)
y = Decimal(m)
#print(n,m)
ans = math.floor(x*y)
print(ans)
def solve():
    N, M = map(int, input().split())
    WAnum = 0
    ACnum = 0
    WA = [0]*max(N, M)
    AC = [False]*max(N, M)

    if N==0:
        print(0, 0)
        exit()

    for _ in range(M):
        p, S = map(str, input().split())
        p = int(p)
        if AC[p]:
            continue
        if S == 'AC':
            AC[p] = True
            ACnum += 1
            WAnum += WA[p]
        elif S == 'WA':
            WA[p] += 1
        #print(AC, WA)
    #print(AC,WA)
    print(ACnum, WAnum)

solve()

### FIXED CODE ###

def solve():
    N, M = map(int, input().split())
    WAnum = 0
    ACnum = 0
    WA = [0]*(N+1)
    AC = [False]*(N+1)

    for _ in range(M):
        p, S = map(str, input().split())
        p = int(p)
        if AC[p] == True:
            continue
        if S == 'AC':
            AC[p] = True
            ACnum += 1
            WAnum += WA[p]
        elif S == 'WA':
            WA[p] += 1
        #print(AC, WA)
    #print(AC,WA)
    print(ACnum, WAnum)

solve()