Counting frequencies or mapping names to values needs a key to value lookup. map keeps keys sorted with O(log n) operations, while unordered_map is a hash table with O(1) average. Use unordered_map for plain counting and map when you need sorted keys or lower_bound. Beware that m[key] inserts a default value if the key is missing, so use count or find just to check.