US indices post largest weekly gains in months