Problem:
 Score : 400 points    Problem Statement We have N dice arranged in a line from left to right. The i -th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.  We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.      Constraints  1 ≤ K ≤ N ≤ 200000  1 ≤ p_i ≤ 1000  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  K  p_1 ... p_N       Output Print the maximum possible value of the expected value of the sum of the numbers shown.  Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-6} .        Sample Input 1 5 3
1 2 2 4 5      Sample Output 1 7.000000000000  When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is 7 . This is the maximum value we can achieve.       Sample Input 2 4 1
6 6 6 6      Sample Output 2 3.500000000000  Regardless of which die we choose, the expected value of the number shown is 3.5 .       Sample Input 3 10 4
17 13 13 12 15 20 10 13 17 11      Sample Output 3 32.000000000000

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

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

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

p = list(map(lambda x: x * (x+1) /2 /x, p))

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

m = p[k-1]
for i in range(k, n):
    a = p[i] - p[i-k]
    if m < a:
        m = a

print(m)

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
wa = sum(p[0:k])
next_wa = wa
for i in range(n-k):
    next_wa = next_wa - p[i] + p[i+k]
    if  next_wa > wa:
        wa = next_wa
print(0.5*(wa+k))

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

li = []
count=0
ans = 0

for i in range(len(p)):
    p[i] += 1
    li.append(p[i])
    if len(li) < k:
        continue
    elif len(li) == k:
        max = sum(li)
        buf = max
    elif len(li) > k:
        tmp = buf - li[count] + li[-1]
        buf = tmp
        if tmp >= max:
            max = tmp
        count+=1

print(max/2)

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

scope_index = 0
max_sum = 0
for i in range(k):
    max_sum += p_list[i]

now_sum = max_sum
for p_i in range(k, len(p_list)):
    now_sum -= p_list[p_i - k]
    now_sum += p_list[p_i]

    if max_sum < now_sum:
        scope_index = p_i
        max_sum = now_sum

ex = (max_sum+k)/2
print(ex)

Solution (Python):
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A = np.array(readline().split(), dtype=np.int64) + 1


Acum = np.zeros(N+1, np.float64)
Acum[1:] = A.cumsum()

x = Acum[K:] - Acum[:-K]
print(x.max()/2)

Solution (Python):
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A = np.array(readline().split(), dtype=np.int64)
A = np.array([(1+a)/2 for a in A])

Acum = np.zeros(N+1, np.float64)
Acum[1:] = A.cumsum()

x = Acum[K:] - Acum[:-K]
print(x.max())

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

max_expp = cumu_expp[k - 1]
for i in range(n - k):
    sumpk = cumu_expp[i + k] - cumu_expp[i]
    if max_expp < sumpk:
        max_expp = sumpk
print(max_expp)

Solution (Python):
import math

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

n = int(n)
k = int(k)




ex =0
ext = []
ext2 = []
for f in range(n):
    pi = int(p[f])
    xs =(pi+1)/2
    ext.append(xs)

ext2.append(ext[0])
for i in range(1,n):
    ext2.append(ext2[i-1]+ext[i])

ex = ext2[k-1]
for j in range(1,n-k+1):
    ext3 =ext2[j+k-1]-ext2[j-1]
    if ext3 > ex: ex = ext3

print('{:.12f}'.format(ex))

Solution (Python):
N,K,*P = map(int,open(0).read().split())
P = [(P[i]+1)/2 for i in range(N)]
M = m = sum(P[:K])

for i in range(N-K):
  if M < m-P[i]+P[i+K]:
    M = m-P[i]+P[i+K]
  m= m-P[i]+P[i+K]

print(M)

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

E = []
value=0

for P_i in p:
    value += (1+P_i)/2
    E.append(value)

flag = E[K-1]

for k in range(K,N):
    S = E[k] - E[k-K]
    if flag < S:
        flag = S
print(format(flag,'.12f'))

Solution (Python):
N,K = map(int,input().split())
P = list(map(int,input().split()))
E = [(p+1)/2 for p in P]
temp = sum(E[0:K])
S =  temp
for i in range(N-K):
  temp -= E[i]
  temp += E[i+K]
  if S < temp:
    S = temp  
print(S)

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

expect = [(e + 1) / 2 for e in A]
window = sum(expect[0:K])
max_s = window
for i in range(N - K):
    window -= expect[i]
    window += expect[i + K]
    if window > max_s:
        max_s = window
print(max_s)

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):
s=list(map(int,input().split()))
t=list(map(int,input().split()))
c=s[1]
d=0
a=sum(t[0:c])
b=0
for j in range(s[0]-s[1]+1):
  if j==0:
    b=sum(t[:c])
    continue
  else:
    a+=(t[j+c-1]-t[j-1])
    b=max(b,a)
b+=s[1]
print(b/2)

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

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

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

print(ans)

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

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] + (1+p[i])/2

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

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [0, 1.0]
for i in range(2, 1001):
    A.append(A[i-1]+0.5)
index = 0
tmp = sum(P[0:K])
B = [tmp]
for i in range(K, N):
    total = B[-1]-P[i-K]+P[i]
    if tmp < total:
        index = i-K+1
        tmp = total
    B.append(total)
ans = 0
for i in range(index, index+K):
    ans += A[P[i]]
print(ans)

Solution (Python):
n,k,*p=map(int,open(0).read().split())
s=m=k
for i in range(n):s+=p[i]-p[i-k]*(i>=k);m=max(m,s)
print(m/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] + (1+p[i])/2

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

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

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

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

        if tmp > tmp_max:
            tmp_max = tmp

    print((tmp_max + K) / 2)

main()

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

pn_t = [0]
for i in range(N):
    pn_t.append(pn[i]+pn_t[i])

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

Solution (Python):
n,k,*p=map(int,open(0).read().split())
s=m=k
for i in range(n):s+=p[i]-p[i-k]*(i>=k);m=max(m,s)
print(m/2)

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

Solution (Python):
import sys
import numpy as np

val = np.fromstring(sys.stdin.buffer.read(), np.int64, sep=' ')
n,k = val[:2]
p_list = val[2:]

S = np.zeros(n+1, np.int64)
S[1:] = p_list.cumsum()

KS = S[k:] - S[0:-k]
print((KS.max()+k)/2)

Solution (Python):
import queue

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

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

s = 0
mx = 0
q = queue.Queue()

for i in range(n):
    s += p[i]
    q.put(p[i])
    if q.qsize() > k:
        s -= q.get()
    if q.qsize() == k:
        mx = max(mx, s)
    
ans = float(mx) / 2.0
print(ans)

Solution (Python):
n,k,*p=map(int,open(0).read().split())
s=m=sum(p[:k])+k
for i in range(k,n):s+=p[i]-p[i-k];m=max(m,s)  
print(m/2)

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

dicesSum=[]
l1=ps[0:K]
dicesSum.append(sum(l1))

if K==N:
    exp= (K+ dicesSum[0])/2
    print(exp)
else:
    for i in range(1,N-K+1):
        dicesSum.append(dicesSum[i-1]-ps[i-1]+ps[i+K-1])
    max_value = max(dicesSum)
    exp= (K+ max_value)/2
    print(exp)

Solution (Python):
n,k,*p=map(int,open(0).read().split())
s=m=sum(p[:k])
for i in range(k,n):s+=p[i]-p[i-k];m=max(m,s)  
print((m+k)/2)

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

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

s_max = -1
pos = 0
for i in range(n-k+1):
    ss = s[i+k] - s[i]
    if ss > s_max:
        s_max = ss
        pos = i

ans = 0.0
for i in range(pos, pos+k):
    ans += (p[i]+1) / 2

print(ans)

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

Solution (Python):
n,k,*p=map(int,open(0).read().split())
s=m=sum(p[:k])
for i in range(k,n):s+=p[i]-p[i-k];m=max(m,s)  
print((m+k)/2)

Solution (Python):
N, K = map(int, input().split())
a = list(map(int, input().split()))
ans = None
s = None

for i in range(0, N - K + 1):
    s = sum(a[i:i+K]) + K if s is None else s - a[i - 1] + a[i + K - 1]

    if ans is None or ans < s:
        ans = s

print(ans/2)

Solution (Python):
from sys import stdin
from itertools import accumulate
n,k = map(int,stdin.readline().rstrip().split())
li = list(map(int,stdin.readline().rstrip().split()))
ma = 0
lin = []
for i in li:
    lin.append((i+1)/2)
lis = [0]+list(accumulate(lin))
ma = 0
for i in range(n-k+1):
    if i+k > n:
        break
    l = lis[i+k]-lis[i]
    ma = max(ma,l)
print(ma)

Solution (Python):

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

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


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

print(ans)

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

max_pos = 0
max_value = sum(P[:K])
tmp_sum = max_value
for i in range(N-K):
    tmp_sum = tmp_sum - P[i] + P[i+K]

    if tmp_sum > max_value:
        max_value = tmp_sum
        max_pos = i + 1


total = 0
for i in range(max_pos, max_pos + K):
    total += (P[i] + 1) / 2


print(total)

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

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

Solution (Python):
import itertools

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    l = list(itertools.accumulate(A))

    score = sum(A[:M])
    for i in range(1, N-M):
        score = max(score, l[i+M] - l[i])
        
    ans = (M + score) / 2

    return ans

print(solve())

Solution (Python):
N,K = map(int,input().split())
List = list(map(int,input().split()))
result = [(1+i)/2 for i in List]
Answer = 0
if N == 1:
  print(result[0])
  exit()
elif N == K:
  print(sum(result))
  exit()
base = [sum(result[0:K])]
for i in range(N-K):
  counter = base[i]-result[i]+result[i+K]
  if counter > Answer:
    Answer = counter
  base.append(counter)
print(Answer)

Solution (Python):
import sys
input = sys.stdin.readline
N,K=map(int,input().split())
P=list(map(int,input().split()))
kouho=0
def saikorokitaiti(A):
    return ((P[A]*(1+P[A])/2)/P[A])
kari=[]
hako=[]
kitaiti=0
if K==1:
    print(saikorokitaiti(P.index(max(P))))
    exit()
for i in range(K):
    hako.append(saikorokitaiti(i))
    kitaiti+=saikorokitaiti(i)
    kouho=kitaiti
b=0
for j in range(N-K+1):
    if j==0:
        continue
    elif j+K-1<N:
        hako.append(saikorokitaiti(j+K-1))
        kitaiti+=saikorokitaiti(j+K-1)
        kitaiti-=hako[b]
        b+=1
        kouho=max(kouho,kitaiti)

print(kouho)

Solution (Python):
import numpy as np

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

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

data = np.sum(x[:K])
ans = data

for i in range(N-K):
	data = data + x[i+K] - x[i]
	if data > ans:
		ans = data

print(ans)

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

for i in range(n-k):
    l1=l[i] - p[i] + p[i+k]
    l.append(l1)

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

Solution (Python):

import sys


def solve(N: int, K: int, p: "List[int]"):
    M = m = sum(p[:K])
    for i in range(N-K):
        m = m - p[i] + p[i + K]
        M = max(M, m)
    print((1*K+M)/2)




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

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

sum = 0
S = [0]

for i in p:
    sum += i
    S.append(sum)



max = 0

for i in range(len(p) - K + 1):
    s = S[i + K] - S[i]
    
    if max < s:
        max = s

print(max)

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


for i in range(1,n):
    p[i]=p[i-1]+p[i]
mx = p[k-1]
for i in range(k,n):
    a = p[i] - p[i-k]
    if a > mx:
        mx = a
        
print(mx)

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

q = []
for p_i in p:
  q.append((p_i+1)/2)
  
s = [0]
pre_s = 0
for q_i in q:
  pre_s += q_i
  s.append(pre_s)

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

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
a = [0 for i in range(n)]

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

Solution (Python):
import numpy as np
 
def main():
    N, K = map(int, input().split(" "))
    ps = np.array(input().split(" "))
    ps = ps.astype("int64")
 
    ps_means = np.zeros(N)
    maxval = 0
 
    for i in range(N):
        ps_means[i] = ((1 + ps[i]) * ps[i])/ (2 * ps[i])
        if i + 1 >= K:
            if i + 1 == K:
                sumval = np.sum(ps_means[i-K+1:i+1])
            else:
                sumval -= ps_means[i-K]
                sumval += ps_means[i]
            if sumval > maxval:
                maxval = sumval
 
    ans = maxval
    print(ans)
 
if __name__ == '__main__':
    main()

Solution (Python):
from itertools import accumulate

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

q=[0]+p
q=list(accumulate(q)) 

ans=[]
for i in range(N-K+1):
    ans.append(((q[i+K]-q[i])+K)*0.5)

print(max(ans))

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

def InMap(): return list(map(int, sys.stdin.readline().split(' ')))
def In(): return int(sys.stdin.readline())
def InS(): return sys.stdin.readline()

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

tmp = sum(P[0:K])
Res = [0]*(N-K+1)
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):
import numpy as np
 
def main():
    N, K = map(int, input().split(" "))
    ps = np.array(input().split(" "))
    ps = ps.astype("int64")
 
    ps_means = np.zeros(N)
    maxval = 0
 
    for i in range(N):
        ps_means[i] = ((1 + ps[i]) * ps[i])/ 2
        if i + 1 >= K:
            if i + 1 == K:
                sumval = np.sum(ps_means[i-K+1:i+1] / ps[i-K+1:i+1])
            else:
                sumval -= ps_means[i-K] / ps[i-K]
                sumval += ps_means[i] / ps[i]
            if sumval > maxval:
                maxval = sumval
 
    ans = maxval
    print(ans)
 
if __name__ == '__main__':
    main()

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

n, k  = MAP()
p = LIST()

def kitai(a):
    tmp = 0
    
    tmp = 1/a * (1/2 * a * (a+1))
    return tmp
acc = [0] * n


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


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

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

m = sum(arr[0:k])
sump = m

for i in range(1, n-k+1):
    sump = sump - arr[i-1] + arr[i+k-1]
    if m < sump:
        m = sump

ans = (m + k) / 2

print(ans)

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

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

Solution (Python):
from itertools import accumulate
N, K = map(int, input().split())
ans = [0] + list(accumulate(map(lambda x: (int(x)+1)/2., input().split())))
print(max([y-x for x,y in zip(ans, ans[K:])]))

Solution (Python):
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=sum(B[0:A[1]])
D=C
for i in range(A[1]-1,A[0]-1):
  D=D+B[i+1]-B[i-A[1]+1]
  C=max(C,D)
print((C+A[1])/2)

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
for i in range(N-1):
    p[i+1] += p[i]

ans = []

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

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

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

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

Solution (Python):
from itertools import accumulate
import sys
read = sys.stdin.buffer.read

def main():
  N, K, *p = map(int, read().split())
  p = [0] + list(accumulate(p))
  print((max(b - a for a, b in zip(p, p[K:])) + K) / 2)

if __name__ == '__main__':
    main()

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

a = sum([(v+1) for v in p[:K]])
m = a
for i in range(1, N-K+1):
    t = a+(p[i+K-1]+1)-(p[i-1]+1)
    if t > m:
        m = t
    a = t
print(m/2)

Solution (Python):
from itertools import accumulate

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


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


acc = [0]+ list(accumulate(expP)) 


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

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

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

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

d = list(map(s, p) )

ans = m = sum(d[0:k])
ans_i = 0



for i in range(n-k):
    m -= d[i]
    m += d[i+k]
    
    if ans < m:
        ans = m
        ans_i = i + 1

print(ans)

Solution (Python):
from itertools import accumulate
import sys

def main():
  read = sys.stdin.buffer.read
  N, K, *p = map(int, read().split())
  p = [0] + list(accumulate(p))
  print((max(y - x for x, y in zip(p, p[K:])) + K) / 2)

if __name__ == '__main__':
    main()

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

ans = sum(sum_p[0:k])
check = sum(sum_p[0:k])
p = 0
for i in range(k,n):
    check = check + sum_p[i] - sum_p[i - k]
    if check > ans:
        ans = check
print(ans)

Solution (Python):
import numpy as np

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

ary = np.array([(1 + n) / 2 for n in numbers])

cumsum = ary.cumsum()

max_exv = cumsum[K-1]
for i in range(N - K):
    if cumsum[i+K] - cumsum[i] > max_exv:
        max_exv = cumsum[i+K] - cumsum[i]
    
print(max_exv)

Solution (Python):
def main():
  from itertools import accumulate
  import sys
  read = sys.stdin.buffer.read
  N, K, *p = map(int, read().split())
  p = [0] + list(accumulate(p))
  print((max(y - x for x, y in zip(p, p[K:])) + K) / 2)

if __name__ == '__main__':
    main()

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

E = [0]*(n+1)

sum_E = 0
max_E = 0

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

for i in range(n-k+1):
  
  if max_E < E[i+k] - E[i]:
    max_E = E[i+k] - E[i]

print(max_E)

Solution (Python):


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

m=sum(p[0:k])
ans=[m]
for i in range(k,n):
    m=m+p[i]-p[i-k]
    ans.append(m)
print(0.5*(max(ans)+k))

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

Solution (Python):

N,K=map(int,input().split())
P=list(map(int,input().split()))
if K==1:
	print((max(P)+1)/2)
elif N==K:
	print((sum(P)+N)/2)
else:
	T=sum(P[0:(K)])
	S=sum(P[0:(K)])
	for k in range(0,N-K):
		S=S-P[k]+P[k+K]
		if T<=S:
			T=S
		else:
			continue
	print((T+K)/2)

Solution (Python):

N,K=map(int,input().split())
P=list(map(int,input().split()))
if K==1:
	print((max(P)+1)/2)
elif N==K:
	print((sum(P)+N)/2)
else:
	T=sum(P[0:(K)])
	S=sum(P[0:(K)])
	for k in range(0,N-K):
		S=S-P[k]+P[k+K]
		if T<=S:
			T=S
		else:
			continue
	print((T+K)/2)

Solution (Python):


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

Solution (Python):

import numpy as np
N, K = map(int,input().split())
p = list(map(int,input().split()))

sums=np.cumsum([(s+1)/2 for s in p])

ans=np.max([ sums[i+K]-sums[i] for i in range(N-K)]+[sums[K-1]])

print(ans )

Solution (Python):
def d_dice_in_line():
    from itertools import accumulate
    N, K = [int(i) for i in input().split()]
    P = [int(i) for i in input().split()]

    expected_value = [0] + [(p + 1) / 2 for p in P]
    cumsum = list(accumulate(expected_value))
    return max([cumsum[j + K] - cumsum[j] for j in range(N - K + 1)])

print(d_dice_in_line())

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

ans = 0
for p in P:
    P_kitaiti.append((1+p)*p/2/p)

for left in range(0, N-K+1):
    if left ==0:
        ans = sum(P_kitaiti[left:left+K])
        now = sum(P_kitaiti[left:left+K])
    else:
        
        now -= P_kitaiti[left-1]
        now += P_kitaiti[left+K-1]
        ans = max(ans, now)
print(ans)

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
 
now = sum(p[:K])
saidai = now
for i in range(K, N):
  now -= p[i-K]
  now += p[i]
  if now > saidai:
    saidai = now
 
print('{:.12f}'.format((saidai + K)/2))

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

summ = sum(P[0:K])
maxi = summ
idx = 0
ans = []
for i in range(N-K):
    summ = summ - P[i] + P[K+i]
    if summ > maxi:
        maxi = summ
        idx = i+1
for j in range(K):
    ans.append((P[idx+j]+1)/2)
print(sum(ans))

Solution (Python):
def main():
    N,K = map(int, input().split())
    p = list(map(int, input().split()))
    if N>K:
        esum = [0]*N
        psum = [0]*(N-K)
        esum[0] = p[1]
        for i in range(1,K):
            esum[i] = esum[i-1]+p[i]
        for i in range(K,N):
            esum[i] = esum[i-1]+p[i]
            psum[i-K] = esum[i]-esum[i-K]
        ans = (max(psum)+K)*0.5
    else:
        ans = (sum(p)+K)*0.5

    print(ans)
    return

if __name__=="__main__":
    main()

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


ex_list = list() 
for i in range(len(p)):
	if i != 0:
		ex_list.append(((1+p[i])/2)+ex_list[-1])
	else:
		ex_list.append((1+p[i])/2)

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

Solution (Python):
n, k = map(int, input().split())
p = list(map(int,input().split()))
val = 0
atai = 0
val2 = 0
for i in range(k):
    val2 += p[i]

val = val2
for i in range(k,n):
    if val < val2:
        val = val2
        atai = i-k+1
    
    val2 += p[i]
    
    val2 -= p[i-k]
    
    if val < val2:
        val = val2

        atai = i-k+1



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

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

Sim = [0]
for i in range(0,N):
  Sim.append(Sim[i]+Pi[i])
MAX = max(Sim[i+K] - Sim[i] for i in range(N+1-K))

print((MAX+K)/2)

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


import numpy as np
s = np.cumsum(p)

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

Solution (Python):
n, k = map(int, input().split())
p = list(map(int,input().split()))
val = 0
atai = 0
val2 = 0
for i in range(k):
    val2 += p[i]

val = val2
for i in range(k,n):
    if val < val2:
        val = val2
        atai = i-k+1
    
    val2 += p[i]
    if i==k:
        val2 == 0
    else:
        val2 -= p[i-k]
    
    if val < val2:
        val = val2

        atai = i-k+1



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

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

s=0
for i in range(k):
    s += E[i]
    
box=[]
box.append(s)
for i in range(k,n):
    s += E[i] - E[i-k]
    box.append(s)
    
print(max(box))

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

s = sum(p[:k])
max_s = s

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

    if max_s < s:
        max_s = s

print((max_s + k) / 2)

Solution (Python):
import numpy as np

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

res = np.cumsum(E)

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

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(0,N-K):
  e=s[i+K]-s[i]
  max_e = max(max_e, e)
    
print(max_e)

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

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

print((k+ans)/2)

Solution (Python):
N, K = map(int,input().split())
p = tuple(map(int,input().split()))
MaxSum = sum(p[:K])
tmp_SumSlice = MaxSum
for i in range(K, N):
    tmp_SumSlice = tmp_SumSlice + p[i] - p[i - K]
    if MaxSum < tmp_SumSlice:
        MaxSum = tmp_SumSlice
print((MaxSum+K)/2)

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

def main():
    N, K, *p = map(int, read().split())
    p = list(map(lambda x: (x+1)*0.5, p))
    p_sum = []
    p_sum.append(p[0])
    for i in range(1, len(p)):
        p_sum.append(p_sum[i-1] + p[i])
    result = p_sum[K-1]
    for i in range(1,N-K+1):
        result = max(result,p_sum[K-1+i] -p_sum[i-1])
    return result

if __name__ == '__main__':
    print(main())

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):
a, b = map(int, input().split())
num_list = list(map(int, input().split()))
k_sum = sum(num_list[0:b])
max_sum = k_sum
for i, j in zip(num_list[0:], num_list[b:]):
    k_sum -= i
    k_sum += j
    max_sum = max(max_sum, k_sum)
out = (max_sum + b) / 2
print(out)

Solution (Python):
from itertools import accumulate


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


expected = [(a+1)/2 for a in A]
accum_expected = list(accumulate(expected))
accum_expected.insert(0, 0)

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

Solution (Python):
import sys
import numpy as np

input = sys.stdin.readline
n, k = map(int, input().split())

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


p_cumsum = np.cumsum(p)

ans = p_cumsum[k-1]

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


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

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