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

INDEX = -1
MA = 0
for i in range((N - K + 1)//2):
    M = 0
    L = 0
    for j in range(K):
        M += P[i + j]
        L += P[-1-i-j]
    # print(L)
    if M > MA:
        MA = M
        INDEX = i
    if L > MA:
        MA = L
        INDEX = N-K-i

ans = 0
for i in range(K):
    ans += P[i+INDEX] * (P[i+INDEX]+1) / (2*P[i+INDEX])

print("{:.12f}".format(ans))


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

INDEX = 0
total = 0
for i in range(K):
    total += P[i]

tmp = total
for i in range(N - K):
    tmp = tmp - P[i] + P[i + K]
    
    if tmp > total:
        total = tmp
        INDEX = i+1


# MA = 0
# for i in range(N - K + 1):
#     M = 0
#     for j in range(K):
#         M += P[i + j]
    
#     if M > MA:
#         MA = M
#         INDEX = i

ans = 0
for i in range(K):
    ans += P[i+INDEX] * (P[i+INDEX]+1) / (2*P[i+INDEX])

print("{:.12f}".format(ans))

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

INDEX = -1
MA = 0
for i in range(N - K + 1):
    M = 0
    for j in range(K):
        M += P[i + j]
    
    if M > MA:
        MA = M
        INDEX = i
# print(i)
ans = 0
for i in range(K):
    # print(P[i+INDEX])
    ans += P[i+INDEX] * (P[i+INDEX]+1) / (2*P[i+INDEX])
    # print(M)
    # print(i)
# print(tmp)
# ans = 0
# for t in tmp:
#     ans += t * (t + 1) / (2 * t)
print("{:.12f}".format(ans))


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

INDEX = 0
total = 0
for i in range(K):
    total += P[i]

tmp = total
for i in range(N - K):
    tmp = tmp - P[i] + P[i + K]
    
    if tmp > total:
        total = tmp
        INDEX = i+1


# MA = 0
# for i in range(N - K + 1):
#     M = 0
#     for j in range(K):
#         M += P[i + j]
    
#     if M > MA:
#         MA = M
#         INDEX = i

ans = 0
for i in range(K):
    ans += P[i+INDEX] * (P[i+INDEX]+1) / (2*P[i+INDEX])

print("{:.12f}".format(ans))

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

tmp = []
MA = 0
for i in range(N - K + 1):
    M = 0
    t = []
    for j in range(K):
        M += P[i + j]
        t.append(P[i + j])
    
    if M > MA:
        tmp = t
        MA = M



    # print(M)
    # print(i)
# print(tmp)
ans = 0
for t in tmp:
    ans += t * (t + 1) / (2 * t)
print("{:.12f}".format(ans))

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

INDEX = 0
total = 0
for i in range(K):
    total += P[i]

tmp = total
for i in range(N - K):
    tmp = tmp - P[i] + P[i + K]
    
    if tmp > total:
        total = tmp
        INDEX = i+1


# MA = 0
# for i in range(N - K + 1):
#     M = 0
#     for j in range(K):
#         M += P[i + j]
    
#     if M > MA:
#         MA = M
#         INDEX = i

ans = 0
for i in range(K):
    ans += P[i+INDEX] * (P[i+INDEX]+1) / (2*P[i+INDEX])

print("{:.12f}".format(ans))

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

tmp = []
MA = 0
for i in range(N - K + 1):
    M = 0
    t = []
    for j in range(K):
        M += P[i + j]
        t.append(P[i + j])
    
    if M > MA:
        tmp = t
        MA = M
    # elif M == MA:
    #     tmp.append(t)
    #     MA = M


    # print(M)
    # print(i)
# print(tmp)
ans = 0
for t in tmp:
    ans += t * (t + 1) / (2 * t)
print("{:.12f}".format(ans))

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

INDEX = 0
total = 0
for i in range(K):
    total += P[i]

tmp = total
for i in range(N - K):
    tmp = tmp - P[i] + P[i + K]
    
    if tmp > total:
        total = tmp
        INDEX = i+1


# MA = 0
# for i in range(N - K + 1):
#     M = 0
#     for j in range(K):
#         M += P[i + j]
    
#     if M > MA:
#         MA = M
#         INDEX = i

ans = 0
for i in range(K):
    ans += P[i+INDEX] * (P[i+INDEX]+1) / (2*P[i+INDEX])

print("{:.12f}".format(ans))