import java.util.Scanner;
import java.io.*;
class dance
{
  public static void main (String[] args) throws IOException
  { 
    File    inputData = new File("B-small-attempt0.in");
	File 	outputData= new File("Boutput.txt");
    Scanner scan = new Scanner( inputData );
	PrintStream print= new PrintStream(outputData);
    
	int t;
	int n,s,p,pi;
	t= scan.nextInt();
	for(int i=1;i<=t;i++)
	{
	n=scan.nextInt();	s=scan.nextInt();	p=scan.nextInt();
	int supTrip=0, notsupTrip=0;
	
	for(int j=0;j<n;j++)
	{
		pi=scan.nextInt();
		if(pi>(3*p-3))
		notsupTrip++;
		else if((pi>=(3*p-4))&&(pi<=(3*p-3))&&(pi>p))
		supTrip++;
	}
	
	if(s<=supTrip)
	notsupTrip=notsupTrip+s;
	else if(s>supTrip)
	notsupTrip= notsupTrip+supTrip;
	print.println("Case #"+i+": "+notsupTrip);
	}
  }
}
package codejam;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.google.common.base.Splitter;

public class ProblemB extends CodeJamRunner {

	
	private int nrOfCases;
	private int testCaseIndex;
	int numberOfGooglers;
	int surprisingTriplets;
	int personalBestBar;
	int maxAbovePersonalBestBar;

	private List<Integer> totalPoints = new ArrayList<Integer>();

	public void process(int lineNr, String line) {
		if (lineNr == 1) {
			nrOfCases = Integer.valueOf(line);
			resetForNextCase();
		} else {
			Iterator<String> split = Splitter.on(" ").split(line).iterator();
			numberOfGooglers = Integer.parseInt(split.next());
			surprisingTriplets = Integer.parseInt(split.next());
			personalBestBar = Integer.parseInt(split.next());
			while ( split.hasNext() ) {
				totalPoints.add(Integer.parseInt(split.next()));
			}
			calc();
			write();
			resetForNextCase();
		}
	}

	private void write() {
		String resultLine = "Case #" + testCaseIndex + ": " + maxAbovePersonalBestBar;
		printlnOutput(resultLine);
	}

	private void calc() {
		int normalAboveCount = 0;
		int surpriseAboveCount = 0;
		for ( int i : totalPoints ) {
			Triplet t = new Triplet( i );
			if ( t.calcMaxNormal() >= personalBestBar ){
				normalAboveCount++;
			}
			else if ( t.calcMaxSurprise() >= personalBestBar ){
				surpriseAboveCount++;
			}
		}
		int surprisesHappened = Math.min(surpriseAboveCount, surprisingTriplets );
		maxAbovePersonalBestBar = normalAboveCount + surprisesHappened;
	}

	private void resetForNextCase() {
		testCaseIndex++;
		totalPoints.clear();
	}

	public static void main(String args[]) {
		ProblemB ao = new ProblemB();
		ao.run(args);
	}

}
