Global and static variables are defined in the Data Segment of the program's memory. I suggest reading about it on wiki.  Allocating such big buffers, either on the stack or in the data segment is a really bad practice. (sorry for not being more polite, but it should be avoided at all costs!) Probably Mac-OS allows bigger Data Segments than other OS, but you should not rely on that!
I need to address a few more issues here:
- Using #define fi(i, n)for example, is another way to make your code completely unreadable, prone to errors, not scalable and so on. Just use for loop as intended!
- This #define lli long long intis obscuring the type, understanding thatlliislong long intisn't that simple!. Since C++11 you can use#include <cstdint>look at the reference and useint64_t, knowing the exact size of the integer. (also, when it comes to not-negative numbers, you should use eitherstd::size_toruintXX_t, I personally use theuint64_ton 64-bit machines).
- In C++ you should use using lli = long long int;instead of#define ...
- Using 'using namespace std' is considered bad practice
- Divide your code into functions, it will make your code more readable.
- const lli _MOD = 1e9 + 7;should be- constexpr uint64_t _MOD = 1e9 + 7;