// Locate the start row of a balanced contiguous validation fold, giving extra rows to earlier folds. Fold count itself returns the end sentinel. pub fn balanced_fold_start(rows: i64, folds: i64, fold: i64) -> i64 { if rows<0 || folds <= 0 || folds>rows || fold<0 || fold>folds { return -1; } let extras = rows%folds; let prior = if fold