private static long dfs ( int cur , String last3 ) {
  if ( memo . get ( cur ) . containsKey ( last3 ) ) {
    return memo . get ( cur ) . get ( last3 ) ;
  }
  if ( cur == N ) {
    return 1 ;
  }
  long ret = 0 ;
  char [ ] cList = {
    'A' , 'C' , 'G' , 'T' };
    for ( char c : cList ) {
      if ( ok ( last3 + c ) ) {
        ret = ( ret + dfs ( cur + 1 , last3 . substring ( 1 ) + c ) ) % MOD ;
      }
    }
    memo . get ( cur ) . put ( last3 , ret ) ;
    return ret ;
  }
  
private static long dfs ( int cur , String last3 ) { if ( memo . get ( cur ) . containsKey ( last3 ) ) { return memo . get ( cur ) . get ( last3 ) ; } if ( cur == N ) { return 1 ; } long ret = 0 ; char [ ] cList = { ' A ' , ' C ' , ' G ' , ' T ' } ; for ( char c : cList ) { if ( ok ( last3 + c ) ) { ret = ( ret + dfs ( cur + 1 , last3 . substring ( 1 ) + c ) ) % MOD ; } } memo . get ( cur ) . put ( last3 , ret ) ; return ret ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (type_identifier) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (return_statement (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (return_statement (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_initializer (character_literal) (character_literal) (character_literal) (character_literal)))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))) right: (identifier)))))) right: (identifier)))))))) (expression_statement (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list (identifier) (identifier)))) (return_statement (identifier))))