include cstdlib to use std::abs for int type