private static String calc ( long n , long k ) {
  TreeMap < Long , Long > treeMap = new TreeMap < > ( ) ;
  treeMap . put ( n , 1L ) ;
  while ( k > 0 ) {
    Map . Entry < Long , Long > entry = treeMap . lastEntry ( ) ;
    treeMap . remove ( entry . getKey ( ) ) ;
    if ( k <= entry . getValue ( ) ) {
      return entry . getKey ( ) / 2 + " " + ( entry . getKey ( ) - 1 ) / 2 ;
    }
    else {
      k -= entry . getValue ( ) ;
      if ( entry . getKey ( ) / 2 > 0 ) {
        long key = entry . getKey ( ) / 2 ;
        treeMap . put ( key , treeMap . getOrDefault ( key , 0L ) + entry . getValue ( ) ) ;
      }
      if ( ( entry . getKey ( ) - 1 ) / 2 > 0 ) {
        long key = ( entry . getKey ( ) - 1 ) / 2 ;
        treeMap . put ( key , treeMap . getOrDefault ( key , 0L ) + entry . getValue ( ) ) ;
      }
    }
  }
  throw new RuntimeException ( ) ;
}

private static String calc ( long n , long k ) { TreeMap < Long , Long > treeMap = new TreeMap < > ( ) ; treeMap . put ( n , 1L ) ; while ( k > 0 ) { Map . Entry < Long , Long > entry = treeMap . lastEntry ( ) ; treeMap . remove ( entry . getKey ( ) ) ; if ( k <= entry . getValue ( ) ) { return entry . getKey ( ) / 2 + " ▁ " + ( entry . getKey ( ) - 1 ) / 2 ; } else { k -= entry . getValue ( ) ; if ( entry . getKey ( ) / 2 > 0 ) { long key = entry . getKey ( ) / 2 ; treeMap . put ( key , treeMap . getOrDefault ( key , 0L ) + entry . getValue ( ) ) ; } if ( ( entry . getKey ( ) - 1 ) / 2 > 0 ) { long key = ( entry . getKey ( ) - 1 ) / 2 ; treeMap . put ( key , treeMap . getOrDefault ( key , 0L ) + entry . getValue ( ) ) ; } } } throw new RuntimeException ( ) ; }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (local_variable_declaration type: (generic_type (scoped_type_identifier (type_identifier) (type_identifier)) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) consequence: (block (return_statement (binary_expression left: (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)) right: (string_literal)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))) right: (decimal_integer_literal))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))) right: (decimal_integer_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))))))))) (throw_statement (object_creation_expression type: (type_identifier) arguments: (argument_list)))))