template<typename T, typename CMP> T max(const T& left, const T& right, CMP cmp) { if (cmp(left, right)) return right; return left; }