package template;

import java.io.*;
import java.util.Random;

public class JavaStressTestGenerator {

    private static final String OUTPUT_GENERATED_FOR_TEST_FILE = "in/stress_test.in";

    static class FastOutput {

        private static String UTF_8 = "UTF-8";

        private PrintWriter outputFileWriter;
        private PrintStream consoleWriter;
        private StringBuilder builder;

        FastOutput(boolean printBatch) {
            if (printBatch) {
                this.consoleWriter = System.out;
            } else {
                this.builder = new StringBuilder();
            }
        }

        FastOutput(String outputFile) {
            try {
                this.outputFileWriter = new PrintWriter(outputFile, UTF_8);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }

        public void println(String str) {
            if (outputFileWriter != null) {
                outputFileWriter.println(str);
            }
            if (consoleWriter != null) {
                consoleWriter.println(str);
            }
            if (builder != null) {
                builder.append(str).append("\n");
            }
        }

        public void print(String str) {
            if (outputFileWriter != null) {
                outputFileWriter.print(str);
            }
            if (consoleWriter != null) {
                consoleWriter.print(str);
            }
            if (builder != null) {
                builder.append(str);
            }
        }

        public void save() {
            if (outputFileWriter != null) {
                outputFileWriter.close();
            }
            if (consoleWriter != null) {
                consoleWriter.close();
            }
            if (builder != null) {
                System.out.println(builder.toString());
            }
        }

        public void reset() {
            if (builder != null) {
                builder = new StringBuilder();
            }
        }

    }

    public static int randomRange(int min, int max) {
        return new Random().nextInt(max - min + 1) + min;
    }

    public void run() {
        FastOutput output = new FastOutput(OUTPUT_GENERATED_FOR_TEST_FILE);
        output.save();
    }

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

}
