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 main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    maxI = 0
    maxV = sum(P[:K])
    curV = maxV
    for i in range(1, N-K+1):
        curV = curV + P[i+K-1] - P[i-1]
        if curV > maxV:
            maxV = curV
            maxI = i

    res = (sum(P[maxI:maxI+K]) + K) / 2.0
    print(res)

main()

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

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

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

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

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

s = s_tmp = sum(p[0:K])
for i in range(N-K):
    s_tmp = s_tmp - p[i] + p[i+K]
    if s < s_tmp:
        s = s_tmp

print((s+K)/2)

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

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

ans = sum(p[:K])
now = sum(p[:K])

for i in range(K, N):
    now = now + p[i] - p[i-K]
    if now > ans:
        ans = now

print(ans)

Solution (Python):
from itertools import accumulate


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


B = [0] + A
B = list(accumulate(B))

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

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

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
dd = [0] * (n + 1)
for i in range(1, n + 1):
    dd[i] = dd[i - 1] + p[i - 1]
total = 0
index = 0
j = 0
while j < n + 1:
    if j + k >= n + 1:
        break
    now = dd[j + k] - dd[j]
    if now > total:
        total = now
        index = j
    j += 1
ans = 0
for i in range(k):
    aa = index + i
    ans += p[index + i] + 1
ans /= 2
print(ans)

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

s = 0
for i in range(K):
    s += 1 + Ps[i]

ans = s

for i in range(K, N):
    s = s - Ps[i-K] + Ps[i]
    ans = ans if ans > s else s

print(ans / 2)

Solution (Python):
nums = list(map(lambda x: int(x), input().split(" ")))
n = nums[0]
k = nums[1]
ps = list(map(lambda x: (int(x) + 1) / 2, input().split(" ")))
res = 0.0
su = 0.0
sums = [0] * n
for i, s in enumerate(ps):
    su = su + s
    sums[i] = su
for i in range(n - k + 1):
    if i == 0:
        res = sums[k - 1]
    else:
        res = max(res, sums[i + k - 1] - sums[i - 1] )
print(res)

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

tem=0
ans=0

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

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

print(ans)

Solution (Python):

def input_one_number():
    return int(input())


def input_multiple_number():
    return map(int, input().split())


def input_multiple_number_as_list():
    return list(map(int, input().split()))


n_given,k_given =input_multiple_number()
pi_given = input_multiple_number_as_list()


wk = sum(pi_given[0:k_given])
maxi = wk

for i in range(n_given - k_given):
    wk = wk - pi_given[i] + pi_given[i+k_given]
    maxi = max(maxi,wk)

print((maxi + k_given )/2)

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

dp=[0]*n
ans,total=0,0
for i in range(n):
  dp[i]=((1/2)*P[i]*(P[i]+1)) / P[i]
  if i>=k:
    ans=max(ans,total)
    total-=dp[i-k]
  total+=dp[i]
ans=max(ans,total)
print(ans)

Solution (Python):
N, K = map(int, input().split())
tmp = input().split()
P = [int(tmp[i]) for i in range(N)]
max_sum = 0
for i in range(K):
    max_sum += P[i]

tmp_sum = max_sum
for i in range(K,N):
    tmp_sum -= P[i-K]
    tmp_sum += P[i]
    if tmp_sum > max_sum:
        max_sum = tmp_sum


ret = max_sum/2 + K/2
print(ret)

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

s = [0]

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

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

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

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

Solution (Python):
n,k = [int(e) for e in input().split()]
p = [int(e) for e in input().split()]
sum = 0
max_index = 0
for i in range(0,k):
    sum += p[i]
max_sum = sum
for i in range(1,n-k+1):
    sum = sum - p[i-1] + p[i+k-1]
    if sum > max_sum:
        max_sum = sum
        max_index = i

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

print(res)

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

ave_pl = []
for i, p in enumerate(pl):
    p_sum = p*(p+1)/2
    if i == 0:
        ave_pl.append(p_sum/p)
    else:
        ave_pl.append(ave_pl[i-1]+(p_sum/p))

ans = 0
if n == k:
    print(ave_pl[-1])
else:
    for i in range(k-1, n):
        if i == 0:
            ans = max(ans, ave_pl[i])
        else:
            ans = max(ans, ave_pl[i]-ave_pl[i-k])
    print(ans)

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

Solution (Python):
n,k = map(int,input().split())
L = [0]
P = list(map(int,input().split()))
L = L+P
cur = 0
for i in range(n+1):
  if i != 0:
    L[i] = (L[i]+1)/2
    L[i] += L[i-1]
for i in range(n-k+1):
  cur = max(L[i+k]-L[i],cur)
print(cur)

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

p1 = (sum(p[:k]) + k)/2

ansum = [p1]
for i  in range(len(p)-k):
    p1 = p1 - (p[i]+1)/2 + (p[i+k]+1)/2
    ansum.append(p1)

print(max(ansum))

Solution (Python):
import itertools
n, k = map(int, input().split())
p = list(map(int, input().split()))
ki = [0]*1001
for i in range(1, 1001):
    ki[i] = ki[i-1]+i

pp = []
for pa in p:
    pp.append(ki[pa]/pa)


ppp = [0] + list(itertools.accumulate(pp))

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

print("{0:.12f}".format(ans))

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

n, k = map(int, input().split())
p = list(map(int, input().split()))
s = [0 for i in range(k)]
ans = 0
mm = 0
j = 0

for i in range(n):
  if j < k:
    s[j] = sumA(p[i])/p[i]
    mm+=s[j]
  else:
    mm-=s[j%k]
    mm+= sumA(p[i])/p[i]
    if ans < mm:
      ans = mm
    s[j%k] = sumA(p[i])/p[i]
  j+=1
  
print(max(mm, ans))

Solution (Python):
from collections import deque
n, k = (int(x) for x in input().split())
p = [int(x) for x in input().split()]
d = deque(p)
tmax = 0
pmax = 0
for i, pp in enumerate(p):
    pmax += pp
    if i >= k:
        pmax -= d.popleft()
    if pmax > tmax:
        tmax = pmax
ans = (tmax + k) / 2
print(ans)

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,k=nm()
ans=0
p=nl()



e=[0]*n

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

s=sum(e[:k])

t=0
ans=0
for i in range(n-k+1):
    if i==0:
        t=s
        ans=max(ans,t)
        continue
    t+=e[i+k-1]
    t-=e[i-1]
    ans=max(ans,t)
print(ans)

Solution (Python):
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]



def A():
    s, t = input().split()
    a, b = LI()
    u = input()
    if u == s:
        print("{} {}".format(a - 1, b))
    elif u == t:
        print("{} {}".format(a, b - 1))
    return



def B():
    s = input()
    print('x' * len(s))
    return



def C():
    n = I()
    a = LI()
    s = set()
    for i in a:
        s.add(i)
    if len(s) == n:
        print('YES')
    else:
        print('NO')
    return



def D():
    N, K = LI()
    p = LI()
    map_p = list(map(lambda x: (1 + x), p))
    cumsum_p = [0] * N
    ans_p = [0] * N
    cumsum_p[0] = map_p[0]
    ans_p[0] = map_p[0]
    for i in range(1, N):
        cumsum_p[i] = cumsum_p[i - 1] + map_p[i]
        ans_p[i] = ans_p[i - 1] + map_p[i]
    for i in range(K, N):
        ans_p[i] -= cumsum_p[i - K]
    print(max(ans_p[K - 1:]) / 2.0)
    return



def E():
    return



def F():
    return



if __name__ == "__main__":
    D()

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

for i in range(N):
    k=((1+P[i])*(P[i]))/(2*P[i])
    A.append(k)
c=0
for i in range(K):
    c+=A[i]
ans=c

for i in range(K,N):
    c=c-A[i-K]+A[i]
    if(ans<c):
        ans=c
print(ans)

Solution (Python):
k,n=map(int,input().split())
ls=list(map(int,input().split()))
sum_ls=ls[:n]
rest_ls=ls[n:]
tmp=sum(sum_ls)
mx=tmp
for i in range(k-n):
    first=ls[i]
    last=ls[i+n]
    tmp=tmp-first+last
    if mx<tmp:
        mx=tmp


print((mx+n)/2)

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

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

saidai = 0
for i in range(n-k+1):
    if sekiwa[i+k] - sekiwa[i] >= saidai:
        saidai = sekiwa[i+k] - sekiwa[i]
        hajimari = i

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

print(ans)

Solution (Python):
from copy import copy
N,K = map(int, input().split())
p=list(map(int, input().split()))
expP = [(1+i)/2 for i in p]
id_H = N-K
id_T = N
minus = sum(expP[:id_H])
minimum = minus
for i in range(id_H):
    minus -= expP[id_H - i -1]
    minus += expP[id_T - i -1]
    if minus < minimum:
        minimum = copy(minus)
ans = sum(expP) - minimum
print(ans)

Solution (Python):
a=input()
b=input()
d=a.split()
N=int(d[0])
K=int(d[1])
c=b.split()
s=0
max=0
for f in range(K):
    s=s+int(c[f])
max=s
for i in range(N-K):
    if(K+i<N):
      s=s+int(c[K+i])-int(c[i])
      if(s>max):
          max=s
    else: break
print(float((max+K)/2))

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

def expectation(p):
    return (p - 1) / 2 + 1

h = {}

answer = 0
for i in range(N):
    if i < K - 1:
        answer += expectation(P[i])
    elif i == K - 1:
        answer += expectation(P[i])
        h[i] = answer
    else:
        answer += expectation(P[i])
        answer -= expectation(P[i - K])
        h[i] = answer
print(max(list(h.values())))

Solution (Python):
n,k = map(int, input().split())
a = list(map(int, input().split()))
sum = [0]*(len(a)+1)
for i,val in enumerate(a):
    ex = val*(val+1)/2/val
    sum[i+1] = sum[i]+ex
ma = 1
for i in range(n):
    if i+k <= n:
        ma = max(ma,sum[i+k]-sum[i])
    else:
        break
print(ma)

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



P2 = [(n+1) for n in P]

S = sum(P2[:K])
max_s = S
for i in range(1, N-K+1):
    S -= P2[i-1]
    S += P2[i+K-1]

    max_s = max(max_s, S)


print('{:.10f}'.format(max_s/2))

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

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

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

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

Solution (Python):
from itertools import accumulate


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

d = {}
for i in range(1, 1001):
    d[i] = (i + 1) * (i / 2) / i

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

cum = list(accumulate(E))
mx = 0
idx = 0
ans = 0
for i in range(N-K+1):
    if i == 0:
        mx = max(mx, cum[i+K-1])
    else:
        mx = max(mx, cum[i+K-1] - cum[i-1])

print(mx)

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

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

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

    tmp=li[i]
    tmp-=(1+p[i])/2
    tmp+=(1+p[k+i])/2
    
    li.append(tmp)


print(max(li))

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

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

DP=[0]*1001
for i in P:
    if DP[i]==0:
        DP[i]=(i*(i+1)//2)/i
    K.append(DP[i])

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

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

    kti = [0] * n
    sm = [0] * (n)
    for i,pp in enumerate(p):
        kti[i] = (pp + 1) / 2
        if i == 0:
            sm[0] = kti[0]
        else:
            sm[i] = sm[i-1] + kti[i]

    ans = sm[k-1]
    j = 0
    for i in range(k,len(sm)):

        tmp = sm[i]-sm[j]
        ans = max(ans,tmp)
        j += 1
    print(ans)
    
if __name__=='__main__':
    main()

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

from collections import deque
d=deque(p_list[:k])
max_val = sum(p_list[:k])
total = max_val
max_idx = 0

for i in range(k, n):
    num = p_list[i]
    total = total + num - d.popleft()
    if total > max_val:
        max_val = total
        max_idx = i-k+1
    d.append(num)

def exp(n):
    return 1+(n-1)*0.5

print(sum(map(exp, p_list[max_idx:max_idx+k])))

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
cs=[]
sum=0
for i in range(n):
	sum+=p[i]
	cs.append(sum)
ans=cs[k-1]
for i in range(1,n-k+1):
	ans=max(ans,cs[i+k-1]-cs[i-1])
print('{:.8f}'.format(ans))

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

    def experience(x):
        return (x + 1) / 2  

    ans = []
    tmp = 0
    for i in range(K):
        tmp += experience(P[i])
    ans.append(tmp)
    for i in range(K, N):
        tmp -= experience(P[i - K])
        tmp += experience(P[i])
        ans.append(tmp)
    return max(ans)

print(d_dice_in_line())

Solution (Python):
N,K=map(int,input().split())
P=[int(i)+1 for i in input().split()]
left = 0
right = K
max_=sum(P[:K])
ans=max_

for _ in range(N-K):
    ans=max(ans,max_ - P[left] + P[right])
    max_=max_ - P[left] + P[right]
    left += 1
    right += 1
print(ans/2)

Solution (Python):
import sys
from functools import lru_cache
def input(): return sys.stdin.readline().rstrip()

sys.setrecursionlimit(10 ** 9)

@lru_cache(maxsize=None)
def calc(n):
    if n == 1:
        return 1
    else:
        return n + calc(n - 1)

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

    l = 0
    sum_v = 0
    max_v = 0
    max_i = 0
    ind = 0
    for i in range(N-K+1):
        while l < K:
            sum_v += P[ind]
            ind += 1
            l += 1
        if sum_v > max_v:
            max_v = sum_v
            max_i = i
        l -= 1
        sum_v -= P[i]
    print(sum([calc(p) / p for p in P[max_i:max_i+K]]))

if __name__ == '__main__':
    main()

Solution (Python):

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

max_sum = sum(p_list[:K])
now_sum = max_sum
for i in range(K, N):
    now_num = p_list[i]
    now_sum -= p_list[i - K]
    now_sum += now_num
    if now_sum > max_sum:
        max_sum = now_sum

print((max_sum + K) / 2)

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

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

sum = [0]
for i in range(n):
    sum.append(sum[i] + exp[i])

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

print(max)

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

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()))

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

mm=0
inx=-1
for i in range(len(b)-k):
 if b[i+k]-b[i]>=mm:
  inx=i
  mm=b[i+k]-b[i]


ans=0
for j in range(inx,inx+k):
  ans+=((p[j]*(p[j]+1))*0.5)*(1/p[j])

print(ans)

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

sum=[0]*N
sum_f=0

for j in range(K):
  sum_f += (p[j]+1)/2
sum[0]=sum_f
  
for i in range(1,N-K+1):
  sum[i]=sum[i-1] - (p[i-1]+1)/2 + (p[i+K-1]+1)/2
  
print(max(sum))

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

maxx = 0
def total(x):
    return int(x*(x+1)/2)

kitai_P = [total(x)/x for x in P]

ans = 0
now = sum(kitai_P[0:k])
for i in range(n-k+1):
    if i >= 1:
        now = now - kitai_P[i-1] + kitai_P[i+k-1]
    ans = max(ans, now)
print(ans)

Solution (Python):
N,K = map(int,input().split())
p_list = list(map(int,input().split()))
ans_list = []
def E(me):
    if me == 1:
        return 1
    else:
        return ((1+me)*me/2)/me
E_list_ruisekiwa = [0,]
for i in range(N):
    E_list_ruisekiwa.append(E_list_ruisekiwa[i]+E(p_list[i]))

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

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

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

ans = List2[0]

for i in range(1,N-K+1):
    List2[i]=List2[i-1]+P_List[i+K-1]-P_List[i-1]
    if ans < List2[i]:
        ans = List2[i]

print(ans)

Solution (Python):
import numpy

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

List=list(map(int,input().split()))
EList = []

for i in range(len(List)):
  a = List[i]
  b = (a+1)/2
  EList.append(b)
  

res = numpy.cumsum(EList)
res = numpy.insert(res,0,0)
ans = 0
for i in range(len(List)+1):
  if i < K-1:
    ans = 0
  else:
    ans = float(max(res[i] - res[i-K],ans))

print(float(ans))

Solution (Python):


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

ps = list(map(int,input().split()))
Es = []
for p in ps:
    Es.append((1+p)/2)
beg = 0
end = K
ans = sum(Es[beg:end])
prev = ans

while end < N:
    prev = prev - Es[beg] + Es[end]

    if prev > ans:
        ans = prev
    beg += 1
    end += 1

print(ans)

Solution (Python):
import sys
import math


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

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

x = sum(p[:k])
y = 0
max = 0
for i in range(n-k):
  y = y + p[k+i] - p[i]
  if y > max:
    max = y

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

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

summax = sum(p[0:K])
sumnow = sum(p[0:K])
maxi = 0

for i in range(1, N-K+1):
  sumnow = sumnow - p[i-1] + p[K+i-1]
  if sumnow > summax:
    summax = sumnow
    maxi = i

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

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
l = []
for x in p:
    tmp = 1.0+0.5*(float(x)-1.0)
    l.append(tmp)
max = sum(l[:k])
now = max
for i in range(k,n):
    now = now + l[i] - l[i-k]
    if now >= max:
        max = now
print(max)

Solution (Python):
import numpy as np

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

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


index = 0
goukei = sum(p[0:k])
max = goukei
for j in range(n-k):
    goukei = (goukei - p[j] + p[j+k])
    if goukei > max:
        max = goukei
        index = j+1

ans = 0
for i in range(index, index+k):
    ans += ((p[i]+1)*0.5)

print(ans)

Solution (Python):
n, k = map(int, input().split())
p_ls = list(map(int, input().split()))
ave_ls = []
'''
if n == 1:
    ave_ls.append(p_ls[0]*0.5+1)
elif n == 2:
    ave_ls.append((p_ls[0]+p_ls[1])*0.5+1)
else:
    for i in range(n-2):
        ave_ls.append((p_ls[i]+p_ls[i+1]+p_ls[i+2])*0.5+1)
'''
now_ave = 0
for i in range(k):
    now_ave +=p_ls[i]
ave_ls.append(now_ave*0.5+0.5*k)
for i in range(n-k):
    
    now_ave -=p_ls[i]
    now_ave+=p_ls[i+k]
    
    ave_ls.append(now_ave*0.5+0.5*k)
print(max(ave_ls))

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

Solution (Python):
def solve():
    N, K = [int(_) for _ in raw_input().split()]
    p = [int(_) for _ in raw_input().split()]
    sumNk = 0
    for i in range (K):
        sumNk += p[i]
    maxSumNk = sumNk
    for i in range (K, N):
        sumNk = sumNk - p[i - K] + p[i]
        if sumNk > maxSumNk:
            maxSumNk = sumNk
    ret = (maxSumNk + K) * 0.5
    print ret

if __name__ == '__main__':
    solve()

Solution (Python):

n,k=map(int,input().split())
p=list(map(int,input().split()))
count=0
ans=[0]*(n-k+2)

for j in range(0,k):
    count+=(p[j]/2+0.5)
ans[0]=count
z=1

for i in range(k,n):
    
    ans[z]=ans[z-1]-(p[z-1]/2+0.5)+(p[i]/2+0.5)
    z+=1

print(max(ans))
"""
n,k=map(int,input().split())
p=list(map(int,input().split()))
count=0
ans=[]
for i in range(n-k+1):
    for j in range(i,k+i):
        count+=(p[j]/2+0.5)

    ans.append(count)
    count=0
print(ans)
print(max(ans))
"""

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

sum_k = [0] * N
tmp = 0
for i in range(K):
    tmp += p[i]
sum_k[0] = tmp
max_sum = tmp
candidate = 0
for i in range(len(p)-K):
    sum_k[i+1] = sum_k[i] - p[i] + p[i+K]
    if max_sum < sum_k[i+1]:
        max_sum = sum_k[i+1]
        candidate = i+1


dice = [-1] * 10000

ans = 0
for i in range(candidate, candidate + K):
    tmp = 0
    if dice[p[i]+1] != -1:
        ans += dice[p[i]+1]
        continue
    for j in range(1, p[i]+1):
        tmp += j * (1 / p[i])
    dice[p[i]+1] = tmp
    ans += tmp
print(ans)

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

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

print(max_exp)

Solution (Python):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy




def get_range_sum(l,s,e):
    return l[e] - l[s]

def main():
    N,K = map(int, input().split())
    pp = list(map(int, input().split()))
    pp_rui = defaultdict(int)
    for i in range(N):
        pp_rui[i+1] = pp_rui[i] + pp[i]
    
    emax = 0
    cc = K/2
    for i in range(N-K+1):
        res = get_range_sum(pp_rui, i, i+K) + K
        res = res / 2
        
        emax = max(emax, res)
    print("{:.12f}".format(emax))

if __name__ == '__main__':
    main()

Solution (Python):
from fractions import gcd

def prime(n:int):
    cnt = 2
    ans = set()
    while n > 1:
        if n%cnt == 0:
            ans.add(cnt)
        while n%cnt == 0:
            n //= cnt
        cnt += 1
    return ans

def main():
    N,K = map(int,input().split())
    P = [(int(p)+1)/2 for p in input().split()]

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

if __name__ == "__main__":
    main()

Solution (Python):




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

acm = [0] * n


for i in range(n):
    if i-k < 0:
        minu = 0
    else:
        minu = p[i-k]
    acm[i] = acm[i-1] + p[i] - minu

ans = (max(acm) + k) / 2


print(ans)

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

ki = [0] * N

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

ans = 0

for j in range(K):
    ans += ki[j]

b_result = ans

for times in range(N-K):
    tmp = b_result
    tmp = tmp - ki[times] + ki[K+times]
    if tmp >= ans:
        ans = tmp
    b_result = tmp

print(ans)

Solution (Python):
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,K=input_int()
P= many_int()

kitaiti = [0]
for p in P:
    kitaiti.append((p+1)/2 )



maxs = 0
temp = sum(kitaiti[:K])
for i in range(N-K+1):

    temp += kitaiti[i+K]
    temp -= kitaiti[i]

    if temp > maxs:
        maxs = temp


print(maxs)

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

Solution (Python):

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


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

tmp = sum(A[:k])

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

print((ans + k) / 2.0)

Solution (Python):
import sys
import itertools 

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,K = MI()
	p = LI()
	for i in range(N):
		p[i] = (1+p[i])*(1/2)
	p=[0]+list(itertools.accumulate(p))
	ans = -1
	for i in range(K,N+1):
		s = p[i]-p[i-K]
		if(ans < s):ans=s
	print(ans)


main()

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

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

for i in range(n-k):
  exp += (1 + p[i+k]) / 2
  exp -= (1 + p[i]) / 2
  if exp_true < exp:
    exp_true = exp

print(exp_true)

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

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

ans =0
if N-K>0:
    for i in range(N-K):
        ans = max(a[i+K] - a[i], ans)
else:
    ans = a[-1]
print("{0:.8f}".format((ans+K)*0.5))

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

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

        if tmp > tmp_max:
            tmp_max = tmp

    ans = (tmp_max + K) / 2
    print(ans)


if __name__ == "__main__":
    main()

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

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

print(max(x))

Solution (Python):
import numpy as np
K,N = list(map(int,input().split()))
arr = np.array(list(map(int,input().split())))
arr = arr.cumsum()
_sum = 0
for i in range(len(arr)-N+1):
  if i==0:
    tmp = arr[N-1]
  else:
    tmp = arr[N+i-1]-arr[i-1]
  _sum = max(_sum,tmp)

print((_sum+N)/2)

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

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

l = []
tmp = 0

for i in range(K):
    a= (p[i]+1)/2
    tmp+=a
    l.append(a)
ans = tmp
for i in range(K,N):
    a = (p[i]+1)/2
    l.append(a)
    b = l[i-K]
    tmp += a
    tmp -= b
    ans=max(ans,tmp)

print(ans)

Solution (Python):

"""
Created on Sun Feb  9 20:53:23 2020

@author: H_Hoshigi
"""

N, K = map(int, input().split())
p_list = list(map(int, input().split()))
E_list = [(1+p)/2 for p in p_list]

moving_sum_E_K_list = [sum(E_list[0:K])]
max_msEK = moving_sum_E_K_list[0]
for i in range(N-K):
    msEK = moving_sum_E_K_list[-1] - E_list[i] + E_list[K+i]
    moving_sum_E_K_list.append(msEK)
    max_msEK = max(max_msEK, msEK)

print(max_msEK)

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