private static int getCNonZero ( int x , int z ) {
  int ans = messages . get ( z ) ;
  int lZan = Math . max ( 1 , z - k ) ;
  int rZan = Math . min ( n , z + k ) ;
  int l = Math . max ( 1 , x - k ) ;
  int r = Math . min ( n , x + k ) ;
  if ( rZan >= l ) l = rZan + 1 ;
  return ans + ( r - l ) + 1 ;
}

private static int getCNonZero ( int x , int z ) { int ans = messages . get ( z ) ; int lZan = Math . max ( 1 , z - k ) ; int rZan = Math . min ( n , z + k ) ; int l = Math . max ( 1 , x - k ) ; int r = Math . min ( n , x + k ) ; if ( rZan >= l ) l = rZan + 1 ; return ans + ( r - l ) + 1 ; }
(method_declaration (modifiers) type: (integral_type) 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: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))) (return_statement (binary_expression left: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))) right: (decimal_integer_literal)))))