Moved MPI_Init to the top.
Added memory option. Changed to medium. I hope this program run properly.

Note that this memory option may make this program slower.