Created
December 7, 2016 07:35
-
-
Save purukaushik/9926cd87f6f66ec20de548a6269f29e0 to your computer and use it in GitHub Desktop.
Competitive Programming template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.purush.hadoop.giscup.script; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.OutputStreamWriter; | |
import java.io.PrintWriter; | |
public class Main { | |
private static int totalchars = 0, offset = 0; | |
private static InputStream stream; | |
private static byte[] buffer = new byte[1024]; | |
private static int readByte() { | |
if (totalchars < 0) | |
return 0; | |
if (offset >= totalchars) { | |
offset = 0; | |
try { | |
totalchars = stream.read(buffer); | |
} catch (IOException e) { | |
return 0; | |
} | |
if (totalchars <= 0) | |
return -1; | |
} | |
return buffer[offset++]; | |
} | |
private static int readInt() { | |
int number = readByte(); | |
while (eolchar(number)) | |
number = readByte(); | |
int sign = 1; | |
int val = 0; | |
if (number == '-') { | |
sign = -1; | |
number = readByte(); | |
} | |
do { | |
if ((number < '0') || (number > '9')) | |
return 0; | |
val *= 10; | |
val += (number - '0'); | |
number = readByte(); | |
} while (!eolchar(number)); | |
return sign * val; | |
} | |
private static boolean eolchar(int c) { | |
return c == ' ' || c == '\n' || c == -1 || c == '\r' || c == '\t'; | |
} | |
public static void main(String[] args) { | |
stream = System.in; | |
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); | |
//READ INPUT, PROCESS | |
pw.flush(); | |
pw.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment