package dancinggooglers;

import java.io.File;
import java.util.Scanner;

public class DanceScoreCalculator {


    public static void main(String[] args) {
        if(args.length <= 0 || args[0] == null) {
            System.out.println("You must enter a file to read");
            System.out.println("Usage: blah <filename>");
            System.exit(0);
        }

        File argFile = new File(args[0]);
        try {
            Scanner googleSpeakScanner = new Scanner(argFile);
            String firstLine = googleSpeakScanner.nextLine();
            Integer linesToScan = new Integer(firstLine);
            for(int i = 1; i <= linesToScan; i++) {
                String googleDancerLine = googleSpeakScanner.nextLine();
                DanceScoreCase danceCase = new DanceScoreCase(googleDancerLine);
                System.out.println(String.format("Case #%d: %d", i, danceCase.maxDancersThatCouldPass()));
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}

import java.util.*;
import java.io.*;
public class Googlers {
   public static void main(String[] args)throws IOException {
    Scanner sc = new Scanner(new File("input2.txt"));
    int loop = sc.nextInt();
    int num;
    int s = 0;
    int p;
    int n;
    int count = 0;
    int check;
    
    ArrayList<Integer> array = new ArrayList<Integer>();
    for (int i = 0 ; i < loop ; i++)  {
      num = sc.nextInt();
      s = sc.nextInt();
      p = sc.nextInt();
      for (int j=0 ; j<num ;j++){
        array.add(sc.nextInt());
      }
      n = p*3-2;
      for (Integer in : array){
        if (in >= n)
          count++;
        else {
          if(s>0){
            check = (p+(p-2)*2);
            if(in >= check && check >0){
              count++;
              s--;
            }
          }
        }   
      }
      System.out.println("Case #"+(i+1)+": "+count);
      count = 0;
      array.clear();
    }
    
   }
}