Hong raises an army with n Orcs. Each Orc has health-point and attack-point, which can be expressed by two positive integers, hp and atk. Hong is a gifted wizard, who masters two powerful spells. One is Divine Spirit, which can double one Orc's hp. The other is Inner Fire, changing one Orc's atk to be equal to its hp.
Hong can cast Divine Spirit at most p times, and Inner Fire q times. He wants to know the maximum sum of the attack-point of all his Orcs after casting two kinds of spells. (You can cast no spells as you wish.)