public static void main ( String [ ] args ) throws IOException {
  File in = new File ( "input.txt" ) ;
  Writer wr = new FileWriter ( "output.txt" ) ;
  Scanner sc = new Scanner ( in ) ;
  int n = sc . nextInt ( ) ;
  int [ ] marked = new int [ 2 * 365 + 1 ] ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    int m = sc . nextInt ( ) ;
    int d = sc . nextInt ( ) ;
    int p = sc . nextInt ( ) ;
    int t = sc . nextInt ( ) ;
    int x = cal ( m , d ) ;
    for ( int j = 1 ;
    j <= t ;
    j ++ ) {
      marked [ x - j + 365 ] += p ;
    }
  }
  int ans = 0 ;
  for ( int i = 0 ;
  i < marked . length ;
  i ++ ) {
    ans = Math . max ( marked [ i ] , ans ) ;
  }
  wr . write ( ans + " " ) ;
  wr . flush ( ) ;
  wr . close ( ) ;
}

public static void main ( String [ ] args ) throws IOException { File in = new File ( " input . txt " ) ; Writer wr = new FileWriter ( " output . txt " ) ; Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int [ ] marked = new int [ 2 * 365 + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { int m = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int p = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int x = cal ( m , d ) ; for ( int j = 1 ; j <= t ; j ++ ) { marked [ x - j + 365 ] += p ; } } int ans = 0 ; for ( int i = 0 ; i < marked . length ; i ++ ) { ans = Math . max ( marked [ i ] , ans ) ; } wr . write ( ans + " ▁ " ) ; wr . flush ( ) ; wr . close ( ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_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)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (decimal_integer_literal)) right: (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 (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)))) (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)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (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: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) right: (identifier))))))) (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: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (string_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))