Rolling Mean and Variance in O(1) Time

Medium algorithms interview practice: Rolling Mean and Variance in O(1) Time.

You need a data structure that maintains the mean and variance of a stream of numbers, supporting O(1) insertion and O(1) query, using O(1) space and remaining numerically stable. Which algorithm should you use?