JAVA Short Solution Using HashMap
\nclass Solution {\n    public long countExcellentPairs(int[] nums, int k) {\n        HashMap<Integer, Long> map = new HashMap<>();\n        \n        long resu
```\nclass Solution {\n    public long countExcellentPairs(int[] nums, int k) {\n        HashMap<Integer, Long> map = new HashMap<>();\n        \n        long result = 0;\n        HashSet<Integer> noDuplicate = new HashSet<>();\n        ArrayList<Integer> newNums = new ArrayList<>();\n        for (int i = 0; i < nums.length; i++) {\n            if (noDuplicate.add(nums[i])) {\n                newNums.add(nums[i]);\n            }\n        }\n    \n        for (Integer newNum : newNums) {\n            int bits = getBits(newNum);\n            long numbersHave = map.getOrDefault(bits, 0l);\n            map.put(bits, numbersHave + 1);\n        }\n        long sum = 0;\n    \n        for (Integer newNum : newNums) {\n            int bits = getBits(newNum);\n            for (Integer key : map.keySet()) {\n                if (key + bits >= k) sum += map.get(key);\n            }\n        }\n        \n        return sum;\n    }\n    \n    int getBits(int i) {\n        int count = 0;\n        while (i > 0) {\n            i = i & (i - 1);\n            count++;\n        }\n        \n        return count;\n    }\n}\n```
['Java']