Based on ab initio calculations, we evaluate the effectiveness of various group I, II, and IV elements as possible codopants in highly n-doped Si. The fabrication of ultrashallow junctions in future silicon technology requires the suppression of donor deactivation and diffusion during the annealing. The main goal is therefore the elimination of excess vacancies, both isolated and in donor-vacancy ͑D n V m ͒ clusters. We find that the isovalent impurities C and Ge are unsuited for the intended purpose of D n V m clustering inhibition. Alkali and earth alkaline metals, on the other hand, can partially reactivate the donors present in clusters at heavy n-type doping. Moreover, by annihilating the vacancies, they inhibit in part the vacancy-mediated donor diffusion. Magnesium and beryllium exhibit very promising properties for the codoping strategy proposed in this paper.