Added copy_atmost_n algorithm.