// uses https://github.com/greg7mdp/sparsepp #include #include #include "sparsepp/spp.h" #include using spp::sparse_hash_map; using namespace std; bool compare(std::pair const & a, std::pair const & b) { return b.second < a.second; } int main() { std::ios::sync_with_stdio(false); string s; sparse_hash_map count; while (cin >> s) { count[s]++; } vector > temp(count.begin(), count.end()); sort(temp.begin(), temp.end(), compare); for (std::size_t i = 0; i < temp.size(); ++i) cout << temp[i].second << " " << temp[i].first << "\n"; }