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

s=input()[::-1]
l=[0]*2019
sm=0
cnt=0
l[0]=1
for i in range(len(s)):
    sm += int(s[i])*(10**i)
    sm %= 2019
    cnt += l[sm]
    l[sm] += 1
print(cnt)

### FIXED CODE ###

from collections import deque
s=input()[::-1]
l=[0]*2019
ten=1
sm=0
cnt=0
l[0]=1
for i in range(len(s)):
    sm += int(s[i])*ten
    sm %= 2019
    cnt += l[sm]
    l[sm] += 1
    ten = ten *10 %2019
print(cnt)
### BUGGY CODE ###

import sys
N, P = list(map(int, input().split()))
M = int(P ** (1 / N)) + 1
for i in range(M, 0, -1):
    if P % (i ** N) == 0:
        print(i)
        sys.exit()


### FIXED CODE ###

import sys
N, P = list(map(int, input().split()))
M = int(P ** (1 / N) + 1.0E-7)
for i in range(M, 0, -1):
    if P % (i ** N) == 0:
        print(i)
        sys.exit()
### BUGGY CODE ###

n = int(input())
s = input()

min_change = n + 1
for i in range(n):
    temp_change = 0
    for j in range(i - 1):
        if s[j] == 'W':
            temp_change += 1
    for k in range(i + 1, n, 1):
        if s[k] == 'E':
            temp_change += 1
    if temp_change < min_change:
        min_change = temp_change

print(min_change)

### FIXED CODE ###

n = int(input())
s = input()

# 累積和を求めておく
cumsum_e = 0
cumsum_w = 0
for i in range(n):
    if s[i] == 'E':
        cumsum_e += 1
    else:
        cumsum_w += 1

min_change = n + 1
current_e = 0
current_w = 0
for i in range(n):
    temp_change = 0
    migi_e = cumsum_e - current_e
    if s[i] == 'E':
        migi_e -= 1
    temp_change = current_w + migi_e

    if temp_change < min_change:
        min_change = temp_change

    if s[i] == 'E':
        current_e += 1
    else:
        current_w += 1

print(min_change)
### BUGGY CODE ###

from numpy import cumsum 
n, m, q = list(map(int, input().split()))
lst = [[0]*n for i in range(n)]
for i in range(m):
    l, r = list(map(lambda x: int(x)-1, input().split()))
    lst[l][r] += 1
newlst = cumsum(lst, axis=1)
for i in range(q):
    a, b = list(map(lambda x: int(x)-1, input().split()))
    ans = sum([newlst[i][b] for i in range(a, b+1)])
    print(ans)

### FIXED CODE ###

from numpy import cumsum 
n, m, q = list(map(int, input().split()))
lst = [[0]*(n+1) for i in range(n+1)]
for i in range(m):
    l, r = list(map(int, input().split()))
    lst[l][r] += 1
ans1 = cumsum(lst, axis=1)
ans = cumsum(ans1, axis=0)
for i in range(q):
    a, b = list(map(int, input().split()))
    print(ans[b, b] - ans[a-1, b])
### BUGGY CODE ###

m = 998244353
def main():
    n,k = map(int,input().split())
    l,r = [],[]
    for _ in range(k):
        l_, r_ = map(int,input().split())
        l.append(l_)
        r.append(r_)

    dp = [0]*(n+1)
    dp[1] = 1
    dpsum = [0]*(n+1)
    dpsum[1] = 1

    for i in range(2,n+1):
        for j in range(k):
            li = i - r[j]
            ri = i - l[j]
            if ri < 0:
                continue
            li = max(li,1)
            dp[i] += dpsum[ri] - dpsum[li-1]
        dpsum[i] = dpsum[i-1]+dp[i]

    print(dp[n]%m)
main()

### FIXED CODE ###

m = 998244353
def main():
    n,k = map(int,input().split())
    l,r = [],[]
    for _ in range(k):
        l_, r_ = map(int,input().split())
        l.append(l_)
        r.append(r_)

    dp = [0]*(n+1)
    dp[1] = 1
    dpsum = [0]*(n+1)
    dpsum[1] = 1

    for i in range(2,n+1):
        for j in range(k):
            li = i - r[j]
            ri = i - l[j]
            if ri < 0:
                continue
            li = max(li,1)
            dp[i] += dpsum[ri] - dpsum[li-1]
        dpsum[i] = (dpsum[i-1]+dp[i])%m

    print(dp[n]%m)
main()
### BUGGY CODE ###

S= input()
q=int(input())

for i in range(q):
    a=input()


    if a[0]=="1":
        S=S[::-1]
    else:
        if a[2] == "1":
            S=a[4]+S
        else:
            S=S+a[4]

print(S)

### FIXED CODE ###

S= input()
q=int(input())
h=0
a=[]
for i in range(q):
    a.append(input())
t=""
w=""
for i in range(1,q+1):
    if a[q-i][0]=="2":
        if a[q - i][2] == "1":
            if h%2==0:
                t=t+a[q-i][4]
            else:
                w =  w+a[q - i][4]
        else:
            if h%2==0:
                w=w+a[q-i][4]
            else:
                t = t + a[q - i][4]
    else:
        h+=1
if h%2==0:
    print(t+S+w[::-1])
else:
    print(t+S[::-1]+w[::-1])
### BUGGY CODE ###

#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C&lang=jp
#??????
if __name__ == "__main__":
    n_line = int(input())
    input_list = [tuple(input().split()) for i in range(n_line)]
    l = []
    for c, s in input_list:
        if c == "insert":
            l.append(s)
        else:
            if s in l:
                print("yes")
            else:
                print("no")

### FIXED CODE ###

#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C&lang=jp
#??????
if __name__ == "__main__":
    n_line = int(input())
    input_list = [tuple(input().split()) for i in range(n_line)]
    l = set([])
    for c, s in input_list:
        if c == "insert":
            l.add(s)
        else:
            if s in l:
                print("yes")
            else:
                print("no")
### BUGGY CODE ###

import math
N,W = list(map(int, input().split(" ")))

items= [list(map(int, input().split(" "))) for _ in range(N)]


dp = [[0 for _ in range(W+1)] for _ in range(N + 1) ]
for w_sum in range(W + 1):
    for i in range(N):


        w,v = items[i]
        if w_sum - w >= 0:
            dp[i + 1][w_sum]  = dp[i][w_sum - w] + v
        # print(dp[i + 1][w],dp[i][w])
        a,b = dp[i + 1][w_sum],dp[i][w_sum]
        dp[i + 1][w_sum] = max(a,b)

print(dp[-1][-1])




### FIXED CODE ###

import math
N,W = list(map(int, input().split(" ")))

items= [list(map(int, input().split(" "))) for _ in range(N)]


dp = [[0 for _ in range(W+1)] for _ in range(N + 1) ]
for w_sum in range(W + 1):
    for i in range(N):


        w,v = items[i]
        if w_sum - w >= 0:
            dp[i + 1][w_sum]  = dp[i][w_sum - w] + v
        # print(dp[i + 1][w],dp[i][w])
        a,b = dp[i + 1][w_sum],dp[i][w_sum]
        dp[i + 1][w_sum] = max(a,b)

print(dp[-1][-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
ablist = [[] for _ in range(N)]
anslist = [0 for i in range(N)]

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

pxlist = [list(map(int,input().split())) for _ in range(Q)]

for q,x in pxlist:
    anslist[q-1] += x

def dfs(nownode,oya=-1):
    for nextnode in ablist[nownode]:
        if oya == nextnode:
            continue
        anslist[nextnode] += anslist[nownode]
        dfs(nextnode,nownode)
dfs(0,-1)
print(*anslist)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 

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

T = [[]for i in range(N)]

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

X = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x

# def dfs(x, p):
#     for j in T[x]:
#         if j == p:
#             continue
#         X[j] += X[x]
#         dfs(j, x)
def dfs(nownode,oya=-1):
    for nextnode in T[nownode]:
        if oya == nextnode:
            continue
        X[nextnode] += X[nownode]
        dfs(nextnode,nownode)

dfs(0, -1)

print(*X)
### BUGGY CODE ###

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

d = [0]*40
for a in A:
    for k in range(len(bin(a))-2):
        d[k] += min(a&2**k,1)

dd = [0]*41
for k in range(40):
    dd[k] = dd[k-1]+max(d[k],N-d[k])*2**k

dp = [0]*(40)

for k in range(40):
    if K&2**k == 0:
        dp[k] = dp[k-1]+d[k]*2**k
    else:
        dp[k] = max(dp[k-1]+(N-d[k])*2**k,dd[k-1]+d[k]*2**k)

print(dp[-1])

### FIXED CODE ###

from collections import defaultdict
N,K = map(int,input().split())
A = list(map(lambda x:bin(int(x))[2:],input().split()))
l = 0
for i in range(N):
    l = max(l,len(A[i]))
count = defaultdict(lambda:0)
for i in range(N):
    for j in range(len(A[i])):
        if A[i][-j-1] == '1':
            count[j] += 1
l = max(count.keys())

def rec(x):
    if x=='':
        return 0
    if '0' not in x:
        res = 0
        for i in range(len(x)):
            res += max(count[i],N-count[i])*2**i
        return res
    if x[0] == '1':
        return max(rec('1'*(len(x)-1))+count[len(x)-1]*2**(len(x)-1),rec(x[1:])+(N-count[len(x)-1])*2**(len(x)-1))
    else:
        return rec(x[1:])+count[len(x)-1]*2**(len(x)-1)
ans = rec(bin(K)[2:])
for i in range(len(bin(K)[2:]),l+1):
    ans += count[i]*2**i
print(ans)
### BUGGY CODE ###

N = int(input())
P = list(map(int,input().split()))
num = 0
for i in range(N):
    flag = 0
    for j in range(i):
        if P[i] > P[j]:
            flag = 1
    if flag == 0:
        num += 1
print(num)

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
num = 1
min_P = P[0]
for i in range(1,N):
    if P[i] < min_P:
        min_P = P[i]
        num += 1
print(num)
### BUGGY CODE ###

s = input()
Q = int(input())
flag = True  # flagがTrueのとき、偶数回数の反転が行われている
tmp = []
cnt = 0
for _ in range(Q):
    query = list(map(str, input().split()))
    # tmp.append(query)
    if len(query) == 1:  # 1のqueryのとき
        cnt += 1
        if flag:
            flag = False
        else:
            flag = True
    else:
        f, c = query[1], query[2]
        if f == "1":  # 先頭に追加するもの
            if flag:
                s = c + s  # 偶数回の反転なら素直に先頭に追加する
            else:
                s += c  # 奇数会の反転なら後ろに追加する
        else:  # 末尾に追加する
            if flag:
                s += c
            else:
                s = c + s

# 最後に反転が必要かどうか
# if flag:
#     cnt = 0
# else:
#     cnt = 1
# tmp.reverse()
# for t in tmp:
#     if len(t) == 1:
#         cnt += 1
#     else:
#         break
if cnt % 2 == 1 and cnt != 0:
    s = s[::-1]
print(s)


### FIXED CODE ###

s = input()
Q = int(input())
flag = True  # flagがTrueのとき、偶数回数の反転が行われている
cnt = 0
query = [list(map(str, input().split())) for _ in range(Q)]
before = []  # 先頭に追加する時
after = []  # 末尾に追加する時
for i in range(Q):
    a = query[i]
    if len(a) == 1:  # 1のqueryのとき
        cnt += 1
        if flag:
            flag = False
        else:
            flag = True
    else:
        f, c = a[1], a[2]
        if f == "1":  # 先頭に追加するもの
            if flag:
                # s = c + s  # 偶数回の反転なら素直に先頭に追加する
                before.append(c)
            else:
                # s += c  # 奇数会の反転なら後ろに追加する
                after.append(c)
        else:  # 末尾に追加する
            if flag:
                # s += c  # 末尾に追加
                after.append(c)
            else:
                # s = c + s  # 先頭に追加
                before.append(c)
before.reverse()
# print(before)
# print(s)
# print(after)
s = "".join(before) + s + "".join(after)
if cnt % 2 == 1 and cnt != 0:
    s = s[::-1]
print(s)
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
A = list(map(int , input().split()))
B = list(map(int , input().split()))
C = list(map(int , input().split()))
A = sorted(A,reverse = True)
B = sorted(B,reverse = True)
C = sorted(C,reverse = True)
AB = []
ABC = []
for i in A:
        for j in B:
                AB.append(i+j)
AB.sort(reverse = True)
AB = AB[:min(3001,x*y*z+1)]
for i in AB:
        for j in C:
                ABC.append(i+j)
ABC.sort(reverse = True)
for i in range(k):
        print(ABC[i])

### FIXED CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
### BUGGY CODE ###

from heapq import *

N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]

h = []
for i in range(N):
    heappush(h, (-B[i], i))

ans = 0
while h:
    b, i = heappop(h)
    b = -b
    if b == A[i]:
        continue
    B[i] -= B[i-1] + B[(i+1)%N]
    if B[i] < A[i]:
        print("-1")
        break
    heappush(h, (-B[i], i))
    ans += 1
else:
    print(ans)


### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
if N > 10000:
    A = A[5050:] + A[:5050]
    B = B[5050:] + B[:5050]
ans = -1

D = [0] * N
L = [i-1 for i in range(N)]
R = [i+1 for i in range(N)]

def calc():
    i = 0
    c = 0
    ans = 0
    while c < N:
        while i < N:
            if B[i] == A[i]:
                if D[i] == 0:
                    c += 1
                    D[i] = 1
                if L[i] >= 0: R[L[i]] = R[i]
                if R[i] < N: L[R[i]] = L[i]
            if B[i] > A[i] and B[i] >= max(B[i-1], B[(i+1)%N]):
                k = - (-(B[i] - max(B[i-1], B[(i+1)%N], A[i])) // (B[i-1] + B[(i+1)%N]))
                B[i] -= (B[i-1] + B[(i+1)%N]) * k
                ans += k
                if k <= 0:
                    return -1
            i = R[i]
        i = N-1
        while i >= 0:
            if B[i] == A[i]:
                if D[i] == 0:
                    c += 1
                    D[i] = 1
                if L[i] >= 0: R[L[i]] = R[i]
                if R[i] < N: L[R[i]] = L[i]
            if B[i] > A[i] and B[i] >= max(B[i-1], B[(i+1)%N]):
                k = - (-(B[i] - max(B[i-1], B[(i+1)%N], A[i])) // (B[i-1] + B[(i+1)%N]))
                B[i] -= (B[i-1] + B[(i+1)%N]) * k
                ans += k
                if k <= 0:
                    return -1
            i = L[i]
    return ans

print(calc())
### BUGGY CODE ###

a = list(map(int,input().split()))
b = []

for i in range(a[0],a[1]+1):
  for j in range(a[0],i):
    c = (i*j)%2019
    b.append(c)
else:
  print(min(b))

### FIXED CODE ###

a = list(map(int,input().split()))
b = []

if a[1]-a[0]>=2019:
  print(0)
else:
  for i in range(a[0],a[1]+1):
    for j in range(a[0],i):
      c = (i*j)%2019
      b.append(c)
  else:
    print(min(b))
### BUGGY CODE ###

n = int(input())
s = [input() for _ in range(n)]
result = 0
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
for i in range(n - 1):
  for j in range(i + 1, n):
    if s[i] == s[j]:
      result += 1
print(result)


### FIXED CODE ###

n = int(input())
s = [input() for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))
### BUGGY CODE ###

def reads(offset = 0):
	return [int(i) - offset for i in input().split(' ')]
(N, M) = reads()
Q = int(input())
A = reads(1)
pos = [-1] * M
pat = []
freq = [0] * (M+1)
freq[0] = N
counter = 0
for i in A[::-1]:
	if (i not in pat):
		pat.append(i)
		pos[i] = counter
		freq[counter] -= 1
		counter += 1
		freq[counter] += 1
	else:
		temp = pos[i]
		if (freq[temp] > 0):
			freq[temp] -= 1
			freq[temp+1] += 1
if(counter != M):
	for i in range(M):
		if (i not in pat):
			pat.append(i)
for i in range(M):
	if (freq[i] != 0):
		start = i
		break
p = pat[start:]
p.sort()
if(p == pat[start:]):
	print("Yes")
else:
	print("No")

### FIXED CODE ###

def reads(offset = 0):
	return [int(i) - offset for i in input().split(' ')]
def Judge(vector):
	length = len(vector)-1
	for i in range(length):
		if(vector[i] > vector[i+1]):		
			return 0
	return 1
(N, M) = reads()
Q = int(input())
A = reads(1)
pos = [-1] * M
pat = []
freq = [0] * (M+1)
freq[0] = N
found = set()
counter = 0
for i in A[::-1]:
	if (i not in found):
		pat.append(i)
		found.add(i)
		pos[i] = counter
		counter += 1
		if(counter == M):
			break
for i in range(M):
	if (pos[i] == -1):
		pat.append(i)	
for i in A[::-1]:
	temp = pos[i]
	if (freq[temp] > 0):
		freq[temp] -= 1
		freq[temp+1] += 1
start = M
for i in range(M):
	if (freq[i] != 0):
		start = i
		break
print("Yes") if Judge(pat[start:]) else print("No")
### BUGGY CODE ###

n=int(input())
lists1=sorted(list(map(int,input().split())))
lists2=sorted(list(map(int,input().split())))
lists3=sorted(list(map(int,input().split())),reverse=True)
lists_small=[]
lists_big=[]
for x in lists2:
    numbers=0
    for y in lists1:
        if y<x:
            numbers+=1
            if numbers==n:
                lists_small.append(numbers)
                break
            else:
                continue
        else:
            lists_small.append(numbers)
            break

for z in lists2:
    numbers=0
    for w in lists3:
        if w>z:
            numbers+=1
            if numbers==n:
                lists_big.append(numbers)
                break
            else:
                continue
        else:
            lists_big.append(numbers)
            break

ans=0
for _ in range(n):
    ans+=lists_small[_]*lists_big[_]
print(ans)
    

### FIXED CODE ###

n=int(input())
lists1=sorted(list(map(int,input().split())))+[10**9+1]

lists2=sorted(list(map(int,input().split())))+[10**9+2]
lists3=sorted(list(map(int,input().split())))+[10**9+3]
lists_small=[0]*(n+1)
lists_big=[0]*(n+1)

numbers=0
for x in range(n):
    while lists1[numbers]<lists2[x]:
        numbers+=1
    lists_small[x]=numbers


numberss=0
for y in range(n):
    while lists3[numberss]<=lists2[y]:
        numberss+=1
    changes=n-numberss
    lists_big[y]=changes



ans=0
for xy in range(n):
    ans+=lists_big[xy]*lists_small[xy]
print(ans)
### BUGGY CODE ###

import sys
from collections import deque

H,W=map(int,input().split())
si,sj=[int(x)-1 for x in input().split()]
ti,tj=[int(x)-1 for x in input().split()]
A=list(sys.stdin)

dirs=[-2,-1,0,1,2]
dist=[[float('inf')]*W for _ in range(H)]
dist[si][sj]=0
dq=deque()
dq.append((0,si,sj))
ok=False
while dq:
    k,i,j=dq.popleft()
    if i==ti and j==tj:
        ok=True
        break
    for di in dirs:
        for dj in dirs:
            if di==dj==0:
                continue
            ni,nj=i+di,j+dj
            if not (0<=ni<H and 0<=nj<W):
                continue
            if A[ni][nj]=='#':
                continue
            if abs(di)+abs(dj)==1:
                append=dq.appendleft
                nk=k
            else:
                append=dq.append
                nk=k+1
            if k>=dist[ni][nj]:
                continue
            dist[ni][nj]=nk
            append((nk,ni,nj))
      
if ok:
    ans=dist[ti][tj]
else:
    ans=-1

print(ans)


### FIXED CODE ###

import sys
from heapq import *

H,W=map(int,input().split())
si,sj=[int(x)-1 for x in input().split()]
ti,tj=[int(x)-1 for x in input().split()]
A=list(sys.stdin)

ans=-1
hp=[(0,si,sj)]
dirs=[-2,-1,0,1,2]
dist=[[float('inf')]*W for _ in range(H)]
dist[si][sj]=0
while hp:
    k,i,j=heappop(hp)
    if i==ti and j==tj:
        ans=k
        break
    if k>dist[i][j]:
        continue
    for di in dirs:
        for dj in dirs:
            if di==dj==0:
                continue
            ni,nj=i+di,j+dj
            if not (0<=ni<H and 0<=nj<W):
                continue
            if A[ni][nj]=='#':
                continue
            if abs(di)+abs(dj)==1:
                nk=k
            else:
                nk=k+1
            if nk>=dist[ni][nj]:
                continue
            dist[ni][nj]=nk
            heappush(hp,(nk,ni,nj))

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


if __name__ == "__main__":
    n, q = map(int, input().split())
    incidenceGraph = [[] for j in range(0, n)]
    for i in range(0, n - 1):
        a, b = map((lambda x: int(x) - 1), input().split())
        incidenceGraph[a].append(b)
        incidenceGraph[b].append(a)

    operationTuples = [0]*n
    ans = [0]*n
    for i in range(0, q):
        p, x = map(int, input().split())
        operationTuples[p-1] += x

    visited = [False]*n
    stack = [0]
    while stack:
        i = stack.pop(0)
        ans[i] += operationTuples[i]
        visited[i] = True
        for j in incidenceGraph[i]:
            if visited[j] is False:
                ans[j] += ans[i]
                stack.append(j)
    print(*ans)

### FIXED CODE ###

from collections import deque

if __name__ == "__main__":
    n, q = map(int, input().split())
    incidenceGraph = [[] for j in range(0, n)]
    for i in range(0, n - 1):
        a, b = map((lambda x: int(x) - 1), input().split())
        incidenceGraph[a].append(b)
        incidenceGraph[b].append(a)

    operationTuples = [0]*n
    ans = [0]*n
    for i in range(0, q):
        p, x = map(int, input().split())
        operationTuples[p-1] += x

    visited = [False]*n
    stack = deque([0])
    while stack:
        i = stack.popleft()
        ans[i] += operationTuples[i]
        visited[i] = True
        for j in incidenceGraph[i]:
            if visited[j] is False:
                ans[j] += ans[i]
                stack.append(j)
    print(*ans)
### BUGGY CODE ###

#!/usr/bin/env python3
# coding: utf-8
# import pprint
# import numpy as np
# import code
import functools

def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        debug = lambda *x: None
        print(arg, file=sys.stderr)

n, x, y = (int(x) for x in input().split())
d = dict.fromkeys(range(1, n), 0)
debug(d)
for i in range(1, n):
    for j in range(i + 1, n + 1):
        debug([i, j, x, y])
        dd1=abs(x - i) + 1 + abs(y - j)
        dd2= j - i
        d[min(dd1, dd2)] += 1
        debug(d)

for k in sorted(d.keys()):
    print(d[k])


### FIXED CODE ###

#!/usr/bin/env python3
# coding: utf-8
# import pprint
# import numpy as np
# import code
import functools

if __debug__:
    def debug(arg):
        pass
else:
    import sys
    def debug(arg):
        debug = lambda *x: None
        print(arg, file=sys.stderr)

n, x, y = (int(x) for x in input().split())
d = dict.fromkeys(range(1, n), 0)
debug(d)
for i in range(1, n):
    for j in range(i + 1, n + 1):
        debug([i, j, x, y])
        dd1=abs(x - i) + 1 + abs(y - j)
        dd2= j - i
        if dd1 < dd2:
            d[dd1] += 1
        else:
            d[dd2] += 1
        debug(d)

for n in d.values():
    print(n)
### BUGGY CODE ###

n,m = map(int, input().split())
a = list(map(int, input().split()))
sub = [0]
a.sort()
for i in range (m):
    if (len(a) != 0):
        if (a[-1] >= sub[-1]):
            x =a.pop()
            sub.insert(1,x//2)
        else:
            x =sub.pop()
            sub.insert(1,x//2)
    else:
        x =sub.pop()
        sub.insert(1,x//2)
print(sum(a)+sum(sub))
        

### FIXED CODE ###

from collections import deque
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
p = a.pop()
sub = deque([p//2])
for i in range (m-1):
    if (len(a) != 0):
        if (a[-1] >= sub[-1]):
            x =a.pop()
            sub.appendleft(x//2)
        else:
            x =sub.pop()
            sub.appendleft(x//2)
    else:
        x =sub.pop()
        sub.appendleft(x//2)
print(sum(a)+sum(sub))
### BUGGY CODE ###

n=int(input())
a=[[0 for i in range(2)] for j in range(n)]
for i in range(n):
    a[i][1],a[i][0]=map(int,input().split())
b=sorted(a)
c=[b[i][1] for i in range(n)]
ans="Yes"
for i in range(n):
    if b[i][0]<sum(c[:i+1]):
        ans="No"
        break
print(ans)

### FIXED CODE ###

n=int(input())
# a=[[0]*2]*n
a=[[0 for i in range(2)] for j in range(n)]
for i in range(n):
    a[i][1],a[i][0]=map(int,input().split())
b=sorted(a)
c=[b[i][1] for i in range(n)]
ans="Yes"
d=0
for i in range(n):
    d+=c[i]
    if b[i][0]<d:
        ans="No"
        break
print(ans)