Maps excel at counting how often each value appears. Create a frequency map with map<int, int> freq; then increment each occurrence: freq[x]++; as you process input. The [] operator automatically creates entries with value 0 if they don't exist.
So freq[x]++ works even for the first occurrence of x without needing to check existence first. This pattern appears in problems asking for the most frequent element, detecting duplicates, grouping by value, or computing histograms.
Maps make frequency counting trivial.