Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def expected_value(n):
    ans = 0

    for i in range(1, n+1):
        ans += i/n

    # eprint(ans)
    return ans

def main():
    n, k = map(int, input().split())
    Ps = list(map(int, input().split()))
    
    Cs = [0]*n
    for i in range(n):
        if i == 0:
            Cs[i] = Ps[i]
        else:
            Cs[i] = Cs[i-1] + Ps[i]
    
    Ds = list()
    mi = -10**9
    mix = 0
    for i in range(n-k+1):
        if i == 0:
            Ds.append(Cs[i+k-1])
        else:
            Ds.append(Cs[i+k-1] - Cs[i-1])

        if Ds[i] > mi:
            mi = Ds[i]
            mix = i

    
    #mix ~ mix+kまでの
    v = int()
    for i in range(k):
        v += expected_value(Ps[mix+i])
        
    print(v)

    return

if __name__ == '__main__':
    main()

Fixed submission:
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def expected_value(n):
    ans = 0

    for i in range(1, n+1):
        ans += i/n

    # eprint(ans)
    return ans

def main():
    n, k = map(int, input().split())
    Ps = list(map(int, input().split()))
    
    Cs = [0]*n
    for i in range(n):
        if i == 0:
            Cs[i] = Ps[i]
        else:
            Cs[i] = Cs[i-1] + Ps[i]
    
    Ds = list()
    mi = -10**9
    mix = 0
    for i in range(n-k+1):
        if i == 0:
            Ds.append(Cs[i+k-1])
        else:
            Ds.append(Cs[i+k-1] - Cs[i-1])

        if Ds[i] > mi:
            mi = Ds[i]
            mix = i

    
    #mix ~ mix+kまでの
    v = int()
    for i in range(k):
        v += expected_value(Ps[mix+i])
        
    print(v)

    return

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def expected_value(n):
    ans = 0

    for i in range(1, n+1):
        ans += i/n

    # eprint(ans)
    return ans

def main():
    n, k = map(int, input().split())
    Ps = list(map(int, input().split()))
    mi = -10**9
    ml = list()
    for i in range(n-k+1):
        if sum(Ps[i:i+k]) > mi:
            ml = Ps[i:i+k]
            mi = sum(Ps[i:i+k])
    
    v = int()
    for j in range(k):
        # 各サイコロについて期待値を求める
        v += expected_value(ml[j])

    
    print(v)
    return

if __name__ == '__main__':
    main()

Fixed submission:
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def expected_value(n):
    ans = 0

    for i in range(1, n+1):
        ans += i/n

    # eprint(ans)
    return ans

def main():
    n, k = map(int, input().split())
    Ps = list(map(int, input().split()))
    
    Cs = [0]*n
    for i in range(n):
        if i == 0:
            Cs[i] = Ps[i]
        else:
            Cs[i] = Cs[i-1] + Ps[i]
    
    Ds = list()
    mi = -10**9
    mix = 0
    for i in range(n-k+1):
        if i == 0:
            Ds.append(Cs[i+k-1])
        else:
            Ds.append(Cs[i+k-1] - Cs[i-1])

        if Ds[i] > mi:
            mi = Ds[i]
            mix = i

    
    #mix ~ mix+kまでの
    v = int()
    for i in range(k):
        v += expected_value(Ps[mix+i])
        
    print(v)

    return

if __name__ == '__main__':
    main()