function main() {
var targetCPA = 100;
var productGroupSelector = AdWordsApp
.productGroups()
.withCondition("Impressions > 100")
.forDateRange("LAST_7_DAYS")
.orderBy("Clicks DESC");
var productGroupIterator = productGroupSelector.get();
while (productGroupIterator.hasNext()) {
var productGroup = productGroupIterator.next();
var conversionRate = productGroup.getStatsFor("LAST_7_DAYS").getConversionRate();
productGroup.setMaxCpc(targetCPA * conversionRate)
}
}