class StatsEntry implements Comparable<StatsEntry> {
        int segments;
        int count;
        final MinMaxAvgLong segStats = new MinMaxAvgLong();
        final MinMaxAvgLong length = new MinMaxAvgLong();
        final MinMaxAvgLong overhead = new MinMaxAvgLong();

        public StatsEntry(int segments) {
            assert segments >= 1 : "segments: " + segments + " < 1";
            this.segments = segments;
        }

        public void add(int segments, int length, int overhead) {
            count++;
            this.segStats.add(segments);
            this.length.add(length);
            this.overhead.add(overhead);
        }

        public void add(@NotNull StatsEntry other) {
            count += other.count;
            this.segStats.add(other.segStats);
            this.length.add(other.length);
            this.overhead.add(other.overhead);
        }

        @Override
        public int compareTo(@NotNull SegmentedSequenceStats.StatsEntry o) {
            int segs = Integer.compare(segments, o.segments);
            if (segs != 0) return segs;
            else return Integer.compare(count, o.count);
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            return segments == ((StatsEntry) o).segments;
        }

        @Override
        public int hashCode() {
            return segments;
        }
    }

    private ArrayList<SegmentedSequenceStats.StatsEntry> aggregatedStats;
    final private HashMap<StatsEntry, StatsEntry> stats = new HashMap<>();

    private SegmentedSequenceStats() {

    }

    public void addStats(int segments, int length, int overhead) {
        StatsEntry entry = new StatsEntry(segments);
        entry = stats.computeIfAbsent(entry, k -> k);
        entry.add(segments, length, overhead);
    }

    public int getCount(int segments) {
        StatsEntry entry = new StatsEntry(segments);
        if (stats.containsKey(entry)) {
            return stats.get(entry).count;
        }
        return 0;
    }

    @NotNull
    public String getStatsText(List<StatsEntry> entries) {<FILL_FUNCTION_BODY>

        StringBuilder out = new StringBuilder();
        int iMax = entries.size();

        out.append(
                String.format("%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%8s",
                        "count",
                        "min-seg",
                        "avg-seg",
                        "max-seg",
                        "min-len",
                        "avg-len",
                        "max-len",
                        "min-ovr",
                        "avg-ovr",
                        "max-ovr",
                        "tot-len",
                        "tot-chr",
                        "tot-ovr",
                        "ovr %"
                )
        ).append("\n");

        for (int i = iMax; i-- > 0; ) {
            StatsEntry entry = entries.get(i);
            out.append(
                    String.format("%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%8.3f",
                            entry.count,
                            entry.count == 1 ? entry.segments : entry.segStats.getMin(),
                            entry.count == 1 ? entry.segments : entry.segStats.getAvg(entry.count),
                            entry.count == 1 ? entry.segments : entry.segStats.getMax(),
                            entry.length.getMin(),
                            entry.length.getAvg(entry.count),
                            entry.length.getMax(),
                            entry.overhead.getMin(),
                            entry.overhead.getAvg(entry.count),
                            entry.overhead.getMax(),
                            entry.length.getTotal(),
                            entry.length.getTotal() * 2,
                            entry.overhead.getTotal(),
                            entry.length.getTotal() == 0 ? 0 : 100.0 * entry.overhead.getTotal() / entry.length.getTotal() / 2.0
                    )
            ).append("\n");
        }
        return out.toString();
    
<no_super_class>