Adding cp.cpp from my end