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

max_pos = 0
max_value = sum(P[:K])
tmp_sum = max_value
for i in range(N-K):
    tmp_sum = tmp_sum - P[i] + P[i+K]
#    print(i, max_value, tmp_sum, P[i:i+K], "-", P[i], "+", P[i+K])
    if tmp_sum > max_value:
        max_value = tmp_sum
        max_pos = i + 1

#print("--------", max_pos)
total = 0
for i in range(max_pos, max_pos + K):
    total += sum(list(range(1, P[i] + 1))) / P[i]
#    print(i, total, sum(list(range(1, P[i] + 1))) / P[i])

print(total)


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

max_pos = 0
max_value = sum(P[:K])
tmp_sum = max_value
for i in range(N-K):
    tmp_sum = tmp_sum - P[i] + P[i+K]
#    print(i, max_value, tmp_sum, P[i:i+K], "-", P[i], "+", P[i+K])
    if tmp_sum > max_value:
        max_value = tmp_sum
        max_pos = i + 1

#print("--------", max_pos)
total = 0
for i in range(max_pos, max_pos + K):
    total += (P[i] + 1) / 2
#    print(i, total, sum(list(range(1, P[i] + 1))) / P[i])

print(total)

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

max_pos = 0
max_value = 0
for i in range(len(P)):
    if i + K > len(P):
        break
    tmp_sum = sum(P[i:i+K])
#    print(i, tmp_sum, P[i:i+K])
    if tmp_sum > max_value:
        max_value = tmp_sum
        max_pos = i

#print("--------", max_pos)
total = 0
for i in range(max_pos, max_pos + K):
    total += sum(list(range(1, P[i] + 1))) / P[i]
#    print(i, total, sum(list(range(1, P[i] + 1))) / P[i])

print(total)


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

max_pos = 0
max_value = sum(P[:K])
tmp_sum = max_value
for i in range(N-K):
    tmp_sum = tmp_sum - P[i] + P[i+K]
#    print(i, max_value, tmp_sum, P[i:i+K], "-", P[i], "+", P[i+K])
    if tmp_sum > max_value:
        max_value = tmp_sum
        max_pos = i + 1

#print("--------", max_pos)
total = 0
for i in range(max_pos, max_pos + K):
    total += (P[i] + 1) / 2
#    print(i, total, sum(list(range(1, P[i] + 1))) / P[i])

print(total)

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

max_pos = 0
max_value = 0
for i in range(len(P)):
    tmp_sum = sum(P[i:i+K])
#    print(i, tmp_sum, P[i:i+K])
    if tmp_sum > max_value:
        max_value = tmp_sum
        max_pos = i

#print("--------", max_pos)
total = 0
for i in range(max_pos, max_pos + K):
    total += sum(list(range(1, P[i] + 1))) / P[i]
#    print(i, total, sum(list(range(1, P[i] + 1))) / P[i])

print(total)


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

max_pos = 0
max_value = sum(P[:K])
tmp_sum = max_value
for i in range(N-K):
    tmp_sum = tmp_sum - P[i] + P[i+K]
#    print(i, max_value, tmp_sum, P[i:i+K], "-", P[i], "+", P[i+K])
    if tmp_sum > max_value:
        max_value = tmp_sum
        max_pos = i + 1

#print("--------", max_pos)
total = 0
for i in range(max_pos, max_pos + K):
    total += (P[i] + 1) / 2
#    print(i, total, sum(list(range(1, P[i] + 1))) / P[i])

print(total)