[C++] Binary Search
\nclass Solution {\npublic:\n    int power(long long x, long long y, long long p)\n    {\n        long long res = 1;\n        x = x % p;\n        if (x == 0) re
```\nclass Solution {\npublic:\n    int power(long long x, long long y, long long p)\n    {\n        long long res = 1;\n        x = x % p;\n        if (x == 0) return 0;\n        while (y > 0)\n        {\n            if (y & 1)\n                res = (res*x) % p;\n            y = y>>1;\n            x = ((x%p)*(x%p)) % p;\n        }\n        return (int)(res%p);\n    }\n    \n    int numSubseq(vector<int>& a, int target) {\n        sort(a.begin(), a.end());\n        int ans = 0, mod = 1e9+7, l=0, r=a.size();\n        for(int i=0;i<r;i++){\n            int idx = upper_bound(a.begin(), a.end(), target-a[i]) - a.begin();\n            if(a[i]*2<=target) {\n                ans+=1;\n            }\n            if(idx>=0 && idx==a.size() || a[idx] != target-a[i]) idx--;\n            if(idx<i) continue;\n            ans = ((ans%mod)+(power(2, idx - i, mod)%mod)%mod) - 1;\n        }\n        return ans;\n    }\n};\n```
['C', 'Binary Tree']