peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
a,b,x = map(int,input().split())
print('YES' if x >= a and (a+b) >= x else 'NO')
# Judge status: Accepted
N = int(input())
T, A = map(int, input().split())
High = list(map(int, input().split()))
Sa = []
for a, i in enumerate(High):
    Sa.append(abs(A-(T-High[a] * 0.006)))

print(Sa.index(min(Sa)) + 1)
# Judge status: Accepted
print("win" if sum(list(map(int,input().split())))<=21 else "bust")
# Judge status: Accepted
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]
l = [k-q] * n
for i in a:
  l[i-1] += 1
for f in l:
  if f <= 0:
    print("No")
  else:
    print("Yes")
# Judge status: Wrong Answer
a,b,c,k=map(int,input().split())
print(c-b)
# Judge status: Accepted
import numpy as np

n, l = map(int, input().split())

if l < 0:
    if l + n <= 0:
        # 絶対値最小が0以下の場合は最右を削る
        taste = sum(range(l, l+n-1))
    else:
        # 0を挟む場合はそのまま全部足す
        taste = sum(range(l, l+n))
else:
        # 絶対値最小が0以上の場合は最左を削る
        taste = sum(range(l+1, l+n))

print(taste)
# Judge status: Wrong Answer
import sys
x = int(input())
for i in range(x+1,100005):
    c = 0
    for j in range(1,i+1):
        if i%j != 0:
            c += 1
    if c == i-2:
        print(i)
        sys.exit()
# Judge status: Accepted
s = input()
k = int(input())

for i in range(len(s)):
    if s[i] == "1":
        if i+1 == k:
            print(1)
            break
    else:
        print(s[i])
        break
# Judge status: Wrong Answer
strN = input()
N = int(strN)
p = {i: {j: 0 for j in range(1, 10)} for i in range(1, 10)}
for i in range(1, 10):
    for j in range(1, 10):
        for k in range(1, N):
            strk = str(k)
            if str(i) == strk[0] and str(j) == strk[-1]:
                p[i][j] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += p[i][j] * p[j][i]

print(ans)
# Judge status: Accepted
N=int(input())
S=input()
if N % 2 ==1:
  print('No')
elif  S[0:N // 2] == S[N//2: N]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
for i in range(10**6+1):
    if i ** 2 >= n:
        break

for j in range(i, 0, -1):
    if n % j == 0:
        break

print(j + n // j - 2)
# Judge status: Wrong Answer
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    S = list(sys.stdin.readline())

    ret = []
    for s in S:
        n = ord(s) + N
        ret.append(chr(((n - 65)%26)+65))

    print("".join(ret))

if __name__ == '__main__':
    main()
# Judge status: Accepted
#W, H, x, y
W, H, x, y = map(int, input().split())

S = W*H/2
if x==W/2 and y == H/2:
    print(S, 1)
else:
    print(S, 0)
# Judge status: Accepted
n=int(input())
if n%2==1:
  print(0)
  exit()
ans=0
for i in range(1,26):
  a=2*5**i
  ans+=n//a
print(ans)
# Judge status: Accepted
numbers = map(int, input().split())
print("Yes") if len(set(numbers)) == 2 else print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
MOD = 1000000007
sum = 0
for i in range(N):
    sum = sum + A[i]

res = 0
for i in range(N):
    sum = sum - A[i]
    res = res + (A[i] % MOD * sum % MOD)

print(res % MOD)
# Judge status: Accepted
N, M = map(int, input().split())

print((N*(N-1))//2 + (M*(M-1))//2)
# Judge status: Accepted
L, R = map(int, input().split())

ans = 3000
if R-L > 2019:
    ans = 0
else:
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(i*j%2019, ans)
print(ans)
# Judge status: Accepted
n = int(input())
alst = [int(input()) for _ in range(n)]
cnt = 0
bef = 0
for num in alst:
    cnt += (num + bef) // 2
    if (num + bef) % 2 == 1 and num > 0:
        bef = 1
    else:
        bef = 0
print(cnt)
# Judge status: Wrong Answer
s = str(input().split())
print(s)
i = 0
while True:
    i += 1
    if i == 4:
        break
    if s[i] == s[i +1]:
        print_ans = 'Bad'
        break
    else:
        print_ans = 'Good'

print(print_ans)
# Judge status: Accepted
s,w = map(int,input().split())
print("unsafe" if s<=w else "safe")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))#o(10^5)
temp = 0
for a in A:
    temp = temp ^ a
for a in A:
    print(temp ^ a, end=' ')
# Judge status: Accepted
from math import sqrt, cos, radians

def solve(A, B, H, M):
    Hr = (H * 60 + M) * 0.5
    Mr = M * 6
    r = abs(Hr - Mr)
    if r > 180:
        r = 360 - r

    if r == 90:
        print(sqrt(A ** 2 + B ** 2))
    else:
        print(sqrt(A ** 2 + B ** 2 - (2 * A * B * cos(radians(r)))))

A, B, H, M = map(int, open(0).read().split())
solve(A, B, H, M)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if a == b and a == c:
    print("NO")
elif a != b and a != c and b != c:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
N,X = map(int,input().split())
L = list(map(int,input().split()))

tmp = 0
cnt = 1

for i in range(N):
    tmp += L[i]

    if(tmp <= X):
        cnt += 1
print(cnt)
# Judge status: Accepted
s1 = input()
s2 = input()
print('YES' if s1 == s2[::-1] else 'NO')
# Judge status: Accepted
x,y=map(int, input().split())
i=0
while x*(2**i)<=y:
  i+=1
print(i)
# Judge status: Wrong Answer
X = int(input())
X = abs(X)
for i in range(10**5):
  if X < i*(i+1)//2:
    ans = X - i*(i-1)//2 + i-1
    break
print(ans)
# Judge status: Accepted
import math
n,m = map(int,input().split())
if (n+1)/0.08 > m/0.1 and (m+1)/0.1 > n/0.08:
    print(max(math.ceil(n/0.08),math.ceil(m/0.1)))
else:
    print(-1)
# Judge status: Wrong Answer
n,a,b,c,d = map(int,input().split())
s = input()

if('##' in s[a-1:d]):
    print('No')
    exit()
if(c < d):
    print('Yes')
else:
    if('...' in s[b-2:d]):
        print('Yes')
    else:
        print('No?')
# Judge status: Accepted
import math


n = int(input())
o = n / 1.080

o_floor = math.floor(o)
o_ceil = math.ceil(o)

if math.floor(o_floor * 1.08) == n:
    print(o_floor)

elif math.floor(o_ceil * 1.08) == n:
    print(o_ceil)

else:
    print(':(')
# Judge status: Accepted
from collections import Counter
S = input()
C = Counter(S).values()
if len(C) == 2:
    print(min(2*c for c in C))
else:
    print(0)
# Judge status: Wrong Answer
a = int(input())
b = int(input())
h = int(input())
print((a*b*h) * 0.5)
# Judge status: Accepted
import numpy as np


n = int(input())
p = [i for i in list(map(int, input().split()))]
p = np.array(p)
p_org = p.copy()
p.sort()
if (p != p_org).sum() <= 2:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
import numpy as np
def combinations(n,k,mod=10**9+7):
    x,y = 1,1
    for i in range(k):
        x = (x*(n-i))%mod
        y = (y*(i+1))%mod
    y = pow(y,mod-2,mod)
    return (x*y)%mod

N,P = map(int,input().split())
a = np.array(list(map(int,input().split())))%2
a1 = np.count_nonzero(a==1)
a0 = np.count_nonzero(a==0)

ans = 0
for i in range(P,a1+1,2):
    ans += combinations(a1,i)

print(ans*(2**a0))
# Judge status: Wrong Answer
import sys

N, K, S = map(int, input().split())
if N == K:
    ans = ''
    for i in range(N): ans += str(S) + ' '
    print(ans.rstrip())
    sys.exit()

ans = ''
s1, s2 = 0, 0
ex = (S + 1) % (10**9 + 1)
if S % 2 == 0:
    s1 = s2 = S // 2
else:
    s1 = S // 2
    s2 = s1 + 1
for i in range(N):
    if i % 2 == 0 and i <= K:
        ans += str(s1) + ' '
    elif i <= K:
        ans += str(s2) + ' '
    else:
        ans += str(ex) + ' '
print(ans.strip())
# Judge status: Accepted
n = int(input())
nums = list(map(int, input().split()))

def cost(x,y):
    return (x-y)**2

avg = round(sum(nums)/len(nums))

res = 0
for n in nums:
    res += cost(n, avg)
print(res)
# Judge status: Accepted
import sys
readline = sys.stdin.readline

W,H,N = map(int,readline().split())
minX = 0
minY = 0
maxX = W
maxY = H

for i in range(N):
  x,y,a = map(int,readline().split())
  if a == 1:
    minX = max(minX,x)
  elif a == 2:
    maxX = min(maxX,x)
  elif a == 3:
    minY = max(minY,y)
  elif a == 4:
    maxY = min(maxY,y)

print(max(0,maxX - minX) * max(0,maxY - minY))
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a>0:
    print("Positive")
elif a<=b<0:
    if (b-a+1)%2==0:
        print("Positive")
    else:
        print("Negative")
else:
    print(0)
# Judge status: Accepted
s = list(input())

count = 0

for i in range(0,len(s)):
  sign = (i+1)%2
  if sign == 1 and s[i] == "L":
    count = 1
  elif sign == 0 and s[i] == "R":
    count = 1
    
if count == 1:
  ans = "No"
elif count == 0:
  ans = "Yes"

print(ans)
# Judge status: Accepted
s_li = [[] for i in range(3)]
for i in range(3):
    for s in input():
        if s=='a':s_li[i].append(0)
        if s=='b':s_li[i].append(1)
        if s=='c':s_li[i].append(2)

x = s_li[0].pop(0)
while len(s_li[x])!=0:
    x = s_li[x].pop(0)
ans_dic={0:'A',1:'B',2:'C'}
print(ans_dic[x])
# Judge status: Wrong Answer
import math

n, h = list(map(int, input().split()))
ab = [[] for _ in range(n)]
for i in range(n):
    ab[i] = list(map(int, input().split()))

az, bz = list(zip(*ab))
maxa = max(az)
minb = min(bz)
cnt = 0
for i in bz:
    if i > maxa:
        h -= i
        cnt += 1
if h >= 0:
    cnt += math.ceil(h / maxa)
print(cnt)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
i = 0
ans = 0
while i < N:
    j = i
    while j < N-1 and A[j]<=A[j+1]:
        j += 1
    k = i
    while k < N-1 and A[k]>=A[k+1]:
        k += 1
    ans += 1
    i = max(j, k) + 1
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
dev = []
count = 1
A = sorted(A, reverse = True)
for i in range(N-1):
  flag = 0
  for j in range(i+1, N):
    if A[i] % A[j] == 0:
      flag = 1
      break
  
  if flag == 0:
    count +=1
l = len(A)
if A[l-1] == A[l-2]:
  count -=1
print(count)
# Judge status: Accepted
def is_valid(n, conditions):
    ns = [int(i) for i in str(n)]
    return all(ns[s - 1] == c for s, c in conditions)


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

sc = []
for _ in range(M):
    s, c = map(int, input().split())
    sc.append((s, c))

candidates = (i for i in range(1000) if len(str(i)) == N and is_valid(i, sc))

try:
    print(next(candidates))
except StopIteration:
    print(-1)
# Judge status: Wrong Answer
s = input()
s1 = int(s[0])
s2 = int(s[1])
s3 = int(s[2])
ans = 0
if s1 == 1:
    ans += 1
elif s2 ==1:
    ans += 1
elif s3 == 1:
    ans += 1
print(ans)
# Judge status: Accepted
N = int(input())
a = [int(i) for i in input().split()]
sum_a = sum(a)
b = []
c = 0
for i in range(N-1):
    c += a[i]
    b.append(abs(2*c-sum_a))
print(min(b))
# Judge status: Accepted
N, x = [int(x) for x in input().split()]
a = list([int(x) for x in input().split()])

count = 0
for i in range(N):
    if a[i] > x:
        count += a[i] - x
        a[i] -= a[i] - x

    if i - 1 >= 0:
        if a[i] + a[i-1] > x:
            count += (a[i] + a[i-1]) - x
            a[i] -= (a[i] + a[i-1]) - x

print(count)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

import numpy as np
S=int(input())

MOD=10**9+7
N=S//3

D=np.zeros([S+1,N+1])
for i in range(3,S+1):
    D[i,1]=1

for j in range(2,N+1):
    for i in range(3*j,S+1):
        for k in range(3,i-3*(j-1)+1):
            #print(k)
            D[i,j]+=D[S-k,j-1]
        D[i,j]%=MOD

ans=0
for j in range(1,N+1):
    ans+=D[S,j]
    ans%=MOD

#print(D)
print(int(ans))
# Judge status: Wrong Answer
n,m = map(int,input().split())
h = list(map(int,input().split()))
tenbo = [list(map(int,input().split())) for _ in range(m)]
#print(tenbo)
tree = [[0]for _ in range(n)]
for i in range(m):

	x = tenbo[i]
	x1 = x[0]
	x2 = x[1]
	#print(x1)
	y1 = h[x1-1]
	y2 = h[x2-1]
	a = [y1,y2]
	#print(x[1])
	tree[x[0]-1].extend(a)
	tree[x[1]-1].extend(a)
c = 0
for i in range(n):
	if max(tree[i]) <=h[i]:
		if len(tree[i]) > 1:
		#print(max(tree[i]))
			c += 1
print(c)
# Judge status: Wrong Answer
import math
n = int(input())

res = 0
if n <= 1:
	print(res)
else:
	max_cnt = int(math.sqrt(n))
	org_n = n
	for z in range(2, max_cnt + 1):
		if n == 1 or z > math.sqrt(n):
			res += 1
			break
		if n % z == 0:
			# print(z, n, n//z)
			res += 1
			n = n // z
			if n == z:
				break
	if n == org_n:
		res += 1
	print(res)
# Judge status: Accepted
n=int(input())
ls=list(map(int,input().split()))

cnt=0
for i in range(n-2):
  a=ls[i]
  for j in range(i+1,n-1):
    b=ls[j]
    if a==b:
      continue
    for k in range(j+1,n):
      c=ls[k]
      if a==c or b==c:
        continue
      if a+b <= c or a+c <= b or b+c <= a:
        continue
      else:
        cnt+=1
print(cnt)
# Judge status: Accepted
s = input()
if s[0]=='A' and 'C' in s[2:-1]:
    s = s.replace('A','',1).replace('C','',1)
    if s == s.lower():
        exit(print('AC'))
print('WA')
# Judge status: Accepted
def resolve():
	n,m = map(int,input().split())
	sc = [tuple(map(int,input().split())) for _ in range(m)]
	for i in range((10**(n-1) if n!=1 else 0),10**n):
		c = 1
		for j in sc:
			if str(i)[j[0]-1] != str(j[1]):
				c = 0
				break
		if c: break
	print(i if c else -1)
    
resolve()
# Judge status: Accepted
def main():
    n = int(input())
    A = [int(e) for e in input().split()]

    ma = max(A)
    N = [0] * (10 ** 6 + 1)
    for a in A:
        for i in range(a, ma + 1, a):
            N[i] += 1

    ans = 0
    for a in A:
        if N[a] == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())

total = 0
x = 0
for i in range(1, N+1):
    total += i
    x = i
    if total >= N:
        break

diff = total-N
for i in range(1, x+1):
    if i!=diff:
        print(i)
# Judge status: Accepted
N, A, B, C, D = map(int, input().split())
S = input()
canCross = False
for i, s in enumerate(S, start=1):
  if A < i < max(C, D) and s == '#' and (S[i-2] == '#' or S[i] == '#'):
    print('No')
    exit()
  if B <= i <= min(C, D) and s == '.' and S[i-2] == '.' and S[i] == '.':
    canCross = True
if C < D:
  print('Yes')
else:
  if canCross:
    print('Yes')
  else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
ans = 1

if ans > 10**18:
    ans = -1
elif min(A) == 0:
    ans = 0
else:
    for i in A:
        ans *= i

print(ans)
# Judge status: Wrong Answer
a,b=map(int, input().split())
x=max(a,b)
print(x+x-1)
# Judge status: Accepted
p,q,r=map(int,input().split())
print(min(p+q,q+r,r+p))
# Judge status: Accepted
a=sorted(list(map(int,input().split())))
if a[1]-a[0]==a[2]-a[1]:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
def resolve():
  N, A, B= map(int, input().split(" "))
  S = list(input())

  sum_of_successful_candidate = 0
  sum_of_successful_b = 0

  for i, s in enumerate(S):
    if sum_of_successful_candidate >= A + B:
      for _ in range(N-i):
        print("No")
      return True

    if s == "a":
      sum_of_successful_candidate += 1
      print("Yes")
    elif s == "b" and sum_of_successful_b < B:
      sum_of_successful_candidate += 1
      sum_of_successful_b += 1
      print("Yes")
    else:
      print("No")

  return True


if __name__ == "__main__":
  resolve()
# Judge status: Accepted
c = input()
vowel=['a','e','i','o','u']
if c in vowel:
  print('vowel')
else:
  print('consonant')
# Judge status: Wrong Answer
a=list(map(int,input().split()))
a.sort()
cnt=0
if a[0]==a[1]==a[2]:
  print(0)
  exit()
if a[0]==[1]:
  print(a[2]-a[1])
  exit()
if a[1]==a[2]:
  if (a[2]-a[0])%2==0:
    print((a[2]-a[0])//2)
    exit()
  else:
    print(a[2]-a[0]+1)
    exit()
cnt+=a[2]-a[1]
a[0]+=cnt
if (a[2]-a[0])%2==0:
  cnt+=(a[2]-a[0])//2
else:
  cnt+=(a[2]-a[0])//2+1
print(cnt)
# Judge status: Accepted
n,k=map(int,input().split())
a=[-1]+list(map(int,input().split()))

count=[0]*(n+1)
cnt=0
i=1
while count[i]==0:
    count[i]=cnt
    if cnt==k:
        print(i)
        exit()
    cnt+=1
    i=a[i]

if cnt==k:
    print(i)
    exit()



loop=cnt-count[i]
#print("loop",loop)
goal=(k-cnt)%loop
#print(loop,goal)
if goal==0:
    print(i)
else:    
    print(count.index(count[i]+goal))
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
N = int(input())
a = [int(i) for i in input().split()]
sum = 0
for i in range(N):
    sum+=a[i]
d = sum//N
m = sum%N
if m != 0:
    d+=1
ans = 0
for i in range(N):
    de = a[i] - d
    ans += de**2
print(ans)
# Judge status: Accepted
X, Y, Z = map(int, input().split())
isu = X - Z
hito = Y + Z
print(isu // hito)
# Judge status: Wrong Answer
# C
import math
def my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) // 2 / p

n, k = map(int, input().split())
s = my_round(n / k)
print(abs(n - int(s * k)))
# Judge status: Accepted
x, y = map(int, input().split())
print(x + y // 2)
# Judge status: Accepted
n = int(input())
a = int(input())
 
z = int(n%500)
 
if a >= z:
  print('Yes')
  
else:
  print('No')
# Judge status: Wrong Answer
# A - ι⊥l

# b-a = c-bを満たしていればYes, そうでなければNoを出力する


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

if b-a == c-b:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split())) + [-1]
m, s = 1000, 0
for i in range(n):
    if a[i] < a[i+1]:
        s = m//a[i]
        m -= a[i]*s
    elif a[i] > a[i+1]:
        m += a[i]*s
        s = 0
print(m)
# Judge status: Wrong Answer
N = int(input())
A = []
a = int(input())
M1 = a
M2 = a
A.append(a)
for i in range(N-1):
    a = int(input())
    A.append(a)
    M1 = max(M1,a)
    if M2 < a < M1:
        M2 = a

if A.count(M1) >= 2:
    for i in range(N):
        print(M1)
else:
    for i in range(N):
        if A[i] == M1:
            print(M2)
        else:
            print(M1)
# Judge status: Accepted
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    a=list(map(int,input().split()))
    for i in range(n//2+1):
        if not(x-i in a):
            print(x-i)
            exit()
        if not(x+i in a):
            print(x+i)
            exit()
    print(x-1-n//2)
# Judge status: Accepted
import sys

n = int(input())
x = list(map(int, input().split()))
min_hp = sys.maxsize

for i in range(1, 100):
    hp = 0    
    for j in range(n):
        hp += (x[j] - i) * (x[j] - i)

    
    min_hp = min(hp, min_hp)
    
print(min_hp)
# Judge status: Accepted
X,Y,Z=map(int,input().split())
A=X
B=Y
C=Z
A,B=B,A
A,C=C,A
print(A,B,C)
# Judge status: Wrong Answer
a = int(input())
s = input()
if a >= 3200:
	print('red')
else:
	print(s)
# Judge status: Accepted
n, m = map(int, input().split())

if n==m:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
k = int(input())
r = 0
for i in range(1, k+1):
    r = (r*10 + 7)%k
    if r == 0:
        print(i)
        exit()
print(-1)
# Judge status: Accepted
x=int(input())
if x==0:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
n, k = map(int,input().split())
x = list(map(int,input().split()))
x.append(0)
x.sort()

ans = []
for i in range(n-k+1):
    cnt = 0
    cnt += abs(x[i])
    for j in range(i,k+i):
        cnt += abs(x[j+1] - x[j])    
    ans.append(cnt)

print(min(ans))
# Judge status: Accepted
N, M = map(int, input().split())

ans = 0
x = max(0, (M-2*N) // 4)
r = min(10, M//2)
for i in range(max(0, x-r), x+r):
    tmp = min(N+i, (M-2*i)//2)
    ans = max(ans, tmp)

print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
c2=0
c4=0
for aa in a:
  if aa%2 == 0:
    if aa%4 == 0:
      c4+=1
    else:
      c2+=1
c0=n-(c2+c4)
cc=c4-c0
if c2>=1 and c2 != n:
  cc-=1
print("Yes" if cc >= -1 else "No")
# Judge status: Accepted
p,q,r = map(int,input().split())
print(min(p+q,q+r,r+p))
# Judge status: Wrong Answer
N = int(input())
a = list(map(int,input().split()))

color = [0 for j in range(9)]

for i in range(N):
    if a[i] >= 3200:
        color[8] += 1
    else:
        for j in range(8):
            if a[i] // 400 == j:
                color[j] += 1

color_min = 8 - color[:8].count(0)
if 8 - color_min <= color[8]:
    if color_min == 0:
        color_min = 1
    color_max = 8
else:
    color_max = color_min + color[8]
print(color_min, color_max)
# Judge status: Accepted
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

INF = 1 << 60

dp = [INF] * (h + 1)
dp[0] = 0

for i in range(0, h + 1):
    #　hを超えるために必要な最小コストは？
    for a, b in ab:
        if i + a <= h:
            dp[i + a] = min(dp[i] + b, dp[i + a])
        else:
            dp[h] = min(dp[i] + b, dp[h])

print(dp[h])
# Judge status: Wrong Answer
n = int(input())
s = input()
strings = [chr(ord(c)+n) if c != "Z" else chr(ord("A")+(n-1)) for c in s]
ans = "".join(strings)
print(ans)
# Judge status: Accepted
import math
R = int(input())
print(R*math.pi*2)
# Judge status: Accepted
L,R=map(int,input().split())
ans=[]
for i in range(L,R):
    for j in range(i+1,R+1):
        ans.append(i*j%2019)
        if (i*j)%2019==0:
            print((i*j)%2019)
            exit()
print(min(ans))
# Judge status: Wrong Answer
def main():
    a, b, c, k = map(int, input().split())
    if a + b >= k:
        print(max(a, k))
    else:
        x = k - a - b
        print(a - x)


main()
# Judge status: Accepted
N = int(input())
C = [[0] * 10 for i in range(10)]

for i in range(1, N + 1):
  p = len(str(i))
  a = i // (10 ** (p - 1))
  b = i % 10
  C[a][b] += 1
  
count = 0
for i in range(10):
  for j in range(10):
    count += C[i][j] * C[j][i]
    #if C[i][j] * C[j][i] > 0:
      #print(i, j)
print(count)
# Judge status: Wrong Answer
import heapq
import math

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

for i in range(N):
    p = A[i]
    A[i] = [-p, i]

heapq.heapify(A)
C = [0]*N
for j in range(K):
    x, y = heapq.heappop(A)
    cnt = C[y]
    x = x * (cnt+1) // (cnt+2)
    C[y] += 1
    heapq.heappush(A, [x, y])

ans = heapq.heappop(A)[0]

ans = math.ceil(-ans)

print(ans)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
#lis = list(map(int,input().split()))
print("YES" if a <= c <= b else "NO")
# Judge status: Wrong Answer
import heapq


def main():
    n, m = map(int, input().split())
    a = list(map(lambda x: int(x)*(-1), input().split()))
    heapq.heapify(a)
    for i in range(m):
        item = heapq.heappop(a)
        heapq.heappush(a, item // 2)
    print(-sum(a))


if __name__ == '__main__':
    main()
# Judge status: Accepted
def I(): return int(input())
def LI(): return list(map(int,input().split()))
##################################################
N = I()
H = LI()
for i in range(N):
    if i==0:
        H[i] -= 1
        continue
    if i==N-1:
        if H[i-1]<=H[i]:
            continue
    if H[i-1]<=H[i]-1<=H[i+1]:
        H[i] -= 1
        continue
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    print('No')
    break
else:
    print('Yes')
# Judge status: Wrong Answer
A,B,X=map(int,input().split())
print("Yes" if A<=X<A+B else "No")
# Judge status: Accepted
S = int(input())

dp = [0] * (S + 1)
dp[0] = 1
M = 10 ** 9 + 7

for i in range(1, S + 1):
    num = 0
    for j in range(i - 2):
        num += dp[j]
        dp[i] = num % M

print(dp[S])
# Judge status: Accepted
from collections import Counter

count_by_kw = Counter()

n=int(input())
l=[]
dict={}
ans=0
for x in range(n):
  a=sorted(input())
  b=''.join(a)
  if not b in dict:
    dict[b]=x
    l.append(b)
    count_by_kw[b]+=1
  else:
    d=count_by_kw[b]
    count_by_kw[b]+=1
    
for y in range(len(l)):
  r=l[y]
  w=count_by_kw[r]
  ans+=w*(w-1)//2

print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
c = [1, 3, 5, 7, 8, 10, 12]
d = [4, 6, 9, 11]
e = [2]
if ((a in c) and (b in c)) or ((a in d) and (b in d)) or ((a in e) and (b in e)):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A, B, K = map(int, input().split())
if K > (A + B):
  print(0, 0) 
elif A > K: 
  print(A - K, B)
else:
  print(0, A + B - K)
# Judge status: Accepted
import collections
n=int(input())
a=list(map(int,input().split()))
a=collections.Counter(a)
values,counts=zip(*a.most_common())
l=len(values)
ans=0
for i in range(0,len(values)):
  if counts[i]<values[i]:
    ans=ans+counts[i]
  elif counts[i]>values[i]:
    ans=ans+counts[i]-values[i]
print(ans)
# Judge status: Accepted
n = int(input())
a = n // 3
b = n // 5
c = n // 15
print(n * (n + 1) // 2 - a * (a + 1) // 2 * 3 - b * (b + 1) // 2 * 5 + c * (c + 1) // 2 * 15)
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
ans=max(a*c,b*d,a*d,b*d)
print(ans)