#include <iostream>
#include <map>
namespace std
{
template<typename Iter, typename = typename iterator_traits<Iter>::iterator_category>
Iter begin(pair<Iter, Iter> const &p)
{
return p.first;
}
template<typename Iter, typename = typename iterator_traits<Iter>::iterator_category>
Iter end(pair<Iter, Iter> const &p)
{
return p.second;
}
}
int main()
{
std::multimap<int, int> mm
{
{1, 1},
{1, 2},
{2, 1},
{2, 2}
};
for(auto &v : mm.equal_range(1))
{
std::cout << v.first << " -> " << v.second << std::endl;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgoKbmFtZXNwYWNlIHN0ZAp7CiAgICB0ZW1wbGF0ZTx0eXBlbmFtZSBJdGVyLCB0eXBlbmFtZSA9IHR5cGVuYW1lIGl0ZXJhdG9yX3RyYWl0czxJdGVyPjo6aXRlcmF0b3JfY2F0ZWdvcnk+CiAgICBJdGVyIGJlZ2luKHBhaXI8SXRlciwgSXRlcj4gY29uc3QgJnApCiAgICB7CiAgICAgICAgcmV0dXJuIHAuZmlyc3Q7CiAgICB9CiAgICB0ZW1wbGF0ZTx0eXBlbmFtZSBJdGVyLCB0eXBlbmFtZSA9IHR5cGVuYW1lIGl0ZXJhdG9yX3RyYWl0czxJdGVyPjo6aXRlcmF0b3JfY2F0ZWdvcnk+CiAgICBJdGVyIGVuZChwYWlyPEl0ZXIsIEl0ZXI+IGNvbnN0ICZwKQogICAgewogICAgICAgIHJldHVybiBwLnNlY29uZDsKICAgIH0KfQoKaW50IG1haW4oKQp7CglzdGQ6Om11bHRpbWFwPGludCwgaW50PiBtbQoJewoJCXsxLCAxfSwKCQl7MSwgMn0sCgkJezIsIDF9LAoJCXsyLCAyfQoJfTsKCWZvcihhdXRvICZ2IDogbW0uZXF1YWxfcmFuZ2UoMSkpCgl7CgkJc3RkOjpjb3V0IDw8IHYuZmlyc3QgPDwgIiAtPiAiIDw8IHYuc2Vjb25kIDw8IHN0ZDo6ZW5kbDsKCX0KfQo=