peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
A,B,X = map(int,input().split())

if A<= X and X<=A+B:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
a, b = map(int, input().split())
start = a+b
if start >= 24:
    start = start - 24

print(start)
# Judge status: Accepted
X, Y = map(int, input().split())
print(X + Y // 2)
# Judge status: Wrong Answer
K,A,B=map(int,input().split())
bis=1
if K==1:
  bis+=1
elif A>=B-1:
  bis+=K
else:
  if int((K-(A-1)))%2==0:
    bis=int(A+(B-A)*(K-(A-1))/2)
  else:
    bis=A+(B-A)*int((K-(A-1))//2)+1
print(bis)
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
dp = [0]*n
dp[1] = abs(l[1] - l[0])
for i in range(2,n):
    dp[i] = min(dp[i-2]+abs(l[i]-l[i-2]),dp[i-1]+abs(l[i] - l[i-1]))
print(dp[n-1])
# Judge status: Accepted
def resolve():
    A, B, C = list(map(int, input().split()))
    ans = ''
    if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
        ans = 0
    else:
        ans = min(B * C, C * A, A * B)

    print(ans)
    return


resolve()
# Judge status: Accepted

n = int(input())

for i in range(500000):
  if int(i*1.08) == n:
    print(i)
    break
else:
  print(":(")
# Judge status: Accepted
X,Y = list(map(int,input().split()))
#X, 2X, 4X,...,2^(t-1)*X<=Yとなる最大のt
#10^18 はだいたい2^60だから全部試せそう
for t in range(1,100):
    if 2**(t-1)*X<=Y:
        out = t
    else:
        break
print(out)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if (a>10 or b>10):
    print(-1)
else:
    print(a*b)
# Judge status: Accepted
n,m=map(int,input().split())
a=[input() for i in range(n)]
b=[input() for i in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        jud=True
        for k in range(m):
            if b[k]!=a[i+k][j:j+m]:
                jud=False
                break
        if jud:
            print("Yes")
            exit()
print("No")
# Judge status: Accepted
from math import factorial

def combi(n, k):
  return factorial(n) // factorial(n-k) // factorial(k)

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

e = len([a for a in A if a % 2 == 0])
o = N - e

ans = 0
if P == 0:
  for i in range(0, o+1, 2):
    ans += combi(o, i)
  print(ans * pow(2, e))
else:
  for i in range(1, o+1, 2):
    ans += combi(o, i)
  print(ans * pow(2, e))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ans = 1
trend = '-'
pre = a[0]
for now in a:
    if (trend=='<' and pre>now) or (trend=='>' and pre<now):
        ans += 1
        trend = '-'
    else:
        if pre<now:
            trend = '<'
        elif pre>now:
            trend = '>'
    pre = now
print(ans)
# Judge status: Accepted
s = input()
l = len(s)
dp = [0]*2019
dp[0] = 1
r = 0
for i in range(1, l + 1):
    r += int(s[-i]) * pow(10, i - 1, 2019)
    r %= 2019
    dp[r] += 1
    
print(sum([(i * (i - 1)) // 2 for i in dp]))
# Judge status: Accepted
N = int(input())
s = []
for i in range(N): s.append(input()) 
M = int(input())
t = []
for i in range(M): t.append(input())
ans = 0  
for i in s:
  ans = max(ans, s.count(i) - t.count(i))
print(ans)
# Judge status: Accepted
n = int(input())
l = map(int,input().split())
d = {}
ans = 0
for i in l:
  if i not in d:
    d[i] = 1
  else:
    d[i] += 1
for k,v in d.items():
  if k != v:
    if k < v:
      ans += v - k
    else:
      ans += v
print(ans)
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))


h[0] -= 1
for i in range(0, n-1):
    if h[i] <= h[i+1] -1:
        h[i+1] -= 1
    elif h[i] > h[i+1]:
        print('No')
        break
else:
    print('Yes')
# Judge status: Wrong Answer
def resolve():
    n = int(input())
    S = tuple(input())

    c_e = S.count('E')
    c_w = 0
    ans = n

    for s in S:
        ans = min(ans, c_w + c_e)
        if s == 'E':
            c_e -= 1
        else:
            c_w += 1

    print(ans)
if __name__ == '__main__':
    resolve()
# Judge status: Accepted
n, m = map(int, input().split())
py = []
for _ in range(m):
    p, y = map(int, input().split())
    py.append((p, y))
prefs = [[] for _ in range(n)]
for ind, (p, y) in enumerate(py):
    prefs[p-1].append((y, ind))
ans = [None]*m
for p, i in enumerate(prefs):
    i.sort()
    for j, (_, ind) in enumerate(i):
        ans[ind] = str(p+1).zfill(6)+str(j+1).zfill(6)
for i in ans:
    print(i)
# Judge status: Accepted
A_s = list(map(int, input().split()))
if sum(A_s) > 21:
    print('bust')
else:
    print('win')
# Judge status: Accepted
n, m = map(int, input().split())
l = [0]*m
for _ in range(n):
    k, *a = map(int, input().split())
    for i in a:
        l[i-1] += 1
print(l.count(n))
# Judge status: Accepted
N,K = map(int,input().split())
treats = [[False for i in range(110)] for j in range(110)]

res = 0

for i in range(1,K+1,1):
  d = int(input())
  A = [i for i in map(int,input().split())]
  for a in A:
    treats[i][a] = True
    
for j in range(1,N+1,1):
  flag = 1
  for i in range(1,K+1,1):
    if treats[i][j] == True:
      flag = 0
      
  if flag: res += 1
    
print(res)
# Judge status: Accepted
x = int(input())

# 6 -> 5- > 6 -> ....が最適？
p, q = divmod(x, 11)
p *= 2
if q != 0:
    if q <= 6:
        p += 1
    else:
        p += 2

print(p)
# Judge status: Accepted
N,K,X,Y = [int(input()) for i in range(4)]
if N>=K:
    print(K*X + (N-K)*Y)
else:
    print(N*X)
# Judge status: Accepted
from math import gcd
k=int(input())
r=range(1,k+1)
ans=0
for i in r:
  for j in r:
    for k in r:
      ans+=gcd(k,gcd(i,j))
print(ans)
# 間に合うはずなくない？？
# Judge status: Wrong Answer
import math
a = int(input())
s = input()
if(a >= 3200):
    print(s)
else:
    print("Red")
# Judge status: Wrong Answer
import math

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

X = math.ceil(sum(a) / n)

P = 0

for i in range(n):
    P += (X - a[i])**2

print(P)
# Judge status: Accepted
n = int(input())
power = 1
for i in range(1,n+1):
    power=power*i%(10**9+7)
print(power)
# Judge status: Wrong Answer
N=int(input())
M=list(map(int,input().split()))
ans=0
list_= sorted(M)
for i in range(N):
  if M[i]==list_[i]:
    ans+=1
if ans>=N-2:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
A, B, C, X, Y = map(int, input().split())
ans = float('inf')
for i in range(10**5 + 1):
    price = 2*C*i + A*max(0, X - i) + B*max(0, Y - i)
    if ans > price:
        ans = price

print(ans)
# Judge status: Accepted
N,X,Y=map(int,input().split())
b=[0 for i in range(N+1)]
#print(b)
for i in range(1,N):
    for j in range(i+1,N+1):
        #print('{},{}'.format(i,j))
        minmin=min([abs(j-i),abs(X-i)+1+abs(Y-j)])
        #print(minmin)
        b[minmin]=1+b[minmin]

for i in range(1,N):

    print(b[i])
# Judge status: Wrong Answer
a, b, c, k = map(int, input().split())
if k % 2 == 0:
  ans = a-b
else:
  ans = b-a
# Judge status: Accepted
def solve(x, n, nums):
	if not nums or x not in nums:
		return x
	a = x - 1
	b = x + 1
	while True:
		if a not in nums:
			return a
		if b not in nums:
			return b
		a -= 1
		b += 1

x, n = map(int, input().split())
A = None
if n > 0:
	A = set(list(map(int, input().split())))
print(solve(x, n, A))
# Judge status: Accepted
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = 10**9
for i in range(N-K+1):
    l, r = A[i], A[i+K-1]
    if l*r >= 0:
        ans = min(ans, max(abs(l), abs(r)))
    else:
        ans = min(ans, r-l+min(abs(l), abs(r)))
print(ans)
# Judge status: Accepted
if __name__ == "__main__":
    x,y = map(int,input().split())
    flag = 0
    for i in range(x + 1) :
        if i * 4 + (x - i) * 2 == y :
            print("Yes")
            flag = 1
            break 

    if flag == 0 :
        print("No")
# Judge status: Accepted
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a,b,c = map(int,input().split())
li = [a,b,c]
li.sort()
cnt = 0
while li[2] != li[1]:
    li[0] += 1
    li[1] += 1
    cnt+=1
cnt += (li[1]-li[0])//2
if (li[1]-li[0])%2 != 0:
    cnt += 2
print(cnt)
# Judge status: Accepted
import collections

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

for i in range(n):
    a.append(a[i] + 1)
    a.append(a[i] - 1)

l = collections.Counter(a)
l = list(l.values())
print(max(l))
# Judge status: Accepted
N = int(input())
A = [int(x) for x in input().split()]

c = dict()
for a in A:
    if a not in c:
        c[a] = 1
    else:
        c[a] += 1

tmp = 0
for k, v in c.items():
    if v < k:
        tmp += v
    else:
        tmp += (v - k)
print(tmp)
# Judge status: Wrong Answer
n = int(input())
w = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += w[i]
    if ans > sum(w)//2:
        print(abs(ans - (sum(w)-ans)))
        break
# Judge status: Wrong Answer
s = input().split()

d = int(s[0])
n = int(s[1])

answer = 0

if d == 0:
    if n == 100:
        answer = 101
    else:    
        answer = n
elif d == 1:
    answer = 100 * n
elif d == 2:
    answer = 10000 * n

print(answer)
# Judge status: Accepted
import collections

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

mod = 998244353

if d[0] != 0:
    print(0)
    exit()

m = max(d)

cnt = collections.Counter(d)
if cnt[0] != 1:
    print(0)
    exit()

ans = 1

for i in range(1, m + 1):
    if cnt[i] == 0:
        print(0)
        exit()
    ans *= pow(cnt[i - 1], cnt[i], mod)
    ans %= mod

print(ans)
# Judge status: Accepted
N = int(input())
Zlist=[]
Wlist = []
for i in range(N):
    x,y = map(int,input().split())
    z = x+y
    w = x-y
    Zlist.append(z)
    Wlist.append(w)
Zlist.sort()
Wlist.sort()
print(max(Zlist[-1]-Zlist[0],Wlist[-1]-Wlist[0]))
# Judge status: Wrong Answer
import bisect

N = int(input())
Alist = sorted(list(map(int, input().split())))
Blist = sorted(list(map(int, input().split())))
Clist = sorted(list(map(int, input().split())))

ans = 0

for B in Blist:
    Aindex = bisect.bisect_left(Alist, B)
    Cindex = bisect.bisect_right(Clist, B)

    print(B, Aindex, N-Cindex)
    ans += Aindex * (N - Cindex)

print(ans)
# Judge status: Accepted
S = input()
N = len(S)

A = [0] * (N+1)

c = 0
for i in range(N):
    if S[i] == '<':
        c += 1
    else:
        c = 0
    A[i+1] = c

c = 0
for i in range(N-1, -1, -1):
    if S[i] == '>':
        c += 1
    else:
        c = 0
    A[i] = max(A[i], c)

print(sum(A))
# Judge status: Wrong Answer
from math import ceil


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    lower = 1
    upper = 10 ** 9 + 7
    while upper - lower >= 0.5:
        target = (lower + upper) / 2
        now = 0
        for i in range(n):
            now += ceil(a[i] / target) - 1
        if now > k:
            lower = target
        else:
            upper = target
    print(ceil(lower) if k > 0 else a[-1])


if __name__ == '__main__':
    main()
# Judge status: Accepted
X, A, B = map(int, input().split())

a = A * (-1)

if (a+B < X+1) and (A < B):
    print("safe")

elif (A >= B):
    print("delicious")

elif (a+B >= X+1):
    print("dangerous")
# Judge status: Accepted
n, d = map(int, input().split())
print((n-1)//(2*d+1)+1)
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
mod = 10**9+7

ones = [0]*60
ans = 0
for i in range(n):
    x = l[i]
    for j in range(60):
        ones[j] += (x>>j)&1
    ans = (ans + (n-1)*x)%mod
# print(ans)

for i in range(60):
    ans = (ans - ones[i]*(ones[i]-1)*2**i)%mod
print(ans)
# Judge status: Accepted
from collections import Counter
N = int(input())
d = list(map(int, input().split()))

MOD = 998244353

dn = Counter(d)
ans = 1
if dn[0] != 1 or d[0] != 0: ans = 0
else:
    for i in range(1, max(d)+1):
        ans *= (dn[i-1]**dn[i])
        ans %= MOD
    
print(ans)
# Judge status: Accepted
import sys
readline = sys.stdin.readline

N = int(readline())
rest = [None] * N
for i in range(N):
  s,p = readline().split()
  rest[i] = [s,int(p),i + 1]
  
rest = sorted(rest, key = lambda x:(x[0],-x[1]))
for r in rest:
  print(r[2])
# Judge status: Accepted
n = int(input())
product_list = list()

for i in range(1, 10):
    for j in range(1, 10):
        product_list.append(i * j)

if n in product_list:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
S = input()

for i in range(10**9):
  s = 1 + 1
# Judge status: Accepted
k,a,b = map(int,input().split())

if b - a < 2:
    ans = k + 1
else:
    k -= a - 1
    ans = (k // 2) * (b - a) + a
    if k % 2 == 1:
        ans += 1
print(ans)
# Judge status: Wrong Answer
S=input()
judge=0
for i in range(0,2):
    if S[i]==S[i+1]:
        judge+=1
if judge>=1:
    print("Bad")
else:
    print("Good")
# Judge status: Accepted
from itertools import groupby

N = int(input())
S = input()

cnt_l = 0
cnt_r = 0
ans = ''
for key, elems in groupby(S):
    elems = list(elems)
    if key == '(':
        cnt_l += len(elems)
        ans += '(' * len(elems)
    else:
        cnt_r += len(elems)
        ans += ')' * len(elems)
        if cnt_l < cnt_r:
            ans = '(' * (cnt_r - cnt_l) + ans
            cnt_l += (cnt_r - cnt_l)

print(ans + ')' * (cnt_l - cnt_r))
# Judge status: Accepted
def resolve():
    S = list(input())
    S.reverse()
    substr = ''
    p = ['dream', 'dreamer', 'erase', 'eraser']
    for i in S:
        substr = i + substr
        if substr in p:
            substr = ''
    ans = 'YES' if substr == '' else 'NO'
    print(ans)


if __name__ == "__main__":
    resolve()
# Judge status: Wrong Answer
x,y,z = map(int,input().split())

ans = 0

s = []

while True:
    x,y,z = y//2+z//2,x//2+z//2,x//2+y//2
    if x%2 == 0 and y%2 == 0 and z%2 == 0:
        ans += 1
        if [x,y,z] in s:
            print(-1)
            break
        else:
            s.append([x,y,z])
    else:
        print(ans+1)
        break
    if tuple([x,y,z]) in s:
        print(-1)
        break
# Judge status: Accepted
a,b,c,k = map(int,input().split())
if k%2==0:
    print(a-b)
else:
    print(b-a)
# Judge status: Wrong Answer
X,K,D = map(int,input().split())
X = abs(X)
 
if X <= K * D :
  if K % 2 == 1 :
    answer = abs(X % D - D)
  else :
    answer = X % D
else :
  answer = X - K * D
  
print(answer)
# Judge status: Wrong Answer
import math
x = int(input())
s = int(math.ceil(x**(0.5)))
ss = s*(s+1)//2
if ss < x: print(s+1)
else: print(s)
# Judge status: Accepted
import numpy as np

abcd = input()
#a,b,c,d = [s for s in abcd]

for i in range(2**3):
    ops = ["-","-","-",""]
    for j in range(3):
        if i>>j&1: ops[j] = "+"
    equa = ""
    for s,op in zip(abcd,ops): equa += (s+op)
    if eval(equa) == 7 : break

ans = equa + "=7"
print(ans)
# Judge status: Accepted
s = input()
n = len(s)
k = 'keyence'
a = 0
b = 6

for i in range(n):
    if k[a] == s[i]:
        a += 1
    else:
        break
    if a == 7:
        break

for i in range(n)[::-1]:
    if k[b] == s[i]:
        b -= 1
    else:
        break
    if b == -1:
        break
    
b = 7 - b - 1
if a + b >= 7:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
ans = 0
height = A[0]
for i in range(1, N):
    if A[i]<height:
        ans += height-A[i]
    elif A[i]>A[i-1]:
        height = A[i]

print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
A=[0]*N
ans=0
e=0
for i in range(M):
  s, c = map(int, input().split())
  if(s==1 and c==0 and N!=1):
    print(-1)
    e=1
    break
  if A[s-1]==0 or A[s-1]==c:
  	A[s-1]=c
  else:
    print(-1)
    e=1
    break
if A[0]==0 and N!=1:
  A[0]=1
for i in range(N):
  ans+=A[i]*(10**(N-i-1))
if e==0:
  print(ans)
# Judge status: Accepted
x,a,b = map(int,input().split())

print("B" if abs(x-a)>abs(x-b) else "A")
# Judge status: Accepted
n = int(input())

d = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for _ in range(n):
    s = str(input())
    d[s] += 1

print('AC x {}\nWA x {}\nTLE x {}\nRE x {}\n'.format(d['AC'], d['WA'], d['TLE'], d['RE']))
# Judge status: Accepted
MM = input()
listM = list(MM)
xx = len(listM)
saisyo =0
saigo  =xx
xx = len(listM)
for i in range(0,xx-1,1):
  
  if listM[i]=='A':
    saisyo = i
    
    break
for i in range(xx-1,0,-1):
  
  if listM[i]=='Z':
    saigo = i
    
    break
ans = saigo -saisyo
print(ans+1)
# Judge status: Accepted
S = input()
 
mods = [0 for _ in range(2019)]
mods[0] = 1
t = 0
mod10 = 1
for s in reversed(S):
    t += int(s) * mod10
    t = t % 2019
    mod10 *= 10
    mod10 %= 2019
    mods[t] += 1

cnt = sum([m*(m-1)/2 for m in mods])
print(int(cnt))
# Judge status: Accepted
import math
import pprint
import fractions
import collections
import itertools
from decimal import *
from collections import deque
from bisect import *
K=int(input())
flag=0
cnt=0
ans=0
for i in range(K):
    cnt=(cnt+7*pow(10,i,K))%K
    if cnt==0:
        flag=1
        ans=i+1
        break
if flag==0:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")

EPS = 1e-8


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

    T = 0
    for a in A:
        T ^= a
    print(" ".join([str(T ^ a) for a in A]))

    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
S = input()
S = S[:3] + '8' + S[4:10]
print(S)
# Judge status: Accepted
#A
import sys
k = int(input())
a, b = list(map(int, input().split()))
for i in range(a, b+1):
    if i % k == 0:
        print("OK")
        sys.exit()
print("NG")
# Judge status: Accepted
#!/usr/bin/env python3

X, Y = map(int, input().split())

print(int(X+Y/2))
# Judge status: Accepted
n = int(input())
ab = [map(int, input().split()) for _ in range(n)]

ans = 0
for a, b in reversed(ab):
    a += ans
    ans += (-a) % b

print(ans)
# Judge status: Wrong Answer
a = input().split()
five = a.count(5)
seven = a.count(7)

if five == 2 and seven == 1:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
import numpy as np
n,m = map(int,input().split())
A = np.array([list(input()) for _ in range(n)])
B = np.array([list(input()) for _ in range(m)])
bl = False

for i in range(n-m+1):
    for j in range(n-m+1):
        if (A[i:i+m,j:j+m] ==B).all():
            bl =True

print('Yes' if bl else 'No')
# Judge status: Accepted
a,b=list(map(int,input().split()))
c=b-a
l=[]
for i in range(c):
    l.append(i+1)

print(sum(l)-b)
# Judge status: Accepted
w, a, b = map(int, input().split())

if abs(a-b) < w:
    print(0)
elif a < b:
    print(b-a-w)
else:
    print(a-b-w)
# Judge status: Accepted
#ABC043C
n=int(input())
a = list(map(int, input().split()))
h=round(sum(a)/len(a))
sum_a=0
for i in range(len(a)):
    sum_a=sum_a+(a[i]-h)**2
print(int(sum_a))
# Judge status: Accepted
def main():
    N, L = map(int, input().split())
    S = [input() for _ in range(N)]
    S.sort()
    print(''.join(S))


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
S = []
Y = {}
c = 0
for i in range(N):
  s = input()
  t = [s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9]]
  t.sort()
  u = t[0]+t[1]+t[2]+t[3]+t[4]+t[5]+t[6]+t[7]+t[8]+t[9]
  if u not in Y:
    Y[u] = 1
  else :
    c += Y[u]
    Y[u] += 1
    


print(c)
# Judge status: Accepted
print((sum(map(int,input().split()))-1)//2+1)
# Judge status: Accepted
# print('input >>')
N = input()
As = list(map(int,(input().split())))

money = 1000
kab = 0

for i in range(len(As)-1):
    if As[i+1] >= As[i]:
        kounyu = money // As[i]
        kab += kounyu
        money -= kounyu * As[i]
    elif As[i+1] < As[i]:
        money += kab * As[i]
        kab = 0
    # print(money, kab)

money += kab * As[-1]

# print('-----output-----')
print(money)
# Judge status: Accepted
x = int(input())

h = x // 100
m = x % 100
if 0 <= m <= h * 5:
    print(1)
else:
    print(0)
# Judge status: Accepted
k=int(input())
x=7
cnt=1
if k%2==0:
    print(-1)
else:
    while True:
        if x%k ==0:
            print(cnt)
            break
        elif cnt<10000000:
            x=(x*10+7)%k
            cnt+=1
        else:
            print(-1)
            break
# Judge status: Accepted
import sys
def input():
  return sys.stdin.readline().rstrip()

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

ans=0
right=0
while True:
  if ans==0:
    right+=K
  else:
    right+=K-1
  ans+=1
  if N<=right:
    break;

print(ans)
# Judge status: Accepted
#入力
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

#空のリストを作る事で，求めた値をそのリストに追加していく
#そして，そのリストの中から一番値が近いものをprintする
l = []
for i in range(N):
    a = T - H[i]*0.006
    b = abs(a-A)
    l.append(b)

c = l.index(min(l))
print(c +1)

#空のリストの作成方法
#l = []
#l.append(引数)
# Judge status: Accepted
def main():
    k,x = map(int, input().split())

    l = []
    
    for i in range(x-k+1,x+k):
        print(i, end=' ')

if __name__ == '__main__':
    main()
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
d = int(input())
ans = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == d:
        ans += 1

print(ans)
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]
x = sorted(a)
m1 = x[n // 2]
m2 = x[n // 2 - 1]
for i in range(n):
    if a[i] < m1: print(m1)
    else: print(m2)
# Judge status: Accepted
n,l=map(int,input().split())
apple=[l+i for i in range(n)]
s=0
while True:
    if s in apple:
        apple.remove(s)
        break
    elif abs(s) in apple:
        apple.remove(abs(s))
        break
    s-=1
print(sum(apple))
# Judge status: Accepted
n=int(input());a=[0];b=[0]
for i in input():t=i=='.';a+=[a[-1]+t];b+=[b[-1]+1-t*2];
print(min([i+a[n] for i in b]))
# Judge status: Accepted
import sys
N, P = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))

kisu = 0
gusu = 0
for a in A:
    if a % 2 == 1:
        kisu += 1
    else:
        gusu += 1

total = 2 ** N # 全場合の数
if kisu == 0:
    ans = 2 ** gusu
else:   
    ans = (2 ** gusu) * (2 ** (kisu - 1)) # 偶数になる場合の数

if P == 0:
    print(ans)
else:
    print(total - ans)
# Judge status: Wrong Answer
a = input("A")
b = input("B")

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

print(6-a-b)
# Judge status: Accepted
n = int(input())
s = input()
l = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
ans = ""
for i in s:
    ans += l[l.index(i)+n]

print(ans)
# Judge status: Wrong Answer

n,m = map(int, input().split())
pyl = [ [] for _ in range(n+1) ]

for i in range(m):
    p,y = map(int, input().split())
    pyl[p].append((y,i))

ans = ['']*m
for p, yil in enumerate(pyl):
    top = str(p).zfill(6)
    yil.sort()
    for order,(y,i) in enumerate(yil):
        print(order,i)
        bottom = order+1
        bottom = str(bottom).zfill(6)
        ans[i] = top+bottom

for a in ans:
    print(a)
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
ans = "ABC"
if N >= 1000 :
    ans = "ABD"
print(ans)
# Judge status: Accepted
x,y = map(int,input().split())
if abs(x)<=abs(y):
    count = 0
    if x <0:
        count += 1
    if y <0:
        count += 1
    count += abs(y)-abs(x)
    print(count)
else:
    if x <=0:
        a = y -x
        b = abs(x)-abs(y)+1
        print(min(a,b))
    else:
        a = 1 + (y+x)
        b = 1 + abs(x) - abs(y)
        if y > 0:
            b+= 1
        print(min(a,b))
# Judge status: Accepted
#create date: 2020-03-28 21:26

import sys
stdin = sys.stdin
import bisect

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

def main():
    x, y, a, b, c = na()
    p = na()
    q = na()
    r = na()
    p.sort(reverse=True)
    q.sort(reverse=True)
    l = p[:x]
    l += q[:y]
    l += r
    l.sort(reverse=True)
    ans = sum(l[:(x+y)])
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
from heapq import heappush, heappop

N, M = map(int, input().split())
AB = []

for i in range(N):
  a, b = map(int, input().split())
  AB.append((a,b))

AB.sort()
index = 0
result = 0
queue = []

for limit in range(1, M+1):
  while index < N and AB[index][0] <= limit:
    a, b = AB[index]
    heappush(queue, -b)
    index += 1

  if queue:
    result += -heappop(queue)

print(result)