func clone2D[M ~[][]T, T any](in M) (out M) {
if len(in) == 0 {
return nil
}
m, n := len(in), len(in[0])
buf := make([]T, m*n)
out = make(M, m)
for i := range out {
out[i] = buf[:n:n]
buf = buf[n:]
copy(out[i], in[i])
}
return out
}
func clone2D[M ~[][]T, T any](in M) (out M) {
if len(in) == 0 {
return nil
}
m, n := len(in), len(in[0])
buf := make([]T, m*n)
out = make(M, m)
for i := range out {
out[i] = buf[:n:n]
buf = buf[n:]
copy(out[i], in[i])
}
return out
}