Convert all frequencies to nearest smaller even values .
vector < int > arr1 ; for ( auto i : freq_2 ) arr1 . push_back ( ( i . first ) * ( freq_2 [ ( i . first ) ] / 2 ) * 2 ) ; sort ( arr1 . begin ( ) , arr1 . end ( ) ) ;