Effect of static local distortions vs. dynamic motions on the stability and band gaps of cubic oxide and halide perovskites. (October 2021)