[c++] dp bitmask
\n#include <iostream>\n#include <queue>\n#include <vector>\n#include <cmath>\n#include <string>\n#include <sstream>\n#include <cstring>\n#include <algorithm>\n#
```\n#include <iostream>\n#include <queue>\n#include <vector>\n#include <cmath>\n#include <string>\n#include <sstream>\n#include <cstring>\n#include <algorithm>\n#include <climits>\n#include <stack>\n#include <set>\n#include <map>\n#include <list>\n#include <cassert>\n#include <unordered_map>\n#include <numeric>\n#include <iomanip>\n#include <iostream>\n#include <cstdio>\n#include <algorithm>\n#include <queue>\n#include <cstdlib>\n#include <cstring>\n\nusing namespace std;\n#pragma GCC optimize("O3,unroll-loops")\n#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")\n\n/* TYPES  */\n#define xf first\n#define xs second\n#define ll long long int\n#define lli int64_t\n#define ulli uint64_t\n#define dbl double\n#define ldbl long double\n#define str string\n#define pii pair<int, int>\n#define pll pair<ll,ll>\n#define vi vector<int>\n#define vs vector<string>\n#define vll vector<long long>\n#define mii map<int, int>\n#define si set<int>\n#define sc set<char>\n\n/* FUNCTIONS */\n#define mid(l, r) \t       ((l + r) >> 1)\n#define all(a)             a.begin(),a.end()\n#define v(t) vector<t>\n#define st(t) stack<t>\n#define ar(t,sz) array<t,sz>\n#define s(t) set<t>\n#define ss(a) sort(a.begin(),a.end())\n#define ms(t) multiset<t>\n#define mipq(t) priority_queue<t>\n#define mapq(t) priority_queue<t,v(t),less<t>>\n#define trpl(a,b,c) tuple<a,b,c>\n#define m(t, t2) map<t, t2>\n#define um(t, t2) unordered_map<t, t2>\n#define p(t, t2) pair<t, t2>\n#define f(i, s, e) for(long long int i=s;i<e;i++)\n#define fc(i, s, e, c) for(long long int i=s;i<e;i+=c)\n#define fa(k,in) for(auto k:in)\n#define fm(i, s, e) for(long long int i=s;i!=e;i++)\n#define cf(i, s, e) for(long long int i=s;i<=e;i++)\n#define rf(i, e, s) for(long long int i=e-1;i>=s;i--)\n#define wl(c) while(c)\n#define pb push_back\n#define mpp make_pair\n#define cl clear\n#define eb emplace_back\n\nint mem[10][2][2][2][1024];\nstr fs;\nclass Solution {\npublic:\n    int dp(int i,bool f,bool f2,int c,int bm){\n        if(i<0)return(!f&&c!=0&&f2)?1:0;\n        if(mem[i][f][f2][c][bm]!=-1)return mem[i][f][f2][c][bm];\n        int z=fs[i]-\'0\';\n        int a=0;\n        f(nk,0,10){\n            ll k=(1<<nk);\n            bool nf2=f2;\n            if((bm&k)!=0){nf2|=1;}\n            a+=dp(i-1,nk<z?0:(nk==z?f:1),nf2,nk!=0,bm|k);\n        }\n        return mem[i][f][f2][c][bm]=a+(c!=0&&f2);\n    }\n\n    int numDupDigitsAtMostN(int n) {\n        if(n<=10){return 0;}\n        memset(mem,-1,sizeof(mem));\n        fs=to_string(n);\n        return dp(fs.size()-1,0,0,0,0);\n    }\n};\n```
[]