Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
 
m = [sum(P[i:i+K]) for i in range(N-K+1)]
m_index = m.index(max(m))

print(sum(map(lambda x: (x+1)/2, P[m_index:m_index+K])))

Fixed submission:
from itertools import accumulate


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


expected = [(a+1)/2 for a in A]
accum_expected = list(accumulate(expected))
accum_expected.insert(0, 0)

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

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
 
m, m_index = 0, 0
for i in range(N-K+1):
    total = sum(P[i:i+K])
    if total > m:
        m = total
        m_index = i

print(sum(map(lambda x: (x+1)/2, P[m_index:m_index+K])))

Fixed submission:
from itertools import accumulate


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


expected = [(a+1)/2 for a in A]
accum_expected = list(accumulate(expected))
accum_expected.insert(0, 0)

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

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
 
m, m_index = 0, 0
for i in range(N-K+1):
    total =sum(P[i:i+K])
    if total > m:
        m = total
        m_index = i

print(sum(map(lambda x: (x+1)/2, P[m_index:m_index+K])))

Fixed submission:
from itertools import accumulate


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


expected = [(a+1)/2 for a in A]
accum_expected = list(accumulate(expected))
accum_expected.insert(0, 0)

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

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
 
m, m_index = 0, 0
for i in range(N-K+1):
    total =sum(P[i:i+K])
    if total > m:
        m = total
        m_index = i
 
print(sum(map(lambda x: sum(list(range(1, x+1)))/x, P[m_index : m_index+K])))

Fixed submission:
from itertools import accumulate


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


expected = [(a+1)/2 for a in A]
accum_expected = list(accumulate(expected))
accum_expected.insert(0, 0)

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

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))

m, m_index = 0, 0
for i in range(N-K+1):
    total =sum(P[i:i+K])
    if total > m:
        m = total
        m_index = i

expected = 0
for p in P[m_index:m_index+K]:
    expected += sum(list(range(1, p+1)))/p
print(expected)

Fixed submission:
from itertools import accumulate


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


expected = [(a+1)/2 for a in A]
accum_expected = list(accumulate(expected))
accum_expected.insert(0, 0)

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