Buggy python submission (verdict: Time Limit Exceeded):
#ABC154D
import sys

n, k = map(int, sys.stdin.readline().split())
p = list(map(int, sys.stdin.readline().split()))

ans = 0
total = 0
for i in range(n+1-k):
    total = 0
    for j in range(k):
        total += (1+p[i+j])/2
    if ans < total:
        ans = total
print(ans)

Fixed submission:
#ABC154D
import sys
N, K = map(int, sys.stdin.readline().split())
P = list(map(int, sys.stdin.readline().split()))

#print(P)

#期待値L
L = [0 for _ in range(N)]
for i in range(N):
    L[i] = (1+P[i])/2
#print(L)

#累積和S
S = [0 for i in range(N)]
S[0] = L[0]
for i in range(1, N):
    S[i] = S[i-1] + L[i]

#print(S)
total = S[K-1]
for i in range(N-K):
    tmp = S[i+K]-S[i]
    if total < tmp:
        total = tmp

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
#ABC154D
import sys

n, k = map(int, sys.stdin.readline().split())
p = list(map(int, sys.stdin.readline().split()))

total = 0
idx = 0
for i in range(n+1-k):
    tmp = sum(p[i:i+k])
    if total < tmp:
        total = tmp
        idx = i

ans = 0
for i in range(k):
    ans +=(1 + p[idx + i])/2

print(ans)

Fixed submission:
#ABC154D
import sys
N, K = map(int, sys.stdin.readline().split())
P = list(map(int, sys.stdin.readline().split()))

#print(P)

#期待値L
L = [0 for _ in range(N)]
for i in range(N):
    L[i] = (1+P[i])/2
#print(L)

#累積和S
S = [0 for i in range(N)]
S[0] = L[0]
for i in range(1, N):
    S[i] = S[i-1] + L[i]

#print(S)
total = S[K-1]
for i in range(N-K):
    tmp = S[i+K]-S[i]
    if total < tmp:
        total = tmp

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
#ABC154D
import sys

n, k = map(int, sys.stdin.readline().split())
p = list(map(int, sys.stdin.readline().split()))
L = [0 for _ in range(n)]

total = 0
idx = 0
for i in range(n+1-k):
    tmp = sum(p[i:i+k])
    if total < tmp:
        total = tmp
        idx = i

ans = 0
for i in range(k):
    ans +=(1 + p[idx + i])/2

print(ans)

Fixed submission:
#ABC154D
import sys
N, K = map(int, sys.stdin.readline().split())
P = list(map(int, sys.stdin.readline().split()))

#print(P)

#期待値L
L = [0 for _ in range(N)]
for i in range(N):
    L[i] = (1+P[i])/2
#print(L)

#累積和S
S = [0 for i in range(N)]
S[0] = L[0]
for i in range(1, N):
    S[i] = S[i-1] + L[i]

#print(S)
total = S[K-1]
for i in range(N-K):
    tmp = S[i+K]-S[i]
    if total < tmp:
        total = tmp

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
#ABC154D
import sys

n, k = map(int, sys.stdin.readline().split())
p = list(map(int, sys.stdin.readline().split()))
L = [0 for _ in range(n)]
for i in range(n):
    L[i] = (1 + p[i])/2

ans = 0
for i in range(n+1-k):
    tmp = sum(L[i:i+k])
    if ans < tmp:
        ans = tmp

print(ans)

Fixed submission:
#ABC154D
import sys
N, K = map(int, sys.stdin.readline().split())
P = list(map(int, sys.stdin.readline().split()))

#print(P)

#期待値L
L = [0 for _ in range(N)]
for i in range(N):
    L[i] = (1+P[i])/2
#print(L)

#累積和S
S = [0 for i in range(N)]
S[0] = L[0]
for i in range(1, N):
    S[i] = S[i-1] + L[i]

#print(S)
total = S[K-1]
for i in range(N-K):
    tmp = S[i+K]-S[i]
    if total < tmp:
        total = tmp

print(total)