Replace map with unordered_map. Now it is fast.