Finite-Sum Coupled Compositional Stochastic Optimization: Theory and Applications