standard library: 'max' and 'min' functions reimplemented to avoid unnecessary null checks

(as proposed for minBy/maxBy in https://github.com/JetBrains/kotlin/pull/324)