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):
def expected_value(x):
    x = int(x)
    return (x + 1) / 2


def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(expected_value, input().split(' ')))
    cumulative_list = [0]
    for p in p_list:
        cumulative_list.append(cumulative_list[-1] + p)
    max_len = 0
    for i in range(0, N - K + 1):
        if max_len < cumulative_list[i + K] - cumulative_list[i]: max_len = cumulative_list[i + K] - cumulative_list[i]
    print(max_len)


if __name__ == '__main__':
    main()

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

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

ans_max = 0
for i in range(k):
    ans_max += p_dash[i]

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

print(ans_max)

Solution (Python):
import sys

N, K = map(int, sys.stdin.readline().split())
p = tuple(map(int, sys.stdin.readline().split()))

max = 0
ite = N - K
base = sum(p[0:K])
max = base
index = 0
for i in range(ite):
    tmp = base + p[i+K] - p[i]
    if tmp > max:
        max = tmp
        index = i+1
    base = tmp

E = [(1+p[index+i])/2 for i in range(K)]
print(sum(E))

Solution (Python):
N, K = map(int, input().split())
p = input().split()
bubun = [0 for i in range(N)]
sums= [0 for i in range(N+K)]
E=0
S=0

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


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

for i in range(N):
    if i == 0:
        bubun[i] = sums[K-1]
    else:
        bubun[i] = sums[i+K-1]-sums[i-1]

for i in range(N):

    if bubun[i] > S:
        S = bubun[i]


E=(S+K)/2

print(E)

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


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



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



max_E = 0
for i in range(N-K+1):
    tmp_E = S[i+K] - S[i]
    
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

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

Solution (Python):
N, K = map(int, input().split())
lis_p = map(int, input().split())
def calc_exp(x):
    return (int(x) + 1)/2
lis_exp = list(map(calc_exp, lis_p))
dp= sum(lis_exp[0:K])
cumKsum = sum(lis_exp[0:K])
for i in range(1, N-K+1):
    cumKsum = cumKsum - lis_exp[i-1] + lis_exp[i+K-1]
    dp = max(cumKsum, dp)
print(dp)

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

for i in range(n-k+1):
    a=s[k+i]-s[i]
    if(m<a):m=a
print(m)

Solution (Python):
import numpy as np

N, K = map(int, input().split())
E = list(map(lambda x: (int(x)+1)/2, input().split()))
E_cumsum = np.cumsum(E)

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

Solution (Python):
import numpy as np

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

e = np.array([(pi+1)/2 for pi in p])
es = np.array([sum(e[:k])] + [0]*(n-k))
for i in range(n-k):
  es[i+1] = es[i] - e[i] + e[i+k]

print(es.max())

Solution (Python):
N,K = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x:(x+1)*0.5, p))
temp = []
p_sum=0
for i in range(N):
    p_sum+=p[i]
    temp.append(p_sum)
ans = []
for j in range(K,N):
    ans.append(temp[j]-temp[j-K])
if len(ans) != 0:
    print(max(ans))
else:
    print(p_sum)

Solution (Python):
N,K = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x:(x+1)/2, p))
temp = []
p_sum=0
for i in range(N):
    p_sum+=p[i]
    temp.append(p_sum)
ans = []
for j in range(K,N):
    ans.append(temp[j]-temp[j-K])
if len(ans) != 0:
    print(max(ans))
else:
    print(p_sum)

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

"""
各pの期待値を算出
p期待値について累積和を出す
最大部分和を出す
"""

p_ex = [0] * n

for i in range(n):
    p_ex[i] = (1 + p[i])/2
p_ruiseki = np.cumsum(p_ex)

maxsum = p_ruiseki[k-1]
for i in range(k, n):
    if maxsum < p_ruiseki[i] - p_ruiseki[i-k]:
        maxsum = p_ruiseki[i] - p_ruiseki[i-k]
print(maxsum)

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

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

for i in range(n-k):
    b = b - a[i] + a[i+k]
    if ans < b:
        ans = b       
    
print((k+ans)/2)

Solution (Python):
def main():
  def CalExVal(x):
    return (1/2*(x+1))
  N, K = map(int, input().split())
  A = list(map(int, input().split()))


  Ex = list((map(CalExVal, A)))
  
  
  
  tem = sum(Ex[:K])
  res = tem
  for i in range(0,N-K):
      tem = tem - Ex[i] + Ex[i+K]
      if res < tem:
      	res = tem
  print(res)
if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
num = sum(p_list[0:k])
max = 0
index = 0
value = 0

for i in range(n - k):
    num = num + p_list[i + k] - p_list[i]
    if num > max:
        max = num
        index = i + 1

for i in range(k):
    value += (1 + p_list[index + i])/ 2

print(value)

Solution (Python):
raw = input()
N, K = raw.split(' ')
N = int(N)
K = int(K)
str_li = input().split(' ')
num_li = list(map(int, str_li))
sum_li = [0]
for i in num_li:
    sum_li.append(sum_li[-1] + i + 1)
ans = 0
for index in range(K, N+1):
    ans_tmp = sum_li[index] - sum_li[index - K]
    if ans_tmp > ans:
        ans = ans_tmp
print(ans/2)

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

max_d = sum(a[0:k])
max_i = 0
total = sum(a[0:k])


for i in range(1,n - k + 1):
    total = total - a[i - 1] + a[i + k - 1]

    if total > max_d:
        max_d = total
        max_i = i

ans = 0
for i in range(max_i,max_i + k):
    ans += (1 + a[i])/2
print("{:7f}".format(ans))

Solution (Python):

n, k = map(int, input().split())
p = list(map(int, input().split()))
pm = pp = sum(p[0:k])
for i in range(n - k):
    pp = pp - p[i] + p[k+i]
    pm = pp if (pp >= pm) else pm
ans = (pm + k) / 2
print(ans)

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


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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
p = LIST()

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

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

Solution (Python):
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = {}
r = s = m = 0
for i in range(k):
  s += a[i]
  if a[i] in b:
    pass
  else:
    d = a[i]
    b[d] = (d+1)/2.0
m = s
    
for i in range(n-k):
  s = s - a[i] + a[k+i]
  if a[k+i] in b:
    pass
  else:
    d = a[k+i]
    b[d] = (d+1)/2.0
  if m < s:
    m = s
    r = i+1
    
sp = 0.0
for i in range(k):
  sp += b[a[r+i]]
print(sp)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, input().split(' ')))
def In(): return int(input())
def InS(): return input()

N, K = InMap()
P = InMap()

Res = [0]*(N - K + 1)
tmp = sum(P[0:K])
for i in range(K, N):
    Res[i-K] = tmp
    tmp -= P[i-K]
    tmp += P[i]
Res[-1] = tmp
print((max(Res) + K) / 2)

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

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

def kitai(x):
  return (1+int(x))/2

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

pre = psum = sum(p[0:k])

for i in range(1, n):
  if i+k > n:
    break
  pre = pre - p[i-1] + p[i+k-1]
  psum = max(psum, pre)

print(psum)

Solution (Python):

import sys
input = sys.stdin.readline
def main():
    n,k = map(int,input().split())
    l=list(map(int,input().split()))
    l2 = [(1+i)/2 for i in l]
    kitai=sum(l2[0:k])
    tmp = kitai
    for idx in range(n)[:n - k]:
        tmp -= l2[idx]
        tmp += l2[idx+k]
        if (kitai < tmp):
           kitai = tmp
    print(kitai)
main()

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

Solution (Python):

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



def Kitaichi(p):
    result = 0
    for i in range(p):
        result += (i+1)*1/p
    
    return result

def Kitaichi2(p):
    return (p+1)*0.5

kitaichi_list=[]
ruisekiwa_list=[]
ruisekiwa=0
for a in range(N):
    kitaichi_list.append(Kitaichi2(P_List[a]))
    ruisekiwa += Kitaichi2(P_List[a])
    ruisekiwa_list.append(ruisekiwa)



pre_max=0
temp_max=0
max_num=0
for j in range(N-(K-1)):
    if j == 0:
        temp_max = ruisekiwa_list[j+K-1] - 0
    else:
        temp_max = ruisekiwa_list[j+K-1] - ruisekiwa_list[j-1]
    

    if pre_max < temp_max:
        pre_max = temp_max
    temp_max=0

print(pre_max)

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

print(max([Q[i+K]-Q[i] for i in range(N-K+1)]))

Solution (Python):
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=sum(l[:k])
kai=sum(l[:k])
for i in range(n-k):
    kai+=l[i+k]-l[i]
    ans=max(ans,kai)
print((ans+k)*0.50)

Solution (Python):
def expect(n):
    return (int(n)+1)/2
N, K = map(int,input().split()) 
P = list(map(expect,input().split()))
sumlist = [sum(P[0:K])]
sumnumber = sum(P[0:K])
for i in range(N-K):
    sumnumber -=P[i]
    sumnumber +=P[i+K]
    sumlist.append(sumnumber)
print(max(sumlist))

Solution (Python):
'''
.append(要素) リストに要素を追加 
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul

f = [int(s) for s in stdin.readline().rstrip().split()]
N = f[0]
K = f[1]
p = list(map(lambda x: 1/2+x/2, [int(s)
                                 for s in stdin.readline().rstrip().split()]))
E = []
tmp = 0
for el in p:
    tmp += el
    E.append(tmp)
past = E[K - 1]
for el in range(len(E)):
    if el - K < 0:
        continue
    e = E[el] - E[el - K]
    if past < e:
        past = e
print(past)

Solution (Python):
import numpy as np
N,K = map(int,input().split())
q = list(map(int,input().split()))
q = np.array(q)
 
p = (q + 1) /2
p = p.tolist()
a = sum(p[:K])
mx = a
 
for i in range(0,N-K):
    a = a - p[i] + p[i+K]
    if a > mx:
        mx = a
print(mx)

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

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

Solution (Python):


import sys
import math

from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


def ex(s):
    n = int(s)
    nn = (n+1) * (n/2)
    return nn / n


N, K = mis()
exs = list(map(ex, input().split()))

if N == K:
    print(sum(exs))
    exit(0)

ex_max = 0

for i in range(K):
    ex_max += exs[i]

left = 0
ex_temp = ex_max
for i in range(K, N):
    ex_temp = ex_temp - exs[left] + exs[i]
    left += 1
    if ex_max < ex_temp:
        ex_max = ex_temp

print('{:.7f}'.format(ex_max))

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

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

cum_sums = [0]*(n+1)
for ind in range(n):
  cum_sums[ind+1] = cum_sums[ind]+exps[ind]

k_exps = [cum_sums[ind+k]-cum_sums[ind] for ind in range(n-k+1)]

print(max(k_exps))

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
    
p_sum=[0]*n
ans=0
for i in range(n):
    if i==0:
        p_sum[i]=p[i]
        ans=p_sum[i]
    elif i<k:
        p_sum[i]=p_sum[i-1]+p[i]
        if p_sum[i]>ans:
            ans=p_sum[i]
    else:
        p_sum[i]=p_sum[i-1]+p[i]-p[i-k]
        if p_sum[i]>ans:
            ans=p_sum[i]
print(ans)

Solution (Python):
n,k=map(int,input().split())
d = tuple(map(int, input().split()))
e = [0]*n

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

max1 = 0
tmp = 0
for j in range(n-k+1):


    if j == 0:
        tmp = sum(e[j:j+k])
    else:
        tmp = tmp - e[j-1] + e[j+k-1]
    if max1 < tmp:
        max1 = tmp
print(max1)

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 = input().split(" ")
N = int(N)
K = int(K)
p = input().split(" ")
expected_list = []
max_list = []
for i in range(N):
  expected_list.append((int(p[i])+1)/2)
anan = 0
for j in range(K):
  anan += expected_list[j]
max_list.append(anan)
for i in range(N):
  if i == 0:
    continue
  anan = 0
  try:
    anan = max_list[i-1]-expected_list[i-1]+expected_list[i+K-1]
  except:
    pass
  max_list.append(anan)
  
print(max(max_list))

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

def main():
	N,K=map(int,input().split())
	
	
	vA=list(map(int,input().split()))
	
	s = sum(vA[:K])
	res = s
	
	for p,a in zip(vA[0:], vA[K:]):
		s -= p
		s += a
		res = max(res, s)
		
			
	
	res = (res + K)/2
	print(res)


main()

Solution (Python):
import sys
from itertools import accumulate

read = sys.stdin.read

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

p = [(1 + i) * i // 2 / i for i in p]
p = [0] + p
P = list(accumulate(p))
answer = 0

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

print(answer)

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

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

p = [(n+1)/2 for n in p]
import numpy as np
s = np.cumsum(p)

e=s[K-1]
max_e=e
for i in range(1,N-K):
  e=s[i+K]-s[i]
  max_e = max(max_e, e)
    
print(max_e)

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

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

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

Solution (Python):
import numpy as np

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

pcm=np.concatenate([np.array([0]),(p+1).cumsum()],0)

print((pcm[K:]-pcm[0:-K]).max() /2)

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

Solution (Python):
n, t = map(int, input().split())
dices = map(int, input().split())
avg = list(map(lambda n: (n+1)/2, dices))
s = prev = sum(avg[0:t])

for i in range(1, n-t+1):
  prev = prev - avg[i-1] + avg[i+t-1]
  s = max(s, prev)
print(s)

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

value = 0
index = 0

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

max = value

for i in range(1, n - k + 1):
    value = value - p[i - 1] + p[i + k - 1]
    if value > max:
        max = value
        index = i

total = 0
for i in range(index, index + k):
    total += p[i] / 2 + 0.5

print(total)

Solution (Python):
import numpy as np
n, d = list(map(int, input().split()))
a = list(map(int, input().split()))
Max = 0
Sum = 0
a = np.array(a)
a = a*0.5 + 0.5
ans = []

if d == 1:
  print(max(a))
elif n == d:
  print(sum(a))
else:
  for i in range(n-d+1):
    left = a[i]
    right = a[i+d-1]

    if i == 0:
      Sum = sum(a[i:i+d])
      Max = sum(a[i:i+d])
      ans = a[i:i+d]
    else:
      Sum = Sum + right - a[i-1]

      if Sum >= Max:
        Max = Sum
        ans = a[i:i+d]
      else:
        pass

  print(sum(ans))

Solution (Python):
N,K=map(int,input().split())
dice = list(map(int, input().split()))
a=sum(dice[0:K])

l = [a]
for i in range(1,N-K+1):
    a = a - dice[i-1] + dice[K-1+i]
    l.append(a)
print((max(l)+K)/2)

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

p = (q + 1) /2
p = p.tolist()
a = sum(p[:K])
mx = a

for i in range(0,N-K):
    a = a - p[i] + p[i+K]
    if a > mx:
        mx = a

print(mx)

Solution (Python):
n, k = map(int, input().split())
li = [(int(j) + 1) / 2 for j in input().split()]

if k == 1:
  print(max(li))
else:
  a = 0
  for i in range(n-k+1):
    if i == 0:
      xe = sum(li[0:k])
    else:
      xe = xe - li[i-1] + li[i+k-1]
    a = max(a, xe)
  print(a)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
P = list(map(int,input().split()))
out_ = 0
p = P[0:K]
base = sum(p)
if N == K:
  answer = (sum(p)+K)/2
else:
  for i in range(N-K):
    out_ += P[i+K]-P[i]
    if i == 0:
      ans = out_
    else:
      if out_ > ans:
        ans = out_
      else:
        continue
  answer = (base+ans+K)/2
print(answer)

Solution (Python):




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


kk=[0] * (N-K+1)

kk[0]=sum(p[0:K])
for ii in range(1,N-K+1):
    kk[ii]=kk[ii-1]-p[ii-1]+p[K+ii-1]
kk=max(kk)
K=float(K)
kk=float(kk)
ans=0.5*(kk+K)

print(ans)

Solution (Python):
def solve(_list,_k):
  accumulate_list = [0.]
  for i in _list:
    accumulate_list.append((i+1)/2 + accumulate_list[-1])

  ans = -1.0
  for i in range(len(accumulate_list)-_k):
    ans = max(ans, accumulate_list[i+_k]-accumulate_list[i])
  return ans

if __name__ == "__main__":
  _n, _k = map(int, input().split())
  _l = [int(i) for i in input().split()]

  result = solve(_l, _k)
  print(result)

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

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

print((ans+k)/2)

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

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




















ANS = 0
for i in range(N-K+1):
    
    if i == 0:
        TEMP = sum(P[i:i+K])
    else:
        TEMP = TEMP - P[i-1] + P[i+K-1]
    if TEMP > ANS:
        ANS = TEMP

print((ANS+K)/2)

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

import numpy as np

E = (np.array(P)+1)/2
E = np.cumsum(E)  

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

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

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

ans = 0

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

ans = sum(num_array[0:K])
temp = ans
for i in range(1, N-K+1):
    j = i+K-1
    temp = temp - num_array[i-1] + num_array[j]
    if temp > ans:
        ans = temp

print(ans)

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

r = 0
c = 0
pre = [None] * len(p)

for i, x in enumerate(p):
    a = (x + 1)/2
    pre[i] = a
    c += a
    if i - K >= 0:
        c = c - pre[i - K]
    if c > r:
        r = c
print(r)

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

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

print(ans)

Solution (Python):
def ex(x):
    return (x+1)/2
 
n, k = map(int, input().split())
lst = list(map(int, input().split()))
source = [ex(i) for i in range(1, 1001)]
exlst = [source[l-1] for l in lst]
maxmum = -1

cumulative = [0]
total = 0
for ex in exlst:
    total += ex
    cumulative.append(total)

maxmum = -1
for i in range(n-k+1):
    sum_ = cumulative[i+k] - cumulative[i]
    if sum_ > maxmum:
        maxmum = sum_
print(maxmum)

Solution (Python):
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

sum = 0
ans = 0

for i in range(a[0]):
    sum += (1 + b[i])/2
    if i > a[1]-1:
        sum -= (1 + b[i-a[1]])/2
    if ans < sum:
        ans = sum

print(ans)

Solution (Python):
a=input().split()
N=int(a[0])
K=int(a[1])
zantei=0
P=list(map(float,input().split()))

P_ex=list(map(lambda x: (x+1)/2,P))


for i in range(0,K):
    
    zantei+=P_ex[i]
zanans=0
buffer=P_ex[0]
beforeans=zantei
for i in range(1,N-K+1):
    if(beforeans-buffer+P_ex[K+i-1]>zantei):
        zantei=beforeans+P_ex[K+i-1]-buffer
    beforeans+=(P_ex[K+i-1]-buffer)
    buffer=P_ex[i]

print(zantei)

Solution (Python):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
A = 0
for j in range(a[1]):
    A = A + b[j]
c = A
d = 0
ans = 0
if a[0] == a[1]:
    for l in range(a[0]):
        ans=ans +((b[l] + 1)/2)
else:
    for i in range(a[1],a[0]):
        B = A - b[(i-a[1])] + b[i]
        if B > c:
            d = i - a[1] + 1
            c = B
        A = B

    for k in range(a[1]):
        ans =ans + ((b[d+k] + 1)/2)

print(ans)

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


maxnum=0
index=0
num=0
for i in range(len(P)):
    num+=P[i]
    if maxnum<num:
        maxnum=num
        index=i




    if i>=K-1:
        num-=P[i-(K-1)]


List=[]
for i in range(K):
    x1=P[index-i]

    sumx1=(1+x1)/2
    List.append(sumx1)


print(sum(List))

Solution (Python):
a,b = map(int, input().split())
l = [(int(i)+1)/2 for i in input().split()]

temp = sum(l[:b])
max = temp
for i in range(b,a):
  temp = temp + l[i] - l[i-b]
  if max < temp:
    max = temp
    
print(max)

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

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

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

print(ans)

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

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

print(max([P_sum[i + K] - P_sum[i] for i in range(N - K + 1)]))

Solution (Python):
N,K = map(int,input().split())
A = list(map(int,input().split()))
total = 0
saidai = -9999

ans = 0
B = [0]*(len(A)+1)

for i in range(len(A)):
    total += A[i]
    B[i+1] = total
    
for j in range(N-K+1):
     if B[j+K]-B[j]>saidai:
      
            saidai = B[j+K]-B[j]
            P = A[j:j+K]
          
for i in range(len(P)):
    ans += (0.5*P[i]*(P[i]+1))/P[i]
    
print(ans)

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

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

ans = 0.0
for pp in p[s:s+k]:
  ans += (1+pp)/2
print(ans)

Solution (Python):
N,K = list(map(int, input().split()))
p = list(map(int, input().split()))
max_l = 0
Max_l = p[0:K]
S = [0]
s=0
for j in range(N):
    s += p[j]
    S.append(s)

for i in range(N-K+1):
    m = S[K+i]-S[i]
    if m > max_l:
        max_l = m



print((max_l+K)/2)

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

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

ans = c[K-1]

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

print((ans + K) / 2)

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:
        xe=sum(p[0:k])
    else:
        xe=xe-p[i-1]+p[i+k-1]
    a=max(a,xe)
print((k+a)/2)

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

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

Max = 0
for i in range(N):
    Sum=0
    if i+K<=N:
        Sum = s[K+i] - s[i]
        if Sum > Max:
            Max = Sum
            index = i
    else:
        break
Sum=0
for i in range(K):
    kitai=1/2*p[index+i]*(p[index+i]+1)
    kitai = kitai / p[index+i]
    Sum+=kitai
print(Sum)

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


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
e_list = [0] * n
ans_list = [0] * n
ans = 0.0

for i in range(n):
    e_list[i] = calc_expected_value(p[i])
    if i == k_range-1:
        ans_list[i] = sum([e_list[i-k] for k in range(k_range)])
    else:
        ans_list[i] = ans_list[i-1] + e_list[i] - e_list[i-k_range]

print(max(ans_list))

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

temp = sum(P[:k])
res = temp
for i in range(n- k):
  temp -= P[i]
  temp += P[i+k]
  res = max(res, temp)
  
ans = (res + k) * 0.5

print(ans)

Solution (Python):
n, k = map(int, input().split())
e = list(map(lambda x: (1 + int(x)) / 2, input().split()))
mt = sum(e[:k])
mf = mt
for i in range(1, n - k + 1):
  mt -= e[i - 1]
  mt += e[i - 1 + k]
  if mt > mf:
    mf = mt
print(mf)

Solution (Python):
N, K = list(map(int, input().strip().split()))
P = list(map(int, input().strip().split()))
start = 0
rec_sum = sum(P[0:K])
max_sum = rec_sum
for i in range(1, N - K + 1):
  rec_sum = rec_sum - P[i-1] + P[i+K-1]
  if rec_sum > max_sum:
    start = i
    max_sum = rec_sum
    
ans = 0.0
for _p in P[start:start+K]:
  ans += (1+_p) / 2
print(ans)

Solution (Python):
def expected_value(x):
    a = int(x)
    s = (a+1) * (a/2)
    
    
    
    return s / a

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


left = 0
max_ev = 0
ev = 0
for i in range(k):
    ev += evs[i]

max_ev = ev
for i in range(k, n):
    ev = ev - evs[left] + evs[i]
    left += 1
    if ev > max_ev:
        max_ev = ev
print('{:.7f}'.format(max_ev))

Solution (Python):
import numpy as np
n,k=map(int,input().split())
exp=tuple(map(lambda x: (int(x)+1)/2,input().split()))
l=np.cumsum(exp)

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

Solution (Python):
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def moving_average(a, n=3) :
    ret = np.cumsum(a, dtype=float)
    ret[n:] = ret[n:] - ret[:-n]
    return ret[n - 1:]

def main():
    N, K = map(int, readline().split())
    p = np.array(readline().split(), dtype=np.int32)
    q = moving_average(p, K)

    print((np.max(q) + K) / 2)


main()

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

s = [1+0.5*(i-1) for i in range(1,max(p)+1)]

q = [0]
c = 0
for i in p:
    c += s[i-1]
    q.append(c)

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

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

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