The Principle of Least Action in Geometry and Dynamics