Reinterpreting the Pavani's restriction #6.
Reduding unecessary work.
Using Boost's hashmap.
Sorting the results.