哈希
#include <iostream>
#include <map>
#include <unordered_map>
using namespace std;
int main() {
int n;
while (cin >> n) {
map<int, int> tmp_map;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
int iter = tmp_map.count(a);
if (iter) {
tmp_map[a] += b;
}
else
tmp_map[a] = b;
}
for (auto i : tmp_map)
cout << i.first << " " << i.second << endl;
}
return 0;
}