Help Distributing Apples CSES problem set

problem link:distributing Apples
submission link:
I tried to solve above problem but my code is giving runtime error for 3 test cases…
can anyone explain whats wrong with my code?

n+m-1 can take the value 2*10^6 -1 but fact array is declared only till 10^6 -1.
Just increase the array size.


thank you