import java.io.*;

class code1
{
	public static void main(String args[]) throws Exception 
	{
		File ii = new File ("C-small-attempt1.in");
		FileInputStream fis = new FileInputStream(ii);
		BufferedReader  br = new BufferedReader(new InputStreamReader (fis));
		int cases = Integer.parseInt(br.readLine());
		FileOutputStream fout = new FileOutputStream ("output.txt");
		DataOutputStream dout = new DataOutputStream (fout);
		int total=0;
		for(int i=0;i<cases;i++){
		String temp = br.readLine();
		String parts [] = temp.split(" ");
		int lower = Integer.parseInt(parts[0]);
		int upper = Integer.parseInt(parts[1]);
		System.out.println(lower+" "+upper);
		
		for(int j=lower;j<=upper;j++)
		{
			int abc = j;int length=0;
			if(j<10)continue;
			while (abc!=0){abc/=10;length++;}
			abc=j;
			for(int m=0;m<length-1;m++){
				int shift = abc%10;
				abc=abc/10;
				System.out.println("hi "+j);
				abc=abc+shift*power(10,length-1);
				if(abc<=upper&&shift!=0&&abc>j)total++;
				System.out.println(total);
			}
		}
 		dout.writeBytes("Case #"+(i+1)+ ": "+total+"\n");
 		total=0;
		}//for close
		
	}

	private static int power(int i, int j) {
		int no=1;
		for(int a=0;a<j;a++){no=10*no;}
		return no;
	}
}
package info.m3o.gcj2012.recyclednumber;


public class MainRecycledNumber {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		// String infilepath = "C:\\eclipse\\workspace\\gcjRecycledNumber\\data\\inputTest.txt";
		
		// String infilepath = "C:\\eclipse\\git_home\\git\\gcjRecycledNumber1\\gcjRecycledNumber\\data\\inputLarge.txt";
		String infilepath = "C:\\eclipse\\git_home\\git\\gcjRecycledNumber1\\gcjRecycledNumber\\data\\inputSmall.txt";

		
		//		String infilepath = "C:\\eclipse\\workspace\\gcjRecycledNumber\\data\\inputSmall.txt";
		//		String infilepath = "C:\\eclipse\\workspace\\gcjRecycledNumber\\data\\inputLarge.txt";

		InputFileLoader inputFileLoader = new InputFileLoader(infilepath);


		inputFileLoader.readInputFile();


		int inT = Integer.valueOf(inputFileLoader.getRawInputLines().get(0));
		// Remove the fist line, which is no logner needed.
		inputFileLoader.getRawInputLines().remove(0);


		int inA, inB;
		int caseCount = 0;
		// System.out.println("T=" + inT);

		ResultUtil resultUtil = new ResultUtil();

		for (String line : inputFileLoader.getRawInputLines()){
			String[] s = line.split("\\s");

			inA = Integer.valueOf(s[0]);
			inB = Integer.valueOf(s[1]);
			// System.out.println("A=" + inA + "B=" + inB );
			caseCount++;

			/*
			 *  Start the actual Job
			 */
			resultUtil.clearSets();
			int n, numRecycledNumber;
			RecycledNumber recycledNumber;

			
			for (n = inA; n <= inB; n++) {
				recycledNumber = new RecycledNumber(n, inA, inB);
				recycledNumber.addRecycledNumbers(resultUtil.recycledNumberSet,
						resultUtil.testedNumberSet);
				for (String str : RecycledNumber.getCycledNumber(recycledNumber
						.getNumStr())) {
					recycledNumber.addRecycledNumbers(resultUtil.recycledNumberSet,
							resultUtil.testedNumberSet, str);
					
				}

				// recycledNumber.addRecycledNumbers(resultUtil.recycledNumberSet,
				// resultUtil.testedNumberSet);
			}			numRecycledNumber = resultUtil.recycledNumberSet.size();
			

			
			
			System.out.print("Case #"+ caseCount+": ");
			System.out.println(numRecycledNumber);
			/*
			for (MyNumberStringPair mnsp: resultUtil.recycledNumberSet){
				System.out.print(mnsp.getS1() + " " + mnsp.getS2() + " " );
			}
			System.out.println("END");
			*/
		}

		/*
		System.out.println("caseCount="+caseCount);
		*/
		assert (inT == caseCount) : "CaseCount mismatch";

	}

}
