Question:
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt(), m=fsc.nextInt();
        HashSet<Integer> dists[]=new HashSet[n];
        HashSet<Integer> edges[]=new HashSet[n];
        HashSet<Integer> mods[]=new HashSet[n];
        for(int i=0;i<n;i++){
            dists[i]=new HashSet();
            edges[i]=new HashSet();
            mods[i]=new HashSet();
        }
        for(int j=0;j<m;j++) edges[fsc.nextInt()-1].add(fsc.nextInt()-1);
        int s=fsc.nextInt()-1, t=fsc.nextInt()-1;
        fsc.close();
        dists[s].add(0);
        mods[s].add(0);
        IntQueue q=new IntQueue(10*n);
        for(int i=0;i<n;i++){
            q.init();
            q.add(s);
            while(q.size()>0){
                int now=q.poll();
                for(int v:edges[now]){
                    boolean b=false;
                    for(int dist:dists[now]){
                        if(!mods[v].contains((dist+1)%3)){
                            mods[v].add((dist+1)%3);
                            dists[v].add(dist+1);
                            b=true;
                        }
                    }
                    if(b) q.add(v);
                }
            }
        }
        int min=Integer.MAX_VALUE;
        for(int dist: dists[t]) if(dist%3==0) min=Math.min(min, dist/3);
        if(min==Integer.MAX_VALUE) min=-1;
        System.out.println(min);
    }
    static class IntQueue{
        int[] a;
        private int max;
        int head=0, tail=0;
        private int size=0;
        public IntQueue(int max){
            this.max=max;
            a=new int[max];
        }
        public IntQueue(){
            this.max=Integer.MAX_VALUE;
            a=new int[max];
        }
        public void add(int x){
            a[tail++]=x;
            size++;
        }
        public int poll(){
            if(size==0) System.exit(1);
            size--;
            return a[head++];
        }
        public void init(){
            tail=0; head=0; size=0;
        }
        public int size(){
            return size;
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

Choices:
- Time Limit Exceeded
- Compile Error
- Memory Limit Exceeded
- Internal error


Question:
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt(), m=fsc.nextInt();
        Node[] nodes=new Node[n];
        for(int i=0;i<n;i++) nodes[i]=new Node();
        for(int j=0;j<m;j++){
            int u=fsc.nextInt()-1, v=fsc.nextInt()-1;
            nodes[u].edges.add(v);
        }
        int s=fsc.nextInt()-1, t=fsc.nextInt()-1;
        fsc.close();
        nodes[s].dists.add(0);
        for(int i=0;i<3;i++){
            IntQueue q=new IntQueue(10*n);
            q.add(s);
            HashSet<Integer> visited=new HashSet<>();
            while(q.size()>0){
                int now=q.poll();
                for(int v:nodes[now].edges){
                    for(int dist:nodes[now].dists) nodes[v].dists.add(dist+1);
                    if(!visited.contains(v)){
                        visited.add(v);
                        q.add(v);
                    }
                }
            }
        }
        int min=Integer.MAX_VALUE;
        for(int dist:nodes[t].dists) if(dist%3==0) min=Math.min(min, dist/3);
        if(min==Integer.MAX_VALUE) min=-1;
        System.out.println(min);
    }
    static class Node{
        HashSet<Integer> dists;
        HashSet<Integer> edges;
        public Node(){
            dists=new HashSet<>();
            edges=new HashSet<>();
        }
    }
    static class Edge{
        int id;
        long cost;
        public Edge(int id, long cost){
            this.id=id;
            this.cost=cost;
        }
    }
    static class IntQueue{
        int[] a;
        private int max;
        int head=0, tail=0;
        private int size=0;
        public IntQueue(int max){
            this.max=max;
            a=new int[max];
        }
        public IntQueue(){
            this.max=Integer.MAX_VALUE;
            a=new int[max];
        }
        public void add(int x){
            a[tail++]=x;
            size++;
        }
        public int poll(){
            if(size==0) System.exit(1);
            size--;
            return a[head++];
        }
        public int size(){
            return size;
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

Choices:
- Memory Limit Exceeded
- Runtime Error
- No abnormally found
- Time Limit Exceeded


Question:
import java.util.*;
import java.io.*;

class　Main{
    static long MOD=1000000007;
    static long[][] dp;
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt(), m=fsc.nextInt();
        int[] s=new int[n];
        int[] t=new int[m];
        for(int i=0;i<n;i++) s[i]=fsc.nextInt();
        for(int j=0;j<m;j++) t[j]=fsc.nextInt();
        fsc.close();
        dp=new long[n+1][m+1];
        for(int i=n;i>=0;i--){
            for(int j=m;j>=0;j--){
                if(i==n) dp[i][j]=0;
                else if(i==n-1){
                    if(j==m) dp[i][j]=0;
                    else if(s[i]==t[j]) dp[i][j]=dp[i][j+1]+1;
                    else dp[i][j]=dp[i][j+1];
                }
                else{
                    if(j==m) dp[i][j]=0;
                    else if(s[i]==t[j]){
                        if(j==m-1) dp[i][j]=dp[i+1][j]+1;
                        else dp[i][j]=dp[i+1][j]+dp[i][j+1]+1;
                    }
                    else{
                        dp[i][j]=dp[i][j+1]+dp[i+1][j]-dp[i+1][j+1];
                    }
                }
                dp[i][j]%=MOD;
            }
        }
        // for(int i=0;i<n;i++){
        //     for(int j=0;j<m;j++){
        //         System.out.print("dp["+i+"]["+j+"]:"+dp[i][j]+" ");
        //     }
        //     System.out.println("");
        // }
        System.out.println(dp[0][0]+1);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

Choices:
- Runtime Error
- Compile Error
- Memory Limit Exceeded
- Time Limit Exceeded


Question:
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int h=sc.nextInt(), w=sc.nextInt();
        char[][] c=new char[h][w];
        for(int i=0;i<h;i++) c[i]=sc.next().toCharArray();
        sc.close();
        int ex=4;
        int[][] sharp=new int[h+ex][w+ex];
        int[][] sharpT=new int[w+ex][h+ex];
        for(int i=0;i<h;i++){
            sharp[i][0]=-1;
            int index=1;
            for(int j=0;j<w;j++){
                if(c[i][j]=='#'){
                    sharp[i][index]=j;
                    index++;
                }
            }
            while(index<w+ex){
                sharp[i][index]=w;
                index++;
            }
        }
        for(int j=0;j<w;j++){
            sharpT[j][0]=-1;
            int index=1;
            for(int i=0;i<h;i++){
                if(c[i][j]=='#'){
                    sharpT[j][index]=i;
                    index++;
                }
            }
            while(index<h+ex){
                sharpT[j][index]=h;
                index++;
            }
        }
        // for(int i=0;i<h+2;i++){
        //     for(int j=0;j<w+2;j++){
        //         System.out.print(sharp[i][j]+" ");
        //     }
        //     System.out.print("\n");
        // }
        // for(int j=0;j<w+2;j++){
        //     for(int i=0;i<h+2;i++){
        //         System.out.print(sharpT[j][i]+" ");
        //     }
        //     System.out.print("\n");
        // }
        int max=Integer.MIN_VALUE;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(c[i][j]=='#') continue;
                int left=binarySearch(sharp[i], j);
                int top=binarySearch(sharpT[j], i);
                int row, column;

                //System.out.println("i,j:"+i+","+j/*+" r:"+row+" c:"+column*/);
                row=sharp[i][left+1]-sharp[i][left]-1;
                column=sharpT[j][top+1]-sharp[j][top]-1;
                max=Math.max(max, row+column-1);
            }
        }
        System.out.println(max);
    }
    public static boolean isOK(int[] array, int index, int key) {
        if (array[index]<key) return true;
        return false;
    }
    public static int binarySearch(int[] array, int key){
        int left=-1;
        int right=array.length;
        while(right-left>1){
            int mid=left+(right-left)/2;
            if(isOK(array, mid, key)) left=mid;
            else right=mid;
        }
        //if(right<array.length && isOK(array, right, key)) return right;
        return left;
    }
}

Choices:
- Memory Limit Exceeded
- Internal error
- Runtime Error
- No abnormally found


Question:
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int h=sc.nextInt(), w=sc.nextInt();
        char[][] c=new char[h][w];
        for(int i=0;i<h;i++) c[i]=sc.next().toCharArray();
        sc.close();
        int[][] sharp=new int[h+2][w+2];
        int[][] sharpT=new int[w+2][h+2];
        for(int i=0;i<h;i++){
            sharp[i][0]=-1;
            int index=1;
            for(int j=0;j<w;j++){
                if(c[i][j]=='#'){
                    sharp[i][index]=j;
                    index++;
                }
            }
            while(index<w+2){
                sharp[i][index]=w;
                index++;
            }
        }
        for(int j=0;j<w;j++){
            sharpT[j][0]=-1;
            int index=1;
            for(int i=0;i<h;i++){
                if(c[i][j]=='#'){
                    sharpT[j][index]=i;
                    index++;
                }
            }
            while(index<h+2){
                sharpT[j][index]=h;
                index++;
            }
        }
        // for(int i=0;i<h+2;i++){
        //     for(int j=0;j<w+2;j++){
        //         System.out.print(sharp[i][j]+" ");
        //     }
        //     System.out.print("\n");
        // }
        // for(int j=0;j<w+2;j++){
        //     for(int i=0;i<h+2;i++){
        //         System.out.print(sharpT[j][i]+" ");
        //     }
        //     System.out.print("\n");
        // }
        int max=Integer.MIN_VALUE;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(c[i][j]=='#') continue;
                int left=binarySearch(sharp[i], j);
                int top=binarySearch(sharpT[j], i);
                int row, column;

                //System.out.println("i,j:"+i+","+j/*+" r:"+row+" c:"+column*/);
                row=sharp[i][left+1]-sharp[i][left]-1;
                column=sharpT[j][top+1]-sharp[j][top]-1;
                max=Math.max(max, row+column-1);
            }
        }
        System.out.println(max);
    }
    public static boolean isOK(int[] array, int index, int key) {
        if (array[index]<key) return true;
        return false;
    }
    public static int binarySearch(int[] array, int key){
        int left=-1;
        int right=array.length;
        while(right-left>1){
            int mid=left+(right-left)/2;
            if(isOK(array, mid, key)) left=mid;
            else right=mid;
        }
        //if(right<array.length && isOK(array, right, key)) return right;
        return left;
    }
}

Choices:
- Memory Limit Exceeded
- No abnormally found
- Time Limit Exceeded
- Runtime Error


Question:
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        MyLong MAX=new MyLong(1_000_000_000l);
        FastScanner fsc=new FastScanner();
        int q=fsc.nextInt();
        long bsum=0;
        long min=0;
        TreeSet<MyLong> fir=new TreeSet<>();
        fir.add(MAX.mlm(-1));
        TreeSet<MyLong> sec=new TreeSet<>();
        sec.add(MAX);
        StringBuilder sb=new StringBuilder();
        boolean rm=false;
        for(int i=0;i<q;i++){
            int query=fsc.nextInt();
            if(query==1){
                MyLong am=new MyLong(fsc.nextLong()), bm=new MyLong(fsc.nextLong());
                MyLong.incr();
                bsum+=bm.l;
                MyLong fl=fir.last();
                MyLong sf=sec.first();
                if(!(fl.l(am.l) && sf.g(am.l))){
                    min+=Math.min(Math.abs(fl.ls(am.l)), Math.abs(sf.ls(am.l)));
                    if(fl.geq(am.l)){
                        if(rm) fir.pollLast();
                        fir.add(am);
                    }
                    else{
                        if(rm) sec.pollFirst();
                        sec.add(am);
                    }
                    rm=false;
                }
                else{
                    fir.add(am);
                    sec.add(am);
                    rm=true;
                }
                while(fir.size()-sec.size()>1) sec.add(fir.pollLast());
                while(sec.size()-fir.size()>1) fir.add(sec.pollFirst());
            }
            else sb.append(fir.last().l).append(" ").append(min+bsum).append("\n");
        }
        fsc.close();
        System.out.print(sb);
    }
}
class MyLong implements Comparable{
    long l;
    static long count=0;
    MyLong(long l){this.l=l;}
    @Override public String toString(){return l*count+l;}
    public int compareTo(Object o){
        if(!(o instanceof MyLong)) return 0;
        MyLong ml=(MyLong) o;
        return l>=ml.l?1:-1;
    }
    public static void incr(){count++;}
    public MyLong mlp(long l){return new MyLong(this.l+l);}
    public MyLong mls(long l){return new MyLong(this.l-l);}
    public MyLong mlm(long l){return new MyLong(this.l*l);}
    public MyLong mld(long l){return new MyLong(this.l/l);}
    public long lp(long l){return this.l+l;}
    public long ls(long l){return this.l-l;}
    public long lm(long l){return this.l*l;}
    public long ld(long l){return this.l/l;}
    public boolean g(long l){return this.l>l;}
    public boolean l(long l){return this.l<l;}
    public boolean geq(long l){return this.l>=l;}
    public boolean leq(long l){return this.l<=l;}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte(){
        if(ptr<buflen) return true;
        else{
            ptr = 0;
            try{
                buflen = in.read(buffer);
            }
            catch(IOException e){
                e.printStackTrace();
            }
            if(buflen<=0) return false;
        }
    return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) throw new NumberFormatException();
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }
            else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
            else throw new NumberFormatException();
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
    public void close(){
        try{in.close();}
        catch(IOException e){e.printStackTrace();}
    }
}

Choices:
- Compile Error
- Runtime Error
- Memory Limit Exceeded
- Time Limit Exceeded


Question:
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        int m=fsc.nextInt();
        int q=fsc.nextInt();
        int[][] lr=new int[m][2];
        int[][] contain=new int[n][n];
        for(int x=0;x<n;x++){
            for(int y=x;y<n;y++){
                contain[x][y]=0;
            }
        }
        for(int i=0;i<m;i++){
            lr[i][0]=fsc.nextInt()-1;
            lr[i][1]=fsc.nextInt()-1;
            for(int x=0;x<=lr[i][0];x++){
                for(int y=lr[i][1];y<n;y++){
                    contain[x][y]++;
                }
            }
        }
        StringBuilder sb=new StringBuilder("");
        for(int k=0;k<q;k++){
            int ql=fsc.nextInt()-1;
            int qr=fsc.nextInt()-1;
            sb.append(contain[ql][qr]+"\n");
        }
        fsc.close();
        PrintWriter pw=new PrintWriter(System.out);
        pw.print(sb);
        pw.flush();
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

Choices:
- Time Limit Exceeded
- Compile Error
- No abnormally found
- Runtime Error


Question:
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        int m=fsc.nextInt();
        int[][] ab=new int[m][2];
        A[] a=new A[n-1];
        for(int k=0;k<n-1;k++){
            a[k]=new A();
        }
        for(int i=0;i<m;i++){
            ab[i][0]=fsc.nextInt()-1;
            ab[i][1]=fsc.nextInt()-1;
            for(int j=ab[i][0];j<ab[i][1];j++){
                a[j].reqs++;
                a[j].reqno.add(i);
            }
        }
        fsc.close();
        //Arrays.sort(ab, new C());
        int res=0;
        int manyreq=-1;
        int reqno=0;
        // for(int k=0;k<n-1;k++){
        //     System.out.println(req[k]);
        // }
        while(true){
            for(int k=0;k<n-1;k++){
                if(a[k].reqs>reqno){
                    reqno=a[k].reqs;
                    manyreq=k;
                }
            }
            if(manyreq==-1) break;
            for(int index:a[manyreq].reqno){
                for(int l=ab[index][0];l<ab[index][1];l++) a[l].reqs--;
                ab[index][0]=-1;
                ab[index][1]=-1;
            }
            res++;
            manyreq=-1;
            reqno=0;
            // for(int k=0;k<n-1;k++){
            //     System.out.println(req[k]);
            // }
        }
        System.out.println(res);
    }
    static class A{
        int reqs;
        HashSet<Integer> reqno;
        public A(){
            this.reqs=0;
            this.reqno=new HashSet<Integer>();
        }
    }
    static class C implements Comparator<int[]>{
        @Override
        public int compare(int[] x, int[] y){
            return x[0]>y[0]?1:x[0]<y[0]?-1:0;
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

Choices:
- Internal error
- Time Limit Exceeded
- No abnormally found
- Runtime Error


Question:
import java.util.*;

public class ABC057{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(sc.next());
        int a=Integer.parseInt(sc.next());
        int b=Integer.parseInt(sc.next());
        ArrayList<Long> v=new ArrayList<Long>();
        for(int i=0;i<n;i++){
            v.add(Long.parseLong(sc.next()));
        }
        sc.close();
        Collections.sort(v,(v1, v2)->{
            if(v1<v2) return 1;
            else if(v1>v2) return -1;
            else return 0;
        });
        long min=v.get(a-1);
        int minCount=0;
        int befA=1;
        double avg=0;
        for(int i=0;i<n;i++){
            if(i<a) avg+=v.get(i);
            if(v.get(i)==min) minCount++;
            if(i==a-1) befA=minCount;
        }
        avg=avg/((double) a);
        long pattern=0;
        long minCj;
        int minCount2;
        int j_max=befA;
        if(min==v.get(0)) j_max+=b-a;
        for(int j=befA;j<=j_max;j++){
            minCount2=minCount;
            minCj=1;
            for(int d=1;d<=j;d++){
                minCj*=minCount2;
                minCount2--;
                minCj/=d;
            }
            pattern+=minCj;
        }
        System.out.println(String.format("%.6f", avg));
        System.out.println(pattern);
    }
}

Choices:
- Time Limit Exceeded
- Runtime Error
- Internal error
- Compile Error


Question:
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int n = fsc.nextInt();
        int[] children = new int[n];
        int[] leafChildren = new int[n];
        HashSet<Integer> leafParents = new HashSet<>();
        HashSet<Integer> leafs = new HashSet<>();
        for (int i = 0; i < n; i++) {
            leafs.add(i);
        }
        int[] parent = new int[n];
        for (int i = 1; i < n; i++) {
            int p = fsc.nextInt() - 1;
            parent[i] = p;
            children[p]++;
            leafs.remove(p);
        }
        for (int e : leafs) {
            leafParents.add(parent[e]);
            leafChildren[parent[e]]++;
        }
        int rank = 0;
        int matches = 0;
        while (matches < n - 1) {
            HashSet<Integer> lp = new HashSet<>(leafParents);
            for (int p : lp) {
                leafChildren[p]--;
                children[p]--;
                if (leafChildren[p] == 0) {
                    leafParents.remove(p);
                }
                if (children[p] == 0) {
                    leafParents.remove(p);
                    leafParents.add(parent[p]);
                    leafChildren[parent[p]]++;
                }
                matches++;
            }
            rank++;
        }
        System.out.println(rank);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Choices:
- Compile Error
- Internal error
- Time Limit Exceeded
- Runtime Error


Question:
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.HashSet;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int n = fsc.nextInt();
        int[] children = new int[n];
        ArrayDeque<Integer>[] leafChildren = new ArrayDeque[n];
        HashSet<Integer> leafParents = new HashSet<>();
        HashSet<Integer> leafs = new HashSet<>();
        for (int i = 0; i < n; i++) {
            leafChildren[i] = new ArrayDeque<>();
            leafs.add(i);
        }
        int[] parent = new int[n];
        for (int i = 1; i < n; i++) {
            int p = fsc.nextInt() - 1;
            parent[i] = p;
            children[p]++;
            leafs.remove(p);
        }
        for (int e : leafs) {
            leafParents.add(parent[e]);
            leafChildren[parent[e]].addLast(e);
        }
        int rank = 0;
        int matches = 0;
        while (matches < n - 1) {
            HashSet<Integer> add = new HashSet<>();
            HashSet<Integer> rm = new HashSet<>();
            for (int p : leafParents) {
                leafChildren[p].pollFirst();
                children[p]--;
                if (leafChildren[p].size() == 0) {
                    rm.add(p);
                    add.remove(p);
                }
                if (children[p] == 0) {
                    rm.add(p);
                    add.remove(p);
                    rm.remove(parent[p]);
                    add.add(parent[p]);
                    leafChildren[parent[p]].addLast(p);
                }
                matches++;
            }
            for (int rmv : rm) {
                leafParents.remove(rmv);
            }
            for (int ad : add) {
                leafParents.add(ad);
            }
            rank++;
        }
        System.out.println(rank);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Choices:
- Internal error
- Memory Limit Exceeded
- Runtime Error
- Time Limit Exceeded


Question:
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int n = fsc.nextInt();
        HashSet<Integer>[] children = new HashSet[n];
        LinkedList<Integer>[] leafChildren = new LinkedList[n];
        HashSet<Integer> leafParents = new HashSet<>();
        HashSet<Integer> leafs = new HashSet<>();
        for (int i = 0; i < n; i++) {
            children[i] = new HashSet<>();
            leafChildren[i] = new LinkedList<>();
            leafs.add(i);
        }
        int[] parent = new int[n];
        for (int i = 1; i < n; i++) {
            int p = fsc.nextInt() - 1;
            parent[i] = p;
            children[p].add(i);
            leafs.remove(p);
        }
        for (int e : leafs) {
            leafParents.add(parent[e]);
            leafChildren[parent[e]].addLast(e);
        }
        int rank = 0;
        int matches = 0;
        while (matches < n - 1) {
            HashSet<Integer> add = new HashSet<>();
            HashSet<Integer> rm = new HashSet<>();
            for (int p : leafParents) {
                int child = leafChildren[p].removeFirst();
                children[p].remove(child);
                if (leafChildren[p].size() == 0) {
                    rm.add(p);
                    add.remove(p);
                }
                if (children[p].size() == 0) {
                    rm.add(p);
                    add.remove(p);
                    rm.remove(parent[p]);
                    add.add(parent[p]);
                    leafChildren[parent[p]].addLast(p);
                }
                matches++;
            }
            for (int rmv : rm) {
                leafParents.remove(rmv);
            }
            for (int ad : add) {
                leafParents.add(ad);
            }
            rank++;
        }
        System.out.println(rank);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Choices:
- Time Limit Exceeded
- Runtime Error
- Internal error
- No abnormally found


Question:
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int n = fsc.nextInt();
        HashSet<Integer>[] children = new HashSet[n];
        LinkedList<Integer>[] leafChildren = new LinkedList[n];
        HashSet<Integer> leafParents = new HashSet<>();
        HashSet<Integer> leafs = new HashSet<>();
        for (int i = 0; i < n; i++) {
            children[i] = new HashSet<>();
            leafChildren[i] = new LinkedList<>();
            leafs.add(i);
        }
        int[] parent = new int[n];
        for (int i = 1; i < n; i++) {
            int p = fsc.nextInt() - 1;
            parent[i] = p;
            children[p].add(i);
            leafs.remove(p);
        }
        for (int e : leafs) {
            leafParents.add(parent[e]);
            leafChildren[parent[e]].addLast(e);
        }
        int rank = 0;
        int matches = 0;
        while (matches < n - 1) {
            HashSet<Integer> lpcp = new HashSet<>(leafParents);
            for (int p : lpcp) {
                int child = leafChildren[p].removeFirst();
                children[p].remove(child);
                if (leafChildren[p].size() == 0) {
                    leafParents.remove(p);
                }
                if (children[p].size() == 0) {
                    leafParents.remove(p);
                    leafParents.add(parent[p]);
                    leafChildren[parent[p]].addLast(p);
                }
                matches++;
            }
            rank++;
        }
        System.out.println(rank);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Choices:
- Memory Limit Exceeded
- Time Limit Exceeded
- No abnormally found
- Compile Error


Question:
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int n = fsc.nextInt();
        HashSet<Integer>[] children = new HashSet[n];
        LinkedList<Integer>[] leafChildren = new LinkedList[n];
        HashSet<Integer> leafParents = new HashSet<>();
        HashSet<Integer> leafs = new HashSet<>();
        for (int i = 0; i < n; i++) {
            children[i] = new HashSet<>();
            leafChildren[i] = new LinkedList<>();
            leafs.add(i);
        }
        int[] parent = new int[n];
        for (int i = 1; i < n; i++) {
            int p = fsc.nextInt() - 1;
            parent[i] = p;
            children[p].add(i);
            leafs.remove(p);
        }
        for (int e : leafs) {
            leafParents.add(parent[e]);
            leafChildren[parent[e]].addLast(e);
        }
        int rank = 0;
        int matches = 0;
        while (matches < n - 1) {
            HashSet<Integer> newLeafs = new HashSet<>();
            HashSet<Integer> noLeafChild = new HashSet<>();
            for (int p : leafParents) {
                int child = leafChildren[p].removeFirst();
                children[p].remove(child);
                if (children[p].size() == 0) {
                    newLeafs.add(p);
                    leafChildren[parent[p]].addLast(p);
                }
                if (leafChildren[p].size() == 0) {
                    noLeafChild.add(p);
                }
                matches++;
            }
            for (int c : noLeafChild) {
                leafParents.remove(c);
            }
            for (int c : newLeafs) {
                leafParents.remove(c);
                leafParents.add(parent[c]);
            }
            rank++;
        }
        System.out.println(rank);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Choices:
- Time Limit Exceeded
- No abnormally found
- Internal error
- Memory Limit Exceeded


Question:
import java.security.SecureRandom;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] a = new int[n][n-1];

        for(int i=0; i<n; i++) {
            for(int j=0; j<n-1; j++) {
                a[i][j] = sc.nextInt() - 1;
            }
        }

        int[] q = new int[n];
        for(int i=0; i<n; i++) {
            q[i] = i;
        }
        Random r = new SecureRandom();
        for(int i=0; i<n; i++) {
            int j = r.nextInt(n);
            int t = q[i];
            q[i] = q[j];
            q[j] = t;
        }

        int[] p = new int[n];
        int fc = 0;
        int res = 0;

        while(true) {
            res++;
            boolean[] v = new boolean[n];
            int c = 0;
            for(int i=0; i<n; i++) {
                int x = q[i];
                if(v[x] || p[x] == n - 1) continue;
                int y = a[x][p[x]];
                if(v[y] || a[y][p[y]] != x) continue;
                v[x] = v[y] = true;
                p[x]++;
                p[y]++;
                if(p[x] == n-1) fc++;
                if(p[y] == n-1) fc++;
                c++;
            }
            if(c == 0) {
                System.out.println(-1);
                return;
            }
            if(fc == n) break;
        }
        System.out.println(res);
    }

}

Choices:
- Memory Limit Exceeded
- Time Limit Exceeded
- Internal error
- No abnormally found


Question:
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] a = new int[n][n-1];

        for(int i=0; i<n; i++) {
            for(int j=0; j<n-1; j++) {
                a[i][j] = sc.nextInt() - 1;
            }
        }

        int[] p = new int[n];
        int fc = 0;
        int res = 0;

        while(true) {
            res++;
            boolean[] v = new boolean[n];
            int c = 0;
            for(int i=0; i<n; i++) {
                int x = i;
                if(v[x] || p[x] == n - 1) continue;
                int y = a[i][p[i]];
                if(v[y] || a[y][p[y]] != x) continue;
                v[x] = v[y] = true;
                p[x]++;
                p[y]++;
                if(p[x] == n-1) fc++;
                if(p[y] == n-1) fc++;
                c++;
            }
            if(c == 0) {
                System.out.println(-1);
                return;
            }
            if(fc == n) break;
        }
        System.out.println(res);
    }

}

Choices:
- Internal error
- Runtime Error
- No abnormally found
- Time Limit Exceeded


Question:
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        System.out.println(xor(a-1) ^ xor(b));
    }

    static long xor(long a) {
        long res = 0;
        int d4 = (int) (a % 4);
        long[] d4a = {0, 1, 1, 0};
        int d8 = (int)  (a % 4);
        long[] d8a = {0, 0, 1, 0, 0, 0, 1, 0};
        long[] da = {1, 0, 1, 0};
        res += d4a[d4];
        res += d8a[d8] << 1;
        for(int i=2; i<50; i++) {
            if((a >> i) % 2 == 1) {
                res += da[d4] << i;
            }
        }
        return res;

    }

}

Choices:
- No abnormally found
- Compile Error
- Memory Limit Exceeded
- Runtime Error


Question:
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long d = scan.nextInt();
		int count = 0;
		for(int i = 0; i < n; i++) {
			long x = scan.nextLong();
			long y = scan.nextLong();
			long xx;
			long yy;
			xx = (long)Math.pow(x,2);
			yy = (long)Math.pow(y,2);

			if(d>=Math.sqrt(xx+yy)) {
				count = count + 1;
			}
		}
		System.out.println(count);
	}

Choices:
- No abnormally found
- Memory Limit Exceeded
- Time Limit Exceeded
- Compile Error


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            int q = Integer.parseInt(in.next());
            int[] b = new int[q];
            int[] c = new int[q];
            for (int i = 0; i < q; i++) {
                b[i] = Integer.parseInt(in.next());
                c[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < q; i++) {
                long sum = 0;
                for (int j = 0; j < n; j++) {
                    if (a[j] == b[i]) a[j] = c[i];
                    sum += a[j];
                }
                out.println(sum);
            }

        }

    }
}

Choices:
- Time Limit Exceeded
- Internal error
- No abnormally found
- Runtime Error


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long a = Long.parseLong(in.next());
            long b = Long.parseLong(in.next());
            long n = Long.parseLong(in.next());
            long ans = -1;
            long cnt = b;

            if (n < b) cnt = n;
            if (n >= b) {
                ans = f(a, b, b - 1);
            } else {

                for (int i = 1; i <= cnt; i++) {
                    long tmp = f(a, b, i);
                    if (tmp - ans < 0) {
                        break;
                    }
                    ans = Math.max(ans, tmp);
                }
            }

            // 出力
            out.println(ans);

        }

        public static long f(long a, long b, long x) {
            long res = 0;
            res = (long) (Math.floor(a * x / b) - a * Math.floor(x / b));
            return res;
        }

    }
}

Choices:
- Time Limit Exceeded
- Memory Limit Exceeded
- Runtime Error
- Compile Error


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long a = Long.parseLong(in.next());
            long b = Long.parseLong(in.next());
            long n = Long.parseLong(in.next());
            long ans = -1;
            long cnt = b;

            if (n < b) cnt = n;
            for (int i = 1; i <= cnt; i++) {
                long tmp = f(a, b, i);
                if (tmp - ans < 0) {
                    break;
                }
                ans = Math.max(ans, tmp);
            }

            // 出力
            out.println(ans);

        }

        public static long f(long a, long b, long x) {
            long res = 0;
            res = (long) (Math.floor(a * x / b) - a * Math.floor(x / b));
            return res;
        }

    }
}

Choices:
- Internal error
- Runtime Error
- Memory Limit Exceeded
- Time Limit Exceeded


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long n = Long.parseLong(in.next());
            long k = Long.parseLong(in.next());
            long ans = 0;
            long x = 0;

            x = n;
            long tmp = Long.MAX_VALUE;
            while (true) {
                if (k == 1) tmp = 0;
                if (n % k == 1) tmp = 1;
                if (n % k == 0) tmp = 0;
                x = Math.abs(x - k);
                tmp = Math.min(tmp, x);
                if (x > tmp) break;
            }
            // 出力
            out.println(tmp);

        }

    }
}

Choices:
- No abnormally found
- Time Limit Exceeded
- Internal error
- Memory Limit Exceeded


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long n = Long.parseLong(in.next());
            long k = Long.parseLong(in.next());
            long ans = 0;
            long x = 0;

            x = n;
            long tmp = Long.MAX_VALUE;
            while (true) {
                x = Math.abs(x - k);
                tmp = Math.min(tmp, x);
                if (x > tmp) break;
                if (k == 1) tmp = 0;
            }
            // 出力
            out.println(tmp);

        }

    }
}

Choices:
- Runtime Error
- Compile Error
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();

            if (S.charAt(3) == S.charAt(4) && S.charAt(5) == S.charAt(6)) {
                out.println("Yes");

            } else {
                out.println("No");
            }

        }

    }
}

Choices:
- No abnormally found
- Memory Limit Exceeded
- Compile Error
- Runtime Error


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            Integer p[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                p[i] = Integer.parseInt(in.next());
            }

            int max = p[0];
            for (int i = 1; i < p.length; i++) {
                int v = p[i];
                if (v > max) {
                    max = v;
                }
            }

            double s[] = new double[n + max];
            s[0] = 0.0;
            s[1] = 1.0;
            for (int i = 1; i < max; i++) {
                s[i + 1] = s[i] + 0.5;
            }

            double ans = 0.0;
            double anstmp = 0.0;
            for (int i = 0; i + k <= n; i++) {
                if (i > 0) anstmp = 0.0;
                for (int j = i; j < i + k; j++) {
                    anstmp += s[p[j]];
                }
                ans = Math.max(anstmp, ans);
            }

            // 出力
            out.println(String.format("%.12f", ans));

        }

    }
}

Choices:
- Compile Error
- Memory Limit Exceeded
- Time Limit Exceeded
- Runtime Error


Question:
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner scanner = new FastScanner(System.in);
        int N = scanner.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = scanner.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans++;
            for (int j = 0; j < i; j++) {
                if (P[i] > P[j]) {
                    ans--;
                    break;
                }
            }
        }

        // 出力
        PrintWriter printWriter = new PrintWriter(System.out);
        printWriter.printf("%d\n", ans);
        printWriter.close();
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
             return Double.parseDouble(next());
         }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}

Choices:
- Time Limit Exceeded
- Memory Limit Exceeded
- Internal error
- No abnormally found


Question:
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner scanner = new FastScanner(System.in);
        int N = scanner.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = scanner.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans++;
            for (int j = 0; j < i; j++) {
                if (P[i] > P[j]) {
                    ans--;
                    break;
                }
            }
        }

        // 出力
        PrintWriter printWriter = new PrintWriter(System.out);
        printWriter.printf("%d\n", ans);
        printWriter.close();
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
             return Double.parseDouble(next());
         }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}

Choices:
- No abnormally found
- Compile Error
- Runtime Error
- Time Limit Exceeded


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int N = Integer.parseInt(in.next());
            int[] P = new int[N];
            for (int i = 0; i < N; i++) {
                P[i] = Integer.parseInt(in.next());
            }
            int ans = 0;
            for (int i = 0; i < N; i++) {
                ans++;
                for (int j = 0; j < i; j++) {
                    if (P[i] > P[j]) {
                        ans--;
                        break;
                    }
                }
            }

            // 出力
            out.println(ans);

        }

    }
}

Choices:
- Internal error
- Runtime Error
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }
        int ans = 0;

        List<String> list = new ArrayList<>();

        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < 1 << d.length; i++) {
            for (int j = 0; j < d.length; j++) {
                if ((i >> j & 1) == 1) {
                    sb.append(d[j]);
                }
            }
            list.add(sb.toString());
        }

        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).length() == 2) {
                ans = ans + Integer.parseInt(list.get(i).substring(0, 1)) * Integer.parseInt(list.get(i).substring(1, 2));
            }
        }
        // 出力
        System.out.println(Integer.toString(ans));

    }
}

Choices:
- Memory Limit Exceeded
- Internal error
- Time Limit Exceeded
- Runtime Error


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int lr[][] = new int[m][2];
            int min = Integer.MAX_VALUE;
            int max = Integer.MIN_VALUE;
            for (int i = 0; i < m; i++) {
                lr[i][0] = Integer.parseInt(in.next());
                lr[i][1] = Integer.parseInt(in.next());
                min = Math.min(min, lr[i][0]);
                max = Math.max(max, lr[i][1]);
            }
            int ans = 0;
            int correct = 0;

            for (int i = min; i <= max; i++) {
                for (int j = 0; j < m; j++) {
                    if (i >= lr[j][0] && i <= lr[j][1]) correct++;
                }
                if (correct == m) ans++;
                correct = 0;
            }

            // 出力
            out.println(ans);

        }

    }
}

Choices:
- Compile Error
- Internal error
- Runtime Error
- Time Limit Exceeded


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int lr[][] = new int[m][2];
            for (int i = 0; i < m; i++) {
                lr[i][0] = Integer.parseInt(in.next());
                lr[i][1] = Integer.parseInt(in.next());
            }
            int ans = 0;
            int correct = 0;

            for (int i = 1; i <= n; i++) {
                for (int j = 0; j < m; j++) {
                    if (i >= lr[j][0] && i <= lr[j][1]) correct++;
                }
                if (correct == m) ans++;
                correct = 0;
            }

            // 出力
            out.println(ans);

        }

    }
}

Choices:
- No abnormally found
- Runtime Error
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CGeTAC solver = new CGeTAC();
        solver.solve(1, in, out);
        out.close();
    }

    static class CGeTAC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int q = Integer.parseInt(in.next());
            String S = in.next();

            // 出力
            for (int i = 0; i < q; i++) {
                int l = Integer.parseInt(in.next());
                int r = Integer.parseInt(in.next());
                out.println(countString(S.substring(--l, r), "AC"));

            }

        }

        private long countString(String str, String a) {
            return (str.length() - str.replace(a, "").length()) / a.length();
        }

    }
}

Choices:
- Runtime Error
- No abnormally found
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            long k = Long.parseLong(in.next());

            if (S.charAt(0) != '1') {
                out.println(S.charAt(0));
            } else {
                out.println(S.charAt(1));
            }

        }

    }
}

Choices:
- Memory Limit Exceeded
- Compile Error
- Runtime Error
- Time Limit Exceeded


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long a = Long.parseLong(in.next());
            long b = Long.parseLong(in.next());
            long c = Long.parseLong(in.next());
            long k = Long.parseLong(in.next());
            long ans = 0;

            long tmpa = 0;
            long tmpb = 0;
            long tmpc = 0;

            if (a == b && b == c && c == a) {

            } else {
                for (int i = 0; i < k; i++) {
                    tmpa = b + c;
                    tmpb = a + c;
                    tmpc = a + b;
                    a = tmpa;
                    b = tmpb;
                    c = tmpc;
                }
            }
            // 出力
            ans = a - b;
            if (Math.abs(ans) >= 1_000_000_000_000_000_000L) out.println("Unfair");
            else out.println(ans);

        }

    }
}

Choices:
- Compile Error
- Internal error
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import java.util.Scanner;

public class MAin {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// N
		int n = sc.nextInt();

		System.out.println(n*n*n);
	}
}

Choices:
- Compile Error
- No abnormally found
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		int a = sc.nextInt();
        int list[];
      list = new int[a];
        double result = 0;
        int i;

      for (i = 0; i < a; i++){
        list(i) = (sc.nextInt());
      }

      Arrays.sort(list);
      result = list.get(0);

      for(i = 1; i < a; i++){
        result = (result + list.get(i))/2.0;
      }

      System.out.println(result);
	}
}

Choices:
- Runtime Error
- Compile Error
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		int a = sc.nextInt();
        int list[];
      list = new int[a];
        double result = 0;
        int i;

      for (i = 0; i < a; i++){
        list(i) = (sc.nextInt());
      }

      list = Arrays.sort(list);
      result = list.get(0);

      for(i = 1; i < a; i++){
        result = (result + list.get(i))/2.0;
      }

      System.out.println(result);
	}
}

Choices:
- Time Limit Exceeded
- Compile Error
- Runtime Error
- No abnormally found


Question:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		int a = sc.nextInt();
        int list[];
      list = new int[a];
        double result = 0;
        int i;

      for (i = 0; i < a; i++){
        list.add(sc.nextInt());
      }

      list = Arrays.sort(list);
      result = list.get(0);

      for(i = 1; i < a; i++){
        result = (result + list.get(i))/2.0;
      }

      System.out.println(result);
	}
}

Choices:
- Compile Error
- Memory Limit Exceeded
- Internal error
- No abnormally found


Question:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		int a = sc.nextInt();
        int list[];
      list = new int[a];
        double result = 0;
        int i;

      for (i = 0; i < a; i++){
        list.add(sc.nextInt());
      }

      list1 = Arrays.sort(list);
      result = list.get(0);

      for(i = 1; i < a; i++){
        result = (result + list.get(i))/2.0;
      }

      System.out.println(result);
	}
}

Choices:
- Runtime Error
- No abnormally found
- Memory Limit Exceeded
- Compile Error


Question:
import java.util.Scanner;
//import java.util.Random;

class a{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);

		String s=stdIn.next();
		for(int i=0;i<3;++i){
			if(s.charAt(i)=='7'){
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");
	}
}

Choices:
- Memory Limit Exceeded
- Compile Error
- Internal error
- Runtime Error


Question:
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long K = sc.nextLong();
		long D = sc.nextLong();

		for(int i = 0; i < K; i ++){
			if(X > 0){
				X -= D;
			}else if(X < 0){
				X += D;
			}
			if(K % 2 == 0 && X == D){
				break;
			}
		}
		System.out.println(Math.abs(X));
	}
}

Choices:
- Memory Limit Exceeded
- No abnormally found
- Runtime Error
- Compile Error


Question:
スコード

Copy
Copy
import java.util.*;

class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
     int A = sc.nextInt();
     int B = sc.nextInt();
     System.out.println(A * B);
   }
}

Choices:
- No abnormally found
- Internal error
- Memory Limit Exceeded
- Compile Error


Question:
import java.util.*;

class Main{
  Scanner sc = new Scanner(System.in);
public static void main(String[] args){
     int A = sc.nextInt();
     int B = sc.nextInt();
     System.out.println(A * B);
   }
}

Choices:
- No abnormally found
- Compile Error
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int A = sc.nextInt();
int B = sc.nextInt();
System.out.println(A * B):
}

Choices:
- Time Limit Exceeded
- Runtime Error
- Compile Error
- Internal error


Question:
public static void main(){
  private int A;
  private int B;

  if(A >= 0 && A <= 100 && B >= 0 && B <= 100){
    int C = A * B;
    System.out.println(C);
  }
}

Choices:
- Time Limit Exceeded
- No abnormally found
- Runtime Error
- Compile Error


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class A {
	public static void main(String[] args) {

		String bar[] = new String[5];
		String temp;

		for(int i=0;i<5;i++) {

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String str = null;
		try {
			str = br.readLine();
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
			bar[i] = str;
		}

		temp = bar[0];
		bar[0] = bar[2];
		bar[2] = temp;

		temp = bar[4];
		bar[4] = bar[0];
		bar[0] = bar[4];

	}
}

Choices:
- Runtime Error
- Memory Limit Exceeded
- Compile Error
- Internal error


Question:
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            int N = nint(sc);
            int M = nint(sc);
            int Q = nint(sc);
            List<Integer[]> LineList = new ArrayList<>();
            for (int i = 0; i < M; i++) {
                int l = nint(sc);
                int r = nint(sc);
                Integer[] lr = {l, r};
                LineList.add(lr);
            }

            List<Integer[]> QuestionList = new ArrayList<>();
            for (int i = 0; i < Q; i++) {
                int p = nint(sc);
                int q = nint(sc);
                Integer[] pq = {p, q};
                QuestionList.add(pq);
            }

            LineList = LineList.stream()
                    .sorted(Comparator.comparing(x -> x[1]))
                    .collect(Collectors.toList());

            for (int i = 0; i < Q; i++) {
                Integer[] Question = QuestionList.get(i);
                int p = Question[0];
                int q = Question[1];
                int count = 0;
                for (int j = 0; j < LineList.size(); j++) {
                    Integer[] Line = LineList.get(j);
                    int l = Line[0];
                    int r = Line[1];
                    if (r > q) {
                        break;
                    }
                    if (l >= p) {
                        count++;
                    }
                }
                out.println(count);
            }
        }
    }

    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }
}

Choices:
- Compile Error
- Time Limit Exceeded
- Runtime Error
- No abnormally found


Question:
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }
    static class Task{
        public void solve(Scanner sc, PrintWriter out){
            int N = nint(sc);
            int M = nint(sc);
            List<Integer[]> warList = new ArrayList<>();
            for (int i=0; i<M; i++){
                int a = nint(sc);
                int b = nint(sc);
                Integer[] ab = {a, b};
                warList.add(ab);
            }
            warList =  warList.stream()
                    .sorted(Comparator.comparing(x -> x[1]))
                    .collect(Collectors.toList());

            int removeBridge = 0;
            int result = 0;
            for (int i =0; i<warList.size(); i++){
                int a = warList.get(i)[0];
                int b = warList.get(i)[1];
                if (i==0){
                    removeBridge = b - 1;
                    result ++;
                }else if(a > removeBridge){
                    removeBridge = b-1;
                    result ++;
                }
            }
            out.println(result);
        }
    }

    static int nint(Scanner sc){
        return Integer.parseInt(sc.next());
    }
    static long nlong(Scanner sc){
        return Long.parseLong(sc.next());
    }
    static double ndouble(Scanner sc){
        return Double.parseDouble(sc.next());
    }
    static float nfloat(Scanner sc){
        return Float.parseFloat(sc.next());
    }
    static String nstr(Scanner sc){
        return  String.valueOf(sc.next());
    }
    static long[] longLine(Scanner sc, int size){
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }
    static int[] intLine(Scanner sc, int size){
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }
    static String[] strLine(Scanner sc, int size){
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }
}

Choices:
- Compile Error
- No abnormally found
- Runtime Error
- Internal error


Question:
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }
    static class Task{
        public void solve(Scanner sc, PrintWriter out){
            int N = nint(sc);
            int[] AList = intLine(sc, N);
            long lcm = 0;
            for (int i=0; i<AList.length; i++){
                if (i>=1){
                    lcm = lcm(AList[i], lcm);
                }else {
                    lcm = AList[0];
                }
            }
            long checknum = lcm -1;
            long result = 0;
            for (int i=0; i<AList.length; i++){
               result += checknum % AList[i];
            }
            out.println(result);

        }
    }
    private static long lcm(long a, long b){
        return a * b /gcd( b, a % b);
    }

    private static long gcd(long a, long b){
        if (a < b) return gcd(b ,a );
        return b == 0 ? a : gcd( b, a % b);
    }

    static int nint(Scanner sc){
        return Integer.parseInt(sc.next());
    }
    static long nlong(Scanner sc){
        return Long.parseLong(sc.next());
    }
    static double ndouble(Scanner sc){
        return Double.parseDouble(sc.next());
    }
    static float nfloat(Scanner sc){
        return Float.parseFloat(sc.next());
    }
    static String nstr(Scanner sc){
        return  String.valueOf(sc.next());
    }
    static long[] longLine(Scanner sc, int size){
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }
    static int[] intLine(Scanner sc, int size){
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }
    static String[] strLine(Scanner sc, int size){
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }
}

Choices:
- No abnormally found
- Runtime Error
- Compile Error
- Memory Limit Exceeded