How do Quantum Software Packages Work? If one wants to calculate a moderate size Alkane (with say 10-15 Carbons , assuming 100 electrons , with Restricted Hartree Fock based methods) we can simply say that electron-electron part will be $100^4 = 100$ million integrals. If we remove the non-unique ones it will become $\frac{100M}{8}= 12.5 M$ Integrals. If we do a pre-screening it may become around 6 million.  Even if we go for DFT it will be around $\frac{100^3}{8} =125,000$ .

I have calculated a small system like Methane with just 10 electrons (around 400 unique/pre-screened integrals) with an efficient C++ code  (based on Rys Integration which is among the most efficient methods) and it took around 1 hour. When 400 cycles takes 1 hour I can assume that 6 million cycles may take years! But software packages do that just in seconds!

My question is if I just want to do a simple math like 2+2 for 6 million times it takes way longer than what these packages do with such complicated integrals!!
Anyone knows what their trick is? Do they have pre-calculated database or some approximation methods?   

UPDATE:
there are many good hints in this question and thanks to all for that. A combination of symmetry, finding negligible integrals and using optimized methods work fine. The only unanswered part is an algorithm for finding the symmetric situations.
There are many tricks. Since I'm not a developer, I'm not privy to all of them, but there are some simple things to start.


Some integrals are predictably close to zero: Even in fully first-principals calculations, there are parts of the code that prune out integrals that will clearly be negligible. This cuts out a lot of work. Consider, for example, overlap or Coulomb integrals between atoms that are very far apart.
Gaussian Orbitals: Using Gaussian-type orbitals are incredibly fast, because most quantum integrals can be derived as simple recurrence relationships. That is, you almost never need to do the integration. See, for example, Obara and Saika and the recent PRISM algorithm from Gill and Pople.


I believe there are some actual quantum developers on here and perhaps they'd be willing to share other tricks. But these are big - eliminate any integral you don't need, and don't actually take the integrals in the first place. ;-)

Yes, there are numeric tricks (using BLAS, LAPACK, etc.) and use of multi-core processing. But these are actually minor optimizations.

UPDATE

I realized that I forgot to talk about convergence of the self-consistent field which is also optimized. There are various convergence strategies, most notably DIIS, which helps to extrapolate the final orbital coefficients and electron density.