static void solve ( ) {
  int n = ni ( ) , k = ni ( ) ;
  int f [ ] = new int [ n ] ;
  int t [ ] = new int [ n ] ;
  for ( int i = 0 ;
  i < n ;
  ++ i ) {
    f [ i ] = ni ( ) ;
    t [ i ] = ni ( ) ;
  }
  long max = 0 ;
  if ( t [ 0 ] > k ) {
    max = f [ 0 ] - t [ 0 ] + k ;
  }
  else {
    max = f [ 0 ] ;
  }
  for ( int i = 0 ;
  i < n ;
  ++ i ) {
    if ( t [ i ] > k ) {
      long p = f [ i ] - t [ i ] + k ;
      if ( p > max ) {
        max = p ;
      }
    }
    else {
      long p = f [ i ] ;
      if ( p > max ) {
        max = p ;
      }
    }
  }
  out ( max ) ;
}

static void solve ( ) { int n = ni ( ) , k = ni ( ) ; int f [ ] = new int [ n ] ; int t [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { f [ i ] = ni ( ) ; t [ i ] = ni ( ) ; } long max = 0 ; if ( t [ 0 ] > k ) { max = f [ 0 ] - t [ 0 ] + k ; } else { max = f [ 0 ] ; } for ( int i = 0 ; i < n ; ++ i ) { if ( t [ i ] > k ) { long p = f [ i ] - t [ i ] + k ; if ( p > max ) { max = p ; } } else { long p = f [ i ] ; if ( p > max ) { max = p ; } } } out ( max ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list))) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) 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 name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (array_access array: (identifier) index: (decimal_integer_literal))) right: (identifier))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (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: (identifier))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier)))))) alternative: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))))))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier))))))