public static <T> List<List<T>> partition(List<T> list, int size) {
    List<List<T>> res = new ArrayList<>();
    int loaded = 0, total = list.size();
    while (loaded < total) {
      int chunkSize = Math.min(size, total - loaded);
      res.add(list.subList(loaded, loaded + chunkSize));
      loaded += chunkSize;
    }
    return res;
  }
public static <T> List<List<T>> partition(List<T> list, int size)