Cost minimizing combination of inputs