public static void main ( String [ ] args ) {
  int n = 5 , m = 5 ;
  int arr [ ] = new int [ n ] ;
  Arrays . fill ( arr , 0 ) ;
  int query [ ] [ ] = {
    {
      1 , 1 , 2 }, {
        1 , 4 , 5 }, {
          2 , 1 , 2 }, {
            2 , 1 , 3 }, {
              2 , 3 , 4 }
            };
            int record [ ] = new int [ m ] ;
            Arrays . fill ( record , 0 ) ;
            for ( int i = m - 1 ;
            i >= 0 ;
            i -- ) {
              if ( query [ i ] [ 0 ] == 2 ) {
                record_sum ( record , query [ i ] [ 1 ] - 1 , query [ i ] [ 2 ] - 1 , m , record [ i ] + 1 ) ;
              }
              else {
                record_sum ( record , i , i , m , 1 ) ;
              }
            }
            for ( int i = 0 ;
            i < m ;
            i ++ ) {
              if ( query [ i ] [ 0 ] == 1 ) {
                record_sum ( arr , query [ i ] [ 1 ] - 1 , query [ i ] [ 2 ] - 1 , n , record [ i ] ) ;
              }
            }
            for ( int i = 0 ;
            i < n ;
            i ++ ) {
              System . out . print ( arr [ i ] + " " ) ;
            }
          }
          
public static void main ( String [ ] args ) { int n = 5 , m = 5 ; int arr [ ] = new int [ n ] ; Arrays . fill ( arr , 0 ) ; int query [ ] [ ] = { { 1 , 1 , 2 } , { 1 , 4 , 5 } , { 2 , 1 , 2 } , { 2 , 1 , 3 } , { 2 , 3 , 4 } } ; int record [ ] = new int [ m ] ; Arrays . fill ( record , 0 ) ; for ( int i = m - 1 ; i >= 0 ; i -- ) { if ( query [ i ] [ 0 ] == 2 ) { record_sum ( record , query [ i ] [ 1 ] - 1 , query [ i ] [ 2 ] - 1 , m , record [ i ] + 1 ) ; } else { record_sum ( record , i , i , m , 1 ) ; } } for ( int i = 0 ; i < m ; i ++ ) { if ( query [ i ] [ 0 ] == 1 ) { record_sum ( arr , query [ i ] [ 1 ] - 1 , query [ i ] [ 2 ] - 1 , n , record [ i ] ) ; } } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } }
(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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (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 (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_initializer (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)) (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)) (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)) (array_initializer (decimal_integer_literal) (decimal_integer_literal) (decimal_integer_literal)) (array_initializer (decimal_integer_literal) (decimal_integer_literal) (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 (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (decimal_integer_literal)) (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (decimal_integer_literal)) (identifier) (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))))) alternative: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier) (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: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (decimal_integer_literal)) (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (decimal_integer_literal)) (identifier) (array_access array: (identifier) index: (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 (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (string_literal)))))))))