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):
A = list(map(int , input().split()))
B = list(map(int , input().split()))
kitaiti =[(i+1)/2 for i in B]
ans = []
dd = [0]
for i in range(A[0]):
    dd.append(dd[i] + kitaiti[i])
for i in range(A[1] , A[0]+1):
    ans.append(dd[i] - dd[i - A[1]])
print(max(ans))

Solution (Python):
from sys import stdin


def get_result(data):
    N, K = data[0]
    A = data[1]
    e_val = [(1 + val) / 2 for val in A]

    
    e_cumsum = [0]
    for i in range(N):
      e_cumsum.append(e_cumsum[i] + e_val[i])

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

    return max(e_sum_k)

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

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

exp_list = [(p + 1) / 2.0 for p in plist]
ans = s = sum(exp_list[:k])
for i in xrange(n - k):
    s = s - exp_list[i] + exp_list[i + k]
    ans = max(ans, s)

print ans

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

for x in p:
    e.append((1 + x) / 2)

for x in range(n):
    s.append(s[x] + e[x])

for x in range(k, n + 1):
    sj.append(s[x] - s[x - k])
    
print(max(sj))

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

def calculate_Expectation(n):
    n = int(n)
    p = 1/n
    e = p * (n*(n+1)/2)
    return e

E = list(map(calculate_Expectation, input().split()))
if N == K:
    print(sum(E))
else:
    S = [0]
    for i, e in enumerate(E):
        S.append(S[i]+e)

    sum_of_E = []
    for left in range(1, N+1-K):
        right = left + K
        sum_of_E.append(S[right]-S[left])
    print(max(sum_of_E))

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

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

tmp = sum(pi[0 : K])
max = tmp

if N == K:
    print((max + K) / 2)
else:
    for i in range(N - K):
        tmp = tmp - pi[i] + pi[i + K]
        if tmp > max:
            max = tmp
    print((max + K) / 2)

Solution (Python):
from collections import deque

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

def f(num) :
    return (num*(num+1) / 2) / num

for i, a in enumerate(A) :
    A[i] = f(a)

res = 0
tmp = 0

for i, a in enumerate(A) :
    if i < k :
        tmp += a
        res += a
    else :
        tmp += a
        tmp -= A[i-k]
        res = max(res, tmp)

print(res)

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

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

a = []

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

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

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

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


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


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


print(max(ans))

Solution (Python):
import numpy as np
n, k = map(int, input().split())
p_seq = np.array(list(map(int, input().split())))
e_seq = (p_seq + 1) / 2
s_seq = [0]
for e in e_seq:
    s_seq.append(s_seq[-1] + e)
print(max(s_seq[i + k] - s_seq[i] for i in range(n - k + 1)))

Solution (Python):

nk = list(map(int, input().split()))
p = list(map(int, input().split()))
s=0
summo=0
l = []
for i in range(1,1001):
    s += i
    l.append(s/i)

r = []
for i in range(nk[0]):
    summo += l[p[i]-1]
    r.append(summo)

ans = 0
for i in range(nk[0]):
    if i-nk[1] >= 0:
        if ans < r[i]-r[i-nk[1]]:
            ans = r[i]-r[i-nk[1]]
    else:
        if ans < r[i]:
            ans = r[i]
print(ans)

Solution (Python):
N, K = (int(i) for i in input().split())
p = [int(i) for i in input().split()]
p_ex = [(i+1)/2 for i in p]
sum_list = [sum(p_ex[0:K]),sum(p_ex[N-K:N])]
tmp_num = sum_list[0]
if N == K:
  print(sum(p_ex))
else:
  for i in range(1,N-K):
    
    tmp_num = tmp_num - p_ex[i-1] + p_ex[i+K-1]
    
    sum_list.append(tmp_num)
  print(max(sum_list))

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

m = 0
pre = 0
for j in range(K):
    pre += l[j]
m = pre

if K>1 and N>K:
  for i in range(N-K):
    temp = pre
    temp += l[i+K]
    temp -= l[i]
    if temp > m:
      m = temp
    pre = temp

if K==1:
  for i in range(N):
    if l[i] > m:
      m = l[i]


print((m+K)/2)

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

def kitai(x):
    return (x+1)/2
nP=list(map(kitai,P))
l=[]
m=sum(nP[0:K])
l.append(m)
for i in range(N-K):
    m -= nP[i]
    m += nP[i+K]
    l.append(m)
print(max(l))

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

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

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

expectedList = [(1 + s) /  2 for s in p]
cumsum = sum(expectedList[:K])
confirm_cumsum = cumsum

for i in range(K, N):
    cumsum += expectedList[i]
    cumsum -= expectedList[i - K]
    if cumsum > confirm_cumsum:
        confirm_cumsum = cumsum

print(confirm_cumsum)

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

Solution (Python):
n,k = map(int,input().split())
ps = [0]*n
ps = list(map(lambda x: (int(x)+1) / 2,input().split()))

ans = 0
for i in range(k):
    ans += ps[i]
tmp = ans
for i in range(k,n):
        tmp = tmp - ps[i-k] + ps[i]
        if ans < tmp:
            ans = tmp
    
print(ans)

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

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

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

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

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

Solution (Python):
from itertools import accumulate
N,K = [int(x) for x in input().split()]
p =[0]+[int(x) for x in input().split()]
pa = list(accumulate(p))
an = 0
ans = 0
for i in range(N-K+1):
  if an<pa[i+K]-pa[i]:
    an = max(an,pa[i+K]-pa[i])
    ans = 0
    for l in range(K):
      ans += (p[l+i+1]+1)/2
print(ans)

Solution (Python):






import math
import statistics
import numpy as np
import queue

n, k = map(int, input().split())
p = (1.00 + np.array(list(int(i) for i in input().split()))) / 2
temp = np.sum(p[:k])
ans = temp

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

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

Solution (Python):






import math
import statistics
import numpy as np
import queue

n,k = map(int, input().split())
p = (1.00 + np.array(list(int(i) for i in input().split()))) / 2
temp = np.sum(p[:k])
ans = temp

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

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

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

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

p.insert(0, 0)
for i in range(1, N+1):
    p[i] = (p[i] + 1) / 2 + p[i-1]

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

print(max(s))

Solution (Python):



from math import *
from copy import *
from string import *				
from random import *				
from sys import stdin
from sys import maxsize
from operator import *				
from itertools import *
from collections import Counter		
from collections import defaultdict 

'''
5 3
1 2 2 4 5
'''

def solve(l,k):
	n = len(l)
	pre = [l[0]]
	for i in range(1,n):
		pre.append(pre[i-1] + l[i])
	maxx = 0
	index = -1
	for i in range(k-1,n):
		summ = 0
		if(i == k-1):
			summ = pre[i]
		else:
			summ = pre[i] - pre[i-k]
		if(maxx < summ):
			maxx = summ
			index = i
	startIndex = index - k + 1
	optimalSub = l[startIndex:index+1]
	
	ans = 0
	for i in optimalSub:
		curr = i*(i+1)/2
		ans += curr/i
	return ans

N,K = map(int, stdin.readline().rstrip().split())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,K)
print("%.10f"%ans)

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

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

S = []
count = 0
max_sum = 0
for p in P:
    e = (int(p) + 1) / 2
    if count == 0:
        S.append(e)
    else:
        S.append(S[count-1] + e)
    if count == (K - 1):
        max_sum = S[count]
    elif count > (K - 1):
        sum = S[count] - S[count - K]
        if max_sum < sum:
            max_sum = sum
    count += 1
print(max_sum)

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

dicesum = 0
maxsum = 0
for i in range(n):
	dicesum += p[i]
	if i >= k:
		if n != k: dicesum -= p[i-k]
	maxsum = max(maxsum, dicesum)

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

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

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

tsum = sum(p[:k])
msum=tsum
for i in range(k, len(p)):
	tsum += p[i] - p[i-k]
	msum = max(msum, tsum)

print(msum)

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

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


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, K = read_ints()
P = read_ints()


def ret_mean(X):
    return (X + 1) / 2



class cumsum1d:
    def __init__(self, ls: list):
        '''
        1次元リストを受け取る
        '''
        from itertools import accumulate
        self.ls_accum = [0] + list(accumulate(ls))

    def total(self, i, j):
        
        return self.ls_accum[j] - self.ls_accum[i]
      
P_mean = [ret_mean(p) for p in P]
P_accum = cumsum1d(P_mean)

ans = 0

for i in range(N - K + 1):
    j = i + K
    ans = max(ans, P_accum.total(i,j))
print(ans)

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    p = LI()
    t = 0
    for i in range(k):
        t += (p[i]+1) / 2
    r = t
    for i in range(k,n):
        t += (p[i]+1) / 2
        t -= (p[i-k]+1) / 2
        if r < t:
            r = t

    return r


print(main())

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

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


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, K = read_ints()
P = read_ints()


def ret_mean(X):
    return (X + 1) / 2




import numpy as np
P_mean = np.array([ret_mean(p) for p in P])
P_accum = np.zeros(N+1)
P_accum[1:] = P_mean.cumsum()

ans = 0

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

Solution (Python):
n, k, *p = map(int, open(0).read().split())

for i, p_i in enumerate(p):
  p[i] = (1+p_i)/2

c_sum = [0]
v_sum = 0
for p_j in p:
  v_sum += p_j
  c_sum.append(v_sum)

a_max = 0
for i in range(n-k+1):
  if a_max < (c_sum[i+k] - c_sum[i]):
    a_max = (c_sum[i+k] - c_sum[i])
  
print(a_max)

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())
arr=list(map(int,input().split()))
for i in range(n):
  arr[i]=(arr[i]+1)/2
tmp=sum(arr[:k])
ans=tmp
for i in range(k,n):
  tmp+=(arr[i]-arr[i-k])
  ans=max(ans,tmp)
print(ans)

Solution (Python):
import queue

n, k = input().split()
p = input().split()
n = int(n)
k = int(k)
p = [int(p_tmp) for p_tmp in p]
q = queue.Queue()

wa = []
max = 0
sum = 0
for i in p:
    i += 1
    sum += i
    q.put(i)
    if q.qsize() > k:
        sum -= q.get()
    
    if q.qsize() == k:
        if max < sum:
            max = sum
        
ans = max
ans /= 2
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
buf=0
maxi=0
for i in range(k):
    buf+=p[i]
maxi=buf
for i in range(k,n):
    
    buf+=p[i]
    buf-=p[i-k]
    if maxi<buf:
        maxi=buf
print(maxi)

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


s = sum(P2[0:K])
ans = s
for i in range(0,N-K):
    s -= P2[i]
    s += P2[i+K]
    ans = max(ans,s)    
    
    
print(ans)

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

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

res = 0
for i in range(0, n-k+1):
    val = cum[i+k] - cum[i]
    if res < val:
        res = val

print(res)

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

Solution (Python):
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n, k = map(int, input().split())
p_array = np.array(list(map(int, input().split())))
expc = lambda x: (x+1.0)/2.0
p_array = expc(p_array)

p_cum = np.cumsum(p_array)
p_cum_diff = p_cum[k:] - p_cum[0:n-k]
if len(p_cum_diff) > 0:
    print(max(p_cum_diff))
else:
    print(p_cum[-1])

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

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

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

wk = 0
nn = n-k

for i in range(0,k):
    wk += li[i]
kwk = wk
for j in range(nn):
    wk = wk - li[j]
    wk = wk + li[j+k]
    kwk = max(wk,kwk)
 
print(kwk)

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))
expects = [0.0]
for i in range(1, 1001):
    p = 0.0
    for j in range(i, 0, -1):
        p += j * 1.0 / i
    expects.append(p)
exp_P = [0.0]
for i in range(N):
    exp_P.append(exp_P[-1] + expects[P[i]])


ans = float('-inf')
for i in range(K, N+1):
    ans = max(ans, exp_P[i] - exp_P[i-K])
print(ans)

Solution (Python):




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

max_p = max(p)

dp = [0] * (max_p+1)
dp[1] = 1
for i in range(2, max_p+1):
    dp[i] = dp[i - 1] + i
    dp[i - 1] /= (i - 1)
dp[max_p] /= max_p

e = 0
for i in range(k):
    e += dp[p[i]]

max_e = e

for i in range(k, n):
    e -= dp[p[i - k]]
    e += dp[p[i]]
    max_e = max(max_e, e)

print(max_e)

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

L = 0
R = k

def expected(pi):
    return (pi+1)/2

value = 0.0
sans  = 0.0
for i in range(0, k):
    sans += expected(p[i])
ans   = sans

while R < n:
    sans -= expected(p[L])
    sans += expected(p[R])

    ans = max(ans, sans)

    L += 1
    R += 1
print("%.7f" % ans)

Solution (Python):
n, k=map(int, input().split())
p=list(map(int, input().split()))
idx=0
sum=0
for i in range(k):
    sum+=p[i]
max=sum
for i in range(k,n):
    sum+=p[i]
    sum-=p[i-k]
    if sum>=max:
        max=sum
        idx=i-k+1

e=0
for i in range(idx,idx+k):
    e+=((p[i]+1)/2)
print(e)

Solution (Python):
import queue

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

q = queue.Queue()


mx = 0
s = 0

for i in range(N):
  s += P[i]+1
  q.put(P[i]+1)
  if q.qsize() > K:
    s -= q.get()
  if q.qsize() == K:
    mx = max(mx, s)

ans = mx/2
print(ans)

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

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


s_list = [0] * (N + 1)

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


max_s_sum = 0
max_sum_index = 0

for n in range(N - K + 1):
    s_sum = s_list[n + K] - s_list[n]
    if max_s_sum < s_sum:
        max_s_sum = s_sum
        max_sum_index = n


ans = 0
for k in range(K):
    x = p_list[max_sum_index]
    ans += (x + 1) / 2
    max_sum_index += 1
  
print(ans)

Solution (Python):
def main():
	n,m = map(int,input().split())
	a = list(map(int,input().split()))
	wa = [0,(1/2 * a[0] * (a[0] +1))/a[0]]
	for i in range(1,n):
		wa.append(wa[i] + (1/2 * a[i] * (a[i]+1))/a[i])
	ans = wa[m-1]
	for i in range(m,len(wa)):
		ans = max(wa[i]-wa[i-m],ans)
	print(ans)
	
 
if __name__ == '__main__':
	main()

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

lis = [(ele+1)/2 for i, ele in enumerate(lis)]

ans_lis = []

ans_lis.append(sum(lis[0:K]))

for i in range(N-K):
    ele = ans_lis[-1] - lis[i] + lis[i+K]
    ans_lis.append(ele)
    
print(max(ans_lis))

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
R = sum(P[:K])
ans = R
for j in range(N-K):
  R = R - P[j] + P[j+K]
  ans = max(ans,R)
print(ans)

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
P = [0 for x in range(n-k+1)]
P[0] = sum([p[i] for i in range(k)])

for i in range(n-k):
    P[i+1] = P[i] - p[i] + p[i+k]

m = max(P)
print((m+k)/2)

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

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

ans = L

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

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

Solution (Python):
import sys
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
P = list(map(int, inputs[1].split()))
EP = [0.5*p + 0.5 for p in P]

buffer = sum(EP[:k])
Q = [buffer]
for i in range(k, n):
    buffer += EP[i] - EP[i-k]
    Q.append(buffer)
print(max(Q))

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

e = [(x + 1) / 2 for x in p]
s = sum(e[:k])
maxsum = s
for i in range(n - k):
    s = s - e[i] + e[k + i]
    maxsum = max(maxsum, s)

print(maxsum)

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

c=[(i+1)/2 for i in p]
d =sum(c[:K])
e =d
for i in range(N-K):
    e -= c[i]
    e += c[i+K]
    if e>d:
        d=e
print(d)

Solution (Python):
import numpy as np

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

max = 0
sum = 0
for i in range(N):
    sum += P[i]
    if i >= K:
        sum -= P[i-K]
    if max < sum:
        max = sum
print((max+K)/2)

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

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

a = 0

for i in range(k):
    a += p[i]

ans = a

for i in range(n-k):
    a -= p[i]
    a += p[i+k]
    if a > ans:
        ans = a

ans = (ans+k)/2

print(ans)

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

sum_=0
for i in range(k):
  sum_+=li[i]
max_=sum_

for i in range(k,len(li)):
  sum_-=li[i-k]
  sum_+=li[i]
  if max_<sum_:
    max_=sum_
max_+=k
max_/=2
print(max_)

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

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

pe = [1] * max(p)
for i in range(1, len(pe)):
    pe[i] += (pe[i-1] + i)

for i in range(1, len(pe)):
    pe[i] *= 1/(i+1)

ans = sum([pe[pi-1] for pi in p[0:k]])
s = ans
for i, t in enumerate(range(k, n)):
    s = s + pe[p[t]-1] - pe[p[i]-1]
    ans = max(ans, s)

print(ans)

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

kdice = [(1+p[i])/2 for i in range(n)]
maxexp = sum(kdice[:k])
ans = maxexp

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

print(ans)

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

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

e = M
for i in range(n-k):
    e -= (1 + p[i]) / 2
    e += (1 + p[i+k]) / 2
    if e > M:
        M = e
print('{:.12f}'.format(M))

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


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


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

total = S[K-1]
for i in range(N-K):
    tmp = S[i+K]-S[i]
    if total < tmp:
        total = tmp

print(total)

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


def mean(value):
    return 0.5 * (value + 1)


res = 0
for l in range(k):
    res += mean(p[l])

cur = res
for l in range(k, n):
    cur += mean(p[l]) - mean(p[l-k])
    res = max(res, cur)
print(res)

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


def expectation(value):
    return 0.5 * (value + 1)


res = 0
for l in range(k):
    res += expectation(p[l])

cur = res
for l in range(k, n):
    cur += expectation(p[l]) - expectation(p[l-k])
    res = max(res, cur)
print(res)

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

sumex = sum(ex[:k])
tmp = sum(ex[:k])
for i in range(n-k):
    tmp = tmp + (ex[i+k] - ex[i])
    sumex = max(sumex, tmp)
print(sumex)

Solution (Python):
from itertools import accumulate

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

exp={}
cum=[]

ans=0
cnt=0
for i in range(1,1001):
    sum=0
    for j in range(1,i+1):
        sum+=j
    exp[i]=sum/i

for i in p:
    cum.append(exp[i])

cumsum=list(accumulate(cum))
cumsum.insert(0,0)

for i in range(n-k+1):
    tmp = cumsum[i+k] - cumsum[i]
    if ans <= tmp:
        ans = tmp

print(ans)

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

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

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

Solution (Python):

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



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


total = S[K-1]
for i in range(N-K):
    tmp = S[i+K]-S[i]
    if total < tmp:
        total = tmp

print(total)

Solution (Python):
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        ans[i] = ans[i]+x
    return ans

nk = input()
textp = input()

N = int(get(nk,2)[0])
K = int(get(nk,2)[1])
ps = get(textp,N)
for i in range(N):
    ps[i] = int(ps[i])

exp = [0] * N
for i in range(N):
    exp[i] = (ps[i]+1)/2

s = 0
for j in range(K):
    s = s + exp[j]
m = s
for i in range(N-K):
    s = s - exp[i] + exp[i+K]
    if m < s:
        m = s

print(m)

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

print(ans)

Solution (Python):
x=input()
x=x.split()
n,k=map(int,x)
x=input()
x=x.split()
p=[]
for i in range(len(x)):
  p.append(int(x[i]))  
s=0
for i in range(k):
  s+=(p[i]+1)/2  
maxim=s
for i in range(k,n):
  s=s+(p[i]+1)/2-(p[i-k]+1)/2
  if s>maxim:
    maxim=s  
print(maxim)

Solution (Python):
n = input().split()
N = int(n[0])
K = int(n[1])
a = input().split()
sum = 0.0
max = 0.0
for j in range(0, N):
  sum += float(a[j])
  if j > K - 1:
    sum -= float(a[j - K])
  if max < sum:
    max = sum
print ((max + K) / 2)

Solution (Python):
import numpy as np
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
expect_list = np.array(p_list)
expect_list = (expect_list + 1)/2
sum_list = []

sum=0
for i in range(K):
    sum += expect_list[i]

sum_list.append(sum)

for i in range(1,N-K+1):
    sum -= expect_list[i-1]
    sum += expect_list[i+K-1]
    sum_list.append(sum)

print(max(sum_list))

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

s = 0
sums = [0]
for i in p:
  	s += i
  	sums.append(s)

maxNum = -1
maxIndex = [0, 0]
for i in range(len(sums)-k):
  if sums[i+k] - sums[i] > maxNum:
    maxNum = sums[i+k] - sums[i]
    maxIndex = [i, i+k-1]

dices = p[maxIndex[0]:maxIndex[1]+1]
e = 0
for dice in dices:
  e += sum(list(range(1, dice+1))) / dice
print(e)

Solution (Python):
N=2*10**5+7
n,k=map(int,input().split())
List=list(map(float,input().split()))
for i in range(n):
    List[i]=(1+List[i])/2
for i in range(1,n):
    List[i]+=List[i-1]
ans=0.0
for i in range(0,n-k+1):
    
    if i==0 :
        ans=max(ans,List[i+k-1])
    else :
        ans=max(ans,List[i+k-1]-List[i-1])
print("{:.12f}".format(ans))

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

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

ex = 0
for i in range(n-K+1):
    if i == 0:
        bre = acc[i+K-1]
    else:
        bre = acc[i+K-1] - acc[i-1]
    exx = (K+bre)/2
    
    if exx > ex:
        ex = exx
print(ex)

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

if n>1:
    m = sum(prr[:k])
    cur = m
    for i in range(n-k):
        cur += -prr[i] + prr[k+i]
        m = max(m,cur)
else:
    m = prr[0]

print((m+k)/2.0)