How do changes in average and marginal productivity affaect the cost of production?