Count and print. C++ code:
#include <cstdio> #include <vector> #include <map> using namespace std; typedef long long int64; map<int64, int64> nInput; vector<int64> input; int64 n; int main() { // input while (scanf("%lld", &n) == 1) { if (!nInput[n]) input.push_back(n); nInput[n]++; } // output for (unsigned int i = 0; i < input.size(); ++i) printf("%lld %lld\n", input[i], nInput[input[i]]); return 0; }