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

dic = {}

max_dice = 0
for i in range(K-1, N):
    tmp_dice = 0
    for j in range(i - K + 1, i + 1):
        if p[j] in dic:
            tmp_kitai = dic[p[j]]
        else:
            tmp_kitai = (p[j] + 1) / 2
            dic[p[j]] = tmp_kitai
        tmp_dice += tmp_kitai
    if tmp_dice > max_dice:
        max_dice = tmp_dice
print(max_dice)

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

dp = [0] * (N)
dp_sub = [0] * (N)

dp[0] = (p[0] + 1) / 2
dp_sub[0] = (p[0] + 1) / 2

for i in range(1, K):
    dp_sub[i] = (p[i] + 1) / 2
    dp[i] = dp[i - 1] + dp_sub[i]

for i in range(K, N):
    dp_sub[i] = (p[i] + 1) / 2
    dp[i] = dp[i - 1] + dp_sub[i] - dp_sub[i-K]
    
print(max(dp))

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

dic = {}

max_dice = 0
for i in range(K-1, N):
    tmp_dice = 0
    for j in range(i - K + 1, i + 1):
        if p[j] in dic:
            tmp_kitai = dic[p[j]]
        else:
            tmp_kitai = 0
            for k in range(p[j]):
                tmp_kitai += (k + 1)
            tmp_kitai = tmp_kitai / p[j]
            dic[p[j]] = tmp_kitai
        tmp_dice += tmp_kitai
    if tmp_dice > max_dice:
        max_dice = tmp_dice
print(max_dice)

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

dp = [0] * (N)
dp_sub = [0] * (N)

dp[0] = (p[0] + 1) / 2
dp_sub[0] = (p[0] + 1) / 2

for i in range(1, K):
    dp_sub[i] = (p[i] + 1) / 2
    dp[i] = dp[i - 1] + dp_sub[i]

for i in range(K, N):
    dp_sub[i] = (p[i] + 1) / 2
    dp[i] = dp[i - 1] + dp_sub[i] - dp_sub[i-K]
    
print(max(dp))

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

max_dice = 0
for i in range(K-1, N):
    tmp_dice = 0
    for j in range(i - K + 1, i + 1):
        tmp_kitai = 0
        for k in range(p[j]):
            tmp_kitai += (k + 1)
        tmp_kitai = tmp_kitai / p[j]
        tmp_dice += tmp_kitai
    if tmp_dice > max_dice:
        max_dice = tmp_dice
print(max_dice)

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

dp = [0] * (N)
dp_sub = [0] * (N)

dp[0] = (p[0] + 1) / 2
dp_sub[0] = (p[0] + 1) / 2

for i in range(1, K):
    dp_sub[i] = (p[i] + 1) / 2
    dp[i] = dp[i - 1] + dp_sub[i]

for i in range(K, N):
    dp_sub[i] = (p[i] + 1) / 2
    dp[i] = dp[i - 1] + dp_sub[i] - dp_sub[i-K]
    
print(max(dp))

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

max_dice = 0
for i in range(K-1, N):
    tmp_dice = 0
    for i in range(i - K + 1, i + 1):
        tmp_kitai = 0
        for j in range(p[i]):
            tmp_kitai += (j + 1)
        tmp_kitai = tmp_kitai / p[i]
        tmp_dice += tmp_kitai
    if tmp_dice > max_dice:
        max_dice = tmp_dice
print(max_dice)

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

dp = [0] * (N)
dp_sub = [0] * (N)

dp[0] = (p[0] + 1) / 2
dp_sub[0] = (p[0] + 1) / 2

for i in range(1, K):
    dp_sub[i] = (p[i] + 1) / 2
    dp[i] = dp[i - 1] + dp_sub[i]

for i in range(K, N):
    dp_sub[i] = (p[i] + 1) / 2
    dp[i] = dp[i - 1] + dp_sub[i] - dp_sub[i-K]
    
print(max(dp))