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):
N, K = map(int, input().split())

E = [(x*(x+1))/2/x for x in range(1, 1001)]
E = [0.0] + E

P = [E[int(p)] for p in input().split()]

ans = sum_ = sum(P[:K])

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

print(ans)

Solution (Python):
def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines
  import numpy as np 
  n,k = map(int,readline().split())
  p =  np.array(read().split(),np.int32)
  np.cumsum(p,out=p)
  chk = p[k-1]
  for i in range(n-k):
    c = p[i+k]-p[i]
    chk = max(c,chk)
  print((chk+k)/2)
if __name__ == '__main__':
    main()

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

ans = 0
for i in range(K):
    ans += p[i]
    tt = ans
for i in range(K,N):
    tt = tt+p[i]-p[i-K]
    ans = max(ans, tt)
print((ans + K)/2)

Solution (Python):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,k=n1()
p=n1()

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

ans=sum(e[0:k])
tmp=ans
for i in range(k,n):
    tmp=tmp+e[i]-e[i-k]
    ans=max(tmp,ans)
print(ans)

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

if n == k:
    print((sum(p) + k) / 2)
    sys.exit(0)
saveSum = sum(p[0:k])
M = 0
for i in range(k, len(p)):
    saveSum = saveSum + p[i] - p[i - k]
    if saveSum > M:
        M = saveSum
print((k+M)/2)

Solution (Python):
N,K = map(int,input().split())
max_total = 0
res = 0
p = list(map(int,input().split()))
for _ in range(len(p)):
  p[_] = (p[_]+1)/2
  
total = sum(p[0:K])
max_total = total
for i in range(K,N):
  if p[i] > p[i-K]:
    total = total + p[i] - p[i-K]
    max_total = max(max_total,total)
  else:
    total = total + p[i] - p[i-K]

print(max_total)

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

from collections import deque

exv = list()

for a in p:
    exv.append((1+a)/2)

sm = 0
mx = 0

q = deque()

for a in range(N):
    sm += exv[a]
    q.appendleft(exv[a])
    if len(q) > K:
        sm -= q.pop()
    if len(q) == K:
        mx = max(mx,sm)

print('{:.12f}'.format(mx))

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

from collections import deque

exv = list()

for a in p:
    exv.append((1+a)/2)

sm = 0
mx = 0

q = deque()

for a in range(N):
    sm += exv[a]
    q.appendleft(exv[a])
    if len(q) > K:
        sm -= q.pop()
    if len(q) == K:
        mx = max(mx,sm)

print('{:.12f}'.format(mx))

Solution (Python):
from collections import deque
import copy
N,K = map(int, input().split())
p = list([(i+1)* i/2/i for i in map(int, input().split())])
que = deque([0]* K)
sumM = 0
sumq = 0
E = 0.0

for i in range(N):
    sumq -= que.popleft()
    sumq += p[i]
    que.append(p[i])
    if E < sumq:
        E = sumq
print(E)

Solution (Python):
import itertools
n, k = map(int, input().split())
num = list(map(int, input().split()))
sumNum = [(1+i)/2 for i in num]
res = [0] + list(itertools.accumulate(sumNum))
ans = -1
for i in range(n-k+1):
  r = res[i+k] - res[i]
  ans = max(ans, r)
print(ans)

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

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

B = []
t = -1
init_sum = sum(A[0:k])

for i in range(n - k+1):
    if t < init_sum:
        B = A[i:i+k]
        t = init_sum
    if i != n - k:
        init_sum = init_sum - A[i] + A[i+k]


import collections
B = sorted(B)
C = collections.Counter(B)

D = list(C.keys())
E = list(C.values())
F = zip(D, E)
F = sorted(F)
D, E = zip(*F)

G = []
j = 0
total = 0
for i in range(max(D) + 1):
    total += i
    if D[j] == i:
        G.append(total)
        j += 1
ans = 0
k = 0
for i, j in zip(D, G):
    ans += (j/i) * E[k]
    k += 1
print(ans)

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

Solution (Python):
s=input()
n=s.split()
s=input()
p=s.split()
a=[]
a.append(int(p[0]))
now=a[0]
for i in range(1,int(n[0])):
	now+=int(p[i])
	a.append(now)
k=int(n[1])
m=a[k-1]
for i in range(k,int(n[0])):
	if m<a[i]-a[i-k] :
		m=a[i]-a[i-k]
print('{:.8f}'.format(m/2+k/2))

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

s = sum(p[:k])
m = s

for i in range(k, n):
    s = s + p[i] - p[i - k]
    m = max(m, s)

print((m + k) / 2)

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

exp_value = (sum(dices[:k]) + k) / 2
max_exp_value = exp_value

for i in range(n - k):
  exp_value += (dices[i + k] - dices[i]) / 2
  if exp_value > max_exp_value:
    max_exp_value = exp_value

print(max_exp_value)

Solution (Python):



def calc_kitaiti(n):
    sum_n = 0
    if n % 2 == 0:
        temp = n / 2
        sum_n = (temp * n) + temp
    else:
        temp = (n - 1) / 2
        sum_n = (n * (temp + 1))

    return sum_n / n


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    kitaitis = [0]
    pre = 0
    for _a in a:
        pre += calc_kitaiti(_a)
        kitaitis.append(pre)

    result = 0
    for i in range(k, n + 1):
        start = i - k
        result = max(result, kitaitis[i] - kitaitis[start])

    return result


if __name__ == '__main__':
    print(main())

Solution (Python):
import queue
N,K=map(int,input().split())
P=list(map(int,input().split()))
que=queue.Queue()
que_tmp=queue.Queue()
ans=0
tmp=0
cnt=0
for p in P:
    if cnt<K:
        que_tmp.put(1+p)
        tmp+=1+p
        cnt+=1
    else:
        que.put(1+p)

while not que.empty():
    dis=que_tmp.get()
    plus=que.get()
    que_tmp.put(plus)
    tmp+=plus-dis
    ans=max(ans,tmp)
print(max(ans,tmp)/2)

Solution (Python):
from collections import defaultdict


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

kitai = []
for i in p:
    if not pd[i]:
        ex = (1 + i) / 2
        kitai.append(ex)
    else:
        kitai.append(pd[i])


rui = []
for i, j in enumerate(kitai):
    if i == 0:
        rui.append(j)
    else:
        rui.append(rui[i-1] + j)

ans = 0
for i, j in enumerate(rui):
    if i + (K-1) >= N:
        continue
    else:
        if i == 0:
            ans = rui[i+K-1]
        else:
            ans = max(ans, rui[i+K-1] - rui[i-1])

print(ans)

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

Solution (Python):
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    s = sum(a[:k])
    m = s
    for i in range(n-k):
        s += a[i+k]-a[i]
        m = max(s, m)
    print((m+k)/2)


main()

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
def expect(i):
    return (i+1) / 2


S=[0]

for i, x in enumerate(p, start=1):
    S.append(S[i-1] + expect(x))
    
ans = 0    

for i in range(N - K + 1):
    r = S[i+K] - S[i]
    if r > ans:
        ans = r
print(ans)

Solution (Python):
N,K=map(int,input().split())
P=list(map(int,input().split()))
for i in range(N):
  P[i]=(P[i]+1)/2
point=sum(P[:K])
tmp=point
for i in range(N-K):
  tmp=tmp-P[i]+P[i+K]
  if tmp>point:point=tmp
  
print(point)

Solution (Python):
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
    
def ev(n):
    return (n+1)/2
    
from collections import deque
    
if K == N:
    print(sum(ev(a) for a in A))
else:
    deq = deque()
    
    while len(deq) < K:
        deq.append(ev(A.pop()))
    
    total = sum(i for i in deq)
    mx = total
    
    while A:
        out = deq.popleft()
        in_ = ev(A.pop())
        deq.append(in_)
        
        total -= out
        total += in_
        mx = max(mx, total)
    
    print(mx)

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

    p = [(p_i+1)/2 for p_i in p]
    ans = 0
    for i in range(N-K+1):
        if i == 0:
            sum_ = sum(p[i:i+K])
        else:
            sum_ = sum_ + p[i+K-1] - p[i-1]
        ans = max(ans, sum_)

    print(ans)

if __name__ == '__main__':
    main()

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

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

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

print(ans)

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

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

print((k + ans) / 2)

Solution (Python):
N,K = map(int,input().split())
p = list(map(int,input().split()))
an = 0
if K == 1:
  ans = (max(p)+1)/2
  print(ans)
else:
  ans = sum(p[0:K])
  an = ans
  for i in range(0,N-K):
    an = an +p[i+K] -p[i]
    ans = max(ans,an)
  num = ans/2 + K/2    
  print(num)

Solution (Python):
def main():
    N, K = map(int,input().split())
    P = [int(i) for i in input().split()]
    value = [((i + 1)  / 2 ) for i in P]
    now = sum(value[:K])
    ans = now
    for i in range(K,N,1):
        add = (value[i] - value[i - K])
        now = now + add
        if now > ans :
            ans = now

    print(ans)

if __name__ == '__main__':
    main()

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

p = input().split()

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

q = 0

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

expt = [q]

for i in range (K , N) :
    q -= p[i - K]
    q += p[i]
    expt.append(q)

ans = max(expt) / 2

print (ans)

Solution (Python):
n, k = list (map (int, input ().split ()))
p = [0] + list (map (int, input ().split ()))
s = [0 for i in range (n + 1)]
mx = 0
tag = 0
f = [0.0 for i in range (n + 1)]
for i in range (1, n + 1) :
    s[i] = s[i - 1] + (p[i] + 1) * p[i] / 2 / p[i]
    if (i >= k and s[i] - s[i - k] > mx) :
        mx = s[i] - s[i - k]
print (mx)

Solution (Python):
n,k = map(int, input().split())
l = list(map(int, input().split()))
el = []
sl = [0]*(n-k+1)
for i in l:
  el.append((1+i)/2)
sl[0] = sum(el[:k])
for i in range(n-k):
  sl[i+1] = sl[i]-el[i]+el[i+k]
print("{:.20}".format(max(sl)))

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

Solution (Python):
def q4():
    from itertools import accumulate

    N, K = (int(i) for i in input().split())
    P = [int(i) for i in input().split()]

    P_kitai = [0]
    
    
    for p in P:
        P_kitai.append((p+1)/2)
    accu = list(accumulate(P_kitai))
    
    max_sum = 0
    for i in range(0, N-K+2):
        max_sum = max(max_sum, accu[i+K-1] - accu[i-1])
    print(max_sum)

if __name__ == '__main__':
    q4()

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

cur = sum(exp[:k])
ans = cur

for i in range(k, n):
    cur = cur - exp[i-k] + exp[i]
    ans = max(ans, cur)

print(ans)

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

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

max_i=-1
max_v=0
for i in range(1,n+1-k):
  if b[i+k]-b[i]>max_v:
    max_i=i
    max_v=b[i+k]-b[i]
ans=0
for i in range(k):
  ans+=(p[max_i+i]+1)/2
print(ans)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    n,k = map(int, input().split())
    p = list(map(int, input().split()))
    q = [0]
    for i in p:
        q.append((i*(i+1)//2)/i)
    r = list(accumulate(q))
    res = 0
    for i in range(k, n+1):
        res = max(res, r[i]-r[i-k])
    print(res)

if __name__ == '__main__':
    main()

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

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

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

s=[0]*(n+1)
for i in range(n):
    s[i+1]=s[i]+e[i]

ans=0
for i in range(n-k+1):
    total=s[i+k]-s[i]
    if total >= ans:
        ans=total
        
print(ans)

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

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

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

print(ans)

Solution (Python):
N, K = map(int, input().split(" "))
expect = [(int(p) + 1) / 2 for p in input().split(" ")]
e_sum = 0
for i in range(0, K):
  e_sum += expect[i]
  
ans = e_sum
for i in range(K, N):
  e_sum += expect[i]
  e_sum -= expect[i - K]
  ans = max(ans, e_sum)

print(ans)

Solution (Python):
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
sumls=[0 for _ in range(N-K+1)]
sumls[0]=sum(ls[:K])
for i in range(N-K):
  sumls[i+1]=sumls[i]+ls[K+i]-ls[i]
x=max(sumls)
print((x+K)/2.0)

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

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

c=[0]*len(p) 

for i in range(len(p)):
  if i>0:
    c[i]=(((p[i]+1)*p[i])/(2*p[i]))+c[i-1]
  else:
    c[i]=(((p[i]+1)*p[i])/(2*p[i]))

maxev=0

for i in range(len(p)-k+1):
  ev=0

  if i==0:
    ev=c[i+k-1]
  else:
    ev=c[i+k-1]-c[i-1]

  if maxev==0 or maxev<ev:
    maxev=ev

print(maxev)

Solution (Python):
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    exp_table = [0] * 200002
    curr_sum = 0
    for i in range(1, 200002):
        curr_sum += i
        exp_table[i] = curr_sum / float(i)
    curr_sum = 0
    max_v = float('-inf')
    for i in range(len(p)):
        if i+1 < K:
            curr_sum += exp_table[p[i]]
        elif i+1 == K:
            curr_sum += exp_table[p[i]]
            max_v = max(max_v, curr_sum)
        else:
            curr_sum = curr_sum - exp_table[p[i-K]] + exp_table[p[i]]
            max_v = max(max_v, curr_sum)
        
    print(max_v)
resolve()

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):
n,k = map(int,input().split())
num_list = list(map(int , input().split()))
candidate = 0
for i in range(n-k+1):
    if i == 0:
        for j in range(k):
            candidate += (num_list[j]+1)/2
        tmp = candidate
    else:
        tmp += -(num_list[i-1]+1)/2 + (num_list[i+k-1]+1)/2
        if tmp > candidate:
            candidate = tmp
        
print(candidate)

Solution (Python):

import sys


def solve(N: int, K: int, p: "List[int]"):
    expectation = [1]*1000
    for i in range(1, len(expectation)):
        expectation[i] = expectation[i-1]+i+1
    for i in range(len(expectation)):
        expectation[i] /= (i+1)
    costs = [0]*(N-K+1)
    for i in range(K):
        costs[0] += expectation[p[i]-1]
    for i in range(1, len(costs)):
        costs[i] = costs[i-1] - expectation[p[i-1]-1]+expectation[p[i+K-1]-1]
    print(max(costs))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    p = [int(next(tokens)) for _ in range(N)]  
    solve(N, K, p)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = [(1/num)*(num)*(num+1)/2 for num in p]
d = deque(p[:k])
result = temp = sum(d)
popleft = d.popleft
dappend = d.append
for el in p[k:]:
    temp -= popleft()
    dappend(el)
    temp += el
    if result < temp:
        result = temp
print(result)

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

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

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

S = [0]
E = []

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

for i in range(0, N-K+1):
    E.append(S[i+K]-S[i])


print((max(E)+K)/2)

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

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

ans = sum(p[:K])
tmp = ans

for i in range(N-K):
    tmp += -p[i] + p[i+K]
    if tmp > ans:
        ans = tmp

print(ans)

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
ansmax = 0
ans = 0
for j in range(K):
  ans += (p[j]+1)/2
if(ansmax < ans):
  ansmax = ans
for i in range(N-K):
  ans =  ans - (p[i]+1)/2 + (p[i+K]+1)/2
  if(ansmax < ans):
    ansmax = ans
print(ansmax)

Solution (Python):
n,k=map(int,input().split())
a=[int(j) for j in input().split()]
ma=0.0
for i in range(0,k):
    temp=(1+a[i])
    temp=temp*a[i]
    temp=temp//2
    ma+=(temp/a[i])

sum=ma


for i in range(k,n):
    temp=(1+a[i])
    temp=temp*a[i]
    temp=temp//2
    temp=temp/a[i]

    temp1=(1+a[i-k])
    temp1=temp1*a[i-k]
    temp1=temp1//2
    temp1=temp1/a[i-k]

    sum=(sum+temp)-temp1
    if(sum>ma):
        ma=sum

print(ma)

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

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

sum = 0
e = [0] * 1001
for i in range(1, 1000 + 1):
    sum += i
    e[i] = sum / i
    


maxV = 0
maxI = 0
for i in range(0, K):
    maxV += p[i]

tmp = maxV

for i in range(1, N-K+1):
    tmp -= p[i-1]
    tmp += p[i+K-1] 
    if tmp > maxV:
        maxV = tmp
        maxI = i
    
    
    
    
    

ans = 0
for i in range(maxI, maxI + K):
    ans += e[p[i]]

print(ans)

Solution (Python):
x,y = map(int,input().split())
li = list(map(int,input().split()))
from collections import deque
l = []
for i in range(len(li)):
    l.append((1+ li[i])/2)
from itertools import accumulate
a = list(accumulate(l))
M = a[y-1]
for i in range(len(a)-y):
    m = a[i+y] - a[i]
    if m > M:
        M = m
print(M)

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

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

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

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

import numpy as np
exps = np.array(p) / 2 + 0.5









cum = exps.cumsum()
diff = cum[k-1:n] - np.r_[0, cum[:n-k]]
print(diff.max())

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

import numpy as np
exps = np.array(p) / 2 + 0.5

s = exps[:k].sum()
m = s
for i in range(1, n - k + 1):
    s = s - exps[i-1] + exps[i+k-1]
    if s > m:
        m = s
print(m)

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

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

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

data = np.fromstring(read(), np.int64, sep =' ')

N, K = data[:2]
P = np.hstack([[0], data[2:] + 1])

Pcum = P.cumsum()
x = Pcum[K:] - Pcum[0:-K]
print(x.max()/2)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

data = np.fromstring(read(), np.int64, sep=' ')

N, K  = data[:2]
P = np.hstack([[0], data[2:] + 1])

Pcum = P.cumsum()
x = Pcum[K:] - Pcum[0:-K]
print(x.max() / 2)

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))
lst = [0]
for x in P:
  lst.append(lst[-1] + (x+1)/2)

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

print("{:.6f}".format(res))

Solution (Python):

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

r=[0]*(n+1)
s=0
for i in range(n):
    s+=p[i]
    r[i+1]=s


def kitaichi(x):
    return (k+x)/2

ans=0
for i in range(n-k+1):
    kitai=r[i+k]-r[i]
    ans=max(kitai,ans)
print(kitaichi(ans))

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
    if a[i]%2==1:
        b[i]=(a[i]+1)//2
    else:
        b[i]=(a[i]+1)/2
from itertools import accumulate
ac=list(accumulate(b))
ans=0
for i in range(n-k+1):
    if i==0:
        tmp=ac[k-1]
    else:
        tmp=ac[i+k-1]-ac[i-1]
    ans=max(tmp,ans)
print(ans)

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

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

E = [(p + 1) / 2 for p in P]

answer = temporary = sum(E[:k])
for i in range(n - k):
    temporary += E[i + k] - E[i]
    answer = max(answer, temporary)

print(answer)

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

j = 0
for i in range(k):
    j += p[i]
ma = j

for i in range(k, n):
    j = j - p[i - k] + p[i]
    ma = max(ma, j)
print((ma+k)/2)

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

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

from itertools import accumulate
Q = [0]+P
Q = list(accumulate(Q))

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

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

loop_time = N - K

l_s = 0
l_e = K
max_score = 0
test_score = 0

ans_list = p_list[l_s:l_e]
for j in ans_list:
    max_score += sum(range(1,j+1)) / j
    test_score = max_score
l_s = l_s + 1

for i in range(loop_time):
    
    pop_e = p_list[l_s-1]
    test_score = test_score - sum(range(1,pop_e+1)) / pop_e
    
    push_e = p_list[l_e]
    test_score = test_score + sum(range(1,push_e+1)) / push_e
    if test_score > max_score:
        max_score = test_score
    l_s = l_s + 1
    l_e = l_e + 1

print(max_score)

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

a = 0
for i in range(N - K + 1):
  if i == 0:
    b = sum(p[0:K])
  else:
    b = b - p[i-1] + p[i + K - 1]
  
  if b > a:
    a = b
    f = i

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

print(ans)

Solution (Python):
from itertools import accumulate
n,k = map(int, input().split())
p = list(map(int,input().split()))
b = []
for i in p:
    b.append((i+1)/2)
c = list(accumulate([0] + b))
ans = []
for j in range(len(b)-(k - 1)):
    ans.append (c[j + k] - c[j])
print(max(ans))

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

me = [0]
for i in range(n):
    p = (P[i] * (P[i] + 1) / 2) / P[i]
    me.append(me[(i+1)-1]+p)

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

Solution (Python):

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

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

for i in range(n - k):
    tmp3 = (p[i] * (1 + p[i])) // 2
    tmp4 = (p[i + k] * (1 + p[i + k])) // 2
    tmp = tmp + (tmp4 / p[i + k]) - (tmp3 / p[i])
    
    
    
    if tmp > ans:
        ans = tmp
print(ans)

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

Q = [(p + 1) / 2 for p in P]
now = sum(Q[:K])
ans = now
for i in range(N - K):
    now -= Q[i]
    now += Q[i + K]
    ans = max(ans, now)
print(ans)

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

E2=[p+1 for p in P]
for i in range(N-1): E2[i+1]+=E2[i]
E2=[0]+E2

ans2=0
for i in range(N-K+1):
    ans2 = max(ans2, E2[i+K]-E2[i])
print(ans2/2)

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

print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, k = MAP()
p = LIST()
psum = [0 for _ in range(n - k + 1)]
for i in range(k):
    psum[0] += (p[i] + 1) / 2
for i in range(1, n - k + 1):
    psum[i] = psum[i - 1] + (p[i + k - 1] + 1) / 2 - (p[i - 1] + 1) / 2
print(max(psum))

Solution (Python):
def main():
    N, K = (int(i) for i in input().split())
    P = [int(i) for i in input().split()]
    B = [(p+1)/2 for p in P]
    from itertools import accumulate
    S = list(accumulate([0] + B))
    
    ans = 0
    for i in range(N-K+1):
        cur = S[i+K] - S[i]
        ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()

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

sum_ = sum(p[0:k])
max_ = sum(p[0:k])
for i in range(k, n):
    sum_ += p[i] - p[i - k]
    max_ = max(sum_, max_)

print((max_ + k) / 2)

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

Solution (Python):
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:K])
m = s
for i in range(K, N):
    s += p[i] - p[i-K]
    m = max(m, s)
print((m + K) / 2)

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

cums = [0]
for p in P:
    cums.append(cums[-1] + (p+1)/2)
ans = 0
for i in range(N-K+1):
    ans = max(ans, cums[i+K] - cums[i])
print(ans)

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

S = []

a = 0
for i in range(N):
  a += P[i]
  S.append(a)

B = []
for i in range(N-K+1):
  if i == 0:
    B.append(S[K-1])
  else:
    B.append(S[(K-1)+i]-S[-1+i])

print(max(B)/2 + K/2)

Solution (Python):
import numpy as np
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
p_sum=[0]
for i in p:p_sum.append(p_sum[-1]+i)
max_sum_val = 0
for j in range(len(p_sum) - K):
    max_sum_val = max(p_sum[K+j]-p_sum[j], max_sum_val)
print((max_sum_val + K)/2)

Solution (Python):
n, k = map(int, input().split())
p =[int(s) for s in input().split()]
s = 0
key = 0
pred = 0
acc = {}
for h in range(n):
    if h == 0:
        acc[0] = p[0]
    else:
        acc[h] = acc[h-1]+p[h]
for r in range(n-k+1):
    if r == 0:
        s2 = acc[k-1]
    else:
        s2 = acc[k+r-1]-acc[r-1]
    if s2>s:
        s = s2
        key = r
print(0.5*(s+k))

Solution (Python):

from itertools import accumulate

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

Solution (Python):
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
r=sum(A[0:K])
re=r
for i in range(N-K):
    r=r+A[K+i]-A[i]
    if r > re:
        re=r
        
print((re+K)/2)

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

hoge=0
for i in range(K):
    hoge += A[i]

re=hoge
for i in range(N-K):
    hoge=hoge+A[K+i]-A[i]
    if hoge >= re:
        re=hoge
        
print((re+K)/2)

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

res = []

res.append((sum(range(1,p[0]+1)))/p[0])

for i in range(1,N):
  
  res.append(res[i-1] + 0.5*(p[i]+1))
  

ans=res[K-1]

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

Solution (Python):
import numpy as np
N,K = (int(x) for x in input().split())
p1 = np.array(list(map(int, input().split())))
s1 = p1.cumsum()
s2 = np.append(0, s1)
p2 = np.array([(s2[i+K] - s2[i]) for i in range(N-K+1)])
max = np.amax(p2)
print((max+K) / 2)