added final c++ code with sample input