When n reaches 1000, C(n, r) has hundreds of digits. Competitive problems ask for it modulo 10⁹ + 7.
Division doesn't work directly under a modulus, but addition does. So use Pascal's rule with a 1-D table:
C(n, r) = C(n−1, r−1) + C(n−1, r) (mod p)
Update the row from right to left so each value still reads the previous row. That takes O(n·r) time and O(r) memory. The faster alternative uses factorials and modular inverses via Fermat's little theorem, combining this lesson with modular exponentiation.