Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
dices = [int(c) for c in line]

max_E = 0
expectations = deque([0] * K, maxlen=K)

E = 0
for dice in dices:
    E -= expectations.popleft()
    e = sum(range(1, dice + 1)) / dice
    expectations.append(e)
    E += e
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)


Fixed submission:
from collections import deque


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
dices = [int(c) for c in line]

max_E = 0
expectations = deque([0] * K, maxlen=K)
e_memo = {}
E = 0
for dice in dices:
    E -= expectations.popleft()
    if e_memo.get(dice) is None:
        e_memo[dice] = sum(range(1, dice + 1)) / dice
    e = e_memo[dice]
    expectations.append(e)
    E += e
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
dices = [int(c) for c in line]

max_E = 0
expectations = deque([0] * K, maxlen=K)

for dice in dices:
    expectations.popleft()
    e = sum(range(1, dice + 1)) / dice
    expectations.append(e)
    E = sum(expectations)
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)


Fixed submission:
from collections import deque


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
dices = [int(c) for c in line]

max_E = 0
expectations = deque([0] * K, maxlen=K)
e_memo = {}
E = 0
for dice in dices:
    E -= expectations.popleft()
    if e_memo.get(dice) is None:
        e_memo[dice] = sum(range(1, dice + 1)) / dice
    e = e_memo[dice]
    expectations.append(e)
    E += e
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


def calc_expectation(dice):
    return sum(list(range(1, dice + 1))) / dice


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
p = [int(c) for c in line]

max_E = 0
expectations = deque(maxlen=K)
for _ in range(K):
    expectations.append(0)

for s_idx in range(0, N):
    expectations.popleft()
    dice = p[s_idx]
    e = calc_expectation(dice)
    expectations.append(e)
    E = sum(expectations)
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)


Fixed submission:
from collections import deque


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
dices = [int(c) for c in line]

max_E = 0
expectations = deque([0] * K, maxlen=K)
e_memo = {}
E = 0
for dice in dices:
    E -= expectations.popleft()
    if e_memo.get(dice) is None:
        e_memo[dice] = sum(range(1, dice + 1)) / dice
    e = e_memo[dice]
    expectations.append(e)
    E += e
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)

Buggy python submission (verdict: Time Limit Exceeded):
indices_expectation = {}
max_E = 0


def expectation(start_idx, dices):
    result = []
    for i, dice in enumerate(dices):
        if indices_expectation.get(start_idx + i) is None:
            indices_expectation[start_idx + i] = sum(list(range(1, dice + 1))) / dice
        result.append(indices_expectation[start_idx + i])
    return sum(result)


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
p = [int(c) for c in line]

for s_idx in range(0, N - K + 1):
    dices = p[s_idx:s_idx + K]
    E = expectation(s_idx, dices)
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)


Fixed submission:
from collections import deque


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
dices = [int(c) for c in line]

max_E = 0
expectations = deque([0] * K, maxlen=K)
e_memo = {}
E = 0
for dice in dices:
    E -= expectations.popleft()
    if e_memo.get(dice) is None:
        e_memo[dice] = sum(range(1, dice + 1)) / dice
    e = e_memo[dice]
    expectations.append(e)
    E += e
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)