static List<Integer> removeAll(List<Integer> list, final int repeat) {
        if (repeat < 1 || list == null) throw new IllegalArgumentException();

        final Map<Integer, Integer> index = new HashMap<>();
        for (Integer n : list) {
            Integer count = index.get(n);
            if (count == null) {
                index.put(n, 1);
            } else {
                count++;
                index.put(n, count);
            }
        }

        List<Integer> result = new ArrayList<>();
        for (Integer n : list) {
            if (index.get(n) < repeat) result.add(n);
        }

        return result;
    }