"""
Exercise 1: Moving Average from Data Stream (LeetCode 346)

MovingAverage(size) keeps the last `size` values; next(val) adds val and
returns the average of the window. Make next() O(1): keep a deque and a
running sum.
"""

class MovingAverage:
    def __init__(self, size):
        # TODO
        pass

    def next(self, val):
        # TODO
        return 0.0


# --- self-check: do not modify below this line ---
m = MovingAverage(3)
got = [m.next(v) for v in [1, 10, 3, 5]]
want = [1.0, 5.5, 14 / 3, 6.0]
print(got)
ok = all(abs(a - b) < 1e-9 for a, b in zip(got, want)) and len(got) == 4
print("PASS" if ok else "FAIL")
