public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int cases = sc . nextInt ( ) ;
  for ( int caze = 1 ;
  caze <= cases ;
  caze ++ ) {
    int N = sc . nextInt ( ) ;
    int K = sc . nextInt ( ) ;
    int [ ] sums = new int [ N - K + 1 ] ;
    for ( int i = 0 ;
    i < sums . length ;
    i ++ ) {
      sums [ i ] = sc . nextInt ( ) ;
    }
    int [ ] min = new int [ K ] , max = new int [ K ] ;
    for ( int i = 0 ;
    i < K ;
    i ++ ) {
      int val = 0 ;
      for ( int j = i ;
      j + 1 < sums . length ;
      j += K ) {
        val += sums [ j + 1 ] - sums [ j ] ;
        min [ i ] = Math . min ( min [ i ] , val ) ;
        max [ i ] = Math . max ( max [ i ] , val ) ;
      }
    }
    int sumModulo = 0 , maxInterval = 0 , canUse = 0 ;
    for ( int i = 0 ;
    i < K ;
    i ++ ) {
      sumModulo -= min [ i ] ;
      maxInterval = Math . max ( maxInterval , max [ i ] - min [ i ] ) ;
    }
    for ( int i = 0 ;
    i < K ;
    i ++ ) {
      canUse += maxInterval - ( max [ i ] - min [ i ] ) ;
    }
    boolean can = false ;
    for ( int i = 0 ;
    i <= canUse ;
    i ++ ) {
      if ( ( sumModulo + i - sums [ 0 ] ) % K == 0 ) {
        can = true ;
        break ;
      }
    }
    if ( ! can ) maxInterval ++ ;
    System . out . println ( "Case #" + caze + ": " + maxInterval ) ;
  }
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cases = sc . nextInt ( ) ; for ( int caze = 1 ; caze <= cases ; caze ++ ) { int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] sums = new int [ N - K + 1 ] ; for ( int i = 0 ; i < sums . length ; i ++ ) { sums [ i ] = sc . nextInt ( ) ; } int [ ] min = new int [ K ] , max = new int [ K ] ; for ( int i = 0 ; i < K ; i ++ ) { int val = 0 ; for ( int j = i ; j + 1 < sums . length ; j += K ) { val += sums [ j + 1 ] - sums [ j ] ; min [ i ] = Math . min ( min [ i ] , val ) ; max [ i ] = Math . max ( max [ i ] , val ) ; } } int sumModulo = 0 , maxInterval = 0 , canUse = 0 ; for ( int i = 0 ; i < K ; i ++ ) { sumModulo -= min [ i ] ; maxInterval = Math . max ( maxInterval , max [ i ] - min [ i ] ) ; } for ( int i = 0 ; i < K ; i ++ ) { canUse += maxInterval - ( max [ i ] - min [ i ] ) ; } boolean can = false ; for ( int i = 0 ; i <= canUse ; i ++ ) { if ( ( sumModulo + i - sums [ 0 ] ) % K == 0 ) { can = true ; break ; } } if ( ! can ) maxInterval ++ ; System . out . println ( " Case ▁ # " + caze + " : ▁ " + maxInterval ) ; } }
(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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (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: (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: (identifier) right: (identifier)) 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: (field_access object: (identifier) field: (identifier))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (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 (identifier)))) declarator: (variable_declarator name: (identifier) 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 (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: (identifier))) condition: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (field_access object: (identifier) field: (identifier))) update: (assignment_expression left: (identifier) right: (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (array_access array: (identifier) index: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (identifier))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) 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: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (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 (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (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: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (array_access array: (identifier) index: (decimal_integer_literal)))) right: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (true))) (break_statement))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (identifier))) consequence: (expression_statement (update_expression (identifier)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (string_literal)) right: (identifier)))))))))