#include <iostream>
#include <map>
using namespace std;
int main() {
map<int, int> foo = {{1, 100}, {2, 200}, {4, 400}};
map<char, int> bar = {{'1', 200}, {'3', 300}, {'5', 500}};
for(auto i = foo.begin(); i != foo.end(); ++i) {
if(bar.end() == bar.find(static_cast<decltype(bar)::key_type>(i->first) + '0')){
foo.erase(i);
}
}
for(auto i = bar.begin(); i != bar.end(); ++i) {
const decltype(foo)::key_type key = i->first - '0';
if(foo.end() == foo.find(key) || foo[key] != i->second) {
foo[key] = i->second;
}
}
for(const auto i : foo){
cout << i.first + 10 << ": " << i.second << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CgltYXA8aW50LCBpbnQ+IGZvbyA9IHt7MSwgMTAwfSwgezIsIDIwMH0sIHs0LCA0MDB9fTsKCW1hcDxjaGFyLCBpbnQ+IGJhciA9IHt7JzEnLCAyMDB9LCB7JzMnLCAzMDB9LCB7JzUnLCA1MDB9fTsKCQoJZm9yKGF1dG8gaSA9IGZvby5iZWdpbigpOyBpICE9IGZvby5lbmQoKTsgKytpKSB7CgkJaWYoYmFyLmVuZCgpID09IGJhci5maW5kKHN0YXRpY19jYXN0PGRlY2x0eXBlKGJhcik6OmtleV90eXBlPihpLT5maXJzdCkgKyAnMCcpKXsKCQkJZm9vLmVyYXNlKGkpOwoJCX0KCX0KCQoJZm9yKGF1dG8gaSA9IGJhci5iZWdpbigpOyBpICE9IGJhci5lbmQoKTsgKytpKSB7CgkJY29uc3QgZGVjbHR5cGUoZm9vKTo6a2V5X3R5cGUga2V5ID0gaS0+Zmlyc3QgLSAnMCc7CgkJCgkJaWYoZm9vLmVuZCgpID09IGZvby5maW5kKGtleSkgfHwgZm9vW2tleV0gIT0gaS0+c2Vjb25kKSB7CgkJCWZvb1trZXldID0gaS0+c2Vjb25kOwoJCX0KCX0KCQoJZm9yKGNvbnN0IGF1dG8gaSA6IGZvbyl7CgkJY291dCA8PCBpLmZpcnN0ICsgMTAgPDwgIjogIiA8PCBpLnNlY29uZCA8PCBlbmRsOwoJfQoJCglyZXR1cm4gMDsKfQ==