add flatten.cpp