C++ Solution with Proper comments
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    long long countExcellentPairs(vector<int>& A, int k) {
        vector<long long> cnt(31,0LL);
        unordered_set<int> a;
        for(auto &op : A){
            a.insert(op);
        }
        for(auto &op : a){
            cnt[__builtin_popcount(op)]++;
        }
        long long ans  = 0;
        for(int i = 0;i<31;i++){
            for(int j = 0;j<31;j++){
                if(i+j>=k){
                    if(i==j){
                        // here if we have eqal then we can choose two different also from the 
                        // same group or array you can say , but we can permute it also
                        // nc2(selecting two elements) * 2!(permuting two elements)
                        // n(n-1)/2 *2 === n(n-1)

                        // and then one more case where we will choose the same element twice
                        // so if group size is n then we can choose n elements;

                        // total = n(n-1) + n
                        // n * n

                        ans += (cnt[i] * cnt[j]); 
                    }else{
                       // m and n elements lets say choose one from  first and one from second
                       // the number of ways will be m * n
                        ans += (cnt[i] * cnt[j]);
                    }
                }
            }
        }
        return ans;
    }
};
```
['Bit Manipulation', 'C++']