map<string, set<string>> mp; for (auto const& pair : mp) { cout << pair.first << ": "; for (auto const& elem : pair.second) { cout << elem << ", "; } cout << " "; }