#include <vector>
#include <algorithm>
#include <iostream>

int main() {
    std::vector<std::pair<int, int>> data {{7, 1}, {3, 2}, {8, 0}, {5, 1}, {3, 1},
                                           {2, 0}, {7, 0}, {6, 0}, {5, 0}, {3, 0}};
    
    std::stable_sort(std::begin(data), std::end(data), [](auto const &a, auto const &b){
    	return a.first < b.first;
    });

    for (auto const &p : data)
        std::cout << p.first << " " << p.second << std::endl;

	return 0;
}