private static int calc ( int orig , int left , int right ) {
  int l = left - orig ;
  int r = right - orig ;
  if ( l <= 0 && 0 <= r ) {
    return ( l * ( l - 1 ) + r * ( r + 1 ) ) / 2 ;
  }
  else if ( r < 0 ) {
    return ( l * ( l - 1 ) - r * ( r + 1 ) ) / 2 ;
  }
  else {
    return ( r * ( r + 1 ) - l * ( l - 1 ) ) / 2 ;
  }
}

private static int calc ( int orig , int left , int right ) { int l = left - orig ; int r = right - orig ; if ( l <= 0 && 0 <= r ) { return ( l * ( l - 1 ) + r * ( r + 1 ) ) / 2 ; } else if ( r < 0 ) { return ( l * ( l - 1 ) - r * ( r + 1 ) ) / 2 ; } else { return ( r * ( r + 1 ) - l * ( l - 1 ) ) / 2 ; } }
(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))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))) consequence: (block (return_statement (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) right: (decimal_integer_literal)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) right: (decimal_integer_literal)))) alternative: (block (return_statement (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) right: (decimal_integer_literal))))))))