Dow, S&P 500 book biggest gains of year