Easy Java solution || 2 pointers
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nimport java.util.*;\nimport java.io.*;\nclass Solution {\n    public int countSetBits(int x){\n        int ans = 0;\n        while(x != 0){\n            x = (x & (x - 1));\n            ans++;\n        }\n        return ans;\n    }\n    public long countPairs1(List<Integer> list, int n, int k){\n        long count = 0;\n        int left = 0;\n        int right = n - 1;\n\n        while (left < right) {\n            if (list.get(left) + list.get(right) >= k) {\n                // If arr[left] + arr[right] >= k, then all pairs (left, left+1), (left, left+2), ..., (left, right-1)\n                // will also have sums >= k because the array is sorted\n                count += (right - left);\n                right--;  // Move the right pointer to the left\n            } else {\n                left++;  // Move the left pointer to the right\n            }\n        }\n\n        return count;\n    }\n    public long countPairs2(List<Integer> list, int n, int k){\n        long ans = 0;\n        k = (int)(Math.ceil(k / 2.0));\n        for(int x: list){\n            if(x >= k) ans++;\n        }\n        return ans;\n    }\n    public long countExcellentPairs(int[] arr, int k) {\n        List<Integer> singleList = new ArrayList<>();\n        List<Integer> dupList = new ArrayList<>();\n        HashMap<Integer, Integer> map = new HashMap<>();\n        int n = arr.length;\n        for(int i = 0; i < n; i++){\n            map.put(arr[i], map.getOrDefault(arr[i], 0) + 1);\n        }\n        for(Map.Entry<Integer, Integer> entry: map.entrySet()){\n            singleList.add(entry.getKey());\n            dupList.add(entry.getKey());\n        }\n        List<Integer> dupListSetBitsCountList = new ArrayList<>();\n        List<Integer> singleListSetBitsCountList = new ArrayList<>();\n        int dupListSize = dupList.size(), singleListSize = singleList.size();\n        for(int x: singleList) singleListSetBitsCountList.add(countSetBits(x));\n        for(int x: dupList) dupListSetBitsCountList.add(countSetBits(x));\n        Collections.sort(dupListSetBitsCountList);\n        Collections.sort(singleListSetBitsCountList);\n        long ans = 0;\n        ans += (2 * countPairs1(singleListSetBitsCountList, singleListSize, k));\n        ans += countPairs2(dupListSetBitsCountList, dupListSize, k);\n        return ans;\n    }\n}\n```
['Array', 'Java']