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

n, d, a = map(int, input().split())
lst = []
for i in range(n):
    xi, hi = map(int, input().split())
    if hi % a == 0:
        hi = hi // a
    else:
        hi = hi // a + 1
    lst.append([xi, hi])
lst.sort(key=lambda x: x[0])
x, h = [], []
for i in range(n):
    x.append(lst[i][0])
    h.append(lst[i][1])

x.append(10**11)
h.append(0)

# 攻撃に巻き込めるインデックスを求める
left = 0 # 可能
right = n # 不可能
while left+1 < right:
    mid = (left + right) // 2
    if x[mid] - x[0] <= 2*d:
        left = mid
    else:
        right = mid
makikomi = [left]
right = left
for i in range(1, n):
    while x[right] - x[i] <= 2*d:
        right += 1
    right -= 1
    makikomi.append(right)

cnt = 0
for i in range(n):
    if h[i] > 0:
        cnt += h[i]
        hiku = h[i]
        for j in range(i, makikomi[i]+1):
            h[j] -= hiku

print(cnt)

### FIXED CODE ###

n, d, a = map(int, input().split())
lst = []
for i in range(n):
    xi, hi = map(int, input().split())
    if hi % a == 0:
        hi = hi // a
    else:
        hi = hi // a + 1
    lst.append([xi, hi])
lst.sort(key=lambda x: x[0])
x, h = [], []
for i in range(n):
    x.append(lst[i][0])
    h.append(lst[i][1])

x.append(10**11)
h.append(0)

# 攻撃に巻き込めるインデックスを求める
left = 0 # 可能
right = n # 不可能
while left+1 < right:
    mid = (left + right) // 2
    if x[mid] - x[0] <= 2*d:
        left = mid
    else:
        right = mid
makikomi = [left]
right = left
for i in range(1, n):
    while x[right] - x[i] <= 2*d:
        right += 1
    right -= 1
    makikomi.append(right)

cnt = [0 for i in range(n)]
left = 0
already = 0
for i in range(n):
    while x[makikomi[left]] < x[i]:
        already -= cnt[left]
        left += 1
    cnt[i] = max(h[i] - already, 0)
    already += cnt[i]

print(sum(cnt))
### BUGGY CODE ###

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

num_without_s = m/4
num_with_s = 0
m_tmp = m
n_tmp = n
while m_tmp > 1 and n_tmp > 0:
    num_with_s += 1
    m_tmp = m_tmp - 2
    n_tmp = n_tmp - 1

if m_tmp > 3:
    num_with_s = num_with_s + int(m_tmp / 4)

if num_with_s > num_without_s:
    print(int(num_with_s))
else:
    print(int(num_without_s))
    

### FIXED CODE ###

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

num_without_s = m/4
num_with_s = 0
m_tmp = m
n_tmp = n
""" while m_tmp > 1 and n_tmp > 0:
    num_with_s += 1
    m_tmp = m_tmp - 2
    n_tmp = n_tmp - 1
 """

if m >= (2 * n):
    num_with_s = n
    if (m_tmp - 2*n) > 3:
        num_with_s = num_with_s + int(((m_tmp - 2*n) / 4))
else:
    num_with_s = int(m/2)

if num_with_s > num_without_s:
    print(int(num_with_s))
else:
    print(int(num_without_s))
### BUGGY CODE ###

import itertools

n = int(input())
l = tuple(map(int, input().split()))
total = 0
mod = 1000000007
L = itertools.combinations(l, 2)
for a,b in L:
    total += ((a % mod) * (b % mod)) % mod
print(total % mod)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
mod = 1000000007
q = sum(l)
ans = 0
for i in range(len(l)):
    q -= l[i]
    ans += l[i] * q % mod
print(ans % mod)
### BUGGY CODE ###

n = int(input())
s = [str(input()) for _ in range(n)]
ans = 0
for i in range(n):
    s[i] = "".join(sorted(s[i]))
    # print(s[i])


for i in range(n):
    for j in range(i,):
        if s[i] == s[j]:
            ans += 1

print(ans)


### 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 ###

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

INF = 10 ** 18

h = H + [0] * K
dp = [INF] * (N + K)
dp[0] = 0

for n in range(N):
	for k in range(1, K + 1):
		l, r = n, n + k
		dp[r] = min(dp[r], dp[l] + abs(h[l] - h[r]))
print(dp[N - 1])


### FIXED CODE ###

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

INF = 10 ** 18

h = H
dp = [0] * N

for n in range(1, N):
	l, r = max(0, n - K), n
	dp[n] = min([dpl + abs(hl - h[r]) for dpl, hl in zip(dp[l:r], h[l:r])])
	#print(dp)
print(dp[N - 1])
### BUGGY CODE ###

#!python3

iim = lambda: map(int, input().rstrip().split())

from bisect import bisect

def resolve():
    def find(i):
        x = S[i]
        while True:
            k = S[i][0]
            if k == i:
                x[0] = i
                return i
            S[i] = x
            i = k
    def join(i, j):
        ai = find(i)
        aj = find(j)
        if ai != aj:
            #S[aj][0] = S[ai][0]
            S[aj] = S[ai]
    def same(i, j):
        ai = find(i)
        aj = find(j)
        return ai == aj

    N, M, K = iim()
    S = [[i] for i in range(N+1)]
    mk = [set() for i in range(N+1)]
    for i in range(M):
        ai, bi = iim()
        if ai > bi:
            ai, bi = bi, ai
        join(ai, bi)
        mk[ai].add(bi)
    for i in range(K):
        ai, bi = iim()
        if ai > bi:
            ai, bi = bi, ai
        mk[ai].add(bi)

    ans = [0] * (N+1)
    #print(S)
    for i in range(1, N):
        aa = 0
        mki = mk[i]
        for j in range(i+1, N+1):
            if j in mki:
                continue
            if same(i, j):
                ans[i] += 1
                ans[j] += 1
    print(*ans[1:])


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

iim = lambda: map(int, input().rstrip().split())

from bisect import bisect

def resolve():
    def find(i):
        x = S[i]
        if x < 0:
            return i
        S[i] = find(x)
        return S[i]

    def join(i, j):
        ai = find(i)
        aj = find(j)
        diff = ai - aj
        #print("j", ai, aj)
        if diff == 0:
            return
        elif diff > 0:
            ai, aj = aj, ai
        S[ai] += S[aj]
        S[aj] = ai
    def same(i, j):
        ai = find(i)
        aj = find(j)
        return ai == aj
    def size(i):
        return -S[find(i)]

    N, M, K = iim()
    S = [-1] * N
    T = [1] * N
    for i in range(M):
        ai, bi = iim()
        ai -= 1; bi -= 1
        join(ai, bi)
        T[ai] += 1
        T[bi] += 1
        #print(ai, bi, S)

    U = [set() for i in range(N)]
    for i in range(K):
        ai, bi = iim()
        ai -= 1; bi -= 1
        U[ai].add(bi)
        U[bi].add(ai)
    #print(S)
    #print(T)

    ans = [size(i) - T[i] - sum(same(i, j) for j in U[i]) for i in range(N)]
    print(*ans)


if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

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

count = [0] * (max(A)+1)
for i in range(len(A)):
    a = A[i]
    
    if count[a] != 0:
        count[a] = 2
        continue

    for j in range(a, max(A)+1, a):
        count[j] += 1

ans = 0
for i in range(len(A)):
    a = A[i]
    if count[a] == 1:
        ans += 1

print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]
num = set(A)
count = Counter(A)
dp = [True] * (10**6 + 1)

for a in num:
    for n in range(a+a, 10**6+1, a):
        dp[n] = False

ans = 0
for a in num:
    if count[a] == 1 and dp[a] == True:
        ans += 1

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

def readinput():
    n=int(input())
    x=input()
    return n,x

def popcount(x):
    return bin(x).count('1')

def f(x):
    #print('f(x), x: {}'.format(x))
    if x==0:
        return 0
    else:
        ans=f(x%popcount(x))+1
        #print(ans)
        return ans    

def main(n,x):
    m=x.count('1')
    #print('m: {}'.format(m))
    xint=int(x,2)
    #print('xint: {}'.format(xint))
    ans=[]
    b=2**(n-1)
    for i in range(n):
        if x[i]=='1':
            if m==1:
                ans.append(0)
            else:
                xx=(xint-b)%(m-1)
                ans.append(f(xx)+1)
        else:
            xx=(xint+b)%(m+1)
            ans.append(f(xx)+1)
        b=b//2
    return ans

if __name__=='__main__':
    n,x=readinput()
    ans=main(n,x)
    for a in ans:
        print(a)



### FIXED CODE ###

def readinput():
    n=int(input())
    x=input()
    return n,x

poptbl=[0]*(2*10**5+1)
def popcount(x):
    global poptbl
    if poptbl[x]!=0:
        return poptbl[x]
    
    poptbl[x]=bin(x).count('1')
    return poptbl[x]

ftbl=[0]*(2*10**5+1)
def f(x):
    global ftbl

    if ftbl[x]!=0:
        return ftbl[x]
    
    #print('f(x), x: {}'.format(x))
    if x==0:
        return 0
    else:
        ans=f(x%popcount(x))+1
        #print(ans)
        ftbl[x]=ans
        return ans    

def main():
    n=int(input())
    x=input()
    m=x.count('1')
    #print('m: {}'.format(m))
    xint=int(x,2)
    #print('xint: {}'.format(xint))
    if m!=1:
        xmodm1=xint%(m-1)
    else:
        xmodm1=1
    xmodp1=xint%(m+1)
    pow2mod1=[0]*n
    pow2mod2=[0]*n
    pow2mod1[0]=1
    pow2mod2[0]=1
    for i in range(1,n):
        if m!=1:
            pow2mod1[i]=pow2mod1[i-1]*2 % (m-1)
        pow2mod2[i]=pow2mod2[i-1]*2 % (m+1)

    ans=[]
    #b=2**(n-1)
    for i in range(n):
        if x[i]=='1':
            if m==1:
                a=0
                ans.append(a)
            else:
                xx=( xmodm1 + (m-1) -pow2mod1[n-i-1] )%(m-1)
                #ans.append(f(xx)+1)
                a=f(xx)+1
                ans.append(a)
        else:
            xx=( xmodp1 + pow2mod2[n-i-1] )%(m+1)
            #ans.append(f(xx)+1)
            a=f(xx)+1
            ans.append(a)
        #b=b//2
        print(a)
    return ans

if __name__=='__main__':
    #n,x=readinput()
    ans=main()
    #for a in ans:
    #    print(a)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N = int(input())
P = list(map(lambda x:int(x)-1,input().split()))

costs = [0]*(N*N)
for i in range(N):
    for j in range(N):
        costs[i*N+j] = min(i,j,N-1-i,N-1-j)
exist = [1]*(N*N)

from collections import deque
dxs = [0,1,0,-1]
dys = [1,0,-1,0]

ans = 0
for p in P:
    ans += costs[p]
    exist[p] = 0
    q = deque([p])
    while q:
        p = q.popleft()
        y,x = divmod(p,N)
        for dx,dy in zip(dxs,dys):
            nx,ny = x+dx,y+dy
            if not 0 <= nx < N: continue
            if not 0 <= ny < N: continue
            np = ny*N + nx
            if costs[np] > costs[p] + exist[p]:
                costs[np] = costs[p] + exist[p]
                q.append(np)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
P = list(map(lambda x:int(x)-1,input().split()))

costs = [0]*(N*N)
for i in range(N):
    for j in range(N):
        costs[i*N+j] = min(i,j,N-1-i,N-1-j)
exist = [1]*(N*N)

from collections import deque
ans = 0
for p in P:
    ans += costs[p]
    exist[p] = 0
    q = deque([p])
    while q:
        p = q.popleft()
        y,x = divmod(p,N)
        if x < N-1:
            np = p + 1
            if costs[np] > costs[p] + exist[p]:
                costs[np] = costs[p] + exist[p]
                q.append(np)
        if x > 0:
            np = p - 1
            if costs[np] > costs[p] + exist[p]:
                costs[np] = costs[p] + exist[p]
                q.append(np)
        if y < N-1:
            np = p + N
            if costs[np] > costs[p] + exist[p]:
                costs[np] = costs[p] + exist[p]
                q.append(np)
        if y > 0:
            np = p - N
            if costs[np] > costs[p] + exist[p]:
                costs[np] = costs[p] + exist[p]
                q.append(np)
print(ans)
### BUGGY CODE ###

N,K=list(map(int,input().split()))
hcost=list(map(int,input().split()))
hcost=[0]+hcost
dp=[0]*(N+1)

for i in range(2,N+1):
  dp[i]=dp[i-1]+abs(hcost[i-1]-hcost[i])
  for k in range(K+1):
    if i-k > 0:
      dp[i]=min(dp[i],dp[i-k]+abs(hcost[i-k]-hcost[i]))
print(dp[N])      

### FIXED CODE ###

N,K= list(map(int,input().split()))
hc=list(map(int,input().split()))
dp=[0]*N
for i in range(1,N):
  li=[abs(hc[i]-hc[j])+dp[j] for j in range( max(i-K,0),i) ]
  dp[i]=min(li)
print(dp[-1])
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(a, b, c)

print(ans)
            

### FIXED CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(a, b, c)

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

from collections import deque
def main():
    h, w = map(int, input().split())
    S = list(map(lambda x: int(x) - 1, input().split()))
    G = list(map(lambda x: int(x) - 1, input().split()))
    A = [list(input()) for _ in range(h)]
    INF = 100000000
    score = [[INF] * w for _ in range(h)]
    score[S[0]][S[1]] = 0
    visited = [[False] * w for _ in range(h)]
    stack = deque([S])
    dxy = [[1, 0], [-1, 0], [0, -1], [0, 1]]
    while stack:
        y, x = stack.popleft()
        if visited[y][x]:
            continue
        else:
            visited[y][x] = True
        count = 0
        for dx, dy in dxy:
            X = x + dx
            Y = y + dy
            if Y < 0 or Y >= h or X < 0 or X >= w:
                continue
            elif A[Y][X] == '.':
                stack.appendleft([Y, X])
                score[Y][X] = min(score[Y][X], score[y][x])
        if count == 0 and A[y][x] == '.':
            for i in range(-2, 3):
                for j in range(-2, 3):
                    X = x + j
                    Y = y + i
                    if Y < 0 or Y >= h or X < 0 or X >= w:
                        continue
                    if A[Y][X] == '.':
                        stack.append([Y, X])
                        score[Y][X] = min(score[Y][X], score[y][x] + 1)
    print(s) if (s := score[G[0]][G[1]]) != INF else print(-1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import deque
def main():
    h, w = map(int, input().split())
    S = list(map(lambda x: int(x) - 1, input().split()))
    G = list(map(lambda x: int(x) - 1, input().split()))
    A = [list(input()) for _ in range(h)]
    INF = 100000000
    score = [[INF] * w for _ in range(h)]
    score[S[0]][S[1]] = 0
    visited = [[False] * w for _ in range(h)]
    stack = deque([S])
    dxy = [[1, 0], [-1, 0], [0, -1], [0, 1]]
    while stack:
        y, x = stack.popleft()
        if visited[y][x]:
            continue
        else:
            visited[y][x] = True
        count = 0
        for dx, dy in dxy:
            X = x + dx
            Y = y + dy
            if Y < 0 or Y >= h or X < 0 or X >= w:
                continue
            elif A[Y][X] == '.':
                stack.appendleft([Y, X])
                score[Y][X] = min(score[Y][X], score[y][x])
        if count == 0 and A[y][x] == '.':
            for i in range(-2, 3):
                for j in range(-2, 3):
                    X = x + j
                    Y = y + i
                    if Y < 0 or Y >= h or X < 0 or X >= w:
                        continue
                    if A[Y][X] == '.' and score[Y][X] > score[y][x] + 1:
                        stack.append([Y, X])
                        score[Y][X] = min(score[Y][X], score[y][x] + 1)
    print(score[G[0]][G[1]]) if score[G[0]][G[1]] != INF else print(-1)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

h,n = map(int,input().split())
a=[0]*n
b=[0]*n

MAX_HP = 10**4
MAX_HP = h
for i in range(n):
  ta,tb = map(int,input().split())
  a[i] = ta
  b[i] = tb

INF = 10**9

dp = [[INF]*(h+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
  for j in range(h+1):    
    dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    dp[i+1][min(j+a[i],h)] = min(dp[i+1][min(j+a[i],h)], dp[i+1][j] + b[i])    

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

### FIXED CODE ###

h,n = map(int,input().split())
a=[0]*n
b=[0]*n

MAX_HP = 10**4
MAX_HP = h
for i in range(n):
  ta,tb = map(int,input().split())
  a[i] = ta
  b[i] = tb

INF = 10**9

dp = [[INF]*(h+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
  for j in range(h+1):    
    dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    dp[i+1][min(j+a[i],h)] = min(dp[i+1][min(j+a[i],h)], dp[i+1][j] + b[i])    

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

x=input().split()
n=int(x[0])
k=int(x[1])
def fast_expo(b,n,p):
    if n==0:
        return 1
    if n==1:
        return b%p
    if n%2==0:
        return fast_expo(((b%p)*(b%p))%p,n//2,p)
    else:
        return (b*fast_expo(((b%p)*(b%p))%p,n//2,p))%p
def combi(n,p):
    X=1
    Y=1
    Z=[1]*(n+1)
    for i in range(n):
        X=(X*(n-i))%p
        Y=(Y*(i+1))%p
        Z[i+1]=(X*fast_expo(Y,p-2,p))%p
    return Z 

p=10**9+7
s=0
L=min(n,k+1)
Z1=combi(n,p)
Z2=combi(n-1,p)
for i in range(L):
  s=(s+(Z1[i]*Z2[i])%p)%p
print(s)  


### FIXED CODE ###

x=input().split()
n=int(x[0])
k=int(x[1])
def fact_inverse(n,p):
    fact=[1]*(n+1)
    inv=[1]*(n+1)
    inv_fact=[1]*(n+1)
    inv[0]=0
    inv_fact[0]=0
    for i in range(2,n+1):
        fact[i]=(fact[i-1]*i)%p
        #compute the inverse of i mod p
        inv[i]=(-inv[p%i]*(p//i))%p
        inv_fact[i]=(inv_fact[i-1]*inv[i])%p
    return fact,inv_fact    
    

def combi2(n,p):
    f,inv=fact_inverse(n,p)
    combis=[1]*(n+1)
    for k in range(1,n+1):
        if k >=n//2+1:
            combis[k]=combis[n-k]
        else:
            combis[k]=(((f[n]*inv[n-k])%p)*inv[k])%p
    return combis    
      
    
p=10**9+7
combis1=combi2(n,p)
combis2=combi2(n-1,p)
s=0
L=min(n,k+1)
for i in range(L):
  s=(s+(combis1[i]*combis2[i])%p)%p
print(s)
### BUGGY CODE ###

n, m = [ int(v) for v in input().split() ]
a_list = list(set([ int(v) for v in input().split() ]))

def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a
def lcm(a,b):
	return a * b // gcd(a,b)

def p2(x):
    ans = 0
    while x % 2 == 0:
        ans += 1
        x //= 2
    return ans

n = len(a_list)

p2_list = [p2(i) for i in a_list]

p2_set = set(p2_list)
if len(p2_set) != 1:
    print(0)
else:
    p = 1
    for i in a_list:
        p = lcm(p, i//2)

    if p > m:
        print(0)
    else:
        m -= p
        print(m//(p*2)+1)

### FIXED CODE ###

n, m = [ int(v) for v in input().split() ]
a_list = [ int(v) for v in input().split() ]

def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a
def lcm(a,b):
	return a * b // gcd(a,b)

def p2(x):
    ans = 0
    while x % 2 == 0:
        ans += 1
        x //= 2
    return ans

n = len(a_list)

p2_list = [p2(i) for i in a_list]

p2_set = set(p2_list)
if len(p2_set) != 1:
    print(0)
else:
    p = 1
    for i in a_list:
        p = lcm(p, i//2)
        if p > m:
            print(0)
            break
    if p <= m:
        m -= p
        print(m//(p*2)+1)
### BUGGY CODE ###

x,y = map(int, input().split())

while True:

    if x == 0 and y == 0 : break

    list = [x, y]
    print(sorted(list, reverse=True))
       


### FIXED CODE ###

while True:
    x,y = map(int, input().split())

    if x == 0 and y == 0:
        break

    elif x <= y:
        print(str(x) + " " + str(y))
    else:
        print(str(y) + " " + str(x))
### BUGGY CODE ###

N = 10**9+7

s = input()
l = len(s)
dp=[[0]*13 for i in range(l+1)]
dp[0][0]=1

c = 1
for i in range(l):
    x = s[-1-i]
    if x == '?':
        for k in range(10):
            for j in range(13):
                dp[i+1][(k*c+j)%13]+=dp[i][j]
                dp[i+1][(k*c+j)%13]%=N
    else:
        k = int(x)
        for j in range(13):
            dp[i+1][(k*c+j)%13]+=dp[i][j]
            dp[i+1][(k*c+j)%13]%=N
    c*=10
    c%=13
print(dp[l][5])


### FIXED CODE ###

N = 10**9+7

s = input()
l = len(s)
dp=[[0]*13 for i in range(l+1)]
dp[0][0]=1

c = 1
for i in range(l):
    x = s[-1-i]
    if x == '?':
        for k in range(10):
            for j in range(13):
                dp[i+1][(k*c+j)%13]+=dp[i][j]
                dp[i+1][(k*c+j)%13]%=N
    else:
        k = int(x)
        for j in range(13):
            dp[i+1][(k*c+j)%13]+=dp[i][j]
            dp[i+1][(k*c+j)%13]%=N
    c*=10
    c%=13
print(dp[l][5])
### BUGGY CODE ###

import sys 
import collections as cl

N=int(input())
A=list(map(int,sys.stdin.readline().split()))
c=cl.Counter(A)
NumberTupleList=c.most_common()
NumberList=[x[1] for x in NumberTupleList[::-1]]
LengthOfNumberList=len(NumberList)
FormulaList=[sum([min(NumberList[i],x) for i in range(LengthOfNumberList)])/x for x in range(1,N+1)]

pin=N-1
for K in range(1,N+1):
    while pin>=0 and K>FormulaList[pin]:
        pin-=1
    print(pin+1)


### FIXED CODE ###

import sys 
import collections as cl


N=int(input())
A=list(map(int,sys.stdin.readline().split()))
c=cl.Counter(A)
NumberTupleList=c.most_common()
NumberList=[x[1] for x in NumberTupleList[::-1]]
LengthOfNumberList=len(NumberList)
FormulaList=[0 for i in range(N)]
flag=0
S=sum(NumberList)
for x in range(1,N+1):
    while flag<LengthOfNumberList and NumberList[flag]<=x:
        flag+=1
    if flag<LengthOfNumberList:
        FormulaList[x-1]=(sum(NumberList[:flag])+x*(LengthOfNumberList-flag))/x
    else:
        FormulaList[x-1]=S/x
pin=N-1
for K in range(1,N+1):
    while pin>=0 and K>FormulaList[pin]:
        pin-=1
    print(pin+1)
### BUGGY CODE ###

S = input().rstrip()
Q = int(input().rstrip())
for _ in range(Q):
    stdin = input().rstrip()
    if int(stdin[0]) == 1:
        S = S[::-1]
    else:
        T,F,C = stdin.split()
        if int(F) == 1:
            S = C + S
        else:
            S = S + C
print(S)

### FIXED CODE ###

S = input().rstrip()
Q = int(input().rstrip())
a = -1
before =[]
after =[]
for _ in range(Q):
    stdin = input().rstrip()
    if int(stdin[0]) == 1:
        a = ~a
    else:
        T,F,C = stdin.split()
        if int(F) == 2+a:
            before.append(C)
        else:
            after.append(C)
S = ''.join(before)[::-1] + S + ''.join(after)
if a == 0:
    S = S[::-1]
print(S)
### BUGGY CODE ###

import sys

N = int(input())
num_line  =[]
for e in map(int, sys.stdin):
    num_line.append(e)
for i in range(N):
    save_num = num_line[i]
    num_line.pop(i)
    print(max(num_line))
    num_line.insert(i, save_num)

### FIXED CODE ###

N = int(input())
num_line = [int(input()) for _ in range(N)]
sort_line = sorted(num_line)
for i in num_line:
    if i == sort_line[N-1]:
        print(sort_line[N-2])
    else:
        print(sort_line[N-1])
### BUGGY CODE ###

l, r = list(map(int, input().split()))

ans = 2019
for i in range(l, r):
    for j in range(i+1, r+1):
        tmp = (i * j) % 2019
        if ans > tmp:
            ans = tmp
print(ans)


### FIXED CODE ###

l, r = list(map(int, input().split()))

if r - l > 2018:
    print(0)
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i+1, r+1):
            tmp = (i * j) % 2019
            if ans > tmp:
                ans = tmp
    print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
P = list(map(int, input().split()))
r = 0
for i in range(n-k+1):
    r = max(r, sum(P[i:i+k]))
print((r+k)/2)

### FIXED CODE ###

def func(x):
    return (x+1)/2

n, k = map(int, input().split())
P = list(map(func, map(int, input().split())))
t = sum(P[0:k])
r = t
for i in range(n-k):
    t = t-P[i]+P[i+k]
    r = r if r>t else t
print(r)
### BUGGY CODE ###

N , M = map(int, input().split())
answer = 0
if M >= 2 * N:
    M -= 2 * N
    answer = N
    if M >= 4:
        answer += M // 4
else:
    for i in range(1, N+1):
        if 2 * i < M:
            answer += 1

print(answer)

### FIXED CODE ###

N , M = map(int, input().split())
answer = 0
if M >= 2 * N:
    M -= 2 * N
    answer = N
    if M >= 4:
        answer += M // 4
else:
    answer += M // 2

print(answer)