Towards Compute-Optimal Many-Shot In-Context Learning