C++ | faster than 99.37%
\nclass Solution {\npublic:\n\tint concatenatedBinary(int n) {\n\t\tint64_t ans = 0;\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tint bits = 32 - __builtin_clz(i)
```\nclass Solution {\npublic:\n\tint concatenatedBinary(int n) {\n\t\tint64_t ans = 0;\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tint bits = 32 - __builtin_clz(i);\n\t\t\tans = (ans << bits | i) % 1\'000\'000\'007;\n\t\t}\n\t\treturn ans;\n\t}\n};\n```
[]