#include <iostream>
#include <map>
using namespace std;
int main()
{
map<string, int> words;
for(string s; cin >> s;)
++words[s];
for(const auto& p :words)
cout << p.first << ": " << p.second << "\n";
}
The elements of a map<string,int> are of type pair<string,int>;
The first member of a pair is called first and the second member second.