public static void main ( String [ ] args ) {
  try ( Scanner scanner = new Scanner ( System . in ) ) {
    int n = scanner . nextInt ( ) ;
    int m = scanner . nextInt ( ) ;
    scanner . nextLine ( ) ;
    List < Store > list = IntStream . range ( 0 , n ) . mapToObj ( i -> {
      Store store = new Store ( ) ;
      store . price = scanner . nextInt ( ) ;
      store . amount = scanner . nextInt ( ) ;
      scanner . nextLine ( ) ;
      return store ;
    }
    ) . sorted ( ( x , y ) -> x . price - y . price ) . collect ( Collectors . toList ( ) ) ;
    long sum = 0 ;
    for ( int i = 0 ;
    i < list . size ( ) ;
    i ++ ) {
      Store store = list . get ( i ) ;
      if ( store . amount >= m ) {
        sum += ( long ) store . price * m ;
        break ;
      }
      else {
        sum += ( long ) store . price * store . amount ;
        m -= store . amount ;
      }
    }
    System . out . println ( sum ) ;
  }
}

public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; scanner . nextLine ( ) ; List < Store > list = IntStream . range ( 0 , n ) . mapToObj ( i -> { Store store = new Store ( ) ; store . price = scanner . nextInt ( ) ; store . amount = scanner . nextInt ( ) ; scanner . nextLine ( ) ; return store ; } ) . sorted ( ( x , y ) -> x . price - y . price ) . collect ( Collectors . toList ( ) ) ; long sum = 0 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { Store store = list . get ( i ) ; if ( store . amount >= m ) { sum += ( long ) store . price * m ; break ; } else { sum += ( long ) store . price * store . amount ; m -= store . amount ; } } System . out . println ( sum ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (try_with_resources_statement resources: (resource_specification (resource type: (type_identifier) name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) 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: (integral_type) 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))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (return_statement (identifier)))))) name: (identifier) arguments: (argument_list (lambda_expression parameters: (inferred_parameters (identifier) (identifier)) body: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier)))))) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (cast_expression type: (integral_type) value: (field_access object: (identifier) field: (identifier))) right: (identifier)))) (break_statement)) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (cast_expression type: (integral_type) value: (field_access object: (identifier) field: (identifier))) right: (field_access object: (identifier) field: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))))