Maximum Average Subarray — a fixed sliding window
The window is always k wide, so there's no need to re-add everything. Each slide adds the entering value and subtracts the leaving one. Track the largest window sum.
Try:
window sum 0
best sum 0