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):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  
def Is(): return map(int, input().split())  
def LI(): return list(map(int, input().split()))  
def TI(): return tuple(map(int, input().split()))  
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  
def LS(): return list(input())  
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n, k = Is()
P = LI()
P_ = [(x+1)/2 for x in P]

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

print(ans)

Solution (Python):
n,m=(int(i) for i in input().split())
l=[]
for i in input().split():
  l.append((int(i)+1)/2)
s=sum(l[0:m])
maxe=s
for i in range(n-m):
  s+=l[m+i]
  s-=l[i]
  if s>maxe:
    maxe=s
print(maxe)

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

from collections import deque

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

d_front = deque(p[:k])
d_back = deque(p[k:])

sum_prev = sum(d_front)
ma = sum_prev

while d_back:
    ff = d_front.popleft()
    bf = d_back.popleft()
    sum_curr = sum_prev - ff + bf
    ma = max(ma, sum_curr)
    d_front.append(bf)
    sum_prev = sum_curr
    
print(ma)

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

p = [0]*1001
for i in range(1, 1001):
    p[i] = p[i-1] + i
pn = list(map(lambda x: p[x] / x, pn))

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

print(ans)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
max = 0
list = [0] * k
evlist = [0] * 1000
for i in range(1000):
    wk = 0
    for j in range(i + 1):
        wk += j + 1
    evlist[i] = float(wk / (i + 1))
wk = 0
start = 0
for i in range(n - (k - 1)):
    if wk == 0:
        for j in range(i, i + k):
            wk += p[j]
    else:
        wk += p[i + k - 1]
        wk -= p[i - 1]
    if max < wk:
        max = wk
        start = i
for i in range(start, start + k):
    list[i - start] = p[i]
ans = 0
for i in range(k):
    ans += evlist[list[i] - 1]
print(ans)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
max = 0
list = [0] * k
evlist = [1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0, 10.5, 11.0,
          11.5, 12.0, 12.5, 13.0, 13.5, 14.0, 14.5, 15.0, 15.5, 16.0, 16.5, 17.0, 17.5, 18.0, 18.5, 19.0, 19.5, 20.0,
          20.5, 21.0, 21.5, 22.0, 22.5, 23.0, 23.5, 24.0, 24.5, 25.0, 25.5, 26.0, 26.5, 27.0, 27.5, 28.0, 28.5, 29.0,
          29.5, 30.0, 30.5, 31.0, 31.5, 32.0, 32.5, 33.0, 33.5, 34.0, 34.5, 35.0, 35.5, 36.0, 36.5, 37.0, 37.5, 38.0,
          38.5, 39.0, 39.5, 40.0, 40.5, 41.0, 41.5, 42.0, 42.5, 43.0, 43.5, 44.0, 44.5, 45.0, 45.5, 46.0, 46.5, 47.0,
          47.5, 48.0, 48.5, 49.0, 49.5, 50.0, 50.5, 51.0, 51.5, 52.0, 52.5, 53.0, 53.5, 54.0, 54.5, 55.0, 55.5, 56.0,
          56.5, 57.0, 57.5, 58.0, 58.5, 59.0, 59.5, 60.0, 60.5, 61.0, 61.5, 62.0, 62.5, 63.0, 63.5, 64.0, 64.5, 65.0,
          65.5, 66.0, 66.5, 67.0, 67.5, 68.0, 68.5, 69.0, 69.5, 70.0, 70.5, 71.0, 71.5, 72.0, 72.5, 73.0, 73.5, 74.0,
          74.5, 75.0, 75.5, 76.0, 76.5, 77.0, 77.5, 78.0, 78.5, 79.0, 79.5, 80.0, 80.5, 81.0, 81.5, 82.0, 82.5, 83.0,
          83.5, 84.0, 84.5, 85.0, 85.5, 86.0, 86.5, 87.0, 87.5, 88.0, 88.5, 89.0, 89.5, 90.0, 90.5, 91.0, 91.5, 92.0,
          92.5, 93.0, 93.5, 94.0, 94.5, 95.0, 95.5, 96.0, 96.5, 97.0, 97.5, 98.0, 98.5, 99.0, 99.5, 100.0, 100.5, 101.0,
          101.5, 102.0, 102.5, 103.0, 103.5, 104.0, 104.5, 105.0, 105.5, 106.0, 106.5, 107.0, 107.5, 108.0, 108.5,
          109.0, 109.5, 110.0, 110.5, 111.0, 111.5, 112.0, 112.5, 113.0, 113.5, 114.0, 114.5, 115.0, 115.5, 116.0,
          116.5, 117.0, 117.5, 118.0, 118.5, 119.0, 119.5, 120.0, 120.5, 121.0, 121.5, 122.0, 122.5, 123.0, 123.5,
          124.0, 124.5, 125.0, 125.5, 126.0, 126.5, 127.0, 127.5, 128.0, 128.5, 129.0, 129.5, 130.0, 130.5, 131.0,
          131.5, 132.0, 132.5, 133.0, 133.5, 134.0, 134.5, 135.0, 135.5, 136.0, 136.5, 137.0, 137.5, 138.0, 138.5,
          139.0, 139.5, 140.0, 140.5, 141.0, 141.5, 142.0, 142.5, 143.0, 143.5, 144.0, 144.5, 145.0, 145.5, 146.0,
          146.5, 147.0, 147.5, 148.0, 148.5, 149.0, 149.5, 150.0, 150.5, 151.0, 151.5, 152.0, 152.5, 153.0, 153.5,
          154.0, 154.5, 155.0, 155.5, 156.0, 156.5, 157.0, 157.5, 158.0, 158.5, 159.0, 159.5, 160.0, 160.5, 161.0,
          161.5, 162.0, 162.5, 163.0, 163.5, 164.0, 164.5, 165.0, 165.5, 166.0, 166.5, 167.0, 167.5, 168.0, 168.5,
          169.0, 169.5, 170.0, 170.5, 171.0, 171.5, 172.0, 172.5, 173.0, 173.5, 174.0, 174.5, 175.0, 175.5, 176.0,
          176.5, 177.0, 177.5, 178.0, 178.5, 179.0, 179.5, 180.0, 180.5, 181.0, 181.5, 182.0, 182.5, 183.0, 183.5,
          184.0, 184.5, 185.0, 185.5, 186.0, 186.5, 187.0, 187.5, 188.0, 188.5, 189.0, 189.5, 190.0, 190.5, 191.0,
          191.5, 192.0, 192.5, 193.0, 193.5, 194.0, 194.5, 195.0, 195.5, 196.0, 196.5, 197.0, 197.5, 198.0, 198.5,
          199.0, 199.5, 200.0, 200.5, 201.0, 201.5, 202.0, 202.5, 203.0, 203.5, 204.0, 204.5, 205.0, 205.5, 206.0,
          206.5, 207.0, 207.5, 208.0, 208.5, 209.0, 209.5, 210.0, 210.5, 211.0, 211.5, 212.0, 212.5, 213.0, 213.5,
          214.0, 214.5, 215.0, 215.5, 216.0, 216.5, 217.0, 217.5, 218.0, 218.5, 219.0, 219.5, 220.0, 220.5, 221.0,
          221.5, 222.0, 222.5, 223.0, 223.5, 224.0, 224.5, 225.0, 225.5, 226.0, 226.5, 227.0, 227.5, 228.0, 228.5,
          229.0, 229.5, 230.0, 230.5, 231.0, 231.5, 232.0, 232.5, 233.0, 233.5, 234.0, 234.5, 235.0, 235.5, 236.0,
          236.5, 237.0, 237.5, 238.0, 238.5, 239.0, 239.5, 240.0, 240.5, 241.0, 241.5, 242.0, 242.5, 243.0, 243.5,
          244.0, 244.5, 245.0, 245.5, 246.0, 246.5, 247.0, 247.5, 248.0, 248.5, 249.0, 249.5, 250.0, 250.5, 251.0,
          251.5, 252.0, 252.5, 253.0, 253.5, 254.0, 254.5, 255.0, 255.5, 256.0, 256.5, 257.0, 257.5, 258.0, 258.5,
          259.0, 259.5, 260.0, 260.5, 261.0, 261.5, 262.0, 262.5, 263.0, 263.5, 264.0, 264.5, 265.0, 265.5, 266.0,
          266.5, 267.0, 267.5, 268.0, 268.5, 269.0, 269.5, 270.0, 270.5, 271.0, 271.5, 272.0, 272.5, 273.0, 273.5,
          274.0, 274.5, 275.0, 275.5, 276.0, 276.5, 277.0, 277.5, 278.0, 278.5, 279.0, 279.5, 280.0, 280.5, 281.0,
          281.5, 282.0, 282.5, 283.0, 283.5, 284.0, 284.5, 285.0, 285.5, 286.0, 286.5, 287.0, 287.5, 288.0, 288.5,
          289.0, 289.5, 290.0, 290.5, 291.0, 291.5, 292.0, 292.5, 293.0, 293.5, 294.0, 294.5, 295.0, 295.5, 296.0,
          296.5, 297.0, 297.5, 298.0, 298.5, 299.0, 299.5, 300.0, 300.5, 301.0, 301.5, 302.0, 302.5, 303.0, 303.5,
          304.0, 304.5, 305.0, 305.5, 306.0, 306.5, 307.0, 307.5, 308.0, 308.5, 309.0, 309.5, 310.0, 310.5, 311.0,
          311.5, 312.0, 312.5, 313.0, 313.5, 314.0, 314.5, 315.0, 315.5, 316.0, 316.5, 317.0, 317.5, 318.0, 318.5,
          319.0, 319.5, 320.0, 320.5, 321.0, 321.5, 322.0, 322.5, 323.0, 323.5, 324.0, 324.5, 325.0, 325.5, 326.0,
          326.5, 327.0, 327.5, 328.0, 328.5, 329.0, 329.5, 330.0, 330.5, 331.0, 331.5, 332.0, 332.5, 333.0, 333.5,
          334.0, 334.5, 335.0, 335.5, 336.0, 336.5, 337.0, 337.5, 338.0, 338.5, 339.0, 339.5, 340.0, 340.5, 341.0,
          341.5, 342.0, 342.5, 343.0, 343.5, 344.0, 344.5, 345.0, 345.5, 346.0, 346.5, 347.0, 347.5, 348.0, 348.5,
          349.0, 349.5, 350.0, 350.5, 351.0, 351.5, 352.0, 352.5, 353.0, 353.5, 354.0, 354.5, 355.0, 355.5, 356.0,
          356.5, 357.0, 357.5, 358.0, 358.5, 359.0, 359.5, 360.0, 360.5, 361.0, 361.5, 362.0, 362.5, 363.0, 363.5,
          364.0, 364.5, 365.0, 365.5, 366.0, 366.5, 367.0, 367.5, 368.0, 368.5, 369.0, 369.5, 370.0, 370.5, 371.0,
          371.5, 372.0, 372.5, 373.0, 373.5, 374.0, 374.5, 375.0, 375.5, 376.0, 376.5, 377.0, 377.5, 378.0, 378.5,
          379.0, 379.5, 380.0, 380.5, 381.0, 381.5, 382.0, 382.5, 383.0, 383.5, 384.0, 384.5, 385.0, 385.5, 386.0,
          386.5, 387.0, 387.5, 388.0, 388.5, 389.0, 389.5, 390.0, 390.5, 391.0, 391.5, 392.0, 392.5, 393.0, 393.5,
          394.0, 394.5, 395.0, 395.5, 396.0, 396.5, 397.0, 397.5, 398.0, 398.5, 399.0, 399.5, 400.0, 400.5, 401.0,
          401.5, 402.0, 402.5, 403.0, 403.5, 404.0, 404.5, 405.0, 405.5, 406.0, 406.5, 407.0, 407.5, 408.0, 408.5,
          409.0, 409.5, 410.0, 410.5, 411.0, 411.5, 412.0, 412.5, 413.0, 413.5, 414.0, 414.5, 415.0, 415.5, 416.0,
          416.5, 417.0, 417.5, 418.0, 418.5, 419.0, 419.5, 420.0, 420.5, 421.0, 421.5, 422.0, 422.5, 423.0, 423.5,
          424.0, 424.5, 425.0, 425.5, 426.0, 426.5, 427.0, 427.5, 428.0, 428.5, 429.0, 429.5, 430.0, 430.5, 431.0,
          431.5, 432.0, 432.5, 433.0, 433.5, 434.0, 434.5, 435.0, 435.5, 436.0, 436.5, 437.0, 437.5, 438.0, 438.5,
          439.0, 439.5, 440.0, 440.5, 441.0, 441.5, 442.0, 442.5, 443.0, 443.5, 444.0, 444.5, 445.0, 445.5, 446.0,
          446.5, 447.0, 447.5, 448.0, 448.5, 449.0, 449.5, 450.0, 450.5, 451.0, 451.5, 452.0, 452.5, 453.0, 453.5,
          454.0, 454.5, 455.0, 455.5, 456.0, 456.5, 457.0, 457.5, 458.0, 458.5, 459.0, 459.5, 460.0, 460.5, 461.0,
          461.5, 462.0, 462.5, 463.0, 463.5, 464.0, 464.5, 465.0, 465.5, 466.0, 466.5, 467.0, 467.5, 468.0, 468.5,
          469.0, 469.5, 470.0, 470.5, 471.0, 471.5, 472.0, 472.5, 473.0, 473.5, 474.0, 474.5, 475.0, 475.5, 476.0,
          476.5, 477.0, 477.5, 478.0, 478.5, 479.0, 479.5, 480.0, 480.5, 481.0, 481.5, 482.0, 482.5, 483.0, 483.5,
          484.0, 484.5, 485.0, 485.5, 486.0, 486.5, 487.0, 487.5, 488.0, 488.5, 489.0, 489.5, 490.0, 490.5, 491.0,
          491.5, 492.0, 492.5, 493.0, 493.5, 494.0, 494.5, 495.0, 495.5, 496.0, 496.5, 497.0, 497.5, 498.0, 498.5,
          499.0, 499.5, 500.0, 500.5]
wk = 0
start = 0
for i in range(n - (k - 1)):
    if wk == 0:
        for j in range(i, i + k):
            wk += p[j]
    else:
        wk += p[i + k - 1]
        wk -= p[i - 1]
    if max < wk:
        max = wk
        start = i
for i in range(start, start + k):
    list[i - start] = p[i]
ans = 0
for i in range(k):
    ans += evlist[list[i] - 1]
print(ans)

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

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

for j in range(K):
  s += p[j]

x = s
 
for k in range(N - K):
  t = s - p[k] + p[K + k]
  if max(s, x) <= t:
    x = t
  else:
    pass
  s = t

print(x)

Solution (Python):
def main():
    N, K = map(int, input().split())
    dice = [int(p) for p in input().split()]
    S = [ 0 for i in range(N+1)]

    for i in range(1, N+1):
        S[i] = S[i-1] + (dice[i-1]+1)/2.0

    max_E = 0
    for i in range(N-K+1):
       E = S[i+K] - S[i]
       if max_E < E:
           max_E = E

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

Solution (Python):
from itertools import accumulate

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

acc=list(accumulate(p))
ans=sum(p[:k])
for i in range(k,n):
    ans=max(ans, acc[i]-acc[i-k])
print(ans/2+0.5*k)

Solution (Python):
from itertools import accumulate

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

acc=list(accumulate(p))

ans=0
if n==k:
    print(sum(p)/2+0.5*k)
    exit()
for i in range(k,n):
    ans=max(ans,acc[i]-acc[i-k])
print(ans/2+0.5*k)

Solution (Python):
N,K = map(int, input().split())
*P, = map(int, input().split())
S   = [0]*(N+1)


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

right = 0
left  = 0
ans   = 0
for i in range(N-K+1):

    if ans <= (S[i+K]-S[i]):
        ans = (S[i+K]-S[i])
        right = i+K
        left  = i

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

Solution (Python):
M,N = list(map(int,input().split()))
s = list(map(int,input().split()))
count = 0
kiroku = 0

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


for i in range(N,M+1):
    count = max(count,t[i]-t[i-N])

print(count)

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

p=list(map(int,input().split()))
def keisan(x):
  return (k+x)/2
ans=0
zzz=list(itertools.accumulate(p))
zzz.insert(0,0)
han=0
for i in range(k,len(zzz)):
  if han<zzz[i]-zzz[i-k]:
    han=zzz[i]-zzz[i-k]
print(keisan(han))

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

Solution (Python):
from sys import stdin


N,K = map(int, stdin.readline().rstrip().split())
P = list(map(int, stdin.readline().rstrip().split()))

Q = [(p+1)/2 for p in P]
c = [0]
for q in Q:
    c.append(c[-1] + q)

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

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

su = [0] * (n + 1)

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

res = 0
for j in range(n - k + 1):
    res = max(res, su[j + k] - su[j])   
print(res)

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

su = [0] * (n + 1)

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

res = 0
for j in range(n - k + 1):
    res = max(res, su[j + k] - su[j])
    
print('{:.12f}'.format(res))

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

def get_e(p):
    return p*(p+1)/2/p

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

max_e = c_e_list[K-1]
for i in range(1, N-K+1):
    e = c_e_list[i+K-1] - c_e_list[i-1]
    if e > max_e:
        max_e = e

print(max_e)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
l=sum([p[i] for i in range(k)])
if n==k:
  ans=l
else:
  ans=0
for i in range(n-k):
  l-=p[i]
  l+=p[i+k]
  ans=max(l,ans)
print('{:.12f}'.format((ans+k)/2))

Solution (Python):
def main():
    N, K = list(map(int, input().split(' ')))
    P = list(map(int, input().split(' ')))
    means = [(p + 1) / 2 for p in P]
    max_mean = sum(means[:K])
    current_mean = max_mean
    next_head = K
    while next_head < N:
        diff = means[next_head] - means[next_head - K]
        current_mean += diff
        max_mean = max([max_mean, current_mean])
        next_head += 1
    print(max_mean)


if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
p = map(lambda x: sum(range(1,x+1))/x, p)
 
l = [0]
for i,v in enumerate(p):
    prev = l.pop()
    l.append(prev)
    l.append(prev + v)
 
ans = 0
for i in range(k, len(l)):
    tmp = l[i] - l[i-k]
    if ans < tmp:
        ans = tmp
 
print(ans)

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

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

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

V = [0] * (N + 1)
S = [0] * (1010)
for i in range(1009):
    S[i + 1] = S[i] + (i + 1)


for i in range(N):
    p = P[i]
    V[i + 1] = V[i] + S[p] / p



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

print(res)

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

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

print((mx + K) / 2)

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

e_p = []
for i in range(n):
    e_p.append(0.5*p[i]+0.5)


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

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

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

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

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

        if tmp > tmp_max:
            tmp_max = tmp

    print((tmp_max + K) / 2)

main()

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

def sum_n(n):
  return n * (n + 1) // 2

sum_list = [0 for _ in range(N)]
for i in range(N):
  sum_list[i] = sum_n(L[i]) / L[i]

st = 0
ed = K - 1
tmp = sum(sum_list[:ed+1])
ans = tmp
for i in range(N - K):
  ed += 1
  tmp = tmp - sum_list[st] + sum_list[ed]
  ans = max(ans, tmp)
  st += 1

print(ans)

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

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

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

s = [0]
for i in range(n):
    s.append(s[i] + p_exp[i])

ans = -1

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

print(ans)

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

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

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

a=sum(p[0:K])
array.append(a)

for n in range(N-K):
  a=a-p[n]+p[n+K]
  array.append(a)

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

Solution (Python):

"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""


"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""


N,K = map(int,input().split())
def kitai(num):
    return (1+int(num))/2
P = list(map(kitai,input().split()))	  

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

Solution (Python):

import sys


def solve(N: int, K: int, p: "List[int]"):
    sums = [0]
    maxsum = 0
    for i in range(0, N):
        sums.append(p[i] + sums[i])

    for i in range(0, N - K + 1):
        maxsum = max(sums[i + K] - sums[i], maxsum)
    print((maxsum + K) / 2)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    p = [int(next(tokens)) for _ in range(N)]  
    solve(N, K, p)

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np


N,K = map(int,input().split())
pn = list(map(int, input().split()))
sumn = list(map(lambda x:x*(x+1)/2/x ,pn))

ans = []
k_sum = sum(sumn[:K])
ans.append(k_sum)
for k in range(1,len(sumn)-K+1):
  k_sum -= sumn[k-1]
  k_sum += sumn[k+K-1]
  ans.append(k_sum)
print(max(ans))

Solution (Python):
from itertools import accumulate

n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
c = [0] + list(accumulate(p))
mx = 0
mx_n = 0
for i in range(len(c)-k):
    if mx < c[i+k] - c[i]:
        mx = c[i+k] - c[i]
        mx_n = i
ans = 0
for i in range(k):
    ans += (p[mx_n + i] + 1) / 2

print(ans)

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

def get_expectation (x):
    return (float(x)+1)/2
exp = list(map(get_expectation,input().split()))


total = sum(exp[0:K])
maxim = total
for i in range(K,N):
    total -= exp[i-K]
    total += exp[i]
   
    
    if maxim <= total:
        maxim = total

print("%.10f" % maxim)

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

Solution (Python):
N,K = map(int, input().split())
A = [(1+int(x))/2 for x in input().split()]
wa = []
w = 0
for i in range(0,K):
    w = w+A[i]
wa.append(w)
for j in range(N-K):
    w = w + A[j+K] - A[j]
    wa.append(w)
print(max(wa))

Solution (Python):
n, k = map(int, input().split())
E = list(map(lambda x: (x + 1) * 0.5, list(map(int, input().split()))))
esum = sum(E[:k])
ans = esum
for i in range(n - k):
    esum = esum - E[i] + E[i + k]
    ans = max(ans, esum)
print(ans)

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

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

DP = [0 for i in range(N+1)]
SS = sum(S[:K])

for i in range(K):
    DP[i] = SS

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


print(max(DP))

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

d={}

for i in range(n):
  if l[i] not in d:
    d[l[i]]=(l[i]+1)/2



dp=[]
dp.append(d[l[0]])
for i in range(1,n):
  dp.append(dp[i-1]+d[l[i]])



mx=dp[k-1]
for i in range(n-k):
  we=dp[i+k]-dp[i]
  
  if we>=mx:
    mx=we
print(mx)

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

evs = [(1 + int(n))/2 for n in input().split()]
cumsum = [0]

for i in range(1,N+1):
    cumsum.append(cumsum[i-1] + evs[i-1])

k_cum = [cumsum[i+K] - cumsum[i] for i in range(N-K+1)]

print(max(k_cum))

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

evs = [(1 + int(n))/2 for n in input().split()]
cumsum = [0]

for i in range(1,N+1):
    cumsum.append(cumsum[i-1] + evs[i-1])

k_cum = [cumsum[i+K] - cumsum[i] for i in range(N-K+1)]

print(max(k_cum))

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

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

for i in range(n-k):
    a -= (p[i]+1)/2
    a += (p[i+k]+1)/2
    if (a > a_max):
        a_max = a
print(a_max)

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

X = []

for i in p:
  X.append((i + 1) / 2)

fK = 0
for i in range(K):
  fK += X[i]

X_sum = [fK]

for i in range(N - K):
  X_sum.append(X_sum[i] - X[i] + X[i+K])

print(max(X_sum))

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

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

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

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

Solution (Python):

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

exps = []
_sum = 0
for v in P:
    _sum += (1+v)/2
    exps.append(_sum)

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

print(ans)

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

Dices = list(map(lambda n:(n+1)/2,Dices))
import numpy as np 
Dices = np.cumsum(Dices)













S=np.append(0,Dices)
total = 0



for j in range(N-K+1):
    total = max(total,S[j+K]-S[j])

print(total)

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

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

print(max(l))

Solution (Python):
n, k = (int(x) for x in input().split())
list = list(map(int, input().split()))

list_sum=[0]
for i in range(n):
    list_sum.append(list_sum[i]+list[i])
max_sum = 0
for i in range(n-k+1):
    sum_num = list_sum[i+k]-list_sum[i]
    if sum_num>max_sum:
        max_sum = sum_num
print((max_sum+k)/2)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def tsum(l, r):
    return (r + l) * (r - l + 1) // 2

def exp(num):
    return tsum(1, num) / num

def solve():
    n, k = MI()
    P = LI()

    E = [0] * n
    pre = 0
    for i in range(n):
        E[i] = pre + exp(P[i])
        pre = E[i]
    

    p = E[0]
    mx = E[k-1]
    for j in range(k, n):
        diff = E[j] - E[j-k]
        
        if mx < diff:
            mx = diff
    print(mx)


if __name__ == '__main__':
    solve()

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

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

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

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

s = []
sums = 0
for i in exp:
    sums += i
    s.append(sums)

exps = [s[k-1]]
for i in range(k,len(p)):
    exps.append(s[i] - s[i-k])
print(max(exps))

Solution (Python):
import numpy as np
n,k = map(int,input().split())
p_ls = list(map(int, input().split()))
e_ls = [0] * n
for i in range(n):
    p = p_ls[i]
    e = (p*(1+p) // 2) / p
    e_ls[i] = e
e_csum = list(np.cumsum(e_ls))
max_exp = 0
for start in range(n):
    if start > 0 and start+k-1 < n:
        sum_exp = e_csum[start+k-1] - e_csum[start-1]
    elif start == 0:
        sum_exp = e_csum[start + k - 1]
    max_exp = max(max_exp, sum_exp)
print(max_exp)

Solution (Python):
N,K=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
e=[(i+1)*0.5 for i in p]
ex=[]

for i in range(N):
  if i==0:
    ex.append(e[0])
  else:
    ex.append(ex[i-1]+e[i])

ans=0
ex.insert(0,0)
for i in range(N-K+1):
  if ans<ex[i+K]-ex[i]:
    ans=ex[i+K]-ex[i]
print(ans)

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

c_s_list = [0] 
c_sum = 0 
for dice in p_list:
    average = (dice + 1) / 2 
    c_sum += average
    c_s_list.append(c_sum)

ans = 0
for i in range(N-K+1):
    tmp = c_s_list[i+K] - c_s_list[i]
    if tmp >= ans:
        ans = tmp
print(ans)

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

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

Solution (Python):
import math
N, K = map(int, input().split())
P = list(map(int, input().split()))
Q = []
for p in P:
    Q.append(sum(range(1, p + 1)) / p)
max = 0
max_i = 0
tmp = 0
for i in range(N - K + 1):
    if i == 0:
        for j in range(K):
            tmp += Q[j]
    else:
        tmp = tmp + Q[i + K - 1] - Q[i - 1]
    if max < tmp:
        max = tmp
        max_i = i
print(max)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=[]
b=[0]*n
q=0
for i in range(n):
  a.append((1/2)*(p[i]+1))
for j in range(k):
  q+=a[j]

b[0]=q

for l in range(1,n-k+1):
  b[l]=b[l-1]-a[l-1]+a[k+l-1]
print(max(b))

Solution (Python):
import itertools
n, k=map(int, input().split())
a=list(map(int, input().split()))
a.insert(0, 0)

ary=[0]
for i in range(1,n+1):
    ary.append((a[i]+1)/2)

cumsum=itertools.accumulate(ary)
ary2=list(cumsum)
ans=0

for i in range(n-k+1):
    tmp=ary2[i+k]-ary2[i]

    if tmp > ans:
        ans=tmp

print(ans)

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

from collections import deque
d = deque()

maxE = 0
sumE = 0


for i in range(n):
    p = arr[i]
    e = (p+1)/2
    
    sumE += e
    d.append(e)
    
    if i+1 >= k:
        if sumE > maxE:
            maxE = sumE
        sumE -= d.popleft()

print(maxE)

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

for i in range(N):
    total.append (total[i] + ex[i])

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

print (ans)

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