Skip to content

Instantly share code, notes, and snippets.

@Aniruddha-Deb
Created April 24, 2018 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aniruddha-Deb/8433fd09c69f8dbaa78613b95678cfcc to your computer and use it in GitHub Desktop.
Save Aniruddha-Deb/8433fd09c69f8dbaa78613b95678cfcc to your computer and use it in GitHub Desktop.
import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
/**
This is my custom comeptitive programming setup.
@author Aniruddha Deb
*/
class Main {
// FastIO
class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int read() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public int readInt() {
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public int[] readIntArray( int n ) {
int[] x = new int[n];
for( int i=0; i<n; i++ ) {
x[i] = readInt();
}
return x;
}
public String readString() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
public boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public String next() {
return readString();
}
}
class OutputWriter {
private final PrintWriter writer;
public OutputWriter(OutputStream outputStream) {
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
}
public OutputWriter(Writer writer) {
this.writer = new PrintWriter(writer);
}
public void print(Object...objects) {
for (int i = 0; i < objects.length; i++) {
if (i != 0)
writer.print(' ');
writer.print(objects[i].toString());
}
writer.flush();
}
public void println(Object...objects) {
print(objects);
print( "\n" );
}
public void close() {
writer.close();
}
public void flush() {
writer.flush();
}
}
void run() throws Exception {
InputReader ir = new Main().new InputReader( System.in );
OutputWriter ow = new Main().new OutputWriter( System.out );
int numTestCases = ir.readInt();
while( numTestCases > 0 ) {
// write code here
numTestCases--;
}
}
public static void main( String args[] ) throws Exception { new Main().run(); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment