Amla, Cook lead South Africa to 329-5