Harryxun/stf_run huggingface dataset:
N, K = map(int,input().split())
listMap = [int(i) for i in input().split()]
minMin = float("inf")
ans = 0
minLR = ""
# 正の数 or 負の数 onlyなら別処理
if listMap[0] >= 0 or listMap[-1] <= 0:
    sorted(listMap)
    ans = listMap[K - 1]

else:
    for j in range(N - K):
        L = j
        R = j + K - 1
        if listMap[L] <= 0 <= listMap[R]:
            sumLR = abs(listMap[L] - listMap[R])
            if sumLR < minMin:
                minMin = sumLR
                ans = L

    # 距離を確認
    if -listMap[L] < listMap[R]:
        ans = -listMap[L] * 2 + listMap[R]
    else:
        ans = listMap[R] * 2 + -listMap[L]

print(ans)

### FIXED CODE ###

N, K = map(int,input().split())
listMap = [int(i) for i in input().split()]
minMin = float("inf")

if N == 1:
    minMin = listMap[0]

for j in range(N - (K - 1)):
    L = j
    R = j + (K - 1)
    sumL = abs(listMap[L]) + abs(listMap[L] - listMap[R])
    sumR = abs(listMap[R]) + abs(listMap[R] - listMap[L])
    sum = min(sumL, sumR)
    if sum < minMin:
        minMin = sum

print(minMin)
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,a[100000],b[100000],i=1,j,saidai=0,m=0,L=0;
    string s;
    cin >> n;
    for(i=0;i<n+1;i++)
    {
        cin >> a[i];
        saidai+=a[i];
    }
    for(i=0;i<n;i++)
    {
        cin >> b[i];
        L+=b[i];
    }
    for(i=0;i<n;i++)
    {
        if(a[i]<b[i])
        {
            a[i+1]-=b[i]-a[i];
            if(a[i+1]<0)
            {
                a[i+1]=0;
            }
            a[i]=0;
        }
        else
        {
            a[i]=a[i]-b[i];
        }
    }
        for(i=0;i<n+1;i++)
        {
            m+=a[i];
        }
    if(saidai-m>L)
    {
        cout << L << endl;
    }
    else
    {
        cout << saidai-m << endl;
    }
    
    
    return 0;

}


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
b = list(map(int, input().split()))
for i in range(n):
    if b[i] >= a[i]:
        b[i] -= a[i]
        a[i] = 0
    else:
        a[i] -= b[i]
        continue
    a[i + 1] -= b[i]
    if a[i + 1] < 0:
        a[i + 1] = 0

if a[-1] < 0:
    a[-1] = 0
print(sum_a - sum(a))
o = str(input())
e = str(input())
ans = []
for i in range(len(o)):
    ans.append(o[i])
    ans.append(e[i])
print(ans)

### FIXED CODE ###

O = str(input())
E = str(input())
ans = []
for i in range(len(E)):
    ans.append(O[i])
    ans.append(E[i])
if(len(O) != len(E)):
    ans.append(O[-1])
print("".join(ans))
import bisect
import math
 
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
 
for m in range(M):
    A[N-1] = math.floor( A[N-1]/2 )
    temp = A[N-1]
    del A[N-1]
    # 挿入    
    bisect.insort(A, temp)
print(sum(A))

### FIXED CODE ###

S = input()
if S == "Sunny" : 
  print("Cloudy")

if S == "Cloudy" : 
  print("Rainy")

if S == "Rainy" : 
  print("Sunny")
import collections
N = int(input())
A = input().split(' ')

c = max(collections.Counter(A).values())
if c == 1:
	print('YES')
else:
	print('NO')


### FIXED CODE ###

S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

if U == S:
	A = A - 1
else:
	B = B - 1

print('{} {}'.format(A, B))
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()
if e - a > k:
  print(':(')
else:
  print('Yay')

### FIXED CODE ###

a = input()
b = input()
c = input()
d = input()
e = input()
k = input()
if int(e) - int(a) <= int(k):
  print('Yay!')
else:
  print(':(')
#! -*- coding:utf-8 -*-
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)
def lcm(a, b):
    return a * b / gcd(a, b)

n = int(input())
arr = []
for i in range(n):
    arr.append(int(input()))

x = [0]*n
x[0] = arr[0]
for i in range(n-1):
    x[i+1] = lcm(x[i],arr[i+1])
print(int(x[-1]))


### FIXED CODE ###

#! -*- coding:utf-8 -*-
def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a
 
def lcm(a, b):
    return a * b // gcd(a, b)

n = int(input())
k = []
for i in range(n):
    k.append(int(input()))

if n == 1:
    print(k[0])
else:
    p = lcm(k[0],k[1])
    for i in range(n):
        p = lcm(p,k[i])
    print(int(p))
import collections

def inputN(typ=str):
    return map(typ, raw_input().split())


N = inputN(int)[0]
v = inputN(int)

col0 = collections.Counter(v[::2])
col1 = collections.Counter(v[1::2])
X0 = col0.most_common()
X1 = col1.most_common()
#print X0
#print X1

if X0[0][0] == X1[0][0]:
    if len(X0) == 1 and len(X1) == 1:
        k0 = X[0][1]
        k1 = 0
    elif len(X0) == 1:
        k0 = X0[0][1]
        k1 = X1[1][1]
    elif len(X1) == 1:
        k0 = X0[1][1]
        k1 = X1[0][1]
    elif X0[1][1] >= X1[1][1]:
        k0 = X0[1][1]
        k1 = X1[0][1]
    elif X0[1][1] < X1[1][1]:
        k0 = X0[0][1]
        k1 = X1[1][1]
else:
    k0 = X0[0][1]
    k1 = X1[0][1]

print N - k0 - k1


### FIXED CODE ###

import collections

def inputN(typ=str):
    return map(typ, raw_input().split())


N = inputN(int)[0]
v = inputN(int)

col0 = collections.Counter(v[::2])
col1 = collections.Counter(v[1::2])
X0 = col0.most_common()
X1 = col1.most_common()
#print X0
#print X1

if X0[0][0] == X1[0][0]:
    if len(X0) == 1 and len(X1) == 1:
        k0 = X0[0][1]
        k1 = 0
    elif len(X0) == 1:
        k0 = X0[0][1]
        k1 = X1[1][1]
    elif len(X1) == 1:
        k0 = X0[1][1]
        k1 = X1[0][1]
    elif X0[1][1] >= X1[1][1]:
        k0 = X0[1][1]
        k1 = X1[0][1]
    elif X0[1][1] < X1[1][1]:
        k0 = X0[0][1]
        k1 = X1[1][1]
else:
    k0 = X0[0][1]
    k1 = X1[0][1]

print N - k0 - k1
import numpy as np

MOD = 10**9+7

N = int(input())
arr = np.zeros((N+1,N+1),dtype=int)
for i in range(3,N+1):
    arr[0,i] = 1

for i in range(1,N+1):
    sum_ = 0
    for j in range(3*i,N+1):
        sum_ += arr[i-1,j]
        sum_ %= MOD
        if j+3 >= N + 1:
            break
        arr[i,j+3] = sum_

ans = 0
for i in range(N+1):
    ans += arr[i,N]
    ans %= MOD
print(ans)










### FIXED CODE ###

D,T,S = [int(i) for i in input().split()]
out = 'Yes' if D <= T * S else 'No'
print(out)
# import math
import fractions

n = int(input())


def prime(n):
    if n == 1:
        n += 1
    while True:
        flag = 0
        for k in range(2, int(fractions.sqrt(n)) + 1):
            if n % k == 0:
                flag = 1
                break
        if flag == 0:
            return n
        n += 1


ans = prime(n)
print(ans)


### FIXED CODE ###

n = int(input())


def prime(n):
    if n == 1:
        n += 1
    while True:
        flag = 0
        for k in range(2, int(n**0.5) + 1):
            if n % k == 0:
                flag = 1
                break
        if flag == 0:
            return n
        n += 1


ans = prime(n)
print(ans)
a,b=map(int,input().split())
x=[0,0,-1,1]
y=[-1,1,0,0]
d=[[0]*a for x in range(b)]
for i in range(b):
    d[i]=list(input())
    
result="Yes"

for i in range(b):
    for j in range(a):
        if d[i][j] == '#':
            check=0
            for xv,yv in zip(x,y):
                if 0 <= xv + j < a  and 0 <= yv + i < b:
                    if d[i+yv][j+xv] == '#':
                        check=1
                        #break
        
            if check==0:
                result="No"
                #break
            
                        
print(result)


### FIXED CODE ###

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

if a > b:
    a -= 1
print(a)
from bisect import bisect_left, bisect_right
from collections import deque
 
N = int(input())
A = list(map(int, input().split(" ")))
A.sort()
A = deque(A)
ans = 0
t_max = len(bin(A[-1])) - 2
for t in range(t_max, 0, -1):
    while len(bin(A[-1])) - 2 > t:
        A.pop()
        if len(A) < 2: break
    if len(A) < 2: break
    pow2 = 1 << t
    A_tmp = deque()
    while t == len(bin(A[-1])) - 2:
        r = A.pop()
        idx = bisect_left(A, pow2 - r)
        for _ in range(idx):
            A_tmp.appendleft(A.popleft())
        if len(A) == 0: break
        if A[0] + r == pow2:
            A.popleft()
            ans += 1
        if len(A) < 2: break
    A.extendleft(A_tmp)
                    
print(ans)

### FIXED CODE ###

from bisect import bisect_left, bisect_right
from collections import deque

N = int(input())
A = list(map(int, input().split(" ")))
A.sort()
A = deque(A)
ans = 0
t_max = len(bin(A[-1])) - 2
for t in range(t_max, 0, -1):
    if len(A) < 2: break
    while len(bin(A[-1])) - 2 > t:
        A.pop()
        if len(A) < 2: break
    if len(A) < 2: break
    pow2 = 1 << t
    A_tmp = deque()
    while t == len(bin(A[-1])) - 2:
        r = A.pop()
        idx = bisect_left(A, pow2 - r)
        for _ in range(idx):
            A_tmp.appendleft(A.popleft())
        if len(A) == 0: break
        if A[0] + r == pow2:
            A.popleft()
            ans += 1
        if len(A) < 2: break
    A.extendleft(A_tmp)
                    
print(ans)
l = input()
m = input()
z = l.split(" ")
M = int(z[1])
F = m.split(" ")
X = []
amount=0
for item in F:
  votes = int(item)
  amount = amount + votes
  X.append(votes)
X.sort(reverse=True)
C = (1/4M)*amount
for i in range(M):
  if X[i]<C:
    print("No")
    return
print("Yes")


### FIXED CODE ###

l = input()
m = input()
z = l.split(' ')
M = int(z[1])
N = int(z[0])
F = m.split(' ')
X = []
 
for item in F:
  votes = int(item)
  X.append(votes)

S = sum(X)
C = (S/(4*M))
X.sort(reverse=True)
if X[M-1]<C:
  print("No")
else:
  print("Yes")
N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
        if l==k or l=0:
            l=k
            n-=1
            if n==0:
                print(j[0],j[1],l)
                break
        else: break
    break

### FIXED CODE ###

N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
l2.sort(key=lambda x:x[2],reverse=True)
for i in lis:
    n=N
    l=0
    for j in l2:
        k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
        if j[2]==0:
            if k>l:
                n-=1
            else:
                if l==k or l==0:
                    l=k
                    n-=1
                else: break
        else:
            if l==k or l==0:
                l=k
                n-=1
            else: break
        if n==0:
            m=(i[0],i[1],l)
print('{} {} {}'.format(m[0],m[1],m[2]))
n,k=map(int,input().split())
s=list(input())
s[k]=chr(ord(s[k])+32)

print(*s,sep='')

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
s[k-1]=chr(ord(s[k-1])+32)

print(*s,sep='')
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        count = 0
        
        if i == 0:
            if j == 0:
                count = [S[i][j+1], S[i+1][j], S[i+1][j+1]].count('#')
            elif j == W - 1:
                count = [S[i][j-1], S[i+1][j], S[i+1][j-1]].count('#')
            else:
                count = [S[i][j-1], S[i][j+1], S[i+1][j-1], S[i+1][j], S[i+1][j+1]].count('#')

        elif i == H - 1:
            if j == 0:
                count = [S[i][j+1], S[i-1][j], S[i-1][j+1]].count('#')
            elif j == W - 1:
                count = [S[i-1][j-1], S[i-1][j], S[i][j-1]].count('#')
            else:
                count = [S[i][j-1], S[i][j+1], S[i-1][j-1], S[i-1][j], S[i-1][j+1]].count('#')
        else:
            if j == 0:
                count = [S[i-1][j], S[i-1][j+1], S[i][j+1], S[i+1][j], S[i+1][j+1]].count('#')
            elif j == W - 1:
                count =[S[i-1][j-1], S[i-1][j], S[i][j-1], S[i+1][j-1], S[i+1][j]].count('#')
            else:
                count =[S[i-1][j-1], S[i-1][j], S[i-1][j+1], S[i][j-1], S[i][j+1], S[i+1][j-1], S[i+1][j], S[i+1][j+1]].count('#')
        if S[i][j] != '#':
            S[i][j] = str(count)
for s in S:
    print("".join(s))
            

### FIXED CODE ###

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        count = 0
        search = [[i-1, j-1], [i-1, j], [i-1, j+1], [i, j-1], [i, j+1], [i+1, j-1], [i+1, j], [i+1, j+1]]
        if S[i][j] == '#':
            continue
        for k in search:
            if k[0]<0 or k[0]>=H or k[1]<0 or k[1]>=W:
                continue
            if S[k[0]][k[1]] == '#':
                count += 1
        S[i][j] = str(count)

for s in S:
    print("".join(s))
# -*- coding: utf-8 -*-

import re

n = int(raw_input())
a = map(int, re.split("\s", raw_input()))
left = 0
right = 0
mask = 10**9 + 7

com = [0]*n+2

tmp = 1
for i in range(1, n+2):
        tmp *= i
        com[i] = tmp

for i in range(0, n + 1):
        x = a.index(a[i])
        if a[i] in a[x+1:]:
                left = i  
                right = a[x+1:].index(a[i]) + x + 1
                break

for i in range(1, n + 2):
        ans = (com[n + 1] / (com[i] * com[n + 1 - i]))
        x = (com[left + n - right] / (com[i - 1] * com[left + n - right - i + 1]))
        print (ans - x) % mask


### FIXED CODE ###

# -*- coding: utf-8 -*-

from collections import Counter
import re

def pow(a, x):
        y = 1
        p = a % mask
        n = x
        while (n > 0):
                if ((n % 2) == 0):
                        p = (p * p) % mask
                        n /= 2
                else:   
                        y = (y * p) % mask
                        n -= 1
        return y

n = int(raw_input())
a = map(int, re.split("\s", raw_input()))
left = 0
right = 0

mask = 10**9 + 7
invm = 10**9 + 5

com = [1]*(n+2)
inv = [1]*(n+2)

tmp = 1 
for i in range(1, n+2):
        tmp = (tmp * i) % mask
        com[i] = tmp
        inv[i] = pow(tmp, invm) % mask

counter = Counter(a)
dup = counter.most_common(1)[0][0]
left = a.index(dup)
right = a[left+1:].index(dup) + left + 1

for i in range(1, n + 2):
        ans = (com[n + 1] * (inv[i] * inv[n + 1 - i]))

        if ((left + n - right - i + 1) >= 0):
                ans -= (com[left + n - right] * inv[i - 1] * inv[left + n - right - i + 1])
        print ans % mask
import sys
h,w=map(int,input().split())
s=[]
for num in range(h):
  s.append(list(map(int,input().split())))
if w==1:
  if h==1:
    if s[0][0]=='#':
      print('No')
      sys.exit()
  if h==2:
    if (s[0][0]=='#' and s[1][0]=='.') or (s[0][0]=='.' and s[1][0]=='#'):
      print('No')
      sys.exit()  
  else:
    for i in range(h-2):
      if (s[i][0]=='.' and s[i+1][0]=='#' and s[i+2][0]=='.'):
        print('No')
        sys.exit()
if w==2:
  if h==1:
    if (s[0][0]=='.' and s[0][1]=='#') or (s[0][0]=='#' and s[0][1]=='.'):
      print('No')
      sys.exit()  
  else:
    for i in range(h-1):
      if s[i][0]=='.' and s[i][1]=='#':
        if s[i+1][1]=='.':
          print('No')
          sys.exit()
      if s[i][0]=='#' and s[i][1]=='.':
        if s[i+1][0]=='.':
          print('No')
          sys.exit()     
for i in range(h):
  for j in range(w-2):
    if s[i][j]=='.' and s[i][j+1]=='#' and s[i][j+2]=='.':
      if s[i][j+1]=='.':
        print('No')
        sys.exit()
    if s[i][0]=='#' and s[i][1]=='.':
      if s[min(h-1,i+1)][0]=='.':
        print('No')
        sys.exit()
    if s[i][w-2]=='.' and s[i][w-1]=='#':
      if s[min(h-1,i+1)][w-1]=='.':
        print('No')
        sys.exit()
print('Yes')
  


### FIXED CODE ###

h, w = map(int, input().split())

s = [input() for _ in range(h)]

ans = 'Yes'

for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == '#' and s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.':
            ans = 'No'

print(ans)
n,k = int(split(input()))
cnt=0
for i in range(1,n+1,2):
  cnt++

if k <= cnt:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

n,k = map(int,input().split())
cnt=0
for i in range(1,n+1,2):
  cnt += 1

if k <= cnt:
  print("YES")
else:
  print("NO")
n,m=map(int,input().split())
acf,waf=[0]*n,[0]*n
ac,wa=0,0
for i in range(m):
    x,y=input().split()
    x=int(x)
    if y=='AC':
        if acf[x]==0:
            ac+=1
            wa+=waf[x-1]
            acf[x-1]+=1
    else:
        waf[x-1]+=1
print(ac,wa)


### FIXED CODE ###

n,m=map(int,input().split())
acf,waf=[0]*n,[0]*n
ac,wa=0,0
for i in range(m):
    x,y=input().split()
    x=int(x)
    if y=='AC':
        if acf[x-1]==0:
            ac+=1
            wa+=waf[x-1]
            acf[x-1]+=1
    else:
        waf[x-1]+=1
print(ac,wa)
t=int(input())
print("{:0<2}:{0<2}:{:0<2}".format(t//60**2,t%60**2//60,t%60**2%60))

### FIXED CODE ###

t=int(input())
print("{}:{}:{}".format(t//60**2,t%60**2//60,t%60**2%60))
def count(st):
    n=len(st)
    tmp=1
    res=[]
    for i in range(n-1):
        if st[i]==st[i+1]:
            tmp+=1
        else:
            res.append(tmp)
            tmp=1
    res.append(tmp)
    return res
S=input()
K=int(input())
T=S*3
N=len(S)

if K<=2:
    Y=count(S*K)
    ans=0
    for i in Y:
        ans+=i//2
    print(ans)
    exit()
X=[]
if S[0]==S[-1]:
    for j in range(1,N):
        if S[j-1]!=S[j]:
            break
    tmp=1
    for i in range(j,j+N-1):
        if T[i]==T[i+1]:
            tmp+=1
        else:
            X.append(tmp)
            tmp=1
    X.append(tmp)
else:
    X=count(S)

cnt=0
for i in X:
    cnt+=i//2
Y=count(T)
cnt2=0
for i in Y:
    cnt2+=i//2
print(cnt*(K-3)+cnt2)


### FIXED CODE ###

def count(st):
    n=len(st)
    tmp=1
    res=[]
    for i in range(n-1):
        if st[i]==st[i+1]:
            tmp+=1
        else:
            res.append(tmp)
            tmp=1
    res.append(tmp)
    return res
S=input()
K=int(input())
T=S*3
N=len(S)
if N==1:
    print(K//2)
    exit()
if K<=2:
    Y=count(S*K)
    ans=0
    for i in Y:
        ans+=i//2
    print(ans)
    exit()
if S.count(S[0])==N:
    print((N*K)//2)
    exit()
X=[]
if S[0]==S[-1]:
    for j in range(1,N):
        if S[j-1]!=S[j]:
            break
    tmp=1
    for i in range(j,j+N-1):
        if T[i]==T[i+1]:
            tmp+=1
        else:
            X.append(tmp)
            tmp=1
    X.append(tmp)
else:
    X=count(S)

cnt=0
for i in X:
    cnt+=i//2
Y=count(T)
cnt2=0
for i in Y:
    cnt2+=i//2
print(cnt*(K-3)+cnt2)
import math

N = int(input())
A = list(map(int, input().split()))
A.sort()
mx = 10 ** 9
idx = 0
g = []
for i in range(N-1):
    tmp = math.gcd(A[i], A[i+1])
    #print(A[i], A[i+1], tmp)
    if tmp < mx:
        mx = tmp
        idx = i
    g.append([tmp, i])
g.sort(key=lambda x:x[0])
#print(g)
if N > 2:
    if g[0][1] + 1 == g[1][1]:
        A.remove(A[g[0][1]+1])
    else :
        tmp1 = math.gcd(A[g[0][1]], A[g[1][1]])
        tmp2 = math.gcd(A[g[0][1]+1], A[g[1][1]])
        #print(tmp1, tmp2)
        A.remove(A[g[0][1]] if tmp1 < tmp2 else A[g[0][1]+1])
else :
    A = [max(A)]
import functools

print(functools.reduce(math.gcd, A))


### FIXED CODE ###

from fractions import gcd
N = int(input())
A = list(map(int, input().split()))

L = []
R = []
tl = A[0]
tr = A[-1]
for i in range(N):
  tl = gcd(tl, A[i])
  L.append(tl)
  tr = gcd(tr, A[N-1-i])
  R.append(tr)
mx = 1
R.reverse()
for i in range(N):
  tl = L[i-1] if i else R[i+1]
  tr = R[i+1] if i+1 < N else L[i-1]
  mx = max(mx, gcd(tl, tr))
print(mx)
n, m = [int(s) for s in input().split()]
s = [int(s) for s in input()]
board = [None]*(n+1)
left = 0
for i in range(1,n+1):
    if s[i]:
        continue
    left = max(left, i-m)
    while s[left]:
        left += 1
        if left >= i:
            break
    if left < i:
        board[i] = left
# print(board)
if board[n] is None:
    print(-1)
else:
    steps = []
    j = n
    while True:
        step = j - board[j]
        steps.append(step)
        j = board[j]
        if j==0:
            break
    print(' '.join(str(s) for s in steps[::-1]))

### FIXED CODE ###


n, m = [int(s) for s in input().split()]
s = [int(s) for s in input()]
board = [None]*(n+1)
left = 0
board[left] = 0
for i in range(1,n+1):
    if s[i]:
        continue
    left = max(left, i-m)
    while board[left] is None:
        left += 1
        if left == i:
            break
    if left < i:
        board[i] = left
# print(board)
if board[n] is None:
    print(-1)
else:
    steps = []
    j = n
    while True:
        step = j - board[j]
        steps.append(step)
        j = board[j]
        if j==0:
            break
    print(' '.join(str(s) for s in steps[::-1]))
import math
n,d,a = map(int,input().split())
lst1 = [list(map(int,input().split())) for i in range(n)]
lst1.sort()

#解法2 - imos法
"""
単純に座標に対してimos法を行うと、座標の制約は10**9なので間に合わない。
process1
そこで、各モンスターに対して、そのモンスターを左端で攻撃を行った際、右側の巻き込めるモンスターのインデックスを
保存するリストを作る。
process2
これにより、imosのテーブルはn+1個で答えを求めることができる。
また、imosの累積和は順次求めていく感じになる。
"""

#process1
index = 0
reach = []
for i in range(n):
    for j in range(i+1,n):
        if lst1[j][0] <= lst1[i][0] + 2*d: #届くなら
            index += 1
        else:
            break
    reach.append(index)

#process2
ans = 0
imos = [0]*(n+1) #その座標に効いている魔法の回数(ダメージ量ではない)

for i in range(n):
    if imos[i]*a < lst1[i][1]: #ダメージが足りないなら
        need = math.ceil((lst1[i][1]-imos[i]*a)/a)
        imos[i] += need
        imos[reach[i]+1] -= need #届かなくなったとこでマイナス
        ans += need
    imos[i+1] += imos[i] #累積和を逐一とる

print(ans)

### FIXED CODE ###

import math,bisect
n,d,a = map(int,input().split())
lst1 = [list(map(int,input().split())) for i in range(n)]
lst1.sort()

#解法2 - imos法
"""
単純に座標に対してimos法を行うと、座標の制約は10**9なので間に合わない。
process1
そこで、各モンスターに対して、そのモンスターを左端で攻撃を行った際、右側の巻き込めるモンスターのインデックスを
保存するリストを作る。
process2
これにより、imosのテーブルはn+1個で答えを求めることができる。
また、imosの累積和は順次求めていく感じになる。
"""
x = []
for i in lst1:
    x.append(i[0])

#process1
index = 0
reach = []
for i in range(n):
    index = bisect.bisect_right(x,lst1[i][0]+2*d)
    reach.append(index)

#process2
ans = 0
imos = [0]*(n+1) #その座標に効いている魔法の回数(ダメージ量ではない)

for i in range(n):
    if imos[i]*a < lst1[i][1]: #ダメージが足りないなら
        need = math.ceil((lst1[i][1]-imos[i]*a)/a)
        imos[i] += need
        imos[reach[i]] -= need #届かなくなったとこでマイナス
        ans += need
    imos[i+1] += imos[i] #累積和を逐一とる

print(ans)
import sys
from collections import defaultdict
N = int(input())
A = [int(sys.stdin.readline()) for _ in range(N-1)]
H = defaultdict(lambda: [])
for i, a in enumerate(A, 2):
    H[a].append(i)

def depth(x):
    if not H[x]:
        return 0
    k = len(H[x])
    return max([k - i + j for i, j in zip(range(k), sorted([depth(x) for x in H[x]]))])

print(depth(1))

### FIXED CODE ###

import sys
sys.setrecursionlimit(2*10**5)
N = int(input())
A = [int(input()) for _ in range(N-1)]
if len(set(A)) == N - 1:
    print(N - 1)
    sys.exit()
H = [[] for _ in range(N+1)]
for i, a in enumerate(A, 2):
    H[a].append(i)

def depth(x):
    if not H[x]:
        return 0
    k = len(H[x])
    return max([k - i + j for i, j in zip(range(k), sorted([depth(x) for x in H[x]]))])

print(depth(1))
t=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
print(t[a])

### FIXED CODE ###

t=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
print(t[a-1])
H = int(input())
W = int(input())

if H % 2 ==0:
    N = H * W / 2

else:
    N = int(H * W / 2) + 1

print(N)

### FIXED CODE ###

H , W = map(int, input() .split())

if W == 1:
    N = 1

elif H == 1:
    N = 1

else:   
    if H % 2 ==0:
        N = H * W / 2
        
            
    elif H % 2 ==1:
        if W % 2 ==0:
            N = H * W / 2
        else:
            N = int(H * W / 2) + 1

print(int(N))
a,b,c=map(int,input().split())
if (a==b or b==c or c==a) :
  if a==B==C:
    print("No")
  else :
    print("Yes")

else :
    print("No")

### FIXED CODE ###

a,b,c=map(int,input().split())
if (a==b or b==c or c==a) :
  if a==b==c:
    print("No")
  else :
    print("Yes")

else :
    print("No")