Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
dice = list(map(int,input().split()))



max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = sum(dice[i:k+i])
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += (dice[max_i+i]-1)*0.5+1
print(sum_odds)

Fixed submission:
n,k = map(int,input().split())
dice = list(map(int,input().split()))

dice_cumsum = [0]*(n+1)

for i in range(1,n+1):
    dice_cumsum[i] = dice_cumsum[i-1] + dice[i-1]
    
max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = dice_cumsum[k+i] - dice_cumsum[i]
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += (dice[max_i+i]-1)*0.5+1

print(sum_odds)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
dice = list(map(int,input().split()))



max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = sum(dice[i:k+i])
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += (dice[max_i+i]-1)*0.5+1
print(sum_odds)

Fixed submission:
n,k = map(int,input().split())
dice = list(map(int,input().split()))

dice_cumsum = [0]*(n+1)

for i in range(1,n+1):
    dice_cumsum[i] = dice_cumsum[i-1] + dice[i-1]
    
max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = dice_cumsum[k+i] - dice_cumsum[i]
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += (dice[max_i+i]-1)*0.5+1

print(sum_odds)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
dice = list(map(int,input().split()))

dice_cumsum = [0]*200001
dice_cumsum[1] = 1

for i in range(2,200001):
    dice_cumsum[i] = dice_cumsum[i-1]+i


max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = sum(dice[i:k+i])
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += dice_cumsum[dice[max_i+i]]/dice[max_i+i]
    
print(sum_odds)

Fixed submission:
n,k = map(int,input().split())
dice = list(map(int,input().split()))

dice_cumsum = [0]*(n+1)

for i in range(1,n+1):
    dice_cumsum[i] = dice_cumsum[i-1] + dice[i-1]
    
max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = dice_cumsum[k+i] - dice_cumsum[i]
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += (dice[max_i+i]-1)*0.5+1

print(sum_odds)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
dice = list(map(int,input().split()))

odds = list(map(lambda x: 0.5*(x-1)+1,dice))

max_n = 0
for i in range(n-k+1):
    sum_odds = sum(odds[i:k+i])
    if sum_odds > max_n:
        max_n = sum_odds


        
print(max_n)

Fixed submission:
n,k = map(int,input().split())
dice = list(map(int,input().split()))

dice_cumsum = [0]*(n+1)

for i in range(1,n+1):
    dice_cumsum[i] = dice_cumsum[i-1] + dice[i-1]
    
max_n = 0
max_i = 0
for i in range(n-k+1):
    sum_dice = dice_cumsum[k+i] - dice_cumsum[i]
    if sum_dice > max_n:
        max_n = sum_dice
        max_i = i

sum_odds = 0
for i in range(k):
    sum_odds += (dice[max_i+i]-1)*0.5+1

print(sum_odds)