C++// 1. 使用 register 关键字
// 2. 预处理器优化
#define _GLIBCXX_USE_CXX11_ABI 0
#define _CRT_SECURE_NO_WARNINGS
// 3. 快速 IO
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define rll register long long
// 4. 减少 cin/cout 操作
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// 5. 使用位运算替代取模
ll mod(ll x, ll m) { return (x & (m - 1)); }
// 6. 预计算阶乘逆元
ll fact[100005], inv[100005];
// 7. 快速幂
ll qpow(ll a, ll b, ll p) {
ll res = 1;
for (; b; b >>= 1) {
if (b & 1) res = res * a % p;
a = a * a % p;
}
return res;
}
// 8. 静态数组优化
static ll arr[100005];
// 9. 减少函数调用
inline ll add(ll x, ll y) { return x + y; }
// 10. 使用 __builtin_expect
if (__builtin_expect(x == 0, 0)) { /* rare case */ }
// 11. 预计算 log2
const int LOG_N = 20;
int lg[1 << LOG_N];
// 12. 使用 __builtin_popcount
ll cnt = __builtin_popcount(x);
// 13. 减少内存分配
vector<ll> vec(100005);
// 14. 使用 __builtin_clz
ll leading_zeros = __builtin_clz(x);
// 15. 预计算阶乘
ll fact[100005];
// 16. 使用 __builtin_ctz
ll trailing_zeros = __builtin_ctz(x);
// 17. 减少浮点运算
double d = (double)x / y;
// 18. 使用 __builtin_prefetch
__builtin_prefetch(&arr[i + 1024], 0, 0);
// 19. 减少字符串操作
string s = "hello";
// 20. 使用 __builtin_expect
if (__builtin_expect(x == 0, 0)) { /* rare case */ }