OIG I - skl

// https://szkopul.edu.pl/problemset/problem/vqmkriwEfsMu-sUdZ-xpiZoB/site/?key=statement

#include <bits/stdc++.h>

std::unordered_map<int, int> m;
std::vector<int> v;

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

    int n;
    std::cin >> n;

    for (int i = 0; i < n; ++i) {
        int a, b;
        std::cin >> a >> b;

        if (m.find(a) == m.end()) {
            v.push_back(a);
        }
        m[a] += b;
    }

    std::cout << v.size() << '\n';
    for (int key : v) {
        std::cout << key << " " << m[key] << '\n';
    }

    return 0;
}