Adaptive Importance Sampling for Finite-Sum Optimization and Sampling with Decreasing Step-Sizes