faster selectgreedy cpp