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

    for i in range(N-K+1):
        max_total = max(max_total, sum(P[i:i+K]))

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


if __name__ == '__main__':
    solve()

Fixed submission:
from itertools import accumulate

N, K = map(int, input().split())
P = map(int, input().split())
acc_P = list(accumulate(P))
ans = (acc_P[K-1] + K) / 2

for i in range(N-K):
    ans = max(ans, (acc_P[i+K] - acc_P[i] + K) / 2)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

for i in range(N-K+1):
    max_total = max(max_total, sum(P[i:i+K]))

ans = (max_total + K) / 2

print(ans)

Fixed submission:
from itertools import accumulate

N, K = map(int, input().split())
P = map(int, input().split())
acc_P = list(accumulate(P))
ans = (acc_P[K-1] + K) / 2

for i in range(N-K):
    ans = max(ans, (acc_P[i+K] - acc_P[i] + K) / 2)

print(ans)

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

for i in range(N-K+1):
    max_total = max(max_total, sum(P[i:i+K]))

ans = (max_total + K) / 2

print(ans)

Fixed submission:
from itertools import accumulate

N, K = map(int, input().split())
P = map(int, input().split())
acc_P = list(accumulate(P))
ans = (acc_P[K-1] + K) / 2

for i in range(N-K):
    ans = max(ans, (acc_P[i+K] - acc_P[i] + K) / 2)

print(ans)

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

for i in range(N-K+1):
    total = sum(P[i:i+K])
    if total > max_total:
        max_total = total
        ans = sum(map(lambda x: (x + 1) / 2, P[i:i+K]))

print(ans)

Fixed submission:
from itertools import accumulate

N, K = map(int, input().split())
P = map(int, input().split())
acc_P = list(accumulate(P))
ans = (acc_P[K-1] + K) / 2

for i in range(N-K):
    ans = max(ans, (acc_P[i+K] - acc_P[i] + K) / 2)

print(ans)

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

for i in range(N-K+1):
    expected = sum(map(lambda x: (x + 1) / 2, P[i:i+K]))
    ans = max(ans, expected)

print(ans)

Fixed submission:
from itertools import accumulate

N, K = map(int, input().split())
P = map(int, input().split())
acc_P = list(accumulate(P))
ans = (acc_P[K-1] + K) / 2

for i in range(N-K):
    ans = max(ans, (acc_P[i+K] - acc_P[i] + K) / 2)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = map(int, input().split())
avg = list(map(lambda x: (x + 1) / 2, P))
ans = 0

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

print(ans)

Fixed submission:
from itertools import accumulate

N, K = map(int, input().split())
P = map(int, input().split())
acc_P = list(accumulate(P))
ans = (acc_P[K-1] + K) / 2

for i in range(N-K):
    ans = max(ans, (acc_P[i+K] - acc_P[i] + K) / 2)

print(ans)