Distance and FindNearestCentroid to C-style