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

int main() {
    std::vector<std::pair<int,int> > v = {{1,0},{0,1},{3,2},{6,3},{2,4},{4,5},{7,6},{5,7}};
    const int l = 2;
    const int r = 5;

    auto begin = v.begin() + l;
    auto end = v.begin() + r + 1;
    auto max_value = *std::max_element(begin, end);
    v.erase(std::remove_if(begin, end, [&](const auto& p) {return p.first != max_value.first; }), end);

    std::cout << "[";
    for (auto& p : v) {
        std::cout << "(" << p.first << ", " << p.second << ")";
    }
    std::cout << "]\n";
}
