Harryxun/stf_run huggingface dataset:
N, M, X, Y = map(int, input().split())
xlist = input().split() # string
ylist = input().split() # string

def judge(z):
    for i in xlist:
        i = int(i)
        if not i < z:
            return 0
    for j in ylist:
        j = int(j)
        if j < z:
            return 0
        else:
            if str(j) == ylist[-1]:
                print('No War')
                sys.exit()

for z in range(X+1, Y+1):
    judge(z)
    if z == Y:
        print('War')

### FIXED CODE ###

import sys
N, M, X, Y = map(int, input().split())
xlist = input().split() # string
ylist = input().split() # string

#intXlist = intYlist = []
intXlist = []
intYlist = []
for i in xlist:
    intXlist.append(int(i))
#intXlist.append(X)
for i in ylist:
    intYlist.append(int(i))
#intYlist.append(Y)

# print(max(intXlist))
# print(min(intYlist))

# mx = max(intXlist)
# my = min(intYlist)

# for z in range(X+1, Y+1):
#     return my <= mx:
#         print('No War')
#         sys.exit()
#     else:
#         continue
# print('War')


def judge(z):
    try:
        for i in xlist:
            i = int(i)
            if not i < z:
                return 0
            else:
                continue
        for j in ylist:
            j = int(j)
            if j < z:
                return 0
            else:
                if str(j) == ylist[-1]:
                    #print(z)
                    print('No War')
                    sys.exit()
    except Exception as e:
        print(e)
for z in range(X+1, Y+1):
    judge(z)
    if z == Y:
        print('War')
N = list(input())

for i in N:
    if i == "7"
        print("Yes")
        break
    
else:
    print("No")

### FIXED CODE ###

N = list(input())

for i in N:
    if i == "7":
        print("Yes")
        break
    
else:
    print("No")
N, K = map(int), input().split())
S = list(input())
S[K - 1] = S[K - 1].lower()
print(''.join(S))


### FIXED CODE ###

N, K = map(int, input().split())
S = list(input())
S[K - 1] = S[K - 1].lower()
print(''.join(S))
n = int(input())

if len(str(n)) % 2 == 0:
  print(int("90" * int(len(str(n)) / 2 - 1) + "9"))
else:
  print(n - int("9" * (len(str(n)) -1)) + int("90" * (int((len(str(n)) - 1) / 2) - 1) + "9"))

### FIXED CODE ###

n = int(input())

if len(str(n)) % 2 == 0:
  print(int("90" * int(len(str(n)) / 2 - 1) + "9"))
elif len(str(n)) == 1:
  print(n)
else:
  print(n - int("9" * (len(str(n)) -1)) + int("90" * (int((len(str(n)) - 1) / 2) - 1) + "9"))
mojiretsu=input()
kakunin="abcdefghijklmnopqrstuvwxyz"
nagasa=len(mojiretsu)
bunkai=[]
for i in range(nagasa): 
    bunkai.append(mojiretsu[i:i+1])
bunkai1=list(set(bunkai))
bunkai1.sort()
ans="None"
NGFlug=False
j=1

for k in range(len(bunkai)):
    if bunkai1[k]!=kakunin[k:k+1]:
        ans=kakunin[k:k+1]
        NGFlug=True
        break

    j+=1

if NGFlug==True:
    
    print(ans)
elif j<27:
    print(kakunin[j:j+1])
else:
    print(ans)

### FIXED CODE ###

S=input()

if "a" not in S:
    print("a")
elif "b"  not in S:
    print("b")
elif "c"  not in S:
    print("c")
elif "d"  not in S:
    print("d")
elif "e"  not in S:
    print("e")
elif "f"  not in S:
    print("f")
elif "g"  not in S:
    print("g")
elif "h"  not in S:
    print("h")
elif "i"  not in S:
    print("i")
elif "j"  not in S:
    print("j")
elif "k"  not in S:
    print("k")
elif "l"  not in S:
    print("l")
elif "m"  not in S:
    print("m")
elif "n"  not in S:
    print("n")
elif "o"  not in S:
    print("o")
elif "p"  not in S:
    print("p")
elif "q"  not in S:
    print("q")
elif "r"  not in S:
    print("r")
elif "s"  not in S:
    print("s")
elif "t"  not in S:
    print("t")
elif "u"  not in S:
    print("u")
elif "v"  not in S:
    print("v")
elif "w"  not in S:
    print("w")
elif "x"  not in S:
    print("x")
elif "y"  not in S:
    print("y")
elif "z"  not in S:
    print("z")
else:
    print("None")
n,m=map(int,input().split())
arr=list(map(int,input().split())
arr.sort()
print(sum(arr[:m]))

### FIXED CODE ###

n,m=map(int,input().split())
arr=sorted(list(map(int,input().split())))
print(sum(arr[:m]))
n,a,b = split(input())
print (min(n*a,b))

### FIXED CODE ###

n,a,b = input().split()
print(min(int(n)*int(a),int(b)))
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

sub_X = []
for i in range(0, M - 1):
    sub_X.append((i, abs(X[i+1] - X[i])))
sub_X.sort(key=lambda x: x[1], reverse=True)

division = set()
if len(sub_X) != 0:
    for i in range(N-1):
        division.add(sub_X[i][0])

ans = 0
start = X[0]
for i in range(M):
    if i in division:
        ans += X[i] - start
        start = X[i+1]
    if i == M-1:
        ans += X[i] - start

print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

if N >= M:
    print(0)
else:
    sub_X = []
    for i in range(0, M - 1):
        sub_X.append((i, abs(X[i+1] - X[i])))
    sub_X.sort(key=lambda x: x[1], reverse=True)

    division = set()
    if len(sub_X) != 0:
        for i in range(N-1):
            division.add(sub_X[i][0])
    ans = 0
    start = X[0]
    for i in range(M):
        if i in division:
            ans += X[i] - start
            start = X[i+1]
        if i == M-1:
            ans += X[i] - start

    print(ans)
N, K, Q = [int(i) for i in input().split()]
ls = [K] * N

for i in range(Q):
    a = int(input())
    ls[a - 1] += 1
    print(ls)

for l in ls:
    if l - Q > 0:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

N, K, Q = [int(i) for i in input().split()]
ls = [K] * N

for i in range(Q):
    a = int(input())
    ls[a - 1] += 1

for l in ls:
    if l - Q > 0:
        print('Yes')
    else:
        print('No')
S = input()
flag = 0
for i in range(N):
	if i%2 == 0 and (S[i] not in ['R', 'U', 'D']):
		flag = 1
	if i%2 == 1 and (S[i] not in ['L', 'U', 'D']):
		flag = 1
if flag == 0:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

S = input()
flag = 0
for i in range(len(S)):
	if i%2 == 0 and (S[i] not in ['R', 'U', 'D']):
		flag = 1
	if i%2 == 1 and (S[i] not in ['L', 'U', 'D']):
		flag = 1
if flag == 0:
	print('Yes')
else:
	print('No')
x = int(input())

 print(x ** 3)

### FIXED CODE ###

x = int(input())
print(x ** 3)
import math
n=int(input())
def lcm(a, b):
  return (a * b) // math.gcd(a, b)
num = 1
for i in range(n):
  num = lcm(num, int(input()))

print(num)

### FIXED CODE ###

n=int(input())
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

def lcm(a, b):
  return (a * b) // gcd(a, b)
num = 1
for i in range(n):
  num = lcm(num, int(input()))

print(num)
import math
n = int(input())
a = list(map(int, input().split()))
mini = float(inf)
for i in a:
    mini = min(mini, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(mini))

### FIXED CODE ###

import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    n, m = map(int, input().split())
    from heapq import heappop, heappush, heapreplace
    a = list(map(int, input().split()))
    from collections import Counter as cc
    a = cc(a)
    q = []
    for key in a:
        heappush(q, (key, a[key]))
    for i in range(m):
        b, c = map(int, input().split())
        now = b
        while 1:
            num, cnt = q[0]
            if c <= num: break
            
            if now >= cnt:
                now -= cnt
                heappop(q)
            else:
                heapreplace(q, (num, cnt-now))
                now = 0
                break
        if now != b:
            heappush(q, (c, b-now))
    ans = 0
    for num, cnt in q:
        ans += num*cnt
    print(ans)



if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    n, m = map(int, input().split())
    from heapq import heappop, heappush, heapreplace
    a = list(map(int, input().split()))
    from collections import Counter as cc
    a = cc(a)
    q = []
    for key in a:
        heappush(q, (key, a[key]))
    for i in range(m):
        b, c = map(int, input().split())
        now = b
        while q:
            num, cnt = q[0]
            if c <= num: break
            
            if now >= cnt:
                now -= cnt
                heappop(q)
            else:
                heapreplace(q, (num, cnt-now))
                now = 0
                break
        if now != b:
            heappush(q, (c, b-now))
    ans = 0
    for num, cnt in q:
        ans += num*cnt
    print(ans)



if __name__ == '__main__':
    main()
def m():
    MOD = 998244353
    N = int(input())
    D = [0] + list(map(int, input().split()))
    if D[1] != 0:
        return 0
    tree = {1:1}
    for i in range(2, N + 1):
        if D[i] == 0: return 0
        tree[D[i] + 1] = tree[D[i] + 1] + 1 if tree.get(D[i] + 1, False) else 1

    height = len(tree.keys())+1
    cnt = 1
    for i in range(2, height):
        cnt = cnt * pow(tree[i-1], tree[i]) % MOD
    return cnt


print(m())


### FIXED CODE ###

def m():
    MOD = 998244353
    N = int(input())
    D = [0] + list(map(int, input().split()))
    if D[1] != 0:
        return 0
    tree = {1:1}
    for i in range(2, N + 1):
        if D[i] == 0: return 0
        tree[D[i] + 1] = tree[D[i] + 1] + 1 if tree.get(D[i] + 1, False) else 1

    height = len(tree.keys())+1
    cnt = 1
    for i in range(2, height):
        if not tree.get(i, 0):
            return 0
        cnt = cnt * pow(tree[i-1], tree[i]) % MOD
    return cnt


print(m())
def solve():
    n, k, q = map(int, input().split())
    a = []
    for i in range(q):
        a.append(0)
    for i in range(q):
        aa = int(input()) - 1
        a[aa] = a[aa]+1
    for i in range(n):
        if k - (q-a[i]) > 0:
            print('Yes')
        else:
            print('No')

if __name__ == "__main__":
    solve()
    

### FIXED CODE ###

def solve():
    n, k, q = map(int, input().split())
    a = []
    for i in range(n):
        a.append(0)
    for i in range(q):
        aa = int(input()) - 1
        a[aa] = a[aa]+1
    for i in range(n):
        if k - (q-a[i]) > 0:
            print('Yes')
        else:
            print('No')

if __name__ == "__main__":
    solve()
# コンテスト中の考えは悪くなかったがN本に固執して貪欲的に考えていた。
# 敗因は動的計画法が思い浮かばず書けなかったこと。
# 提出4298627を参考にした


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

A.sort(reverse=True)  # 大きい方から探索したいため

# 各数字を作るのに必要なマッチの本数
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

# dpをするための配列を用意
# pd[i]としたときに、i本のマッチで実現できる最大桁数を格納するものとする
# shapeは(N+1,) ∵ i=0~N本のときも考える
dp = [-1 * float("inf")] * (N + 1)

# 各数字を一つずつ使う場合は1桁だとわかりきっているので、初期化ができる
dp[0] = 0
for a in A:
    if num[a] <= N:  # ここは念のための処理、指定されたNがマッチで使う数字より少ないかもしれない。
        dp[num[a]] = 1

# dpのmain
for i in range(1, N + 1):  # dpに格納されているすべての要素をなめていく。
    for a in A:  # i本使うときの最大桁数を決定するためにはaを全探索して下式を最大となるものが取得できればよい
        if i - num[a] >= 0:  # 念の為の条件
            # この式については解説を参照のこと
            dp[i] = max(dp[i], dp[i - num[a]] + 1)

# 探索が終わったので答えを出す。
# 大きい桁にはなるべく大きな数字を割り振る
ans = ""
for i in range(dp[N]):  # dpによって得た桁数について上位桁から決定していく
    for a in A:  # すでに大きい順にソートしたので決定次第break
        # 1つ目の条件は探索中に配列外アクセスをするのを防ぐため。2つ目の条件についても解説を参照のこと
        if N - num[a]　> -1 and dp[N - num[a]] == dp[N] - 1:
            ans += str(a)
            N -= num[a]  # マッチの本数から引くのを忘れずにね
            break

print(ans)


### FIXED CODE ###

# コンテスト中の考えは悪くなかったがN本に固執して貪欲的に考えていた。
# 敗因は動的計画法が思い浮かばず書けなかったこと。
# 提出4298627を参考にした


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

A.sort(reverse=True)  # 大きい方から探索したいため

# 各数字を作るのに必要なマッチの本数
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

# dpをするための配列を用意
# pd[i]としたときに、i本のマッチで実現できる最大桁数を格納するものとする
# shapeは(N+1,) ∵ i=0~N本のときも考える
dp = [-1 * float("inf")] * (N + 1)

# 各数字を一つずつ使う場合は1桁だとわかりきっているので、初期化ができる
dp[0] = 0
for a in A:
    if num[a] <= N:  # ここは念のための処理、指定されたNがマッチで使う数字より少ないかもしれない。
        dp[num[a]] = 1

# dpのmain
for i in range(1, N + 1):  # dpに格納されているすべての要素をなめていく。
    for a in A:  # i本使うときの最大桁数を決定するためにはaを全探索して下式を最大となるものが取得できればよい
        if i - num[a] >= 0:  # 念の為の条件
            # この式については解説を参照のこと
            dp[i] = max(dp[i], dp[i - num[a]] + 1)

# 探索が終わったので答えを出す。
# 大きい桁にはなるべく大きな数字を割り振る
ans = ""
for i in range(dp[N]):  # dpによって得た桁数について上位桁から決定していく
    for a in A:  # すでに大きい順にソートしたので決定次第break
        # 1つ目の条件は探索中に配列外アクセスをするのを防ぐため。2つ目の条件についても解説を参照のこと
        if N - num[a] > -1 and dp[N - num[a]] == dp[N] - 1:
            ans += str(a)
            N -= num[a]  # マッチの本数から引くのを忘れずにね
            break

print(ans)
n=int(input())
A=[int(x) for x in input().split()]
B=sorted(A)
Alice=[]
Bob=[]
while len(B)!=0 or len(B)!=1:
  Alice.append(B[-1])
  B.pop()
  Bob.append(B[1-])
  B.pop()
if len(B)==1:
  Alice.append(B[0])
  B.pop()
print(sum(Alice)-sum(Bob))

### FIXED CODE ###

n=int(input())
A=[int(x) for x in input().split()]
B=sorted(A)
Alice=[]
Bob=[]
while len(B)!=0 and len(B)!=1:
  Alice.append(B[-1])
  B.pop()
  Bob.append(B[-1])
  B.pop()
if len(B)==1:
  Alice.append(B[0])
  B.pop()
print(sum(Alice)-sum(Bob))
p = [x, y, z]
x, y, z = map(int, input().split())

p.sort()
print(p)


### FIXED CODE ###

a = list(map(int, input().split()))

a.sort()
print(a[0], a[1], a[2])
##### 解けた #####

a,b,c=list(map(int,input().split(" ")))

if sum(a,b)==c or sum(a,c)==b or sum(b,c)==a:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

##### 解けた #####

a,b,c=list(map(int,input().split(" ")))

if (a+b)==c or (a+c)==b or (b+c)==a:
    print("Yes")
else:
    print("No")
a = []
x = 1
while True:
    n = input()
    if n == 0:
        break
    a.append(n)
    x += 1
print ("Case",x,":",a) 


### FIXED CODE ###

c = 0
while True:
    x = int(input()); c += 1
    if x == 0: break
    print("Case {}: {}".format(c, x))
S = input()
K = int(input())

if len(S) <= K:
    print(S)
else
    S = S[0:K]　+ '...'
    print(S)

### FIXED CODE ###

N = int(input())
N = N % 10
if N in [2, 4, 5, 7, 9]:
    print('hon')

elif N in [0, 1, 6, 8]:
    print('pon')

else:
    print('bon')
a,b,c,d=map(int,input().split())
print(max(a*b,c*d))

### FIXED CODE ###

H,A=map(int,input().split())
count=0
while H>0:
  H-=A
  count+=1
print(count)
N,K = map(int,input().split())

delta = abs(N-K)

while N>=delta:
  N//=delta
  delta = abs(N-K)
  if delta==0:
    N=0
    break
  
print(N)

### FIXED CODE ###

N,K=map(int,input().split())
N=N%K
print(min(N,abs(N-K)))
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

count_m = 0
count_z = 0
count_p = 0
sum_abs = 0

for i in range(N):
    if A[i] < 0:
        count_m += 1
        sum_abs -= A[i]
    elif A[i] == 0:
        count_z += 1
    else:
        count_p += 1
        sum_abs += A[i]

if count_m + count_z == 0:
    print(sum_abs-2*min(A))
    tmp = A[0]
    for i in range(N-2):
        print(tmp, A[i+1])
        tmp -= A[i+1]
    print(A[-1], tmp)

elif count_p + count_z == 0:
    print(sum_abs+2*max(A))
    tmp = A[-1]
    for i in range(N-1):
        print(tmp, A[i])
        tmp -= A[i]

elif count_p + count_m == 0:
    print(0)
    for i in range(N-1):
        print(0, 0)

elif count_z > 20:
    print(A[2*N])
    print(sum_abs)
    cmz = count_m + count_z
    tmp = A[-1]
    for i in range(cmz - 1):
        print(tmp, A[i])
        tmp -= A[i]
    tmp_2 = A[cmz-1]
    for i in range(count_p-1):
        print(tmp_2, A[i+cmz])
        tmp_2 -= A[i+cmz]
    print(tmp, tmp_2)

else:
    print(sum_abs)
    cmz = count_m + count_z
    tmp = A[-1]
    for i in range(cmz - 1):
        print(tmp, A[i])
        tmp -= A[i]
    tmp_2 = A[cmz-1]
    for i in range(count_p-1):
        print(tmp_2, A[i+cmz])
        tmp_2 -= A[i+cmz]
    print(tmp, tmp_2)

### FIXED CODE ###

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

A = sorted(A)

count_m = 0
count_z = 0
count_p = 0
sum_abs = 0

for i in range(N):
    if A[i] < 0:
        count_m += 1
        sum_abs -= A[i]
    elif A[i] == 0:
        count_z += 1
    else:
        count_p += 1
        sum_abs += A[i]

if count_m + count_z == 0:
    print(sum_abs-2*min(A))
    tmp = A[0]
    for i in range(N-2):
        print(tmp, A[i+1])
        tmp -= A[i+1]
    print(A[-1], tmp)

elif count_p + count_z == 0:
    print(sum_abs+2*max(A))
    tmp = A[-1]
    for i in range(N-1):
        print(tmp, A[i])
        tmp -= A[i]

elif count_p + count_m == 0:
    print(0)
    for i in range(N-1):
        print(0, 0)

else:
    print(sum_abs)
    cmz = count_m + count_z
    tmp = A[-1]
    for i in range(cmz - 1):
        print(tmp, A[i])
        tmp -= A[i]
    tmp_2 = A[cmz-1]
    if count_p != 0:
        for i in range(count_p-1):
            print(tmp_2, A[i+cmz])
            tmp_2 -= A[i+cmz]
        print(tmp, tmp_2)
H,W = map( int, input().split() )

x = []

for _ in range(H):
    row = list( input() )
    x.append(row)

blacks = []
count = 0

for i in range(H):
    for j in range(W):
        a = x[i][j]
        if a == '#':
            count += 1
            blacks.append((i,j))

result = 0

DIRS = [(0,1),(0,-1),(1,0),(-1,0)]

while count < H*W:
    result += 1
    new_blacks = []
    for black in blacks:
        for dir in DIRS:
            i = black[0]+dir[0]
            j = black[1]+dir[1]
            if i < 0 or i >= H:
                continue
            if j < 0 or j >= H:
                continue
            if x[i][j] == '.':
                new_blacks.append((i,j))
                x[i][j] = '#'
                count += 1
    blacks = new_blacks

print(result)

### FIXED CODE ###

H,W = map( int, input().split() )

x = []

for _ in range(H):
    row = list( input() )
    x.append(row)

blacks = []
count = 0

for i in range(H):
    for j in range(W):
        a = x[i][j]
        if a == '#':
            count += 1
            blacks.append((i,j))

result = 0
DIRS = [(0,1),(0,-1),(1,0),(-1,0)]

while count < H*W:
    result += 1
    new_blacks = []
    for black in blacks:
        for dir in DIRS:
            i = black[0]+dir[0]
            j = black[1]+dir[1]
            if i < 0 or i >= H:
                continue
            if j < 0 or j >= W:
                continue
            if x[i][j] == '.':
                new_blacks.append((i,j))
                x[i][j] = '#'
                count += 1
    blacks = new_blacks

print(result)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

import numpy as np
import bisect

ra=list(np.cumsum(a))
rb=list(np.cumsum(b))

ans=0
j=m-1
for i in range(n):    
    capa = k - ra[i]
    if ra[i]>k:
        ans=max(ans,i)
        break
    while ra[i]+rb[j]>k:
        j-=1

    ans=max(ans,i+1+j+1)
            
print(ans)    

### FIXED CODE ###

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

import numpy as np
import bisect

ra=[0]+list(np.cumsum(a))
rb=[0]+list(np.cumsum(b))

ans=0
for i in range(n+1):    
    capa = k - ra[i]
    if capa<0:
        break
    j=bisect.bisect_right(rb,capa)


    ans=max(ans,i-1+j)
            
print(ans)
x,k,d=map(int,input().split())
c=0
for i in range(k):
  while x>0 and i<k:
    x-=d
    i+=1
  while x<0i and i<k:
    x+=d
    i+=1
print(abs(x))

### FIXED CODE ###

x,k,d=map(int,input().split())

x=abs(x)
ans=0
if x>=d*k:
  ans=x-k*d
else:
  e= int(x/d)
  k-=e
  x-=e*d
  if k%2==1:
    x=abs(x-d)
  ans=x

print(ans)
A,B = map(int,input())
if A * 500 >= B:
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

A,B = map(int,input().split())
if A * 500 >= B:
  print("Yes")
else:
  print("No")
#!/usr/bin/env python3

N, W = list(map(int, input().split()))
item_list = []

for _ in range(N):
    w, v = list(map(int, input().split()))
    item_list.append((w, v))

dp_table = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    w, v = item_list[i - 1]
    for j in range(W + 1):
        # 品物iを入れない場合
        before_best_value = dp_table[i - 1][j]
        dp_table[i][j] = before_best_value
        # 品物iを入れる場合
        if j - w < 0:
            continue
        value = dp_table[i - 1][j - w] + v
        best_value = max(before_best_value, value)
        dp_table[i][j] = best_value

ans = max(dp_table[-1])
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3

N, W = list(map(int, input().split()))
item_list = []

for _ in range(N):
    w, v = list(map(int, input().split()))
    item_list.append((w, v))

max_v = (10 ** 3) * 100
dp_table = [[0] + [float("inf")] * (max_v + 1) for _ in range(N + 1)]
total_v = 0

for i in range(1, N + 1):  # 最大で10**2
    w, v = item_list[i - 1]
    # 品物iまで考慮したときの価値の最大値
    total_v += v
    for j in range(total_v + 1):  # 最大で10 ** 5
        # 品物iを入れない場合
        dp_table[i][j] = dp_table[i - 1][j]
        before_min_weight = dp_table[i - 1][j]
        # dp_table[i][j] = before_min_weight
        # 品物iを入れる場合
        if j - v < 0:
            continue
        weight = dp_table[i - 1][j - v] + w
        min_weight = min(before_min_weight, weight)
        dp_table[i][j] = min_weight
        if i == N:
            if min_weight <= W:
                max_value = j

ans = max_value
print(ans)
n=int(input())
s=[list(input()) for in range(n)]
for i in s:
  i.sort()

### FIXED CODE ###

n=int(input())
s=[input() for i in range(n)]
l=list("abcdefghijklmnopqrstuvwxyz")
c_tmp=[]
for j in l:
  for i in s:
    c_tmp.append(i.count(j))
  print(j*min(c_tmp),end="")
  c_tmp.clear()
input()
xs = map(int, input().split())
print(' '.join(map(str,[f(xs) for f in [min,max,sum]])))

### FIXED CODE ###

n = input()
nums = list(map(int, input().split()))
print(min(nums), max(nums), sum(nums))
A,B,C,D=map(int,input().split())
if (A+B)<(C+D):
   print("Right")
elif (A+B)==(C+D)
   print("Balanced")
else:
   print("Left")

### FIXED CODE ###

A,B,C,D=map(int,input().split())
if (A+B)<(C+D):
   print("Right")
elif (A+B)==(C+D):
   print("Balanced")
else:
   print("Left")
l=[int(x) for x in input().split()]
N=l[0]
R=l[1]
ans = 0

if N  >= 10:
  ans = R
  print(ans)
else:
  ans = R + 100*(10-k)
  print(ans)


### FIXED CODE ###

l=[int(x) for x in input().split()]
N=l[0]
R=l[1]

if N >= 10:
  ans = R
  print(ans)
else:
  ans = R + 100*(10-N)
  print(ans)
a,b=[int(x) for x in input().split()]
if abs(a-b)<=1:
  	print("Brown):
else:
    print("Alice")

### FIXED CODE ###

a,b=[int(x) for x in input().split()]
if abs(a-b)<=1:
  	print("Brown")
else:
  	print("Alice")
if b == 2:
    print('3')
  else
    print('2')


### FIXED CODE ###

a = int(input())
b = int(input())

if a == 1:
  if b == 2:
    print('3')
  else:
    print('2')
elif a == 2:
  if b == 1:
    print('3')
  else:
    print('1')
else:
  if b == 1:
    print('2')
  else:
    print('1')
n = int(input())
for i in range(n):
    arr = map(int, input().split())
    b,c = 0,0
    flag = True
    for i in range(len(arr)):
        if b < arr[i]:
            b = arr[i]
            continue
        if c < arr[i]:
            c = arr[i]
            continue
        print("NO")
        flag = False
        break
    if flag:
        print("YES")

### FIXED CODE ###

def ball(nums):
    b, c = 0, 0
    for i in range(len(nums)):
        if b < nums[i]:
            b = nums[i]
            continue
        if c < nums[i]:
            c = nums[i]
            continue
        return "NO"
    return "YES"

N = int(input())

for _ in range(N):
    a = list(map(int, input().split()))
    print(ball(a))
day = input()
if day == "SUN":
  return 7
elif day == "MON":
  return 1
elif day == "TUE":
  return 2
elif day == "WED":
  return 3
elif day == "THU":
  return 4
elif day == "FRI":
  return 5
elif day == "SAT":
  return 6
else:
  return -1


### FIXED CODE ###

day = input()
if day == "SUN":
  print(7)
elif day == "MON":
  print(6)
elif day == "TUE":
  print(5)
elif day == "WED":
  print(4)
elif day == "THU":
  print(3)
elif day == "FRI":
  print(2)
elif day == "SAT":
  print(1)
else:
  print(-1)