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();
        }
    }
}

package codejam;

import java.io.*;
public class Dance {
    public static void main(String[] args)throws IOException{
        BufferedReader cin=new BufferedReader(new FileReader("B-large.in"));
        PrintWriter cout=new PrintWriter(new BufferedWriter(new FileWriter("out1.txt")));
        String[] in;
        int x,y,n,p,s,count,a;
        int t=Integer.parseInt(cin.readLine());
        for(int i=0;i<t;i++){
            count=0;
            in=cin.readLine().split(" ");
            n=Integer.parseInt(in[0]);
            s=Integer.parseInt(in[1]);
            p=Integer.parseInt(in[2]);
            int sum=3*p-3;
            for(int j=3;j<n+3;j++){
                a=Integer.parseInt(in[j]);
                if(a==0){
                    if(p==0) count++;
                    continue;
                }
                if(a>sum){
                    count++;
                    continue;
                }
                if(a>=sum-1 && s>0){
                    count++;
                    s--;
                }
            }
            cout.println("Case #"+(i+1)+": "+count);
        }
        cout.flush();
    }
}
