Power up

Power Up is a game mechanic in Pokémon Go that allows the player to strengthen their Pokémon by increasing their CP level.

Powering Up or leveling up Pokémon involves two items, Stardust and Candy.

How to Power Up
From the Pokémon menu, select a Pokémon you wish to Power Up. If you have the required Candy and Stardust, simply tap Power Up to increase your Pokémon's CP level. Your resources will be consumed and your Pokémon's CP level will increase. Most Pokémon award you with three of their specific candies when captured, meaning you can level up a Pokémon 3 times if it's the only one you've captured. An additional Candy can be acquired from transferring extra Pokémon to the Professor.

Stardust
Stardust is obtained by catching Pokemon or holding a Gym location for 21 hours or more and claiming its Defender Bonus.

Candy
Candy is a Pokémon specific item used to evolve your evolution-capable PokémonEvolving a Pokémon results in an immediate CP boost. At least one piece of Pokémon specific candy is also required for a basic CP Power Up.

Costs
The cost increase as each Pokémon level increases. The Stardust code is a good way to determine the Pokémon level since this value is hidden. Each power up increases the level of a Pokémon by 0.5.

The formula for Candy cost is the following:
 * $$CandyCost = \left \lfloor \frac{TrainerLevel - 1}{10} \right \rfloor + 1$$