// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <fstream>
#include <string>
#include <map>

using namespace std;

int main(int argc, char *argv[])
{
    map<string,int> count;
    ifstream f(argv[1]);
    string s;
    while(f >> s)
    {
        if(count[s])
        {
            count[s]++;
        }
        else
        {
            count[s] = 1;
        }
    }
    for(map<string,int>::iterator it = count.begin(); it != count.end(); it++ )
    {
        cout << it->first << " " << it->second << endl;
    }
    return 0;
}
