#include <map>
#include <string>
#include <sstream>
#include <iomanip>
#include <iostream>

int main()
{
    std::map< unsigned char, char > look_up ;

    // populate the map with data from the stream containing the table
    {
        std::istringstream stream( "61=M \n 62=N \n 63=O \n 64=P \n 65=Q \n" ) ;
        std::string byte ;
        char separator ;
        char data ;
        while( stream >> std::setw(2) >> byte >> separator >> data && separator == '=' )
        {
            // look_up[ std::stoi(byte,nullptr,16) ] = data ;

            std::istringstream stm(byte) ;
            int key ;
            stm >> std::hex >> key ;
            look_up[key] = data ;
        }
    }

    // use the map to translate the input data
    {
        std::istringstream stm( "abcdexedcbayaedbc" ) ;
        unsigned char byte ;
        while( stm >> byte )
        {
            auto p = look_up.find(byte) ;
            if( p != look_up.end() ) std::cout << p->second ;
            else std::cout << char(byte) ; // lookup failed
        }
    }
}
