/* reads whole lines from stdin and counts how many times each was repeated, overall and NOT "adjacently" by bliako, 25.06.2019 for https://perlmonks.org/?displaytype=edit;node_id=11101856 g++ -O puniq.cpp -o puniq */ #include #include using namespace std; int main(void){ unordered_map uniq; string aline; while(getline(cin, aline)){ if( uniq.count(aline) == 0 ) uniq[aline] = 1; else uniq[aline]++; } for(unordered_map::iterator itr=uniq.begin();itr!=uniq.end();itr++){ cout << itr->first << " => " << itr->second << endl; } }