Fundamentals of CostEfficient AI