#include<bits/stdc++.h>
using namespace std;
void pMap(map<string,int> m){
cout << "size = " << m.size() << endl;
for(auto it = m.begin();it != m.end();++it){
cout << it->first << " " << it->second << endl;
//cout << (*it).first << " " << (*it).second << endl;
// string s = it->first;
// cout << s << " " << m[s] << endl;
}
for(const auto &pair : m){
cout << pair.first << " " << pair.second << endl;
}
cout << endl;
}
int main(){
map<string,int> m;
//basic initialization
// m["date"] = 22;
// m["month"]; //declared and initialized to zero.
// m["month"] = 05, m["year"] = 2004;
// pMap(m);
//initializing using pair.
// m.insert({"Date",22});
// m.insert(make_pair("month",05));
// m["year"];
// m.insert({"year",2004});
// pMap(m);
// //insert() doesnt update pre-existent keys!!!
// m["year"] = 2004;
// pMap(m);
//using find(key):return an it for the key.
// map<int,int> m2 = {{1,6},{2,8},{4,9}};
// int n; cin >> n;
// auto it = m2.find(n); // return an it for the key 1;
// it == m2.end() ? cout << "not found\n" : cout << "found\n";
//using erase(key/it) to erase a particular element from the map.
// map<int,int> m2 = {{1,6},{2,8},{4,9}};
// int n; cin >> n;
// auto it = m2.find(n); // return an it for the key 1;
// if(it != m2.end()) m2.erase(it);
// else cout << "not found\n";
//pMap(m2);
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZvaWQgcE1hcChtYXA8c3RyaW5nLGludD4gbSl7Cgljb3V0IDw8ICJzaXplID0gIiA8PCBtLnNpemUoKSA8PCBlbmRsOwoJZm9yKGF1dG8gaXQgPSBtLmJlZ2luKCk7aXQgIT0gbS5lbmQoKTsrK2l0KXsKCQljb3V0IDw8IGl0LT5maXJzdCA8PCAiICIgPDwgaXQtPnNlY29uZCA8PCBlbmRsOwoJCS8vY291dCA8PCAoKml0KS5maXJzdCA8PCAiICIgPDwgKCppdCkuc2Vjb25kIDw8IGVuZGw7CgkJLy8gc3RyaW5nIHMgPSBpdC0+Zmlyc3Q7CgkJLy8gY291dCA8PCBzIDw8ICIgIiA8PCBtW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