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

N, K = map(int, input().split())
P = map(int, input().split())
avg = list(map(lambda x: (x + 1) / 2, P))
ans = 0

for i in range(N-K+1):
    ans = max(ans, sum(avg[i:i+K]))

print(ans)

### FIXED CODE ###

from itertools import accumulate

N, K = map(int, input().split())
P = map(int, input().split())
acc_P = list(accumulate(P))
ans = (acc_P[K-1] + K) / 2

for i in range(N-K):
    ans = max(ans, (acc_P[i+K] - acc_P[i] + K) / 2)

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

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools

n, m, d = [int(i) for i in input().split()]

num = [i for i in range(1, n+1)]
summation = []
for lis in itertools.product(num, repeat=m):
    summation.append(len([i for i in range(len(lis)-1) if abs(lis[i+1] - lis[i]) == d]))

print(sum(summation) / n**m)


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

n, m, d = [int(i) for i in input().split()]

"""
from scipy.special import perm, comb

d == 0
def expectation_0(n, m, d):
    return sum([i * comb(m-1, k) * (n/n**2)**k * (1 - n/n**2)**(m-1-k) for k in range(0, m-1)])

d != 0
def expectation_0(n, m, d):
    return sum([i * comb(m-1, k) * (2(n-d)/n**2)**k * (1 - 2(n-d)/n**2)**(m-1-k) for k in range(0, m-1)])

def expectation(p, m):
        return sum([k * comb(m-1, k) * p**k * (1 - p)**(m-1-k) for k in range(0, m-1)])
"""
if d == 0:
    p = 1 / n  # n / n**2
    print((m - 1) * 1/n)

else:
    p = 2 * (n - d) / n**2
    print((m - 1) * p)
### BUGGY CODE ###

from numpy import*;a,b=loadtxt(open(0),'i',skiprows=1);c=0;l=2**29
while l:h=l;l//=2;i,j=searchsorted(sort(hstack((b%h-h,b%h))),(l-a%h,h-a%h));c+=sum(j-i)%2*l
print(c)

### FIXED CODE ###

from numpy import*;B,I=searchsorted,lambda:int32(input().split());input();a,b=I(),I();c=0
for k in range(29):l=2**k;h=l*2;x,y=a%h,sort(b%h);y=hstack((y-h,y));c+=sum(B(y,h-x)-B(y,l-x))%2*l
print(c)
### BUGGY CODE ###

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

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N = i_i()
S = i_s()

ans = 0
for i in range(N):
    for j in range(i, N):
        if S[i] != S[j]:
            if S[i] == 'R' and S[j] == 'G':
                tmp = 'B'
            elif S[i] == 'R' and S[j] == 'B':
                tmp = 'G'
            elif S[i] == 'G' and S[j] == 'R':
                tmp = 'B'
            elif S[i] == 'B' and S[j] == 'R':
                tmp = 'G'
            else:
                tmp = 'R'
            
            if tmp in S[j:]:
                for k in range(j, N):
                    if S[k] == tmp and k - j != j - i:
                        ans += 1

print(ans)

### FIXED CODE ###

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

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N = i_i()
S = i_s()

r = S.count('R')
g = S.count('G')
b = S.count('B')

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            cnt += 1

print((r * g * b) - cnt)
### BUGGY CODE ###

H, N = map(int, input().split(' '))
magic = [[0 for _ in range(3)] for j in range(N)]
total_cost = 0
for i in range(N):
  temp_a, temp_b = map(int, input().split())
  magic[i][0] = temp_a
  magic[i][1] = temp_b
  magic[i][2] = temp_a / temp_b

hp = H
dp = [float('inf')] * (H + 1)
dp[0] = 0
for i in range(1, H + 1):
  for j in range(N):
    if i >= magic[j][0]:
      dp[i] = min(dp[i - magic[j][0]] + magic[j][1], dp[i])
    else:
      dp[i] = min(magic[j][1], dp[i])

print(dp[H])

### FIXED CODE ###

H, N = map(int, input().split(' '))
magic = [[0 for _ in range(3)] for j in range(N)]
for i in range(N):
  temp_a, temp_b = map(int, input().split())
  magic[i][0] = temp_a
  magic[i][1] = temp_b

dp = [float('inf')] * (H + 1)
dp[0] = 0

for i in range(1, H + 1):
  for j in range(N):
    if i >= magic[j][0]:
      dp[i] = min(dp[i - magic[j][0]] + magic[j][1], dp[i])
    else:
      dp[i] = min(magic[j][1], dp[i])

print(dp[H])
### BUGGY CODE ###

from fractions import gcd
N,M=map(int,input().split())
S=input()
T=input()
L=N*M//gcd(N,M)
ans=L


U=[]
V=[]

#1個目
for i in range(N):
  U.append( [i*(L//N),S[i]])
#2個目
for i in range(M):
  V.append( [i*(L//M),T[i]])
#print(U)
#print(V)

for i in U:
  for j in V:
    #print(i,j)
    if i[0]==j[0] and i[1]!=j[1]:
      print(-1)
      exit()


#  U[i*(L//N)]=S[i]
#  if U[j*(L//M)]!="#" and U[j*(L//M)]!=T[j]:
print(ans)

### FIXED CODE ###

from fractions import gcd
N,M=map(int,input().split())
S=input()
T=input()
L=N*M//gcd(N,M)
p=[]
q=[]

if S[::L//M]==T[::L//N]:
  print(L)
else:
  print(-1)
### BUGGY CODE ###

n=int(input())
lamp=[]
status=1
count=0
possible=1
for i in range(n):
  p=int(input())
  lamp.append(p)
while status!=2 or count==n:
  status=lamp[status-1]
  count+=1
  if count==n and status!=2:
    possible=0
if possible==1:
  print(count)
else:
  print(-1)


### FIXED CODE ###

n=int(input())
lamp=[]
status=1
count=0
possible=0
for i in range(n):
  p=int(input())
  lamp.append(p)
while status!=2:
  if lamp[status-1]!=0:
    var=lamp[status-1]
    lamp[status-1]=0
    status=var
    count+=1
  else:
    possible+=1
    break
if possible==0:
  print(count)
else:
  print(-1)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import collections
import heapq
N = int(input())
a = list(map(int, input().split()))
ans = 1
max_ = pow(10, 18)
for tmp in a:
    ans *= tmp
if (ans > max_):
    print(-1)
else:
    print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import collections
import heapq
N = int(input())
a = list(map(int, input().split()))
ans = 1
max_ = pow(10, 18)
if 0 in a:
    print(0)
    exit()
for tmp in a:
    ans *= tmp
    if (ans > max_):
        print(-1)
        exit()
print(ans)
### BUGGY CODE ###

s=list(input())
tot=-1000000
for i in range(len(s)):
	if s[i]=='?':
		s[i]=='D'
		
		tot1=s.count('D')+s.count('PD')
		
		s[i]=='P'
		
		tot2=s.count('D')+s.count('PD')
		
		if tot2>tot1:
			s[i]='P'
		else:
			s[i]='D'
		
print(''.join(s))

		



### FIXED CODE ###

s=list(input())
for i in range(len(s)):
	if s[i]=='?':
		s[i]='D'
print(''.join(s))
### BUGGY CODE ###

from collections import deque
n = int(input())
a = deque()
for i in range(n):
    j = int(input())
    a.append(j)
for i in range(n):
    s = a.popleft()
    m = max(a)
    print(m)
    a.append(s)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
m = max(a)
p = a.index(m)
a.remove(m)
s = max(a)
for i in range(n):
    if i != p:
        print(m)
    else:
        print(s)
### BUGGY CODE ###

import copy

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

result = [Int_A[0]]
Int_A.remove(Int_A[0])


def check(a):
    if len(Int_A) == 1:
        if result[0] == Int_A[0] ^ a:
            print("Yes")
            exit()
        return []

    res = []
    co_other = copy.deepcopy(Int_A)
    for o in Int_A:
        co_other.remove(o)
        if a ^ o in co_other:
            res.append(o)
        co_other.append(o)
    del co_other

    return res


def deep_check(depth):

    resp = check(result[depth - 1])

    if len(resp) == 0:
        depth -= 1
        return

    for k in resp:
        result.append(k)
        Int_A.remove(k)
        depth += 1
        deep_check(depth)
        result.remove(k)
        Int_A.append(k)
    depth -= 1
    return


deep_check(1)
print('No')




### FIXED CODE ###

# import copy
#
N = input()
A = input().split()
n = int(N)
Int_A = [int(a) for a in A]

k = 0

for a in Int_A:
    k ^= a

if k == 0:
    print("Yes")
else:
    print("No")


#
# result = [Int_A[0]]
# Int_A.remove(Int_A[0])
#
#
# def check(a):
#     if len(Int_A) == 1:
#         if result[0] == Int_A[0] ^ a:
#             print("Yes")
#             exit()
#         return []
#
#     res = []
#     co_other = copy.deepcopy(Int_A)
#     for o in Int_A:
#         co_other.remove(o)
#         if a ^ o in co_other:
#             res.append(o)
#         co_other.append(o)
#     del co_other
#
#     return res
#
#
# def deep_check(depth):
#
#     resp = check(result[depth - 1])
#
#     if len(resp) == 0:
#         depth -= 1
#         return
#
#     for k in resp:
#         result.append(k)
#         Int_A.remove(k)
#         depth += 1
#         deep_check(depth)
#         result.remove(k)
#         Int_A.append(k)
#     depth -= 1
#     return
#
#
# deep_check(1)
# print('No')
### BUGGY CODE ###

L, R = map(int, input().split())

I = 0
J = 0
now = 0
mod = 2019
for i in range(R-L):
    for j in range(R-L-i):
        I = L + i
        J = L + i + j + 1
        now = (I * J) % 2019
        if(now < mod):
            mod = now

print(mod)



### FIXED CODE ###

L, R = map(int, input().split())

I = 0
J = 0
now = 0
mod = 2019

end = 0

for i in range(R-L):
    if(L+i % 2019 == 0 or end == 1):
        mod = 0
        break
    for j in range(R-L-i):
        if (L + i + j + 1 % 2019 == 0):
            mod = 0
            break
        I = L + i
        J = L + i + j + 1
        now = (I * J) % 2019
        if(now < mod):
            mod = now
        if(mod == 0):
            end += 1
            break

print(mod)
### BUGGY CODE ###

PN = [i for i in range(100001)]
i = 2
while True:
    if i >= len(PN):
        break
    j = i * 2
    while True:
        if j >= len(PN):
            break
        PN[j] = 0
        j += i
    while True:
        i += 1
        if i >= len(PN):
            break
        if PN[i] != 0:
            break
PN[1] = 0
PN_2 = []
for i in range(100001):
    if PN[i] != 0 and PN[int((PN[i] + 1) / 2)] != 0:
        PN_2.append(PN[i])
    else:
        PN_2.append(0)

Q = int(input())
lr = []
for i in range(Q):
    cnt = 0
    l, r = map(int, input().split())
    for j in range(l, r + 1):
        if PN_2[j] != 0:
            cnt += 1
    print(cnt)

### FIXED CODE ###

PN = [i for i in range(100001)]
i = 2
while True:
    if i >= len(PN):
        break
    j = i * 2
    while True:
        if j >= len(PN):
            break
        PN[j] = 0
        j += i
    while True:
        i += 1
        if i >= len(PN):
            break
        if PN[i] != 0:
            break
PN[1] = 0
PN_2 = [0]
DPN = [0]
for i in range(1, 100001):
    if PN[i] != 0 and PN[int((PN[i] + 1) / 2)] != 0:
        PN_2.append(PN[i])
        DPN.append(DPN[i - 1] + 1)
    else:
        PN_2.append(0)
        DPN.append(DPN[i - 1])

#print(PN[1:30])
#print(PN_2[1:30])
#print(DPN[1:30])

Q = int(input())
lr = []
for i in range(Q):
    cnt = 0
    l, r = map(int, input().split())
    print(DPN[r] - DPN[l - 1])
### BUGGY CODE ###

import sys,queue,math,copy,itertools,bisect,collections
from heapq import *

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**3
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    P = LI()

    seat = [[1] * N for _ in range(N)]
    zero = [[1] * N for _ in range(N)]

    ans = 0

    for i in P:
        x = (i-1) % N
        y = (i-1) // N
        min_cnt = INF
        if x == 0 or x == N-1 or y == 0 or y == N-1:
            min_cnt = 0
        else:

            dp = [[INF] * N for _ in range(N)]
            d = 0
            f = 0
            q = []
            heapify(q)
            heappush(q,(f,d,x,y))
            dp[x][y] = 0
            while q:
                f,d,i,j = heappop(q)
                if d > min(x,N-x,y,N-y): break
                for di,dj in ((1,0),(0,1),(-1,0),(0,-1)):
                    if not(0 <= i+di < N and 0 <= j+dj < N):
                        break
                    if zero[i+di][j+dj] == 0:
                        break
                    e = seat[i+di][j+dj]
                    if dp[i+di][j+dj] > f+e:
                        dp[i+di][j+dj] = f+e
                        heappush(q,(f+e,d,i+di,j+dj))
                else:
                    continue
                break
            min_cnt = f

        seat[x][y] = 0
        if min_cnt == 0:
            zero[x][y] = 0
        ans += min_cnt
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    P = LI()

    s = []
    for i in range(N):
        for j in range(N):
            s.append(min(i,N-1-i,j,N-1-j))

    r = [1] * (N*N)

    ans = 0
    q = []
    for p in P:
        p -= 1
        ans += s[p]
        r[p] = 0
        q.append(p)
        while q:
            a = q.pop()
            nc = s[a] + r[a]

            if a >= N:
                if s[a-N] > nc:
                    s[a-N] = nc
                    q.append(a-N)
            if a + N < N*N:
                if s[a+N] > nc:
                    s[a+N] = nc
                    q.append(a+N)
            if a % N:
                if s[a-1] > nc:
                    s[a-1] = nc
                    q.append(a-1)
            if a % N < N -1:
                if s[a+1] > nc:
                    s[a+1] = nc
                    q.append(a+1)

    print(ans)

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

import math

def get_distance(x1, y1, x2, y2):
	d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	return d
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

N, D  = map(int, input().split())
count = 0
num_list = []
for i in range(N):
    num_list.append(list(map(int,input().split())))
get_unique_list(num_list)

for i in range (N):
	k = get_distance(num_list[i][0], num_list[i][1], 0, 0)
	if k <= D:
		count += 1

print(count)

### FIXED CODE ###

import math

def get_distance(x1, y1):
	d = math.sqrt((x1) ** 2 + (y1) ** 2)
	return d


N, D  = map(int, input().split())
count = 0
num_list = []
for i in range(N):
    num_list.append(list(map(int,input().split())))


for i in range (N):
	if abs(num_list[i][0]<= D) and abs(num_list[i][1]) <= D:
		
		k = get_distance(num_list[i][0], num_list[i][1])
		if k <= D:
			count += 1


print(count)
### BUGGY CODE ###

#http://compro.tsutajiro.com/archive/180220_probability_dp.pdf
import sys
sys.setrecursionlimit(10 ** 8)
n = int(input())
a = list(map(int, sys.stdin.readline().split( )))
cnt =[0,0,0]
for i in range(n):
    cnt[3-a[i]] += 1

divT = [1/i for i in range(1,n+1)]

from functools import lru_cache### 
@lru_cache(100100100)

def f(x,y,z):
    if x==y==z==n:
        return 0
    res = 0
    delta = n*divT[n-z-1]
    if x != n:
        res += (f(x+1,y,z) + delta) * (n-x)
    if y != x:
        res += (f(x,y+1,z) + delta) * (x-y)#x+1,y+1ではない
    if z != y:
        res += (f(x,y,z+1) + delta)* (y-z)#x+1,y+1,z+1ではない
    res *=divT[n-z-1]
    return res
    

print(f(cnt[1]+cnt[2],cnt[2],0))


### FIXED CODE ###

#http://compro.tsutajiro.com/archive/180220_probability_dp.pdf
import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split( )))
cnt =[0,0,0]
for i in range(n):
    cnt[3-a[i]] += 1
dp = [[[0 for _ in range(n+1)] for __ in range(n+1)] for ___ in range(n+1)]

dp[n][n][n] = 0
divT = [1/i for i in range(1,n+1)]

for x in range(n,cnt[1]+cnt[2]-1,-1):## -2だったのを-1に
    for y in range(x,cnt[2]-1,-1):##cnt[2]
        for z in range(y,-1,-1):
            delta = n*divT[n-z-1]#2枚以下を引くまで
            if x != n:
                dp[x][y][z] += (dp[x+1][y][z] + delta) * (n-x)
            if y != x:
                dp[x][y][z] += (dp[x][y+1][z] + delta) * (x-y)#x+1,y+1ではない
            if z != y:
                dp[x][y][z] += (dp[x][y][z+1] + delta)* (y-z)#x+1,y+1,z+1ではない
            dp[x][y][z] *=divT[n-z-1]

print(dp[cnt[1]+cnt[2]][cnt[2]][0])
### BUGGY CODE ###

from collections import defaultdict

N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]

counter = defaultdict(lambda: 0)
parent_dict = defaultdict(lambda: 0)  # 親ノード
rank_dict = defaultdict(lambda: 0)  # 根からの距離

for p, x in px:
    counter[p] += x

# 根からの距離(after test用)
ab = sorted(ab)
for a, b in ab:
    if a == 1:
        rank_dict[b] = 1
        parent_dict[b] = 1
    else:
        if rank_dict[a] != 0 and rank_dict[b] == 0:
            rank_dict[b] = rank_dict[a] + 1
            parent_dict[b] = a
        elif rank_dict[a] == 0 and rank_dict[b] != 0:
            rank_dict[a] = rank_dict[b] + 1
            parent_dict[a] = b

rank_sorted = sorted(rank_dict.items(), key=lambda x: x[1])
for k, v in rank_sorted:
    counter[k] += counter[parent_dict[k]]

ans = []
for i in range(1, N+1):
    ans.append(counter[i])
print(" ".join(map(str, ans)))


### FIXED CODE ###

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


def dfs(cur, par):
    for child in edge[cur]:
        if child == par:
            continue
        counter[child] += counter[cur]
        dfs(child, cur)


N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]
counter = [0] * N

edge = [[] for _ in range(N)]
for i in range(N-1):
    a = ab[i][0] - 1
    b = ab[i][1] - 1
    edge[a].append(b)
    edge[b].append(a)

for i in range(Q):
    p = px[i][0] - 1
    x = px[i][1]
    counter[p] += x


dfs(0, -1)
print(*counter)
### BUGGY CODE ###

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

m = 0
p = []
for i in range(n - k + 1):
    tmp = P[i:i+k]
    if m < sum(tmp):
        m = sum(tmp)
        p = tmp

s = 0
for i in p:
    s += (1 + i) / 2

print(s)

### FIXED CODE ###

import numpy as np
from scipy.signal import fftconvolve

n, k = map(int, input().split())
P = np.array(input().split(), dtype=int)
template = np.ones(k)

a = fftconvolve(P, template, mode="valid")

print((max(a) + k) / 2)
### BUGGY CODE ###

def main():
  raw, answer = raw_input(), 0
  s = raw[0]
  for x in xrange(1, len(raw)):
      if raw[x] == s[-1]:
          continue
      s += raw[x]

  while len(set(s)) > 1:
    char, pos = "", 0
    for i in xrange(len(s)-1,-1,-1):
      if s[i] != s[-1]:
        pos, char = i, s[i]
        break
    s = s[0:pos]+char
    answer += 1
  print(answer)


main()

### FIXED CODE ###

def main():
  raw = raw_input()
  s = raw[0]
  for x in xrange(1, len(raw)):
      if raw[x] == s[-1]:
          continue
      s += raw[x]
  print(len(s)-1)


main()
### BUGGY CODE ###

N = int(input())
X_bin = input()

X_int = int(X_bin, 2)  # bin => int
dp = {}


def calc_ans(next_int):
    key = next_int
    if key in dp.keys():
        return dp[key]
    ans = 0
    while next_int > 0:
        next_bin = format(next_int, 'b')
        # popcount
        cnt = 0
        for i in next_bin:
            if i == '1':
                cnt += 1
        next_int = next_int % cnt
        next_bin = format(next_int, 'b')
        ans += 1
    dp[key] = ans
    return ans


for i in range(N):
    if X_bin[i] == '1':
        print(calc_ans(X_int - (2**(N-i-1))))
    else:
        print(calc_ans(X_int + (2**(N-i-1))))


### FIXED CODE ###

N = int(input())
X_bin = input()
#N = 10**5
#X_bin = '1' * N

X_int = int(X_bin, 2)  # bin => int


def calc_bin_cnt(next_int):
    if next_int == 0:
        return 0
    next_bin = bin(next_int)[2:]
    # popcount
    cnt = 0
    for i in next_bin:
        if i == '1':
            cnt += 1
    return cnt


def calc_ans(next_int, cnt=None):
    if next_cnt == 0:
        return 0
    if next_int == 0:
        return 1
    if cnt is None:
        cnt = calc_bin_cnt(next_int)
    next_int = next_int % cnt
    if next_int > 0:
        ans = calc_ans(next_int) + 1
    else:
        ans = 1
    return ans


X_cnt = calc_bin_cnt(X_int)
f_p = X_int % (X_cnt+1)
if X_cnt-1 == 0:
    f_m = 0
else:
    f_m = X_int % (X_cnt-1)
for i in range(N):
    if X_bin[i] == '1':
        next_cnt = X_cnt - 1
        if next_cnt == 0:
            next_int = 0
        else:
            next_int = f_m - pow(2, (N-i-1), next_cnt)  # マイナスでも正しく求まる？
    else:
        next_cnt = X_cnt + 1
        next_int = f_p + pow(2, (N-i-1), next_cnt)
    print(calc_ans(next_int, next_cnt))
    #calc_ans(next_cnt, next_cnt)
### BUGGY CODE ###

def resolve():
    n,k= map(int,input().split())
    h = list(map(int,input().split()))
    d = [float("inf")]*(n)
    d[0] = 0
    for i in range(n):
        for j in range(min(i,k)+1):
            d[i] = min(d[i-j]+abs(h[i]-h[i-j]),d[i])
    print(d[-1])

resolve()


### FIXED CODE ###

import numpy as np
def resolve():
    n,k= map(int,input().split())
    h = np.array(list(map(int,input().split())))
    d = np.array([0]*n)
    d[0] = 0
    for i in range(1,n):
        j=max(0,i-k)
        d[i] = (d[j:i]+np.abs(h[i]-h[j:i])).min()
    print(d[-1])

resolve()
### BUGGY CODE ###

import sys
input=sys.stdin.buffer.readline
n=int(input())+1
data=[0]*n*2
def update(i,x):
  i+=n
  data[i]=x
  i//=2
  while i:
    data[i]=data[i*2]|data[i*2+1]
    i//=2
def query(l,r):
  l+=n
  r+=n
  s=0
  while l<r:
    if l&1:
      s|=data[l]
      l+=1
    if r&1:
      r-=1
      s|=data[r]
    l//=2
    r//=2
  return sum(map(int,bin(s)[2:]))
for i,c in enumerate(input()[:-1]):
  update(i,2**(c-97))
for _ in range(int(input())):
  q,a,b=input().split()
  if q[0]>49:print(query(int(a)-1,int(b)))
  else:update(int(a)-1,2**(b[0]-97))

### FIXED CODE ###

import sys
input=sys.stdin.buffer.readline
n=int(input())+1
data=[0]*n*2
def update(i,x):
  i+=n
  data[i]=x
  i//=2
  while i:
    data[i]=data[i*2]|data[i*2+1]
    i//=2
def query(l,r):
  l+=n
  r+=n
  s=0
  while l<r:
    if l&1:
      s|=data[l]
      l+=1
    if r&1:
      r-=1
      s|=data[r]
    l//=2
    r//=2
  return sum(map(int,bin(s)[2:]))
for i,c in enumerate(input()[:-1]):
  update(i,2**(c-97))
for _ in range(int(input())):
  q,a,b=input().split()
  if q[0]>49:print(query(int(a)-1,int(b)))
  else:update(int(a)-1,2**(b[0]-97))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

s=list(input())
n=len(s)

count=0
flag=1
while flag!=0:
    flag=0
    for i in range(n):
        if s[i]=="#":
            continue 
        for j in range(i,n):
            if s[i]!=s[j] and s[j]!="#":
                s[i]="#"
                s[j]="#"
                flag+=1
                count+=1
                break
    if flag==0:
        print(2*count)



### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

s=list(input())
n=len(s)

#print(s[0],s[1])

cnt0=0
cnt1=0
for i in range(n):
    if s[i]=="0":
        cnt0+=1
    elif s[i]=="1":
        cnt1+=1

print(2*min(cnt0,cnt1))
### BUGGY CODE ###

num = int(input(""))
val = list(map(int,input().split()))
val_sum = 0
mod = 10**9 + 7

for i in range(num):
    for j in range(i+1,num):
        val_sum = val_sum + val[i]*val[j]
        
print(val_sum%mod)

### FIXED CODE ###

num = int(input(""))
val = list(map(int,input().split()))
val_sum = sum(val)
ans = 0
mod = 10**9 + 7

for i in range(num):
    val_sum = val_sum - val[i]
    ans     = val[i] * val_sum + ans
        
print(ans%mod)
### BUGGY CODE ###

# import sys
# input = sys.stdin.readline
import itertools


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n, k = input_list()
    a = input_list()
    sums = 0
    max_kukan = []
    for i in range(n-k+1):
        kukan = a[i:i+k]
        if sum(kukan) > sums:
            sums = sum(kukan)
            max_kukan = kukan
    ans = list(map(lambda x: (x+1)/2, max_kukan))
    print(sum(ans))


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


### FIXED CODE ###

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

def kitai(x):
  return (1+int(x))/2

p = list(map(kitai, input().split()))

pre = psum = sum(p[0:k])

for i in range(1, n):
  if i+k > n:
    break
  pre = pre - p[i-1] + p[i+k-1]
  psum = max(psum, pre)

print(psum)