Understanding doping at the nanoscale: the case of codoped Si and Ge nanowires