Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def main():
    n,d,a = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]
    l.sort()
    count = 0
    import math

    i = 0
    

    while True:
        sn = i
        s = l[i][0]
        s += 2*d
        mi = math.ceil(l[i][1]/a)
        count += mi
        b = mi*a
        l1 = 0
        while i < n and l[i][0] <= s:
            
            l[i][1] -= b
            if l[i][1] > 0:
                if l1 == 0:
                    l1 = i
            i += 1
            
        if l1 > 0:
            i = l1
        else:
            if i == n:
                print(count)
                exit()
    
if __name__ == "__main__":
    main()



### FIXED CODE ###

def main():
    n,d,a = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]
    l.sort()
    count = 0
    from collections import deque

    i = 0
    area = deque([])
    damage = deque([])
    total_damage = 0
    count = 0
    ans = 0
    for pos,hp in l:
        while area:
            ar = area[0]
            if ar < pos:
                area.popleft()
                power = damage.popleft()
                total_damage -= power
            else:
                break
        if hp <= total_damage:
            continue
        else:
            count = (hp-total_damage+a-1)//a
            ans += count
            total_damage += count*a
            area.append(pos+2*d)
            damage.append(count*a)

    print(ans)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

#!/usr/bin/env python3
#ABC75 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,K = LI()
xy = [LI() for _ in range(n)]
xy.sort(key = itemgetter(1))
xy.sort(key = itemgetter(0))
ans = inf
for i in range(n):
    ux,uy = xy[i]
    for j in range(n):
        dx,dy = xy[j]
        if uy < dy:
            continue
        for k in range(n):
            rx,ry = xy[k]
            for l in range(n):
                lx,ly = xy[l]
                if rx < lx:
                    continue
                cnt = 0
                for m in range(n):
                    x,y = xy[m]
                    if lx <= x <= rx and dy <= y <= uy:
                        cnt += 1
                if cnt >= K:
                    S = (uy - dy)*(rx - lx)
                    ans = min(ans,S)
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC75 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,K = LI()
xy = []
X = []
Y = []
for _ in range(n):
    x,y = LI()
    xy.append([x,y])
    X.append(x)
    Y.append(y)
X.sort(reverse = True)
Y.sort(reverse = True)
ans = inf
for i in range(n):
    uy = Y[i]
    for j in range(i+1,n):
        dy = Y[j]
        for k in range(n):
            rx = X[k]
            for l in range(k+1,n):
                lx = X[l]
                cnt = 0
                for x,y in xy:
                    if lx <= x <= rx and dy <= y <= uy:
                        cnt += 1
                if cnt >= K:
                    S = (uy - dy)*(rx - lx)
                    ans = min(ans,S)
print(ans)
### BUGGY CODE ###

n = int(input())
a = [int(e) for e in input().split()]

sum = 0
for i in range(n-1):
    for j in range(i+1, n):
       sum += a[i] * a[j]

res = sum % (10**9 + 7)

print(res)


### FIXED CODE ###

n = int(input())
a = [int(e) for e in input().split()]

my_sum = [0]
#print(my_sum)

tmp = 0
c = 0
for i in a:
    my_sum.append(my_sum[c]+i)
    c += 1

#print(my_sum)

my_sum2 = 0
length = len(my_sum)

c = 0
for i in a:
    my_sum2 += i * (my_sum[length-1] - my_sum[c+1])
    c += 1

print(my_sum2 % (10**9 + 7))
### BUGGY CODE ###

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

count = 0

for i in range(N):
    for j in range(i, N):
        for k in range(j, N):
            if (j - i) == (k - j):
                continue
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                count += 1

print(count)



### FIXED CODE ###

N=int(input())
S=input()
r=S.count('R')
b=S.count('B')
g=S.count('G')
ans=r*b*g
for i in range(N):
    for s in range(N):
        j=i+s
        k=j+s
        if k>=N:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans-=1
print(ans)
### BUGGY CODE ###

N,M = map(int,input().split())
AB = [[0,0]]*N
for n in range(N):
    AB[n] = list(map(int,input().split()))
work_schedule = [0]*M
sorted_AB = sorted(AB,key=lambda x:(-x[1],x[0]))
for work in sorted_AB:
    cnt = 0
    while True:
        if work[0]-1+cnt >= M:
            break
        elif work_schedule[work[0]-1+cnt] == 0:
            work_schedule[work[0]-1+cnt]  = work[1]
            break
        elif  work_schedule[work[0]-1+cnt] != 0:
            cnt+=1
print(sum(work_schedule))

### FIXED CODE ###

from collections import defaultdict
import heapq

n, m = map(int, input().split())
dct = defaultdict(list)

for i in range(n):
    a, b = map(int, input().split())
    dct[a].append(-b)

h = []
res = 0

for i in range(1, m + 1):
    if dct[i]:
        for item in dct[i]:
            heapq.heappush(h, item)
    if h:
        res += heapq.heappop(h)

print(-res)
### BUGGY CODE ###

import numpy as np
N,K = map(int,input().split())
p = list(map(int,input().split()))
e = [(p[i]+1)/2. for i in range(N)]
s = [sum(e[0:i]) for i in range(N+1)]
f = [(s[i+K]-s[i]) for i in range(N-K+1)]
print(max(f))

### FIXED CODE ###

import numpy as np
N,K = map(int,input().split())
p = np.array(list(map(int,input().split())))
e = (p+1) / 2.0
s = np.zeros(len(e)+1)
s[1:] = np.cumsum(e)
f = s[K:] - s[:-K]

print(np.max(f))
### BUGGY CODE ###

a,b = (int(i) for i in input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def is_prime(n):
  for p in range(2, n):
    if n % p == 0:
      return False
  return True
cnt = 0
for i in divisor(gcd(a,b)):
  if is_prime(i):
    cnt += 1
print(cnt)

### FIXED CODE ###

a,b = (int(i) for i in input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
  
def is_prime(n):
  for p in range(2, n):
    if n % p == 0:
      return False
  return True

cnt = 0

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
list = prime_factorize(gcd(a,b))

print(len(set(list))+1)
### BUGGY CODE ###

A, B, N = map(int, input().split())
l = -1
r = N
# ans = 0
# for i in range(1, N+1):
#     ans = max(ans, (A*i)//B - (A*(i//B)))
ans2 = (A*N)//B - (A*(N//B))
for i in range(B-1, N, B):

    ans2 = max(ans2, (A*i)//B - (A*(i//B)))
print(ans2)


### FIXED CODE ###

A, B, N = map(int, input().split())
l = -1
r = N
# ans = 0
# for i in range(1, N+1):
#     ans = max(ans, (A*i)//B - (A*(i//B)))
k = min(B-1, N)
ans2 = (A*k)//B - (A*(k//B))

print(ans2)
### BUGGY CODE ###

def main():
	n=int(input())
	a=list(map(int, input().split()))
	count = 0
	for i in range(n):
		if  a.count(a[i])> 1:
			count+=1
			print('NO')
			break
	if count==0:
		print('YES')
main()

### FIXED CODE ###

def main():
	n=int(input())
	a=list(map(int, input().split()))
	a.sort()
	c=0
	for i in range(n-1):
		if a[i] == a[i+1]:
			print('NO')
			c+=1
			break
	if c==0:
		print('YES')
main()
### BUGGY CODE ###

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

negative = []
zero = []
positive = []
for i in map(int, input().split()):
    if i < 0:
        negative.append(i)
    elif i > 0:
        positive.append(i)
    else:
        zero.append(i)

count_negative = len(negative) * len(positive)
count_zero = len(negative)*len(zero) + len(zero)*len(positive) + (len(zero)*(len(zero)-1))//2
count_positive = (len(positive)*(len(positive)-1))//2 + (len(negative)*(len(negative)-1))//2

values = []
if K <= count_negative:
    for i in negative:
        for j in positive:
            values.append(i * j)
    values.sort()
    print(values[K-1])
elif count_negative < K <= count_negative + count_zero:
    print(0)
else:
    for i in range(len(negative)):
        for j in range(i+1, len(negative)):
            values.append(negative[i] * negative[j])
    for i in range(len(positive)):
        for j in range(i+1, len(positive)):
            values.append(positive[i] * positive[j])
    values.sort()
    print(values[K-1-count_negative-count_zero])


### FIXED CODE ###

import numpy as np
n, k = map(int,input().split())
a = np.array(list(map(int,input().split())))
a.sort()
posi = a[a>0]
zero = a[a==0]
nega = a[a<0]

# 2分探索, midより小さいものを数える
l = -10**18-1
r = 10**18+1
while r-l > 1:
    mid = (r+l)//2
    cnt = 0
    if mid >= 0:
        cnt += len(zero)*n
    
    # a.searchsorted(v, side="left"): a[i-1] < v <= a[i]であるvのindexを返す  
    # a.searchsorted(v, side="right"): a[i-1] <= v < a[i]であるvのindexを返す  

    cnt += a.searchsorted(mid//posi, side="right").sum()
    cnt += (n - a.searchsorted(-(-mid//nega), side="left")).sum()
    cnt -= np.count_nonzero(a*a <= mid)
    cnt //= 2
    # print("mid:", mid)
    # print("mid//posi:", mid//posi)
    # print("search:", a.searchsorted(mid//posi,side="right"))
    # print("-(-mid//nega):", -(-mid//nega))
    # print("search:", a.searchsorted(-(-mid//nega),side="left"))
    # print("nonzero_count:", np.count_nonzero(a*a<=mid))
    # print("count:", cnt)
    # print('-' * 20)
    if cnt >= k:
        r = mid
    else:
        l = mid
print(r)
### BUGGY CODE ###

import numpy as np
import heapq

# 1から初めて、xがあるとき10x、x+1のいずれかが行えるとしてqueue

K = int(input())
h = []
heapq.heappush(h,(1,1)) # 各桁の和、modulo K
visited = np.full(K,False)

ans = 0

while ans == 0:
  s,x = heapq.heappop(h)
  visited[x] = True
  for ss,xx in [(s,(10*x)%K), (s+1,(x+1)%K)]:
    if visited[xx]:
      continue
    if xx == 0:
      ans = ss
      break
    heapq.heappush(h,(ss,xx))
  
print(ans)

### FIXED CODE ###

from collections import deque
 
# 1から初めて、xがあるとき10x、x+1のいずれかが行えるとしてqueue
 
K = int(input())
q = deque()
q.append((1,1)) # 各桁の和、modulo K
visited = [False]*K
 
ans = 0
 
while ans == 0:
  s,x = q.popleft()
  if visited[x]:
    continue
  visited[x] = True
  if x == 0:
    ans = s
    break
  q.appendleft((s,(10*x)%K))
  q.append((s+1,(x+1)%K))
 
print(ans)
### BUGGY CODE ###

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

from bisect import insort, bisect_left
bit = [L[0]+L[1]]
ans = 0
for k in range(2, N):
  ans += len(bit) - bisect_left(bit, L[k]+1)
  for j in range(k):
    insort(bit, L[j]+L[k])

print(ans)  


### FIXED CODE ###

# Binary Indexed Tree (Fenwick Tree)
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)


N = int(input())
L = list(map(int, input().split()))
L.sort()
bit = BIT(L[-1]*2+1)
bit.add(L[0]+L[1], 1)
total = 1
ans = 0
for k in range(2, N):
  ans += total - bit.sum(L[k])
  for j in range(k):
    bit.add(L[j]+L[k], 1)
    total += 1

print(ans)
### BUGGY CODE ###

def gcd(x,y):
  while y>0:
    bk=x%y
    x=y
    y=bk
  return x

k=int(input())
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    for h in range(1,k+1):
      ans+=gcd(gcd(i,j),h)
print(ans)

### FIXED CODE ###

import math
k=int(input())
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    tmp=math.gcd(i,j)
    for h in range(1,k+1):
      ans+=math.gcd(tmp,h)
print(ans)
### BUGGY CODE ###

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

while abs(N-K)<N:
    N=abs(N-K)
    nums.append(N)
print(min(nums))

### FIXED CODE ###

N, K=map(int,input().split())
t=N%K
ans=min(abs(t),abs(t-K))
print(ans)
### BUGGY CODE ###

q = int(input())
a = []
for i in range(q):
    l, r = map(int, input().split())
    a.append([l, r])

def is_prime(n):
    for i in range(2, int(n**(1/2))+1, 1):
        if n%i == 0:
            return False
    return n != 1

def lnum(n):  # Like number
    if is_prime(n) and is_prime((n+1)//2):
        return True
    else:
        return False

ans = [0]*q
for j in range(q):
    for k in range(a[j][0], a[j][1]+1, 1):
        if lnum(k):
            ans[j] += 1
        else:
            continue
for x in ans:
    print(x, end=" ")

### FIXED CODE ###

def is_prime(n):
    for i in range(2, int(n**(1/2))+1, 1):
        if n%i == 0:
            return False
    return n != 1

def lnum(n):  # Like number
    if is_prime(n) and is_prime((n+1)//2):
        return True
    else:
        return False

MAX = 101010
a = [0]*MAX
for i in range(MAX):
    if lnum(i):
        a[i] = 1
    else:
        continue

s = [0]*MAX
for i in range(MAX-1):
    s[i+1] = s[i] + a[i]
    
q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(s[r+1]-s[l])
### BUGGY CODE ###

K_S = input().split(" ")
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        for Z in range(int(K_S[0]) + 1):
            if (X + Y + Z) == int(K_S[1]):
                ans += 1

print(ans)
    

### FIXED CODE ###

K_S = input().split()
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        Z = int((K_S[1])) - X - Y
        if 0 <= Z & Z <= int(K_S[0]):
            ans += 1

print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
n, m, q = list(map(int, input().split()))
a, b, c, d = [0] * q, [0] * q, [0] * q, [0] * q

for i in range(q):
    a[i], b[i], c[i], d[i] = list(map(int, input().split()))
# Aは単調増加数列でNこの要素を持って最大でもMまで
ans = 0
locked_index = []
# dp = [0]*q
# dp[0] = d[0]
# for i in range(1, q):
#     # 普通に追加できるとき
#     if(a[i] in locked_index and b[i] in locked_index):

#     dp[i] = dp[i-1] + d[i]
#     locked_index.append(a[i])
#     locked_index.append(b[i])

max_point = 0

for i in range(2 ** q):
    ok_flg = True
    point = 0
    A = [1]*(n+1)
    locked_index = []
    saiyou = []
    for j in range(q):
        if ((i >> j) & 1):
            point += d[j]
            saiyou.append(j)
            A[b[j]] = A[a[j]] + c[j]
            if ((A[b[j]] > m)):
                ok_flg = False
                break
    # if(point == 357500):

    # ここで最終チェック
    for j in saiyou:
        if (A[b[j]] != A[a[j]] + c[j]):
            ok_flg = False

    # print(A, '\n', point)
    # print(saiyou)
    # print('==============')
    if max_point < point and ok_flg:
        max_point = point
print(max_point)
# A[b[i]] - A[a[i]] == c[i]


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import itertools

n, m, q = list(map(int, input().split()))
a, b, c, d = [0] * q, [0] * q, [0] * q, [0] * q

for i in range(q):
    a[i], b[i], c[i], d[i] = list(map(int, input().split()))
    a[i] -= 1
    b[i] -= 1
# Aは単調増加数列でNこの要素を持って最大でもMまで
ans = 0
for seq in itertools.combinations_with_replacement(range(m), n):
    tmp = 0
    for i in range(q):
        if seq[b[i]]-seq[a[i]] == c[i]:
            tmp += d[i]
    ans = max(ans, tmp)
print(ans)
### BUGGY CODE ###

f=lambda:map(int,input().split())
n,k=f()
l=sorted(f())
INF=10**18+1
from bisect import *
tl=bisect_left(l,0)
tr=bisect(l,0)
tm,tz,tp=tl,tr-tl,n-tr
cm=tm*tp
cz=tz*(n*2-tz-1)//2
cp=(tm*(tm-1)+tp*(tp-1))//2
lm=l[:tl]
lma=list(map(lambda x:-x,lm))[::-1]
lp=l[tr:]
if 0<k-cm<=cz:
  print(0)
elif k<=cm:
  l,r=-INF,0
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in lp:
      li,ri=-1,tm
      while ri-li>1:
        mi=(li+ri)//2
        if i*lm[mi]<m: li=mi
        else: ri=mi
      s+=ri
    if s<k: l=m
    else: r=m
  print(l)
else:
  l,r=0,INF
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in lma:
      li,ri=-1,tm
      while ri-li>1:
        mi=(li+ri)//2
        if i*lma[mi]<m: li=mi
        else: ri=mi
      s+=ri
      if i*i<m: s-=1
    for i in lp:
      li,ri=-1,tp
      while ri-li>1:
        mi=(li+ri)//2
        if i*lp[mi]<m: li=mi
        else: ri=mi
      s+=ri
      if i*i<m: s-=1
    if cm+cz+s//2<k: l=m
    else: r=m
  print(l)

### FIXED CODE ###

f=lambda:map(int,input().split())
n,k=f()
lm,lp=[],[]
for i in f():
  if i<0: lm.append(-i)
  else: lp.append(i)
lm.sort()
lp.sort()
cm=len(lm)
cp=len(lp)
def cnt(x):
  c=0
  if x<0:
    r=cp
    for i in lm:
      while r and i*lp[r-1]>=-x: r-=1
      c+=cp-r
    return c
  r=cm
  for i in lm:
    while r and i*lm[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  r=cp
  for i in lp:
    while r and i*lp[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  return cm*cp+c//2
INF=10**18+1
l,r=-INF,INF
while r-l>1:
  m=l+r>>1
  if cnt(m)<k: l=m
  else: r=m
print(r)
### BUGGY CODE ###

n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]
l = []
r = []
for i in range(m):
  l.append(lr[i][0])
  r.append(lr[i][1])
ans = 0
for i in range(1, n+1):
  if max(l) <= i <= min(r):
    ans += 1
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]
l = []
r = []
for i in range(m):
  l.append(lr[i][0])
  r.append(lr[i][1])
lm = max(l)
rm = min(r)
ans = 0
for i in range(1, n+1):
  if lm <= i <= rm:
    ans += 1
print(ans)
### BUGGY CODE ###

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

cnt=0

for i in range(a,b+1):
  if i%c!=0 and i%d!=0:
    cnt+=1

print(cnt)


### FIXED CODE ###

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

cyaku=b//c
dyaku=b//d


cds=b//((c*d)//(math.gcd(c,d)))

x=b-(cyaku+dyaku-cds)

cyaku2=(a-1)//c
dyaku2=(a-1)//d

cds2=(a-1)//((c*d)//(math.gcd(c,d)))

y=(a-1)-(cyaku2+dyaku2-cds2)

print(x-y)
### BUGGY CODE ###

import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    #n = int(stdin.readline().rstrip())
    n,m = map(int, stdin.readline().rstrip().split())
    x = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    if n>m:
        print(0)
        exit()
    spl = n-1
    sa = [0]*(m-1)
    x.sort()
    for i in range(m-1):
        sa[i] = x[i+1] - x[i]
    for i in range(spl):
        sa.pop(sa.index(max(sa)))
    print(sum(sa))



main()


### FIXED CODE ###

import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    #n = int(stdin.readline().rstrip())
    n,m = map(int, stdin.readline().rstrip().split())
    x = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    if n>m:
        print(0)
        exit()
    spl = n-1
    sa = [0]*(m-1)
    x.sort()
    for i in range(m-1):
        sa[i] = x[i+1] - x[i]
    sa.sort()
    i = m-n
    print(sum(sa[:i]))



main()
### BUGGY CODE ###

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

if max(a)-min(a)>=2:
    print("No")

elif max(a)-min(a)==0:
    count=0
    for i in range(N):
        if a[i]==N-1 or a[i]<=N//2:
            count+=1
    if count==N:
        print("Yes")
    else:
        print("No")
else:
    q=0
    p=0
    for i in range(N):
        if a[i]==max(a):
            q+=1
        elif a[i]==min(a):
            p+=1
    if p+q//2 >= max(a) and max(a)>=p+1:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
M=max(a)
m=min(a)

if M-m>=2:
    print("No")

elif M-m==0:
    count=0
    for i in range(N):
        if a[i]==N-1 or a[i]<=N//2:
            count+=1
    if count==N:
        print("Yes")
    else:
        print("No")
else:
    q=0
    p=0
    for i in range(N):
        if a[i]==M:
            q+=1
        elif a[i]==m:
            p+=1
    if p+q//2 >= max(a) and max(a)>=p+1:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

X = int(input())
ans = 100000000
def move(x, T):
    for i in range(T, 0, -1):
        if x >= i:
            x -= i
    if x == 0:
        return T
    else:
        return 100000000

for i in range(1, 50000):
    ans = min(ans, move(X, i))

print(ans)


### FIXED CODE ###

X = int(input())
ans = []
def move(x, T):
    for i in range(T, 0, -1):
        if x >= i:
            x -= i
    if x == 0:
        return T
    else:
        return 50000

for i in range(1, 45000):
    ans.append(move(X, i))

print(min(ans))
### BUGGY CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
d=0
for i in range(m):
    b,c=map(int,input().split())
    a+=[c]*b
    d+=b
a.sort()
a=a[d:]
print(sum(a))

### FIXED CODE ###

n,m=map(int,input().split())
*a,=map(int,input().split())
l=[list(map(int,input().split()))[::-1] for _ in range(m)]
a.sort()
d=[]
e=0
for c,b in sorted(l)[::-1]:
	d+=[c]*b
	e+=b
	if e>n:break
for i,(x,y) in enumerate(zip(a,d)):
	if x<y:a[i]=y
print(sum(a))
### BUGGY CODE ###

S = input()
old_answer = [1 for i in range(len(S))]
new_answer = [0 for i in range(len(S))]
for _ in range(1000000):
    new_answer = [0 for i in range(len(S))]
    for i in range(len(S)):
        if S[i] == "R":
            new_answer[i + 1] += old_answer[i]
        elif S[i] == "L":
            new_answer[i - 1] += old_answer[i]
    old_answer = new_answer
print(" ".join(map(str, new_answer)))

### FIXED CODE ###

S = input()

s_list = S.split("LR")
all_list = []

for idx, s in enumerate(s_list):
    if len(s_list) > 1:
        if idx != 0 and idx != len(s_list)-1:
            s = "R" + s + "L"
        elif idx == 0:
            s = s + "L"
        elif idx == len(s_list)-1:
            s = "R" + s
    s_len = len(s)
    R_count = s.count('R')
    L_count = s.count('L')
    R_list = [0 for _ in range(R_count)]
    L_list = [0 for _ in range(L_count)]

    if s_len % 2 == 0:
        R_list[R_count - 1] = s_len // 2
        L_list[0] = s_len // 2

    else:
        if R_count % 2 == 1:
            R_list[R_count - 1] = s_len - (s_len // 2)
            L_list[0] = s_len // 2
        else:
            R_list[R_count - 1] = s_len // 2
            L_list[0] = s_len - (s_len // 2)

    all_list.extend(R_list)
    all_list.extend(L_list)

print(" ".join(map(str, all_list)))