Why 2e7 passes in JAVA and gives TLE in C++
I wrote 3 codes, One was 2e7 * log(n). This gave me TLE in c++, I thought maybe because I\'m using a data structure, then I tried using a vector and complexity 
I wrote 3 codes, One was 2e7 * log(n). This gave me TLE in c++, I thought maybe because I\'m using a data structure, then I tried using a vector and complexity came down to 2e7. Still, I got tle then I switched the language from C++ to JAVA and it passed quite smoothly. I want to say that this is absurd. C++ is the fastest language for Contests in all platforms and here you are giving TLE on a code with 2e7 complexity.  \n\n**My all 3 codes**\n\n*1st whose complexity is 2e7  * log(n). This should also usually pass.*\n\n```\n#define ll long long\n#define pi (3.141592653589)\n#define mod 1000000007\n#define float double\n#define pb push_back\n#define mp make_pair\n#define ff first\n#define ss second\n#define all(c) c.begin(), c.end()\n#define min3(a, b, c) min(c, min(a, b))\n#define min4(a, b, c, d) min(d, min(c, min(a, b)))\n#define rrep(i, n) for(int i=n-1;i>=0;i--)\n#define rep(i,n) for(int i=0;i<n;i++)\nclass Solution {\npublic:\n    int beautifulSubsets(vector<int>& nums, int k) {\n        ll n= nums.size();\n        ll cnt=0;\n        \n        rep(i, (1<<n)){\n            vector<ll> f;\n            map<ll, ll> m;\n            rep(j, n){\n                \n                if( (i & (1<<j))) {f.pb(nums[j]); m[nums[j]]++; }\n            }\n            if(f.size()==0) continue;\n            \n            ll flag=0;\n            rep(j,f.size()){\n                ll x= f[j] + k;\n                ll y= f[j] - k;\n                \n                if(m.find(x)!=m.end()) { flag=1; break; }\n                if(m.find(y)!= m.end()) { flag=1; break; }\n            }\n            \n            if(!flag) cnt++;\n            \n        }\n        \n        return cnt;\n    }\n};\n```\n**Verdict -TLE**\n\n*2nd - Complexity is now 2e7*\n\n```\n#define ll long long\n#define pi (3.141592653589)\n#define mod 1000000007\n#define float double\n#define pb push_back\n#define mp make_pair\n#define ff first\n#define ss second\n#define all(c) c.begin(), c.end()\n#define min3(a, b, c) min(c, min(a, b))\n#define min4(a, b, c, d) min(d, min(c, min(a, b)))\n#define rrep(i, n) for(int i=n-1;i>=0;i--)\n#define rep(i,n) for(int i=0;i<n;i++)\nclass Solution {\npublic:\n    int beautifulSubsets(vector<int>& nums, int k) {\n        ll n= nums.size();\n        ll cnt=0;\n        \n        // cout<<n<<"\\n";\n        \n        \n        vector<int> fre(1001, 0);\n        rep(i, (1<<n)){\n             ll flag=0;\n            ll lol=0;\n            rep(j, n){\n                \n                if( (i & (1<<j))) {                 \n                    fre[nums[j]]++; \n                    int x= nums[j] + k;\n                    int y= nums[j] - k;\n                    lol++;\n                    if(x>=1 && x<=1000 && fre[x]>0 ) { flag=1; break; }\n                    if(y>=1 && y<=1000 && fre[y]>0) { flag=1; break; }\n                  }\n                \n            }\n            if(lol==0 ) continue;\n            rep(j,n){\n                fre[nums[j]]=0;\n            }\n            \n       \n            \n            if(!flag) cnt++;\n            \n        }\n        \n        \n        return cnt;\n    }\n};\n```\n\n**Verdict - This got TLE too**\n\n*3rd now i TRIED same code in JAVA,*\n\n```\nclass Solution {\n    public int beautifulSubsets(int[] nums, int k) {\n        int n= nums.length;\n        int cnt=0;\n\n        int[] fre = new int[1001];\n        for (int i = 0; i < (1<<n); i++) {\n            int flag=0;\n            int lol=0;\n            for (int j = 0; j < n; j++) {\n\n                if( (i & (1<<j)) != 0) {\n                    fre[nums[j]]++;\n                    int x= nums[j] + k;\n                    int y= nums[j] - k;\n                    lol++;\n                    if(x>=1 && x<=1000 && fre[x]>0 ) { flag=1; break; }\n                    if(y>=1 && y<=1000 && fre[y]>0) { flag=1; break; }\n                }\n\n            }\n            if(lol==0 ) continue;\n            for (int j = 0; j < n; j++) {\n                fre[nums[j]]=0;\n            }\n\n            if(flag == 0) cnt++;\n        }\n\n        return cnt;\n    \n        \n    }\n}\n```\n**Verdict - It passed quite comfortably with time complexity at 1300ms.**\n\nWhy you are doing this to c++ now after python
['C', 'Bitmask', 'Java']