Problem: https://www.hackerrank.com/contests/300-bai-code-thieu-nhi/challenges/dem-cap-so-1/problem
If the container has another value type with expression, we must cast it to same type in expression follow the type of container
Example:
unordered_map<long, int> mp; // Declare the umap has value type is {long, int}
int a = 1; // 4 byte
short b = 1; // 2 byte --> int has the higher priority
// Wrong:
mp[a + b] = 2; // 4 is type int, so the expression a + b is return the int value, so no long value has stored in the map. That why it's giving a wrong answer
// --> we must cast value type of expression follow the priority of container
mp[long(a) + b] = 2; // same as: mp[long(a) + long(b)] = 2;