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 main(sample_file = ''):

    """ convenient functions
    
    
    
    
    
    """

    """convenient decorator
    
    
        
        
        
        
        
        
        
        
        
        
    """
    
    
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product 
    
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  
        b, e = 2, 0  
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):   
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
        return result
    def combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict 
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest 
    from copy import deepcopy, copy 
    import operator
    from operator import itemgetter 
    
    
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd 
    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)
    def make_divisors(n, reversed=False):
        """create list of divisors
        
        Args:
            number (int): number from which list of divisors is created
            reversed (bool, optional): ascending order if False. Defaults to False.
        
        Returns:
            list: list of divisors
        """
        divisors = set()
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.add(i)
                divisors.add(n//i)
        return sorted(list(divisors),reverse=reversed)
    
    
    
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    modpow = lambda a, n, p = MOD: pow(a, n, p) 
    def modinv(a, p = MOD):
        
        
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        
        
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    class UnionFindTree:
        """union find tree class
        TODO: fix this description...
        how to use (example):
        >>  uf = UnionFindTree(N) 
        >>  if uf.find_root(a) == uf.find_root(b):
        >>      do something
        >>  else:
        >>      do something
        >>      uf.unite(a, b)
        """
        def __init__(self, N):
            self.root = [-1] * (N+1)
            self.rank   = [0]  * (N+1)
            self.connected_num = [1] * (N+1)
    
        def find_root(self,x):
            root = self.root
            while root[x] != -1:
                x = root[x]
            return x
    
        def unite(self,x,y):
            root = self.root
            rank = self.rank
            connected_num = self.connected_num
            find_root = self.find_root
    
            rx = find_root(x)
            ry = find_root(y)
            if rx != ry:
                if rank[rx] < rank[ry]:
                    root[rx] = ry
                    rx,ry = ry,rx
                else:
                    if rank[rx] == rank[ry]:
                        rank[rx] += 1
                    root[ry] = rx       
                connected_num[rx] += connected_num[ry]

    
    
    
    
    

    def BellmanFord(N, M, ABC, vertex_start, vertex_end, value_if_inf = -1, find_shortest = False):
        """to calculate furthest or shortest length between vertex_start and vertex_end using BellmanFord algorithm
        
        Args:
            N (int): number of vertices
            M (int): number of edges
            ABC (list): [(ai, bi, ci) for _ in range(N)] where i-th edge is directed from vertex ai to vertex bi and the length is ci 
            vertex_start (int): start vertex. usually use 0.
            vertex_end (int): end vertex. usually use N-1.
            value_if_inf (int or string as you like, optional): value you want when the furthest (or shortest) distance is infinite (or -infinite). Defaults to -1.
            find_shortest (bool, optional): choose False to find furthest path. Defaults to False.
        
        Returns:
            int or string: normally int (but can be str if you set value_if_inf to str)
            
        Example:
                N, M, P = R()
                ABC = [R() for _ in range(M)]
                ABC = [(a-1, b-1, c-P) for a, b, c in ABC]
                print(BellmanFord(N, M, ABC, 0, N-1, value_if_inf = 'inf'))

        """

        def make_reachable_list(N, M, ABC, vertex_start, vertex_end):
            reachable_to_direct = defaultdict(list)
            reachable_from_direct = defaultdict(list)
            reachable_from_start = [False] * N
            reachable_to_end = [False] * N
            reachable_from_start[vertex_start] = True
            reachable_to_end[vertex_end] = True
            reachable_from_both_sides = [False] * N
            dfs_from_start = []
            dfs_to_end = []
            for a, b, c in ABC:
                reachable_to_direct[a].append(b)
                reachable_from_direct[b].append(a)
                if a == vertex_start:
                    dfs_from_start.append(b)
                    reachable_from_start[b] = True
                if b == vertex_end:
                    dfs_to_end.append(a)
                    reachable_to_end[a] = True
            while dfs_from_start:
                v = dfs_from_start.pop()
                for i in reachable_to_direct[v]:
                    if not reachable_from_start[i]:
                        reachable_from_start[i] = True
                        dfs_from_start.append(i)
            while dfs_to_end:
                v = dfs_to_end.pop()
                for i in reachable_from_direct[v]:
                    if not reachable_to_end[i]:
                        reachable_to_end[i] = True
                        dfs_to_end.append(i)
            for i in range(N):
                reachable_from_both_sides[i] = reachable_from_start[i] and reachable_to_end[i]
            return reachable_from_both_sides
        
        reachable_from_both_sides = make_reachable_list(N, M, ABC, vertex_start, vertex_end)
        
        if find_shortest:
            dist = [INF for i in range(N)]
        else:
            dist = [-INF for i in range(N)]
        
        dist[vertex_start] = 0
        for i in range(N):
            updated = False
            for a, b, c in ABC:
                if not reachable_from_both_sides[a]:
                    continue
                elif find_shortest:
                    update_condition = dist[a] + c < dist[b]
                else:
                    update_condition = dist[a] + c > dist[b]
                if dist[a] != INF and update_condition:
                    dist[b] = dist[a] + c
                    updated = True
                    if i == N-1:
                        return value_if_inf
            if not updated:
                break
        return dist[vertex_end]

    """ initialize variables and set inputs
    
        
        
            
            
    
        
        
        
        
        
        
        
    
        
        
        
        
    
        
        
    """

    
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    r_float = lambda: float(r())
    R = lambda: list(map(int, r().split()))
    R_str = lambda: r().split()
    R_map = lambda: map(int, r().split())
    R_float = lambda: list(map(float, r().split()))
    R_tuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    
    
    
    
    
    
    
    """

    
    if sample_file:
        sys.stdin = open(sample_file)
        
    
    

    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    

    N, K = R()
    P = R()
    Q = [(1+p)/2 for p in P]
    now = sum(Q[:K])
    ans = now
    for i in range(0,N-K):
        ans = max(ans, now)
        now = now - Q[i] + Q[i+K]
    else:
        ans = max(ans, now)
    print(ans)
    
    
    

    """memo: how to use defaultdict of list
    
    Dic = defaultdict(list)
    
    Dic[x].append(y)
    
    for k, v in Dic.items():
    """
    
    """memo: how to solve binary problems
    
    >>> a = 5
    >>> bin_str_a = format(a, '
    >>> print(bin_str_a)
    0b0101 
    """
    
    """memo: how to solve the problem
    creating simple test/answer
    greed
    simple dp
    graph
    """

if __name__ == '__main__':
    main()

Solution (Python):
def inpl():
    return list(map(int, input().split()))


N, K = inpl()
P = inpl()

cumP = [0]
for p in P:
    cumP.append(cumP[-1] + p)

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

print((max_s + K) / 2)

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

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

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

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

Solution (Python):
def get_E(p):
    return sum(range(1, p + 1)) / p


N, K = map(int, input().split())
P = [int(x) for x in input().split()]
E = [get_E(p) for p in P]

left = 0
cur = 0
res = 0
for right in range(N):
    cur += E[right]
    while right - left + 1 > K:
        cur -= E[left]
        left += 1
    if right - left + 1 == K:
        res = max(res, cur)
print(res)

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l0=LI()
  l=copy.deepcopy(l0)

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

  l=[0]+l
  n+=1
  l2=[]

  for i in range(k,n):
    l2.append(l[i]-l[i-k])

  ind=l2.index(max(l2))
  ans=0

  for i in range(ind,ind+k):
    x=l0[i]
    ans+=(((1+x)*x)/2)/x
    

  return ans


print(main())

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

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

s=sum(P[:K])
tmp=s
k=0
for i in range(N-K):
    s=s-P[i]+P[K+i]
    
    if tmp<s:
        k=i+1
        tmp=s
ans=0
for i in range(k,k+K):
    ans+=(P[i]+1)/2

print(ans)

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

S = sum(P[0:K])
O = [S]
for i in range(N-K):
    S = S + P[K+i] - P[i]
    O.append(S)

print(max(O))

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

EP = [(p+1)*0.5 for p in P]


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


print(ans)

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

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):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n,k = m()


a = l()


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

co = sum(aaa[:k])

ma = co
for i in range(0,n-k):
    co = co - aaa[i] + aaa[i+k]
    
    ma = max(ma,co)
print(ma)

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

Solution (Python):

from fractions import Fraction as F

def solve():
    N, K = map(int,input().split())
    P = list(map(int,input().split()))
    q = sum(P[:K])
    res = q
    for i in range(K,N):
        q += P[i]-P[i-K]
        res = max(res, q)
    return str((res+K)/2)

if __name__ == '__main__':
    print(solve())

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

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

for i in range(n - k):
  ans -= (p[i] + 1) / 2
  ans += (p[k + i] + 1) / 2
  anses.append(ans)

print(max(anses))

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, K: int, p: "List[int]"):
    ans = 0
    
    
    
    
    pi = [p[i]*(p[i]+1)/(2*p[i]) for i in range(N)]
    api = [0] * (N+1)
    for i in range(N):
        api[i+1] = api[i] + pi[i]
    ans = 0
    for i in range(0, N-K+1):
        ans = max(ans, api[K+i]-api[i])

    print(ans)
    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):
n,k,*p=map(int,open(0).read().split())

m=sum(p[0:k])
ans=[m]
for i in range(k,n):
    m=m+p[i]-p[i-k]
    ans.append(m)
print(0.5*(max(ans)+k))

Solution (Python):
MOD = 1000000007
INF = float("inf")

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

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

start = 0
end = k-1
cur_sum = sum(A[start:end+1])
ans = cur_sum

for i in range(len(A)-k):
    cur_sum = cur_sum - A[start] + A[end+1]
    ans = max(ans, cur_sum)
    end += 1
    start += 1

print(ans)

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

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

num = sum(a[:k])
num_max = num
for i in range(k, n):
    num = num-a[i-k]+a[i]
    if num>num_max:
        num_max=num

print((num_max+k)/2)

Solution (Python):
N, K = map(int, input().split())
P = tuple(map(int, input().split()))
tmp = sum(P[:K])
M = tmp
for i in range(N - K):
    tmp += P[i + K]
    tmp -= P[i]
    if M < tmp:
        M = tmp
print((M + K) / 2)

Solution (Python):

N, K = [int(str) for str in input().strip().split()]
x = [int(str) for str in input().strip().split()]

sums = [0]
for i in x:
    sums.append(sums[-1] + (i + 1) / 2)

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

print(ans)

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


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

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

n,k = mi()
p = li()
for i in range(n):
    p[i] = (p[i]+1) / 2
ans = 0
ima = 0
for i in range(k):
    ima += p[i]
ans = ima
for i in range(k,n):
    tmp1 = p[i]
    tmp2 = p[i-k]
    ima = ima +tmp1 -tmp2
    ans = max(ima,ans)
print(ans)

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']



show_flg = False


def main():
    N, K = MI()
    p = LI()

    ans = 0
    cur = 0
    right = 0
    ans_arr = []
    for left in range(N):

        while right < len(p) and right - left < K:
            cur += p[right]
            right += 1

        if ans <= cur:
            ans = cur
            ans_arr = p[left:right]
        cur -= p[left]
        

    
    p = 0

    for a in ans_arr:
        t = (a * (a + 1)) // 2
        
        p += t / a

    print(p)



if __name__ == '__main__':
    main()

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

sum_p = [None] * (n - k + 1)
sum_p[0] = sum(p[0:k])
for i in range(1, n - k + 1):
  sum_p[i] = sum_p[i -1] + p[i + k - 1] - p[i -1]

max_sum_p = max(sum_p)

print((k + max_sum_p) / 2)

Solution (Python):
N, K = map(int, input().split())
p = [int(c) for c in  input().split()]
ans = 0
m = 0
for i in range(K):
  m += (1+p[i])/2
ans = m
for i in range(K,N,1):
  m -= p[i-K]/2
  m += p[i]/2
  if m>ans:
    ans = m
print(ans)

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

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

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

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

ans = sum(p_e[:K])
tmp = ans
i = 0

while 1:
    try:
        ans = max(ans, tmp - p_e[i] + p_e[K + i])
        tmp = tmp - p_e[i] + p_e[K + i]
        i += 1
    except IndexError:
        break

print(ans)

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

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

for i in range(N):
    ss[i+1] = ss[i] + s[i]

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

print(ans)

Solution (Python):
n,k=[int(j) for j in input().split()]
p=[int(j) for j in input().split()]
from itertools import accumulate
l=[0]+list(accumulate(p))
t=0
a,b=0,0
for i in range(n-k+1):
    if t<l[i+k]-l[i]:
        t=l[i+k]-l[i]
        a,b=i+k,i
ans=0
for i in range(b,a):
    j=p[i]
    ans+=j*(j+1)//2/j
    
print(ans)

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

e = [0]*n

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

from itertools import accumulate
a = [0] + e
b = list(accumulate(a))

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

Solution (Python):
from itertools import accumulate

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    max_sum = 0
    index = -1
    sum_P = [0] + list(accumulate(P))
    for i in range(N + 1 - K):
        tmp = sum_P[i+K] - sum_P[i]
        if tmp > max_sum:
            max_sum = tmp
            index = i
        
    ans = 0
    for i in range(index,index + K):
        tmp = P[i] * (P[i] + 1) // 2
        ans += tmp / P[i]
    print(ans)



if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
a = IL()
rui = [0]
tmp = 0
for i in range(N):
  tmp += a[i] + 1
  rui.append(tmp)

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

Solution (Python):
def A():
    temp = input().split()
    S = temp[0]
    T = temp[1]
    temp = [int(i) for i in input().split()]
    A = temp[0]
    B = temp[1]
    U = input()
    if U == S:
        print(A-1, B)
    else:
        print(A, B-1)

def B():
    print('x'*len(input()))

def C():
    N = int(input())
    A = [int(i) for i in input().split()]
    if N > len(set(A)):
        print('NO')
    else:
        print('YES')

def D():
    temp = [int(i) for i in input().split()]
    N = temp[0]
    K = temp[1]
    p = [int(i) for i in input().split()]
    expected_val = [(i+1)/2.0 for i in p]
    cur = sum(expected_val[:K])
    ans = cur
    for i in range(N-K):
        cur -= expected_val[i]
        cur += expected_val[i+K]
        ans = max(ans, cur)
    print(ans)

D()

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

    max_val = 0
    val = 0
    count = 0
    start = 0
    for i in arr:
        val += i
        count += 1
        if count == k:
            max_val = max(max_val,val)
            count -= 1
            val -= arr[start]
            start += 1

    print(max_val)

main()

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

SP = [0]*(N-K+1)
S0 = 0
for j in range(K):
    S0 += EP[j]
SP[0] = S0
for i in range(1,len(SP)):
    SP[i] = SP[i-1]+EP[i+K-1]-EP[i-1]

print(max(SP))

Solution (Python):
from itertools import accumulate

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

pc = [0] * N

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

L = [0] + list(accumulate(pc))

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

print(ans)

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

ans = 0
for i in range(k):
    ans += (1+a[i])/2
answer = ans
for i in range(k, len(a)):
    ans = ans + (a[i]+1)/2 - (a[i-k]+1)/2
    if ans > answer:
        answer = ans
print(answer)

Solution (Python):
n,k=map(int, input().split())  
P=list(map(int, input().split()))
import numpy as np
Px=np.array([(P[i]+1)/2 for i in range(n)])
Pcum=np.cumsum(Px)
Pcum=np.insert(Pcum,0,0)
ans=0
for i in range(k,n+1):
    ans=max(ans, Pcum[i]-Pcum[(i-k)])
print(ans)

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

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

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

current = ans

for i in range(K, N):
    diff = p[i] - p[i-K]
    temp = current + diff
    if temp >  ans:
        ans = temp
    current = temp

print ans

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

kitai=[]
for i in p:
  kitai.append((i+1)/2)

ans=sum(kitai[0:k])
temp=ans


for i in range(0,n-k):
  temp+=kitai[k+i]-kitai[i]
  ans=max(ans,temp)
print(ans)

Solution (Python):
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))
def to_cumsum(arr, pad=True):
    """
    1次元配列を累積和の1次元配列に変換する
    pad: 先頭に0の項を作る場合はTrue
    """
    cumsum = 0
    padding = 1 if pad else 0
    new = [0] * (len(arr) + padding)
    for i, e in enumerate(arr):
        cumsum += e
        new[i + padding] = cumsum
    return new


N, K = MI()
P = LMI()
cum = to_cumsum(P, pad=True)

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

Solution (Python):
def main():

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

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

    
    u = sum(v[:K])
    max_u = u
    
    for i in range(K, N):
        u += v[i] - v[i-K]
        
        max_u = max(max_u, u)
    return max_u


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

Solution (Python):
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    m = e = sum(P[:K])
    c = 0
    for i in range(N - K):
        e = e + P[K + i] - P[i]
        if e > m:
            m = e
            c = i + 1
    t = sum((k + 1) for k in P[c:c + K]) / 2
    print(t)

main()

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

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

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

Solution (Python):
from itertools import accumulate

N, K, *P = map(int, open(0).read().split())

E = [(p + 1) for p in P]

A = [0] + list(accumulate(E))

print("{:.8f}".format(max(A[i + K] - A[i] for i in range(N - K + 1)) / 2))