MIN Use range instead of xrange

k is a small value anyway and this way we are Python2/3 independent