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())
p=list(map(int,input().split()))

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


cnt=0
for i in range(len(a)-1):
    cnt=max(cnt,a[i+1]-a[i-k+1])

print(cnt)

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

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

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

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

Solution (Python):

def main():
    import sys
    N, K = map(int, sys.stdin.readline().split())
    P = list(map(int, sys.stdin.readline().split()))
    L =[0 for _ in range(N)]
    
    for i in range(N):
        L[i]=(1 +P[i])/2
    
    
    for i in range(N-1):
        L[i+1] +=L[i]
    
    ans = L[K-1]
    for i in range(N-K):
        s = L[i+K]-L[i]
        if ans < s:
            ans = s
    print(ans)

if __name__=='__main__':
    main()

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


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

tmp = sum(map(E, P[:K]))
res = tmp

for i in range(1, N - K + 1):
    tmp = tmp - E(P[i - 1]) + E(P[i + K - 1])
    res = max(res, tmp)

print(res)

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

E = []
for p in P:
    e = ((p * p + p) / 2) * (1 / p)
    E.append(e)

memo = sum(E[:K])
ans = memo
for i in range(0, N - K):
    memo = memo - E[i] + E[i + K]
    ans = max(ans, memo)

print(ans)

Solution (Python):

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

  total = sum(p[:K])
  

  max_total = total
  max_start_i = 0

  for i in range(1, N-K+1):
    total = total-p[i-1]+p[i-1+K]
    
    if total > max_total:
      max_total = total
      max_start_i = i

  

  print(sum([(1+p)/2. for p in p[max_start_i:max_start_i+K]]))

main()

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

expected_value = []
for i in range(len(p)):
    expected_value.append((p[i] + 1)/ 2)


cumsum = []
cumsum_temp = 0
for i in range(len(p) - K + 1):
    if i == 0:
        cumsum_temp = sum(expected_value[:K])
    else:
        cumsum_temp = cumsum_temp - expected_value[i - 1] + expected_value[i + K - 1]
    cumsum.append(cumsum_temp)


print(max(cumsum))

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

s=[0]*(n+1)

for i in range(1,n+1):
  s[i]=s[i-1]+1/2*(p[i-1]+1)
res=s[k]
for i in range(n-k+1):
  res = max(res,s[i+k]-s[i])
print(res)

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

meanList = []

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

sums = [0]

for a in meanList:
    sums.append(sums[-1] + a)

ans = 0

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

print(ans)

Solution (Python):
def f(n, k, p):
    p = [(i+1)/2 for i in p]
    sums = sum(p[:k])
    mx = sums
    for i in range(k, n):
        sums = sums - p[i - k] + p[i]
        
        if sums > mx:
            mx = sums
    print(mx)

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

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


ans = 0
for i in range(len(P)-K+1):
    if i == 0:
        c = sum(P[:K])
    else:
        c = c + P[i+K-1] - P[i-1]
    if c > ans:
        ans = c


print((ans+K)/2)

Solution (Python):


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


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



def dice_expectations(num:int)->float:
    return (num+1) / 2


E = list(map(dice_expectations, P)) 


tmp = sum(E[0:k])
ans = 0

for i in range(n-k+1):
    if tmp > ans:
        ans = tmp
    else:
        pass
    if i != n-k:
        tmp -= E[i]     
        tmp += E[k+i]   
    else:
        pass

print(ans)

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

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

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

ans = [psum[k+i] - psum[i] for i in range(n-k+1)]
print((max(ans)+k) / 2)

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

Solution (Python):
N, K = map(int, input().split())
*p, = map(int, input().split())
Ep = [(x + 1) / 2 for x in p]
S = [0 for _ in range(N+1)]

for i in range(N):
  S[i+1] = S[i] + Ep[i]
m = 0
for i in range(N):
  if i + K > N:
    break
  m = max(m, S[i+K]-S[i])
print(m)

Solution (Python):
N, K = map(int, input().split())
*p, = map(int, input().split())
Ep = [(x + 1) / 2 for x in p]
sums = [0 for _ in range(N - K + 1)]
sums[0] = sum(Ep[:K])
for i in range(N-K):
  sums[i+1] = sums[i]+Ep[i+K]-Ep[i]
print(max(sums))

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

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

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

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

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

ans = 0
for i in range(1, K + 1):
    ans += E[i]

cur = ans
for i in range(1, N - K + 1):
    cur = cur - E[i] + E[i + K]
    if cur > ans:
        ans = cur
print(ans)

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
def P(x):
    return (x+1)/2
a=0
y=0
for i in range(N):
    y+=P(p[i])
    if i>=K:
        y-=P(p[i-K])
    if a<y:
        a=y
print(a)

Solution (Python):
import numpy as np
N,K=map(int,input().split())
p=list(map(int,input().split()))
E=[]
for i in range(N):
  E.append((1+p[i])/2)
S=np.cumsum(E)
max=0
if N!=K:
  for i in range(N-K+1):
    if S[i+K-1]-S[i-1]>max:
       max=S[i+K-1]-S[i-1]
  print(max)
else:
  print(sum(E))

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

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

a = sum(p[:k])
ans = a

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

Solution (Python):
n, k = map(int, input().split())
p = list(map(float, input().split()))
tmp = sum(p[:k])
ans = 0

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

ans = max(ans, tmp)
print((ans + k) / 2)

Solution (Python):
dice_num, use_num = [int(n) for n in input().rstrip().split()]

points = [int(n) for n in input().rstrip().split()]

sum = sum(points[:use_num])
max_sum = sum
    
for i in range(dice_num-use_num):
    next = sum + points[i+use_num] - points[i]
    max_sum = max(next,max_sum)
    sum = next
    
max_sum_expectation = (use_num + max_sum)/2

print(max_sum_expectation)

Solution (Python):


if False:
    S,T=input().split()
    A,B=map(int,input().split())
    U=input()
    if U==S:
        A-=1
    else:
        B-=1
    print(A,B)

if False: print('x'*len(input()))

if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    print('YES' if len(A)==len(set(A)) else 'NO')

if True:
    N,K=map(int,input().split())
    P=[int(i) for i in input().split()]
    E=[(p+1)/2 for p in P]
    
    ans=tmp=sum(E[0:K])
    l,r=1,K
    while r<len(E):
        
        tmp=tmp-E[l-1]+E[r]
        ans=max(ans,tmp)
        
        l+=1
        r+=1
    print(ans)

Solution (Python):
[N,K]=[int(item)for item in input().split()]
p = [int(item) for item in input().split()]
su = sum(p[0:K])
maxsu=su
ind=0
for i in range(0, N-K):
    su=su - p[i] + p[i + K ]
    if su > maxsu:
        ind = i+1
        maxsu=su



print(sum([n*(n+1)/(2*n) for n in p[ind:ind+K]]))

Solution (Python):
import math
import sys
N,K=map(int,input().split())
pi=list(map(int,input().split()))
dice=[0]*N
for i in range(N):
    dice[i]=pi[i]*(pi[i]+1)/2/(pi[i])

a = sum(dice[0:K])
max=a
for i in range(1,N-K+1):
    a=a-dice[i-1]+dice[K+i-1]
    
    if a>max:
        max=a

print(max)

Solution (Python):
N, K =map(int, input().split())
P = list(map(float, input().split()))
EXP = [0]*N
for i in range(N):
    if P[i] == 1:
        EXP[i] = 1
    else:
        EXP[i] = (P[i]+1)/2
ADD = [0]*N
for i in range(N):
    if i == 0:
        ADD[i] = EXP[i]
    else:
        ADD[i] = ADD[i-1] + EXP[i]
SUM = [0]*N
for i in range(K-1, N):
    if i == K-1:
        SUM[i] = ADD[K-1]
    else:
        SUM[i] = ADD[i] - ADD[i-K]
print(max(SUM))

Solution (Python):
from itertools import accumulate
N,K = map(int,input().split())
P = [(int(i) + 1) / 2 for i in input().split()]
ans = []
hope = [0] + list(accumulate(P))

for j in range(N-K+1):
  ans.append(hope[j+K]-hope[j])
print(max(ans))

Solution (Python):

"""
Created on Sun Apr 12 04:56:52 2020

@author: Kanaru Sato
"""

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

sum = 0
sumlist = [0]
for i in range(n):
    sum += p[i]
    sumlist.append(sum)


Max = -100000
for i in range(n-k+1):
    e = sumlist[i+k]-sumlist[i]
    if Max < e:
        Max = e

print((Max+k)/2)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

Solution (Python):

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
P = np.array(lr())
P = np.hstack([[0], P+1])
Pcum = P.cumsum()
result = Pcum[K:] - Pcum[:-K]
answer = result.max()
print(answer / 2)

Solution (Python):

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
P = np.array([0] + lr(), np.float64)
P = (P+1) / 2
Pcum = P.cumsum()
expectation = Pcum[K:] - Pcum[:-K]
answer = expectation.max()
print(answer)

Solution (Python):
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""

n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append((a[i]+1)/2)
c=[]
s=sum(b[0:k])
for i in range(k-1,n):
    c.append(s)
    if(i==n-1):
        break
    s=s+b[i+1]-b[i-k+1]

print(max(c))

Solution (Python):
a,b=map(int,input().split())
List=list(map(int,input().split()))
t=-1
S=[0]
for i in range(a):
    S+=[S[i]+List[i]]
t=-1
for i in range(a-b+1):
    if S[i+b]-S[i]>t:
        t=S[i+b]-S[i]
print((t+b)/2)

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

rsum = [(p[0] + 1) / 2]
for i in range(1, n):
  rsum.append((p[i] + 1) / 2 + rsum[i-1])
  
result = 0
if (n == k):
  result = rsum[-1]

else:
  for i in range(n-k):
    if result < rsum[i+k] - rsum[i]:
      result = rsum[i+k] - rsum[i]

print(result)

Solution (Python):
from collections import deque 
n,k = map(int,input().split())
p = list(map(int,input().split()))
q = deque()
s = 0
m = 0
ans = 0
for i in range(len(p)):
  p[i]+=1
for j in range(n):
  s+=p[j]
  q.append(p[j])
  if len(q)>k:
    s-=q.popleft()
  if len(q)==k:
    m = max(m,s)
ans = m
ans/=2
print(ans)

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

rsum  = [0]*n
for i in range(n):
    rsum[i] = (p[i]+1) / 2
    if(i != 0):
        rsum[i] = rsum[i] + rsum[i-1]

result = 0
if(n == k):
    result = rsum[n-1]
else:
    for i in range(n-k):
        if(result < rsum[i+k] - rsum[i]):
            result = rsum[i+k] - rsum[i]
print(result)

Solution (Python):
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n,k = l_in()
P = list(map(lambda p: (1+p)/2, l_in()))

res = sum(P[:k])
current = res

for i in range(k, n):
    current -= P[i-k]
    current += P[i]
    res = max(res, current)

print(res)

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

Solution (Python):
input_line=input().split(" ")
N,K=int(input_line[0]),int(input_line[1])
P=input().split(" ")
cumsum=[0]
tol=0
for i in range(N):
    P[i]=(int(P[i])+1)/2
    tol=tol+P[i]
    cumsum.append(tol)
    
k_sum=[]

for i in range(N-K+1):
  k_sum.append(cumsum[i+K]-cumsum[i])  

ans=max(k_sum)
print(ans)

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

    def expectation(x):
        return (1 + x) / 2

    e = map(expectation, p)

    def accumulation(a):
        s = 0
        yield s
        for x in a:
            s += x
            yield s

    *acc, = accumulation(e)

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

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

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

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n,k = input_list()
  p = input_list()
  kakus = [0]*(n+1)
  for i in range(1, n+1):
    kaku = (1+p[i-1])/2
    pre = kakus[i-1]
    kakus[i] = kaku+pre
  ans = []
  for i in range(len(p)-k+1):
    ans.append(kakus[i+k]-kakus[i])
  print(max(ans))
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Solution (Python):
def main():  
  import sys
  input = sys.stdin.readline
  import numpy as np 
  n,k = map(int,input().split())
  p = np.array(input().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()))
p=[pp+1 for pp in p]
ans=sum(p[0:k])
last=ans
for i in range(n-k):
  tmp=last-p[i]+p[i+k]
  ans=max(ans,tmp)
  last=tmp

ans/=2
print(ans)

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

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

print(ans)

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):
def examA():
    def calc_L(x1,y1,x2,y2):
        return ((x2-x1)**2 + (y2-y1)**2)**0.5
    N = I()
    X = [LI()for _ in range(N)]
    ans = 0
    for x in itertools.permutations(X):
        cur = 0
        for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        
        ans += cur
    for i in range(1,N+1):
        ans /= i
    print(ans)
    return

def examB():
    def judge(n):
        sn = 0
        for i in n:
            sn += int(i)
        if int(n)%sn==0:
            return "Yes"
        return "No"
    N = SI()
    ans = judge(N)
    print(ans)
    return

def examC():
    N, K = LI()
    P = LI()
    ans = 0
    S = [0]*(N+1)
    for i in range(N):
        S[i+1] = S[i]+(P[i]+1)/2
    for i in range(N-K+1):
        cur = S[i+K] - S[i]
        if cur>ans:
            ans = cur
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examC()

"""

"""

Solution (Python):



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

E = [0]*N

for i, a in enumerate(A):
    E[i] = (a+1)/2

L = [0]*N

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


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

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

s = sum((pi+1)/2 for pi in p[:K])
m = s
for i, pi in enumerate(p):
    if i < K:
        continue
    s -= (p[i-K]+1)/2
    s += (p[i]+1)/2
    if s > m:
        m = s

print(m)

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

Solution (Python):



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


kitai_list = [0]*N
for i in range(N):
    p = p_list[i]
    p_sum = (1 + p)*p / 2
    p_ave = p_sum / p
    kitai_list[i] = p_ave
max_score = -1


tmp = 0
for i in range(N):
    if i-K<0:
        tmp += kitai_list[i]
        max_score = max(max_score, tmp)
    else:
        tmp -= kitai_list[i-K]
        tmp += kitai_list[i]
        max_score = max(max_score, tmp)


print(max_score)

Solution (Python):
import numpy as np
n,k = map(int,input().split())
p = list(map(int,input().split()))
cs = []
for x in p:
    cs.append(((x+1)*x//2)/x)
cs = [0]+np.cumsum(cs).tolist()
ans = 0
for i in range(k, n+1):
    ans = max(ans, cs[i]-cs[i-k])
print(ans)

Solution (Python):

n,k=map(int,input().split())
p=list(map(int,input().split()))
e=[]
for pp in p:
    e.append((pp+1)/2)
ans=0
t=0
for i in range(n-k+1):
    if i==0:
        t=sum(e[:k])
        ans=t
        continue
    t-=e[i-1]
    t+=e[i+k-1]
    ans=max(ans,t)
print(ans)

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

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

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

print(ans)

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

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

P = [(int(i) + 1) / 2 for i in input().split()]

from itertools import accumulate

P = [0] + list(accumulate(P))

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

print(ans)

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
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()
for i in range(n):
    a[i] = (a[i]+1)/2
cnt = sum(a[:k])
res = cnt
for i in range(n-k):
    cnt -= a[i]
    cnt += a[k+i]
    res = max(res,cnt)
print(res)

Solution (Python):
from itertools import accumulate



def expectation(n):
    return (n + 1) / 2


def main():
    n, k = map(int, input().split())
    p = [0] + list(map(int, input().split()))
    n += 1
    for i in range(1, n):
        p[i] = expectation(p[i])
    p = list(accumulate(p))
    answer = 0
    for i in range(n - k + 1):
        answer = max(answer, p[i + k - 1] - p[i - 1])
    print(answer)


if __name__ == '__main__':
    main()

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

pl = [(p+1) / 2 for p in pl]
import itertools

pl_ac = [0] + list(itertools.accumulate(pl))

ans = 0
for i in range(len(pl_ac) - k):
    ans = max(ans, pl_ac[i + k] - pl_ac[i])

print(ans)

Solution (Python):
N,K = map(int,input().split())
ruiseki = [0]*(N+1)
now = 0
maximum = -999999999
ans = 0
p = list(map(int,input().split()))
for i in range(N):
    now += p[i]
    ruiseki[i+1] = now
for i in range(0,N-K+1):
    P = ruiseki[i+K]-ruiseki[i]
    if P > maximum:
        maximum = P
        Q = p[i:i+K]
for i in range(len(Q)):
    ans += (0.5*Q[i]*(Q[i]+1))/Q[i]
print(ans)

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

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

sm = sum(ds[:K])
out = sm
for i in range(N-K):
    sm = sm-ds[i]+ds[i+K]
    out = max(out,sm)

print((out+K)/2)

Solution (Python):


import numpy as np


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


def pront(X):
    
    
    if debug==0:
        print(X)


debug=1




pront(P)

def d_1(p):
    
    return((p+1)/2)


P=list(d_1(P))

pront(P)

X=[0]
for i in range(N):
    if i==0:
        X.append(P[i])
    else:
        X.append(P[i]+X[-1])
result=-1
pront(X)
for i in range(N-K+1):
    cal=X[i+K]-X[i]
    if result<cal:
        result=cal
print(result)

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

maxsum = -1
cul = sum(pe[0:k])
maxsum = cul
for i in range(1,n-k+1):
    cul = cul - pe[i-1] + pe[i+k-1]
    if cul > maxsum:
        maxsum = cul
print(maxsum)

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



tmp = sum(P[0:K])
result = tmp

for i in range(1, N-K+1):
    tmp += (P[i+K-1] - P[i-1])
    if (tmp > result):
        result = tmp

print((result+K)/2)

Solution (Python):
from itertools import accumulate

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

cumsum = [0] + list(accumulate(P))


res = []
for i in range(N-K+1):
    res.append(cumsum[i+K] - cumsum[i])

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

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

excepted = [(v*(v+1) / 2) / v for v in p]

left = 0
right = 0

ans = 0
tmp = 0

while True:
    ans = max(tmp,ans)
    if left == n : break
    if right - left < k and right != n:
        tmp += excepted[right]
        right += 1
    else:
        tmp -= excepted[left]
        left += 1

print(ans)

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

cumsum = [0]*(N+1)
for i in range(1, N+1):
    cumsum[i] = cumsum[i-1] + P[i-1]
ans = 0
for i in range(N-K+1):
    if ans < cumsum[i+K]-cumsum[i]:
        ans = cumsum[i+K]-cumsum[i]
print(ans)

Solution (Python):
N,K = map(int, input().split())
P = list(map(int, input().split()))
L = []
S = [0]
for i in range(N):
    if P[i] % 2 == 0:
        L.append((P[i]+1)*(P[i]//2)*(1/P[i]))
    else:
        L.append(((P[i]+1)*(P[i]//2)+(P[i]//2+1))*(1/P[i]))
    S.append(L[-1]+S[-1])
n = 0
for i in range(N-K+1):
    n = max(n,S[i+K]-S[i])
print(n)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
i = k
total = maximum = sum(p[0:k])
i = k
while i < n:
    total = total-p[i-k]+p[i]
    maximum = max(maximum, total)
    i += 1
print((maximum+k)/2)

Solution (Python):
N, K = map(int,input().split())
pn = list(map(int,input().split()))
num = [0]*(N-K+1)
num[0] = sum(pn[0:K])
for n in range(1,N-K+1):
  num[n] = num[n-1] - pn[n-1] + pn[n+K-1]
print(0.5*(K + max(num)))

Solution (Python):
import numpy as np
N, K = map(int, input().split())
Ps = np.array(input().split(), dtype=int)

cumsum = Ps.cumsum()
cumsum = np.concatenate([[0], cumsum])
moving_cumsum = cumsum[K:] - cumsum[:-K]

res = (moving_cumsum.max() + K) / 2
print(res)

Solution (Python):
n, k = map(int, input().split())
p = list(map(lambda pi: (int(pi) + 1) / 2, input().split()))
ex = sum(p[:k])
mx = ex
for i in range(n - k):
    ex += p[i + k] - p[i]
    if mx < ex:
        mx = ex
print(mx)

Solution (Python):
import sys
input = sys.stdin.readline
n, k = map(int,input().split())
p = list(map(int, input().split()))
p = [(1+i)/2 for i in p]

s = [0] * (n+1)
for i in range(1,n+1):
    s[i] = s[i-1] + p[i-1]
max = -1 * float("inf")
for i in range(n-k+1):
    sum = s[k+i] - s[i]
    if max <= sum:
        max = sum
print(max)

Solution (Python):
N,K = map(int,input().split())
P = list(map(int,input().split()))
goukei = 0
max = 0
startnum = 0
for i in range(K):
    goukei += P[i]

for i in range(N-K):
    goukei = goukei - P[i] + P[i+K]
    if goukei > max:
        max = goukei
        startnum = i+1
        
answer = 0
for i in range(startnum,startnum+K):
    n = P[i]
    answer += n*(n+1)/2/n
print(answer)

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

e_list = [(int(s) + 1) / 2 for s in input().split()]

temp = sum(e_list[:k])
ans = temp

for i in range(k, n):
    temp = temp - e_list[i - k] + e_list[i]
    if temp > ans:
        ans = temp

print(ans)

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

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

if __name__ == '__main__':
    main()

Solution (Python):
from itertools import accumulate
n, k = map(int,input().split())
p = list(map(int,input().split()))
kt = []
for i in range(n):
    kt.append((p[i]*(p[i]+1)/2/p[i]))
skt = sum(kt)

ac = [0] + list(accumulate(kt))
ans = -float('inf')
for i in range(n-k+1):
    ans = max(ans, ac[i+k] - ac[i])
print(ans)

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

sum_p = 0
sum_list = []
sum_list.append(sum_p)
for p_element in p:
    sum_p += p_element 
    sum_list.append(sum_p)

sum = 0
start = 0
for i in range(N-K+1):
    if sum < sum_list[i+K]-sum_list[i]:
        sum = sum_list[i+K]-sum_list[i]
        start = i

answer = 0
for i in range(K):
    answer += (1+p[start+i])/2
print(answer)

Solution (Python):
import queue
q = queue.Queue()
N,K = map(int,input().split())
ds = list(map(int,input().split()))

sm = sum(ds[:K])
out = sm
for i in range(N-K):
    sm = sm-ds[i]+ds[i+K]
    out = max(out,sm)

print((out+K)/2)

Solution (Python):
N,K=input().split()
n,k=int(N),int(K)
p=list(input().split())
ans = 0

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

pre=[0 for i in range (n+1)]
q=[0 for i in range (n-k+100)]


pre[0]=p[0]
for i in range(n):
    pre[i+1]=pre[i]+p[i]

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

print ((ans + k) / 2)

Solution (Python):
N,K=input().split()
n,k=int(N),int(K)
p=list(input().split())
ans = 0

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

pre=[0 for i in range (n+1)]
q=[0 for i in range (n-k+100)]


pre[0]=p[0]
for i in range(n):
    pre[i+1]=pre[i]+p[i]

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

print ((ans + k) / 2)

Solution (Python):

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

sm = sum(p[:k])
adj_sum = [sm]
for i in range(k,n):
  sm -= p[i-k]
  sm += p[i]
  adj_sum.append(sm)
  
mx = max(adj_sum)
print((mx+k)/2)

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

e = [(i+1)/2 for i in p]
e = np.cumsum(e)
e = np.append(0,e)
ans = 0
for i in range(n-k+1):
    ans = max(e[i+k]-e[i],ans)
print(ans)

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


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

tmp=sum(e[0:K])
ans=tmp
for i in range(K,N):
	tmp+=e[i]-e[i-K]
	ans=max(ans,tmp)

print(ans)

Solution (Python):
N, K = map(int, input().split())
plist = [((num*(num+1))//2)/num for num in list(map(int, input().split()))]

ans = 0
for i in range(K):
    ans += plist[i]
_ = ans
for i in range(N-K):
    temp = _
    temp -= plist[i]
    temp += plist[i+K]
    
    ans = max(ans, temp)
    _ = temp
print(ans)