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

s = [0]
sum_ = 0
for i in range(1, 1001):
    sum_ += i
    s.append(sum_)

b = []
for i in range(n):
    b.append(s[p[i]] / p[i])

bcum = [0] * (n+1)
for i in range(n):
    bcum[i+1] = bcum[i] + b[i]

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

print(ans)

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

saidai=0

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

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

print(saidai)

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

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

Solution (Python):
n,k=map(int,input().split())
P=[(int(i)+1)/2 for i in input().split()]
S=[P[0]]
for i in range(n-1):
    S.append(S[i]+P[i+1])
ans=0
S.insert(0,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()))

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

curr = best_score
for i in range(N-K):
    curr += p[i+K] + 1
    curr -= p[i] + 1
    if curr > best_score:
        best_score = curr

print(best_score/2)

Solution (Python):
def main():
    N, K = (int(i) for i in input().split())
    P = [int(i) for i in input().split()]
    E = [(p*(p+1)//2)/p for p in P]
    S = [0]*(N+1)
    ma = 0
    for i in range(N):
        S[i+1] = S[i] + E[i]
    for i in range(N-K+1):
        ma = max(ma, S[K+i] - S[i])
    print(ma)


if __name__ == '__main__':
    main()

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

T=sum(p[0:k])
S=T
num=0

for i in range(n-k):
    T-=p[i]
    T+=p[k+i]
    if T>S:
        S=T
        num=i+1

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

ans=0
for i in p[num:num+k]:
    ans+=kitai(i)

print(ans)

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

sm = sum(pn[:k])
maxi = sm
for i in range(n-k):
  sm -= pn[i]
  sm += pn[i+k]
  maxi = max(maxi, sm)
print((maxi + k) / 2.0)

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

sum_p = [0]

for p in P:
    sum_p.append(sum_p[-1] + p)

max_sum = 0
for i in range(K, N+1):
    buf = sum_p[i] - sum_p[i-K]
    if buf > max_sum:
        max_sum = buf

print((max_sum + K) / 2)

Solution (Python):
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
p_v = {i:sum([1/i*j for j in range(1,i+1)]) for i in range(1, 1001)}
p = [p_v[one] for one in p]

sums = [sum(p[:K])]
for i in range(1,N-K+1):
    sums.append(sums[-1]-p[i-1]+p[i+K-1])
print(max(sums))

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

Solution (Python):
import sys

n, k, *p = map(int, sys.stdin.read().split())

def main():
    ex = [(1 + i) * i // 2  / i for i in p]
    l = 0; r = k

    res = []
    s = sum(ex[l:r])
    res.append(s)
    while r < n:
        s -= ex[l]
        s += ex[r]
        l += 1
        r += 1
        res.append(s)
    return max(res)
    
if __name__ == '__main__':
    ans = main()
    print(ans)

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

i = 0
s = 0
while i < K:
	s += p_list[i]
	i += 1

m = 0
while True:
	if m < s:
		m = s
	if i == N:
		break
	s += p_list[i] - p_list[i - K]
	i += 1

print((K + m) / 2)

Solution (Python):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))



from collections import deque

N,K = II()
p = III()
x = [(p0+1)/2 for p0 in p]

d = deque(x[:K])
ans = sum(d)
now = sum(d)
for i in range(K,N):
    now = now-x[i-K]+x[i]
    if now>ans:
        ans = now

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
x=[0]
for i in range(n):
  x.append(p[i]+x[-1])
l=[]
for i in range(n-k+1):
  l.append(x[i+k]-x[i])
print(max(l))

Solution (Python):
import sys
sys.setrecursionlimit(100000)

def ii(): return int(input())
def iis(): return input().split()
def imi(): return map(int,iis())
def iil(): return list(imi())

n, k = imi()
p = iil()
li = [0]
for i in range(n):
    li.append(li[i]+(1+p[i])/2)
ans = 0
for i in range(n-k+1):
    ans = max(ans, li[i+k]-li[i])
print(ans)

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))
measuring = [sum(P[:K])]
for i in range(K, N):
    measuring.append(measuring[-1]+P[i]-P[i-K])


pointa = measuring.index(max(measuring))

tmp = P[pointa:pointa+K]

ans = 0
for t in tmp:
    ans += (t+1)/2
print(ans)

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

Solution (Python):

import sys
input = sys.stdin.readline
INF = 10**9

n, k = map(int, input().split())
p = [int(item) for item in input().split()]
total = 0
for i in range(k):
    total += p[i]
max_t = total
l = 0; r = k
for i in range(k, n):
    total += p[i] - p[i-k]
    if total > max_t:
        max_t = total
        l = i - k
        r = i

print(0.5 * k + max_t / 2.0)

Solution (Python):
from collections import deque

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

Q = deque([(p + 1) / 2 for p in ps[:K]])

max_ = sum(Q)
now = max_
for p in ps[K:]:
    p = (p + 1) / 2
    head = Q.popleft()
    now = now - head + p
    Q.append(p)
    max_ = max(max_, now)

print(max_)

Solution (Python):
n,k = (int(num) for num in input().split())
p = [int(num) for num in input().split()]
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + p[i]
ans = 0

for j in range(n-k+1):
    t = cum[j+k] - cum[j]
    if t > ans:
        ans = t
print((ans+k)/2)

Solution (Python):



from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n,k = mi()
    p = li()

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

    tmpl = [0]
    tmp = 0
    for i in range(len(p)):
        tmp+=p[i]
        tmpl.append(tmp)

    

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

    print(ans)



main()

Solution (Python):
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
P = np.array([0] + lr())
P = (P+1) / 2
Pcum = P.cumsum()
X = Pcum[K:] - Pcum[:-K]
answer = X.max()
print(answer)

Solution (Python):


import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def get_sum(a, b, c):
    """ 等差数列の和：(初項a, 末項b, 項数c) """
    return (a+b) * c // 2

N, K = MAP()
A = LIST()

B = [0] * N
for i in range(N):
    B[i] = get_sum(1, A[i], A[i]) / A[i]

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

Solution (Python):
from itertools import accumulate

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

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

sum_k=sum(P[:k])
ans=[sum_k]
for i in range(n-k):
    temp=ans[-1]
    temp-=P[i]
    temp+=P[k+i]
    ans.append(temp)
print(k/2+max(ans)/2)

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

exp = [(a+1)/2 for a in p]

tot = sum(exp[:K])
max_tot = tot
for i in range(N-K):
    tot += exp[i+K]- exp[i]
    if tot > max_tot:
        max_tot = tot
        
print(max_tot)

Solution (Python):
from itertools import accumulate

N,K = [int(zz) for zz in input().split()]
P = [int(zz) for zz in input().split()]

Q = [0] + list(accumulate(P))
ans = 0
for i in range(N-K+1):
    ans = max(ans,Q[i+K]-Q[i])

print((ans+K)/2)

Solution (Python):
N, K = map(int, input().split())
P = [int(x) for x in input().split()]
for i, p in enumerate(P):
  P[i] = (p + 1) / 2
ans = 0
E = 0
for i, p in enumerate(P):
  E += p
  if K <= i:
    E -= P[i - K]
  ans = max(E, ans)
print(ans)

Solution (Python):
def main():
    N, K = [int(x) for x in input().split()]
    p = [int(x) for x in input().split()]
    e = [(x+1)/2 for x in p]

    s = sum(e[:K])
    ans = s
    for i in range(K, N):
        s = s - e[i-K] + e[i]
        ans = max(s, ans)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

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

def main():
    n,k=MI()
    pp=LI()
    ev=[]
    for p in pp:
        ev.append((p+1)/2)
    mx=0
    cur=0
    for i in range(n):
        cur+=ev[i]
        if i-k>=0:cur-=ev[i-k]
        if cur>mx:mx=cur
    print(mx)

main()

Solution (Python):
from bisect import bisect_right, bisect_left
from collections import Counter, deque
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import groupby, permutations, combinations, product
from sys import stdin, stderr





def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)





def exgcd(x, y):
    if y == 0:
        return 1, 0
    a, b = exgcd(y, x % y)
    return b, a - (x // y) * b



def lcm(x, y):
    m = gcd(x, y)
    return (x // m) * (y // m)


def main():
    n, k = [int(x) for x in input().split()]
    p = [int(x) for x in input().split()]
    s = 0
    for i in range(k):
        s += p[i]
    max_sum = s
    for i in range(n-k):
        s += p[k+i] - p[i]
        max_sum = max(s, max_sum)
    return (max_sum + k) / 2


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

Solution (Python):
from itertools import accumulate

n, k = map(int, input().split())
e = [(int(i) + 1) / 2 for i in input().split()]
a = list(accumulate(e))
s = [a[i + k] - a[i] for i in range(n - k)]
print(max(a[k - 1], *s) if n > k else a[-1])

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,k,*ppp = get_all_int()

sum_ = sum(ppp[:k])
maxs = sum_
maxt = 0

tail = 0
while tail+k < len(ppp):
    sum_ -= ppp[tail]
    sum_ += ppp[tail+k]
    tail += 1
    if sum_ > maxs:
        maxs = sum_
        maxt = tail

ans = 0
for p in ppp[maxt:maxt+k]:
    ans += (p+1)/2

print(ans)

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

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

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

print(ans)

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    P = [int(p) for p in input().split()]
    Ex = [0] * N
    for i, p in enumerate(P):
        total = (p + 1) * p / 2
        Ex[i] = total / p
    maxEx = sum(Ex[:K])
    now = maxEx
    for i in range(N - K):
        now -= Ex[i]
        now += Ex[i + K]
        maxEx = max(maxEx, now)
    print(maxEx)

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):

import sys
input = sys.stdin.buffer.readline


from collections import defaultdict

con = 10 ** 9 + 7

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


def main():
	N, K = getlist()
	P = getlist()
	B = [0] * (N + 1)
	for i in range(N):
		B[i + 1] = B[i] + P[i]
	
	ans = 0
	for i in range(N - K + 1):
		val = B[i + K] - B[i]
		ans = max(ans, val)

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


if __name__ == '__main__':
	main()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



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


print(ans)

Solution (Python):
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
p = inpl()
maxsum = sum(p[:K])
s = maxsum
for i in range(N-K):
    s += p[i+K]-p[i]
    if s > maxsum:
        maxsum = s
print((maxsum+K)/2)

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

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

Solution (Python):
N, K = [int(i) for i in input().split()]
D = [(1+int(i))/2 for i in input().split()]
v = sum(D[0:K])
maxv = v
for i in range(N-K):
    v -= D[i]
    v += D[i+K]
    maxv = max(maxv, v)
print(maxv)

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

max_sum, max_P = 0, None
for i in range(N - K + 1):
    if max_sum < P_sum[i + K] - P_sum[i]:
        max_sum = P_sum[i + K] - P_sum[i]
        max_P = P[i:i + K]

print(sum([(p * (p + 1) // 2) / p for p in max_P]))

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

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

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

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    

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

    def cum(array):
        result = [0]
        for i in range(len(array)):
            result.append(array[i]+result[i])
        return result

    def calc(N):
        t = 0
        for i in range(1, N+1):
            t += i / N
        return t

    p2 = cum(p)

    for i in range(n - k+1):
        if ans < p2[i+k]-p2[i]:
            ans = p2[i+k]-p2[i]
            pos = i

    ans = 0
    for i in range(pos, pos + k):
        ans += calc(p[i])
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import accumulate
N, K = map(int, input().split())
P = [0] + list(map(int, input().split()))
P_acc = list(accumulate(P))


M = 0
Mi = -1
for i in range(1, N - K + 2):
    if P_acc[i + K - 1] - P_acc[i - 1] > M:
        M = P_acc[i + K - 1] - P_acc[i - 1]
        Mi = i


ans = 0
for i in range(Mi, Mi + K):
    ans += ((1 + P[i]) * 0.5 * P[i]) / P[i]

print(ans)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
p = LI()
lst = [(i+1)/2 for i in p]
l = [0]+ list(accumulate(lst))
ans = 0
for i in range(n-k+1):
    ans = max(ans,l[i+k] - l[i])
print(ans)

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

maxind=-1
cur=sum(P[:K])
maxval=cur
for i in range(K,N):
  cur=cur+P[i]-P[i-K]
  if cur>maxval:
    maxval=cur
    maxind=i


ans=0
for i in range(maxind-K+1,maxind+1):
    ans+=(P[i]*(P[i]+1)//2)/P[i]
    
print(ans)

Solution (Python):

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

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

ans = sum(p2[:K])
tmp = ans
idx = 0
while idx<N-K:
    tmp += p2[idx+K]
    tmp -= p2[idx]
    ans = max(ans,tmp)
    idx += 1

print(ans)

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

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

n,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))
memo = [0]
for i in range(1,1001):
    memo.append(memo[-1]+i)
for i in range(1,1001):
    memo[i] /= i 

for i in range(len(lst1)):
    lst1[i] = memo[lst1[i]]

p = sum(lst1[:k])
ans = 0
for i in range(n-k+1):
    ans = max(ans,p)
    if i + k >= len(lst1):
        break 
    p -= lst1[i]
    p += lst1[i+k]

print(ans)

Solution (Python):
from bisect import *
from collections import *
from fractions import gcd

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

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])
c = []
for i in range(n-k+1):
  c.append(b[i+k]-b[i])


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

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

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

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

Solution (Python):

def resolve():
    N,K=map(int,input().split())
    P=[int(i) for i in input().split()]
    PP= [i*(i+1)/2/i for i in P]
    mx = sum(PP[:K])
    sm=mx
    for i in range(K,N):
        sm+=PP[i]
        sm-=PP[i-K]
        mx=max(sm,mx)
    print(mx)





if __name__ == "__main__":
    resolve()

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

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

ruiseki = [0] * (n + 1)
for i in range(n):
    ruiseki[i + 1] = ruiseki[i] + ans[i]
    
res = 0
for i in range(n):
    if k+i > n:
        break
    res = max(res, ruiseki[k + i] - ruiseki[i])
print(res)

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]
ans = tmp

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

print (ans)

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

S = sum(Q[:K])
ans = S

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

print(ans)

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

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def e(a):
        return ((a*(a+1))>>1)/a
    n,k = LI()
    p = LI()
    p = [e(i) for i in p]
    ans = m = sum(p[:k])
    for i in range(n-k):
        m -= p[i]
        m += p[i+k]
        if ans < m:
            ans = m
    print(ans)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
n, k=map(int, input().split())
plist = list(map(int, input().split()))
now=sum(plist[:k])
answer=now

for i in range(n-k):
    now-=plist[i]
    now+=plist[i+k]
    if now>=answer:
        answer=now

print((k+answer)/2)

Solution (Python):

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

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

acc = [0]*(n+1)
for i in range(n):
    acc[i+1] += acc[i]+ppl[i]

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

print(res)

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

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

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

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

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def ki(p):
    return (p + 1) / 2

def main():
    N, K = LI()
    p = LI()
    p = [ki(x) for x in p]
    cursum = sum(p[:K])
    ans = cursum
    i = K
    for i in range(K, N):
        cursum -= p[i-K]
        cursum += p[i]
        ans = max(cursum, ans)
    print(ans)
main()

Solution (Python):
from itertools import accumulate

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


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


kitai = [0] + [f(e) for e in p]
acm = list(accumulate(kitai))

ans = 0
for e1, e2 in zip(acm, acm[k:]):
    ans = max(ans, e2 - e1)

print(ans)

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

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

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

Solution (Python):
def main():
    from itertools import accumulate

    n, k = map(int, input().split())
    *p, = ((float(x) + 1) / 2 for x in input().split())

    acc = (0,) + tuple(accumulate(p))

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


if __name__ == '__main__':
    main()

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

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

ps = list(map(int, input().split()))
cur = 0
for i in range(k):
    cur += ps[i] + 1

mx = cur

for i in range(n-k):
    j = i+k
    cur += -ps[i] + ps[j]
    mx = max(mx, cur)

print(mx / 2)

Solution (Python):
import sys
import math
import bisect

def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    max_val = 0
    val = 0
    for i in range(n):
        val += A[i]
        if i >= m:
            val -= A[i-m]
        if i >= m - 1:
            max_val = max(max_val, val)
    max_val = (max_val + m) / 2
    print('%.10f' % max_val)

if __name__ == "__main__":
    main()

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

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

Q = [p+1 for p in P]

S = [sum(Q[:K])]
for m,p in zip(Q[:N-K],Q[K:]):
    S.append(S[-1]+p-m)
ans = max(S)/2
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
t = sum(P[:K])
ans = t
for i in range(K, N):
  t = t - P[i-K] + P[i]
  ans = max(ans, t)

print(ans)

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

Solution (Python):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

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

tmp=ans
for i in range(k,n):

    tmp-=(p[i-k]+1)/2
    tmp+=(p[i]+1)/2
    ans=max(ans,tmp)
print(ans)

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

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

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

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

window = deque()
ev = 0
best = 0
for p in P:
    if len(window) == K:
        old = window.popleft()
        ev -= (old + 1) / 2
    window.append(p)
    ev += (p + 1) / 2
    best = max(best, ev)

print(best)

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

kitai = []
for i in range(n):
    kitai.append((1+p[i])/2)
ans = 0
sum_kitai = 0
for i in range(k):
    sum_kitai += kitai[i]
ans = sum_kitai
for i in range(1,n-k+1):
    sum_kitai -= kitai[i-1]
    sum_kitai += kitai[i+k-1]
    ans = max(ans,sum_kitai)
print(ans)

Solution (Python):
def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    m = t = sum(p[:K])
    for i in range(N-K):
        t -= p[i]
        t += p[i + K]
        m = max(m, t)
    return (m + K)/2
print(main())

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

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

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