```
int countPrimes(int n) {
int retval = 0;
int *list = calloc(n, sizeof(int));
for (int i = 2; i < n; ++i) {
for (int j = 2; j * i < n; ++j) {
++list[j * i];
}
}
for (int k = 2; k < n; ++k) {
if (list[k] == 0) ++retval;
}
free(list);
return retval;
}
```

Submission Result: Memory Limit Exceeded.

Could someone provide some help on my code?

Thanks a lot!