Frequency array
var f = Array . from ( { length : MAX + 1 } , ( _ , i ) => 0 ) ; for ( i = 0 ; i < n ; i ++ ) f [ countSetBits ( arr [ i ] ) ] ++ ; for ( i = 0 ; i <= MAX ; i ++ ) { for ( j = i ; j <= MAX ; j ++ ) {