The following is a Haskell program that uses Monte Carlo to calculate pi. However, when the input is 10 million, the program ran for 20 seconds. The C program written in the same logic took only 0.206 seconds. Why is this, and how can I speed it up? Thank you all.

This is Haskell version.

```
import System.Random
import Draw
import Data.List
import System.Environment
montecarloCircle :: Int -> Double
montecarloCircle x = 4*fromIntegral (foldl' (x y -> if y <= 1 then x+1 else x) 0 $ zipWith (x y -> (x**2 + y**2)) (take x $ randomRs (-1.0,1) (mkStdGen 1) :: (Double)) (take x $ randomRs (-1.0,1) (mkStdGen 2) :: (Double)) ) / fromIntegral x
main = do
num <- getArgs
let n = read (num !! 0)
print $ montecarloCircle n
```

This is C version

```
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#define N 10000000
#define int_t long // the type of N and M
// Rand from 0.0 to 1.0
double rand01()
{
return rand()*1.0/RAND_MAX;
}
int main()
{
srand((unsigned)time(NULL));
double x,y;
int_t M = 0;
for (int_t i = 0;i < N;i++)
{
x = rand01();
y = rand01();
if (x*x+y*y<1) M++;
}
double pi = (double)4*M/N;
printf("%lfn", pi);
}
```