static long nCr_RangeSum ( long n , long r1 , long r2 , long p ) {
  long num = 1 , den = 1 ;
  long sum = 0l ;
  if ( r1 == 0 ) sum += 1l ;
  for ( int i = 0 ;
  i < r2 ;
  i ++ ) {
    num = ( num * ( n - i ) ) % p ;
    den = ( den * ( i + 1 ) ) % p ;
    if ( i - r1 >= - 1 && ( i - r1 + 1 ) % 2 == 0 ) {
      sum += ( num * mod_power ( den , p - 2 , p ) ) % p ;
      sum %= p ;
    }
  }
  return sum ;
}

static long nCr_RangeSum ( long n , long r1 , long r2 , long p ) { long num = 1 , den = 1 ; long sum = 0l ; if ( r1 == 0 ) sum += 1l ; for ( int i = 0 ; i < r2 ; i ++ ) { num = ( num * ( n - i ) ) % p ; den = ( den * ( i + 1 ) ) % p ; if ( i - r1 >= - 1 && ( i - r1 + 1 ) % 2 == 0 ) { sum += ( num * mod_power ( den , p - 2 , p ) ) % p ; sum %= p ; } } return sum ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))))) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (unary_expression operand: (decimal_integer_literal))) right: (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier))))) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (return_statement (identifier))))