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.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;


public class B {

	public static void main(String[] args) throws IOException {
		int nCases;
		String filename="B-large";
		//String filename="B-small-attempt0";
		//String filename="TestB";
		Scanner reader = new Scanner (new FileReader(filename + ".in"));
		PrintWriter writer = new PrintWriter(new FileWriter(filename + ".out"));

		nCases = reader.nextInt();
		for (int i=0; i<nCases; i++){
			writer.print("Case #" + (i+1)+": ");
		
			int nDancers= reader.nextInt();
			int S = reader.nextInt();
			int p = reader.nextInt();
			int out = 0; //output
			
			for (int j=0;j<nDancers;j++){
				int temp = reader.nextInt();
				if (temp > 3*p-3)
					out++;
				else if (S>0 && (temp == 3*p-3 || temp == 3*p-4) && p!=1){
					out ++;
					S--;
				}
			}
			
			writer.println(out);
		}
		writer.flush();

	}

}
