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=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
ex=[1/2*(i+1) for i in p]
ruiseki=[0]
ans=0

for i in range(N):
  ruiseki.append(ruiseki[i]+ex[i])


for i in range(N+1-K):
  if ans<ruiseki[i+K]-ruiseki[i]:
    ans=ruiseki[i+K]-ruiseki[i]
print(ans)

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

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

b[0] = sum(e[0:k])
for i in range(1, len(b)):
  b[i] = e[i+k-1] + b[i-1] - e[i-1]
print(max(b))

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

Solution (Python):
import copy as c

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


def solve(N, p, K):
    ans = sum(p[:K])
    
    
    ans = c.copy(sum(p[:K]))
    sm = c.copy(ans)
    for i in range(K, N):
        
        sm = sm - p[i-K] + p[i]
        ans = max(ans, sm)
        
    return ans


print(1/2.0 * k + 1.0/2 * solve(n, P, k))

Solution (Python):

import sys


def solve(N: int, K: int, p: "List[int]"):
    p = [(p_ +1)/2 for p_ in p]
    temp = sum(p[0:K])
    max_s = temp

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




    return



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

if __name__ == '__main__':
    main()

Solution (Python):

import sys


def solve(N: int, K: int, p: "List[int]"):
    def f(pp):
        return pp * (pp + 1) / 2 / pp
    q = tuple(map(f, p))
    ma = su = sum(q[:K])
    for i, (qq, qqq) in enumerate(zip(q, q[K:]), 1):
        su = su - qq + qqq
        ma = max(ma, su)
    return ma



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

if __name__ == '__main__':
    main()

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

Solution (Python):

import numpy as np
from collections import deque
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
max_value = 0
ans_p = 0

s = [0]*(n+1)
for i, _p in enumerate(p):
    s[i+1] = s[i] + _p

for i in range(n-k+1):
    sum_ = s[i+k] - s[i]
    if (max_value < sum_):
        max_value = sum_

print((max_value+k)/2)

Solution (Python):
def solve():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    x = sum([1+ P[i] for i in range(K)])
    prob = x/2
    for i in range(1,N - K + 1):
        x += P[i+K-1]-P[i-1]
        prob = max(prob, x / 2)
    print(prob)

if __name__ == '__main__':
    solve()

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

p_sm=0

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

p_mx=p_sm

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

print((p_mx+k)/2)

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

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

tmp = sum(p[:k])
res = tmp
start = 0
end = k-1
for i in range(n-k):
  tmp -= p[i]
  tmp += p[k+i]
  if res < tmp:
    res = tmp
    start = i+1
    end = k+i

ans = 0
for i in range(start,end+1):
  if p[i] % 2 == 0:
    ans += ((p[i]+1) * (p[i] // 2)) / p[i]
  else:
    ans += (1 + p[i]//2 + (p[i]+1) * (p[i] // 2)) / p[i]
print(ans)

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

res = 0
flag = 0
ans = 0
Sum = 0

for i in range(n-k+1):
    if i == 0:
        Sum = sum(p[i:i+k])
        res = Sum
        continue
    
    Sum -= p[i-1]
    Sum += p[i+k-1]
    
    if res < Sum:
        res = Sum
        flag = i
        
for i in range(k):
    if p[flag+i]%2 == 0:
        ans += (p[flag+i]/2) + 0.5
    else:
        ans += (p[flag+i] + 1)/2
        
print(ans)

Solution (Python):
N,K = map(int, input().split())
P = list(map(int, input().split()))
P_sum = 0
for i in range(K):
    P_sum += P[i]
P_max = P_sum
for i in range(N-K):
    P_sum = P_sum + P[K+i]-P[i]
    if P_sum > P_max:
        P_max = P_sum
print(P_max/2+0.5*K)

Solution (Python):
def myAnswer(N:int,K:int,P:list) ->  int:
   ans =[]
   for p in P:
      tmp =(p+1)/2
      ans.append(tmp)
   
   accum = [sum(ans[:K])]
   for i in range(K,N,1):
      accum.append(accum[-1]-ans[i - K]+ans[i])
   
   return max(accum)

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   P = list(map(int,input().split()))
   print(myAnswer(N,K,P[:]))
if __name__ == '__main__':
   main()

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

sum = 0
for i in range(k):
    sum += p[i]
max = sum
for i in range(n-k):
    sum = sum+p[k+i]-p[i]
    if max<sum:
        max = sum
print(max/2+0.5*k)

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

    for i in range(n):
        p[i]=(p[i]+1)/2
    s = [0]
    for i in range(n):
        s.append(s[i]+p[i])
    m = 0
    for i in range(n-k+1):
        if m<s[i+k]-s[i]:
            m = s[i+k]-s[i]
    print(m)

if __name__ == "__main__":
    main()

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

MAX = 0
for i in range(N-K+1):
    if i == 0:
        SUM = 0
        for j in range(K):
            SUM += (A[i+j]+1)/2

    else:
        SUM += (A[i+K-1]+1)/2
        SUM -= (A[i-1]+1)/2
    
    if MAX < SUM:
        MAX = SUM

print(MAX)

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

Solution (Python):
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
ans = 0
save = 0
sum = 0
ans_o = 0
ans_check = 0
for j in range(k):
    ans_check += p_list[0 + j]
    ans_o += p_list[0 + j]
for i in range(1,n-k+1):
    ans = ans_o-p_list[i-1]+p_list[i+k-1]

    if ans > ans_check:
        save = i
        ans_check = ans
    ans_o = ans
    

for i in range(save,save+k):
    sum += p_list[i]*0.5 + 0.5
print(sum)

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

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

num = sum(num_li[:k])
ans = num
for j in range(n-k):
    num = num-num_li[j]+num_li[j+k]
    ans = max(num, ans)

print(ans)

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
ps = [0]
for i in range(len(p)):
         ps.append(((p[i] + 1)/2)+ps[i])
ans = 0
for i in range(n+1-k):
         if ans < (ps[i+k] - ps[i]):
                  ans = (ps[i+k] - ps[i])
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
ans = 0
tmp = 0
for i in range(k):
    tmp += p[i]
    ans += p[i]
for i in range(1,n - k + 1):
    tmp = tmp - p[i - 1] + p[i + k - 1]
    if ans < tmp:
        ans = tmp
print("{:.12f}".format(ans))

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

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

for i in range(1,1001):
    t = 0
    for j in range(i+1):
        t+=j
    l.append(t/i)

ans = 0

for e,i in enumerate(p):
    p[e] = l[i]
P = [0]*(n+1)
P[0] = 0
for e,i in enumerate(p):
    P[e+1] +=P[e]+i
M = 0  
for i , j in zip(P,P[k:]):
    M = max(M,j-i)
print(M)

Solution (Python):
from itertools import accumulate
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = list(map(lambda x: (((x + 1) * x) / 2) / x, l))
s = list(accumulate(l))
l_2 = [s[k - 1]]
for i in range(len(l) - (k - 1) - 1):
    l_2 += [s[i + k] - s[i]]
print(max(l_2))

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

for j in range(N-K):
    
    temp_num = temp_num-Px[j]+Px[j+K]
    if temp_max <temp_num:
        temp_max=temp_num
print(temp_max)

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

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

Solution (Python):
a,b=map(int,input().split())
c=list(map(lambda x:(int(x)+1)/2,input().split()))
i=0
summ=0
maxx=0
for j in range(b):
  summ+=c[i]
  i+=1
maxx=summ
for j in range(a-b):
  summ+=c[i]
  summ-=c[i-b]
  i+=1
  if maxx<summ:maxx=summ
print(maxx)

Solution (Python):

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

temp_num = sum(line[0:K])
temp_max = temp_num

for i in range(N - K):
    temp_num = temp_num - line[i] + line[i + K]
    if temp_num > temp_max:
        temp_max = temp_num


print((temp_max + K) / 2)

Solution (Python):
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))

sum_si=sum(dices[0:renzoku])
max_si=sum_si
for i in range(1,num-renzoku+1):
  sum_si=sum_si-dices[i-1]+dices[i+renzoku-1]
  if max_si<sum_si:
    max_si=sum_si
print((renzoku+max_si)/2)

Solution (Python):
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
Si=[0]*(num+1)
for i in range(1,num+1):
  Si[i]=Si[i-1]+(1+dices[i-1])/2
max_Si=0
for i in range(0,num-renzoku+1):
  if max_Si<Si[i+renzoku]-Si[i]:
    max_Si=Si[i+renzoku]-Si[i]
print(max_Si)

Solution (Python):
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
for i in range(num):
  pi=dices[i]
  expects[i]=(1+pi)/2
Si=[0]*(num+1)
for i in range(1,num+1):
  Si[i]=Si[i-1]+expects[i-1]
max_Si=0
for i in range(0,num-renzoku+1):
  if max_Si<Si[i+renzoku]-Si[i]:
    max_Si=Si[i+renzoku]-Si[i]
print(max_Si)

Solution (Python):
from itertools import accumulate
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = list(map(lambda x: (((x + 1) * x) / 2) / x, l))
s = list(accumulate(l))
l_2 = [s[k - 1]]
for i in range(len(l) - (k - 1) - 1):
    l_2 += [s[i + k] - s[i]]
print(max(l_2))

Solution (Python):



import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    Et = [0]*(N+1)
    for i in range(N):
        Et[i+1] = Et[i] + (1+P[i])/2
    ret = 0
    for i in range(N-K+1):
        ret = max(ret, Et[i+K]-Et[i])
    print(ret)

if __name__ == '__main__':
    main()

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

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

for i in range(x-y+1):
    if i == 0:
        z = sum(p[:y])
    else:
        z = z - n + p[i+y-1]
    n = p[i]
    if z > ans:
        ans = z

print((ans+y)/2)

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

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

tmp = sum(P[:K])
maxV = tmp

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

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

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

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

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

tmp = sum([expect(p) for p in P[:K]])
maxV = tmp
for i in range(N-K):
  tmp -= expect(P[i]) 
  tmp += expect(P[i+K])
  maxV = max(maxV, tmp)
print(maxV)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
import numpy as np
def main():
    n,k=map(int,input().split())
    P=np.array([int(_) for _ in input().split()])
    PP=(P+1)/2
    PP_cum=np.cumsum(PP)
    PP_cum=np.insert(PP_cum,0,0)
    print(np.max(PP_cum[k:]-PP_cum[:n-k+1]))

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
import numpy as np
def main():
    n,k=map(int,input().split())
    P_num=np.array([int(_) for _ in input().split()])
    PP=(P_num+1)/2
    PP_cum=np.cumsum(PP)
    PP_cum=np.insert(PP_cum,0,0)
    ans=PP_cum[k:]-PP_cum[:n-k+1]
    print(np.max(ans))

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import accumulate
import numpy as np
def main():
    n,k=map(int,input().split())
    P=[int(_) for _ in input().split()]
    P_num=np.array(P)
    PP=(P_num+1)/2
    PP_cum=np.cumsum(PP)
    PP_cum=np.insert(PP_cum,0,0)
    ans=PP_cum[k:]-PP_cum[:n-k+1]
    print(np.max(ans))

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import accumulate
def main():
    n,k=map(int,input().split())
    P=[int(_) for _ in input().split()]
    PP=[0]*n
    for i in range(n):
        PP[i]=(P[i]+1)/2
    PP_ac=list(accumulate(PP))
    ans=PP_ac[k-1]
    for i in range(1,n-k+1):
        ans=max(ans,PP_ac[i+k-1]-PP_ac[i-1])
    print(ans)

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import accumulate
def main():
    n,k=map(int,input().split())
    P=[int(_) for _ in input().split()]
    PP=[0]*n
    for i in range(n):
        PP[i]=(P[i]+1)/2
    PP_ac=list(accumulate(PP))
    ans=PP_ac[k-1]
    for i in range(1,n-k+1):
        ans=max(ans,PP_ac[i+k-1]-PP_ac[i-1])
    print(ans)

if __name__=='__main__':
    main()

Solution (Python):

url = "https://atcoder.jp//contests/abc154/tasks/abc154_d"

def search_ind(lis, k):
    tmp = sum(lis[0:k])
    m = tmp
    inds = [0, k - 1]
    for i in range(0, len(lis) - k):
        tmp = tmp - lis[i] + lis[i + k]
        
        if tmp > m:
            inds = [i + 1, i + k]
            m = tmp
    return inds

def main():
    n, k = list(map(int, input().split()))
    daice = list(map(int, input().split()))
    f, t = search_ind(daice, k)
    kitai = daice[f:t + 1]
    ans = 0
    for v in kitai:
        sumt = 0
        for i in range(1, v + 1):
            sumt += i * (1 / v)
        ans += sumt
    print(ans)




if __name__ == '__main__':
    main()

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

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

Solution (Python):
n, k = map(int, input().split())
table = [0.5+i*0.5 for i in range(1001)]
a = list(map(int, input().split()))

ans = sum([table[a[i]] for i in range(k)])
last = ans
for i in range(1, n-k+1):
    last = last - table[a[i-1]] + table[a[i+k-1]]
    ans = max(last, ans)
print(ans)

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

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

ev_list =  np.array((p_list+1)/2)

max_num = sum(ev_list[0:K])
tmp = sum(ev_list[0:K])

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

print(max_num)

Solution (Python):
n,k = map(int,input().split())
li = list(map(int,input().split()))
new_li = [0]
for l in li:
    new_li.append(new_li[-1]+(l+1)/2)


tmp_li = []
for i,n in enumerate(new_li):
    if i < k-1:
        continue
    tmp_li.append(new_li[i] - new_li[i-k])
    
print(max(tmp_li))

Solution (Python):
def main():
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    kitai=[]
    ans=0
    for i in range(n):
        buf=sum(range(1,p[i]+1))/p[i]
        kitai.append(buf)
        if i<=k-1:
            ans+=buf
    x=ans
    for i in range(k,n):
        x-=kitai[i-k]
        x+=kitai[i]
        if ans<=x:
            ans=x
    print(ans)

if __name__=='__main__':
    main()

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

Solution (Python):
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
rui = [0]*(N+1)
for i in range(1,N+1):
    rui[i] = rui[i-1] + l[i-1]
maxwa = 0
for i in range(N-K+1):
    wa = rui[K+i]-rui[i]
    maxwa = max(maxwa,wa)
print((maxwa+K)/2)

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

q = []
for i in range(n):
    q.append((p[i] + 1) * 0.5)
maxv = 0
for i in range(k):
    maxv += q[i]
cnt = maxv
for i in range(n):
    if i + k >= n:break
    cnt = cnt - q[i] + q[i + k]
    maxv = max(cnt, maxv)
print(maxv)

Solution (Python):
n,k = map(int,input().split()) 
a = list(map(int,input().split()))
max_a = [sum(a[0:k])]
exp = max_a[0]
for i in range(n-k):
    max_a.append(max_a[i]-a[i]+a[k+i])
    if max_a[i+1] > exp:
      exp = max_a[i+1]
print((k+exp)/2)

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

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

num = sum(num_li[:k])
ans = num
for j in range(n-k):
    num = num - num_li[j] + num_li[j+k]
    ans = max(num,ans)

print(ans)

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

Solution (Python):

n, k = map(int, input().split())
ppp = list(map(int, input().split()))
tot = sum(ppp[:k])
ans = tot
for i in range(k, n):
    tot += ppp[i] - ppp[i - k]
    ans = max(ans, tot)
print((ans + k) / 2)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
s = max = sum(p[0 : k])
x = 0
for i in range(0, n - k):
    s = s - p[i] + p[i + k]
    if s > max:
        max = s
        x = i + 1
ans = 0
for i in range(x, x + k):
    ans += (p[i] + 1) / 2
print('{:.12f}'.format(ans))

Solution (Python):


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

def expectations(d:int)->float:
    return (d+1) / 2
E = list(map(expectations, P))  

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

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
Exception_p=[]
for i in range(N):
    Exception_p.append((1+p[i])/2)
sum_Exception=[]
sum=0
for k in range(K):
    sum=(p[k]+1)/2+sum
sum_Exception.append(sum)
for i in range(N-K):
    sum=sum_Exception[i]-p[i]/2+p[i+K]/2
    sum_Exception.append(sum)
list.sort(sum_Exception)    
print(sum_Exception.pop(-1))

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

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

result = []
sub_total = sum(p[:k])
result.append(sub_total)

for i in range(1, n-k+1):
    sub_total = sub_total - p[i-1] + p[i-1+k]
    result.append(sub_total)

print(max(result))

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

result = []
sub_total = sum(p[0:K])
result.append(sub_total)

for i in range(1, N-K+1):
    sub_total = sub_total - p[i-1] + p[i+K-1]
    result.append(sub_total)

print(max(result))

Solution (Python):
def main():
  N, K = (int(x) for x in input().split())
  p = [(int(x)+1)/2 for x in input().split()]
  wa = [0] * (N + 1)
  for i in range(1, N + 1):
    wa[i] = wa[i-1] + p[i-1]
  ret = 0
  for i in range(N-K+1):
    ret = max(ret, wa[K+i]-wa[i])
  print(ret)
  return

if __name__ == '__main__':
  main()

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

ranges = 0
temp = 0
for i in range(n - k + 1):
    if ranges == 0:
        ranges = sum(p[:k])
        temp = ranges
    else:
        temp = temp - p[i - 1] + p[i - 1 + k]
        if temp > ranges:
            ranges = temp

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

Solution (Python):
import math

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

mx = 0
cs = 0
for i in range(k):
    cs += pL[i]
    mx = cs
for i in range(1, len(pL) - k + 1):
    cs = cs - pL[i - 1] + pL[i + k - 1]
    mx = max(mx, cs)
print((mx + k) / 2)

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

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

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

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


main()

Solution (Python):

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


C    = list()
cumsum = 0
for ii in range( len(P) ):
    E = (1+P[ii])/2
    C.append( cumsum + E )
    cumsum += E

ans = 0.0
if( N==K ):
    ans = C[-1]
for ii in range( K, N ):
    E = C[ii] - C[ii-K]
    if( ans < E ):
        ans = E


print( ans )

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

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

cumu=[0]
for i in P:
    cumu.append(cumu[-1]+i+1)

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

print(ans/2)

Solution (Python):
N, K = map(int, input().split())
P = [int(p) for p in input().split()]
P_cum = [0] * N
P_cum[0] = P[0]
for i in range(1, len(P)):
    P_cum[i] = P_cum[i - 1] + P[i]

me = 0
for i in range(N - K + 1):
    if i >= 1:
        e = (P_cum[i + K - 1] - P_cum[i - 1] + K) / 2
    else:
        e = (P_cum[i + K - 1] + K) / 2
    me = max(e, me)

print(me)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
def exp(x):
    return (x+1)*(1/2)
p2=[]
for i in range(n):
    p2.append(exp(p[i]))
sum=0
for i in range(k):
    sum+=p2[i]
max=sum
for j in range(n-k):
    sum-=p2[j]
    sum+=p2[j+k]
    if sum>max:
        max=sum
print(max)

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

sc=list(map(int,input().split()))
c=[]
t=[]

for i in range(n):
  c.append((1+sc[i])/2)
t.append(0.0)
for i in range(n):
  t.append(c[i]+t[i])
total = 0
for i in range(n-k+1):
  
  if total < t[i+k] - t[i]:
    total = t[i+k] - t[i]
print(total)

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

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

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









def calculate(n, k, prr):

    sumarr = []
    for i in range(n):
        if len(sumarr) == 0:
            sumarr.append(prr[0])
        else:
            sumarr.append(sumarr[-1] + prr[i])

    maxSum = []

    for i in range(k-1,n):

        if i - k < 0:
            sss = sumarr[i] - 0
        else:
            sss = sumarr[i] - sumarr[i - k]
        maxSum.append(sss)

    print((k+max(maxSum))/2)


calculate(N, K, PRR)

Solution (Python):
import itertools
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))
k = [(1+i)/2 for i in p]
a = list(itertools.accumulate(k))
max = a[K-1]
for i in range(K,N):
    if max < a[i] - a[i-K]:
        max = a[i] - a[i-K]
print(max)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0

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

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

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

kouho=0
lis=[0]*n
lis[0]=(1+p[0])/2
for i in range(0,n):
  if i>=1:
    lis[i]=lis[i-1]+(1+p[i])/2
  if i==k-1:
    kouho=lis[i]
  if i>k:
    if lis[i]-lis[i-k]>kouho:
      kouho=lis[i]-lis[i-k]
print(kouho)

Solution (Python):
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, K = rl()
P = rl()

sums = [0]
s = 0
for i in range(N):
	s += P[i]
	sums.append(s)
max_ksum = 0
max_i = -1
for i in range(N-K+1):
	ksum = sums[i+K]-sums[i]
	if max_ksum < ksum:
		max_ksum = ksum
		max_i = i

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

Solution (Python):
import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))
ans = tmp = np.sum((p[0:K]+1)/2)

for n in range(1, N-K+1):
	last = (p[n-1]+1)/2
	next = (p[n+K-1]+1)/2
	tmp = tmp - last + next
	if ans < tmp:
		ans = tmp

print(ans)

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

N, K = map(int, input().split())
p = list(map(int, input().split()))
E = [0]*K
max = 0
for i in range(K):
    E[i%K] = (1+p[i])/2
    max += E[i%K]
tmp_E = max
for j in range(K, N):
    tmp_E -= E[j%K]
    E[j%K] = (1+p[j])/2
    tmp_E += E[j%K]
    if max < tmp_E:
        max = tmp_E
print(max)

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

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

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

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

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

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

d = [0] * n

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

x=r=sum(d[:k])


for i in range(1,n-k+1):
    
    x=x-d[i-1]+d[i+k-1]
    r=max(r,x)
    

print(r)

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

d = []

for v in p:
    d.append((1+v)/2)

x=r=sum(d[:k])


for i in range(1,n-k+1):
    
    x=x-d[i-1]+d[i+k-1]
    r=max(r,x)
    

print(r)

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

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

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
def expect(a):
  return 0.5 * (a+1)

total = 0
for i in range(k):
  total += expect(p[i])

r = [total]

for j in range(n-k):
  total = total-expect(p[j])+expect(p[j+k])
  r.append(total)

print(max(r))

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

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

print((K + maxS) / 2)

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

T = [0] * (N+1)

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

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

print(ans)

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

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

ans =  sum(nums[:k])
pre_sum = ans

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

Solution (Python):
N,K=map(int,input().split())
A=list(map(int,input().split()))
summation=[0,A[0]]
for i in range(1,N):
  summation.append(summation[i]+A[i])

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