Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
# 期待値
E = [(p+1)/2 for p in P]
#print(E)
# 隣接K個の和
ans = 0
for i in range(K, N+1):
    tmp_e = sum(E[i-K: i])
    #print(i, tmp_e)
    ans = max(ans, tmp_e)
print(ans)

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

# 期待値
E = [(p+1)/2 for p in P]
#print(E)

# 累積和
S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + E[i]
#print(S)

# 隣接K個を取り出して足す
max_E = 0
for i in range(N-K+1):
    tmp_E = S[i+K] - S[i]
    #print(tmp_E)
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

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

from collections import deque
P_dq = deque(P, N)

P_sum = P
for i in range(K-1):
    P_dq.append(0)
    P_sum = list(map(sum, zip(P_sum, P_dq)))

max_sum = max(P_sum)

max_E = (max_sum + K) / 2
print(max_E)

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

# 期待値
E = [(p+1)/2 for p in P]
#print(E)

# 累積和
S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + E[i]
#print(S)

# 隣接K個を取り出して足す
max_E = 0
for i in range(N-K+1):
    tmp_E = S[i+K] - S[i]
    #print(tmp_E)
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

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

P_total = sum(P)

max_sum = 0

if K < (N/2):
    for i in range(N-K+1):
        tmp_sum = sum(P[i:i+K])
        if tmp_sum > max_sum:
            max_sum = tmp_sum
else:
    for i in range(N-K+1):
        tmp_sum = P_total - sum(P[0:i]) - sum(P[i+K:])
        if tmp_sum > max_sum:
            max_sum = tmp_sum

max_E = (max_sum + K) / 2
print(max_E)

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

# 期待値
E = [(p+1)/2 for p in P]
#print(E)

# 累積和
S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + E[i]
#print(S)

# 隣接K個を取り出して足す
max_E = 0
for i in range(N-K+1):
    tmp_E = S[i+K] - S[i]
    #print(tmp_E)
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

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

max_sum = 0
for i in range(N-K+1):
    tmp_sum = sum(P[i:i+K])
    if tmp_sum > max_sum:
        max_sum = tmp_sum

max_E = (max_sum + K) / 2
print(max_E)

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

# 期待値
E = [(p+1)/2 for p in P]
#print(E)

# 累積和
S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + E[i]
#print(S)

# 隣接K個を取り出して足す
max_E = 0
for i in range(N-K+1):
    tmp_E = S[i+K] - S[i]
    #print(tmp_E)
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

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

max_E = 0
for i in range(N-K+1):
    tmp_E = (sum(P[i: i+K]) + K) / 2
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

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

# 期待値
E = [(p+1)/2 for p in P]
#print(E)

# 累積和
S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + E[i]
#print(S)

# 隣接K個を取り出して足す
max_E = 0
for i in range(N-K+1):
    tmp_E = S[i+K] - S[i]
    #print(tmp_E)
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

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

# 期待値配列
E = [(p+1)/2 for p in P]

# 隣接K個を取り出して足す
max_E = 0
for i in range(N-K+1):
    tmp_E = sum(E[i: i+K])
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

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

# 期待値
E = [(p+1)/2 for p in P]
#print(E)

# 累積和
S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + E[i]
#print(S)

# 隣接K個を取り出して足す
max_E = 0
for i in range(N-K+1):
    tmp_E = S[i+K] - S[i]
    #print(tmp_E)
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)