C++ 100% faster code
\nclass Solution {\n    long MOD = 1e9 + 7;\npublic:\n    int numPrimeArrangements(int n) {\n        vector<int> prime = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31
```\nclass Solution {\n    long MOD = 1e9 + 7;\npublic:\n    int numPrimeArrangements(int n) {\n        vector<int> prime = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89,\n                             97};\n        long long ans = 1;\n        int k = distance(prime.begin(), upper_bound(prime.begin(), prime.end(), n));\n        for (int i = 1; i <= k; ++i) {\n            ans = ans * i % MOD;\n        }\n        for (int i = 1; i <= n - k; ++i) {\n            ans = ans * i % MOD;\n        }\n        return ans;\n    }\n};\n```
[]