import java.util.Random;

/**
 * Created by chavit on 27.10.2015.
 */
public class numbers_stress_vd {
    public static void main(String[] args) {
        long time = System.currentTimeMillis();
        Random rnd = new Random(239);
        for (int i = 1; i <= 100000; i++) {
            if (i % 1000 == 0) {
                System.err.println(i);
                System.err.println("Time = " + (System.currentTimeMillis() - time));
                time = System.currentTimeMillis();
            }
            testSlow(1, i);
            for (int it = 0; it < 20; it++) {
                testSlow(1 + rnd.nextInt(i), i);
            }
        }
        for (int i = 1; ; i++) {
            if (i % 1000 == 0) {
                System.err.println(i);
                System.err.println("Time(fast) = " + (System.currentTimeMillis() - time));
                time = System.currentTimeMillis();
            }
            long n1 = Math.abs(rnd.nextLong());
            long n2 = Math.abs(rnd.nextLong());
            testFast(n1,n2);
        }
    }

    private static void testSlow(int l, int r) {
        long ans1 = new numbers_vd().getAnswer(Integer.toString(l), Integer.toString(r));
        long ans2 = new numbers_linear_vd().getAnswer(l,r);
        long ans3 = new numbers_answertime_vd().getAnswer(Integer.toString(l), Integer.toString(r));
        if (ans1 != ans2 || ans1 != ans3) {
            System.out.println(l + " " + r + " : " + ans1 + " " + ans2);
            throw new AssertionError();
        }
    }

    private static void testFast(long l, long r) {
        long ans1 = new numbers_vd().getAnswer(Long.toString(l), Long.toString(r));
        long ans2 = new numbers_answertime_vd().getAnswer(Long.toString(l), Long.toString(r));
        if (ans1 != ans2) {
            System.out.println(l + " " + r + " : " + ans1 + " " + ans2);
            throw new AssertionError();
        }
    }
}
