private static int thanos ( int [ ] input ) {
  if ( input . length == 1 ) {
    return 1 ;
  }
  if ( sorted ( input ) ) {
    return input . length ;
  }
  int l [ ] = new int [ input . length / 2 ] ;
  int r [ ] = new int [ input . length / 2 ] ;
  for ( int i = 0 ;
  i < input . length / 2 ;
  i ++ ) {
    l [ i ] = input [ i ] ;
  }
  for ( int i = input . length / 2 ;
  i < input . length ;
  i ++ ) {
    r [ i - input . length / 2 ] = input [ i ] ;
  }
  int left = thanos ( l ) ;
  int right = thanos ( r ) ;
  return left > right ? left : right ;
}

private static int thanos ( int [ ] input ) { if ( input . length == 1 ) { return 1 ; } if ( sorted ( input ) ) { return input . length ; } int l [ ] = new int [ input . length / 2 ] ; int r [ ] = new int [ input . length / 2 ] ; for ( int i = 0 ; i < input . length / 2 ; i ++ ) { l [ i ] = input [ i ] ; } for ( int i = input . length / 2 ; i < input . length ; i ++ ) { r [ i - input . length / 2 ] = input [ i ] ; } int left = thanos ( l ) ; int right = thanos ( r ) ; return left > right ? left : right ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) consequence: (block (return_statement (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (return_statement (field_access object: (identifier) field: (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (field_access object: (identifier) field: (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: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) right: (array_access array: (identifier) index: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (return_statement (ternary_expression condition: (binary_expression left: (identifier) right: (identifier)) consequence: (identifier) alternative: (identifier)))))