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):
import bisect,collections,copy,heapq,itertools,math,numpy,string,scipy
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pe = [(v+1)/2 for v in P]
    P_ms = numpy.cumsum(Pe)
    if K==N:print("{:.12f}".format(sum(Pe)));exit(0)
    ans = 0
    for i in range(K,N):
        ans = max(ans,P_ms[i]-P_ms[i-K])
    print("{:.12f}".format(ans))
main()

Solution (Python):
expected = {}

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

max_sum = 0
for i in range(k):
  max_sum += p[i]
  
last_sum = max_sum
max_init_index = 0

for i in range(1, n - k + 1):
  current_sum = last_sum - p[i - 1] + p[i + k - 1]
  if max_sum < current_sum:
    max_sum = current_sum
    max_init_index = i
  last_sum = current_sum

for i in range(1, 1001):
  expected[i] = 1 + (i - 1)/2

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

print(ans)

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

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


s=[]
p=np.array(p)
sum=0
for i in range(n):
  sum+=(1+p[i])/2
  s.append(sum)

if k==n:
  print(s[-1])
  exit()
max=s[k-1]-s[0]
for j in range(1,n-k):
  
  if max<= s[j+k]-s[j]:
    max=s[j+k]-s[j]
  
print(max)

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

P = [int(_) for _ in input().split()]

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

ans = 0
tmp = 0
for i in range(N):
    tmp += P[i]
    if i < K - 1: continue
    ans = max(tmp, ans)
    tmp -= P[i - K + 1]
print(ans)

Solution (Python):
n,k,*a=map(int,open(0).read().split())
b=[q+1 for q in a]
ans=sum(b[:k])
now=ans
for i in range(k,n):
  now=now+b[i]-b[i-k]
  ans=max(ans,now)
print(ans/2)

Solution (Python):
import sys
from itertools import accumulate

rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n, k = rm()
a = [(i+1)/2 for i in rl()]
a = [0] + list(accumulate(a))
ans = 0
for i in range(n-k+1):
    ans = max(ans, a[i+k] - a[i])
print(ans)

Solution (Python):

import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n,k = MAP()

p = LIST()




mx = 0

for i in range(k):
    mx+=(p[i]+1)/2
    
gndMax = mx
i = 1
j=k

while(j<n):
    mx = mx + (p[j] + 1) / 2 - (p[i - 1] + 1) / 2
    gndMax=max(gndMax, mx)
    i+=1
    j+=1
    
print(gndMax)

Solution (Python):

from itertools import accumulate
def resolve():
    def ev(x):
        return (x*(x+1)//2)/x

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

    E = [0]+[ev(a) for a in A]
    E = list(accumulate(E))
    ans = 0
    for i in range(N-K+1):
        if ans < E[i+K] - E[i]:
            ans = E[i + K] - E[i]
    print(ans)

if __name__ == "__main__":
    resolve()

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

(n, k), s, res, sm = map(int, input().split()), list(map(lambda x: (int(x) + 1) / 2, input().split())), 0, 0
for i in range(n):
	if i < k: sm += s[i]
	else: sm += s[i]; sm -= s[i-k]
	res = max(res, sm)
print(f'{res:.10f}')

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

for i in range(n - k):
  expected_value.append(expected_value[-1]-p[i]+p[i+k])
print((max(expected_value)+k)/2)

Solution (Python):
def kitaichi(x):
    return x * (x+1) / (2 * x)

def main():
    n, k = map(int, input().split())
    inlis = tuple(map(int, input().split()))
    kitalis = list(map(kitaichi, inlis))
    kitadic = {}
    kitadic[0] = kitalis[0] 
    for i in range(1, n):
        kitadic[i] = kitadic[i-1] + kitalis[i]
       
    tmp = 0
    if n == k:
        print(kitadic[n-1])
    else:
        for i in range(n - k):
            atai = kitadic[i+k] - kitadic[i]
            if tmp < atai:
                tmp = atai
        print(tmp)
        exit()



    
if __name__ == "__main__":
    main()

Solution (Python):
N, K, *X = map(int, open(0).read().split())

y = [float(x * (x + 1) / 2 / x) for x in X]
ans = sum(y[:K])
res = ans
for i in range(K, N):
    res = res - y[i - K] + y[i]
    ans = max(ans, res)
print(ans)

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

pre = sum(plist[:K])
ans = pre
for i in range(0, N-K):
    pre = pre - plist[i] + plist[i+K]
    ans = max(ans, pre)

print((ans + K)/2)

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

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

pos_acum = list(itertools.accumulate(pos))

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

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

P_ac = [sum(P[:k])]
for i in range(n-k):
    P_ac.append(P_ac[-1]-P[i]+P[i+k])

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

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

Solution (Python):
N,K=map(int,input().split())
P=list(map(int,input().split()))
A=[]
for num in P:
    num=(num+1)*0.5
    A.append(num)

T=sum(A[:K])
ans=sum(A[:K])
for i in range(N-K):
    a=T-A[i]+A[i+K]
    ans=max(ans,a)
    T=a
print(ans)

Solution (Python):
import sys






def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))




def main():
	n,k=MI()
	p=LI()

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

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

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















if __name__ == "__main__":
	main()

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


MAXX = 1001
ave = [0.0]*MAXX

ans = 0.0
right = 0















sumz = 0.0
for left in range(0, N):
    if right <= left: right = left+1
    while right <= N and right - left <= K:
        x = dice[right-1]
        if ave[x] <= 0.000001:
            ave[x] = (x+1)/2.0
        sumz += ave[x]
        right += 1

    if ans < sumz:
        ans = sumz

    sumz -= ave[dice[left]]

print(ans)

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


MAXX = 1001
ave = [0.0]*MAXX

ans = 0.0
sumz = [0.0]*(N+1)
right = 0

for i in range(N):
    x = dice[i]
    if ave[x] <= 0.000001:
        ave[x] = (x + 1) / 2.0
    sumz[i+1] = sumz[i]+ ave[x]


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

print(ans)

Solution (Python):
import sys






def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))




def main():
	n,k=MI()
	p=LI()

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

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

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















if __name__ == "__main__":
	main()

Solution (Python):
import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

d = defaultdict(float)
for i in range(1, 1001):
    j = i
    while 0 < j:
        t = j * (1 / i)
        d[i] += t
        j -= 1

sum = [0.0]*(n+1)
for i in range(n):
    sum[i+1] = sum[i] + d[p[i]]

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

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

Solution (Python):
import sys
from builtins import enumerate
from io import StringIO
import unittest
import os


sys.setrecursionlimit(999999999)



def resolve(test_def_name=""):
    
    
    
    
    
    

    
    
    
    n, k = map(int, input().split())
    p_s = [0] + list(map(int, input().split()))

    avr_s = [0]
    cumsum = 0
    for i in range(1, 1001):
        cumsum += i
        avr_s.append(cumsum / i)

    ans = 0
    val = 0
    for i in range(1, len(p_s)):
        val += avr_s[p_s[i]]
        if i < k:
            continue
        elif i == k:
            ans = val
        else:
            val -= avr_s[p_s[i - k]]
            ans = max(ans, val)

    print(ans)





class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """5 3
1 2 2 4 5"""
        output = """7.000000000000"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """4 1
6 6 6 6"""
        output = """3.500000000000"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """10 4
17 13 13 12 15 20 10 13 17 11"""
        output = """32.000000000000"""
        self.assertIO(test_input, output)

    
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)



if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        
        resolve()

    else:
        
        unittest.main()

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
p = [0] + list(map(lambda x: int (x) + 1, input().split()))
cum = list(accumulate(p))
res = 0
for i in range(len(p)-k):
    res = max(res, cum[i+k] - cum[i])
print(res / 2)

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

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

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

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

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

print((k+ans)/2)

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

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

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

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

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

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

Solution (Python):
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *P = map(int, read().split())

    csum = [0]
    csum.extend(accumulate(P))

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

    print((K + ans) / 2)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *P = map(int, read().split())

    csum = [0] * (N + 1)
    for i, p in enumerate(P):
        csum[i + 1] = csum[i] + p

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

    print((K + ans) / 2)
    return


if __name__ == '__main__':
    main()

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

Solution (Python):






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





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

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


N, K = map(int, input().split())
p = list(map(int, input().split()))
prev = ev(p[0])
ans = sum([ev(i) for i in p[:K]])
total = ans

for i in range(1, N-K+1):
    total -= prev
    total += ev(p[i+K-1])
    prev = ev(p[i])
    ans = max(ans, total)

print(ans)

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


cum_sum_list = [0]*(N+1)
cum_sum = 0
pListLen = len(pList)
for i in range(pListLen):
  cum_sum += pList[i]
  cum_sum_list[i+1] = cum_sum

max_sumK = 0
max_start = 0
max_end = 0
for i in range(N-K+1):
  start = i
  end = (i+K)
  sumK = cum_sum_list[end] - cum_sum_list[start]
  if (sumK > max_sumK):
    max_sumK = sumK
    max_start = start
    max_end = end

answer = 0
for num in pList[max_start:max_end]:
  answer += sum(list(range(1, (num+1))))/num
print(answer)

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

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

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

ans = [0] * n

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

print(max(ans))

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

def kitai(n):
  result = 0
  for i in range(1,n+1):
    result += i
  return result/n

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

resi = 0
tmp = 0
for i in range(n-k+1):
  if s[i+k]-s[i] > tmp:
    resi = i
    tmp = s[i+k]-s[i]

result = 0
for i in range(resi,k+resi):
  result += kitai(p[i])
print(result)

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
q=[0]*(n-k+1)
q[0]=sum(p[0:k])
for i in range(1,n-k+1):
    q[i]=q[i-1]-p[i-1]+p[k+i-1]
print(max(q))

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
m=0

for i in range(n):
    b[i]=(a[i]+1)/2

c=sum(b[:k])
m=c
for i in range(n-k):
    c-=b[i]
    c+=b[k+i]
    m=max(m,c)
print(m)

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

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

e = sum(le[:k])
m = e
for i in range(n - k):
    e -= le[i]
    e += le[k + i]
    m = max(m, e)

print(m)

Solution (Python):
from itertools import accumulate
N, K = map(int, input().split())
P = [0]+list(map(int, input().split()))
Psum = list(accumulate(P))
total = 0
for i in range(K, N+1):
    if Psum[i]-Psum[i-K] > total:
        total = Psum[i]-Psum[i-K]
        index = i
ans = 0
for i in range(index, index-K, -1):
    ans += (P[i]+1)*0.5

print(ans)

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

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

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
best=0
for i in range(K):
  best+=(p[i]+1)/2

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

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

ans = 0
P_sum = 0

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

for j in range(K):
  P_sum += P[j]

ans = P_sum
for t in range(K, N):
  P_sum -= P[t - K]
  P_sum += P[t]
  ans = max(ans, P_sum)

print(ans)

Solution (Python):
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re

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

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

    max = sum(P[:K])
    add = max
    for i in range(len(P)-K):
        add = add + P[i+K] - P[i]
        if add > max:
            max = add
    print(max)


main_sum()

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

m = prev = sum(P[:k])
s = 0
for i in range(1, n - k + 1):
    tmp = prev - P[i - 1]+ P[i + k - 1]
    prev = tmp
    if tmp > m:
        s = i
    m = max(tmp, m)

ans = 0
d = dict()
for i in range(s, s + k):
    p = P[i]
    if p not in d.keys():
        tmp = sum(range(p + 1)) / p
        ans += tmp
        d[p] = tmp
    else:
        ans += d[p]
print(ans)

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

Solution (Python):
from statistics import median

N, K = [int(x) for x in input().split()]
line_in_dice = list([(int(x) + 1) / 2 for x in input().split()])

result = [0] * (N + K)

result[0] = line_in_dice[0]
result[K] -= line_in_dice[0]

max_point = 0
max_value = 0

for i in range(1, N):
    result[i] += (result[i - 1] + line_in_dice[i])
    result[i + K] -= line_in_dice[i]

print(max(result))

Solution (Python):
from statistics import median
from time import time

t = time()

N, K = [int(x) for x in input().split()]
line_in_dice = list([int(x) for x in input().split()])

result = [0] * (N + K)

result[0] = line_in_dice[0]
result[K] -= line_in_dice[0]

max_point = 0
max_value = 0

for i in range(1, N):
    result[i] += (result[i - 1] + line_in_dice[i])
    result[i + K] -= line_in_dice[i]

    if result[i] > max_value:
        max_point = i
        max_value = result[i]


def create_median(x):
    if x % 2 == 1:
        return (1 + x) // 2
    else:
        return ((x // 2) + (x // 2 + 1)) / 2


print(sum(create_median(x)
          for x in line_in_dice[max_point - K + 1: max_point+1]))

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

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

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

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


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


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



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

print(ans)

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

print("{:.10f}".format(tmp))

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

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

temp = sum(p[:K])
ind = 0
ma = 0

for i in range(N - K):
    temp = temp - p[i] + p[i + K]
    if temp > ma:
        ind = i + 1
        ma = temp

def calc_e(N):
    ans = 0
    for j in range(1, N + 1):
        ans += j / N
    return ans

ans = 0
for i in range(K):
    ans += calc_e(p[ind + i])
print(ans)

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

ex_p = [(pi+1)/2 for pi in pN]
cum_p = [ex_p[0]]
for i in range(1,N):
    cum_p.append(cum_p[i-1]+ex_p[i])

max_ex = cum_p[K-1]
for i in range(1,N-K+1):
    if max_ex < cum_p[K+i-1] - cum_p[i-1]:
        max_ex = cum_p[K+i-1] - cum_p[i-1]

print(max_ex)

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


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

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

a = list(map(int,input().split()))
sum_a = [0]

for i in range(K):
    sum_a[0] += a[i]

j = 0

max_v = sum_a[0]
ele = K-1
expected_value = 0

for i in range(K,N):
    sum_a.append(sum_a[j]+(a[i]-a[i-K]))
    if max_v < sum_a[j+1]:
        max_v = sum_a[j+1]
        ele = i
    j += 1
s_ele = ele+1-K
for n in range(s_ele,ele+1):
    expected_value += (a[n]*0.5)+0.5
print(expected_value)

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

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

def expectation(N):
    
    
    
    
    return N/2+0.5

Ps = []
s = 0
for p in P:
    s += p
    Ps.append(s)
    
cmax = Ps[K-1]
max_sp = 0

for ix in range(1, N-K+1):
    csum = Ps[ix+K-1] - Ps[ix-1]
    if cmax < csum:
        max_sp = ix
        cmax = csum

ans = 0
for ix in range(max_sp, max_sp+K):
    ans += expectation(P[ix])

print(ans)

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

Solution (Python):

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

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

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

Solution (Python):
from itertools import accumulate

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

Es = [(P+1)/2 for P in Ps]
accEs = list(accumulate([0]+Es))

ans = 0.0
for i in range(N-K+1):
    e = accEs[i+K] - accEs[i]
    if e > ans:
        ans = e

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, K = inm()
P = inl()


def solve():
    ex = 0.0
    for i in range(K):
        ex += (P[i] + 1) / 2
    mex = ex
    for i in range(K, N):
        j = i - K
        ex += (P[i] + 1) / 2
        ex -= (P[j] + 1) / 2
        if mex < ex:
            mex = ex
    return mex


print(solve())

Solution (Python):
N , K = map(int, input().split())
p = list(map(int, input().split()))
Etop = 0
E = 0
q = []
Ruiseki = 0
S = []
Top = 0
for i in p:
    q.append((i+1) / 2)

for E in q:
    Ruiseki += E
    S.append(Ruiseki)

if N == K:
    print(S[N-1])
    quit()
else:
    for j in range(N-K):
        Sig = S[K+j] - S[j]
        if Sig > Top:
            Top = Sig

print(Top)

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

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

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

ans=(sum(P[:K])+K)/2
now=ans
i=K
while i<N:
    now=now+(P[i]+1)/2-(P[i-K]+1)/2
    ans=max(now,ans)
    i+=1

print(ans)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

s = sum(p[:k])
best = (s, 0)
for i in range(1,n-k+1):
    s = s - p[i-1] + p[i+k-1]
    if s>best[0]:
        best = (s, i)
        
ans = sum((p[i]+1)/2 for i in range(best[1], best[1]+k))
print(ans)

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

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

s = [0]*(n+1)

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

res = 0

for i in range(n-k+1):
    res = max(res, s[i+k] - s[i])
    
print("{:.10f}".format(res))

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

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

ans = max(cand)
print((ans+k)/2)

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

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

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

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

Solution (Python):
inf = int(1e9+7)
mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    n, k = [int(x) for x in raw_input().split()]
    
    arr = [(1 + float(x)) / 2 for x in raw_input().split()]
    
    if k == 1:
        print(max(arr))
        return
    
    
    """
    total = sum(probs)
    
    arr = [0] * n
    
    for i in range(n):
        arr[i] = float(i) * (probs[i] / total)
    
    print(arr)
    """
    
    pref_sum = [0] * n
    
    pref_sum[0] = arr[0]
    
    for i in range(1, n):
        pref_sum[i] = pref_sum[i-1] + arr[i]
    
    
    
    max_sub = -inf
    
    for end in range(k-1, n):
        start = end - k + 1
        
        cur = pref_sum[end] 
        if start > 0:
            cur -= pref_sum[start-1]
        if cur > max_sub:
            max_sub = cur
        
    
    
    print(max_sub)

main()

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

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


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

mx = 0
mx_i = -1
for i in range(n-k+1):
  st = c[i+k] - c[i]
  if st > mx:
    mx = st
    mx_i = i
ans = 0
for i in range(mx_i, mx_i+k):
  a = p[i]
  ans += ((a * (a+1)) // 2) / a
print(ans)