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.FileInputStream;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class ProblemB {
	public static void main(String[] args) throws Exception {

		Scanner in = new Scanner(
		// System.in
		// new FileInputStream("b-small.in")
				new FileInputStream("b-large.in"));
		PrintStream out = new PrintStream(
		// System.out
		// new FileOutputStream("b-small.out")
				new FileOutputStream("b-large.out"));
		int T = in.nextInt();
		in.nextLine();

		for (int i = 1; i <= T; i++) {
			int res = 0;
			int N = in.nextInt();
			int S = in.nextInt();
			int p = in.nextInt();
			int[] ts = new int[N];
			for (int j = 0; j < N; j++)
				ts[j] = in.nextInt();
			in.nextLine();
			Arrays.sort(ts);

			int nscore = Math.max(p * 3 - 2, p);
			int sscore = Math.max(p * 3 - 4, p);

			for (int j = N; --j >= 0;) {
				if (ts[j] >= nscore)
					res++;
				else if (ts[j] >= sscore && S-- > 0)
					res++;
				else
					break;
			}
			out.println("Case #" + i + ": " + res);
		}
	}
}
