#include #include #include #include #include #include #include using namespace std; int main() { std::map> people { }; std::map movies { }; std::cout << "On each line, enter a person's name followed" << " by their movie preferences." << std::endl << "To exit, press ctrl+D." << std::endl; std::string name; while (std::cin >> name) { std::string line; getline(std::cin, line); std::istringstream iss { line }; std::string movie; while (iss >> movie) { auto [it, success] = people[name].insert(movie); if (success) { ++movies[movie]; } } } std::cout << std::endl; std::cout << "The candidates for watching: " << std::endl; for (auto&& [movie, count] : movies) { if (count == people.size()) { std::cout << " - " << movie << std::endl; } } }