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

import sys
input = sys.stdin.readline
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
gh, gw = map(int, input().split())

s = []
for i in range(h):
    s.append(input().rstrip('\n'))

d = [10 ** 18 for j in range(h*w)]

stack = deque([[ch-1, cw-1, 0]])

while stack:
    curh, curw, cnt = stack.popleft()
    if d[curh * w + curw] <= cnt:
        continue
    else:
        d[curh * w + curw] = cnt
    for dh, dw in ((-1,0), (1,0), (0,1), (0,-1)):
        nh = curh + dh
        nw = curw + dw
        if nh >= 0 and nh < h and nw >= 0 and nw < w and s[nh][nw] == '.':
            stack.append([nh, nw, cnt])
    for nh in range(curh-2, curh+3):
        if nh >= 0 and nh < h:
            for nw in range(curw-2,curw+3):
                if nw >= 0 and nw < w and s[nh][nw] == '.':
                     stack.append([nh, nw, cnt+1])

# for item in d:
#     print(item)
gh -= 1
gw -= 1

if d[gh*w + gw] == 10 ** 18:
    print(-1)
else:
    print(d[gh*w + gw])

### FIXED CODE ###

import sys
input = sys.stdin.readline

import heapq

INF = 10 ** 10

def dijkstra(n, G, s):
    dist = [INF] * n
    dist[s] = 0
    h = []
    heapq.heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heapq.heappop(h)
        if dist[v] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for end, cost in G[v]:
            if dist[end] > dist[v] + cost:
                dist[end] = dist[v] + cost
                heapq.heappush(h, (dist[end], end))
    return dist


H, W = map(int, input().split())
N = H * W
ch, cw = map(lambda x:int(x)-1, input().split())
gh, gw = map(lambda x:int(x)-1, input().split())

s = []
es = tuple([] for i in range(N))

for h in range(H):
   s.append(input().rstrip('\n'))

for h in range(H):
    for w in range(W):
        if s[h][w] != '.':
            continue
        a = h*W+w
        esappend = es[a].append
        for dh in (-2, -1, 0, 1, 2):
            for dw in (-2, -1, 0, 1, 2):
                if dh == 0 and dw == 0:
                    continue
                nh = h + dh
                nw = w + dw
                if 0 <= nh and nh < H and 0 <= nw and nw < W and s[nh][nw] == '.':
                    b = nh*W+nw
                    if (dh, dw) in [(-1,0),(1,0),(0,-1),(0,1)]:
                        esappend((b, 0))
                    else:
                        esappend((b, 1))

dist = dijkstra(N, es, ch*W+cw)
if dist[gh*W+gw] == INF:
    print(-1)
else:
    print(dist[gh*W+gw])
### BUGGY CODE ###

def main():
    N, K = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    exceptation = [0] * N
    answer = 0
    for i in range(N):
        exceptation[i] = (p[i] + 1) / 2
    for i in range(N - K + 1):
        answer = max(answer, sum(exceptation[i:i+K]))
    print(answer)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    # 差分だけ微調整する解法
    N, K = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    answer = sum(p[:K])
    tmp = sum(p[:K])
    for i in range(N - K):
        tmp = tmp + p[i+K] - p[i]
        answer = max(answer, tmp)
    print((answer + K) / 2)


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

N = int(input())
a = [int(i) for i in input().split()]
s = list(set(a))
cnt = 0
for i in s:
    if a.count(i) == i:
        continue
    elif a.count(i) < i:
        cnt += a.count(i)
    else:
        cnt += a.count(i)-i
print(cnt)

### FIXED CODE ###

from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]
s = set(a)
c = Counter(a)

cnt = 0
for i in s:
    if c[i] < i:
        cnt += c[i]
    else:
        cnt += c[i]-i
print(cnt)
### BUGGY CODE ###

import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        min_c=max(j+1,bisect.bisect_right(l, l[j]-l[i])+1)
        max_c=bisect.bisect_left(l, l[j]+l[i])-1
        num=max_c-min_c+1
#        print(str(l[i])+" "+str(l[j])+":"+str(min_c)+" "+str(max_c)+":"+str(num))
        ans += num if num > 0 else 0
print(ans)


### FIXED CODE ###

import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        min_c=j+1
        max_c=bisect.bisect_left(l, l[j]+l[i])-1
        num=max_c-min_c+1
#        print(str(l[i])+" "+str(l[j])+":"+str(min_c)+" "+str(max_c)+":"+str(num))
        ans += num if num > 0 else 0
print(ans)
### BUGGY CODE ###


# -*- coding: utf-8 -*-
import random
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))

def warshall_floyd(g):
    d = g
    N = len(g)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


def slv(N, M, L, ABC, Q, ST):
    g = [[sys.maxsize]*(N) for _ in range(N)]
    for i in range(N):
        g[i][i] = 0
    for a, b, c in ABC:
        if c > L:
            continue
        g[a-1][b-1] = c
        g[b-1][a-1] = c
    
    d = g
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    gg = [[sys.maxsize]*(N) for _ in range(N)]
    for u in range(N):
        for v in range(N):
            if d[u][v] <= L:
                gg[u][v] = 1
    
    d = gg
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    for s, t in ST:
        c = d[s-1][t-1]
        if c != sys.maxsize:
            print(c-1)
        else:
            print(-1)



def main():
    N, M, L = read_int_n()
    ABC = [read_int_n() for _ in range(M)]
    Q = read_int()
    ST = [read_int_n() for _ in range(Q)]
    
    (slv(N, M, L, ABC, Q, ST))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    n, m, l = list(map(int, input().rstrip('\n').split()))
    INF = 10 ** 11
    w = [[INF] * n for _ in range(n)]
    wl = [[INF] * n for _ in range(n)]

    for i in range(n):
        w[i][i] = 0

    for i in range(m):
        a, b, c = list(map(int, input().rstrip('\n').split()))
        if c <= l:
            w[a - 1][b - 1] = c
            w[b - 1][a - 1] = c

    for i in range(n):
        for j in range(n):
            for k in range(n):
                w[j][k] = min(w[j][k], w[j][i] + w[i][k])

    for i in range(n):
        for j in range(n):
            if w[i][j] <= l:
                wl[i][j] = 1
    for i in range(n):
        for j in range(n):
            for k in range(n):
                wl[j][k] = min(wl[j][k], wl[j][i] + wl[i][k])

    q = int(input().rstrip('\n'))
    for i in range(q):
        s, t = list(map(int, input().rstrip('\n').split()))
        if wl[s-1][t-1] == INF:
            print(-1)
        else:
            print(wl[s-1][t-1] - 1)


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

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

for i in range(N):
    NA = A[:i] + A[i+1:]
    set_NA = set(NA)
    #print('NA=', NA)
    #print('set_NA=', set_NA)
    ans = 0
    for j in set_NA:
        count = NA.count(j)
        ans += count*(count - 1) // 2
    print(ans)



### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
X = [0]*N

for i in A:
    X[i-1] += 1

cnt = 0
for i in X:
    cnt += i* (i-1) // 2

for i in A:
    ans = cnt - (X[i-1] - 1)
    print(ans)
### BUGGY CODE ###

S =input()
l=len(S)
N=int(S,2)

    
apopcount=0
bpopcount=0
for i in range(0,l):
  if i%2==0:
    if (N & 0b10**i)!=0:
   		apopcount+=1
    else:
      	bpopcount+=1
  else:
    if (N & 0b10**i)!=0:
    	bpopcount+=1
    else:
      	apopcount+=1
if apopcount<bpopcount:print(apopcount)
else:print(bpopcount) 




### FIXED CODE ###

S =input()
l=len(S)

    
apopcount=0
bpopcount=0
for i in range(0,l):
  if i%2==0:
    if int(S[i])==1:
   		apopcount+=1
    else:
      	bpopcount+=1
  else:
    if int(S[i])==1:
    	bpopcount+=1
    else:
      	apopcount+=1
if apopcount<bpopcount:print(apopcount)
else:print(bpopcount)
### BUGGY CODE ###

import re

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

for q in range(Q):
    l,r = list(map(int,input().split()))
    count = 0
    for m in re.findall(r'AC', s[l-1:r]):
        count += 1
    print(count)


### FIXED CODE ###

import re
 
N,Q = list(map(int,input().split()))
s = input()
lis=[0]
 
count = 0
for i in range(1,len(s)):
    if s[i-1] == 'A' and s[i] == 'C':
        count +=1
    lis.append(count)
for i in range(Q):
    l,r = list(map(int,input().split()))
    print(lis[r-1]-lis[l-1])
### BUGGY CODE ###

S=list(input())
cnt=0
for i in range(len(S)):
  if S[i]=='B':
    for j in range(i,len(S)):
      if S[j]=='W':
        cnt+=1
print(cnt)

### FIXED CODE ###

S=list(input())
cnt=0
ans=0
for i in range(len(S)-1,-1,-1):
  if S[i]=='W':
    cnt+=1
  else:
    ans+=cnt

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

n,q = map(int,input().split())
s = input()
ans = []
for i in range(q):
    l,r = map(int,input().split())
    cnt = 0
    for i in range(l,r):
        if s[i-1:i+1]=='AC':
            cnt += 1
    ans.append(cnt)
for j in range(q):
    print(ans[j])

### FIXED CODE ###

from itertools import accumulate
n,q = list(map(int,input().split()))
s = input()
A = [list(map(int,input().split())) for i in range(q)]

flg = []
for i in range(n-1):
    tmp_s = s[i:i+2]
    if tmp_s == 'AC':
        flg.append(1)
    else:
        flg.append(0)

flg2 = [0] + flg
flg2 = list(accumulate(flg2))


for a in A:
    print(flg2[a[1]-1] - flg2[a[0]-1])
### BUGGY CODE ###

def main():
    from bisect import bisect_left
    I=10**9+1
    n,q,*t=map(int,open(0).read().split())
    d=tuple(t[-q:])
    t=t[:-q]
    N0=2**(q-1).bit_length()
    data=[I]*2*N0
    for x,l,r in sorted(((x,bisect_left(d,s-x)+N0,bisect_left(d,t-x)+N0)for s,t,x in zip(t[::3],t[1::3],t[2::3])),reverse=1):
        while l<r:
            if r&1:
                r-=1
                data[r-1]=x
            if l&1:
                data[l-1]=x
                l+=1
            l>>=1
            r>>=1
    a=[]
    for k in range(N0-1,q+N0-1):
        s=I
        k=[k]
        [k.append((i-1)//2)for i in k if i]
        for k in k:
            if data[k]<s:s=data[k]
        a.append(-(s==I)or s)
    print('\n'.join(map(str,a)))
if __name__=='__main__':
    main()

### FIXED CODE ###

def main():
    from bisect import bisect_left
    def update(l,r,v):
        L,R=l+N0,r+N0
        while L<R:
            if R&1:
                R-=1
                data[R-1]=v
            if L&1:
                data[L-1]=v
                L+=1
            L>>=1
            R>>=1
    def query(k):
        k+=N0-1
        s=10**18
        while k+1:
            if data[k]<s:s=data[k]
            k=~-k//2
        return s
    n,*t=open(0)
    n,q=map(int,n.split())
    d=[-10**18]+list(map(int,t[n:]))+[10**18]
    N0=2**(q+1).bit_length()
    data=[10**18]*2*N0
    for x,t,s in sorted(list(map(int,t.split()))[::-1]for t in t[:n])[::-1]:
        l=bisect_left(d,s-x)
        r=bisect_left(d,t-x)
        update(l,r,x)
    for i in range(q):
        a=query(i+1)
        print(-(a==10**18)or a)
if __name__=='__main__':
    main()
### BUGGY CODE ###

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


def xor(x, y):
    X = bin(max(x, y))[2:]
    Y = bin(min(x, y))[2:]
    w = str(int(X)+int(Y))
    ans = 0
    for i in reversed(range(len(w))):
        if w[i] == "1":
            ans += 2**(len(w)-1-i)
    return ans


Ans = 0
mod = 10**9 + 7
for i in itertools.combinations(a, 2):
        Ans = (Ans + xor(i[0], i[1])) % mod
print(Ans)


### FIXED CODE ###

def powmod(x, y, mod):
    if y == 0:
        return 1
    return (((powmod(x, y >> 1, mod) ** 2) % mod) * x ** (y & 1)) % mod


n = int(input())
a = tuple(map(int, input().split()))
mod = 10**9 + 7
cnt = [0] * 60
for i in range(n):
    r = a[i]
    for j in range(60):
        if r & 1:
            cnt[j] += 1
        r >>= 1

ans = 0
for i in range(60):
    ans += powmod(2, i, mod) * cnt[i] * (n-cnt[i])
    ans %= mod
print(ans)
### BUGGY CODE ###

s = input()
k = int(input())

index = []

for i in range(len(s)):
    for j in range(i+1,i+k+1):
        jyuhuku = 0
        for a in index:
            if(a == s[i:j]):
                jyuhuku = 1
                break
            
        if(jyuhuku == 0):
            index.append(s[i:j])
    
print(sorted(index)[k-1])


### FIXED CODE ###

s = input()
k = int(input())

index = []

for i in range(len(s)):
    for j in range(i+1,i+k+1):
        index.append(s[i:j])
    
print(sorted(list(set(index)))[k-1])
### BUGGY CODE ###

import os
import sys

import numpy as np


def solve(n,k,p,c):
    ans = -10**9
    for x in range(n):
        t = k
        visit = [0] * n
        visit[x] = 1
        loop = [0] * n
        count = 0
        l = True
        sub = 0
        while True:
            x = p[x] - 1
            if l:
                if visit[x]:
                    if loop[x]:
                        ln = sum(loop)
                        if t > l:
                            sub += (t // ln - 1) * count * (count > 0)
                            t %= ln
                            t += ln
                        l = False
                    count += c[x]
                    loop[x] = 1
                visit[x] = 1
            sub += c[x]
            t -= 1
            ans = max(sub, ans)
            if t < 1:
                break
    return ans


# >>> numba compile >>>
if sys.argv[-1]=='ONLINE_JUDGE':
  from numba.pycc import CC
  cc=CC('my_module')
  cc.export('solve','i8(i8,i8,i8[:],i8[:])')(main)
  cc.compile()
  exit()
#from my_module import main
# <<< numba compile <<<
(n, k), p, c = [np.int_(i.split()) for i in open(0)]
print(solve(n,k,p,c))


### FIXED CODE ###

(n, k), p, c = [[*map(int, i.split())] for i in open(0)]

def solve(x, t):
    visit = [0] * n
    visit[x] = 1
    loop = [0] * n
    count = 0
    ans = c[p[x] - 1]
    l = True
    sub = 0
    while True:
        x = p[x] - 1
        if l:
            if visit[x]:
                if loop[x]:
                    ln = sum(loop)
                    if t > l:
                        sub += (t//ln -1)*count*(count>0)
                        t %= ln
                        t += ln
                    l = False
                count += c[x]
                loop[x] = 1
            visit[x] = 1
        sub += c[x]
        t -= 1
        ans = max(sub, ans)
        if t < 1:
            return ans


print(max(solve(i, k) for i in range(n)))
### BUGGY CODE ###

n, k = map(int, input().split())
a_in = list(map(int, input().split()))
diff_list = [0 for num in range(n)]
diff_list[0] = a_in[0]
for i in range(1, n):
    diff_list[i] = a_in[i] - a_in[i-1]


for i in range(k):
    new_list = [0 for num in range(n)]
    d_sum = 0
    for j, d in enumerate(diff_list):
        d_sum += d
        if j-d_sum > 0:
            new_list[j-d_sum] += 1
        else:
            new_list[0] += 1
        if d_sum+j+1 < n:
            new_list[j+d_sum+1] -= 1
    # print(new_list)
    diff_list = new_list.copy()

ans = 0
for d in diff_list:
    ans += d
    print(ans, end= ' ')


### FIXED CODE ###

n, k = map(int, input().split())
a_in = list(map(int, input().split()))

diff_list = [0 for num in range(n)]
diff_list[0] = a_in[0]
for i in range(1, n):
    diff_list[i] = a_in[i] - a_in[i-1]

itr = k
if k > 41:
    itr = 41
for i in range(itr):
    new_list = [0 for num in range(n)]
    d_sum = 0
    for j, d in enumerate(diff_list):
        d_sum += d
        if j-d_sum > 0:
            new_list[j-d_sum] += 1
        else:
            new_list[0] += 1
        if d_sum+j+1 < n:
            new_list[j+d_sum+1] -= 1
    # print(new_list)
    diff_list = new_list.copy()

ans = 0
for d in diff_list:
    ans += d
    print(ans, end= ' ')
### BUGGY CODE ###

S = int(input())
S = str(S)
n = len(str(S))
nnn = 0

if n>4:
    for i in range(n-3):
        for j in range(i+3, n):
            nn = int(S[i:j+1])
            
            if nn % 2019 == 0:
                nnn += 1
print(nnn)


### FIXED CODE ###

from collections import Counter
S = input()[::-1]
MOD = 2019

X = [0]
for i, s in enumerate(S):
    X.append((X[-1] + int(s) * pow(10, i, MOD)) % MOD)

C = Counter(X)
ans = 0
for v in C.values():
    ans += v * (v - 1) // 2
print(ans)
### BUGGY CODE ###

import numpy as np
S = input()
mod = 1000000007

n = len(S)
a = S[-1]
x = np.zeros(26, int)
l = [[13 - i * j % 13 for j in range(0, 10)] for i in [1, 10, 9, 12, 3, 4]] * (n // 6 + 1)
if a == "?":
    x[0:10] += 1
else:
    x[int(a)] += 1
x[13:] = x[:13]
for s, l_ in zip(S[-2::-1], l[1:]):
    if s == "?":
        x[:13] = sum([x[v:v+13] for v in l_])
    else:
        v = l_[int(s)]
        x[:13] = x[v:v+13]
    x %= mod
    x[13:] = x[:13]
print(x[5])

### FIXED CODE ###

#!python3

LI = lambda: list(map(int, input().split()))

# input
S = input()

MOD = 10 ** 9 + 7


def main():
    n = len(S)
    m = 5
    w = []
    p = 1
    for i in range(n):
        s = S[-1 - i]
        if s == "?":
            w.append(p)
        else:
            m = (m - int(s) * p) % 13
        p = p * 10 % 13

    n = len(w)
    l1 = [0] * 13
    l1[0] = 1
    for i in range(1, n + 1):
        l2 = [0] * 13
        for j in range(10):
            x = w[i - 1] * j % 13
            for k in range(13):
                t = (x + k) % 13
                l2[t] += l1[k]
        l1 = [y % MOD for y in l2]
    
    ans = l1[m]
    print(ans)


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

import sys
readline = sys.stdin.readline

N = int(readline())
S = readline().rstrip()

# dp[i][j] = i文字目からとj文字目からとで最長の長さ
# S[i] != S[j] ならdp[i][j] = 0
# S[i] == S[j] ならdp[i][j] = dp[i + 1][j + 1] + 1

dp = [[0] * (N + 1) for i in range(N + 1)]

ans = 0
for i in range(N - 1, -1, -1):
  for j in range(N - 1, i, -1):
    if S[i] == S[j]:
      dp[i][j] = dp[i + 1][j + 1] + 1
      ans = max(ans, min(dp[i][j], j - i))
print(ans)

### FIXED CODE ###

import sys
readline = sys.stdin.readline

N = int(readline())
S = readline().rstrip()

def zalgo(S):
  N = len(S)
  res = [0] * N
  res[0] = N
  i = 1
  j = 0
  while i < N:
    while i + j < N and S[j] == S[i + j]:
      j += 1
    res[i] = j
    if j == 0:
      i += 1
      continue
    k = 1
    while i + k < N and k + res[k] < j:
      res[i + k] = res[k]
      k += 1
    i += k
    j -= k
  return res

res = 0
for i in range(N):
  T = S[i:]
  lcp = zalgo(T)
  for j in range(len(T)):
    l = min(lcp[j],j)
    if res < l:
      res = l

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

N,K,*P = map(int,open(0).read().split())

m = 0
maxIdx = 0
for i in range(0,N-K+1):
  sa =sum(P[i:i+K])
  if m < sa:
    m = sa
    maxIdx = i
ans = 0
for i in range(K):
  ans += (P[maxIdx+i]+1)/2
print(ans)

### FIXED CODE ###

N,K,*P = map(int,open(0).read().split())
P = [(P[i]+1)/2 for i in range(N)]
M = m = sum(P[:K])

for i in range(N-K):
  if M < m-P[i]+P[i+K]:
    M = m-P[i]+P[i+K]
  m= m-P[i]+P[i+K]

print(M)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().strip().split()))
A = [0] + A + [0]

Diff = [abs(A[i]-A[i+1]) for i in range(N+1) ]

for j in range(N):
        print(sum(Diff)-sum(Diff[j:j+2])+abs(A[j]-A[j+2]))

### FIXED CODE ###

N = int(input().strip())
A = list(map(int,input().strip().split(' ')))
B = [0]+A+[0]
sums=0
for i in range(N+1):
    sums = sums+abs(B[i]-B[i+1])

for i in range(1,N+1):
    if min(B[i-1],B[i+1]) <= B[i] and B[i] <= max(B[i-1],B[i+1]):
        print(sums)
    else:
        print(sums-2*min(abs(B[i]-B[i-1]),abs(B[i]-B[i+1])))
### BUGGY CODE ###

#!/usr/bin/env python3
def main():
    from itertools import combinations

    _ = int(input())
    S = input()

    seen = set()
    ans = 0
    for i, j, k in combinations(S, 3):
        string = ''.join([i, j, k])
        if string in seen:
            continue
        ans += 1
        seen.add(string)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
def main():
    N = int(input())
    S = input()

    seen = set()
    ans = 0
    for i in range(N - 2):
        if S[i] in seen:
            continue
        seen.add(S[i])
        for j in range(i + 1, N - 1):
            if S[i] + S[j] in seen:
                continue
            seen.add(S[i] + S[j])
            for k in range(j + 1, N):
                if S[i] + S[j] + S[k] in seen:
                    continue
                seen.add(S[i] + S[j] + S[k])
                ans += 1
    print(ans)


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

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

while True:
  if N%K == 0:
    print(0)
    break
  else:
    N = abs(N-K)
    if pn <= N:
      print(pn)
      break
    elif N == 0:
      print(0)
      break
    else:
      pn = N


### FIXED CODE ###

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

result = N % K
if result <= abs(result-K):
  print(result)
elif result > abs(result-K):
  result = abs(result-K)
  print(result)
### BUGGY CODE ###

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

max_v=0

for i in range(N-K+1):
    if max_v < sum(p[i:i+K]):
        max_v = sum(p[i:i+K])
        max_i = i
    
ans = 0

for i in range(max_i,max_i+K):
    ans += (1/2*p[i]*(p[i]+1))/p[i]

print(ans)



### FIXED CODE ###

# ruisekiwa by itertools

from itertools import accumulate

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

b1=[0]+list(accumulate(p))

ans=[]

for i in range(N-K+1):
    ans.append(b1[K+i]-b1[i])
    
print((max(ans)+K)/2)
### BUGGY CODE ###

k,n=map(int,input().split())
a=list(map(int,input().split()))
resf=10**8
for i in a:
    if i==a[0]:
        res=min(a[-1]-a[0],k-(a[1]-a[0]))
    elif i==a[-1]:
        res=min(k-(a[-1]-a[-2]),a[-1]-a[0])
    else:
        res=min(k-(a[a.index(i)+1]-i),k-(i-a[a.index(i)-1]))
    resf=min(resf,res)
print(resf)


### FIXED CODE ###

# coding: utf-8
# Your code here!
def main():
    k,n=map(int,input().split())
    a=list(map(int,input().split()))
    resf=10**7
    z=0
    for i in a:
        if i==a[0]:
            res=min(a[-1]-a[0],k-(a[1]-a[0]))
        elif i==a[-1]:
            res=min(k-(a[-1]-a[-2]),a[-1]-a[0])
        else:
            if k-(a[z+1]-i)<=k-(i-a[z-1]):
                res=k-(a[z+1]-i)
            else:
                res=k-(i-a[z-1])
        if resf>=res:
            resf=res
        z+=1
    print(resf)

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

import itertools

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

positive = []
negative = []
zero = 0

for combi in itertools.combinations(A, 2):
    c = combi[0]
    n = combi[1]
    if c*n > 0:
        positive.append(c*n)
    elif c*n < 0 :
        negative.append(c*n)
    else:
        zero += 1

if K <= len(negative):
    negative.sort()
    print(negative[K-1])
elif K <= len(negative)+zero:
    print(0)
else:
    positive.sort()
    k = K - len(negative) - zero
    print(positive[k-1])

### FIXED CODE ###

import itertools
import numpy as np

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

positive = A[A>0]
negative = A[A<0]
zero = A[A==0]

l = -10**18
r = 10**18

while l + 1 < r:
    x = (l+r) // 2 # 中央位置
    cnt = 0
    if x >= 0:
        cnt += N * len(zero)
    
    # x//pos : 中央値/posのそれぞれの値
    cnt += A.searchsorted(x//positive, side="right").sum()
    cnt += (N - A.searchsorted(-(-x//negative), side="left")).sum()
    cnt -= np.count_nonzero(A * A <= x)
    cnt //= 2
 
    if cnt >= K:
        r = x
    else:
        l = x
print(r)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
  print(A.index(i)+1,end=" ")

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
D = {}
for i in range(N):
  D[A[i]] = str(i+1)
print(" ".join(D.values()))