The Rolling Forecast

A stock display board smooths noisy price moves with a short rolling average so traders can spot the trend and make quick predictions about the next ticks.

You are asked to compute that rolling average for each moment in a price series, looking only at a fixed window of recent values.

The first line of the input contains two integers n and w, where n is the number of price points and w is the window size (1 ≤ w ≤ n).

The second line contains n space-separated prices (integers).
For each position i (from oldest to newest), compute the average of the last w prices up to and including the i-th price. If fewer than w prices exist yet, use all available so far.

Print n space-separated, smoothed out values.

Input

Output

6 3
10 13 7 7 20 10

10 11.5 10 9 11.333 12.333

4 2
1 2 3 4

1 1.5 2.5 3.5

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue