Precomputation of binomial coefficients
for i in range ( 1 , 3000 ) : NEW_LINE INDENT bin [ i ] [ 0 ] = 1 NEW_LINE for j in range ( 1 , i + 1 ) : NEW_LINE INDENT bin [ i ] [ j ] = ( bin [ i - 1 ] [ j ] + bin [ i - 1 ] [ j - 1 ] ) % mod NEW_LINE DEDENT DEDENT