I was solving this task: https://oj.uz/problem/view/IOI17_mountains. The first submission got 20 points (brute-force using bitsets). The second submission got 70 points because I used memoization. After that, I wrote my own bitset with custom hash and got 100! Can someone suggest why the number of different bitsets is $$$O(n^2)$$$?