Aerobic fitness is probably the best, but some studies have shown benefits from resistance training. Stretching – used as a control at times – has not shown any benefit. In terms of duration and effort, the best evidence seems to be for what's called a dose-response curve: That is, any exercise is beneficial. If you are physically active your whole life, it is predictive of better cognitive abilities later in life.