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 sin(): return input()
def ssin(): return input().split()
def nin(): return int(input())
def lin(): return list(map(int, ssin()))

N, K = lin()
p = [n*(n+1)/2/n for n in lin()]    

t = sum(p[:K])    
ans = t
l, r = 0, K-1

for i in range(N-K):
    t = t - p[l] + p[r+1]
    r += 1; l += 1
    ans = max(ans, t)
    
print(ans)

Solution (Python):
N, K = map(int,input().split())
p = [0] + [int(x) for x in input().split()]
p = [(x+1)/2 for x in p]
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)

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

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

Solution (Python):
n, k = [int(i) for i in input().split(' ')]
input_list = [int(i) for i in input().split(' ')]
 
maximum = sum(input_list[:k])
s = sum(input_list[:k])
for i in range(1, n-k+1):
  s = s - input_list[i-1] + input_list[i+k-1]
  maximum = max(maximum, s)

print( (maximum + k) / 2 )

Solution (Python):
N,K = list(map(int,input().split(' ')))
pi = list(map(int,input().split(' ')))
value = sum(pi[:K])
max_value = value
for i in range(N-K):
  value -= pi[i]
  value += pi[i+K]
  max_value = max(value, max_value)
print((max_value+K)/2)

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))
sum = 0
li = []
for i in range(N):
    A[i] = A[i] / 2 + 0.5

for i in range(K):
    sum += A[i]
li.append(sum)
for i in range(N - K):
    sum -= A[i]
    sum += A[i+K]
    li.append(sum)


print(max(li))

Solution (Python):
import numpy as	np
N,K=map(int,input().replace('\n','').split())
P=list(map(int,input().replace('\n','').split()))

s=np.sum(P[0:K])
m=s
for i in range(1,N-K+1):
  s=s-P[i-1]+P[i+K-1]
  if s>=m:
    m=s
	
print((m+K)/2)

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

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


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


ex_list = []
for i in range(N):
    ex_list += [expected_value(P[i])]

sum_list = []
for i in range(N+1-K):
    if i == 0:
        sum_list += [sum(ex_list[i:i+K])]
    if i >= 1:
        sum_list += [sum_list[i-1] + ex_list[i+K-1] - ex_list[i-1]]

print(max(sum_list))

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

MX = 0
ttl = 0

for i in range(K):
    ttl += p[i]

mm = ttl

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

print((ttl+K)/2)

Solution (Python):
n, k = map(int, input().split())
List = list(map(int, input().split()))
score = []
score1 = []

def cal_score(num):
    return 1 + 0.5 * (num - 1)

score.append(cal_score(List[0]))

for i in range(1, n):
    score.append(score[i - 1] + cal_score(List[i]))
    
score1.append(score[k - 1])
m = 0
for i in range(k, n):
    score1.append(score[i] - score[m])
    m += 1



print(max(score1))

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
pE=list(map(lambda i :(1+i)/2,p))
pA=[sum(pE[0:K])]
inter=sum(pE[0:K])
for i in range(0,N-K):
    inter=inter+pE[K+i]-pE[i]
    pA.append(inter)

ans=max(pA)
print(ans)

Solution (Python):
N, K = map(int, input().split())
P = [int(p) for p in input().split()]
tmp = sum(P[: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):
q1=list(map(int,input().split(" ")))
a1=list(map(int,input().split(" ")))


sum1=sum(a1[:q1[1]])
sumsum=sum1
for i in range(q1[0]-q1[1]):
    sum1=sum1+a1[i+q1[1]]-a1[i]
    if(sumsum<sum1):
        sumsum=sum1
sumsum+=q1[1]
print(sumsum/2)

Solution (Python):
from sys import stdin

def main():

    input = stdin.readline

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

    
    S = [0]
    for p in p_list:
        S.append(S[-1] + p)
        

    

    maxs = 0
    for i in range(N-K+1):
        p_num = S[i+K] - S[i]
        if(maxs < p_num):
            maxs = p_num
    
    print(maxs)

if __name__ == "__main__":
    main()

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

ans = tmp = sum(L[:K])

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

print(ans)

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

number = sum(p[0:y])
bigNumber = number

for i in range(x-y):

    number = number - p[i] + p[i+y]

    if number > bigNumber:
        bigNumber = number

print((bigNumber + y) / 2)

Solution (Python):
n,k=(int(x) for x in input().split())
lst=[int(x) for x in input().split()]
sum_lst=[sum(lst[0:k])]
for i in range(n-k):
  next_element=sum_lst[-1]-lst[i]+lst[i+k]
  sum_lst.append(next_element)
print((max(sum_lst)+k)/2.0)

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

    number = sum(p[0:y])
    bigNumber = number

    for i in range(x-y):

        number = number - p[i] + p[i+y]

        if number > bigNumber:
            bigNumber = number

    print((bigNumber + y) / 2)

main()

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

    number = sum(p[0:y])
    bigNumber = number

    for i in range(x-y):

        number = number - p[i] + p[i+y]

        if number > bigNumber:
            bigNumber = number

    print((bigNumber + y) / 2)

main()

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

li_kitai = list()
d_kitai_memo = dict()
for l in li_p:
    if l not in d_kitai_memo:
        val = sum(range(1, l + 1)) / l
        d_kitai_memo[l] = val
        li_kitai.append(val)
    else:
        li_kitai.append(d_kitai_memo[l])

answer = 0
memo = 0
for idx, v in enumerate(li_kitai[:len(li_kitai) - k + 1]):
    if idx == 0:
        memo = sum(li_kitai[idx:idx + k])
    else:
        memo = memo - li_kitai[idx - 1] + li_kitai[idx + (k - 1)]
    answer = max(answer, memo)

print(answer)

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

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

Solution (Python):


def cal_ans(x):
    ans = (x+1)/2
    return ans
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = list(map(cal_ans,p))

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




t_len = len(S)
ans1 = 0
for i in range(t_len - k):
    if ans1 < S[i+k]-S[i]:
        ans1 = S[i+k]-S[i]
print(ans1)

Solution (Python):
n, k = map(int, input().strip().split())
arr = [int(i) for i in input().strip().split()]
maxi = s = (sum(arr[0:k]) + k) / 2
for i in range(1, n - k + 1):
  s += (arr[i + k - 1] - arr[i - 1]) / 2
  if s > maxi: maxi = s
print(maxi)

Solution (Python):



def main():
    N, K = map(int, input().split())
    p = [((int(i)+1) * int(i) / 2)/int(i) for i in input().split()]
    result = sum(p[:K])
    prev = result
    for i in range(0, N-K):
        prev = prev - p[i] + p[i+K]
        result = max(result, prev)
    print(result)

if __name__ == "__main__":
    main()

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

def main():
    N,K = map(int,input().split())
    a = list(map(int,input().split()))
    cum = [0]
    for num in a:
        cum.append(cum[-1]+num)
    M = 0
    for i in range(N-K+1):
        M = max(M,cum[i+K]-cum[i])
    
    print((M+K)/2)
    
if __name__ == "__main__":
    main()

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


def cumsum(a):
    r = [0]
    for v in a:
        r.append(r[-1] + v)
    return r

cs = cumsum(p)

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

print(ans)

Solution (Python):
n, k = map(int, input().split())
 
dice = list(map(int, input().split()))
 
a = sum(dice[0: k])
b = sum(dice[0: k])
 
res = 0
ll = 0
s = 0

for i in range(k, len(dice)):
    a += dice[i]
    a -= dice[i - k]
    if a > b:
        b = a
 
res = (b + k) /2.0
 
print(res)

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


if n==k:
    print(sum(p))
else:
    sump = [0]*n
    sump[0]=p[0]
    for i in range(n-1):
        sump[i+1] = sump[i]+p[i+1]
    ans=max(sump[i+k]-sump[i] for i in range(n-k))
    print(ans)

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
p_sum = [0]
max = 0

for i in range(len(p)):
    p_sum.append(p_sum[i] + (p[i]+1)/2) 

for i in range(K,N+1):
    sum = p_sum[i] - p_sum[i-K]
    if(max < sum):
        max = sum














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

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

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

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

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

expectations = [(((1 + i) * i) / 2) / i for i in p] 
i = 0
MAX = e = sum(expectations[i:i + k])
while i + k < n: 
    i += 1
    t = e - expectations[i - 1] + expectations[i + k - 1]
    MAX = max(MAX, t)
    e = t

print(MAX)

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

Solution (Python):
import collections

def get_input_line():
    return list(map(int, input().split()))
n, k = get_input_line()
p_list = get_input_line()

def calc_dice_score(p):
    return 0.5*(p+1)

def calc_score(score_list):
    return sum(score_list)

dice_scores = [0] * n

max_score = 0
tmp_score = 0

for i in range(k):
    dice_scores[i] = 0.5*(p_list[i]+1)
    tmp_score += dice_scores[i]

max_score = tmp_score
for i in range(1, n- k + 1):
    dice_scores[i+k-1] = 0.5*(p_list[i+k-1]+1)
    tmp_score -= dice_scores[i-1]
    tmp_score += dice_scores[i+k-1]
    max_score = max(max_score, tmp_score)
print(max_score)

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
tmp=0
for i in range(k):
  tmp+=p[i]
t=[tmp]
for j in range(1,n-k+1):
  tj=t[j-1]-p[j-1]+p[j+k-1]
  t.append(tj)
t.sort()
print(t[n-k])

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

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

Solution (Python):
from itertools import accumulate
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [0]+[(p+1)/2 for p in P]
S_list = []
S = 0
for i in range(N+1):
    S += P[i]
    S_list.append(S)

B = []
for j in range(N-K+1):
    B.append(S_list[j+K]-S_list[j])
ans = max(B)
print(ans)

Solution (Python):
def calc_e(num):
    return (num + 1) / 2

def main():
    n, k = map(int, input().split())
    dices = list(map(int, input().split()))

    current = (sum(dices[:k]) + k) / 2
    e_max = (sum(dices[:k]) + k) / 2
    for i in range(n-k):
        current = current + calc_e(dices[i+k]) - calc_e(dices[i])
        e_max = max(e_max, current)

    print(e_max)


if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
L = list(map(int, input().split()))
E = [(v+1)/2 for v in L]
tmp = sum(E[:K])
ans = tmp
for l, p in zip(E[K:], E):
    tmp = tmp+l-p
    ans = max(ans, tmp)
print(ans)

Solution (Python):
N,K = map(int,input().split())
p = list(map(int,input().split()))
P = [0]*N
E = [0]*N
ev = [0]*(N+1)
EV = [0]*(N-K+1)

for i in range(N):
    P[i] = (p[i]+1)*p[i]/2
    E[i] = P[i]/p[i]
if N==K:
    print(sum(E))
elif K==1:
    print(max(E))
else:
    for i in range(N):
        ev[i+1] = ev[i]+E[i]
    for i in range(N-K+1):
        EV[i]=ev[i+K]-ev[i]
    print(max(EV))

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    P=LI()
    Q=[(1+p)*p/2/p for p in P]
    now = sum(Q[:K])
    ans = now
    for i in range(N-K):
        now -= Q[i]
        now += Q[i+K]
        ans = max(ans, now)
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
from itertools import accumulate
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [0]+[(p+1)/2 for p in P]
S = list(accumulate(P))
B = []
for j in range(N-K+1):
    B.append(S[j+K]-S[j])
ans = max(B)
print(ans)

Solution (Python):
n, k = map(int, input().split(" "))
dices_e = [float((e+1)/2) for e in list(map(int, input().split(" ")))]
e = max_e = sum(dices_e[:k])
for i in range(1, n-k+1):
  e = e - dices_e[i-1] + dices_e[i+k-1]
  if e>max_e:
    max_e = e

print(max_e)

Solution (Python):
import itertools

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

pa = list(itertools.accumulate([0] + p))

m = 0
for i in range(n-k+1):
  s = pa[i+k] - pa[i]
  if s > m:
    m = s
print((m+k)/2)

Solution (Python):
def expectation(li):
  total = 0
  for i in li:
    total += (i+1)/2
  return total

n,k = map(int,input().split())
p = list(map(int,input().split()))
ex = expectation(p[0:k])
li = [ex]
for i in range(1,n-k+1):
  ex = ex - (p[i-1]+1)/2 + (p[i+k-1]+1)/2
  li.append(ex)
print(max(li))

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

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

Sj = []
Sj.append(0)
S=0
for i in range(N):
    S += pn_ave[i]
    Sj.append(S)

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

Sk.sort()
print(Sk[-1])

Solution (Python):
n, k = [int(x) for x in input().split()]
p = [1/2 + int(x)/2 for x in input().split()]
sum_p =[]
buf = 0
for i in p:
    buf += i
    sum_p.append(buf)
max_t = 0
for i in range(n - k + 1):
    buf = sum_p[i+k-1]
    if i > 0:
        buf -= sum_p[i-1]
    if max_t < buf:
        max_t = buf
print(max_t)

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

tmp = 0
for i in range(k):
    tmp += 0.5 * p[i] + 0.5

ans = tmp
for i in range(1, n-k+1):
    tmp -= 0.5 * p[i-1] + 0.5
    tmp += 0.5 * p[i+k-1] + 0.5
    if ans < tmp:
        ans = tmp

print(ans)

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

Solution (Python):
dp = [0]*1001
dp[1] = 1
for i in range(2,1001):
    dp[i]=dp[i-1]+0.5

n,k = map(int,input().split())
p = list(map(int,input().split()))
s = 0
for i in range(k):
    s += p[i]
ans = 0
for i in range(n):
    if i>k-1:
        tmp = tmp + dp[p[i]] - dp[p[i-k]]
        if tmp>ans:
            ans = tmp
    else:
        ans+=dp[p[i]]
        tmp = ans
print(ans)

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

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

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

print( (K+t)/2 )

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

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

x = 0.0
SUM = [0.0]
for e in E:
    x += e
    SUM += [x]

MAX = 0
for i in range(N-K+1):
    a = SUM[i+K] - SUM[i]
    if a > MAX:
        MAX = a

print(MAX)

Solution (Python):
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('d3.in')


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


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def gen():
  N = 200000
  K = 4000
  p = [6] * N
  print(N, K)
  print(*p)


def main():
    N, K = read_int_list()
    p = read_int_list()
    cp = [0] * (N+1)
    for i in range(N):
      cp[i+1] = cp[i] + (p[i]+1)/2
    
    
    
    res = 0    
    for i in range(N-K+1):
      
      if cp[i+K]-cp[i] > res:
        res = cp[i+K]-cp[i]
    
    print(res)



main()

Solution (Python):
import numpy as np

N, M = list(map(int, input().split()))
num_array = np.cumsum(list(map(lambda x: (x+1)/2, list(map(int, input().split())))))

max_exp = num_array[M-1]
for i in range(len(num_array)-M):
    tmp = num_array[i+M] - num_array[i]
    if max_exp < tmp:
        max_exp = tmp

print(max_exp)

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

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

ans  = sum(values[:K])

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

print(ans)

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

s=sum(p[0:K])
d=0
e=0
for i in range(N-K):
  d+=p[i+K]-p[i]
  if d>e:
    e=d
s+=e
print((s+1*K)/2)

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

Solution (Python):
def main():
    n,k=map(int,input().split())
    pp=list(map(int,input().split()))
    m=s=sum(pp[i] for i in range(k))
    for i in range(k,n):
        s=s-pp[i-k]+pp[i]
        if s>m:
            m=s
    print(0.5*k+0.5*m)

main()

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

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

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

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

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

P = [0 for n in range(N - K + 1)]

P[0] = sum([p[i] for i in range(K)])

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

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

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

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

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


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




S =[0] * N
S[0] = p_exp[0]
for i in range(len(p_exp) - 1):
    S[i + 1] = S[i] + p_exp[i + 1]


S.insert(0, 0)


max =0
exp_sum = 0
for j in range(N - K + 1):
    exp_sum = S[j + K] - S[j]
    if max < exp_sum:
        max = exp_sum


print(max)

Solution (Python):
N,K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
for i in range(N):
    p[i] = (1+p[i])/2
s = sum(p[:K])
max_s = s
for i in range(N-K):
    max_s+=p[K+i]
    max_s-=p[i]
    if max_s>s:
        s = max_s
print(s)

Solution (Python):
N,K = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
p =[]
for i in b:
    p.append((i+1)/2)
s = sum(p[:K])
max_s = s
for i in range(N-K):
    max_s+=p[K+i]
    max_s-=p[i]
    if max_s>s:
        s = max_s
print(s)

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

ans = sum(p[:k])

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

anss = [0] * n
for i in range(n-k):
  anss[i] = psum[i+k] - psum[i]

print((max(ans, max(anss))+k)/2)

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

p = list(map(lambda x: (sum(list(range(x + 1)))) / x, p))
tmp = sum(p[:k])
ans = tmp
for i in range(1, (n - k + 1)):
    tmp = tmp + p[i + k - 1] - p[i - 1]
    ans = max(ans, tmp)
print(ans)

Solution (Python):
n,k = (int(x) for x in input().split())
ln = list(map(float, input().split()))
ln_mean=[1+0.5*(x-1) for x in ln]


if n == k:
  print(sum(ln_mean))
else:
  lnk = [0]*(n-k+1)
  m_in = 0
  for i in range(k):
    m_in += ln_mean[i]
  m_max = m_in
  tmp_max = m_in
  for i in range(n-k):
    tmp_max = tmp_max - ln_mean[i] + ln_mean[i+k]
    if m_max < tmp_max:
      m_max = tmp_max
  print(m_max)

Solution (Python):
from itertools import accumulate


def solve(string):
    n, k, *p = map(int, string.split())
    *p, = accumulate((1 + _p) / 2 for _p in p)
    return str(max(p2 - p1 for p1, p2 in zip(p, p[k:]))) if k < n else str(p[-1])


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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


def modify(x):
    return int(x) + 1


l = list(map(modify, input().split()))

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

print(m/2)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10


def solve():
    n, k = LI()
    p = LI()
    dp = [0] * n
    bf = list(itertools.accumulate([i for i in range(1001)]))
    for i in range(n):
        dp[i] = bf[p[i]] / p[i]
    ans = 0
    bf = 0
    for i in range(k):
        ans += dp[i]
    bf = ans
    for i in range(k, n):
        bf -= dp[i - k]
        bf += dp[i]
        ans = max(ans, bf)
    print(ans)

    return



if __name__ == '__main__':
    solve()

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

exp = [] 
exp.append(0) 
count = 1
max = 0
tmp = 0

for i in range(1,1001):
    exp.append(count/i)
    count = count + (i+1)


for i in range(n[1]):
    tmp = tmp + exp[p[i]]
if(tmp >= max):
    max = tmp


for j in range(n[0]-n[1]):
    
    tmp = tmp + exp[p[j+n[1]]] - exp[p[j]]
    if(tmp >= max):
        max = tmp

print(max)

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
rui = [0]
for tmp in p:
    tmp = (tmp + 1) / 2
    rui.append(tmp + rui[-1])

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

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy


from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])
 
def main():
    n,k = inpm()
    p = inpl()
    for i in range(n):
        p[i] = (1+p[i])/2
    cnt = 0
    for i in range(k):
        cnt += p[i]
    ans = cnt
    for i in range(n-k):
        cnt -= p[i]
        cnt += p[i+k]
        ans = max(ans,cnt)
    print(ans)
    
if __name__ == "__main__":
    main()

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
  
a = sum(p[:k])
s = a

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

Solution (Python):
N,T = input().split(' ')
ps = input().split(' ')
N=(int)(N)
T=(int)(T)

def E_cal(i):
    return (i+1)/2

Es=[]

ruiseki_sum=[0]

for i,p in enumerate(ps):
    Es.append(E_cal((int)(p)))
    ruiseki_sum.append(Es[i]+ruiseki_sum[i])



TEs_max = 0

for j in range(N-T+1):
    now = ruiseki_sum[j+T]-ruiseki_sum[j]
    if now>TEs_max:
        TEs_max=now
    
print(TEs_max)

Solution (Python):

"""
Created on Wed Feb 12 16:38:08 2020

@author: matsui
"""

N,K=map(int,input().split())
p=[int(num) for num in input().split()]

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

M=0
for i in range(N-K+1):
    
    if dp[i+K]-dp[i] > M: M=dp[i+K]-dp[i]
    
print(M)

Solution (Python):
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(a[0]):
  b[i]=(b[i]+1)/2
c=0
for i in range(a[1]):
  c+=b[i]
c=[c]
for i in range(1,a[0]-a[1]+1):
  d=c[i-1]
  d+=b[i+a[1]-1]-b[i-1]
  c.append(d)
print(max(c))

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

max=0
tmp=0
for x in range(0,K):
    max+=p[x]
    tmp+=p[x]
for i in range(K,N):
    tmp=tmp+p[i]-p[i-K]
    if tmp>max:
        max=tmp
print((max+K)*0.5)

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

for i in range(N):
  ans.append((nums[i]+1)/2)

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

print(M)

Solution (Python):
import numpy
 
N,K=map(int,input().split())
p=list(map(int,input().split()))
ans = 0
tmp = [0]*(N-K+1)

for i in range(K):
  tmp[0] = tmp[0]+p[i]

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

max_index=numpy.argmax(tmp)
for i in range(max_index,max_index+K):
  ans=ans+float(((p[i]*(p[i]+1))/2)*1/p[i])
print(ans)

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

for p in ps:
  es.append((1 + p) * p / 2 / p)

t = sum(es[0:k])
r = t

for i in range(k, n):
  t = t + es[i] - es[i - k]
  r = max(r, t)

print(r)

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

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

s = sum(ex[0:k])
t = s
for i in range(n-k):
    s = s-ex[i]+ex[i+k]
    t = max(t, s)

print(t/2)

Solution (Python):
N,K=(int(x) for x in input().split())
P=list(map(int, input().split()))
s=sum(P[0:K])
ans=[s]

for i in range(K,N):
    s=s+P[i]-P[i-K]
    ans.append(s)

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

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

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