public static String exec ( ) {
  int n = sc . nextInt ( ) ;
  int [ ] s1 = new int [ n ] ;
  int [ ] s2 = new int [ n ] ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    s1 [ i ] = sc . nextInt ( ) ;
    s2 [ i ] = sc . nextInt ( ) ;
  }
  int stars = 0 ;
  int goal = n * 2 ;
  int [ ] obtained = new int [ n ] ;
  int plays = 0 ;
  loop : while ( stars < goal ) {
    for ( int i = 0 ;
    i < n ;
    i ++ ) {
      if ( s2 [ i ] > stars ) continue ;
      if ( obtained [ i ] == 2 ) continue ;
      stars += 2 - obtained [ i ] ;
      obtained [ i ] = 2 ;
      plays ++ ;
      continue loop ;
    }
    int s2OfWinner = - 1 ;
    int idxOfWinner = - 1 ;
    for ( int i = 0 ;
    i < n ;
    i ++ ) {
      if ( obtained [ i ] != 0 ) continue ;
      if ( s1 [ i ] > stars ) continue ;
      if ( s2 [ i ] < s2OfWinner ) continue ;
      s2OfWinner = s2 [ i ] ;
      idxOfWinner = i ;
    }
    if ( s2OfWinner == - 1 ) return "Too Bad" ;
    stars ++ ;
    obtained [ idxOfWinner ] = 1 ;
    plays ++ ;
  }
  return String . valueOf ( plays ) ;
}

public static String exec ( ) { int n = sc . nextInt ( ) ; int [ ] s1 = new int [ n ] ; int [ ] s2 = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { s1 [ i ] = sc . nextInt ( ) ; s2 [ i ] = sc . nextInt ( ) ; } int stars = 0 ; int goal = n * 2 ; int [ ] obtained = new int [ n ] ; int plays = 0 ; loop : while ( stars < goal ) { for ( int i = 0 ; i < n ; i ++ ) { if ( s2 [ i ] > stars ) continue ; if ( obtained [ i ] == 2 ) continue ; stars += 2 - obtained [ i ] ; obtained [ i ] = 2 ; plays ++ ; continue loop ; } int s2OfWinner = - 1 ; int idxOfWinner = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( obtained [ i ] != 0 ) continue ; if ( s1 [ i ] > stars ) continue ; if ( s2 [ i ] < s2OfWinner ) continue ; s2OfWinner = s2 [ i ] ; idxOfWinner = i ; } if ( s2OfWinner == - 1 ) return " Too ▁ Bad " ; stars ++ ; obtained [ idxOfWinner ] = 1 ; plays ++ ; } return String . valueOf ( plays ) ; }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (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: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (labeled_statement (identifier) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (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 (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (continue_statement)) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (array_access array: (identifier) index: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))) (continue_statement (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (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 (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (continue_statement)) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (continue_statement)) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (return_statement (string_literal))) (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier)))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))