Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.Random;
import java.io.InputStreamReader;
import java.util.function.LongUnaryOperator;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BGarbageCollector solver = new BGarbageCollector();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGarbageCollector {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long X = in.nextInt();
            long[] x = in.readLongArray(n);

            LongUnaryOperator cost = tripsLong -> {
                int trips = (int) tripsLong;
                int[] sizes = new int[trips];
                for (int t = 0; t < n; t++) {
                    sizes[t % trips]++;
                }

                long[] costs = new long[n];
                int index = 0;
                for (int i = 0; i < trips; i++) {
                    long prev = 0;
                    for (int j = 1; j <= sizes[i]; j++) {
                        long cur = (1 + (j + 1) * (j + 1));
                        costs[index++] = cur - prev;
                        prev = cur;
                    }
                }

                long r = 0;
                Util.safeSort(costs);
                Util.reverse(costs);
                for (int i = 0; i < n; i++) {
                    r += costs[i] * x[i];
                }
                r += n * X;
                r += trips * X;

                return r;
            };
            long answer = Long.MAX_VALUE;

            for (int t = 1; t <= n; t++) {
                long c = cost.applyAsLong(t);
                answer = Math.min(answer, c);
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

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

    }

    static class Util {
        public static void safeSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(long[] x) {
            Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(long[] x, int i, int j) {
            long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void reverse(long[] x) {
            for (int i = 0, j = x.length - 1; i < j; i++, j--) {
                swap(x, i, j);
            }
        }

        private Util() {
        }

    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.function.BiFunction;
import java.io.IOException;
import java.util.function.Function;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class BMinimumSum {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }

            SegmentTree<Integer> min = new SegmentTree<>(n, Math::min, Integer.MAX_VALUE);
            for (int i = 0; i < n; i++) {
                min.update(i, a[i]);
            }

            long answer = 0;
            for (int i = 0; i < n; i++) {
                final int currentIndex = i;
                final int currentValue = a[i];
                Function<Integer, Boolean> tooManyElementsToTheLeft = (elementCount) -> {
                    if (elementCount <= 0) {
                        return false;
                    }

                    if (currentIndex - elementCount < 0) {
                        return true;
                    }

                    return min.query(currentIndex - elementCount, currentIndex - 1) < currentValue;
                };

                int l = currentIndex - (BinarySearch.binarySearch(tooManyElementsToTheLeft) - 1);

                Function<Integer, Boolean> tooManyElementsToTheRight = (elementCount) -> {
                    if (elementCount <= 0) {
                        return false;
                    }

                    if (currentIndex + elementCount >= n) {
                        return true;
                    }

                    return min.query(currentIndex + 1, currentIndex + elementCount) < currentValue;
                };

                int r = currentIndex + (BinarySearch.binarySearch(tooManyElementsToTheRight) - 1);

                answer += a[i] * (nc2(r - l + 2) - nc2(currentIndex - 1 - l + 2) - nc2(r - (currentIndex + 1) + 2));
            }

            out.println(answer);
        }

        static long nc2(long n) {
            if (n < 2) return 0;
            return n * (n - 1) / 2;
        }

    }

    static class SegmentTree<T> {
        public int size;
        public T[] value;
        private final BiFunction<T, T, T> combiner;
        private final T identityElement;

        public SegmentTree(int size, BiFunction<T, T, T> combiner, T identityElement) {
            this.size = size;
            value = (T[]) new Object[2 * size];
            Arrays.fill(value, identityElement);
            this.combiner = combiner;
            this.identityElement = identityElement;
        }

        private T combine(T a, T b) {
            return combiner.apply(a, b);
        }

        public void update(int i, T v) {
            i += size;
            value[i] = v;
            while (i > 1) {
                i /= 2;
                value[i] = combine(value[2 * i], value[2 * i + 1]);
            }
        }

        public T query(int i, int j) {
            T res_left = identityElement, res_right = identityElement;
            for (i += size, j += size; i <= j; i /= 2, j /= 2) {
                if ((i & 1) == 1) res_left = combine(res_left, value[i++]);
                if ((j & 1) == 0) res_right = combine(value[j--], res_right);
            }
            return combine(res_left, res_right);
        }

    }

    static class BinarySearch {
        public static int binarySearch(Function<Integer, Boolean> bigEnough) {
            int tooSmall = 0, tooBig;
            if (bigEnough.apply(tooSmall)) {
                return tooSmall;
            }

            for (tooBig = 1; !bigEnough.apply(tooBig); tooBig *= 2) ;

            if (!bigEnough.apply(tooBig - 1)) {
                return tooBig;
            }

            while (tooBig - tooSmall > 1) {
                int center = (tooBig + tooSmall) / 2;
                if (!bigEnough.apply(center)) {
                    tooSmall = center;
                } else {
                    tooBig = center;
                }
            }

            return tooBig;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.function.BiFunction;
import java.io.IOException;
import java.util.function.Function;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class BMinimumSum {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            IntSegmentTree min = new IntSegmentTree(n, Math::min, Integer.MAX_VALUE);
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                min.update(i, a);
            }

            long answer = 0;
            for (int i = 0; i < n; i++) {
                final int currentIndex = i;
                final int currentValue = min.get(i);
                Function<Integer, Boolean> tooManyElementsToTheLeft = (elementCount) -> {
                    if (elementCount <= 0) {
                        return false;
                    }

                    if (currentIndex - elementCount < 0) {
                        return true;
                    }

                    return min.query(currentIndex - elementCount, currentIndex - 1) < currentValue;
                };

                int l = currentIndex - (BinarySearch.binarySearch(tooManyElementsToTheLeft) - 1);

                Function<Integer, Boolean> tooManyElementsToTheRight = (elementCount) -> {
                    if (elementCount <= 0) {
                        return false;
                    }

                    if (currentIndex + elementCount >= n) {
                        return true;
                    }

                    return min.query(currentIndex + 1, currentIndex + elementCount) < currentValue;
                };

                int r = currentIndex + (BinarySearch.binarySearch(tooManyElementsToTheRight) - 1);

                answer += currentValue * (nc2(r - l + 2) - nc2(currentIndex - 1 - l + 2) - nc2(r - (currentIndex + 1) + 2));
            }

            out.println(answer);
        }

        static long nc2(long n) {
            if (n < 2) return 0;
            return n * (n - 1) / 2;
        }

    }

    static class BinarySearch {
        public static int binarySearch(Function<Integer, Boolean> bigEnough) {
            int tooSmall = 0, tooBig;
            if (bigEnough.apply(tooSmall)) {
                return tooSmall;
            }

            for (tooBig = 1; !bigEnough.apply(tooBig); tooBig *= 2) ;

            if (!bigEnough.apply(tooBig - 1)) {
                return tooBig;
            }

            while (tooBig - tooSmall > 1) {
                int center = (tooBig + tooSmall) / 2;
                if (!bigEnough.apply(center)) {
                    tooSmall = center;
                } else {
                    tooBig = center;
                }
            }

            return tooBig;
        }

    }

    static class IntSegmentTree {
        public int size;
        public int[] value;
        private final BiFunction<Integer, Integer, Integer> combiner;
        private final int identityElement;

        public IntSegmentTree(int size, BiFunction<Integer, Integer, Integer> combiner, int identityElement) {
            this.size = size;
            value = new int[2 * size];
            Arrays.fill(value, identityElement);
            this.combiner = combiner;
            this.identityElement = identityElement;
        }

        private int combine(int a, int b) {
            return combiner.apply(a, b);
        }

        public int get(int i) {
            return value[size + i];
        }

        public void update(int i, int v) {
            i += size;
            value[i] = v;
            while (i > 1) {
                i /= 2;
                value[i] = combine(value[2 * i], value[2 * i + 1]);
            }
        }

        public int query(int i, int j) {
            int res_left = identityElement, res_right = identityElement;
            for (i += size, j += size; i <= j; i /= 2, j /= 2) {
                if ((i & 1) == 1) res_left = combine(res_left, value[i++]);
                if ((j & 1) == 0) res_right = combine(value[j--], res_right);
            }
            return combine(res_left, res_right);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.function.BiFunction;
import java.io.IOException;
import java.util.function.Function;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class BMinimumSum {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            SegmentTree<Integer> min = new SegmentTree<>(n, Math::min, Integer.MAX_VALUE);
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                min.update(i, a);
            }

            long answer = 0;
            for (int i = 0; i < n; i++) {
                final int currentIndex = i;
                final int currentValue = min.get(i);
                Function<Integer, Boolean> tooManyElementsToTheLeft = (elementCount) -> {
                    if (elementCount <= 0) {
                        return false;
                    }

                    if (currentIndex - elementCount < 0) {
                        return true;
                    }

                    return min.query(currentIndex - elementCount, currentIndex - 1) < currentValue;
                };

                int l = currentIndex - (BinarySearch.binarySearch(tooManyElementsToTheLeft) - 1);

                Function<Integer, Boolean> tooManyElementsToTheRight = (elementCount) -> {
                    if (elementCount <= 0) {
                        return false;
                    }

                    if (currentIndex + elementCount >= n) {
                        return true;
                    }

                    return min.query(currentIndex + 1, currentIndex + elementCount) < currentValue;
                };

                int r = currentIndex + (BinarySearch.binarySearch(tooManyElementsToTheRight) - 1);

                answer += currentValue * (nc2(r - l + 2) - nc2(currentIndex - 1 - l + 2) - nc2(r - (currentIndex + 1) + 2));
            }

            out.println(answer);
        }

        static long nc2(long n) {
            if (n < 2) return 0;
            return n * (n - 1) / 2;
        }

    }

    static class SegmentTree<T> {
        public int size;
        public T[] value;
        private final BiFunction<T, T, T> combiner;
        private final T identityElement;

        public SegmentTree(int size, BiFunction<T, T, T> combiner, T identityElement) {
            this.size = size;
            value = (T[]) new Object[2 * size];
            Arrays.fill(value, identityElement);
            this.combiner = combiner;
            this.identityElement = identityElement;
        }

        private T combine(T a, T b) {
            return combiner.apply(a, b);
        }

        public T get(int i) {
            return value[size + i];
        }

        public void update(int i, T v) {
            i += size;
            value[i] = v;
            while (i > 1) {
                i /= 2;
                value[i] = combine(value[2 * i], value[2 * i + 1]);
            }
        }

        public T query(int i, int j) {
            T res_left = identityElement, res_right = identityElement;
            for (i += size, j += size; i <= j; i /= 2, j /= 2) {
                if ((i & 1) == 1) res_left = combine(res_left, value[i++]);
                if ((j & 1) == 0) res_right = combine(value[j--], res_right);
            }
            return combine(res_left, res_right);
        }

    }

    static class BinarySearch {
        public static int binarySearch(Function<Integer, Boolean> bigEnough) {
            int tooSmall = 0, tooBig;
            if (bigEnough.apply(tooSmall)) {
                return tooSmall;
            }

            for (tooBig = 1; !bigEnough.apply(tooBig); tooBig *= 2) ;

            if (!bigEnough.apply(tooBig - 1)) {
                return tooBig;
            }

            while (tooBig - tooSmall > 1) {
                int center = (tooBig + tooSmall) / 2;
                if (!bigEnough.apply(center)) {
                    tooSmall = center;
                } else {
                    tooBig = center;
                }
            }

            return tooBig;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

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


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] d = new int[n];
		Arrays.fill(d, 0);
		for(int i=0;i<m;i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			d[Math.min(a[i], b[i])-1] ++;
			d[Math.max(a[i], b[i])-1] --;
		}
		sc.close();
		boolean success = true;
		for(int i=0;i<n;i++){
			if(d[i]%2!=0){
				success = false;
				break;
			}
		}
		if(success)System.out.println("YES");
		else System.out.println("NO");

	}

}

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


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

public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    // int N = Integer.parseInt(scanner.nextLine());
    // int N = scanner.nextInt(), M = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    // long[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
    static void solve(Scanner scanner) {
        int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int N = n[0], M = n[1], K = n[2];

        Combination combination = new Combination(100_000, MOD);
        long x = 0, y = 0;
        for (int d = 1; d < N; d++) {
            x = (x + d * (N - d) * M * M) % MOD;
        }
        for (int d = 1; d < M; d++) {
            y = (y + d * (M - d) * N * N) % MOD;
        }
        long abs = (combination.kFromN(K - 2, N * M - 2) * (x + y)) % MOD;
        System.out.println(abs);
    }

}

class Combination {

    private int MOD = 1_000_000_007;
    private int MAX = 1_000_000;

    private final long[] fac, facInv, inv;

    public Combination(int max, int mod) {
        this.MAX = max + 1;
        this.MOD = mod;
        fac = new long[MAX];
        facInv = new long[MAX];
        inv = new long[MAX];

        fac[0] = fac[1] = 1;
        facInv[0] = facInv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            facInv[i] = facInv[i - 1] * inv[i] % MOD;
        }
    }

    public long kFromN(int k, int n) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (facInv[k] * facInv[n - k] % MOD) % MOD;
    }
}

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


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

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

		Scanner keyboard = new Scanner(System.in);

		String NN = keyboard.next();
			int N = Integer.parseInt(NN);

		int[] yama = new int[N];
			for(int i=0; i < N; i++) {
				yama[i] = keyboard.nextInt();
			}

		int count = 1;

		int max = yama[0];
		int min = yama[1];

		for (int j = 1; j < N; j++) {
		    int height = yama[j];
		    if ( height >= max) {
		        max = height;
		        count ++;
		        continue;
		    }else {
		    	if (height < min) {
		    		min = height;
		    		continue;
		    	}
		    }
		}
			System.out.print(count);

		keyboard.close();
	}
}

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


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

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

		Scanner keyboard = new Scanner(System.in);

		String NN = keyboard.next();
			int N = Integer.parseInt(NN);

		int[] yama = new int[N];
			for(int i=0; i < N; i++) {
				yama[i] = keyboard.nextInt();
			}

		int count = 1;

		int max = yama[0];
		int min = yama[1];

		for (int j = 1; j < N; j++) {
		    int v = yama[j];
		    if (v >= max) {
		        max = v;
		        count ++;
		        continue;
		    }else {
		    	if (v <= min) {
		    		min = v;
		    		continue;
		    	}
		    }
		}
			System.out.print(count);

		keyboard.close();
	}
}

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


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

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int Aup;
			int Abottom;
			int Bup;
			int Bbottom;
			int count = 0;

			for(int i=1;i<=n;i++) {
				Abottom = i%10;
				int APow = (int) Math.pow(10,(String.valueOf(i).length()-1));
				Aup =i/APow;

				for(int j=1;j<=n;j++) {
					Bbottom = j%10;
					int BPow = (int) Math.pow(10,(String.valueOf(j).length()-1));
					Bup =j/BPow;

					if(Abottom==Bup && Bbottom==Aup) {
						count++;
					}

				}

			}

			System.out.println(count);

		}

	}

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


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[] a = new int[n];
			int[] b = new int[n];

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

			int ret = 0;

			for(int i=n-1;i>=0;i--) {
				a[i]+=ret;

				while(a[i]%b[i]!=0) {
					if(a[i]%b[i]!=-0) {
						a[i]++;
						ret++;
					}
				}
			}

			System.out.println(ret);
		}

	}

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


Question:
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			int h = sc.nextInt();
			int w = sc.nextInt();

			char[][] ac = new char[h][w];
			String S;

			for(int i=0;i<h;i++) {
				S = sc.next();
				for(int j=0;j<w;j++) {
					ac[i][j] = S.charAt(j);
				}
			}

			int num = 0;

			for(int i=0;i<h;i++) {
				for(int j=0;j<w;j++) {
					if(ac[i][j]=='#') {
						num++;
					}
				}
			}

			if(num != h+w-1) {
				System.out.println("Impossible");
				return;
			}

			int x = 0;
			int y = 0;

			for(int j=1;j<num;j++) {
				if((ac[x][y+1]!='#')&&(ac[x+1][y]!='#')) {
					System.out.println("Impossible");
					return;
				}

				if(y<=w-1) {
					if((ac[x][y+1]=='#')) {
						y++;
					}
				}

				if(x<=h-1) {
					if((ac[x+1][y]=='#')) {
						x++;
					}
				}

			}

			System.out.println("Possible");

		}

	}

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


Question:
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			int h = sc.nextInt();
			int w = sc.nextInt();

			char[][] ac = new char[h][w];
			String S;

			for(int i=0;i<h;i++) {
				S = sc.next();
				for(int j=0;j<w;j++) {
					ac[i][j] = S.charAt(j);
				}
			}

			int num = 0;

			for(int i=0;i<h;i++) {
				for(int j=0;j<w;j++) {
					if(ac[i][j]=='#') {
						num++;
					}
				}
			}

			if(num != h+w-1) {
				System.out.println("Impossible");
				return;
			}

			int x = 0;
			int y = 0;

			for(int j=1;j<num;j++) {
				if((ac[x][y+1]!='#')&&(ac[x+1][y]!='#')) {
					System.out.println("Impossible");
					return;
				}

				if(y+1<w) {
					if((ac[x][y+1]=='#')) {
						y++;
					}
				}

				if(x+1<h) {
					if((ac[x+1][y]=='#')) {
						x++;
					}
				}

			}

			System.out.println("Possible");

		}

	}

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


Question:
7 6
......
....#.
.#....
..#...
..#...
......
.#..#.

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


Question:
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt(); //じゃんけんをする回数
		int k = stdIn.nextInt(); //k回目までのじゃんけんは好きな手を出せる
		int r = stdIn.nextInt(); //グーで勝った時の得点
		int s = stdIn.nextInt(); //パーで勝った時の得点
		int p = stdIn.nextInt(); //チョキで勝った時の得点

		String t = stdIn.next(); //筐体の出す手の文字列
		int ans = 0;
		String[] hand = new String[t.length()];

		for(int i = 0; i < k; i++) {
			if(t.charAt(i)== 'r') {
				ans += p;
				hand[i] = "p";
			}else if(t.charAt(i)=='s') {
				ans += r;
				hand[i] = "r";
			}else {
				ans += s;
				hand[i] = "s";
			}

		}

		for(int i = k; i < t.length(); i++) {
			if(t.charAt(i)== 'r') {
				if(!hand[i-k].equals("p")) {
					ans += p;
					hand[i] = "p";
				}else if(i < t.length()-k) {
					if(t.charAt(i+k) == 'p') {
						hand[i] = "r";
					}else {
						hand[i] = "s";
					}
				}
			}
			if(t.charAt(i)== 's') {
				if(!hand[i-k].equals("r")) {
					ans += r;
					hand[i] = "r";
				}else if(i < t.length()-k){
					if(t.charAt(i+k)== 's') {
						hand[i] = "s";
					}else {
						hand[i] ="r";
					}
				}
			}
			if(t.charAt(i)== 'p') {
				if(!hand[i-k].equals("s")) {
					ans += s;
					hand[i] = "s";
				}else if(i < t.length()-k){
					if(t.charAt(i+k)== 'r')
					hand[i] = "r";
				}else {
					hand[i] = "p";
				}
			}
		}

		System.out.println(ans);

	}
}

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


Question:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String n = Integer.toString(N);
		String a[] = n.split("", 0);
		int b[] = new int[a.length];
		int max = 0;
		for(int i = 0;i < a.length;i++) {
			b[i] = Integer.parseInt(a[i]);
			if(max < b[i]) {
				max = b[i];
			}
		}
		for(int i = 0;i < a.length;i++) {
			System.out.print(max);
		}
		sc.close();
	}
}

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


Question:
import java.util.*;
public class Screw {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[2*n];
        for(int i=0;i<2*n;i++)
        {
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        int t=0;
        for(int i=0;i<2*n;i+=2)
        {
            t+=Math.min(a[i],a[i+1]);
        }
        System.out.println(t);
    }

}

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


Question:
package AGC43;

import java.util.*;

public class Main {
    static int MAX = 1_000_005;
    static int MOD = 1_000_000_007;

    private static long[] FAC = new long[MAX];
    private static long[] INV_FAC = new long[MAX];

    private static void initCom(){
        FAC[0]=FAC[1]=1;
        INV_FAC[0]=INV_FAC[1]=1;
        for(int i=2;i<MAX;i++){
            FAC[i]=FAC[i-1]*i % MOD;
            INV_FAC[i]=modinv(FAC[i]);
        }
    }

    private static long comb(int n, int k){
        return (((FAC[n] * INV_FAC[n-k]) % MOD) * INV_FAC[k]) % MOD;
    }

    private static long modpow(long a, long b){
        if(b == 1){
            return a % MOD;
        }
        if(b == 0){
            return 1;
        }
        long res = b/2;
        long rem = b%2;
        long p = modpow(a, res) % MOD;
        if(rem == 1){
            return (((p*p) % MOD)*a) % MOD;
        }else{
            return (p*p) % MOD;
        }
    }

    private static long modinv(long a){
        return modpow(a, MOD-2);
    }

    private static long lucus(int n, int k, int mod){
        long res = 1L;
        while(n > 0){
            int n1 = n % mod;
            int k1 = k % mod;
            if(n1 == k1){
                res *= 1;
                n /= mod;
                k /= mod;
                continue;
            }else if(n1 < k1){
                res = 0;
                break;
            }else {
                res *= (long) comb(n1, k1);
                res %= mod;
                n /= mod;
                k /= mod;
            }
        }
        return res;
    }

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        char[] s = S.toCharArray();
        int[] ans = new int[N];
        long sum = 0;
        initCom();
        boolean aruflag = false;
        for(int i=0;i<N;i++) {
            ans[i] = s[i] - '1';
            if(ans[i] == 1){aruflag = true;}
        }
        for(int i=0;i<N;i++){
            sum += lucus(N-1, i, 2) * ans[i];
            //System.out.print(lucus(N-1, i, 2)+" ");
            sum %= 2;
        }
        int res = 20;
        if(sum % 2 == 1){
            res = 1;
        }else if(!aruflag){
            sum = 0;
            for(int i=0;i<N;i++){
                sum += lucus(N-1, i, 2) * (ans[i]/2);
                sum %= 2;
            }
            if(sum % 2 == 1){
                res = 2;
            }else{
                res = 0;
            }
        }else{
            res = 0;
        }
        System.out.println(res);
    }

}

Choices:
- Runtime Error
- Time Limit Exceeded
- Memory Limit Exceeded
- 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();
        String S = sc.next();
        char[] s = S.toCharArray();
        if(N==2){
            System.out.println(Math.abs(s[0] - s[1]));
            return;
        }
        if(N==3){
            int[] ans = new int[2];
            ans[0]=Math.abs(s[0]-s[1]);
            ans[1]=Math.abs(s[1]-s[2]);
            System.out.println(Math.abs(ans[0]-ans[1]));
            return;
        }
        int[] ans = new int[N-1];
        for(int i=0;i<N-1;i++){
            ans[i] = Math.abs(s[i]-s[i+1]);
        }
        List<ZIP> zl = new ArrayList<>();
        for(int i=0;i<N-2;i++){
            ans[i] = Math.abs(ans[i]-ans[i+1]);
            if(zl.size() == 0 || (zl.get(zl.size()-1).num != ans[i])){
                zl.add(new ZIP(ans[i], 1));
            }else{
                zl.get(zl.size()-1).addCnt();
            }
        }
        for(int i=0;i<N-3;i++){
            List<ZIP> nxt = new ArrayList<>();
            for(int j=0;j<zl.size();j++){
                if(zl.get(j).cnt > 1){
                    ZIP n = zl.get(j);
                    n.minusCnt();
                    n.num = 0;
                    nxt.add(n);
                }
                if(j < zl.size()-1){
                    int newNum = Math.abs(zl.get(j).num - zl.get(j+1).num);
                    nxt.add(new ZIP(newNum, 1));
                }
            }
            zl = nxt;
        }
        System.out.println(zl.get(0).num);
    }
    private static class ZIP{
        public int cnt;
        public int num;
        ZIP(int num, int cnt){
            this.cnt = cnt;
            this.num = num;
        }
        public void addCnt(){
            cnt++;
        }
        public void minusCnt(){
            cnt--;
        }
        @Override
        public String toString(){
            return num +"-"+cnt;
        }
    }
}

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


Question:
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int R = sc.nextInt();
        int S = sc.nextInt();
        int P = sc.nextInt();
        String T = sc.next();
        int res = IntStream.range(0, K).map(
            mod->maxValue(mod, T, R, S, P, K)
        ).sum();
        System.out.println(res);
    }

    public static int maxValue(int mod, String T, int R, int S, int P, int K){
        List<Character> chars = IntStream.range(0, T.length()).filter(a-> a%K == mod)
                .mapToObj(ind->T.charAt(ind)).collect(Collectors.toList());
        int rock, sci, pap;
        rock=0;sci=0;pap=0;
        for(int i=0;i<chars.size();i++){
            int nr, ns, np;
            np = Math.max(rock, sci);
            nr = Math.max(sci, pap);
            ns = Math.max(rock, pap);
            switch(chars.get(i)){
                case 'r':
                    np += P;
                    break;
                case 's':
                    nr += R;
                    break;
                case 'p':
                    ns += S;
                    break;
            }
            rock = nr;sci = ns;pap = np;
        }
        return Math.max(rock, Math.max(sci, pap));
    }
}

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


Question:
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        String ans = "Positive";

        if (a <= 0 && b >= 0) {
            ans = "Zero";
        } else if (a < 0 && (a + b) % 2 == 0) {
            ans = "Negative";
        }

        out.println(ans);

        out.flush();
    }

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


Question:
import java.util.*;
import java.lang.Math;

class Test {
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        if(n==2){
            System.out.println(2);
        }
        else{
            if(n%2==0){
                n+=1;
            }
            int f=0;
            while(f==0){
                int k= (int) Math.ceil(Math.sqrt(n));
                int l=0;
                for(int i=2;i<k;i++){
                    if(n%i==0){
                        break;
                    }
                    else{
                        l+=1;
                    }

                }
                if(l==k-2){
                    f=1;
                    System.out.println(n);
                }
                else{
                    n+=2;
                }

            }

        }
        }

    }

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


Question:
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int[] k = new int[m];
    int[][] s = new int[m][];
    int[] p = new int[m];
    for(int i=0;i<m;i++){
      k[i] = Integer.parseInt(sc.next());
      s[i] = new int[k[i]];
      for(int j=0;j<k[i];j++){
        s[i][j] = Integer.parseInt(sc.next())-1;
      }
    }
    for(int i=0;i<m;i++){
      p[i] = Integer.parseInt(sc.next());
    }
    int res = 0;
    outer:for(int i=0;i<(1<<n);i++){
      for(int j=0;j<m;j++){
        int count = 0;
        for(int l=0;l<k[j];l++){
          if((i>>s[j][l]) & 1)==1){
            count++;
          }
        }
        if(count%2!=p[j]){
          continue outer;
        }
      }
      res++;
    }
    System.out.println(res);

  }
}

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


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

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

        int n = sc.nextInt();
        int[] arr = new int[2*n];
        for(int i = 0; i < 2*n; i++){
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int ans = 0;
        for(int i = 2*n - 1; i > 0; i -= 2){
            ans += Math.min(arr[i], arr[i-1]);
        }
        System.out.println(ans);
    }
}

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


Question:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        int[][] ab = new int[N][2];
        for(int i=0;i<N;i++){
            ab[i][0] = sc.nextInt();
            ab[i][1] = sc.nextInt();
        }
        if(N%2 == 1){
            int med_min = ab[0][0];
            int med_max = ab[0][1];
            for(int i=1;i<N;i+=2){
                if(ab[i][0] >= ab[i+1][0]){
                    med_min = Math.max(Math.min(ab[i][0], med_min), ab[i+1][0]);
                }else{
                    med_min = Math.max(Math.min(ab[i+1][0], med_min), ab[i][0]);
                }
                if(ab[i][1] >= ab[i+1][1]){
                    med_max = Math.max(Math.min(ab[i][1], med_max), ab[i+1][1]);
                }else{
                    med_max = Math.max(Math.min(ab[i+1][1], med_max), ab[i][1]);
                }
            }
            System.out.println(med_max - med_min + 1);
        }else{
            int[] med_min = {Math.min(ab[0][0], ab[1][0]), Math.max(ab[0][0], ab[1][0])};
            int[] med_max = {Math.min(ab[0][1], ab[1][1]), Math.max(ab[0][1], ab[1][1])};
            for(int i=2;i<N;i+=2){
                List<Integer> min = new ArrayList<>();
                min.add(ab[i][0]);
                min.add(ab[i+1][0]);
                min.add(med_min[0]);
                min.add(med_min[1]);
                Collections.sort(min);
		med_min[0] = min.get(1);
		med_min[1] = min.get(2);
                List<Integer> max = new ArrayList<>();
                min.add(ab[i][1]);
                min.add(ab[i+1][1]);
                min.add(med_max[0]);
                min.add(med_max[1]);
                Collections.sort(max);
		med_min[0] = max.get(1);
		med_min[1] = max.get(2);
	    }
            System.out.println((med_max[1] + med_max[0]) - (med_min[1] + med_min[0]) + 1);
        }
    }
}

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


Question:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        int[][] ab = new int[N][2];
        for(int i=0;i<N;i++){
            ab[i][0] = sc.nextInt();
            ab[i][1] = sc.nextInt();
        }
        if(N%2 == 1){
            int med_min = ab[0][0];
            int med_max = ab[0][1];
            for(int i=1;i<N;i+=2){
                if(ab[i][0] >= ab[i+1][0]){
                    med_min = Math.max(Math.min(ab[i][0], med_min), ab[i+1][0]);
                }else{
                    med_min = Math.max(Math.min(ab[i+1][0], med_min), ab[i][0]);
                }
                if(ab[i][1] >= ab[i+1][1]){
                    med_max = Math.max(Math.min(ab[i][1], med_max), ab[i+1][1]);
                }else{
                    med_max = Math.max(Math.min(ab[i+1][1], med_max), ab[i][1]);
                }
            }
            System.out.println(med_max - med_min + 1);
        }else{
            int[] med_min = {Math.min(ab[0][0], ab[1][0]), Math.max(ab[0][0], ab[1][0])};
            int[] med_max = {Math.min(ab[0][1], ab[1][1]), Math.max(ab[0][1], ab[1][1])};
            for(int i=2;i<N;i+=2){
                List<Integer> min = new ArrayList<>();
                min.add(ab[i][0]);
                min.add(ab[i+1][0]);
                min.add(med_min[0]);
                min.add(med_min[1]);
                Collections.sort(min);
		med_min[0] = min.get(1);
		med_min[1] = min.get(2);
                List<Integer> max = new ArrayList<>();
                min.add(ab[i][1]);
                min.add(ab[i+1][1]);
                min.add(med_max[0]);
                min.add(med_max[1]);
                Collections.sort(max);
		med_min[0] = max.get(1);
		med_min[1] = max.get(2);
	    }
            System.out.println(((med_max[1] + med_min[1]) - (med_max[0] + med_min[0])) + 1);
        }
    }
}

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


Question:
/**
 * Created at 00:27 on 2019-07-01
 */

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

public class Main {

  static FastScanner sc = new FastScanner();
  static PrintStream out = System.out;
  static PrintWriter pw = new PrintWriter(out);

  static final int[] dx = {0, 1, 0, -1};
  static final int[] dy = {-1, 0, 1, 0};

  static final long MOD = (long) (1e9 + 7);
  static final long INF = Long.MAX_VALUE / 2;

  static long[] fact;

  public static class Solver implements Runnable {
    public void run() {

      long N = sc.nextLong();
      long M = sc.nextLong();

      fact = new long[(int)(N*M)+1];

      long K = sc.nextLong();

      long C = comb(M*N-2, K-2);
      long M2 = M * M;
      long N2 = N * N;

      long ans = 0;
      for (long i=0; i<N; i++) {
        for (long j=0; j<N; j++) {
          ans += (Math.abs(i-j) * C * M2) % MOD;
        }
      }
      for (long i=0; i<M; i++) {
        for (long j=0; j<M; j++) {
          ans += (Math.abs(i-j) * C * N2) % MOD;
        }
      }

      ans = (ans / 2) % MOD;

      out.println(ans);

    }
  }

  public static long power(long a, long b) {
    if (b == 0) return 1;

    if (b % 2 == 0) {
      long p = power(a, b/2);
      return (p * p) % MOD;
    } else {
      return (a * power(a, b - 1)) % MOD;
    }
  }

  public static long factorial(long n) {
    if (n == 0) return 1;
    if (fact[(int)n] == 0) {
      return fact[(int)n] = (n * factorial(n - 1)) % MOD;
    } else {
      return fact[(int)n];
    }
  }

  public static long factorialInverse(long n) {
    return power(factorial(n), MOD-2);
  }

  public static long comb(long n, long r) {
    if (r < 0 || r > n) return 0;
    return (((factorial(n) * factorialInverse(r)) % MOD) * factorialInverse(n-r)) % MOD;
  }

  public static void main(String[] args) {
    Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
    new Thread(null, new Solver(), "", 128 * 1024 * 1024).start();
  }

  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;
    }

    private void skipUnprintable() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
      skipUnprintable();
      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() {
      return (int) nextLong();
    }

    public int[] nextIntArray(int N, boolean oneBased) {
      if (oneBased) {
        int[] array = new int[N + 1];
        for (int i = 1; i <= N; i++) {
          array[i] = sc.nextInt();
        }
        return array;
      } else {
        int[] array = new int[N];
        for (int i = 0; i < N; i++) {
          array[i] = sc.nextInt();
        }
        return array;
      }
    }

    public long[] nextLongArray(int N, boolean oneBased) {
      if (oneBased) {
        long[] array = new long[N + 1];
        for (int i = 1; i <= N; i++) {
          array[i] = sc.nextLong();
        }
        return array;
      } else {
        long[] array = new long[N];
        for (int i = 0; i < N; i++) {
          array[i] = sc.nextLong();
        }
        return array;
      }
    }
  }

}

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


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

public class Stress {

    public void solve() throws IOException {
        int q = nextInt(), h = nextInt(), s = nextInt(), d = nextInt();
        long n = nextInt();
        if(h > 2 * q){
            h = 2 * q;
        }
        if(s > 2 * h){
            s = 2 * h;
        }
        if(d > 2 * s){
            d = 2 * s;
        }
        long res = 0;
        if(d <= 2 * s){
            res += n / 2 * d;
            res += (n % 2) * s;
        }else{
            res = n * s;
        }
        out.print(res);
    }

    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Stress().run();
    }

    void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            br = new BufferedReader(new FileReader("reverse.in"));
//            out = new PrintWriter(new File("reverse.out"));
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
}

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


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

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    int n = Integer.parseInt(r.readLine());
    int a[] = new int[200001];
    int x[] = new int[200001];

    for(int i = 0; i < n; i++)
    {
      a[i] = Integer.parseInt(r.readLine());
    }

    for(int i = 0; i < n; i++)
    {
      if(i < a[i] || a[i + 1] - a[i] > 1)
      {
        System.out.println(-1);
        System.exit(0);
      }
    }

    int v = 0;
    for(int i = n - 1; 0 < i; i--)
    {
      boolean f = false;
      for(int c = 0; c <= a[i]; c++)
      {
        if(x[i - c] == a[i] - c)
        {
          for(int j = i; i - c < j; j--)
          {
            x[j] = a[i] - i + j;
            v++;
          }
          f = true;
          break;
        }
      }
      if(!f)
      {
        System.out.println(-1);
        System.exit(0);
      }
    }
    System.out.println(v);

  }
}

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


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

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    int n = Integer.parseInt(r.readLine());
    int a[] = new int[200000];
    int x[] = new int[200000];

    for(int i = 0; i < n; i++)
    {
      a[i] = Integer.parseInt(r.readLine());
    }

    for(int i = 0; i < n; i++)
    {
      if(i < a[i])
      {
        System.out.println(-1);
        System.exit(0);
      }
    }

    int v = 0;
    for(int i = n - 1; 0 < i; i--)
    {
      boolean f = false;
      for(int c = 0; c <= a[i]; c++)
      {
        if(x[i - c] == a[i] - c)
        {
          for(int j = i; i - c < j; j--)
          {
            x[j] = a[i] - i + j;
            v++;
          }
          f = true;
          break;
        }
      }
      if(!f)
      {
        System.out.println(-1);
        System.exit(0);
      }
    }
    System.out.println(v);

  }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemB solver = new ProblemB();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemB {
		final int N = 200010;
		final int MOD = (int) (1e9 + 7);
		int[] fact = new int[N];
		int[] inv = new int[N];
		int[] invFact = new int[N];

		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			precalc();

			int n = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
			}

			long[] f = new long[n];
			for (int d = 0; d < n; d++) {
				int b = n - 1 - d;
				long cur = 0;
				for (int k = 0; k <= b; k++) {
					long v = 1;
					v = v * fact[n - k - 1] % MOD;
					v = v * invFact[b - k] % MOD;
					cur = (cur + v) % MOD;
				}
				f[d] = cur * fact[b] % MOD;
			}

			long ans = 0;
//		for (int i = 0; i < n; i++) {
//			for (int j = 0; j < n; j++) {
//				ans = (ans + f[Math.abs(i - j)] * a[i]) % MOD;
//			}
//		}

			long[] inc = new long[n + 1];
			for (int i = 0; i < n; i++) {
				addSegment(inc, 0, 0, a[i]);
				addSegment(inc, 1, i, a[i]);
				addSegment(inc, 1, n - i - 1, a[i]);
			}

			long sum = 0;
			for (int i = 0; i < n; i++) {
				sum += inc[i];
				if (sum >= MOD) {
					sum -= MOD;
				}
				ans = (ans + sum * f[i]) % MOD;
			}

			out.println(ans);
		}

		private void addSegment(long[] inc, int l, int r, int val) {
			inc[l] += val;
			if (inc[l] >= MOD) {
				inc[l] -= MOD;
			}
			inc[r + 1] -= val;
			if (inc[r + 1] < 0) {
				inc[r + 1] += MOD;
			}
		}

		private void precalc() {
			inv[1] = 1;
			for (int i = 2; i < N; i++) {
				inv[i] = (int) ((MOD - (MOD / i) * (long) inv[MOD % i] % MOD) % MOD);
			}
			fact[0] = 1;
			invFact[0] = 1;
			for (int i = 1; i < N; i++) {
				fact[i] = (int) (i * (long) fact[i - 1] % MOD);
				invFact[i] = (int) (inv[i] * (long) invFact[i - 1] % MOD);
			}
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

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

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

	}
}

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


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

class Main {
  public static void main(String [] args) {
    Reader in = new Reader();
    char [] s = in.next().toCharArray();
    StringProcessor solver = new StringProcessor(s);
    System.out.println(solver.countWays());
  }
}
class StringProcessor {
  char [] s;
  int n;
  final int mod = 998244353;
  boolean [][][] vis;
  int [][][] mem;
  int [] cnt;
  int [][] opt;

  StringProcessor(char [] s) {
    this.s = s.clone();
    this.n = this.s.length;
    vis = new boolean [this.n + 1][this.n + 1][this.n + 1];
    cnt = new int [this.n + 1];
    opt = new int [this.n + 1][this.n + 1];
    mem = new int [this.n + 1][this.n + 1][this.n + 1];
    cnt[n] = 0;
    for(int i = n - 1; i >= 0; i--) {
      cnt[i] = cnt[i + 1];
      if(s[i] == '1') cnt[i] = cnt[i] + 1;
    }
    for(int i = 0; i <= n; i++) {
      for(int j = 0; j <= n; j++) {
        for(int k = 0; k <= n; k++) {
          mem[i][j][k] = -1;
          vis[i][j][k] = false;
        }
        opt[i][j] = -1;
      }
    }
  }
  void dfs(int cur, int cntMove, int cntOne) {
    if(vis[cur][cntMove][cntOne]) return ;
    vis[cur][cntMove][cntOne] = true;
    opt[cntMove][cntOne + cnt[cur]] = Math.max(opt[cntMove][cntOne + cnt[cur]], cur);
    int cntZero = cur - cntMove - cntOne;
    if(cntOne >= 2) {
      dfs(cur, cntMove + 1, cntOne - 1);
    }
    if(cntZero >= 2) {
      dfs(cur, cntMove + 1, cntOne);
    }
    if(cntOne >= 1 && cntZero >= 1) {
      dfs(cur, cntMove + 1, cntOne - 1);
      dfs(cur, cntMove + 1, cntOne);
    }
    if(cur + 2 <= n) {
      if(s[cur] == '0' || s[cur + 1] == '0') {
        dfs(cur + 2, cntMove + 1, cntOne);
      }
      if(s[cur] == '1' || s[cur + 1] == '1') {
        dfs(cur + 2, cntMove + 1, cntOne + 1);
      }
    }
    if(cur + 1 <= n) {
      if(s[cur] == '0') {
        if(cntOne > 0) dfs(cur + 1, cntMove + 1, cntOne - 1);
        if(cntZero > 0) dfs(cur + 1, cntMove + 1, cntOne);
      } else {
        if(cntZero > 0) dfs(cur + 1, cntMove + 1, cntOne + 1);
        if(cntOne > 0) dfs(cur + 1, cntMove + 1, cntOne);
      }
    }
  }
  int dp(int cur, int cntOne, int cntZero) {
    if(cntOne == 0 && cntZero == 0) {
      return (cur == n) ? 1 : 0;
    }
    if(mem[cur][cntOne][cntZero] != -1) {
      return mem[cur][cntOne][cntZero];
    }
    int ans = 0;
    if(cur < n) {
      if(s[cur] == '0') {
        if(cntZero > 0) ans += dp(cur + 1, cntOne, cntZero - 1);
        if(cntOne > 0) ans += dp(cur, cntOne - 1, cntZero);
      } else {
        if(cntOne > 0) ans += dp(cur + 1, cntOne - 1, cntZero);
        if(cntZero > 0) ans += dp(cur, cntOne, cntZero - 1);
      }
      ans %= mod;
    } else {
      if(cntOne > 0) {
        ans += dp(cur, cntOne - 1, cntZero);
      }
      if(cntZero > 0) {
        ans += dp(cur, cntOne, cntZero - 1);
      }
      ans %= mod;
    }
    return mem[cur][cntOne][cntZero] = ans;
  }
  int countWays() {
    dfs(0, 0, 0);
    int ans = 1;
    for(int i = 1; i <= n; i++) {
      for(int j = 0; j <= n; j++) {
        int idx = opt[i][j];
        if(idx < 0) continue;
        ans += dp(idx, j, n - i - j);
        ans %= mod;
      }
    }
    return ans;
  }
}

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


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

public class Main {
    public static void main(String [] args) {
        Solver s = new Solver();
        s.solve();
    }
}

class Queue {
    int [] q;
    int head, tail;
    Queue (int n) {
        q = new int [n];
        head = tail = 0;
    }
    void push(int x) {
        q[tail++] = x;
    }
    int front() {
        return q[head];
    }
    int pop() {
        return q[head++];
    }
    int size() {
        return tail - head;
    }
}

class Solver {
    Reader in = new Reader ();
    Writer out = new Writer ();
    ArrayList <Integer> g[] = new ArrayList [100010];

    Pair farthest_node(int root, int n) {
        int [] dist = new int [n];
        Arrays.fill(dist, -1);

        Queue q = new Queue (n);
        q.push(root);
        dist[root] = 0;

        while(q.size() > 0) {
            int x = q.pop();
            for(int i : g[x]) {
                if(dist[i] == -1) {
                    dist[i] = 1 + dist[x];
                    q.push(i);
                }
            }
        }
        int farthest = 0;
        for(int i = 1; i < n; i++) {
            if(dist[farthest] < dist[i]) {
                farthest = i;
            }
        }
        return new Pair(dist[farthest], farthest);
    }
    void solve () {
        int n = in.nextInt();
        for(int i = 0; i < n; i++) {
            g[i] = new ArrayList <> ();
        }
        for(int i = 1; i < n; i++) {
            int p = in.nextInt() - 1;
            int q = in.nextInt() - 1;
            g[p].add(q);
            g[q].add(p);
        }
        Pair p = farthest_node(0, n);
        Pair q = farthest_node(p.second, n);
        int diameter = q.first;

        if(diameter % 3 == 1) {
            System.out.println("Second");
        } else {
            System.out.println("First");
        }
    }
}

class Reader {
    private StringTokenizer a;
    private BufferedReader b;
    Reader () {
        a = null;
        try {
            b = new BufferedReader (new InputStreamReader (System.in)); // for file IO, replace this with new FileReader ("in.txt")
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public String next () {
        while(a == null || !a.hasMoreTokens()) {
            try {
                a = new StringTokenizer (b.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return a.nextToken();
    }
    public int nextInt() {
        return Integer.parseInt(this.next());
    }
    public long nextLong () {
        return Long.parseLong(this.next());
    }
    public double nextDouble () {
        return Double.parseDouble(this.next());
    }
    public String nextLine() {
        try {
            return b.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }
}
class Writer {
    private PrintWriter a;
    private StringBuffer b;
    Writer () {
        try {
            a = new PrintWriter (System.out); // for file IO, replace this with new FileWriter ("out.txt")
        } catch (Exception e) {
            e.printStackTrace();
        }
        b = new StringBuffer ("");
    }
    public void write (Object s) {
        b.append(s);
    }
    public void writeln(Object s) {
        b.append(s).append('\n');
    }
    public void flush () {
        a.print(b);
        a.flush();
        a.close();
    }
}
class Pair implements Comparator <Pair> {
    int first;
    int second;
    Pair  (int a, int b) {
        this.first = a;
        this.second = b;
    }
    Pair (Pair a) {
        this.first = a.first;
        this.second = a.second;
    }
    Pair () {}
    public String toString () {
        return "[" + first + ", " + second + "]";
    }
    public int compare (Pair a, Pair b) {
        if(a.first == b.first) {
            return a.second - b.second;
        } else {
            return a.first - b.first;
        }
    }
}

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


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

public class RemoveCoin {
    public static void main(String [] args) {
        Solver s = new Solver();
        s.solve();
    }
}

class Queue {
    int [] q;
    int head, tail;
    Queue (int n) {
        q = new int [n];
        head = tail = 0;
    }
    void push(int x) {
        q[tail++] = x;
    }
    int front() {
        return q[head];
    }
    int pop() {
        return q[head++];
    }
    int size() {
        return tail - head;
    }
}

class Solver {
    Reader in = new Reader ();
    Writer out = new Writer ();
    ArrayList <Integer> g[] = new ArrayList [100010];

    Pair farthest_node(int root, int n) {
        int [] dist = new int [n];
        Arrays.fill(dist, -1);

        Queue q = new Queue (n);
        q.push(root);
        dist[root] = 0;

        while(q.size() > 0) {
            int x = q.pop();
            for(int i : g[x]) {
                if(dist[i] == -1) {
                    dist[i] = 1 + dist[x];
                    q.push(i);
                }
            }
        }
        int farthest = 0;
        for(int i = 1; i < n; i++) {
            if(dist[farthest] < dist[i]) {
                farthest = i;
            }
        }
        return new Pair(dist[farthest], farthest);
    }
    void solve () {
        int n = in.nextInt();
        for(int i = 0; i < n; i++) {
            g[i] = new ArrayList <> ();
        }
        for(int i = 1; i < n; i++) {
            int p = in.nextInt() - 1;
            int q = in.nextInt() - 1;
            g[p].add(q);
            g[q].add(p);
        }
        Pair p = farthest_node(0, n);
        Pair q = farthest_node(p.second, n);
        int diameter = q.first;

        if(diameter % 3 == 1) {
            System.out.println("Second");
        } else {
            System.out.println("First");
        }
    }
}

class Reader {
    private StringTokenizer a;
    private BufferedReader b;
    Reader () {
        a = null;
        try {
            b = new BufferedReader (new InputStreamReader (System.in)); // for file IO, replace this with new FileReader ("in.txt")
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public String next () {
        while(a == null || !a.hasMoreTokens()) {
            try {
                a = new StringTokenizer (b.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return a.nextToken();
    }
    public int nextInt() {
        return Integer.parseInt(this.next());
    }
    public long nextLong () {
        return Long.parseLong(this.next());
    }
    public double nextDouble () {
        return Double.parseDouble(this.next());
    }
    public String nextLine() {
        try {
            return b.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }
}
class Writer {
    private PrintWriter a;
    private StringBuffer b;
    Writer () {
        try {
            a = new PrintWriter (System.out); // for file IO, replace this with new FileWriter ("out.txt")
        } catch (Exception e) {
            e.printStackTrace();
        }
        b = new StringBuffer ("");
    }
    public void write (Object s) {
        b.append(s);
    }
    public void writeln(Object s) {
        b.append(s).append('\n');
    }
    public void flush () {
        a.print(b);
        a.flush();
        a.close();
    }
}
class Pair implements Comparator <Pair> {
    int first;
    int second;
    Pair  (int a, int b) {
        this.first = a;
        this.second = b;
    }
    Pair (Pair a) {
        this.first = a.first;
        this.second = a.second;
    }
    Pair () {}
    public String toString () {
        return "[" + first + ", " + second + "]";
    }
    public int compare (Pair a, Pair b) {
        if(a.first == b.first) {
            return a.second - b.second;
        } else {
            return a.first - b.first;
        }
    }
}

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


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

class TreeRestore {
	public static void main (String[] args) {
		Reader in = new Reader ();
		int n = in.nextInt();
		int [] d = new int [n + 5];
		int [] cnt = new int [n + 5];

		int diametre = 0;
		for(int i = 1; i <= n; i++) {
			d[i] = in.nextInt();
			cnt[d[i]] += 1;
			diametre = Math.max(diametre, d[i]);
		}
		boolean ans = true;
		if(diametre >= n) ans = false;
		if(diametre % 2 == 1) {
			int mid = (diametre >> 1) + 1;
			for(int i = mid; i <= diametre; i++) {
				if(cnt[i] > 1) {
					cnt[i] -= 2;
				} else {
					ans = false;
					break;
				}
			}
			for(int i = 0; i <= n; i++) {
				if(cnt[i] > 0) {
					if(i <= mid) ans = false;
				}
			}
		} else {
			int mid = diametre >> 1;
			for(int i = mid; i <= diametre; i++) {
				if(i == mid) {
					if(cnt[i] > 0) {
						cnt[i] -= 1;
					} else {
						ans = false;
						break;
					}
				} else {
					if(cnt[i] > 1) {
						cnt[i] -= 2;
					} else {
						ans = false;
						break;
					}
				}
			}
			for(int i = 0; i <= n; i++) {
				if(cnt[i] > 0) {
					if(i <= mid) ans = false;
				}
			}
		}
		if(ans) System.out.println("Possible");
		else System.out.println("Impossible");
	}
	static class Reader {
		private BufferedReader a;
		private StringTokenizer b;
		Reader() {
			a = new BufferedReader (new InputStreamReader (System.in));
		}
		public String next () {
			while(b == null || !b.hasMoreTokens()) {
				try {
					 b = new StringTokenizer (a.readLine());
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
			 return b.nextToken();
		}
		public int nextInt () {
		     return Integer.parseInt(next());
		}
		public long nextLong () {
			return Long.parseLong(next());
		}
		public double nextDouble () {
			return Double.parseDouble(next());
		}
		public String nextLine () {
		 	try {
		 		return a.readLine();
		 	} catch (IOException e) {
		 		e.printStackTrace ();
		 	}
		 	return "##";
		}
	}
}

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


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

class Main {
	static long [][] c = new long [2002][2002];
	static long [] fac = new long [2002];
	static final int mod = 924844033;
	static long [][] dp = new long [4002][4002];

	public static void main (String[] args) {
		Reader in = new Reader();
		int n = in.nextInt();
		int k = in.nextInt();

		fac[0] = 1;
		for(int i = 1; i <= n; i++) {
			fac[i] = fac[i - 1] * i;
			fac[i] %= mod;
		}
		for(int i = 0; i <= n; i++) {
			c[i][0] = 1;
			for(int j = 1; j <= i; j++) {
				c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
				c[i][j] %= mod;
			}
		}
		ArrayList <Integer> chain = new ArrayList <> ();
		for(int i = 1; i <= k; i++) {
			int sz = 0;
			int cur = i;
			while(cur <= n) {
				++sz;
				cur += k;
			}
			chain.add(sz);
			chain.add(sz);
		}
		dp[0][0] = 1;
		for(int i = 1; i <= chain.size(); i++) {
			int sz = chain.get(i - 1);
			for(int j = 0; j <= n; j++) {
				for(int x = 0; x <= Math.min(j, sz); x++) {
					dp[i][j] += dp[i - 1][j - x] * c[sz - x][x];
					dp[i][j] %= mod;
				}
			}
		}

		long ans = 0;
		for(int i = 0; i <= n; i++) {
			if(i % 2 == 1) {
				ans -= fac[n - i] * dp[chain.size()][i];
			} else {
				ans += fac[n - i] * dp[chain.size()][i];
			}
			ans %= mod;
		}
		if(ans < 0) ans += mod;
		System.out.println(ans);
	}
	static class Reader {
		private BufferedReader a;
		private StringTokenizer b;
		Reader() {
			a = new BufferedReader (new InputStreamReader (System.in));
		}
		public String next () {
			while(b == null || !b.hasMoreTokens()) {
				try {
					 b = new StringTokenizer (a.readLine());
				 } catch (IOException e) {
					 e.printStackTrace();
				 }
			 }
			 return b.nextToken();
		}
		public int nextInt () {
		     return Integer.parseInt(next());
		}
		public long nextLong () {
			return Long.parseLong(next());
		}
		public double nextDouble () {
			return Double.parseDouble(next());
		}
		public String nextLine () {
		 	try {
		 		return a.readLine();
		 	} catch (IOException e) {
		 		e.printStackTrace ();
		 	}
		 	return "##";
		}
	}
}

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


Question:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int M = Integer.parseInt(lines[1]);
		int[][] ks = new int[M][N];

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

		int[] p = new int[M];
		for(int i = 0 ; i < p.length; i++) {
			p[i] = sc.nextInt();
		}

		int sum = 0;
		//Shift演算を使っているらしい
		for(int i = 0; i < (1 << N); i++) {
			boolean exist = true;
			for(int j2 = 0; j2 < ks.length; j2++) {
				int count = 0;
				for(int k = 0; k < ks[j2].length; k++) {
					if(ks[j2][k] == 1) {
						if((1 & i >> k) == 1) {
							count++;
						}
					}
				}
				if(count % 2 != p[j2] ) {
					exist = false;
					break;
				}
			}
			if(exist) {
				sum++;
			}

		}

		System.out.println(sum);
	}

}

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


Question:
import io.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    String[] lines = line.split();

    int T = Integer.parseInt(lines[0]);
    int X = Integer.parseInt(lines[1]);

    System.out.println(T / X);
  }
}

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


Question:
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;
import static java.math.BigInteger.ONE;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	static final int MOD = 998244353;
	static final BigInteger BMOD = BigInteger.valueOf(MOD);

	static int add(int a, int b) {
		int res = a + b;
		return res >= MOD ? res - MOD : res;
	}

	static int sub(int a, int b) {
		int res = a - b;
		return res < 0 ? res + MOD : res;
	}

	static int mul(int a, int b) {
		int res = (int) ((long) a * b % MOD);
		return res < 0 ? res + MOD : res;
	}

	static void solve() throws Exception {
		int n = scanInt();
		BigInteger bigMod = ONE.shiftLeft(n).add(ONE), lim = new BigInteger(scanString(), 2).add(ONE);
		int ans = 0;
		List<Integer> divs = new ArrayList<>(), divCnts = new ArrayList<>();
		for (int i = 1; i <= 2 * n; i++) {
			if (2 * n % i != 0) {
				continue;
			}
			int cnt = lim.divide(bigMod.divide(bigMod.gcd(ONE.shiftLeft(i).subtract(ONE)))).mod(BMOD).intValue();
			for (int j = 0; j < divs.size(); j++) {
				if (i % divs.get(j) == 0) {
					cnt = sub(cnt, divCnts.get(j));
				}
			}
			divs.add(i);
			divCnts.add(cnt);
			ans = add(ans, mul(i, cnt));
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long penalty = in.nextInt();
            long[] x = new long[n];
            for (int i = 0; i < n; ++i) {
                x[i] = in.nextInt();
            }
            long res = Long.MAX_VALUE;
            for (long trips = n; trips >= 1; --trips) {
                int cnt = 0;
                int val = 5;
                int iter = 0;
                long cur = 0;
                for (int i = n - 1; i >= 0; --i) {
                    if (cnt == trips) {
                        cnt = 0;
                        ++iter;
                        if (iter > 1)
                            val += 2;
                    }
                    ++cnt;
                    cur += val * x[i];
                }
                if (cur >= res) break;
                res = Math.min(res, cur + penalty * trips);
            }
            out.println(res + penalty * n);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long penalty = in.nextInt();
            long[] x = new long[n];
            for (int i = 0; i < n; ++i) {
                x[i] = in.nextInt();
            }
            long res = Long.MAX_VALUE;
            for (long trips = n; trips >= 1; --trips) {
                int cnt = 0;
                int val = 5;
                int iter = 0;
                long cur = penalty * trips;
                if (cur > res) break;
                for (int i = n - 1; i >= 0; --i) {
                    if (cnt == trips) {
                        cnt = 0;
                        ++iter;
                        if (iter > 1)
                            val += 2;
                    }
                    ++cnt;
                    cur += val * x[i];
                }
                res = Math.min(res, cur);
            }
            out.println(res + penalty * n);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Set;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            List<TaskE.Vertex> vs = new ArrayList<>();
            for (int i = 0; i < n; ++i) {
                TaskE.Vertex v = new TaskE.Vertex();
                v.index = i;
                vs.add(v);
            }
            for (int i = 0; i < n - 1; ++i) {
                TaskE.Vertex a = vs.get(in.nextInt() - 1);
                TaskE.Vertex b = vs.get(in.nextInt() - 1);
                a.blueAdj.add(b);
                b.blueAdj.add(a);
            }
            for (int i = 0; i < n - 1; ++i) {
                TaskE.Vertex a = vs.get(in.nextInt() - 1);
                TaskE.Vertex b = vs.get(in.nextInt() - 1);
                a.redAdj.add(b);
                b.redAdj.add(a);
            }
            List<TaskE.Candidate> cands = new ArrayList<>();
            for (TaskE.Vertex a : vs) {
                for (TaskE.Vertex b : a.blueAdj) {
                    if (a.index < b.index && a.redAdj.contains(b)) {
                        cands.add(new TaskE.Candidate(a, b));
                    }
                }
            }
            for (int ptr = 0; ptr < cands.size(); ++ptr) {
                TaskE.Candidate ca = cands.get(ptr);
                TaskE.Vertex a = ca.a;
                TaskE.Vertex b = ca.b;
                if (a.blueAdj.size() + a.redAdj.size() < b.blueAdj.size() + b.redAdj.size()) {
                    TaskE.Vertex t = a;
                    a = b;
                    b = t;
                }
                if (!a.blueAdj.remove(b)) throw new RuntimeException();
                if (!b.blueAdj.remove(a)) throw new RuntimeException();
                if (!a.redAdj.remove(b)) throw new RuntimeException();
                if (!b.redAdj.remove(a)) throw new RuntimeException();
                for (TaskE.Vertex c : b.blueAdj) {
                    if (!a.blueAdj.add(c)) throw new RuntimeException();
                    if (!c.blueAdj.remove(b)) throw new RuntimeException();
                    if (!c.blueAdj.add(a)) throw new RuntimeException();
                    if (a.redAdj.contains(c)) {
                        cands.add(new TaskE.Candidate(a, c));
                    }
                }
                for (TaskE.Vertex c : b.redAdj) {
                    if (!a.redAdj.add(c)) throw new RuntimeException();
                    if (!c.redAdj.remove(b)) throw new RuntimeException();
                    if (!c.redAdj.add(a)) throw new RuntimeException();
                    if (a.blueAdj.contains(c)) {
                        cands.add(new TaskE.Candidate(a, c));
                    }
                }
            }
            out.println(cands.size() == n - 1 ? "YES" : "NO");
        }

        static class Vertex {
            int index;
            Set<TaskE.Vertex> blueAdj = new HashSet<>();
            Set<TaskE.Vertex> redAdj = new HashSet<>();

        }

        static class Candidate {
            TaskE.Vertex a;
            TaskE.Vertex b;

            public Candidate(TaskE.Vertex a, TaskE.Vertex b) {
                this.a = a;
                this.b = b;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

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


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

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            TaskE.Vertex[] vs = new TaskE.Vertex[n];
            for (int i = 0; i < n; ++i) vs[i] = new TaskE.Vertex();
            TaskE.Vertex us = vs[in.nextInt() - 1];
            TaskE.Vertex root = vs[in.nextInt() - 1];
            for (int i = 0; i < n - 1; ++i) {
                TaskE.Vertex a = vs[in.nextInt() - 1];
                TaskE.Vertex b = vs[in.nextInt() - 1];
                a.adjUs.add(b);
                b.adjUs.add(a);
            }
            for (int i = 0; i < n - 1; ++i) {
                TaskE.Vertex a = vs[in.nextInt() - 1];
                TaskE.Vertex b = vs[in.nextInt() - 1];
                a.adjThey.add(b);
                b.adjThey.add(a);
            }
            root.fillWhenThey(0);
            us.fillWhenUs(0);

            int res = 0;
            for (TaskE.Vertex v : vs)
                if (v.whenUs >= 0) {
                    boolean golden = false;
                    for (TaskE.Vertex u : v.adjUs) {
                        golden = true;
                        if (v == u.parentThey) golden = false;
                        if (u == v.parentThey) golden = false;
                        if (u.parentThey != null && v == u.parentThey.parentThey) golden = false;
                        if (v.parentThey != null && u == v.parentThey.parentThey) golden = false;
                        if (u.parentThey != null && u.parentThey == v.parentThey) golden = false;
                        if (golden) break;
                    }
                    if (golden) {
                        out.println(-1);
                        return;
                    } else {
                        res = Math.max(res, 2 * v.whenThey);
                    }
                }
            out.println(res);
        }

        static class Vertex {
            int whenThey = -1;
            int whenUs = -1;
            List<TaskE.Vertex> adjUs = new ArrayList<>(1);
            List<TaskE.Vertex> adjThey = new ArrayList<>(1);
            TaskE.Vertex parentThey;

            public void fillWhenThey(int val) {
                whenThey = val;
                for (TaskE.Vertex v : adjThey)
                    if (v.whenThey < 0) v.fillWhenThey(val + 1);
                    else parentThey = v;
            }

            public void fillWhenUs(int val) {
                if (val >= whenThey) return;
                whenUs = val;
                for (TaskE.Vertex v : adjUs) if (v.whenUs < 0) v.fillWhenUs(val + 1);
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

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


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

public class MainB {
	static final Reader in = new Reader();

	public static void main(String[] args) {
		int n=in.nextInt();
		long x=in.nextInt(), ans=Long.MAX_VALUE;
		long[] ps = new long[n+1];
		for(int i=0; i<n; ++i)
			ps[i+1]=ps[i]+in.nextInt();
		for(int i=1; i<=n; ++i) {
			long ca=2*(ps[n]-ps[n-i])+i*x;
			for(int j=0; n-i*j>0; ++j) {
				long b=(2*j+3)*(ps[n-i*j]-ps[Math.max(n-i*(j+1), 0)]);
				if(Long.MAX_VALUE-b<ca) {
					ca=Long.MAX_VALUE;
					break;
				}
				ca+=b;
			}
			ans=Math.min(ca, ans);
		}
		System.out.println(ans+n*x);
	}

	static class Reader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		String next() {
			while(st==null||!st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

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


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

public class Main {
	static final Reader in = new Reader();

	public static void main(String[] args) {
		int n=in.nextInt();
		long x=in.nextInt(), ans=LLONG_MAX;
		long[] a = new long[n], ps = new long[n+1];
		for(int i=0; i<n; ++i) {
			a[i]=in.nextInt();
			ps[i+1]=ps[i]+a[i];
		}
		for(int i=1; i<=n; ++i) {
			long ca=2*(ps[n]-ps[n-i])+i*x;
			for(int j=0; n-i*j>0; ++j) {
				long b=(2*j+3)*(ps[n-i*j]-ps[Math.max(n-i*(j+1), 0)]);
				if(LLONG_MAX-b<ca) {
					ca=LLONG_MAX;
					break;
				}
			}
			ans=Math.min(ca, ans);
		}
		System.out.println(ans+n*x);
	}

	static class Reader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		String next() {
			while(st==null||!st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

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


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

public class MainA {
	static final StdIn in = new StdIn();
	static final PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		int n=in.nextInt(), a=in.nextInt(), b=in.nextInt();
		out.println(a%2==b%2?"Alice":"Borys");
		out.close();
	}

	interface Input {
		public String next();
		public String nextLine();
		public int nextInt();
		public long nextLong();
		public double nextDouble();
	}
	static class StdIn implements Input {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;
		public StdIn() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}
		public StdIn(InputStream in) {
			try{
				din = new DataInputStream(in);
			} catch(Exception e) {
				throw new RuntimeException();
			}
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}
		public String next() {
			int c;
			while((c=read())!=-1&&(c==' '||c=='\n'||c=='\r'));
			StringBuilder s = new StringBuilder();
			while (c != -1)
			{
				if (c == ' ' || c == '\n'||c=='\r')
					break;
				s.append((char)c);
				c=read();
			}
			return s.toString();
		}
		public String nextLine() {
			int c;
			while((c=read())!=-1&&(c==' '||c=='\n'||c=='\r'));
			StringBuilder s = new StringBuilder();
			while (c != -1)
			{
				if (c == '\n'||c=='\r')
					break;
				s.append((char)c);
				c = read();
			}
			return s.toString();
		}
		public int nextInt() {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do
				ret = ret * 10 + c - '0';
			while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}
		public int[] readIntArray(int n) {
			int[] ar = new int[n];
			for(int i=0; i<n; ++i)
				ar[i]=nextInt();
			return ar;
		}
		public long nextLong() {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do
				ret = ret * 10 + c - '0';
			while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}
		public long[] readLongArray(int n) {
			long[] ar = new long[n];
			for(int i=0; i<n; ++i)
				ar[i]=nextLong();
			return ar;
		}
		public double nextDouble() {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do
				ret = ret * 10 + c - '0';
			while ((c = read()) >= '0' && c <= '9');
			if (c == '.')
				while ((c = read()) >= '0' && c <= '9')
					ret += (c - '0') / (div *= 10);
			if (neg)
				return -ret;
			return ret;
		}
		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}
		private byte read() {
			try{
				if (bufferPointer == bytesRead)
					fillBuffer();
				return buffer[bufferPointer++];
			} catch(IOException e) {
				throw new RuntimeException();
			}
		}
		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}
}

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


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

public class Main {
	static final StdIn in = new StdIn();
	static final PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		int q=in.nextInt();
		while(q-->0) {
			int a=in.nextInt(), b=in.nextInt(), c=in.nextInt()-1, d=in.nextInt(), e=a>=b?(a-1)/(b+1)+1:(b-1)/(a+1)+1;
			int fl=0, fr=a, f=fl;
			while(fl<=fr) {
				int fm=(fl+fr), al=a-fm, bl=b-(fm-1)/e;
				if((bl-1)/e<=al) {
					f=fm;
					fl=fm+1;
				} else
					fr=fm-1;
			}
			f+=(f-1)/e;
			for(int i=c; i<Math.min(d, f); ++i)
				out.print(i%(e+1)<e?'A':'B');
			for(int i=Math.max(c, f); i<d; ++i)
				out.print((a+b-i)%(e+1)==0?'A':'B');
			out.println();
		}
		out.close();
	}

	interface Input {
		public String next();
		public String nextLine();
		public int nextInt();
		public long nextLong();
		public double nextDouble();
	}
	static class StdIn implements Input {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;
		public StdIn() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}
		public StdIn(InputStream in) {
			try{
				din = new DataInputStream(in);
			} catch(Exception e) {
				throw new RuntimeException();
			}
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}
		public String next() {
			int c;
			while((c=read())!=-1&&(c==' '||c=='\n'||c=='\r'));
			StringBuilder s = new StringBuilder();
			while (c != -1)
			{
				if (c == ' ' || c == '\n'||c=='\r')
					break;
				s.append((char)c);
				c=read();
			}
			return s.toString();
		}
		public String nextLine() {
			int c;
			while((c=read())!=-1&&(c==' '||c=='\n'||c=='\r'));
			StringBuilder s = new StringBuilder();
			while (c != -1)
			{
				if (c == '\n'||c=='\r')
					break;
				s.append((char)c);
				c = read();
			}
			return s.toString();
		}
		public int nextInt() {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do
				ret = ret * 10 + c - '0';
			while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}
		public int[] readIntArray(int n) {
			int[] ar = new int[n];
			for(int i=0; i<n; ++i)
				ar[i]=nextInt();
			return ar;
		}
		public long nextLong() {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do
				ret = ret * 10 + c - '0';
			while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}
		public long[] readLongArray(int n) {
			long[] ar = new long[n];
			for(int i=0; i<n; ++i)
				ar[i]=nextLong();
			return ar;
		}
		public double nextDouble() {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do
				ret = ret * 10 + c - '0';
			while ((c = read()) >= '0' && c <= '9');
			if (c == '.')
				while ((c = read()) >= '0' && c <= '9')
					ret += (c - '0') / (div *= 10);
			if (neg)
				return -ret;
			return ret;
		}
		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}
		private byte read() {
			try{
				if (bufferPointer == bytesRead)
					fillBuffer();
				return buffer[bufferPointer++];
			} catch(IOException e) {
				throw new RuntimeException();
			}
		}
		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}
}

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