Consensus and profile solved in C++