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 jam2012.qround;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class PB {
	public static void main(String args[])
	{
		int line = 0;
		try{
			BufferedReader br = new BufferedReader(new FileReader("B-large.in"));
			BufferedWriter bw = new BufferedWriter(new FileWriter("B-large.out"));
			String str;
			String[] strIn;
			System.out.println(Integer.parseInt(br.readLine()));
			while ((str = br.readLine()) != null){
				strIn = str.split(" ");
				int i=0;
				int N = Integer.parseInt(strIn[i++]);
				int S = Integer.parseInt(strIn[i++]);
				float p = Integer.parseInt(strIn[i++]);
				int cases = 0;
				while(N>0){
					float score = Integer.parseInt(strIn[i++]);
					N--;
					if (score >= (3*p-2))
						cases++;
					else 
						if (score >= (3*p-4) && S>0 && score >=2){
							cases++;
							S--;
						}	
				}
				line++;
				System.out.println("Case #"+line+": "+cases);
				bw.write("Case #"+line+": "+cases);
				bw.newLine();
			}
			br.close();
			bw.close();
		}catch (Exception e){//Catch exception if any
			System.err.println("Error: " + e.getMessage());
		}
	}
}
