Problem:
 Score : 400 points    Problem Statement We have N dice arranged in a line from left to right. The i -th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.  We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.      Constraints  1 ≤ K ≤ N ≤ 200000  1 ≤ p_i ≤ 1000  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  K  p_1 ... p_N       Output Print the maximum possible value of the expected value of the sum of the numbers shown.  Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-6} .        Sample Input 1 5 3
1 2 2 4 5      Sample Output 1 7.000000000000  When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7 . This is the maximum value we can achieve.       Sample Input 2 4 1
6 6 6 6      Sample Output 2 3.500000000000  Regardless of which die we choose, the expected value of the number shown is 3.5 .       Sample Input 3 10 4
17 13 13 12 15 20 10 13 17 11      Sample Output 3 32.000000000000

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))


n,k = inpl()
a = inpl()
now = sum(a[:k])
max = now
ans = 0
for i in range(n-k):
    now = now + a[k+i] - a[i]
    if now > max: 
        ans = i+1
        max = now
res = 0
for i in range(ans,ans+k):
    res += (a[i]+1)/2
print(res)

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

s = 0
for i in range(0,K):
    s = s + p[i]
t = s
for j in range(0,N-K):
    u = s + p[j+K] - p[j]
    if u > t:
        t = u
    s = u
print((t+K)/2)

Solution (Python):
n,k=map(int,input().split())
p=[int(i)+1 for i in input().split()]

num=sum(p[:k])
ans=num
for i in range(n-k):
  tmp=p[i+k]-p[i]
  num+=tmp
  if ans<num:
    ans=num

print(ans/2)

Solution (Python):
N, K = map(int, input().split())
ps = list(map(int, input().split()))
Es = [(ps[i]+1)/2 for i in range(N)]
maxs = []
for i in range(1, N+1):
  if i<K:
    continue
  elif i==K:
    tmp = sum(Es[:i])
    maxs.append(tmp)
  else:
    tmp = tmp +Es[i-1]-Es[i-K-1]
    maxs.append(tmp)
print(max(maxs))

Solution (Python):
import sys

def LI(): return list(map(int, sys.stdin.readline().split()))
N, K = LI()
p = LI()
ps = []
for i in range(N):
    ps.append((p[i] + 1) / 2)
 
anss = []
tmp = 0
for i in range(N):
    tmp += ps[i]
    if i > K - 1:
        tmp -= ps[i - K]
    anss.append(tmp)
 
print(max(anss))

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
p = LI()
ps = []
for i in range(N):
    ps.append((p[i] + 1) / 2)

anss = []
tmp = 0
for i in range(N):
    tmp += ps[i]
    if i > K - 1:
        tmp -= ps[i - K]
    anss.append(tmp)

print(max(anss))

Solution (Python):
N, K = map(int, input().split())
pi = list(map(int,input().split()))
def EV(x):
    return 1+(x-1)*0.5
for i in range(N):
    pi[i] = EV(pi[i])

ruisekiwa = sum(pi[0:K])
max_EV = ruisekiwa

for i in range(N-K):
    ruisekiwa = ruisekiwa + pi[i+K]-pi[i]
    if ruisekiwa > max_EV:
        max_EV = ruisekiwa
print(max_EV)

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

A = [p[0]]
for i in range(N-1):
	A.append(A[i] + p[i+1])

res = 0
for i in range(N - K):
	res = max(A[i + K] - A[i], res)

if N == K:
	res = A[N-1]

print( (res + K) / 2)

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))

def avg2(x):
  result = 0
  if (x == 0):
    result = 0
  elif(x == 1):
    result = 1 * 2
  else:
    result = (1 + x)
  return result

check_ary = P[0:K]
avg2_ary = list(map(avg2, check_ary))  
max2_value = sum(avg2_ary)
current_value = max2_value

for index in range(1,N - K + 1):
  
  

  next_value = current_value - avg2(P[index-1]) + avg2(P[index-1 + K])
  if (max2_value < next_value):
    max2_value = next_value
  current_value = next_value 

print(max2_value/2)

Solution (Python):
n, k = map(int,input().split())
p = list(map(int,input().split()))




sum_1tok = 0
sum_k =[]
for i in range(k):
    sum_1tok += p[i]
sum_k.append(sum_1tok)


sum_max= 0

for i in range(1,n-k+1):
    sum_k.append(sum_k[i-1] + p[k+i-1] - p[i-1])



ans = (max(sum_k) + k) /2
print(ans)

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
p=[0]*n
s=0
for i in range(n):
    p[i]=(a[i]*(a[i]+1))/2*1/a[i]
for i in range(k):
    s+=p[i]
ans=s
for i in range(k,n):
    s+=p[i]
    s-=p[i-k]
    ans=max(ans,s)
print(ans)

Solution (Python):
import sys
from itertools import accumulate

read = sys.stdin.read

N, K, *p = map(int, read().split())

p = [(1 + i) / 2 for i in p]
p = [0] + p
P = list(accumulate(p))
answer = max(b - a for a, b in zip(P, P[K:]))

print(answer)

Solution (Python):
import sys
from itertools import accumulate

read = sys.stdin.read

N, K, *p = map(int, read().split())

p = [(1 + i) / 2 for i in p]
p = [0] + p
P = list(accumulate(p))
answer = max(P[i] - P[i - K] for i in range(K, N + 1))

print(answer)

Solution (Python):
N, K = map(int, input().split())
P = list(map(lambda x: int(x) * (int(x) + 1) / 2 / int(x), input().split()))

S = sum(P[0:K])

ans = S
for s, a in zip(P[0: N - K], P[K: N]):
    S += a - s
    ans = max(ans, S)
print(ans)

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

sum_k = [0] * N
tmp = 0
for i in range(K):
    tmp += p[i]
sum_k[0] = tmp
max_sum = tmp
candidate = 0
for i in range(len(p)-K):
    sum_k[i+1] = sum_k[i] - p[i] + p[i+K]
    if max_sum < sum_k[i+1]:
        max_sum = sum_k[i+1]
        candidate = i+1


ans = 0
for i in range(candidate, candidate + K):
    ans += (1 + p[i]) / 2
print(ans)

Solution (Python):
import sys
from itertools import accumulate


def solve():
    N, K = map(int, sys.stdin.readline().split())
    cusum_p = (0,) + tuple(accumulate(map(int, sys.stdin.read().split())))
    return (max(i - j for i, j in zip(cusum_p[K:], cusum_p[:-K])) + K) / 2


if __name__ == "__main__":
    answer = solve()
    print(answer)

Solution (Python):
from collections import deque

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

mx = 0
s = 0
q = deque()

for i in range(N):
    p[i] += 1

for i in range(N):
    s += p[i]
    q.append(p[i])
    if len(q) > K:
        s -= q.popleft()
    if len(q) == K:
        mx = max(mx, s)

print(mx / 2)

Solution (Python):
n,k=map(int,input().split())
*p,=map(int,input().split())
px=[(i+1)/2 for i in p]
px_sum=[0]
for j in range(len(px)):
	px_sum.append(px_sum[j]+px[j])
ans=0
for i in range(n-k+1):
	a=px_sum[i+k]-px_sum[i]
	ans=max(a,ans)
print(ans)

Solution (Python):
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
tmp = sum(p_list[:k])
max_num = sum(p_list[:k])
for i in range(len(p_list)-k):
  tmp = tmp - p_list[i] + p_list[i+k]
  if tmp >= max_num:
    max_num = tmp
print((max_num+k)/2)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
cnt=sum(p[:k])
ans=cnt
for i in range(k,n):
  cnt-=p[i-k]
  cnt+=p[i]
  ans=max(ans,cnt)
print(ans/2+k/2)

Solution (Python):
N, K = [int(n) for n in input().split()]
P = [(int(n)+1)/2 for n in input().split()]
ans = sum(P[:K])
e = ans
for p,x in zip(P, P[K:]):
    e = e-p+x
    if ans < e:
        ans = e
print(ans)

Solution (Python):
N,K=map(int,input().split())
P=list(map(int,input().split()))
E=[0]*N

for i in range (N):
	E[i]=((P[i]+1)/2)

L=[0]*(N+1)
L[0]=0

for i in range (N):
	L[i+1]=L[i]+E[i]

ans=0

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

print(ans)

Solution (Python):
def cal(a):
 	return ((1 + a) / 2)
 
N, K = map(int, input().split())
p = list(map(int, input().split()))
ans_raw = []
sum_raw = []
sum_cal = 0
 
for i in range(0, N):
    p[i] = cal(p[i])


for i in range(0, N):
	sum_cal += p[i]
	sum_raw.append(sum_cal)

for i in range(0, N - K):
	ans = sum_raw[i + K] - sum_raw[i]
	ans_raw.append(ans)

ans_0 = sum_raw[K - 1]
ans_raw.append(ans_0)

print(max(ans_raw))

Solution (Python):
def tasu(x):
    return x / 2 * (x + 1)

def kitaiti(n , k , p):

    ans = 0
    count = 0
    kitai = [0]*n
    kitaisum = [0]*n
    mod = 10**9+7

    for i in range(n):
        kitai[i] = tasu(p[i]) / p[i]

    for i in range(n):
        if i == 0:
            kitaisum[i] += kitai[i]
        else:
            kitaisum[i] += kitai[i] + kitaisum[i-1]

    for i in range(n - k + 1):

        ans = max(ans , (kitaisum[i + k - 1] - kitaisum[i-1]) if i != 0 else kitaisum[i + k - 1])

    return ans

def main():
    n , k = map(int , input().split())
    p = list(map(int,input().split()))
    print(kitaiti(n , k , p))

if __name__ == '__main__':
    main()

Solution (Python):
size, count = list(map(int,input().split()))
dices = list(map(int,input().split()))

max_sum = sum(dices[0:count])
now_sum = max_sum

for p,d in zip(dices,dices[count:]):
    now_sum = now_sum - p + d
    if max_sum < now_sum:
        max_sum = now_sum

print((max_sum+count)/2)

Solution (Python):
from itertools import accumulate

n, k = list(map(int, input().split()))
p = [0] + list(accumulate([(int(d) + 1) / 2 for d in input().split()]))

ans = 0
for i in range(k, n+1):
    ans = max(ans, p[i] - p[i-k])

print(ans)

Solution (Python):


n, k = list(map(int,input().split()))
p = [((int(x)+1)/2) for x in input().split()]

ave = sum(p[0:k])
max = ave
for i in range(n-k):
    ave = ave-p[i]+p[k+i]
    if ave > max:
        max = ave
print(max)

Solution (Python):
N,K = list(map(lambda x:int(x),input().split()))
P = list(map(lambda x:int(x),input().split()))
s = [0]*(len(P)-K+1)
for i in range(len(P)-K+1):
    if i==0:
	    s[i] = sum(P[i:i+K])
    else:
        s[i] = s[i-1]-P[i-1]+P[i+K-1]
    
ans  = max(s)/2. + K/2.
print(ans)

Solution (Python):
N,K = (int(i) for i in input().split())
P = [int(i) for i in input().split()]
P_expect_sum = [0 for i in range(N)]

P_pred = 0
for i in range(N):
  P_expect = (1+P[i])/2
  P_expect_sum[i] = P_pred + P_expect
  P_pred = P_expect_sum[i]

ans = P_expect_sum[K-1]
for i in range(K-1,N):
  ans = max(ans, P_expect_sum[i] - P_expect_sum[i-K])
print(ans)

Solution (Python):
def calc(n):
    return (1 + n) / 2

def solve():
    n, k = map(int, input().split())

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

    sum = [0.0]

    for e in p:
        sum.append(sum[-1] + calc(e))

    ans = 0.0
    for i in range(k, len(sum)):
       ans = max(ans, sum[i] - sum[i - k]) 

    print(ans)

def main():
    solve()
    pass

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    ex = [0 for _ in range(n)]
    for i in range(n):
        ex[i] = (p[i]+1)/2
    
    sumex = sum(ex[:k])
    tmp = sum(ex[:k])
    for i in range(n-k):
        tmp = tmp + (ex[i+k] - ex[i])
        sumex = max(sumex, tmp)
    print(sumex)
    
main()

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))

sum_acc = [0]
tmp = 0
 
for i in range(n):
  tmp += (1 + p[i]) / 2
  sum_acc.append(tmp)

ans = 0
for j in range(k, n + 1): 
  ans = max(sum_acc[j] - sum_acc[j - k], ans)

print(ans)

Solution (Python):
import itertools 
N,K =list(map(int,input().split()))
p =list(map(int,input().split()))
E = [0] * N

for i in range(N):
  E[i]=(p[i]+1)/2
acc = [0]
acc += list(itertools.accumulate(E))

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

print(ans)

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

sum_p = 0
sum_p_list =[]

for i in range(K):
    sum_p += p[i]

sum_p_list.append(sum_p)

for j in range(K,N):
    sum_p -= p[j - K]
    sum_p += p[j]
    sum_p_list.append(sum_p)
    

ex = (max(sum_p_list) - K + 2)/2

print(ex + K - 1)

Solution (Python):
import queue
n,k=map(int,input().split())
l=list(map(int,input().split()))
el=queue.deque(maxlen=k)
ans = 0
m = 0
for i in l[:]:
    if len(el) == k:
        el.append((1+i)/2)
        m = m-m_e+el[-1]
    else:
        el.append((1+i)/2)
        m +=el[-1]
    ans = m if m>ans else ans
    m_e = el[0]
print(ans)

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))

wrk = sum(p[:k])
ans = wrk
for i in range(1,n-k+1):
    wrk-=p[i-1]
    wrk+=p[i+k-1]
    ans = max(ans,wrk)

print(0.5+(0.5*ans)+(k-1)*0.5)

Solution (Python):
n,k=map(int,input().split())
def expe(n):
  return (n+1)/2
p=[expe(int(x)) for x in input().split()]
l,r=[p[0]]*(n+1),[p[n-1]]*(n+1)
for i in range(n-1):
  l[i+1]=l[i]+p[i+1]
  r[n-2-i]=r[n-1-i]+p[n-2-i]
r[n],l[n]=0,sum(p)
su=sum(p)
ans=max(su-r[k],su-l[n-k-1])
for i in range(1,n-k-1):
  sumk=su-l[i-1]-r[i+k]
  ans=max(sumk,ans)
print(ans)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))

num_li = [0]*n

for i in range(n):
    num_li[i] = (p[i]+1)/2

num = sum(num_li[:k])
ans = num

for j in range(n-k):
    num = num-num_li[j]+num_li[j+k]
    ans = max(num, ans)

print(ans)

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

sum_p = 0

for i in range(K):
    sum_p += p[i]

max_p = sum_p

for j in range(K,N):
    sum_p -= p[j - K]
    sum_p += p[j]
    max_p = max(max_p,sum_p)

ex = (max_p - K + 2)/2

print(ex + K - 1)

Solution (Python):
N, K = list(map(int, input().split()))
Ps = list(map(int, input().split()))


def expected(val):
    return (val*(val+1) / 2) / val

est = sum([expected(x) for x in Ps[:K]])
max_est = est
for i in range(K, N):
    est -= expected(Ps[i - K])
    est += expected(Ps[i])
    max_est = max(max_est, est)
print(max_est)

Solution (Python):
n, k = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = [(p+1)/2 for p in P]
c = [0]
for q in Q:
   c.append(c[-1]+q)
ans = 0
for i in range(k, n+1):
   ans = max(ans, c[i] - c[i-k])
print(ans)

Solution (Python):
n, k = map(int, input().split())
 
p = list(map(int, input().split()))
 
p = [(e+1) / 2 for e in p]
 
s = sum(p[0:k])
s_max = s
 
for i in range(n-k):
  s = s - p[i] + p[i+k]
  if s_max < s:
    s_max = s
    
print(s_max)

Solution (Python):
n,k = [int(i) for i in input().split()]
l = [int(i) + 1 for i in input().split()]

ans = [0 for _ in range(n+1)]
for i in range(n):
    ans[i+1] = ans[i]+ l[i]

expect = 0   
for i in range(k,n+1):
    expect = max(expect,(ans[i] - ans[i-k])/2)
    
print(expect)

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

m = [(e + 1) / 2 for e in p]

t = sum(m[0:K])
result = t
for i in range(N - K):
    t -= m[i]
    t += m[i + K]
    if t > result:
        result = t
print(result)

Solution (Python):
def cal(x): return (x+1)/2

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

ans  = sum(cal(p[i]) for i in range(K))
    
cnt = ans

for i in range(K, N):
  cnt = cnt-cal(p[i-K])+cal(p[i])
  ans = max(cnt, ans)
print(ans)

Solution (Python):
def cal(x): return (x+1)/2
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=sum([cal(p[i]) for i in range(k)])
cnt=ans
for i in range(k,n):
  cnt=cnt-cal(p[i-k])+cal(p[i])
  ans=max(ans,cnt)
print(ans)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0
pp=[0]
for i in p:
    a+=i
    pp.append(a)
a=0
for i in range(k,n+1):
    a=max(a,pp[i]-pp[i-k])

print(a/2+k/2)

Solution (Python):
n, k, *p_n = map(int, open(0).read().split())
p_n.insert(0, 0)
for i in range(n):
    p_n[i + 1] = ((p_n[i + 1] + 1) / 2) + p_n[i]

exp_sum = [0] * (n - k + 1)
for i in range(n - k + 1):
    exp_sum[i] = p_n[i + k] - p_n[i]
    
print(max(exp_sum))

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:k])
m = s
for i in range(1, n-k+1):
  s = s-p[i-1]+p[i+k-1]
  if s > m:
    m = s
print((m+k)/2)

Solution (Python):
s = list(map(int, input().split()))
n=s[0]
k=s[1]
s = list(map(int, input().split()))
ep=[]
for i in s:
    ep.append((1+i)/2)
s={}
s[k-1]=0
for i in range(k):
    s[k-1]+=ep[i]
for i in range(k-1,n-1):
    s[i+1]=s[i]+ep[i+1]-ep[i-k+1]
print(max(s.values()))

Solution (Python):
n, k = map(int, input().split())
p = list(int(i) for i in input().split())

kitai = [(x+1)/2 for x in p]

rui_kitai = [kitai[0]]

for i in range(1, n):
    ruiseki=rui_kitai[i-1]+kitai[i]
    rui_kitai.append(ruiseki)

gokei = 0

for i in range(n-k+1):
    if i==0:
        wa = rui_kitai[k-1]
    else:
        wa = rui_kitai[i+k-1]-rui_kitai[i-1]
    if gokei < wa:
        gokei = wa

print(gokei)

Solution (Python):
def cal_expe(x):
  ret = (1 + x) / 2
  return ret

N,K = map(int, input().split())
data = [int(i) for i in input().split()]
sma = 0
for i in range(N):
  data[i] = cal_expe(data[i]) + sma
  sma = data[i]
max_score = data[K-1]
for i in range(K-1,N):
  pro = data[i] - data[i-K]
  if pro > max_score:
    max_score = pro
print(max_score)

Solution (Python):
import numpy as np

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

begin = 0
till = K

max = np.sum(p[0:K])
partial = max
for i in range(N-K):
    partial = partial - p[begin] + p[till]
    if(max < partial):
        max = partial

    begin += 1
    till += 1

print((max + K) / 2)

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))
P = pow(1 / 6, K)

now = sum(map(lambda a: a * (a + 1) // 2 / a, A[:K - 1]))
ans = 0
for left, right in zip(A, A[K - 1:]):
    now += right * (right + 1) // 2 / right
    ans = max(ans, now)
    now -= left * (left + 1) // 2 / left

print('{:.10f}'.format(ans))

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


E = [0] * 1001

total = 0
for i in range(1, 1001):
    total += i
    e = total / i
    E[i] = e

P_to_E = [E[p] for p in P]


candidate = sum(P_to_E[:k])
candidates = [candidate]

for i in range(n-k):
    drop = P_to_E[i]
    add = P_to_E[i+k]
    candidate += add - drop
    candidates.append(candidate)

print(max(candidates))

Solution (Python):
import itertools

n, k = map(int, input().split())
p = list(map(int, input().split()))
e = []
ans = 0

def getExp(n):
    return (n*(n+1)/2) / n

for i in range(n):
    e.append(getExp(p[i]))

s = [0] + list(itertools.accumulate(e))

for i in range(k, n+1):
    temp = s[i] - s[i-k]
    ans = max(ans, temp)

print(ans)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
lis = []
for i in range(n):
    lis.append((p[i]+1)/2)

val = [0]
for i in range(1,n+1):
    val.append(val[i-1] + lis[i-1])


ans = val[k-1]
for i in range(k,n+1):
    if val[i] - val[i-k] > ans:
        ans = val[i] - val[i-k]
print(ans)

Solution (Python):
import numpy as np

n, k = map(int, input().split())
p_list = [int(i) for i in input().split()]

p_list = [0] + p_list

cum_list = []
p_sum = 0
for p in p_list:
    p_sum += p
    cum_list.append(p_sum)
    
cum_list = np.array(cum_list)
sum_list = cum_list[k:]-cum_list[:-k]
index = np.argmax(sum_list)

kitaichi = k/2 + sum_list[index]/2

print(kitaichi)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))

total = [0]
for i in range(1, 200000):
    total.append(total[i-1]+i)

ans_index = 0
cur = sum(p[0:k])
max_p = cur
for i in range(n-k+1):
    cur = cur + p[i+k-1] - p[i-1]
    if cur > max_p:
        max_p = cur
        ans_index = i
ans = 0
for i in range(k):
    ans += total[p[ans_index+i]] / p[ans_index+i]
print(ans)

Solution (Python):
import numpy
N, K = map(int, input().split())
p = numpy.array(list(map(int, input().split())))
P = []
nowsum = 0
for p1 in p:
    nowsum += p1
    P.append(nowsum)

max = 0
nowsum = 0
for i in range(N-K+1):
    if i == 0:
        temp = P[K-1]
    else:
        temp = P[i+K-1]-P[i-1]
    if max < temp:
        max = temp
        maxno = i
exsum = 0
for i in range(K):
    temp = p[i+maxno]
    exsum += (0.5*temp*(temp+1))/temp
print(exsum)

Solution (Python):
N , K = map(int,input().split())
deme = [int(i) for i in input().split() ]

cusum = [0.0] * ( N + 1 )

for x in range( len(deme) ):
    cusum[x+1] = cusum[x] + float(( deme[x] + 1 ) / 2)

ans = 0.0
for i in range( K, len(cusum)):
    if i > 0:
        pre = i - K
        kukan = cusum[i] - cusum[i-K]
        ans = max(ans, kukan)

print(ans)

Solution (Python):
[n,k]=[int(x) for x in input().split()]
P=[int(x) for x in input().split()]

E=[0]*n 
S=[0]*(n+1) 

for i in range(n):
	E[i]=(1+P[i])/2
	S[i+1]=S[i]+E[i]
max=0
for i in range(k,n+1):
	if S[i]-S[i-k] > max:
		max=S[i]-S[i-k]
print(max)

Solution (Python):
from collections import deque
N, K = map(int, input().split())
p = list(map(int, input().split()))
max_ans = 0
tmp_ans = 0
queue = deque([])
for i in range(N):
    e = (p[i] + 1) / 2 
    tmp_ans += e
    queue.append(e)
    if len(queue) > K:
        tmp_ans = tmp_ans - queue.popleft()
    max_ans = max(max_ans, tmp_ans)
print(max_ans)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = sum(p[:k])
res = tmp
for i in range(n - k):
    tmp -= p[i]
    tmp += p[i + k]
    res = max(res, tmp)
print((res + k) / 2)

Solution (Python):
n, k = map(int,input().split())
p = list(map(int, input().split()))

val = 0
for i in range(k):
    val += p[i]
point = 0

cnt = val
for i in range(k,n):
    cnt = cnt +  p[i] - p[i-k]
    if cnt > val:
        val = cnt
        point = i-k+1


ans = 0
for i in range(k):
    ans += (p[point] + 1) / 2
    point += 1

print(ans)

Solution (Python):
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)

Solution (Python):
N,K = map(int,input().split())
p = list(map(int,input().split()))
x = []
for i in p:
    if i % 2 == 0:
        x.append(i//2 + 0.5)
    else:
        x.append(i // 2 + 1)

ans = 0
for i in range(K):
    ans += x[i]

ans_list = [ans]
if N != K:
    for i in range(K,N):
        ans_list.append(ans_list[len(ans_list)-1]+x[i]-x[i-K])
print(max(ans_list))

Solution (Python):
import itertools

N, K=map(int, input().split())
p=list(map(int, input().split()))
acup=list(itertools.accumulate(map(lambda x:(x+1)/2, p)))
ans=acup[K-1]
for i in range(K, N):
    ans=max(ans, acup[i]-acup[i-K])
print(ans)

Solution (Python):
import numpy as np
n,k = map(int, input().split())
p = np.array(list(map(int, input().split())))
m = (p+1)/2
s = sum(m[:k])
r = s
for i in range(n-k):
    s -= m[i]
    s += m[i+k]
    r = max(r,s)
print(r)

Solution (Python):
from itertools import accumulate

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

A = []
for i in P:
    A.append(1/2*(i+1))
    

ans = 0
'''
for i in range(len(A)):
    ans = max(ans,sum(A[i:i+K]))
'''
    
accum = [0] + list(accumulate(A))
for i in range(len(accum)):
    ans = max(ans,accum[i] - accum[i-K])
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 
input=lambda:sys.stdin.readline().rstrip()
from collections import deque
def resolve():
    n, k =map(int,input().split())
    Q = deque([])
    sum = 0
    ans = 0
    for a in map(int,input().split()):
        Q.append(a)
        sum += a
        if(len(Q)==k):
            ans = max(ans, (sum+k)/2)
            sum -= Q.popleft()

    print(ans)
resolve()

Solution (Python):
def solve(n, k, p):
    mu = [(p[i] + 1) / 2.0 for i in range(n)]
    best = sum(mu[:k])
    cur = best
    for i in range(k, n):
        cur += mu[i] - mu[i-k]
        best = max(best, cur)
    return best

n, k = map(int, input().split())
p = list(map(int, input().split()))
print(solve(n, k, p))

Solution (Python):
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = []
R = P[K:]
s = 0.0
for i in range(K):
    Q.append((P[i]+1)/2)
s = sum(Q)
ans = s
for j in range(len(R)):
    r = (R[j] + 1)/2
    Q.append(r)
    s += (r - Q[j])
    ans = max(s,ans)
print(ans)

Solution (Python):
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n,k = LI()
p = LI()

def a(num):
    return (num+1)/2

l = [a(i) for i in p]
ll = [0] + list(itertools.accumulate(l))
ans=0
for i in range(n-k+1):
    ans = max(ans,ll[i+k]-ll[i])
print(ans)

Solution (Python):
n, k = map(int, input().split())
ppp = list(map(int, input().split()))
tot = sum(ppp[:k])
ans = tot
for i in range(k, n):
    tot += ppp[i] - ppp[i - k]
    ans = max(ans, tot)
print((ans + k) / 2)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = [0 for i in range(n)]
ans = 0
cnt = 0
for i in range(n):
  l[i] = p[i]*(p[i]+1)/(2*p[i])
if n == k:
  ans = sum(l)
else:
  ans = sum(l[:k])
  cnt = ans
  for i in range(n-k):
    cnt = cnt - l[i] + l[i+k]
    if cnt > ans:
      ans = cnt
print(ans)

Solution (Python):
n,k = map(int,input().split())
p = input().split(' ')

ans = 0

start,end = 0,k - 1
cur = 0
for i in range(k):
    cur += (int(p[i]) + 1)/2
ans = max(ans,cur)
for i in range (k,n):
    cur += ((int(p[i]) + 1)/2)
    cur -= ((int(p[i - k]) + 1)/2)
    ans = max(ans,cur)
print(ans)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
e = [(1 + p[i]) / 2.0 for i in range(n)]
res = 0
cur = 0
for i in range(k):
    cur += e[i]
res = cur
for i in range(k, n):
    cur += e[i] - e[i-k]
    res = max([res, cur])
print(res)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))

s = 0
s_max = 0

for i in range(n):
    if i < k:
        s += p[i]
        if i == k-1:
            s_max = s
    else:
        s += p[i] - p[i-k]
        s_max = max(s_max, s)

print((k+s_max)/2)

Solution (Python):
n, k = map(int, input().split())
p = [0] + list(map(int, input().split()))
for i in range(1, n+1):
    p[i] = ((p[i] + 1)/2)
    p[i] += p[i-1]
ans = 0
for i in range(1, n-k+2):
    ans = max(ans, p[i+k-1]-p[i-1])
print(ans)

Solution (Python):

from itertools import accumulate


def main():
    N, K, *P = map(int, open(0).read().split())
    
    cumsum = tuple(accumulate([0] + [(i + 1) / 2 for i in P]))
    ans = max(right - left for left, right in zip(cumsum, cumsum[K:]))
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
tmp = (sum(p[0:K]) + K) / 2
ret = tmp
for i in range(N-K):
    tmp = tmp - (p[i] - p[i+K]) / 2
    ret = max(tmp, ret)
print(ret)

Solution (Python):

from itertools import accumulate


def main():
    N, K, *P = map(int, open(0).read().split())
    
    cumsum = tuple(accumulate([0] + [i * (1 + i) / (2 * i) for i in P]))
    ans = max(right - left for left, right in zip(cumsum, cumsum[K:]))
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n,k=map(int,input().split())
A=list(map(int,input().split()))

for i in range(n-1):
    A[i+1]+=A[i]

ans=0.0
A.reverse()
A.append(0)
A.reverse()

for i in range(n-k+1):
    now=A[i+k]-A[i]
    if now>ans:
        ans=now

print((ans+k)/2)

Solution (Python):
n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n):
    A[i]+=1

for i in range(n-1):
    A[i+1]+=A[i]

ans=0.0
A.reverse()
A.append(0)
A.reverse()

for i in range(n-k+1):
    now=A[i+k]-A[i]
    if now>ans:
        ans=now

print(ans/2)

Solution (Python):
from collections import deque

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

queue = deque()
currentSum = 0
maxSum = 0
for i in range(len(p)):
    currentSum = currentSum + p[i] + 1
    queue.append(p[i] + 1)
    if i >= K:
        currentSum = currentSum - queue.popleft()

    if i >= K - 1:
        maxSum = max(maxSum, currentSum)

print("{:.12f}".format(maxSum / 2))

Solution (Python):

from itertools import accumulate


def main():
    N, K, *P = map(int, open(0).read().split())
    
    cumsum = tuple(accumulate(i * (1 + i) / (2 * i) for i in P))
    if N == K:
        print(cumsum[-1])
        return
    ans = 0
    for i in range(N - K):
        ans = max(ans, cumsum[i + K] - cumsum[i])
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n,k = map(int, input().split())
dice = list(map(int, input().split()))
dice_sum = [0]
for i in dice:dice_sum.append(dice_sum[-1]+(i+1)/2)
def SumArea(r, l):
    return dice_sum[l]-dice_sum[r]

ans = 0
for i in range(n-k+1):
    tmp = SumArea(i, i+k)
    if tmp >= ans:
        ans = tmp
print(ans)

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))

cml_sum = [(P[0]+1)/2.0]
for i in range(1, N):
    cml_sum.append(cml_sum[i-1] + (P[i]+1)/2.0)

ans = cml_sum[K-1]
for i in range(N-K):
    target = cml_sum[i+K] - cml_sum[i]
    if ans < target:
        ans = target

print(ans)

Solution (Python):
import numpy as np

N,K,*P = map(int,open(0).read().split())
E = np.cumsum([(P[i]+1)/2 for i in range(N)])



M = E[K-1]

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

print(M)

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

res = sum(p[:K])
res_max = res
i_max = 0
for i in range(1, N-K+1):
    res += p[i+K-1] - p[i-1]
    if res > res_max:
        res_max = res
        i_max = i

ans = 0
for j in range(K):
    ans += (p[i_max + j] + 1) / 2
print(ans)

Solution (Python):
import queue

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

queue = queue.Queue()
currentSum = 0
maxSum = 0
for i in range(len(p)):
    currentSum = currentSum + p[i] + 1
    queue.put(p[i] + 1)
    if i >= K:
        currentSum = currentSum - queue.get()

    if i >= K - 1:
        maxSum = max(maxSum, currentSum)

print("{:.12f}".format(maxSum / 2))

Solution (Python):
import queue

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

for i in range(len(p)):
    p[i] = p[i] + 1

queue = queue.Queue()
currentSum = 0
maxSum = 0
for i in range(len(p)):
    currentSum = currentSum + p[i]
    queue.put(p[i])
    if i >= K:
        currentSum = currentSum - queue.get()

    if i >= K - 1:
        maxSum = max(maxSum, currentSum)

print("{:.12f}".format(maxSum / 2))

Solution (Python):
import queue

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

for i in range(len(p)):
    p[i] = p[i] + 1

queue = queue.Queue()
currentSum = 0
maxSum = 0
for i in range(len(p)):
    currentSum = currentSum + p[i]
    queue.put(p[i])
    if queue.qsize() > K:
        currentSum = currentSum - queue.get()
    
    if queue.qsize() == K:
        maxSum = max(maxSum, currentSum)

print("{:.12f}".format(maxSum / 2))

Solution (Python):
import numpy as np

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

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