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

sum_num = sum(nums[:K])
max_num = sum_num

for i in range(1, N - K + 1):
  sum_num = sum_num - nums[i - 1] + nums[i + K - 1]
  if sum_num > max_num:
    max_num = sum_num
    
print((max_num + K) / 2)

Solution (Python):
def calc_ex(P):
    sum = 0
    for p in range(1, P+1):
        sum += p
    return sum / P

def main():
    N, K = map(int,input().split())
    P = list(map(int,input().split()))
    accumP = [0] * (N + 1)
    for i in range(N):
        accumP[i+1] = accumP[i] + P[i]

    
    idx = 0
    sum = accumP[idx+K] - accumP[idx] 
    for i in range(0, N-K+1):
        if accumP[i+K] - accumP[i] > sum:
            idx = i
            sum = accumP[i+K] - accumP[i]
    
    
    ans = 0
    for i in range(idx, idx+K):
        ans += calc_ex(P[i])

    print(ans)

if __name__ == "__main__":
    main()

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

Solution (Python):
def main():

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

    ex = [0]
    for x in p:
        ex.append(ex[-1] + (x+1)/2)

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

    print(ans)

main()

Solution (Python):
n,k = map(int,input().split())
lst = list(map(int,input().split()))
E = [0]
for x in lst:
  E.append((1+x)/2+E[-1])
s = 0
for i in range(n+1-k):
  if s < E[i+k] - E[i]:
    s = E[i+k] - E[i]
print(s)

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

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

sum_e = [0]

for i in range(1,n+1):
    sum_e.append(sum_e[i-1]+e[i-1])

ans = []

for i in range(n-k+1):
    ans.append(sum_e[i+k]-sum_e[i])

print(max(ans)/2)

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











def inp():
    return int(input())
def inps():
    return input().rstrip()
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)



n, k = inpl()
p = inpl()

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

sm = 0
for i in range(k):
    sm += p[i]
idx = 0

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

print(mx)

Solution (Python):
N,K = map(int,input().split())
pls = list(map(int,input().split()))
ans = sum(pls[:K])/2 + 0.5*K
sum1 = ans
for i in range(1,N-K+1):
    sum1 += -pls[i-1]/2+pls[i+K-1]/2
    ans = max(ans,sum1) 
print(ans)

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

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

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

print(ans)

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

s = [0]*(n+1)

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

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

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

if n==k:
    ans = 0
    for i in li:
        ans += i*0.5+0.5
    print(ans)
    exit()

K = sum(li[:k])
ans = K
t = 0
for i in range(n-k):
    K += li[i+k] - li[i]
    if K > ans:
        ans = K
        t = i
ans = 0
for i in range(k):
    ans += li[t+i+1]*0.5 + 0.5
print(ans)

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


print(ans)

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

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

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

ans = (d_max + k)/2
print(ans)

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

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

if N == K:
    print(sum(P))

else:
    for i in range(1,N):
        P[i] += P[i-1]

    for i in range(K,N):
        T[i] = P[i] - P[i-K]

    T = T[K:]

    print(max(T))

Solution (Python):
import copy
n, k = map(int, input().split())
P = list(map(int, input().split()))
U = [0]*n

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

ans = sum(U[:k])
t = copy.copy(ans)

for i in range(n-k):
    t =  t+U[k+i]-U[i]
    ans = max(ans, t)
    
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
a=[0]
for i in range(N):
    a.append(a[-1]+p[i])
ans=0
for i in range(N-K+1):
    ans=max(ans,a[i+K]-a[i])
print(ans)

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

for k in range(K):
    ans+=(1+p[hoge+k])/2

print(ans)

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

P[0] = (P[0]+1.)/2
for i in range(1,len(P)):
    P[i] = (P[i]+1.)/2
    P[i] = P[i-1]+P[i]

ans = 0.

if n==1:
    ans = P[0]

elif len(P)-k==0:
    ans = P[k-1]
else:
    for i in range(len(P)-k):
        ans = max(ans,(P[i+k]-P[i]))
        
    
print(ans)

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

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

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


tmp = 0
for j in range(n - k + 1):
    if tmp <= q[j + k] - q[j]:
        tmp = q[j + k] - q[j]
print(tmp)

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    P=LI()
    S=[0]*(N+1)
    
    for i in range(N):
        S[i+1]=S[i]+P[i]
        
    M=0
    for i in range(N-K+1):
        temp=S[K+i]-S[i]
        M=max(M,temp)
        
    ans=(M+K)/2
    print(ans)

main()

Solution (Python):
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = sum(P[:K])
R = Q

for n in range(N-K):
  Q = Q-P[n]+P[n+K]
  R = max(Q,R)

print((R+K)/2)

Solution (Python):
from numpy import *
N,K = map(int,input().split())
P = list(map(int,input().split()))
Q = (N-K+1)*[0]
R = sum(P[0:K])
Q[0] = R

for n in range(1,N-K+1):
  R+=P[n-1+K]-P[n-1]
  Q[n] = R

S = argmax(Q)
print(0.5*(sum(P[S:S+K])+K))

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

E = []

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

tnt = sum(E[:K])
ans = tnt

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

print(ans)

Solution (Python):

def main():
    n, k = map(int, input().split(" "))
    p = list(map(int, input().split(" ")))
    u = [0]
    v = []
    w = []
    for i in range(n):
        u.append(u[i]+p[i])
    for i in range(n-k+1):
        w.append(u[k+i]-u[i])
    x = w.index(max(w))
    for i in range(k):
        v.append(p[x+i])
    a=0
    for i in range(k):
        a += 1+0.5*(v[i]-1)
    print(a)

if __name__ == "__main__":
    main()

Solution (Python):

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

total = [0] * N
total[0] = p[0]
for i in range(1, N):
  total[i] = total[i-1] + p[i]

total_K = 0
max_i = 0
for i in range(N-K+1):
  if i == 0:
    total_K = total[K-1]
  else:
    if total[i+K-1] - total[i-1] > total_K:
      total_K = total[i+K-1] - total[i-1]
      max_i = i

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
def main():
    N, K = MI()
    P = LI()
    a = sum(P[0:K])
    Sums = []
    Sum = 0
    for i in range(N):
        Sum += P[i]
        Sums.append(Sum)
    ans = [a, 0, K - 1]
    for i in range(K, N):
        X = Sums[i] - Sums[i - K]
        if X > ans[0]:
            ans[0] = X
            ans[1] = i - K + 1
            ans[2] = i
    cnt = 0
    for i in range(ans[1], ans[2] + 1):
        cnt += (P[i] + 1) / 2
    print(cnt)
if __name__ == "__main__":
    main()

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

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

Solution (Python):
n, k = map(int, input().split())
p = list(map(int,input().split()))
q = [(x+1)/2 for x in p]
q1 = sum(q[:k])
ans = q1

for i in range(n-k):
  x = q1-q[i] +q[i+k]
  q1 = x
  if ans < x:
    ans = x
  
print(ans)

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

res=0
s=sum(p[:K])
for i in range(N-K+1):
    res=max(res,(s+K)/2)
    if i!=N-K:
        s=s+p[i+K]-p[i]
print(res)

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

Solution (Python):
N,K=map(int,input().split())
List = list(map(int, input().split()))
INF = 10000000000
expList = [INF]*1001
def expectationF(num):
  if expList[num] == INF:
    exp = 0
    for i in range(1,num+1):
      exp += i/num
    expList[num] = exp
  return expList[num]

res = 0
mid = 0
midList=[]
for i in range(N):
  if i>=1:
    midList.append(expectationF(List[i])+midList[i-1])
  else:
    midList.append(expectationF(List[i]))
m=K-1
for j in range(N-m):
  if j == 0:
    mid = midList[j+m]
  else:
    mid = midList[j+m]- midList[j-1] 
  res = max(res,mid)
print(res)

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

Solution (Python):
def main():
    n, k = map(int, input().split())
    p_lst = list(map(int, input().split()))
    lst = []

    for i in range(n):
        lst.append((p_lst[i] + 1) / 2)

    tmp_sum = sum(lst[:k])
    maximum = tmp_sum
    for i in range(n - k):
        tmp_sum -= lst[i]
        tmp_sum += lst[i + k]
        maximum = max(maximum, tmp_sum)

    print(maximum)


if __name__ == '__main__':
    main()

Solution (Python):
def dice_expectation(p):
  return ((1 + p) * p / 2) * (1/p)

n, k = map(int, input().split())
pp = [0] * (n+1)
for i, p in enumerate(map(int, input().split())):
  pp[i+1] = pp[i] + dice_expectation(p)

max = -1
for i in range(k, n+1, 1):
  max = pp[i] - pp[i-k] if pp[i] - pp[i-k] > max else max

print(max)

Solution (Python):
def main():
    N, K = map(int, input().split())
    P = map(int, input().split())
    E = [(p+1)/2 for p in P]
    sums = [sum(E[0:K])]
    for i in range(N-K):
        sums.append(sums[-1] - E[i] + E[i+K])
    print(max(sums))


if __name__ == '__main__':
    main()

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]*(N-K+1)
ans[0]=sum(p[:K])
for i in range(1, N-K+1):
  ans[i]=ans[i-1]-p[i-1]+p[i+K-1]

print(max(ans))

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n, k = i_map()
    p = i_list()


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

    l = [sowa[p[0]]/p[0]]

    for i in range(1,n):
        l.append(l[i-1] + sowa[p[i]]/p[i])


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


if __name__=="__main__":
    main()

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

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

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

Solution (Python):

def main():
    import numpy as np

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

    P[:] += 1
    Pcum = np.zeros(N + 1, np.int32)
    Pcum[1:] = np.cumsum(P)
    length_K_sums = Pcum[K:] - Pcum[:-K]
    print(length_K_sums.max() / 2)


if __name__ == '__main__':
    main()

Solution (Python):
import sys



def input():
    return sys.stdin.readline().rstrip()


def main():

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

    current = sum(A[:K])
    ans =(current+K)/2

    for i in range(1,N-K+1):
        current = current - A[i-1] + A[i+K-1]
        ans = max(ans, (current+K)/2 )
    print(ans)



if __name__ == "__main__":
    main()

Solution (Python):

def main():
    def expected_val(limit):
        
        return sum(range(limit + 1)) / limit

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

    lst = [0]
    res = 0
    for p in P:
        res += expected_val(p)
        lst.append(res)
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

def main():
    def expected_val(limit):
        return (1 + limit) / 2

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

    lst = [0]
    res = 0
    for p in P:
        
        res += expected_val(p)
        lst.append(res)
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

def main():
    def expected_val(limit):
        return (1 + limit) / 2

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

    lst = [0]
    res = 0
    for p in P:
        
        res += expected_val(p)
        lst.append(res)
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

def main():
    def expected_val(limit):
        return (1 + limit) / 2

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

    lst = [0]
    res = 0
    for p in P:
        res += (p + 1) / 2
        lst.append(res)
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

def main():
    def expected_val(limit):
        return (1 + limit) / 2

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

    lst = [0]
    res = 0
    for p in P:
        res += p + 1
        lst.append(res)
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans / 2)


if __name__ == '__main__':
    main()

Solution (Python):
N,K= map(int,input().split())
p = list(map(int,input().split()))
sum1=0.0
for i in range (K):
    sum1=((p[i]+1)/2.0)+sum1
sum2=sum1
for i in range(N-K):
    sum1=sum1+((p[i+K]-p[i])/2.0)
    if sum1>sum2:
        sum2=sum1
print(sum2)

Solution (Python):
N,K=map(int, input().split())
P=list(map(int, input().split()))
saikoro=[1+0.5*sai for sai in range(1000)]

ruiseki=0
for i in range(K):
	ruiseki+=saikoro[P[i]-1]

ans=ruiseki
for k in range(N-K):
	ruiseki=ruiseki-saikoro[P[k]-1]+saikoro[P[K+k]-1]
	ans=max(ans,ruiseki)
	
print(ans)

Solution (Python):

"""
Created on Mon Sep  7 22:29:36 2020

@author: liang
"""
N, K = map(int, input().split())

P = [1 + (int(p)-1)*0.5 for p in input().split()]


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

Solution (Python):
N, K = map(int, input().split())
nums = list(map(int, input().split()))
expect = 0
answer = 0
for i in range(N):
  if i < K:
    expect += (nums[i]+1)/2
  else:
    expect += (nums[i]+1)/2 - (nums[i-K]+1)/2
  answer = max(answer, expect)
print(answer)

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,K = mint()
p = lint()

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

Solution (Python):
def main():
	N, K = [int(x) for x in input().split(" ")]
	P = [int(p) for p in input().split(" ")]
	E = [sum(P[:K])]
	for i in range(N - K):
		E.append(E[-1] - P[i] + P[i + K])
	print((max(E) + K)/2)

main()

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

ruisekiwa = [0]

for P in Ps:
    ruisekiwa.append(P + ruisekiwa[-1])


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

print(ans)

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

a = [1+(i-1)/2 for i in p]
l = sum(a[:k])
ans = l
for i in range(1, n-k+1):
    l = l-a[i-1]+a[k+i-1]
    ans = max(ans, l)
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] / 2 + 0.5

s = 0
for i in range(K):
    s += p[i]
maxSum = s
j = 0

for i in range(K, N):
    s = s + p[i] - p[i-K]
    maxSum = max(maxSum, s)
print(maxSum)

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

Solution (Python):



nk = input().split()
N = int(nk[0])
K = int(nk[1])

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



max_sum = sum(Ps[:K])
current_sum = max_sum


for i in range(K, N):
    current_sum -= Ps[i-K]
    current_sum += Ps[i]

    max_sum = max(max_sum, current_sum)



ans = 1.0 * (max_sum + K) / 2
print(ans)

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


range_total = sum(P[:K]) + K
max_value = range_total
for i in range(N-K):
    range_total += P[K+i] - P[i]
    max_value = max(max_value, range_total)
print(max_value / 2)

Solution (Python):
N,K = map(int,input().split())
ps = list(map(int,input().split()))
su = sum(ps[0:K])
ksum = su
ind = 0
for i in range(1,N-K+1):
    ksum -= ps[i-1]
    ksum += ps[i+K-1]
    if ksum > su:
        ind = i
        su = ksum
ki = 0

for i in range(ind, ind+K):
    ki += (ps[i]*(ps[i]+1))/2/ps[i]
print(ki)

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

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

cnt = 0

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


print((ans+K)/2)

Solution (Python):
nk = input().split()
n = int(nk[0])
k = int(nk[1])
p_s = input().split()
p = [int(s) for s in p_s]
max_val = 0
for i in range(0,k):
    max_val+=p[i]
tmp = max_val
for i in range(k,len(p)):
    tmp = tmp - p[i-k] + p[i]
    if tmp > max_val:
        max_val=tmp
print(max_val/2 + 0.5 * k)

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

nk = input().split()
N = int(nk[0])
K = int(nk[1])
p = input().split()

tmp = 0
for i in range (K):
    tmp += expect(int(p[i]))

tmpMax = tmp

for i in range(N - K):
    tmp -= expect(int(p[i]))
    tmp += expect(int(p[i+K]))
    tmpMax = max(tmpMax, tmp)

print(tmpMax)

Solution (Python):
def rsum(n):return (n+1)*(n//2)+((n+1)//2) if n%2 else (n+1)*(n//2)
N,K=map(int,input().split())
p=list(map(int,input().split()))
l=[0]*N
for i in range(N):l[i]=rsum(p[i])*(1/p[i])
s=sum(l[0:K])
ans=0
for i in range(N-K):
    ans=max(ans,s)
    s-=l[i]
    s+=l[i+K]
print(max(ans,s))

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    n, k = map(int, input().split())
    p = np.array(read().split(), np.int32)
    p += 1
    pcum = np.zeros(n + 1, np.int32)
    pcum[1:] = p.cumsum()
    sum_k = pcum[k:] - pcum[:-k]
    print(sum_k.max()/2)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import accumulate
def main():
    n, k, *p = map(int, read().split())
    p2 = [0] + [(1 + pe) / 2 for pe in p]
    r = 0
    p2a = tuple(accumulate(p2))
    for i1 in range(k, n+1):
        r = max(r, p2a[i1] - p2a[i1-k])
    print(r)

if __name__ == '__main__':
    main()

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

t = sum(p[:k])
ans = t
for i in range(k,n):
  t += p[i] - p[i-k]
  if ans < t: ans = t
print(ans)

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

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

ans, total = sum(li[:K]), sum(li[:K])
if N != K:
  for i in range(1, N - K + 1):
    total = total - li[i-1] + li[i-1+K]
    ans = max(ans, total)
  print(ans)
else: print(ans)

Solution (Python):
n, k = map(int,input().split())
p = list(map(int,input().split()))
mu = [(a+1)/2 for a in p]
maxsum = sum(mu[:k])
now = maxsum
left = 0
right = k
while right<n:
    now = now+mu[right]-mu[left]
    if maxsum<now:
        maxsum = now
    left += 1
    right += 1
print(maxsum)

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

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

for i in range(N):
  ls[i+1] += ls[i] + (P[i] + 1) / 2
  
ans = 0
for j in range(N-K+1):
  tmp = ls[K+j] - ls[j]
  ans = max(ans, tmp)
  
print(ans)

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





S = [0]*(N+1)
for i in range(N):
  S[i+1] = S[i] + p[i]
'''
S[0] = 0
S[1] = p[0]
S[2] = p[0] + p[1]
S[N] = p[0] + ... + p[N-1]
 
S[K]-S[0] = p[K-1] + ... + p[0]
S[K+1]-S[1] = p[K] + ... + p[1]
S[K+2]-S[2] = p[K+1] + ... + p[2]
S[N]-S[N-K] = p[N-1] + ... + p[N-K]
'''
 
ans = 0 
for i in range(N-K+1):
  ans = max(ans, S[i+K] - S[i])
  
print(ans)

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





S = [0]*(N+1)
for i in range(N):
  S[i+1] = S[i] + p[i]
'''
S[0] = 0
S[1] = p[0]
S[2] = p[0] + p[1]
S[N] = p[0] + ... + p[N-1]

S[K]-S[0] = p[K-1] + ... + p[0]
S[K+1]-S[1] = p[K] + ... + p[1]
S[K+2]-S[2] = p[K+1] + ... + p[2]
S[N]-S[N-K] = p[N-1] + ... + p[N-K]
'''

ans = 0

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

Solution (Python):
from functools import reduce
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
tmp_max = sum([i / 2 + 0.5 for i in p[0:k]])
tmp = tmp_max
idx = 0
for i in range(1, len(p) - k + 1):
	tmp -= p[i - 1] / 2 + 0.5
	if i + k - 1 < len(p):
		tmp += p[i + k - 1] / 2 + 0.5
	tmp_max = max(tmp_max, tmp)
print(tmp_max)

Solution (Python):
N, K = [int(s) for s in input().split(' ')]
P = [int(s) for s in input().split(' ')]
s = []
a = sum(P[0:K])
s.append(a)
for p0, p1 in zip(P, P[K:]):
    a = a - p0 + p1
    s.append(a)

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

Solution (Python):
import os, sys, re, math


def get_exp_value(number):
    if number == 0:
        return 0
    a = (number + 1) / number
    exp = a * (number // 2)
    if number % 2 != 0:
        exp += a / 2

    return exp


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

exps = [get_exp_value(i) for i in range(200001)]

s = sum(P[0:K])
max_sum = 0
max_pos = 0
for i in range(K, N):
    s = s - P[i - K] + P[i]
    if s > max_sum:
        max_sum = s
        max_pos = i

answer = 0
for i in range(max_pos - K, max_pos):
    answer += exps[P[i + 1]]

print(answer)

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

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


E = list(map(lambda x: (x + 1) / 2, P))
E_SUMS = [E[0]]
for i in range(1, N):
    E_SUMS.append(E_SUMS[i - 1] + E[i])

m = E_SUMS[K - 1]
for i in range(K, N):
    m = max(m, E_SUMS[i] - E_SUMS[i - K])

print(m)

Solution (Python):
n, k = list(map(int, input().split(' ')))
aaa = list(map(int, input().split(' ')))
ans = 0
v = []
for a in aaa:
  v.append((a * (a + 1)) / (2.0 * a))

current = 0
for i in range(n):
  current += v[i]
  if i >= k:
    current -= v[i-k]
  ans = max(ans, current)
print(ans)

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

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

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

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

s = sum(p[:K])
ss = []
ss.append(s)

for i in range(N - K):
    s = s - p[i] + p[i+K]
    ss.append(s)

print(K + (max(ss) - K) / 2)

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

e = sum(range(1,p[0]+1))/p[0]
S = [e]

for i in range(1,N):
    ex = p[i]*(p[i]+1) / (2*p[i])
    S.append(ex + S[i-1])

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

print(ans)

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

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

p_list_E = []
p_list_E_temp = [1, 1.5, 2, 2.5, 3, 3.5]

for i in range(len(p_list)):
    p_list_E.append((p_list[i]+1)*0.5)


p_list_sum = [0]
for i in range(0,N):
    p_list_sum.append(p_list_sum[i]+p_list_E[i])


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

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


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

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

print(ans)

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

kitai = [0]*1000
tmp = 0
for i in range(1000):
  tmp += i+1
  kitai[i] = tmp/(i+1)


total_kitai = [0]*(n+1)
tmp = 0
for i in range(n):
  tmp += kitai[p[i]-1]
  total_kitai[i+1] = tmp


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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, K = map(int, readline().split())
    P = [0] + list(map(int, readline().split()))

    cur = sum(P[:K])
    s_max = 0

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

    print((s_max + K) / 2)


if __name__ == '__main__':
    main()