Heavy flavor production in pp and AA collisions at the LHC