#include <iostream>
#include <map>
#include <string>
#include <ctime>
#include <cstdlib>
#include <iterator>
int main ()
{
std::srand(std::time(nullptr));
std::multimap<std::string, int> mymm;
mymm.emplace("Hello", 50);
mymm.emplace("Bye", 100);
mymm.emplace("Bye", 150);
mymm.emplace("Bye", 200);
mymm.emplace("?", 250);
mymm.emplace("?", 300);
auto range = mymm.equal_range("Bye");
auto count = std::distance(range.first, range.second);
if (count != 0) {
auto it = std::next(range.first, std::rand() % count);
std::cout << it -> second;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8Y3RpbWU+CiNpbmNsdWRlIDxjc3RkbGliPgojaW5jbHVkZSA8aXRlcmF0b3I+CgoKaW50IG1haW4gKCkKewogICAgc3RkOjpzcmFuZChzdGQ6OnRpbWUobnVsbHB0cikpOwogICAgc3RkOjptdWx0aW1hcDxzdGQ6OnN0cmluZywgaW50PiBteW1tOwoKICAgIG15bW0uZW1wbGFjZSgiSGVsbG8iLCA1MCk7CiAgICBteW1tLmVtcGxhY2UoIkJ5ZSIsICAxMDApOwogICAgbXltbS5lbXBsYWNlKCJCeWUiLCAgMTUwKTsKICAgIG15bW0uZW1wbGFjZSgiQnllIiwgIDIwMCk7CiAgICBteW1tLmVtcGxhY2UoIj8iLCAgICAyNTApOwogICAgbXltbS5lbXBsYWNlKCI/IiwgICAgMzAwKTsKCiAgICBhdXRvIHJhbmdlID0gbXltbS5lcXVhbF9yYW5nZSgiQnllIik7CiAgICBhdXRvIGNvdW50ID0gc3RkOjpkaXN0YW5jZShyYW5nZS5maXJzdCwgcmFuZ2Uuc2Vjb25kKTsKICAgIGlmIChjb3VudCAhPSAwKSB7CiAgICAgICAgYXV0byBpdCA9IHN0ZDo6bmV4dChyYW5nZS5maXJzdCwgc3RkOjpyYW5kKCkgJSBjb3VudCk7CiAgICAgICAgc3RkOjpjb3V0IDw8IGl0IC0+IHNlY29uZDsKICAgIH0KfQ==