c++ solution using fenwink tree
\nclass Solution {\npublic:\n    int N=1e5+10;\n    int bit[100005];\n    void update(int i,int val)\n    {\n        i++;\n        while(i<N)\n        {\n      
```\nclass Solution {\npublic:\n    int N=1e5+10;\n    int bit[100005];\n    void update(int i,int val)\n    {\n        i++;\n        while(i<N)\n        {\n            bit[i]|=val;\n            i+=(i&-i);\n        }\n    }\n    int find(int i)\n    {\n        i++;\n        int sum=0;\n        while(i>0)\n        {\n            sum|=bit[i];\n            i-=(i&-i);\n        }\n        return sum;\n    }\n    vector<int> smallestSubarrays(vector<int>& nums) \n    {\n        int n=nums.size();\n        vector<int>ans(n,0);\n        int total=0;\n        for(int i=n-1;i>=0;i--)\n        {\n            total|=nums[i];\n            update(i,nums[i]);\n            int l=i;\n            int r=n-1;\n            int index=n-1;\n            while(l<=r)\n            {\n                int mid=(l+r)/2;\n                if(find(mid)==total)\n                {\n                    index=mid;\n                    r=mid-1;\n                }\n                else\n                {\n                    l=mid+1;\n                }\n            }\n            ans[i]=(index-i+1);\n        }\n        return ans;\n    }\n};\n```
['C', 'C++']