Refactor the code to avoid allocating large arrays on the stack. Use heap allocation instead (e.g., via Vec).