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

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

p_ruikei = [0] * n
p_ruikei[0] =  p_mean[0]

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

maxx = p_ruikei[k-1]
for i in range(1, n-k+1):
    mean = p_ruikei[i+k-1] - p_ruikei[i-1]

    if mean > maxx:
        maxx = mean

print(maxx)

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

pi = [0 for _ in range(n)]
si = [0 for _ in range(n)]

pi = [int(s) for s in input().split()]
pi = [(1+s)/2 for s in pi]

si[0] = pi[0]
for i in range(1,n):
    si[i] = si[i-1] + pi[i]





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

print(float(ans))

Solution (Python):
n, k = map(int, input().split())
p_list = list(map(lambda x: (1 + int(x)) / 2, input().split()))
csum_list = [0]
sum = 0
for p in p_list:
    sum += p
    csum_list.append(sum)
now_max = 0
for i in range(n - k + 1):
    tmp = csum_list[i + k] - csum_list[i]
    if tmp > now_max:
        now_max = tmp
print(now_max)

Solution (Python):

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

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

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

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

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

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

print(ans)

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

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

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

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

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

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

    print(ans)

if __name__ == "__main__":
    main()

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

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




E_list = []
for dice in dices:
    E_list.append((1 + dice) * 0.5)

S_list = []  
for i in range(len(dices)):
    
    S_list.append(E_list[0] if i == 0 else S_list[i - 1] + E_list[i])

print(max(list(S_list[j + K] - S_list[j] for j in range(len(dices) - K))) if len(dices) != K else S_list[-1])

Solution (Python):
N,K = map(int,input().split())
dice_list = [int(i) for i in input().split()]
wa_list = [0]
for dice in dice_list :
    
    
    
    prob = (1+dice) / 2
    wa_list.append(wa_list[-1] + prob)

max_p = -1
for i in range(N-K+1) :
    p = wa_list[i+K] - wa_list[i]
    if (max_p < p) :
        max_p = p

print(max_p)

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

left = 0
right = k - 1
maxi = sum(P[left: right + 1])
now = maxi
for i in range(n - k):
    if now - P[i] + P[i + k] > maxi:
        left = i + 1
        right = i + k
        maxi = now - P[i] + P[i + k]
    now = now - P[i] + P[i + k]

kitai = []
for i in range(1001):
    if i == 0:
        kitai.append(0)
    else:
        kitai.append((1 + i)/ 2)

ans = 0
for p in P[left: right + 1]:
    ans += kitai[p]
print(ans)

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

def sm(lst, j, k):
  return lst[j+k]-lst[j]

def max(lst, k):
  sumlst = [0]
  for i in range(len(lst)):
    sumlst.append(sumlst[i]+lst[i])
  res = 0
  for i in range(N-k+1):
    if res < sm(sumlst, i, k):
      res = sm(sumlst, i, k)
  res = (res+k)/2
  return res

print(max(List, K))

Solution (Python):
N, K = map(int, input().split())
P = [int(x) for x in input().split()]
B = [0] * (N+1)
for i in range(1, N+1):
    B[i] = P[i-1] + B[i-1]
ans = 0
for i in range(K, N+1):
    ans = max(ans, B[i] - B[i-K])

print((ans+K)/2)

Solution (Python):
if __name__ == '__main__':
    import sys
    
    i = list(map(int, input().split()))
    N = i[0]
    K = i[1]
    
    p = list(map(int, sys.stdin.readline().split()))
    max_s = 0
    s_current = 0
    
    for i in range(N - K + 1):
        if i == 0:
            p_list = p[:K]
            max_s = sum(p_list)
            s_current = max_s
        else:
            s_current = s_current - p[i - 1] + p[i + K - 1]
            if s_current > max_s:
                max_s = s_current
        
    ans = (max_s + K) / 2.0
    print(ans)

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

e_max = 0
e_prev = 0

for i in range(n - k + 1):
    e = 0
    if i == 0:
        for j in range(k):
            e += p[i + j]
    else:
        e = e_prev - p[i-1] + p[i+k-1]
    if e > e_max:
        e_max = e
    e_prev = e

r = e_max/2 + (0.5 * k)
print(str(r))

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

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

e=[0]*n

for i in range(n):
  e[i]=(1+p[i])/2
  if i!=0:
    e[i]+=e[i-1]

arr=[]

if n==k:
  print(e[-1])
  exit()

for i in range(k,n):
  s=i-k
  arr.append(e[i]-e[s])

print(max(arr))

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

for i in range(k):
    e[0] += float(1/2 * (1 + p[i]))
for j in range(n-k):
    e[j+1] = e[j] + float(1/2 * (p[j+k]-p[j]))
print(max(e))

Solution (Python):

n,k=map(int,input().split())
p=list(map(int,input().split()))
wa=[0]*(n+1)

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

ans=0
for i in range(n-k+1):
    kitai=k+wa[i+k]-wa[i]
    if kitai>ans:
        ans=kitai
ans/=2
print(ans)

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])
ans = t
for i in range(N - K):
    t -= m[i]
    t += m[i + K]
    if t > ans:
        ans = t
print(ans)

Solution (Python):




n,k = map(lambda x: int(x), input().split())
p_lst = list(map(lambda x: int(x), input().split()))


def cum_sum(list):
    result = []
    for i in range(len(list)):
        if i == 0:
            result.append(list[i])
        else:
            result.append(result[i-1] + list[i])
    return result


def cum_sum_exp(list):
    result = []
    for i in range(len(list)):
        if i == 0:
            result.append((list[i]+1)/2)
        else:
            result.append(result[i-1] + (list[i]+1)/2)
    return result



cum_sum_main = cum_sum_exp(p_lst)


cmp = cum_sum_main[k-1]


for i in range(k-1,n):
    if i == k-1:
        cmp = cum_sum_main[i]
    else:
        tmp = cum_sum_main[i] - cum_sum_main[i-k]

        if cmp < tmp:
            cmp = tmp



print(cmp)

Solution (Python):
from itertools import accumulate

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

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

sum=0
temp=0
for i in range(0,K):
  temp+=pp[i]
sum=temp
for i in range(0,N-K):
  temp=temp-pp[i]+pp[i+K]
  sum=max(sum,temp)
print(sum)

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

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

    cumsum = []
    c = 0
    for num in ev:
        c += num
        cumsum.append(c)
    cumsum.append(0)  
    
    ans = 0
    for i in range(n):
        if i + k - 1 > n - 1:
            break
        nominee = cumsum[i+k-1] - cumsum[i-1]
        if nominee > ans:
            ans = nominee

    print(ans)

main()

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

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

    cumsum = []
    c = 0
    for num in ev:
        c += num
        cumsum.append(c)
    cumsum.append(0)  
    
    ans = 0
    for i in range(n):
        if i + k - 1 > n - 1:
            break
        nominee = cumsum[i+k-1] - cumsum[i-1]
        if nominee > ans:
            ans = nominee

    print(ans)

main()

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

Solution (Python):

from itertools import accumulate
N, K = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x:(x+1)/2, p))
P = list(accumulate([0]+p))
ans = 0
for i in range(N-K+1):
    if P[i+K]-P[i]>= ans:
        ans = P[i+K]-P[i]
print(ans)

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

print(ans)

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

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

ans=s

for i in range(n-k):

    s += (p[i+k]-p[i])/2

    if s>ans:
        ans=s
print(ans)

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

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


w = 0

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

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

Solution (Python):
if __name__ == '__main__':
    n, k = list(map(int, input().split(" ")))
    p = list(map(int, input().split(" ")))

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

    

    max_sum = 0
    rangeN = n - k + 1

    for i in range(rangeN):
        sum_d = d[i + k] - d[i]
        if max_sum < sum_d:
            max_sum = sum_d
    

    
    print((max_sum + k) / 2)

Solution (Python):
from collections import deque

if __name__ == '__main__':
    n, k = list(map(int, input().split(" ")))
    p = list(map(int, input().split(" ")))

    d = deque([0])
    for i in range(n):
        d.append(d[i] + p[i])

    

    max_sum = 0
    rangeN = n - k + 1

    for i in range(rangeN):
        sum_d = d[i + k] - d[i]
        if max_sum < sum_d:
            max_sum = sum_d
    

    
    print((max_sum + k) / 2)

Solution (Python):
from collections import deque

if __name__ == '__main__':
    n, k = list(map(int, input().split(" ")))
    p = list(map(int, input().split(" ")))

    d = deque([0])
    for i in range(n):
        d.append(d[i] + p[i])

    

    max_sum = 0
    rangeN = n - k + 1

    for i in range(rangeN):
        sum_d = d[i + k] - d[i]
        if max_sum < sum_d:
            max_sum = sum_d
    

    
    print((max_sum / 2) + (k * 0.5))

Solution (Python):
from collections import deque

if __name__ == '__main__':
    n, k = list(map(int, input().split(" ")))
    p = list(map(int, input().split(" ")))

    d = deque([0])
    for i in range(n):
        d.append(d[i] + p[i])

    

    max_sum = 0
    rangeN = n - k + 1

    for i in range(rangeN):
        max_sum = max(max_sum, d[i + k] - d[i])
    

    
    print((max_sum / 2) + (k * 0.5))

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

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

Solution (Python):
n,k = map(int,input().split())
L = list(map(int,input().split()))
LL = []
for i in range(n):
    kitai = L[i]*(L[i]+1)//2/L[i]
    LL.append(kitai)

k_sum = sum(LL[:k])
num = []
num.append(k_sum)
for i in range(1,n-k+1):
    k_sum += (LL[k+i-1] - LL[i-1])
    
    num.append(k_sum)
print(max(num))

Solution (Python):
def resolve():
    import sys
    input = sys.stdin.readline
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    p1 = list(map(lambda x: (x+1)/2, p))
    ans = 0
    if k==1:
        print(max(p1))
        exit()
    else:
        initial = sum(p1[0:k])
        if ans <= initial:
            ans = initial
            cal = initial
        for i in range(n-k):
            cal = cal-p1[i]+p1[i+k]
            if ans <= cal:
                ans = cal
    print(ans)
resolve()

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]
for i in range(n):
    b.append(b[-1]+a[i])
max=0
for j in range(k,len(b)):
    if max<b[j]-b[j-k]:
        max=b[j]-b[j-k]
print((max+k)/2)

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


def calc(value):
    return value * (value + 1) / (2 * value)


max_value = 0
for i in range(k):
    max_value += calc(p[i])

cur = max_value
for l in range(k, n):
    cur += (calc(p[l]) - calc(p[l-k]))
    max_value = max(max_value, cur)
print(max_value)

Solution (Python):
import numpy as np

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




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

cum_exp = np.cumsum(exp)

max = cum_exp[K-1]
for i in list(range(K, N)):
    val = cum_exp[i] - cum_exp[i - K]
    if val > max:
        max = val

print(max)

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

for key, v in enumerate(p):
    t = (v+1)*v//2/v
    s.append(s[key] + t)

ans = -1

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

print(ans)

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

Solution (Python):
import numpy

n,k = map(int,input().split())
li = [(int(x)*(int(x)+1))/(2*int(x)) for x in input().split()]
a = numpy.cumsum(li)
ans = 0
for i in range(n-k+1):
    if i == 0:
        ans = a[i+k-1]
    else:
        if ans < (a[i+k-1] - a[i-1]):
            ans = a[i+k-1] - a[i-1]
print(ans)

Solution (Python):
def main():
    n,k = map(int,input().split())
    plist = list(map(int,input().split()))
    summax = sum(plist[:k])
    temp = summax
    for i in range(1,n-k+1):
        temp = temp + plist[i+k-1] - plist[i-1]
        if temp > summax:
            summax = temp
    print((summax+k)/2)
if __name__ == '__main__':
    main()

Solution (Python):
import math
import copy
from copy import deepcopy
import sys
import fractions

from functools import reduce

import heapq
import collections
import itertools
sys.setrecursionlimit(100001)






def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList




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

data = []
input_data = input().split()
data = [int(n) for n in input_data]

data_exp = [0]
for i in range(n):
    data_exp.append(data_exp[i] + 1 + (data[i]-1)/2)

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

print(ans)

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

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

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

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

iter_num = n - k + 1

num = sum(p[0:k])
ans = [(num+k)/2]
for i in range(iter_num-1):
	num = num - p[i] + p[k+i]
	ans.append((num+k)/2)

print(max(ans))

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

summax=sum(plist[:k])


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

print((summax+k)/2)

Solution (Python):
def main():
    n , k = map(int, input().split())
    p = list(map(int, input().split()))
    size = max(p)
    sheet = [0]*size
    for i in range(size):
        if (i == 0):
            sheet[i]=1
        else:
            sheet[i] = (sheet[i-1]*i + (i+1))/(i+1)
    ans = 0
    total = 0
    for i in range(n-k+1):
        if (i == 0):
            for j in range(k):
                total += sheet[p[i+j]-1]
            if (total > ans):
                ans = total
        else:
            total -= sheet[p[i-1]-1]
            total += sheet[p[i+k-1]-1]
            if (total > ans):
                ans = total
    print (ans)
main()

Solution (Python):
a,b = map(int, input().split())
max = 0
arr = list(map(int, input().split()))
cumsum = [0] * (a + 1)
for i in range(a):
  cumsum[i+1] = cumsum[i] + arr[i]
for i in range(a - b + 1):
  sum = 0
  sum = cumsum[i + b] - cumsum[i]
  if sum > max:
    max = sum
print((max + b) / 2)

Solution (Python):

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


expl=[0.0]
ansl=[]
cum=0
for i in range(n):
    cum+=(1+pl[i])/2
    expl.append(cum)

for i in range(n-k+1):
    ansl.append(expl[i+k]-expl[i])

print('{:.9f}'.format(max(ansl)))

Solution (Python):
N, K = map(int,input().split())
p = list(map(int,input().split()))
S = [0]
a = 0
sum1 = 0
sumMax = 0
for i in range(N):
    a += p[i]
    S.append(a)
for i in range(N-K+1):
    sum1 = S[i+K] - S[i]
    if(sumMax < sum1):
        sumMax = sum1
result = 0.5*K + 0.5*(sumMax)
print(result)

Solution (Python):
from sys import stdin

n, k = (int(x) for x in stdin.readline().rstrip().split())
p = [int(x) for x in stdin.readline().rstrip().split()]
ev = [(i+1)/2 for i in p]
s = [ev[0]]
for i in range(1, n):
    s.append(s[i-1] + ev[i])

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

print(m)

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

print(max(p))

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

ruisekiwa =[0]
for x in P:
    ruisekiwa.append(ruisekiwa[-1]+x)
maxN =0
maxArg =[0]*2
maxArg[0] = 0
maxArg[1] = 0+K
for x in range(N-(K-1)):
    cal = ruisekiwa[x+K]-ruisekiwa[x]
    if maxN <cal:
        maxN = cal
        maxArg[0]=x
        maxArg[1]=x+K
kitai = 0
p = maxArg[1]-maxArg[0]
for y in range(maxArg[0],maxArg[1]):
    kitai +=  (P[y]+1)/2
    
    
print(kitai)

Solution (Python):
expected_value_dic = {}

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

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

P = list(map(int, input().split()))
expected_values = [get_expected_value(p) for p in P]
cumulative_values = [expected_values[0]]
for expected_value in expected_values[1:]:
    cumulative_values.append(cumulative_values[-1] + expected_value)

result = cumulative_values[k-1]
for i in range(k, n):
    temp = cumulative_values[i] - cumulative_values[i - k]
    if temp > result:
        result = temp

print(result)

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

for j in range(N-K+1):
    if Q[j+K]-Q[j]>Kmax:
        Kmax=Q[j+K]-Q[j]
print((Kmax+K)/2)

Solution (Python):
n,k = (int(x) for x in input().split())
list = [int(i) for i in input().split()]
sumlist = []
sum = 0;ans = 0
for l in range(n):
    list[l] = (1+list[l])/2

for i in range(n):
    sum += list[i]
    sumlist.append(sum)

if k!=n:
    for j in range(n-k):
        ans = max(ans,sumlist[j+k]-sumlist[j])
    print(ans)
else:
    print(sum)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
e=[]
for pp in p:
    ex=(pp+1)/2
    e.append(ex)
ans=0
for i in range(n-k+1):
    if i==0:
        t=sum(e[:k])
        ans+=t
        continue
    t-=e[i-1]
    t+=e[i+k-1]
    ans=max(ans,t)

print(ans)

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

st = 0
i = 0
sa = 0
while i+K < N:
    sa += p[i+K]-p[i]
    if sa > 0:
        st = i+1
        sa = 0
    i += 1

psum = p[st:st+K]
for i in range(K):
    psum[i] = (psum[i]+1)/2
print(sum(psum))

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

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

Solution (Python):
def main():
    n, k = map(int,input().split())
    li = list(map(int,input().split()))
    pi_list = [(i + 1) / 2 for i in li]
    spot = 0
    for i in range(k):
        spot += pi_list[i]
    ans_li = []
    ans_li.append(spot) 
    for i in range(n-k):
        spot -= pi_list[i]
        spot += pi_list[i+k]
        ans_li.append(spot)
    print(max(ans_li))

if __name__ == '__main__':
    main()

Solution (Python):
N,K = map(int,input().split())
p = list(map(int,input().split()))
summ = sum(p[i] for i in range(K))
sum_list = [summ]
maximum = 0

for i in range(N - K):
    summ += p[i + K] - p[i]
    sum_list.append(summ)

maximum = max(sum_list)

print("{}".format((maximum + K) / 2))

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

print('{:.8f}'.format(max))

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

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

Solution (Python):
import numpy as np

n, k = (int(x) for x in input().split())
p = np.array(list(int(x) for x in input().split()))

p = (p + 1) / 2

sump = []
e = []
s = 0

for i in range(len(p)):
    s += p[i]
    sump.append(s)

sump.insert(0, 0)
sump = np.array(sump)

for i in range(n - k + 1):
    e.append(sump[i + k] - sump[i])


print(max(e))

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

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

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

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

for i in range(n-k+1):
    if i == 0:
        res = sum(pKList[i:i+k])
    else:
        res = res - pKList[i-1] + pKList[i+k-1]
    pListMax = max(pListMax, res)
print(pListMax)

Solution (Python):
n,k=map(int,input().split())
P=list(map(int,input().split()))
for i in range(n):
    P[i]=0.5*(P[i]+1)
x=sum(P[:k])
s=[x]

for i in range(1,n-k+1):
    x=x-P[i-1]+P[i+k-1]
    s.append(x)

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):
nk = [int(s) for s in input().split()]
n = nk[0]
k = nk[1]

p = [int(s)+1 for s in input().split()]
l = [sum(p[:k])]

for x in range(n-k):
  l.append(l[x]-p[x]+p[x+k])
print(max(l)/2)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
q=[(1+pp)/2 for pp in p]
ans=0
c=[0]
for qq in q:
      c.append(c[-1]+qq)
ans=0

for qq in range(k,1+n):
  ans=max(ans,c[qq]-c[qq-k])

print(ans)

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

sum_max = 0
for i in range(k - 1, n):
    if i == k - 1:
        sum_now = sum(ps[:i + 1])
    else:
        sum_now = sum_now + ps[i] - ps[i - k]
    sum_max = max(sum_max, sum_now)
    
print(float(sum_max + k) / 2)

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
smax=0
for i in range(k-1,n):
    if i==k-1:
        sumnow=sum(a[:i+1])
    else:
        sumnow+=a[i]-a[i-k]
    smax=max(smax,sumnow)
print((smax+k)/2)

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



sum_max = 0
for i in range(k - 1, n):
    if i == k - 1:
        sum_now = sum(ps[:i + 1])
    else:
        sum_now = sum_now + ps[i] - ps[i - k]
    sum_max = max(sum_max, sum_now)

print((sum_max + k) / 2)

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

p_sum = 0
ans = 0
for i in range(n):
    p_sum += p[i]
    if i >= k:
        p_sum -= p[i - k]

    ans = max(p_sum, ans)

ans = (ans + k) / 2

print(ans)

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

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

max_kitai = 0
res = 0
for i in range(N - K + 1):
    if i == 0: 
        res = sum(P_kitai[i:i+K])
    else:
        res = res - P_kitai[i-1] + P_kitai[i+K-1]
    max_kitai = max(max_kitai, res)
print(max_kitai)

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

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

temp = 0
S = [0]

for i in range(N):
    S.append(S[-1] + kitai(p[i]))
    
    
temp = 0

for i in range(N-K+1):      
    add = S[i+K] - S[i]
    if add > temp:
        temp = add
    
print(temp)

Solution (Python):
def dice_in_line(k, p_list):
    max_line = [0 for i in range(k+1)]
    max_sum = 0
    sum_list = [0]
    for i in range(len(p_list)):
        sum_list.append(p_list[i]+sum_list[i])
    for i in range(len(p_list)-k+1):
        if max_sum < sum_list[i+k]-sum_list[i]:
            max_sum = sum_list[i+k]-sum_list[i]
        
    return (max_sum+k)/2.0

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

print(float(dice_in_line(k, p_list)))

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

V = []
for i, p in enumerate(P):
    V.append((p + 1) / 2)

psum = sum(V[:K])
ans = psum
for i in range(K, len(V)):
    psum -= V[i - K]
    psum += V[i]
    ans = max(ans, psum)
print(ans)

Solution (Python):

N, K = map(int, input().split())
p= [int(x) for x in input().split()]
ap = p
ans = 0
for i in range(N):
    if i == 0:
        ap[i] = (p[i]+1)/2
    else:
        ap[i] = (p[i]+1)/2 + ap[i-1]
for i in range(N-K+1):
    now = 0
    if i == 0:
        now = ap[K-1]
    else:
        now = ap[K+i-1]-ap[i-1]
    ans = max(ans, now)

print (ans)

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

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

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

sum_list = [0] * N

for i in range(N):
    if i == 0:
        sum_list[i] = p[i]
    else:
        sum_list[i] = sum_list[i-1]+p[i]
res = sum_list[K-1]

for i in range(N):
    if i < K:
        continue
    if sum_list[i] - sum_list[i-K] > res:
        res = sum_list[i] - sum_list[i-K]

print(res)

Solution (Python):
import itertools

n, k = map(int, input().split())
dices = map(int, input().split())
dices_EV = list(map(lambda x:(x+1)/2, dices))
dices_EV_accumulate = list(itertools.accumulate(dices_EV))
dices_EV_sums = [dices_EV_accumulate[i+k] - dices_EV_accumulate[i] for i in range(n-k)]
dices_EV_sums.append(dices_EV_accumulate[k-1])
print(max(dices_EV_sums))

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

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

dp = [0] * (n + 1)

for i in range(n):
    dp[i+1] = dp[i] + (pl[i] + 1)/2

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

print(ans)

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

sums = 0
for i in range(k):
    sums += p[i]
maxi = sums
for i in range(k, n):
    sums += p[i]
    sums -= p[i-k]
    if sums > maxi:
        maxi = sums
print((maxi+k)/2)

Solution (Python):
s, t  = map(int, input().split())
u = list(map(int,input().split()))
ln = []
for i in u:
    ln.append((1 + i)/2)

from itertools import accumulate

B = [0] + ln

B = list(accumulate(B)) 
answer = []

for i in range(s-(t-1)):
    answer.append(B[i+t]-B[i])

print(max(answer))