#include #include #include #include using namespace std; const int size = 20000; int C[size]; // this counts the number of strings that share each possible hash value const int max_occurs = 20; int occurs[max_occurs]; // this counts the number of times each linked list length occurs int hash(string s) { int value = 79561; for (int i = 0; i < s.length(); i += 1) value = value * 69 + s[i]; if (value < 0) value = - value; return value % size; } int main() { for (int i = 0; i < size; i += 1) C[i] = 0; for (int i = 0; i < max_occurs; i += 1) occurs[i] = 0; while (true) { string s; cin >> s; if (cin.fail()) break; int pos = hash(s); C[pos] += 1; } for (int i = 0; i < size; i += 1) if (C[i] < max_occurs) occurs[C[i]] += 1; for (int i = 0; i < max_occurs; i += 1) cout << i << ": " << occurs[i] << "\n"; }