Apple leads midweek gains for US stocks