static int ans ( int n , int c ) {
  if ( c == 10 ) return 0 ;
  int temp = 0 ;
  if ( ( 1 + n ) % power ( 10 , c + 1 ) >= 2 * power ( 10 , c ) ) {
    temp = power ( 10 , c ) ;
  }
  else if ( ( 1 + n ) % power ( 10 , c + 1 ) > power ( 10 , c ) ) {
    temp = ( n + 1 ) % power ( 10 , c + 1 ) - power ( 10 , c ) ;
  }
  return ans ( n , c + 1 ) + power ( 10 , c ) * ( ( n + 1 ) / power ( 10 , c + 1 ) ) + temp ;
}

static int ans ( int n , int c ) { if ( c == 10 ) return 0 ; int temp = 0 ; if ( ( 1 + n ) % power ( 10 , c + 1 ) >= 2 * power ( 10 , c ) ) { temp = power ( 10 , c ) ; } else if ( ( 1 + n ) % power ( 10 , c + 1 ) > power ( 10 , c ) ) { temp = ( n + 1 ) % power ( 10 , c + 1 ) - power ( 10 , c ) ; } return ans ( n , c + 1 ) + power ( 10 , c ) * ( ( n + 1 ) / power ( 10 , c + 1 ) ) + temp ; }
(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))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (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: (binary_expression left: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (binary_expression left: (decimal_integer_literal) right: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier)))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier)))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal))))) right: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))))))))) (return_statement (binary_expression left: (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) right: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (method_invocation name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) right: (identifier)))))