Question:
import java.util.*;

class Main{
	public static void main(String args[]){
      Scanner scan = new Scanner(System.in);
      int N = scan.nextInt();

      String previous = scan.next();
      String next;
      Set<String> used_words = new HashSet<String>();
      used_words.add(previous);

      while(N>1){
        next = scan.next();
        if(!((previous.charAt(previous.length()-1)==next.charAt(0))&&used_words.add(next))){
          System.out.println("No");
          scan.close();
          return;
        }
        previous = next;
        N--;
      }//while
      scan.close();
      System.out.println("Yes");

    }
}

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


Question:
import java.util.*;

public class Main{
    public static void main(String[] args){
	    Scanner sc=new Scanner(System.in);
            int N =sc.nextInt();
  		    long[] A = new long[N];
  		    long ans=1;
		    for(int i=0; i<N; i++){
    		    A[i]=sc.nextLong();
          	    if(A[i]==0){
            	    ans=0;
                }
    	    }
  	    	if(ans!=0){
		    	for(int i=0; i<N; i++){
            	if(A[i] <= (long)Math.pow(10,18)/ans){
                	ans *= A[i];
            	}else{
          	    	ans=-1;
                	break;
            	}
    		}
  	    }
    	System.out.println(ans);
    }
}

Choices:
- Internal error
- No abnormally found
- 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);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int count = 1;
		while (N >= K) {
			N = N / K;
			count++;
		}
		System.out.println(count);
		return ;
	}
}

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


Question:
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] b = new int[n-1];
        for (int i = 0; i < n-1; i++) {
            b[i] = sc.nextInt();
        }

        int count = b[0] + b[n-2];
        for (int i = 0; i < n - 2; i++) {
            count += Math.min(b[i], b[i+1]);
        }
        System.out.println(count);

    }
}

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


Question:
import java.util.*;

public class Main {
    public static void main(String args[]) {
       //値の取得
       Scanner sc = new Scanner(System.in);
       int[] time = new int[5];
       for(int i = 0; i < 5; ++i){
           time[i] = sc.nextInt();
       }

       int dish[] = new int[5];

       for(int i = 0; i < 5; ++i){
           if(time[i]%10==0){
               dish[i] = (time[i]/10)*10;
           }else{
               dish[i] = (time[i]/10)*10 +10;
           }
       }

       int max = 0;
       int total = 0;
       for(int i = 0; i < 5; ++i) {
           if(Math.abs(dish[i] - time[i]) > max) {
               max = Math.abs(dish[i] - time[i]);
           }

           total += dish[i];
       }
       System.out.println(total - max);
    }
}

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


Question:
import java.util.*;

public class Main {
    public static void main(String args[]) {
       //値の取得
       Scanner sc = new Scanner(System.in);
       int[] time = new int[5];
       for(int i = 0; i < 5; ++i){
           time[i] = sc.nextInt();
       }

       int dish[] = new int[5];

       for(int i = 0; i < 5; ++i){
           if(time[i]%10==0){
               dish[i] = (time[i]/10)*10;
           }else{
               dish[i] = (time[i]/10)*10 +10;
           }
       }

       int max = 0;
       int total = 0;
       for(int i = 0; i < 5; ++i) {
           if(Math.abs(dish[i] - time[i]) > max) {
               max = Math.abs(dish[i] - time[i]);
           }

           total += dish[i];
       }
       System.out.println(total - max);
    }
}

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


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

class Main{
    static long dp[][];
    static long price[];
    static HashSet<Integer> keys[];
    static int n, m;
    static long MAX=1000000000;
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        n=fsc.nextInt();
        m=fsc.nextInt();
        price=new long[m];
        keys=new HashSet[m];
        for(int i=0;i<m;i++){
            price[i]=fsc.nextLong();
            int b=fsc.nextInt();
            keys[i]=new HashSet<>(b);
            for(int j=0;j<b;j++) keys[i].add(fsc.nextInt()-1);
        }
        fsc.close();
        dp=new long[m][1<<n];
        long ans=dp(0, (1<<n)-1);
        ans=ans<MAX?ans:-1;
        System.out.println(ans);
    }
    static long dp(int k, int close){
        if(k==m) return close==0?0:MAX;
        if(close==0) return dp[k][close]=0;
        if(dp[k][close]>0) return dp[k][close];
        long ret=dp(k+1, close);
        int nextClose=close;
        for(int key:keys[k]){
            if((close&(1<<key))!=0) nextClose-=(1<<key);
        }
        return dp[k][close]=Math.min(ret, dp(k+1, nextClose)+price[k]);
    }
    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:
- Compile Error
- Runtime Error
- No abnormally found
- Time Limit Exceeded


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

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        long k = fsc.nextLong();
        int x = fsc.nextInt();
        int y = fsc.nextInt();
        int rx = x >= 0 ? 1 : -1;
        int ry = y >= 0 ? 1 : -1;
        x *= rx;
        y *= ry;
        if (k % 2 == 0 && (x + y) % 2 != 0) {
            System.out.println(-1);
            return;
        }
        StringBuilder sb = new StringBuilder();
        long a = 0;
        long bx = 0;
        long by = 0;
        while (x + y > 2 * k) {
            if (x >= k) {
                bx += k;
                x -= k;
                sb.append(bx * rx).append(' ').append(by * ry).append('\n');
                a++;
            } else {
                by += k;
                y -= k;
                sb.append(bx * rx).append(' ').append(by * ry).append('\n');
                a++;
            }
        }
        if (x + y == k) {
            a++;
            sb.append((bx + x) * rx).append(' ').append((by + y) * ry).append('\n');
        } else if (x + y > 0) {
            if (k % 2 == 1 && (x + y) % 2 == 1) {
                if (x + y < k) {
                    sb.append(bx * rx).append(' ').append((by - k) * ry).append('\n');
                    by -= k;
                    y += k;
                } else {
                    long dx = Math.min(x, k);
                    sb.append((bx + dx) * rx).append(' ').append((by + k - dx) * ry).append('\n');
                    bx += dx;
                    by += k - dx;
                    y -= k - dx;
                    x -= dx;
                }
                a++;
            }
            for (int i = 0; i < 1 << 4; i++) {
                int s = (i & (1 << 0)) == 0 ? -1 : 1;
                int t = (i & (1 << 1)) == 0 ? -1 : 1;
                int u = (i & (1 << 2)) == 0 ? -1 : 1;
                int v = (i & (1 << 3)) == 0 ? -1 : 1;
                int inv = s * v - t * u;
                if (inv == 0) {
                    continue;
                }
                long x1 = -t * u * x - t * v * y + v * k + t * k;
                long y1 = +s * u * x + s * v * y - u * k - s * k;
                long x2 = +s * v * x + t * v * y - v * k - t * k;
                long y2 = -s * u * x - t * u * y + u * k + s * k;
                if (((x1 & 1) | (y1 & 1) | (x2 & 1) | (y2 & 1)) == 0) {
                    x1 /= inv;
                    y1 /= inv;
                    x2 /= inv;
                    y2 /= inv;
                    if (x1 * s >= 0 && y1 * t >= 0 && x2 * u >= 0 && y2 * v >= 0) {
                        sb.append((bx + x1) * rx).append(' ').append((by + y1) * ry).append('\n');
                        sb.append((bx + x1 + x2) * rx).append(' ').append((by + y1 + y2) * ry).append('\n');
                        a += 2;
                        break;
                    }
                }
            }
        }
        System.out.println(a);
        System.out.print(sb);
    }
}

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
- No abnormally found
- Compile Error
- Internal error


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 || j==m) dp[i][j]=1;
                else if(i==n-1){
                    if(s[i]==t[j]) dp[i][j]=dp[i][j+1]+1;
                    else dp[i][j]=dp[i][j+1];
                }
                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];
                    }
                    else dp[i][j]=dp[i][j+1]+dp[i+1][j]-dp[i+1][j+1];
                }
                if(dp[i][j]<0) dp[i][j]+=MOD;
                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]);
    }
    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
- No abnormally found
- Internal error
- Runtime Error


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; sharp[i][1]=-1;
            int index=2;
            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; sharpT[j][1]=-1;
            int index=2;
            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]-sharpT[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
- Runtime Error
- Internal 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 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; sharp[i][1]=-1;
            int index=2;
            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; sharpT[j][1]=-1;
            int index=2;
            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]-sharpT[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:
- Internal error
- Time Limit Exceeded
- No abnormally found
- 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;
        int m=0;
        TreeSet<MyLong> fir=new TreeSet<>();
        fir.add(MAX.mlm(-1));
        TreeSet<MyLong> sec=new TreeSet<>();
        sec.add(MAX);
        StringBuilder sb=new StringBuilder();
        for(int i=0;i<q;++i){
            int query=fsc.nextInt();
            if(query==1){
                ++m;
                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(m%2==1) sec.add(fir.last());
                        else fir.pollLast();
                        fir.add(am);
                    }
                    else{
                        if(m%2==1) fir.add(sec.first());
                        else sec.pollFirst();
                        sec.add(am);
                    }
                }
                else{
                    fir.add(am);
                    sec.add(am);
                }
                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 String.valueOf(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:
- Memory Limit Exceeded
- Runtime Error
- Compile 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=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:
- No abnormally found
- Compile Error
- Runtime Error
- Memory Limit Exceeded


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

import static java.util.Arrays.sort;

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int n = fsc.nextInt();
        int[] parent = new int[n];
        HashSet<Integer>[] children = new HashSet[n];
        for (int i = 0; i < n; i++) {
            children[i] = new HashSet<>();
        }
        for (int i = 1; i < n; i++) {
            int p = fsc.nextInt() - 1;
            parent[i] = p;
            children[p].add(i);
        }
        System.out.println(rounds(parent, children, 0));
    }

    public static int rounds(int[] parent, HashSet<Integer>[] children, int p) {
        int size = children[p].size();
        if (size == 0) {
            return 0;
        }
        int[] c = new int[size];
        int indx = 0;
        for (int ch : children[p]) {
            c[indx++] = rounds(parent, children, ch);
        }
        sort(c);
        int round = 0;
        for (int i = 0; i < c.length; i++) {
            if (c[i] >= round) {
                round = c[i] + 1;
            } else {
                round++;
            }
        }
        return round;
    }
}

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
- Runtime Error
- No abnormally found
- Compile Error


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

import static java.util.Arrays.sort;

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int n = fsc.nextInt();
        int[] parent = new int[n];
        HashSet<Integer>[] children = new HashSet[n];
        for (int i = 0; i < n; i++) {
            children[i] = new HashSet<>();
        }
        for (int i = 1; i < n; i++) {
            int p = fsc.nextInt() - 1;
            parent[i] = p;
            children[p].add(i);
        }
        System.out.println(rounds(parent, children, 0));
    }

    public static int rounds(int[] parent, HashSet<Integer>[] children, int p) {
        int size = children[p].size();
        if (size == 0) {
            return 0;
        }
        int[] c = new int[size];
        int indx = 0;
        for (int ch : children[p]) {
            c[indx++] = rounds(parent, children, ch);
        }
        sort(c);
        int round = 0;
        for (int i = 0; i < c.length; i++) {
            if (c[i] >= round) {
                round = c[i] + 1;
            } else {
                round++;
            }
        }
        return round;
    }
}

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
- No abnormally found
- Memory Limit Exceeded
- Runtime Error


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) {
        a = Math.max(a, 0);
        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
- 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);
        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(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
                out.println("Yes");

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

        }

    }
}

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


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());
                p[i]++;
            }

            long s[] = new long[n + 1];
            for (int i = 0; i < n; i++) {
                s[i + 1] = s[i] + p[i];
            }

            long ans = 0;
            for (int i = 0; i + k <= n; i++) {
                ans = Math.max(s[i + k] - s[i], ans);
            }

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

        }

    }
}

Choices:
- Internal error
- No abnormally found
- Compile 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int N = Integer.parseInt(in.next());
            int[] d = new int[N];
            for (int i = 0; i < N; i++) {
                d[i] = Integer.parseInt(in.next());
            }
            int ans = 0;
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    ans += d[i] * d[j];
                }
            }

            // 出力
            out.println(ans);

        }

    }
}

Choices:
- Internal error
- Compile Error
- No abnormally found
- 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());

            if (k % 2 == 0) out.println(a - b);
            else out.println(b - a);
        }

    }
}

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


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:
- Internal error
- No abnormally found
- Memory Limit Exceeded
- Compile Error


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

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 sum  = 0;
            int[] nint = intLine(sc, 3);
            Arrays.sort(nint);

            int a1 = nint[0];
            int a2 = nint[1];
            int a3 = nint[2];

            int a1a2 = Math.abs(a2-a1);
            int a1a3 = Math.abs(a3-a1);

            if (a1a2 <= a1a3){
                sum += a1a2 + Math.abs(a2-a3);
             }else {
                sum += a1a3 + Math.abs(a2-a3);
            }

            out.println(sum);

        }
    }

    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
- Internal error
- No abnormally found
- Time Limit Exceeded


Question:
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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){
            String S = nstr(sc);
            String T = nstr(sc);
            List<String> SList = new ArrayList<>();

            for(int i = 0; i < S.length(); i++){
                String x = String.valueOf(S.charAt(i));
                SList.add(x);
            }
            List<String> TList = new ArrayList<>();
            for(int i = 0; i < T.length(); i++){
                String x = String.valueOf(T.charAt(i));
                TList.add(x);
            }

            for (int i=0; i<SList.size(); i++){
                String tmp = SList.get(SList.size()-1);
                SList.remove(SList.size()-1);
                SList.add(0, tmp);
                if (SList.equals(TList)){
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");

        }
    }

    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:
- Memory Limit Exceeded
- Compile Error
- Internal error
- No abnormally found


Question:
import java.util.Scanner;

public class  Main{
    public static void main(String[] args){
        Scanner sr = new Scanner(System.in);
        String inputLine = sr.nextLine();
        int result = 0;
        if(inputLine.length() == 4){
            for (int i = 0; i < inputLine.length(); i++){
                String plusOrMinus =inputLine .substring(i,i+1);
                if(plusOrMinus.equals("+")){
                    result ++;
                }else{
                    result--;
                }
            }
        }
        System.out.println(result);
    }

}

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


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

    public class Main {
        public static void main(String[] args) throws FileNotFoundException {
            new Main().run();
        }

        void run() {
            Scanner sc = new Scanner(System.in);
            long K = sc.nextLong();
            long ans = 0;
            long add = 1;
            PrintWriter pw = new PrintWriter(System.out);

            int cnt = 0;
            while (cnt++ < K) {
                if ((ans + add) * S(ans + add * 10) > (ans + add * 10) * S(ans + add))
                    add = add * 10;
                ans += add;
                pw.println(ans);
            }
            pw.close();
        }

        long S(long a) {
            long ret = 0;
            while (a > 0) {
                ret += a % 10;
                a /= 10;
            }
            return ret;
        }

        static void tr(Object... objects) {
            System.out.println(Arrays.deepToString(objects));
        }

}

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


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

    public class Main {
        public static void main(String[] args) throws FileNotFoundException {
            new Main().run();
        }

        void run() {
            Scanner sc = new Scanner(System.in);
            long K = sc.nextLong();
            long ans = 0;
            long add = 1;
            PrintWriter pw = new PrintWriter(System.out);

            int cnt = 0;
            while (cnt++ < K) {
                if ((ans + add) * S(ans + add * 10) > (ans + add * 10) * S(ans + add))
                    add = add * 10;
                ans += add;
                pw.println(ans);
            }
            pw.close();
        }

        long S(long a) {
            long ret = 0;
            while (a > 0) {
                ret += a % 10;
                a /= 10;
            }
            return ret;
        }

        static void tr(Object... objects) {
            System.out.println(Arrays.deepToString(objects));
        }

}

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


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

    public class Main {
        public static void main(String[] args) throws FileNotFoundException {
            new Main().run();
        }

        void run() {
            Scanner sc = new Scanner(System.in);
            long K = sc.nextLong();
            long ans = 0;
            long add = 1;
            PrintWriter pw = new PrintWriter(System.out);

            int cnt = 0;
            while (cnt++ < K) {
                if ((ans + add) * S(ans + add * 10) > (ans + add * 10) * S(ans + add))
                    add = add * 10;
                ans += add;
                pw.println(ans);
            }
            pw.close();
        }

        long S(long a) {
            long ret = 0;
            while (a > 0) {
                ret += a % 10;
                a /= 10;
            }
            return ret;
        }

        static void tr(Object... objects) {
            System.out.println(Arrays.deepToString(objects));
        }

}

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


Question:
import java.io.*;
import java.util.*;
public class Main{

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] cmd=br.readLine().split(" ");
		long x=Long.valueOf(cmd[0]);
		long k=Long.valueOf(cmd[1]);
		long[] sum1=new long[(int)x+2];
		for(long i=1;i<=x+1;i++)
		{
			sum1[(int)i]=sum1[(int)i-1]+i;
		}
		long[] sum2=new long[(int)x+2];
		for(long i=x+1;i>=1;i--)
		{
			sum2[(int)(x+2-i)]=sum2[(int)(x+1-i)]+i;
		}
		long ans=0;
		for(long i=k;i<=x+1;i++)
		{
			long diff=sum2[(int)i]-sum1[(int)i]+1;
			ans=(ans+diff)%1000000007;
		}
		System.out.println(ans);
	}

}

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


Question:
import java.io.*;
import java.util.*;
public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	static long mod=1000000007;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		long n=Long.valueOf(br.readLine());
		if(n%2!=0)
			System.out.println(0);
		else
		{
			long x=n/2;
			long twos=x;
			long fives=0;
			long st=2;
			while(true)
			{
				long h=x/st;
				if(h==0)
					break;
				twos+=h;
				st=st*2;
			}
			st=5;
			while(true)
			{
				long h=x/st;
				if(h==0)
					break;
				fives+=h;
				st=st*5;
			}
			System.out.println(Math.min(twos, fives));
		}
	}
}

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


Question:
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String steps = br.readLine();
		boolean often_pattern = true;

		for(int i = 1; i <= steps.length(); i++){
			char step = steps.charAt(i-1);
			if(i % 2 == 0){
				if(step == 'R'){
					often_pattern = false;
					break;
				}
			} else {
				if(step == 'L'){
					often_pattern = false;
					break;
				}
			}
		}

		String answer;
		if(often_pattern){
			answer = "Yes";
		} else {
			answer = "No";
		}
		System.out.println(answer);
	}
}

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


Question:
import java.io.*;

/**
 * Copyright © 2018 Chris. All rights reserved.
 *
 * @author Chris
 * 2018/6/23 11:55
 * @see meituan.n2018.Bturn
 */
public class Main {

    private static BufferedReader br;
    private static StreamTokenizer st;
    private static PrintWriter pw;

    private static void solve() throws IOException {
        int h = nextInt();
        int w = nextInt();

        char a[][] = new char[h][w];
        for (int i = 0; i < h; i++) {
            a[i] = nextLine().toCharArray();
        }

        boolean vstH[] = new boolean[h];
        boolean vstW[] = new boolean[w];

        for (int i = 0; i < h; i++) {
            boolean flag = true;
            for (int j = 0; j < w; j++) {
                if (a[i][j] == '#') {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                vstH[i] = true;
            }
        }
        for (int i = 0; i < w; i++) {
            boolean flag = true;
            for (int j = 0; j < h; j++) {
                if (a[j][i] == '#') {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                vstW[i] = true;
            }
        }

        for (int i = 0; i < h; i++) {
            if (vstH[i]) {
                continue;
            }
            for (int j = 0; j < w; j++) {
                if (!vstW[j]) {
                    pw.print(a[i][j]);
                }
            }
            if (i < h - 1) {
                pw.println();
            }
        }
    }

    public static void main(String args[]) throws IOException {
//        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
//        if (!oj) {
//            System.setIn(new FileInputStream("src/in.txt"));
//        }
        br = new BufferedReader(new InputStreamReader(System.in));
        st = new StreamTokenizer(br);
        pw = new PrintWriter(new OutputStreamWriter(System.out));
        st.ordinaryChar('\''); //指定单引号、双引号和注释符号是普通字符
        st.ordinaryChar('\"');
        st.ordinaryChar('/');

        long t = System.currentTimeMillis();
        solve();
//        if (!oj) {
//            pw.println("[" + (System.currentTimeMillis() - t) + "ms]");
//        }
        pw.flush();
    }

    private static int nextInt() throws IOException {
        st.nextToken();
        return (int) st.nval;
    }

    private static long nextLong() throws IOException {
        st.nextToken();
        return (long) st.nval;
    }

    private static double nextDouble() throws IOException {
        st.nextToken();
        return st.nval;
    }

    private static String[] nextSS(String reg) throws IOException {
        return br.readLine().split(reg);
    }

    private static String nextLine() throws IOException {
        return br.readLine();
    }
}

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


Question:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int a[] = new int [N-1];

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

        int count = a[0] + a[N-2];

        for(int i=0;i<N-2;i++){

            count += Math.min(a[i],a[i+1]);

        }

        System.out.println(count);

    }
}

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


Question:
import java.util.*;
class Main{
  public static void main(String[] args){
Scanner sc=new Scanner(System.in);
     long n=sc.nextLong();
    long a[]=new long[(int)n+1];
    Arrays.fill(a,1);
    for(int i=2;i<=n;i++){
for(int j=i;j<=n;j+=i){    //O(logN)
a[j]++;
}
    }
    long sum=0;
    for(int i=1;i<=n;i++){
sum+=(i*a[i]);
    }
    System.out.println(sum);
  }
}

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


Question:
import java.util.*;
class Main{
  public static void main(String[] args){
Scanner sc=new Scanner(System.in);
     long n=sc.nextLong();
    long a[]=new long[(int)n+1];
    Arrays.fill(a,1);
    for(int i=2;i<=n;i++){
for(int j=i;j<=n;j+=i){    //O(logN)
a[j]++;
}
    }
    long sum=0;
    for(int i=1;i<=n;i++){
sum+=(i*a[i]);
    }
    System.out.println(sum);
  }
}

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


Question:
import java.io.FileNotFoundException;
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	double A = sc.nextDouble();
    	BigDecimal B = BigDecimal.valueOf(sc.nextDouble());
    	//double B = sc.nextDouble();

    	BigDecimal times = B.multiply(BigDecimal.valueOf(A));

    	System.out.println(times.longValue());
    }
}

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


Question:
import java.io.FileNotFoundException;
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	double A = sc.nextDouble();
    	BigDecimal B = BigDecimal.valueOf(sc.nextDouble());
    	//double B = sc.nextDouble();

    	BigDecimal times = B.multiply(BigDecimal.valueOf(A));

    	System.out.println(times.longValue());
    }
}

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


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

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int N = sc.nextInt();
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += sc.nextInt();
		}
		if (sum >= H) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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


Question:
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int[] d = new int[N];
		for(int i=0;i<N;i++) {
			d[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(d);
		if(d[N/2-1]==d[N/2]) {
			System.out.println("0");
		} else {
			System.out.println(d[N/2]-d[N/2-1]);
		}
	}
}

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


Question:
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner scan = new Scanner(System.in);

        int k = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();

        int largest = (b / k) * k;

        if (largest >= a) {
            System.out.println("OK");
        } else {
            System.out.println("NG");
        }

    }
}

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


Question:
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    String t=sc.next();
    char[] ss=new char[s.length()];
    char[] tt=new char[t.length()];
    for(int i=0;i<ss.length;i++){
      ss[i]=s.charAt(i);
    }
    for(int i=0;i<tt.length;i++){
      tt[i]=t.charAt(i);
    }
    int count;
    int min=tt.length;
    for(int i=0;i<1+ss.length-tt.length;i++){
      count=0;
      int j=i,k=0;
      while(k<tt.length){
        if(ss[j]!=tt[k]) count++;
        j++;k++;
      }
      if(min>count)min=count;
    }
    System.out.println(min);
  }
}

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


Question:
import java.util.*;
public class Main {
	public static void main(String[] args){
		  Scanner sc=new Scanner(System.in);
	      int n=sc.nextInt();
	      int sum=0;
	      int[] L=new int[n*2];
	      for(int i=0;i<L.length;i++){
	        L[i]=sc.nextInt();
	      }
	      Arrays.sort(L);
	      for(int i=0;i<L.length;i+=2){
	        sum+=L[i];
			}
	      sc.close();
	      System.out.println(sum);
	    }
}

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


Question:
import java.util.*;
public class Main {
	public static void main(String[] args){
		  Scanner sc=new Scanner(System.in);
	      int n=sc.nextInt();
	      int sum=0;
	      int[] L=new int[n*2];
	      for(int i=0;i<L.length;i++){
	        L[i]=sc.nextInt();
	      }
	      Arrays.sort(L);
	      for(int i=0;i<L.length;i+=2){
	        sum+=L[i];
			}
	      sc.close();
	      System.out.println(sum);
	    }
}

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


Question:
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int K;
		int[] P = new int [100100];
		for(int i=0; i<N; i++){
			P[i] = sc.nextInt();
		}
		Arrays.sort(P,0,N);

		K = P[N/2] - P[N/2-1];

		System.out.println(K);
	}
}

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


Question:
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int K;
		int[] P = new int [100100];
		for(int i=0; i<N; i++){
			P[i] = sc.nextInt();
		}
		Arrays.sort(P,0,N);

		K = P[N/2] - P[N/2-1];

		System.out.println(K);
	}
}

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


Question:
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str1 = scan.nextLine();
    String str2 = scan.next();
    String str3 = scan.next();

    int num1 = Integer.parseInt(str1);
    int num2 = Integer.parseInt(str2);
    int num3 = Integer.parseInt(str3);

    int sum = 0;
    String str4 = "";

    for(int i=1;i<=1000;i++) {
      sum = num1 * i;
      if(num2 <= sum && num3 >= sum) {
          str4 = "OK";
          break;
      }
      str4 = "NG";
    }
    String str = String.valueOf(num1);
    str = str4;
    System.out.println(str);
    scan.close();
  }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedOutputStream;
import java.io.UncheckedIOException;
import java.nio.charset.Charset;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class AIntegerProduct {
        public void solve(int testNumber, LightScanner in, LightWriter out) {
            int n = in.ints();
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                String[] s = in.string().split("\\.");
                if (s.length == 2) {
                    a[i] = Long.parseLong(s[1]);
                    int len = s[1].length();
                    for (int j = len; j < 9; j++) {
                        a[i] *= 10;
                    }
                }
                a[i] += Long.parseLong(s[0]) * 1_000_000_000L;

            }
            int[][] tbl = new int[19][19];
            long ans = 0;
            for (int i = 0; i < n; i++) {
                int c2 = 0, c5 = 0;
                while (a[i] % 2 == 0) {
                    a[i] /= 2;
                    c2++;
                }
                while (a[i] % 5 == 0) {
                    a[i] /= 5;
                    c5++;
                }
                c2 = Math.min(c2, 18);
                c5 = Math.min(c5, 18);
                for (int j = 18 - c2; j <= 18; j++) {
                    for (int k = 18 - c5; k <= 18; k++) {
                        ans += tbl[j][k];
                    }
                }
                tbl[c2][c5]++;
            }
            out.ans(ans).ln();
        }

    }

    static class LightScanner implements AutoCloseable {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

        public void close() {
            try {
                this.reader.close();
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
        }

    }

    static class LightWriter implements AutoCloseable {
        private final Writer out;
        private boolean autoflush = false;
        private boolean breaked = true;

        public LightWriter(Writer out) {
            this.out = out;
        }

        public LightWriter(OutputStream out) {
            this(new OutputStreamWriter(new BufferedOutputStream(out), Charset.defaultCharset()));
        }

        public LightWriter print(char c) {
            try {
                out.write(c);
                breaked = false;
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
            return this;
        }

        public LightWriter print(String s) {
            try {
                out.write(s, 0, s.length());
                breaked = false;
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
            return this;
        }

        public LightWriter ans(String s) {
            if (!breaked) {
                print(' ');
            }
            return print(s);
        }

        public LightWriter ans(long l) {
            return ans(Long.toString(l));
        }

        public LightWriter ln() {
            print(System.lineSeparator());
            breaked = true;
            if (autoflush) {
                try {
                    out.flush();
                } catch (IOException ex) {
                    throw new UncheckedIOException(ex);
                }
            }
            return this;
        }

        public void close() {
            try {
                out.close();
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
        }

    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.IntStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedOutputStream;
import java.io.UncheckedIOException;
import java.nio.charset.Charset;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class B123Triangle {
        public void solve(int testNumber, LightScanner in, LightWriter out) {
            // out.setBoolLabel(LightWriter.BoolLabel.YES_NO_FIRST_UP);
            int n = in.ints();
            int[] s = in.string().chars().map(c -> c - '0').toArray();
            for (int i = 0; i < 10 && n > 1; i++) {
                n--;
                for (int j = 0; j < n; j++) {
                    s[j] = Math.abs(s[j] - s[j + 1]);
                }
            }
            if (n == 1) {
                out.ans(s[0]).ln();
                return;
            }

            int coeff = 2;
            for (int i = 0; i < n; i++) {
                if ((s[i] & 1) == 1) coeff = 1;
            }
            if (coeff == 2) {
                for (int i = 0; i < n; i++) {
                    s[i] >>= 1;
                }
            }

            int p = 0;
            for (int i = 0; i < n; i++) if ((i & (n - i - 1)) == 0) p += s[i] & 1;
            p &= 1;
            out.ans(p * coeff).ln();
        }

    }

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

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

    }

    static class LightWriter implements AutoCloseable {
        private final Writer out;
        private boolean autoflush = false;
        private boolean breaked = true;

        public LightWriter(Writer out) {
            this.out = out;
        }

        public LightWriter(OutputStream out) {
            this(new OutputStreamWriter(new BufferedOutputStream(out), Charset.defaultCharset()));
        }

        public LightWriter print(char c) {
            try {
                out.write(c);
                breaked = false;
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
            return this;
        }

        public LightWriter print(String s) {
            try {
                out.write(s, 0, s.length());
                breaked = false;
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
            return this;
        }

        public LightWriter ans(String s) {
            if (!breaked) {
                print(' ');
            }
            return print(s);
        }

        public LightWriter ans(int i) {
            return ans(Integer.toString(i));
        }

        public LightWriter ln() {
            print(System.lineSeparator());
            breaked = true;
            if (autoflush) {
                try {
                    out.flush();
                } catch (IOException ex) {
                    throw new UncheckedIOException(ex);
                }
            }
            return this;
        }

        public void close() {
            try {
                out.close();
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
        }

    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.UncheckedIOException;
import java.util.List;
import java.nio.charset.Charset;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class ECoinsRespawn {
        public void solve(int testNumber, LightScanner in, LightWriter out) {
            int n = in.ints(), m = in.ints(), p = in.ints();
            BellmanFord bf = new BellmanFord(n);
            for (int i = 0; i < m; i++) {
                bf.addEdge(in.ints() - 1, in.ints() - 1, p - in.ints());
            }
            try {
                out.ans(Math.max(0L, -bf.shortestPath(0, n - 1))).ln();
            } catch (RuntimeException ex) {
                out.ans(-1).ln();
            }
        }

    }

    static class BellmanFord {
        private final int nodes;
        private final List<BellmanFord.Edge> edges = new ArrayList<>();
        private long[] distance;

        public BellmanFord(int n) {
            nodes = n;
            distance = new long[n];
        }

        public void addEdge(int from, int to, int cost) {
            edges.add(new BellmanFord.Edge(from, to, cost));
        }

        public long shortestPath(int src, int dst) {
            Arrays.fill(distance, Long.MAX_VALUE);
            distance[src] = 0;
            for (int i = 0; i < 2 * nodes; i++) {
                boolean updated = false;
                for (BellmanFord.Edge e : edges) {
                    if (distance[e.from] < Long.MAX_VALUE && distance[e.to] > distance[e.from] + e.cost) {
                        updated = true;
                        distance[e.to] = distance[e.from] + e.cost;
                        if (i >= nodes - 1 && e.to == dst) {
                            throw new RuntimeException("negative loop");
                        }
                    }
                }
                if (!updated) {
                    break;
                }
            }
            return distance[dst];
        }

        private static class Edge {
            int from;
            int to;
            long cost;

            Edge(int from, int to, long cost) {
                this.from = from;
                this.to = to;
                this.cost = cost;
            }

        }

    }

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

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

    }

    static class LightWriter implements AutoCloseable {
        private final Writer out;
        private boolean autoflush = false;
        private boolean breaked = true;

        public LightWriter(Writer out) {
            this.out = out;
        }

        public LightWriter(OutputStream out) {
            this(new BufferedWriter(new OutputStreamWriter(out, Charset.defaultCharset())));
        }

        public LightWriter print(char c) {
            try {
                out.write(c);
                breaked = false;
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
            return this;
        }

        public LightWriter print(String s) {
            try {
                out.write(s, 0, s.length());
                breaked = false;
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
            return this;
        }

        public LightWriter ans(String s) {
            if (!breaked) {
                print(' ');
            }
            return print(s);
        }

        public LightWriter ans(long l) {
            return ans(Long.toString(l));
        }

        public LightWriter ans(int i) {
            return ans(Integer.toString(i));
        }

        public LightWriter ln() {
            print(System.lineSeparator());
            breaked = true;
            if (autoflush) {
                try {
                    out.flush();
                } catch (IOException ex) {
                    throw new UncheckedIOException(ex);
                }
            }
            return this;
        }

        public void close() {
            try {
                out.close();
            } catch (IOException ex) {
                throw new UncheckedIOException(ex);
            }
        }

    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.UncheckedIOException;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

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

    static class DGridGame {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int h = in.ints(), w = in.ints(), n = in.ints();
            Map<Integer, List<Integer>> m = new HashMap<>();
            for (int i = 0; i < n; i++) {
                int x = in.ints(), y = in.ints();
                if (y <= x) {
                    if (!m.containsKey(y)) {
                        m.put(y, new ArrayList<>());
                    }
                    m.get(y).add(x);
                }
            }
            for (List<Integer> e : m.values()) {
                e.sort(Comparator.naturalOrder());
            }
            int ans = h;
            int minx = 1;
            for (int i = 1; i <= w; i++) {
                //System.out.println("FOR " + i + " minx " + minx);
                int rx = h;
                if (m.containsKey(i)) {
                    for (Integer d : m.get(i)) {
                        if (d == minx) {
                            throw new RuntimeException();
                        } else if (d > minx) {
                            rx = d - 1;
                            //System.out.println("FOUND " + d);
                            if (minx == d + 1) {
                                ans = Math.min(ans, rx - 1);
                            } else {
                                ans = Math.min(ans, rx);
                            }
                            break;
                        }
                    }
                }
                if (minx == rx) {
                    break;
                }
                minx++;
                if (m.containsKey(i + 1)) {
                    while (m.get(i + 1).contains(minx)) {
                        minx++;
                    }
                }
                if (minx > rx) {
                    break;
                }
            }
            out.println(ans);
        }

    }

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

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.UncheckedIOException;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

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

    static class DGridGame {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int h = in.ints(), w = in.ints(), n = in.ints();
            Map<Integer, List<Integer>> m = new HashMap<>();
            for (int i = 0; i < n; i++) {
                int x = in.ints(), y = in.ints();
                if (y <= x) {
                    if (!m.containsKey(y)) {
                        m.put(y, new ArrayList<>());
                    }
                    m.get(y).add(x);
                }
            }
            for (List<Integer> e : m.values()) {
                e.sort(Comparator.naturalOrder());
            }
            int ans = h;
            int minx = 1;
            for (int i = 1; i <= w; i++) {
                //System.out.println("FOR " + i + " minx " + minx);
                int rx = h;
                if (m.containsKey(i)) {
                    for (Integer d : m.get(i)) {
                        if (d == minx) {
                            throw new RuntimeException();
                        } else if (d > minx) {
                            rx = d - 1;
                            //System.out.println("FOUND " + d);
                            if (minx == d + 1) {
                                ans = Math.min(ans, rx - 1);
                            } else {
                                ans = Math.min(ans, rx);
                            }
                            break;
                        }
                    }
                }
                if (minx == rx) {
                    break;
                }
                minx++;
                if (m.containsKey(i + 1)) {
                    while (m.get(i + 1).contains(minx)) {
                        minx++;
                    }
                }
                if (minx > rx) {
                    break;
                }
            }
            out.println(ans);
        }

    }

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

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}

Choices:
- Runtime Error
- No abnormally found
- 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.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.UncheckedIOException;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

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

    static class DGridGame {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int h = in.ints(), w = in.ints(), n = in.ints();
            Map<Integer, List<Integer>> m = new HashMap<>();
            for (int i = 0; i < n; i++) {
                int x = in.ints(), y = in.ints();
                if (y <= x) {
                    if (!m.containsKey(y)) {
                        m.put(y, new ArrayList<>());
                    }
                    m.get(y).add(x);
                }
            }
            for (List<Integer> e : m.values()) {
                e.sort(Comparator.naturalOrder());
            }
            int ans = h;
            int minx = 1;
            for (int i = 1; i <= w; i++) {
                //System.out.println("FOR " + i + " minx " + minx);
                int rx = h;
                if (m.containsKey(i)) {
                    for (Integer d : m.get(i)) {
                        if (d == minx) {
                            throw new RuntimeException();
                        } else if (d > minx) {
                            rx = d - 1;
                            //System.out.println("FOUND " + d);
                            if (minx == d + 1) {
                                ans = Math.min(ans, rx - 1);
                            } else {
                                ans = Math.min(ans, rx);
                            }
                            break;
                        }
                    }
                }
                if (minx == rx) {
                    break;
                }
                minx++;
                if (m.containsKey(i + 1)) {
                    while (m.get(i + 1).contains(minx)) {
                        minx++;
                    }
                }
                if (minx > rx) {
                    break;
                }
            }
            out.println(ans);
        }

    }

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

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.stream.LongStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.OptionalLong;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class DEqualCut {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int[] a = in.ints(n);
            long p = a[0], q = a[1], r = a[2], s = Arrays.stream(a).skip(3).mapToLong(i -> i).sum();
            int ab = 1, bc = 2, cd = 3;
            long ans = Long.MAX_VALUE;
            do {
                while (bc - ab > 1 && Math.abs(p - q) >= Math.abs(p - q + 2 * a[ab])) {
                    p += a[ab];
                    q -= a[ab];
                    ab++;
                }
                while (n - cd > 1 && Math.abs(r - s) >= Math.abs(r - s + 2 * a[cd])) {
                    r += a[cd];
                    s -= a[cd];
                    cd++;
                }
                ans = Math.min(ans, IntMath.max(p, q, r, s) - IntMath.min(p, q, r, s));

                q += a[bc];
                r -= a[bc];
                bc++;
            } while (bc < n - 1);
            out.println(ans);
        }

    }

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

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }

    static final class IntMath {
        private IntMath() {
        }

        public static long min(long... v) {
            return Arrays.stream(v).min().orElseThrow(() -> new IllegalArgumentException("Empty argument"));
        }

        public static long max(long... v) {
            return Arrays.stream(v).max().orElseThrow(() -> new IllegalArgumentException("Empty argument"));
        }

    }
}

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


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
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);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int length = in.nextInt();
            if (in.nextInt() > 0) {
                System.out.println(-1);
                return;
            }
            long ans = 0;
            int prev = 0;
            for (int i = 1; i < length; i++) {
                int n = in.nextInt();
                if (n == 0) {
                } else if (n - prev > 1) {
                    System.out.println(-1);
                    return;
                } else if (n - prev == 1) {
                    ans++;
                } else if (n - prev <= 0) {
                    ans += n;
                }
                prev = n;
            }
            System.out.println(ans);
        }

    }
}

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


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
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);
        BColorfulSlimes solver = new BColorfulSlimes();
        solver.solve(1, in, out);
        out.close();
    }

    static class BColorfulSlimes {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long x = in.nextLong();
            long[][] a = new long[n][n];
            a[0] = LongStream.range(0, n).map(z -> in.nextInt()).toArray();
            long ans = LongStream.of(a[0]).sum();
            for (int k = 1; k < n; k++) {
                for (int i = 0; i < n; i++) {
                    a[k][i] = Math.min(a[k - 1][(i + n - 1) % n], a[0][i]);
                }
                ans = Math.min(ans, LongStream.of(a[k]).sum() + k * x);
            }
            out.println(ans);
        }

    }
}

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


Question:
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), t = sc.nextInt(), ans = 0;
        for(int i=1;i<t+1;i++)if(i%a==0)ans+=b;
        System.out.println(ans);
    }
}

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