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

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

			String S = scan.next();
			char[]s = S.toCharArray();
			int K = scan.nextInt();

			ArrayList<Character>chara = new ArrayList<Character>();
			ArrayList<Integer>inte = new ArrayList<Integer>();

			Runlength(S,chara,inte);

/*
			for(Character c:chara) {
				System.out.println(c);
			}

			for(Integer i:inte) {
				System.out.println(i);
			}
			*/

			if(chara.size()==1) {
				System.out.println(K*(long)(inte.get(0)/2));
			}else{
				char f = chara.get(0);
				char l = chara.get(chara.size()-1);
				long goukei = 0;
				if(f==l) {
					long F = (long)(inte.get(0)/2);
					long L = (long)(inte.get(inte.size()-1)/2);
					goukei+=F;
					goukei+=L;
					goukei+=(K-1)*(long)((inte.get(0)+inte.get(inte.size()-1))/2);
					long p = 0;
					for(int i = 1;i<inte.size()-1;i++) {
						p+=(long)(inte.get(i)/2);
					}

					p+=(K-1)*p;
					goukei+=p;

					System.out.println(goukei);

				}else {

					for(Integer i:inte) {
						goukei+=(long)(i/2);
					}

					goukei+=(K-1)*goukei;
					System.out.print(goukei);

				}

			}

		}

	}

	//ランレングス圧縮
	//必ず２個配列用意するように。

	private static void Runlength(String S,ArrayList<Character> chara,ArrayList<Integer>inte) {

		char[]s = S.toCharArray();

		char mem = s[0];
		int count = 1;
		for(int i = 1;i<s.length;i++) {
			if(s[i]==mem) {
				count++;
				if(i==s.length-1) {
					chara.add(s[i-1]);
					inte.add(count);
				}
			}else if(s[i]!=mem) {
				chara.add(s[i-1]);
				inte.add(count);
				mem=s[i];
				count = 1;
				if(i==s.length-1) {
					chara.add(s[i-1]);
					inte.add(count);
				}
			}

		}

	}

}

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


Question:
import java.util.Scanner;

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

			int N = scan.nextInt();

			int []M =new int[N];
			long goukei = 0;
			M[0] = 1;
			goukei+=M[0];
			for(int i = 1;i<N;i++) {
				M[i] = (i+1)%i;
				goukei+=M[i];
				System.out.println(M[i]);
			}

			System.out.println(N*(N-1)/2);

		}
	}
}

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


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

public class Main{
    static long MOD = 998244353L;
    static long [] fac;

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
            int n = sc.nextInt();
            int cur = 0;
            boolean valid = true;
            int [][] a = new int[n][3];
            for(int i = 0; i < n; i++)
            {
                String s = sc.nextLine();
                int res = 0, min = 0;
                for(char c : s.toCharArray())
                {
                    if(c == '(') res++;
                    else res--;
                    min = Math.min(min, res);

                }
                a[i][0] = min;
                a[i][1] = res;
                a[i][2] = min - res;
            }
            Arrays.sort(a, (m1, m2) -> m1[1] * m2[1] < 0 ? m2[1] - m1[1] : (m1[1] + m2[1] > 0 ? m2[0] - m1[0] : m2[2] - m1[2]));
            for(int [] m : a)
            {
                if(cur + m[0] < 0) valid = false;
                else cur += m[1];
            }
            if(cur != 0) valid = false;
            out.println(valid ? "Yes" : "No");
        }
        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long x, long[] res){
        int n = res.length;
        long a = x / n;
        int b = (int)(x % n);
        return res[n - 1] * a + res[b];
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

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


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

public class Main{
    static long MOD = 998244353L;
    static long [] fac;

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
            int n = sc.nextInt();
            int cur = 0;
            boolean valid = true;
            int [][] a = new int[n][3];
            for(int i = 0; i < n; i++)
            {
                String s = sc.nextLine();
                int res = 0, min = 0;
                for(char c : s.toCharArray())
                {
                    if(c == '(') res++;
                    else res--;
                    min = Math.min(min, res);

                }
                a[i][0] = min;
                a[i][1] = res;
                a[2][2] = min - res;
            }
            Arrays.sort(a, (m1, m2) -> m1[1] * m2[1] < 0 ? m2[1] - m1[1] : m1[1] + m2[1] > 0 ? m2[0] - m1[0] : m2[2] - m1[2]);
            for(int [] m : a)
            {
                if(cur + m[0] < 0) valid = false;
                else cur += m[1];
            }
            if(cur != 0) valid = false;
            out.println(valid ? "Yes" : "No");
        }

        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long x, long[] res){
        int n = res.length;
        long a = x / n;
        int b = (int)(x % n);
        return res[n - 1] * a + res[b];
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

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


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

public class Main{
    static long MOD = 998244353l;
    static long [] fac;

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
            int n = sc.nextInt();
            int cur = 0;
            boolean valid = true;
            int [][] a = new int[n][3];
            for(int i = 0; i < n; i++)
            {
                String s = sc.nextLine();
                int res = 0, min = 0;
                for(char c : s.toCharArray())
                {
                    if(c == '(') res++;
                    else res--;
                    min = Math.min(min, res);

                }
                a[i][0] = min;
                a[i][1] = res;
                a[2][2] = min - res;
            }
            Arrays.sort(a, (m1, m2) -> m1[1] * m2[1] < 0 ? m2[1] - m1[1] : m1[1] + m2[1] > 0 ? m2[0] - m1[0] : m1[2] - m2[2]);
            for(int [] m : a)
            {
                if(cur + m[0] < 0) valid = false;
                else cur += m[1];
            }
            if(cur != 0) valid = false;
            out.println(valid ? "Yes" : "No");
        }

        out.close();
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

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


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

public class Main{
    static long MOD = 998244353 ;
    static long [] fac;

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
            int n = sc.nextInt();
            int cur = 0;
            boolean valid = true;
            int [][] min = new int[n][2];
            for(int i = 0; i < n; i++)
            {
                String s = sc.nextLine();
                int cnt = 0, cMin = 0;
                for(char c : s.toCharArray())
                {
                    if(c == '(') cnt++;
                    else cnt--;
                    cMin = Math.min(cMin, cnt);
                }
                min[i][0] = cMin;
                min[i][1]= cnt;
            }
            Arrays.sort(min, (m1, m2) -> m1[1] * m2[1] < 0 ? m2[1] - m1[1] : m1[1] + m2[1] > 0 ? m2[0] - m1[0] : (m2[1] - m2[0]) - (m1[1] - m1[0]));
            for(int [] m : min)
            {
                if(cur + m[0] < 0){
                    valid = false;
                    break;
                }
                cur += m[1];
            }
            if(cur != 0) valid = false;
            out.println(valid ? "Yes" : "No");
        }

        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long x, long[] res){
        int n = res.length;
        long a = x / n;
        int b = (int)(x % n);
        return res[n - 1] * a + res[b];
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

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


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

public class Main{
    static long MOD = 998244353 ;
    static long [] fac;

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
            int n = sc.nextInt();
            int cur = 0;
            boolean valid = true;
            int [][] min = new int[n][2];
            for(int i = 0; i < n; i++)
            {
                String s = sc.nextLine();
                int cnt = 0, cMin = 100000000;
                for(char c : s.toCharArray())
                {
                    if(c == '(') cnt++;
                    else cnt--;
                    cMin = Math.min(cMin, cnt);
                }
                min[i][0] = cMin;
                min[i][1]= cnt;
            }
            Arrays.sort(min, (m1, m2) -> m1[1] * m2[1] < 0 ? m2[1] - m1[1] : m1[1] + m2[1] > 0 ? m2[0] - m1[0] : (m2[1] - m2[0]) - (m1[1] - m1[0]));
            for(int [] m : min)
            {
                if(cur + m[0] < 0){
                    valid = false;
                    break;
                }
                cur += m[1];
            }
            if(cur != 0) valid = false;
            out.println(valid ? "Yes" : "No");
        }

        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long x, long[] res){
        int n = res.length;
        long a = x / n;
        int b = (int)(x % n);
        return res[n - 1] * a + res[b];
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

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


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

public class Main{
    static long MOD = 998244353 ;
    static long [] fac;

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
            int n = sc.nextInt();
            int cur = 0;
            boolean valid = true;
            int [][] min = new int[n][2];
            for(int i = 0; i < n; i++)
            {
                String s = sc.nextLine();
                int cnt = 0, cMin = 100000000;
                for(char c : s.toCharArray())
                {
                    if(c == '(') cnt++;
                    else cnt--;
                    cMin = Math.min(cMin, cnt);
                }
                min[i][0] = cMin;
                min[i][1]= cnt;
            }
            Arrays.sort(min, (m1, m2) -> m1[1] * m2[1] >= 0 ? m1[1] + m2[1] > 0 ? m2[0] - m1[0] : m1[0] - m2[0] : m2[1] - m1[1]);
            for(int [] m : min)
            {
                if(cur + m[0] < 0){
                    valid = false;
                    break;
                }
                cur += m[1];
            }
            if(cur != 0) valid = false;
            out.println(valid ? "Yes" : "No");
        }

        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long x, long[] res){
        int n = res.length;
        long a = x / n;
        int b = (int)(x % n);
        return res[n - 1] * a + res[b];
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

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


Question:
import java.util.*;

public class Main {

    static <T extends Comparable<? super T>> boolean nextPermutation(T[] sequence) {
        int first = getFirst(sequence);
        if (first == -1) return false;
        int toSwap = sequence.length - 1;
        while (sequence[first].compareTo(sequence[toSwap]) >= 0) --toSwap;
        swap(sequence, first++, toSwap);
        toSwap = sequence.length - 1;
        while (first < toSwap) swap(sequence, first++, toSwap--);
        return true;
    }

    static <T extends Comparable<? super T>> int getFirst(T[] sequence) {
        for (int i = sequence.length - 2; i >= 0; --i)
            if (sequence[i].compareTo(sequence[i + 1]) < 0) return i;
        return -1;
    }

    static <T extends Comparable<? super T>> void swap(T[] sequence, int i, int j) {
        T tmp = sequence[i];
        sequence[i] = sequence[j];
        sequence[j] = tmp;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] matrix = new int[N][M];
        for (int i = 0; i < N; ++i) Arrays.fill(matrix[i], 0);
        for (int i = 0; i < M; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            matrix[a][b] = 1;
            matrix[b][a] = 1;
        }

        Integer[] arr = new Integer[N];
        for (int i = 0; i < N; ++i) arr[i] = i;

        int cnt = 0;
        do {
            if (arr[0] != 0) break;
            boolean flag = true;
            for (int i = 0; i < N-1; ++i) {
                if (matrix[arr[i]][arr[i+1]] == 0) flag = false;
            }
            if (flag) ++cnt;
        } while (nextPermutation(arr));

        System.out.println(cnt);
    }
}

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


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

public class Main {

    static <T extends Comparable<? super T>> boolean nextPermutation(T[] sequence) {
        int first = getFirst(sequence);
        if (first == -1) return false;
        int toSwap = sequence.length - 1;
        while (sequence[first].compareTo(sequence[toSwap]) >= 0) --toSwap;
        swap(sequence, first++, toSwap);
        toSwap = sequence.length - 1;
        while (first < toSwap) swap(sequence, first++, toSwap--);
        return true;
    }

    static <T extends Comparable<? super T>> int getFirst(T[] sequence) {
        for (int i = sequence.length - 2; i >= 0; --i)
            if (sequence[i].compareTo(sequence[i + 1]) < 0) return i;
        return -1;
    }

    static <T extends Comparable<? super T>> void swap(T[] sequence, int i, int j) {
        T tmp = sequence[i];
        sequence[i] = sequence[j];
        sequence[j] = tmp;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
        int M = fs.nextInt();
        int[][] matrix = new int[N][M];
        for (int i = 0; i < N; ++i) Arrays.fill(matrix[i], 0);
        for (int i = 0; i < M; ++i) {
            int a = fs.nextInt() - 1;
            int b = fs.nextInt() - 1;
            matrix[a][b] = 1;
            matrix[b][a] = 1;
        }

        Integer[] arr = new Integer[N];
        for (int i = 0; i < N; ++i) arr[i] = i;
        int cnt = 0;
        do {
            if (arr[0] != 0) break;

            boolean flag = true;
            for (int i = 0; i < N-1; ++i) {
                if (matrix[arr[i]][arr[i+1]] == 0) flag = false;
            }

            if (flag) ++cnt;
        } while (nextPermutation(arr));

        System.out.println(cnt);
    }

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

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

        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

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

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

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

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

}

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


Question:
import java.util.Scanner;

public class ABC169_F {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int s = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();

        }

        int mod = 998244353;
        long[][] dp = new long[3003][3003];
        dp[0][0] = 1;
        for (int i = 0 ; i < n ; i++) {
            for (int j = 0 ; j <= s ; j++) {
              dp[i + 1][j] += (dp[i][j] * 2);
              dp[i + 1][j] %= mod;
              if (j >= a[i]) {
                  dp[i + 1][j] += dp[i][j-a[i]] % mod;
              }
            }
        }

        System.out.println(dp[n][s] % mod);
    }

}

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


Question:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[][] a = new String[h][w];
        for (int i = 0; i < h; i++) {
            String s = sc.next();
            for (int j = 0; j < w; j++) {
                a[i][j] = s.substring(j, j + 1);
            }
        }
        boolean[][] b = new boolean[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                b[i][j] = false;
            }
        }
        //横一列が.であるときにtrueを入れる。
        for (int i = 0; i < h; i++) {
            boolean isBlackContained = false;
            for (int j = 0; j < w; j++) {
                if (a[i][j].equals("#")) {
                    isBlackContained = true;
                }
            }
            if (!isBlackContained) {
                for (int j = 0; j < w; j++) {
                    b[i][j] = true;
                }
            }
        }

        //縦一列が.であるときにtrueを入れる。
        for (int i = 0; i < w; i++) {
            boolean isBlackContained = false;
            for (int j = 0; j < h; j++) {
                if (a[j][i].equals("#")) {
                    isBlackContained = true;
                }
            }
            if (!isBlackContained) {
                for (int j = 0; j < w; j++) {
                    b[j][i] = true;
                }
            }
        }

        for (int i = 0; i < h; i++) {
            int cnt = 0;
            for (int j = 0; j < w; j++) {
                if (!b[i][j]) {
                    System.out.print(a[i][j]);
                    cnt++;
                }
            }
            if (cnt > 0) {
                System.out.println("");
            }

        }
    }

}

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


Question:
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int k = sc.nextInt();
            int a = sc.nextInt();
            int b = sc.nextInt();
            for(; a <= b+1; a++){
              if(a % k == 0){
                System.out.println("OK");
                break;
              } else if(a == b){
                System.out.println("NG");
                break;
              }
            }

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


Question:
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            long N = sc.nextLong();
            long sum = 0;
            for(long i = 1; i <= N;i++){
              if(i % 3 != 0 || i % 5 !=0 || i % 15 != 0){
                sum += i;
              }
            }
            System.out.prinlnt(sum);
          }
}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    	int vertical = sc.next();
    	int side = sc.next();
    	System.out.println((vertical - 1) * (side - 1));
  }
}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System in);
    	int vertical = sc.next();
    	int side = sc.next();
    	System.out.println((vertical - 1) * (side - 1));
  }
}

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


Question:
import java.util.Scanner;
class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int c=sc.nextInt();
int b[] = new int[m];
for(int i=0; i<m; i++){
b[i]=sc.nextInt();
}
int a[][]=new int[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
a[n][m]=sc.nextInt();
}}
int sum =0;
int total=0;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
sum=sum+a[n][m]*b[m];
}
if (sum+c>0)
total++;
sum=0;
}
System.out.println(total);
}}

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


Question:
import java.util.Scanner;
class Main {
public static void main(String[] args){
int sc = new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int c=sc.nextInt();
int b[] = new int[m];
for(int i=0; i<m; i++){
b[i]=sc.nextInt();
}
int a[][]=new int[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
a[n][m]=sc.nextInt();
}}
int sum =0;
int total=0;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
sum=sum+a[n][m]*b[m];
}
if (sum+c>0)
total++;
sum=0;
}
System.out.println(total);
}}

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


Question:
import java.util.Scanner;
class Main {
public static void main(String[] args){
int sc = new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int c=sc.nextInt();
int b[] = new int[m];
for(int i=0; i<m; i++){
b[i]=sc.nextInt();
}
int a[][]=new int[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
a[n][m]=sc.nextInt();
}}
int sum =0;
int total=0;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
sum=sum+a[n][m]*b[m];
}
if (sum+c>0)
total++;
sum=0;
}}
System.out.println(total);
}}

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


Question:
import java.util.*;
class abc149_c{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int x=scan.nextInt();
    int y=x;
    if(x==2){
      System.out.println(x);
    }else {
      while(true){
        boolean ok=true;
        for(int i=2;i<y;i++){
          if(y%i==0){
            ok=false;
            break;
          }
        }
        if(ok){
          break;
        }
        y++;
      }
      System.out.println(y);
    }
  }
}

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


Question:
import java.util.*;
class Shiritori{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    scan.nextLine();
    String[] W=new String[N];
    for(int i=0;i<N;i++){
      W[i]=scan.nextLine();
    }

    for(int i=0;i<N-1;i++){
      for(int j=i+1;j<N;j++){
        if(W[i].equals(W[j])){
          System.out.println("No");
          System.exit(0);
        }
      }
    }
      for(int i=0;i<N-1;i++){
        int j=i+1;
        String A=W[i].substring(W[i].length()-1);
        String B=W[j].substring(0,1);
        if(!A.equals(B)){
          System.out.println("No");
          System.exit(0);
        }
      }
      System.out.println("Yes");
    }
  }

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


Question:
#incimport java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    scan.nextLine();
    String[] W=new String[N];
    for(int i=0;i<N;i++){
      W[i]=scan.nextLine();
    }

    for(int i=0;i<N-1;i++){
      for(int j=i+1;j<N;j++){
        if(W[i].equals(W[j])){
          System.out.println("No");
          System.exit(0);
        }
      }
    }
      for(int i=0;i<N-1;i++){
        int j=i+1;
        String A=W[i].substring(W[i].length()-1);
        String B=W[j].substring(0,1);
        if(!A.equals(B)){
          System.out.println("No");
          System.exit(0);
        }
      }
      System.out.println("Yes");
    }
  }

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


Question:
#incimport java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    scan.nextLine();
    String[] W=new String[N];
    for(int i=0;i<N;i++){
      W[i]=scan.nextLine();
    }

    for(int i=0;i<N-1;i++){
      for(int j=i+1;j<N;j++){
        if(W[i].equals(W[j])){
          System.out.println("No");
          System.exit(0);
        }
      }
    }
      for(int i=0;i<N-1;i++){
        int j=i+1;
        String A=W[i].substring(W[i].length()-1);
        String B=W[j].substring(0,1);
        String B_end=W[j].substring(W[j].length()-1);
        if(!A.equals(B)){
          System.out.println("No");
          System.exit(0);
        }
      }
      System.out.println("Yes");
    }
  }

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


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int MOD = 998244353;
		int N = sc.nextInt();
		int S = sc.nextInt();
		int[] A = new int[N];
		Arrays.setAll(A, i -> sc.nextInt());
		long ans = 0;
		long[] t = new long[N+1];
		t[0] = 1;
		for(int i = 1; i <= N; i++)
			t[i] = t[i-1] * 2 % MOD;
		Map<Integer, List<Integer>> m = new HashMap<>();
		m.put(0, new ArrayList<>());
		m.get(0).add(0);
		for(int i = 0; i < N; i++) {
			for(int j = i; j >= 0; j--) {
				if(!m.containsKey(j+1))
					m.put(j+1, new ArrayList<>());
				for(int k : m.get(j))
					if(k + A[i] <= S)
						m.get(j+1).add(k + A[i]);
			}
		}
		for(int i = 1; i <= N; i++) {
			int c = 0;
			for(int j : m.get(i))
				if(j == S)
					c++;
			ans += c * t[N-i];
			ans %= MOD;
		}
		System.out.println(ans);
	}

}

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


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

	static int MOD = 1000000007;

	static long modpow(int N, int K) {
		return BigInteger.valueOf(N).modPow(BigInteger.valueOf(K), BigInteger.valueOf(MOD)).longValue();
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long ans = 0;
		long[] x = new long[K+1];
		for(long i = K; i >= 1; i--) {
			x[i] = modpow(K/i, N);
			for(int j = i * 2; j <= K; j += i)
				x[i] -= x[j];
			ans = (ans + x[i] * i) % MOD;
		}
		System.out.println(ans);
	}

}

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


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long M = sc.nextInt();
		int V = sc.nextInt();
		int P = sc.nextInt();
		List<Long> A = new ArrayList<>();
		for(int i = 0; i < N; i++)
			A.add(sc.nextLong());
		Collections.sort(A, Collections.reverseOrder());
		int ans = P;
		if(P >= V) {
			for(int i = P; i < N; i++) {
				if(A.get(i)+M < A.get(P-1))
					break;
				ans++;
			}
		}
		else {
			//P番目以降の累積和
			long[] sum = new long[N];
			for(int i = P-1; i < N; i++) {
				sum[i] = sum[i-1];
				sum[i] += A.get(i);
			}
			for(int i = P; i < N; i++) {
				if(A.get(i)+M < A.get(P-1))
					break;
				if((i-(P-1))*(A.get(i)+M)-sum[i-1] < M*(V-(P-1+N-i)))
					break;
				ans++;
			}
		}
		System.out.println(ans);

	}

}

Choices:
- Memory Limit Exceeded
- Runtime Error
- No abnormally found
- Time 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();
		long M = sc.nextInt();
		int V = sc.nextInt();
		int P = sc.nextInt();
		List<Long> A = new ArrayList<>();
		for(int i = 0; i < N; i++)
			A.add(sc.nextLong());
		Collections.sort(A, Collections.reverseOrder());
		int ans = P;
		if(P >= V) {
			for(int i = P; i < N; i++) {
				if(A.get(i)+M < A.get(P-1))
					break;
				ans++;
			}
		}
		else {
			//P番目以降の累積和
			long[] sum = new long[N];
			for(int i = P-1; i < N; i++) {
				sum[i] = sum[i-1];
				sum[i] += A.get(i);
			}
			for(int i = P; i < N; i++) {
				if((long)(i-(P-1))*(A.get(i)+M)-sum[i-1] < M*(V-(P-1+N-i)))
					break;
				ans++;
			}
		}
		System.out.println(ans);

	}

}

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


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long M = sc.nextInt();
		int V = sc.nextInt();
		int P = sc.nextInt();
		List<Long> A = new ArrayList<>();
		for(int i = 0; i < N; i++)
			A.add(sc.nextLong());
		Collections.sort(A, Collections.reverseOrder());
		int ans = P;
		if(P >= V) {
			for(int i = P; i < N; i++) {
				if(A.get(i)+M < A.get(P-1))
					break;
				ans++;
			}
		}
		else {
			//P番目以降の累積和
			long[] sum = new long[N];
			for(int i = P-1; i < N; i++) {
				sum[i] = sum[i-1];
				sum[i] += A.get(i);
			}
			for(int i = P; i < N; i++) {
				if((i-(P-1))*(A.get(i)+M)-sum[i-1] < M*(V-(P-1+N-i)))
					break;
				ans++;
			}
		}
		System.out.println(ans);

	}

}

Choices:
- Runtime Error
- Compile Error
- No abnormally found
- 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();
		int M = sc.nextInt();
		int V = sc.nextInt();
		int P = sc.nextInt();
		List<Long> A = new ArrayList<>();
		for(int i = 0; i < N; i++)
			A.add(sc.nextLong());
		Collections.sort(A, Collections.reverseOrder());
		int ans = P;
		if(P >= V) {
			for(int i = P; i < N; i++) {
				if(A.get(i)+M < A.get(P-1))
					break;
				ans++;
			}
		}
		else {
			//P番目以降の累積和
			long[] sum = new long[N];
			for(int i = P-1; i < N; i++) {
				sum[i] = sum[i-1];
				sum[i] += A.get(i);
			}
			for(int i = P; i < N; i++) {
				if((i-(P-1))*(A.get(i)+M)-sum[i-1] < M*(V-(P-1+N-i)))
					break;
				ans++;
			}
		}
		System.out.println(ans);

	}

}

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


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] S = new int[N];
		int[] T = new int[N];
		for(int i = 0; i < N; i++)
			S[i] = sc.nextInt();
		for(int i = 0; i < M; i++)
			T[i] = sc.nextInt();
		int mod = 1_000_000_007;
		long[][] dp = new long[N+1][M+1];
		for(int i = 1; i <= N; i++) {
			for(int j = 1;  j <= M; j++) {
				dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
				if(S[i-1] == T[j-1])
					dp[i][j] += dp[i-1][j-1] + 1;
				dp[i][j] %= mod;
			}
		}
		System.out.println(dp[N][M] + 1);
	}

}

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


Question:
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	private static final byte WHITE = 1;
	private static final byte BLACK = 2;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int q = sc.nextInt();

		int[] minx = new int[n];
		int[] miny = new int[n];

		for( int i=0 ; i<n ; i++ ) {
			minx[i] = n-2;
			miny[i] = n-2;
		}
		int minyy = n-2;
		int minxx = n-2;
		long blackCnt = ((long)n-2)*(n-2);

//		byte[][] grid = new byte[n][n];
//		for( int i=0 ; i<n ; i++ ) {
//			grid[i][n-1] = WHITE;
//			grid[n-1][i] = WHITE;
//		}
//		for( int i=1 ; i<n-1 ; i++ ) {
//			Arrays.fill(grid[i], 1, n-1, BLACK);
//		}

//		long whiteCnt = 0;
		for( int i=0 ; i<q ; i++ ) {
			int q1 = sc.nextInt();
			int q2 = sc.nextInt()-2;

			if( q1==1 ) {
				// vertical
				int m = minx[q2];
				if( q2 < minxx ) {
					for( int j=0 ; j<m ; j++ ) {
						miny[j]=Math.min(miny[j],q2);
					}
					minxx = q2;
				}
				minx[q2]=0;
				blackCnt -= m;
			}else {
				// horizontal
				int m = miny[q2];
				if( q2 < minyy ) {
					for( int j=0 ; j<m ; j++ ) {
						minx[j]=Math.min(minx[j],q2);
					}
					minyy = q2;
				}
				miny[q2]=0;
				blackCnt -= m;
			}

		}
		System.out.println(blackCnt);

	}

}

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


Question:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

import atCoder.template.f.Main.Pair;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();

		Pair LU = new Pair(0,0);
		Pair RU = new Pair(0,Integer.MAX_VALUE);
		Pair LD = new Pair(Integer.MAX_VALUE,0);
		Pair RD = new Pair(Integer.MAX_VALUE,Integer.MAX_VALUE);

		Pair LUN = RD;
		Pair RUN = LD;
		Pair LDN = RU;
		Pair RDN = LU;

		for( int i=0; i<n ; i++ ) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			Pair c = new Pair(x,y);

			if(	LU.dist(c) < LU.dist(LUN) ) {
				LUN = c;
			}
			if(	RU.dist(c) < RU.dist(RUN) ) {
				RUN = c;
			}
			if(	LD.dist(c) < LD.dist(LDN) ) {
				LDN = c;
			}
			if(	RD.dist(c) < RD.dist(RDN) ) {
				RDN = c;
			}
		}

		long ans = Integer.MIN_VALUE;
		ans = Math.max( ans, LUN.dist(RUN) );
		ans = Math.max( ans, LUN.dist(LDN) );
		ans = Math.max( ans, LUN.dist(RDN) );
		ans = Math.max( ans, RUN.dist(LDN) );
		ans = Math.max( ans, RUN.dist(RDN) );
		ans = Math.max( ans, LDN.dist(RDN) );

		System.out.println(ans);

	}

	public static class Pair implements Comparable<Pair>{
		int c = 0;
		int d = 0;

		public Pair(int c, int d) {
			super();
			this.c = c;
			this.d = d;
		}

		public long dist( Pair o) {
			return Math.abs((long)o.c-c)+Math.abs((long)o.d-d);
		};

		@Override
		public int compareTo(Pair o) {
			int dd = this.d - o.d;
			if( dd != 0 ) {
				return dd;
			}
			int cc = this.c - o.c;
			return cc;
		}

		@Override
		public String toString() {
			return "Pair [c=" + c + ", d=" + d + "]";
		}

	}
}

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


Question:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		int keta = 1;
		while (true){
			if (Math.pow(K, keta -1) <= N && (Math.pow(K, keta) -1) > N){
				System.out.println(keta);
				break;
			}
			keta ++;
		}

	}
}

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


Question:
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        s = s + s;
        s.contains(t)
        System.out.println(s.contains(t) ? "Yes" : "No");
    }
}

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


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

  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();

      long sum = 0;
      for(int i = 0; i < n; i++) {
        int min = arr[i];
        for(int j = i; j < n; j++) {
          min = Math.min(min, arr[j]);
          sum += min;
        }
      }
      System.out.println(sum);
  }
}

Choices:
- Internal error
- 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.Arrays;
import java.io.IOException;
import java.io.InputStream;

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

    static class EGetEverything {
        long INF = (long) 1e14 + 1;
        int MAXN = 1005;
        PrintWriter out;
        InputReader in;
        int n;
        int m;
        int[] masks = new int[MAXN];
        long[] cost = new long[MAXN];
        int MAX_MSK = (1 << 12);
        long[][] dp = new long[MAXN][MAX_MSK];

        long go(int ind, int mask) {
            if (ind == m) {
                if (mask == (1 << n) - 1)
                    return 0;
                else
                    return INF;
            }
            long mn = INF;
            mn = Math.min(go(ind + 1, mask), mn);
            mn = Math.min(go(ind + 1, mask | masks[ind]) + cost[ind], mn);
            dp[ind][mask] = mn;
            return mn;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            n = ni();
            m = ni();
            int i = 0;
            for (i = 0; i < m; i++) {
                cost[i] = nl();
                int x = ni();
                for (int j = 0; j < x; j++)
                    masks[i] |= (1 << (ni() - 1));
            }
            for (i = 0; i < MAXN; i++)
                Arrays.fill(dp[i], -1);
            long ans = go(0, 0);
            if (ans == INF)
                pn(-1);
            else
                pn(ans);
        }

        int ni() {
            return in.nextInt();
        }

        long nl() {
            return in.nextLong();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

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

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

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


Question:
import java.io.*;
import java.util.*;
public class gym{
	/*
	 * 0 0 0 0
	 * 0 0 0 0
	 * 0 0 0 0
	 * 0 0 0 0
	 */
	static void main() throws Exception{
		int n=sc.nextInt();
		int[]in=sc.intArr(n*n);
		int[][]curAns=new int[n+1][n+1];
		for(int ans=0;ans<n;ans++) {
			for(int i=1+ans;i<=n-ans;i++) {
				curAns[1+ans][i]=ans;
				curAns[i][1+ans]=ans;
				curAns[n-ans][i]=ans;
				curAns[i][n-ans]=ans;
			}
		}
		boolean[][]removed=new boolean[n+1][n+1];

		int ans=0;
		int[]dx= {1,0,-1,0},dy= {0,1,0,-1};
		for(int i:in) {
			int x=i-1;
			int curi=(x/n)+1,curj=(x%n)+1;
			LinkedList<int[]>q=new LinkedList<>();
//			System.out.println(i+" "+curi+" "+curj+" "+curAns[curi][curj]);
			removed[curi][curj]=true;
			ans+=curAns[curi][curj];
			q.add(new int[] {curi,curj});
			while(!q.isEmpty()) {
				int [] cur=q.poll();
				for(int k=0;k<4;k++) {
					int nxti=cur[0]+dx[k],nxtj=cur[1]+dy[k];
					if(nxti<=0 || nxtj<=0 || nxti>n || nxtj>n)continue;
					int newval=curAns[cur[0]][cur[1]]+(removed[cur[0]][cur[1]]?0:1);
					if(curAns[nxti][nxtj]<=newval)continue;
					curAns[nxti][nxtj]=newval;
					q.add(new int[] {nxti,nxtj});
				}
			}
		}
		pw.println(ans);
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
		while(tc-->0)main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

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


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

public class  zz{
    public static void main(String[] args) throws Exception{
        //MScanner sc = new MScanner("chess.in");
        MScanner sc = new MScanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        //int n=sc.nextInt();int[]in=new int[n];
        //for(int i=0;i<n;i++)in[i]=sc.nextInt();
        int w=sc.nextInt();
        int h=sc.nextInt();
        int x=sc.nextInt();
        int y=sc.nextInt();
        int ans1=Math.min(x*h,(w-x)*h);
        int ans2=Math.min(y*w,(h-y)*w);
        if(ans1==ans2) {
        	pw.println(ans1+" "+1);
        }
        else
        	pw.println(Math.max(ans2,ans1)+" "+0);
        pw.flush();
    }
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;

		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Choices:
- No abnormally found
- Compile Error
- 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 k = sc.nextInt();
    int r = sc.nextInt();
    int s = sc.nextInt();
    int p = sc.nextInt();
    long sum = 0;
    String way = "";
    String t = sc.next();

    for (int i = 0; i < k; i++) {
      char c = t.charAt(i);
      switch (c) {
      case 'r':
        sum += p;
        way += 'p';
        break;

      case 's':
        sum += r;
        way += 'r';
        break;

      case 'p':
        sum += s;
        way += 's';
        break;
      }
    }

    for (int i = k; i + k < n; i++) {
      char c = t.charAt(i);
      switch (c) {
      case 'r':
        if (way.charAt(i - k) == 'p') {
          way += getWay(t, i + k, 'p');
        } else {
          sum += p;
          way += 'p';
        }
        break;

      case 's':
        if (way.charAt(i - k) == 'r') {
          way += getWay(t, i + k, 'r');
        } else {
          sum += r;
          way += 'r';
        }
        break;

      case 'p':
        if (way.charAt(i - k) == 's') {
          way += getWay(t, i + k, 's');
        } else {
          sum += s;
          way += 's';
        }
        break;
      }
    }

    for (int i = n - k; i < n; i++) {
      char c = t.charAt(i);
      switch (c) {
      case 'r':
        if (way.charAt(i - k) != 'p') {
          sum += p;
        }
        break;

      case 's':
        if (way.charAt(i - k) != 'r') {
          sum += r;
        }
        break;

      case 'p':
        if (way.charAt(i - k) != 's') {
          sum += s;
        }
        break;
      }
    }

    System.out.println(sum);

  }

  public static char getWay(String t, int index, char ban) {
    char c = t.charAt(index);
    char ret = 0;
    switch (c) {
    case 'r':
      if (ban == 'r') {
        ret = 's';
      } else {
        ret = 'r';
      }
      break;
    case 's':
      if (ban == 's') {
        ret = 'p';
      } else {
        ret = 's';
      }
      break;
    case 'p':
      if (ban == 'p') {
        ret = 'r';
      } else {
        ret = 'p';
      }
      break;
    }

    return ret;
  }

}

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


Question:
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    if (b == (a + 1)) {
      System.out.println("Borys");
      return;
    }

    while (true) {
      if (++a == (b - 1)) {
        System.out.println("Alice");
        return;
      }
      if ((a + 1) == ++b) {
        System.out.println("Borys");
        return;
      }
    }

  }
}

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


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

public class B {
	public static void main(String[] args) throws IOException {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		int n = sc.nextInt();
		int[] array = new int[n];
		for(int i = 0; i < n; i++)
			array[i] = sc.nextInt();

		long sum = 0;
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				sum += array[i] * array[j];
			}
		}

		System.out.println(sum);
	}
}

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


Question:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0;
        for(int i = 1 ; i <= n ; i++){
            if((i % 3) != 0 && (i % 5) != 0){
                sum += i;
            }
        }
        System.out.println(sum));
    }
}

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


Question:
import java.util.*;

public static void Main(){
	Scanner sc = new Scanner(System.in);
  	int n = sc.nextInt();
  	long ans = 0;
  	for(int i = 1 ; i < n ; i++){
      ans += i;
    }
  	System.out.println(ans);
}

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


Question:
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    static int n;
    static List<Node> nodes;
    static int[] l;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        nodes = new ArrayList<>();
        for (int i = 0; i < n + 1; i++) {
            nodes.add(new Node(i));
        }
        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            nodes.get(a).next.add(nodes.get(b));
            nodes.get(b).next.add(nodes.get(a));
        }
        Deque<Integer> q = new ArrayDeque<>();
        List<Integer> lList = new ArrayList<>();
        for (int i = 0; i < nodes.get(1).next.size(); i++) {
            q.add(nodes.get(1).next.get(i).num);
            l = new int[n + 1];
            l[nodes.get(1).next.get(i).num] = 1;
            while (q.size() > 0) {
                int next = q.poll();
                for (Node node : nodes.get(next).next) {
                    if (l[node.num] != 0 || node.num== 1) continue;
                    l[node.num] = l[next] + 1;
                    q.add(node.num);
                }
            }
            lList.add(IntStream.of(l).max().getAsInt());
        }
        int size= 0;
        if(lList.size() == 1) {
            size= lList.get(0)+1;
        }
        else {
            lList.sort(Integer::compareTo);
            size = lList.get(lList.size()-1);
            size += lList.get(lList.size()-2)+1;
        }
        if((size + 1) % 3 == 0) {
            System.out.println("Second");
        }
        else {
            System.out.println("First");
        }
    }

    static class Node {
        public int num;
        public List<Node> next;

        public Node(int num) {
            this.num = num;
            next = new ArrayList<>();
        }
    }
}

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


Question:
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    static int n;
    static List<Node> nodes;
    static int[] l;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        nodes = new ArrayList<>();
        for (int i = 0; i < n + 1; i++) {
            nodes.add(new Node(i));
        }
        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            nodes.get(a).next.add(nodes.get(b));
            nodes.get(b).next.add(nodes.get(a));
        }
        Deque<Integer> q = new ArrayDeque<>();
        q.add(1);
        List<Integer> lList = new ArrayList<>();
        for (int i = 0; i < nodes.get(1).next.size(); i++) {
            l = new int[n + 1];
            while (q.size() > 0) {
                int next = q.poll();
                for (Node node : nodes.get(next).next) {
                    if (l[node.num] != 0) continue;
                    l[node.num] = l[next] + 1;
                    q.add(node.num);
                }
            }
            lList.add(IntStream.of(l).max().getAsInt());
        }
        int size= 0;
        if(lList.size() == 1) {
            size= lList.get(0)+1;
        }
        else {
            lList.sort(Integer::compareTo);
            size = lList.get(lList.size()-1) +11;
            size += lList.get(lList.size()-2)+1;
        }
        if((size + 1) % 3 == 0) {
            System.out.println("Second");
        }
        else {
            System.out.println("First");
        }
    }

    static class Node {
        public int num;
        public List<Node> next;

        public Node(int num) {
            this.num = num;
            next = new ArrayList<>();
        }
    }
}

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


Question:
import java.util.Scanner;
import java.util.concurrent.SynchronousQueue;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int M=stdIn.nextInt();
		int s[][]=new int[M][N];
		int k[]=new int[M];
		int p[]=new int[M];
		int ans=0;
		for(int i=0;i<M;i++){
			k[i]=stdIn.nextInt();
			for(int j=0;j<k[i];j++){
				s[i][j]=stdIn.nextInt();
			}
		}
		for(int i=0;i<M;i++){
			p[i]=stdIn.nextInt();
		}
		for(int i=0;i<Math.pow(2,N);i++){
			boolean key[]=new boolean[N];
			boolean bool=true;
			for(int j=0;j<N;j++){
				if((1&i>>j)==1)
					key[j]=true;
			}
			for(int j=0;j<M;j++){
				int cout=0;
				for(int l=0;l<k[j];l++){
					if(key[s[j][l]])
						cout++;
				}
				if(cout%2!=p[i]){
					bool=false;
					break;
				}
			}
			if(bool)
				ans++;
		}
		System.out.println(ans);
	}
}

Choices:
- Memory Limit Exceeded
- No abnormally found
- Compile Error
- Runtime 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 A[]=new int[N];
		int B[]=new int[N];
		int z=0,sum=0;
		while(z<N){
			A[z]=stdIn.nextInt();
			B[z]=stdIn.nextInt();
			z++;
		}z--;
		while(z>=0) {
			A[z]+=sum;
			while(true) {
				if(A[z]%B[z]==0)
					break;
				A[z]++;sum++;
			}
			z--;
		}
		System.out.println(sum);
	}
}

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


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

   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 c[] = new int[m];
    	int d[] = new int[m];
    	int dist=0;
    	int min[] = new int[2];
    	List<Integer> ans = new ArrayList<Integer>();
    	for(int i=0;i<n;i++) {
    		a[i]=sc.nextInt();
    		b[i]=sc.nextInt();
    	}
    	for(int i=0;i<m;i++) {
    		c[i]=sc.nextInt();
    		d[i]=sc.nextInt();
    	}
    	for(int i=0;i<n;i++) {
    		Arrays.fill(min, 1000000);
    		for(int j=0;j<m;j++) {
    			dist=Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j]);
    			if(dist<min[0]) {
    				min[0]=dist;
    				min[1]=j+1;
    			}
    		}
    		ans.add(min[1]);
    	}
    	for(int i=0;i<n;i++) {
    		System.out.println(ans.get(i));
    	}
    }
}

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


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

   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 c[] = new int[m];
    	int d[] = new int[m];
    	int dist=0;
    	int min[] = new int[2];
    	List<Integer> ans = new ArrayList<Integer>();
    	for(int i=0;i<n;i++) {
    		a[i]=sc.nextInt();
    		b[i]=sc.nextInt();
    	}
    	for(int i=0;i<m;i++) {
    		c[i]=sc.nextInt();
    		d[i]=sc.nextInt();
    	}
    	for(int i=0;i<n;i++) {
    		Arrays.fill(min, 10000000);
    		for(int j=0;j<m;j++) {
    			dist=Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j]);
    			if(dist<min[0]) {
    				min[0]=dist;
    				min[1]=j+1;
    			}
    		}
    		ans.add(min[1]);
    	}
    	for(int i=0;i<n;i++) {
    		System.out.println(ans.get(i));
    	}
    }
}

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


Question:
import java.util.*;
import java.util.Map.Entry;

 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        long[] a = new long[M];
        long[] b = new long[M];
        long[] m = new long[M];
        for (int i=0 ; i<M; i++) {
            a[i] = sc.nextLong();
            b[i] = sc.nextLong();
            for(int j=0;j<b[i];j++) {
            	m[i]=(long) (m[i]+Math.pow(2, sc.nextInt()-1));
            }
        }

        //2^12
        int[] dp=new int[(int) Math.pow(2, N)];
        for(int i=0;i<(int) Math.pow(2, N);i++)dp[i]=9999999;
        dp[0]=0;
        for(int i=1;i<Math.pow(2, N);i++) {
        	for(int j=0;j<M;j++) {
        		int tmp=0;
        		for(int k=0;k<=N;k++) {
        			if((i/(int)Math.pow(2,k))%2==1&&(m[j]/(int)Math.pow(2,k))%2==0) {
        				tmp=(int) (tmp+Math.pow(2, k));
        			}
        		}
        		if(tmp==i)continue;
        		dp[i]=(int) Math.min(dp[i], dp[tmp]+a[j]);
        	}
        }

        int ans=dp[(int) (Math.pow(2,N)-1)];
        if(ans==9999999) {
        	ans=-1;
        }
        System.out.println(ans);

    }

}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.function.UnaryOperator;
import java.util.stream.IntStream;

public class Main {
    private static final int[] xMove = {-1, 0, 1, 0};
    private static final int[] yMove = {0, -1, 0, 1};

    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();

        final boolean[][] isSitting = new boolean[n + 1][n + 1];
        for (final boolean[] array : isSitting) {
            Arrays.fill(array, true);
        }

        final UnaryOperator<Integer> bfs = point -> {
            final int[] distances = new int[n * n + 1];
            Arrays.fill(distances, Integer.MAX_VALUE);
            final int x = (point - 1) / n;
            final int y = (point - 1) % n + 1;

            isSitting[x][y] = false;
            distances[point] = 0;
            final PriorityQueue<Destination> queue = new PriorityQueue<>(Comparator.comparingInt(dest -> dest.cost));
            queue.add(new Destination(point, 0));

            while (!queue.isEmpty()) {
                final Destination current = queue.poll();
                final int currentX = (current.point - 1) / n;
                final int currentY = (current.point - 1) % n + 1;
                final int distance = distances[current.point];
                if (currentX == 0 || currentX == n - 1 || currentY == 1 || currentY == n) {
                    return distance;
                }

                if (current.cost > distance) {
                    continue;
                }

                distances[point] = current.cost;
                for (int i = 0; i < 4; i++) {
                    final int nextX = currentX + xMove[i];
                    final int nextY = currentY + yMove[i];
                    final int next = nextX * n + nextY;
                    final int nextCost = distances[point] + (isSitting[nextX][nextY] ? 1 : 0);
                    if (nextCost < distances[next]) {
                        queue.add(new Destination(next, nextCost));
                        distances[next] = nextCost;
                    }
                }
            }

            return -1;
        };

        final long count = IntStream.range(0, n * n)
            .map(i -> bfs.apply(scanner.nextInt()))
            .sum();

        System.out.println(count);
    }

    private static class Destination {
        final int point;
        final int cost;

        Destination(final int point, final int cost) {
            this.point = point;
            this.cost = cost;
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

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

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.function.BiFunction;

import static java.lang.Math.abs;

public class Main {
    private static final long MOD = 1_000_000_007;

    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final Map<Sardine, Integer> plusSardines = new HashMap<>();
        final Map<Sardine, Integer> minusSardines = new HashMap<>();
        final BiFunction<Sardine, Integer, Integer> counter = (k, v) -> v == null ? 1 : v + 1;
        long zeroCount = 0;

        for (int i = 0; i < n; i++) {
            final long a = scanner.nextLong();
            final long b = scanner.nextLong();

            if (a == 0 && b == 0) {
                zeroCount++;
                continue;
            }

            if (a == 0) {
                plusSardines.compute(new Sardine(0, 1), counter);
                continue;
            }

            if (b == 0) {
                minusSardines.compute(new Sardine(0, 1), counter);
                continue;
            }

            final long gcd = euclideanAlgorithm(abs(a), abs(b));
            if (a / abs(a) == b / abs(b)) {
                plusSardines.compute(new Sardine(abs(a) / gcd, abs(b) / gcd), counter);
            } else {
                minusSardines.compute(new Sardine(abs(b) / gcd, abs(a) / gcd), counter);
            }
        }

        final long[] exp = new long[100_001];
        long base = 1;
        for (int i = 0; i <= 100_000; i++) {
            exp[i] = base;
            base *= 2;
            base %= MOD;
        }

        long answer = 1;

        for (final Map.Entry<Sardine, Integer> entry : plusSardines.entrySet()) {
            if (minusSardines.containsKey(entry.getKey())) {
                answer *= exp[entry.getValue()] + exp[minusSardines.get(entry.getKey())] - 1;
            } else {
                answer *= exp[entry.getValue()];
            }
            answer %= MOD;
        }

        for (final Map.Entry<Sardine, Integer> entry : minusSardines.entrySet()) {
            if (plusSardines.containsKey(entry.getKey())) {
                continue;
            }

            answer *= exp[entry.getValue()];
            answer %= MOD;
        }

        answer = (answer - 1 + zeroCount + MOD) % MOD;
        System.out.println(answer);
    }

    private static long euclideanAlgorithm(final long a, final long b) {
        if (b > a) {
            return euclideanAlgorithm(b, a);
        }

        if (b == 0) {
            return a;
        }

        return euclideanAlgorithm(b, a % b);
    }

    private static class Sardine {
        final long a;
        final long b;

        Sardine(final long a, final long b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int hashCode() {
            return (int) (a + b);
        }

        @Override
        public boolean equals(final Object obj) {
            if (!(obj instanceof Sardine)) {
                return false;
            }
            final Sardine sardine = (Sardine) obj;
            return this.a == sardine.a && this.b == sardine.b;
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

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

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

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


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

public class Main {
    private static int[] locks;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final List<Key> keys = new ArrayList<>();
        locks = new int[n + 1];
        locks[0] = 1;
        for (int i = 0; i < m; i++) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();

            final Key key = new Key();
            key.price = a;
            for (int j = 0; j < b; j++) {
                final int lock = scanner.nextInt();
                key.locks.add(lock);
                locks[lock]++;
            }
            keys.add(key);
        }

        for (final int lock : locks) {
            if (lock == 0) {
                System.out.println(-1);
                return;
            }
        }

        keys.sort(Comparator.comparingInt(key -> key.price));

        System.out.println(recursive(keys.size() - 1, keys));
    }

    private static int recursive(final int index, final List<Key> keys) {
        if (index == -1) {
            return getPrice(keys);
        }

        final int a = recursive(index - 1, keys);

        final Key key = keys.get(index);
        for (final int lock : key.locks) {
            if (locks[lock] == 1) {
                return a;
            }
        }

        for (final int lock : key.locks) {
            locks[lock]--;
        }

        keys.remove(key);

        final int b = recursive(index - 1, keys);

        for (final int lock : key.locks) {
            locks[lock]++;
        }

        keys.add(index, key);

        return Math.min(a, b);
    }

    private static int getPrice(final List<Key> keys) {
        return keys.stream()
                .map(key -> key.price)
                .mapToInt(Integer::intValue)
                .sum();
    }

    static class Key {
        int price;
        List<Integer> locks = new ArrayList<>();
    }
}

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


Question:
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int h = scanner.nextInt();
        final int w = scanner.nextInt();
        scanner.nextLine();
        final HashSet<Integer> points = new HashSet<>();

        for (int i = 0; i < h; i++) {
            final String str = scanner.nextLine();
            for (int j = 0; j < w; j++) {
                if (str.charAt(j) == '#') {
                    points.add(10000 * i + j);
                }
            }
        }

        int counter = 0;
        while (points.size() != h * w) {
            final HashSet<Integer> points1 = new HashSet<>();
            for (final int point : points) {
                final int hh = point/10000;
                final int ww = point%10000;
                add(points1, hh - 1, ww, h, w);
                add(points1, hh + 1, ww, h, w);
                add(points1, hh, ww + 1, h, w);
                add(points1, hh, ww - 1, h, w);
            }
            points.addAll(points1);
            counter++;
        }

        System.out.println(counter);
    }

    private static void add(final Set<Integer> pointSet, final int h, final int w, final int hh, final int ww) {
        if (h >= 0 && h < hh && w >= 0 && w < ww) {
            pointSet.add(10000 * h + w);
        }
    }
}

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


Question:
package atCoder;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		exec();
	}

	private static void exec() {

		try(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();

			Map<String, Integer> score = new HashMap<>();

			score.put("r", P);
			score.put("s", R);
			score.put("p", S);

			String[] past = new String[K];

			Long ans = 0L;
			for(int i=0; i<N; i++) {
				String ene = String.valueOf(T.charAt(i));

				if(ene.equals(past[i%K])) {
					past[i%K] = null;
				} else {
					ans += score.get(ene);
					past[i%K] = ene;
				}
			}

			System.out.println(ans);
		}

	}
}

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


Question:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

     try (Scanner scan = new Scanner(System.in)) {
			int inputN = scan.nextInt();
			int inputQ = scan.nextInt();
			String inputStr = scan.next();

			List<Integer> ans = new ArrayList<>();

			for (int i = 0; i < inputQ; i++) {
				int inputI = scan.nextInt()-1;
				int inputR = scan.nextInt();
				int cnt = 0;
				String t=inputStr.substring(inputI,inputR);
				for(int n=0; n < t.length()-1; n++) {
					if('A'==(t.charAt(n)) && 'C'==(t.charAt(n+1))) {
						cnt++;
						n++;
					}
				}
				ans.add(cnt);
			}

			for (int i = 0; i < inputQ; i++) {
				System.out.println(ans.get(i));

			}
		}
    }
}

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


Question:
import java.util.*;
class Abc
{
    static int MOD = 1000000007;
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a == 5 || a == 7 || a == 3)
            System.out.println("YES");
            else System.out.println("NO");
    }
}

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


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

        int N = sc.nextInt();
        String[] s = new String[N];

        for(int i = 0; i < N; i++){
            s[i] = sc.next();
        }

        String ans = "Yes";
        for(int i = 0; i < N-1; i++){
            if(s[i].charAt(s[i].length() - 1) != s[i+1].charAt(0)){
                ans = "No";
                //System.out.println(s[i]);
                break;
            }
        }
        for(int i = 0; i < N - 1; i++)
        {
            for(int j = i+1; j < N; j++){
                boolean bl = true;
                int k = 0;
                while(bl == true && s[i].length() == s[j].length() && k < s[i].length()) {
                    if(s[i].charAt(k) != s[j].charAt(k)){
                        bl = false;
                    }
                    k++;
                }
                if(bl == true){
                    ans = "No";
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}

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


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

        int N = sc.nextInt();
        int K = sc.nextInt();

        long ans = 0;

        if( K > 2 * N){
            ans = 0;
        }
        else if (K > N){
            if(K % 2 == 0){
                ans = 1;
            }
            else{
                ans = 0;
            }
        }
        else if(K % 2 == 0){
            int KK = 2 * N/K;
            ans += (long) Math.pow((KK/2), 3) + (long) Math.pow( ( ( KK + 1 ) / 2 ), 3);
        }
        else if(K % 2 == 1){
            ans += (long) Math.pow( (N/K) , 3);
        }
        System.out.println(ans);
    }
}

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


Question:
import java.util.*;
class Main
{
    static int MOD = 1000000007;
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();

        int[] cntA = new int[n+1];
        int[] cntB = new int[n+1];
        int[] cntC = new int[n+1];
        int[] cntQ = new int[n+1];
        cntA[0] = cntB[0] = cntC[0] = cntQ[0] = 0;
        for(int i = 1; i < n+1; i++){
            char c = s.charAt(i-1);
            cntA[i] = cntA[i-1];
            cntB[i] = cntB[i-1];
            cntC[i] = cntC[i-1];
            cntQ[i] = cntQ[i-1];
            switch(c){
                case 'A':
                    cntA[i]++;
                    break;
                case 'B':
                    cntB[i]++;
                    break;
                case 'C':
                    cntC[i]++;
                    break;
                default:
                    cntQ[i]++;
                    break;

            }
        }
        long ans = 0;
        long left;
        long right;
        for(int i = 0; i < n; i++){
            left = right = 0;
            if(s.charAt(i) == 'B' || s.charAt(i) == '?'){
                left += cntA[i+1] * pow3(cntQ[i]) % MOD;
                left += cntQ[i] * pow3(cntQ[i] - 1) % MOD;
                left %= MOD;
                right += (cntC[n] - cntC[i+1]) * pow3(cntQ[n] - cntQ[i+1]) % MOD;
                right += (cntQ[n] - cntQ[i+1]) * pow3(cntQ[n] - cntQ[i+1] - 1) % MOD;
                right %= MOD;
                ans += left * right % MOD;
                ans %= MOD;
            }
        }
        System.out.println(ans);
    }
    static long pow3(int n){
        if(n < 0) return 0;
        if(n == 0) return 1;
        if(n % 2 == 0){
            long d = pow3(n / 2);
            return d * d　% MOD;
        }
        return 3 * pow3(n-1)　% MOD;
    }
}

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


Question:
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(system.in);
    String s = sc.next();
    String t = sc.next();
    boolean flag = false;
    for(int i = 0; i < s.length(); i++)
    {
      for(int j = 0; j < s.length(); j++)
      {
        if(s.charAt(i) != t.charAt((i+j) % s.length()))
        {
          break;
        }
        flag = true; break;
      }
    }
    if(flag) System.out.println("Yes");
    else System.out.pritnln("No");
  }
}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long k = sc.nextLong();
    long MOD = (long)Math.pow(10, 9) + 7;
    long[] dp = new long[(int)k + 1];
    for(long i = k; i >= 1; i--) {
      long t = k / i;
      long s = func(t, n);
      long u = 0;
      for(long j = (2 * i); j <= k; j += i) {
        u = (u + dp[j]) % MOD;
      }
      dp[(int)i] = (s + MOD - u) % MOD;
    }
    long ans = 0;
    for(long i = 1; i <= k; i++) {
      long t = (i * dp[(int)i]) % MOD;
      ans = (ans + t) % MOD;
    }
    System.out.println(ans);
  }

  public static long func(long a, long x) {
    if(x == 0) return 1;
    if((x % 2) == 0) {
      long t = func(a, x / 2);
      return (t * t) % MOD;
    } else {
      return (a * func(a, x - 1)) % MOD;
    }
  }
}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    boolean[] prime = new boolean[200001];
    for(int i = 2; i < 2000001; i++) {
      prime[i] = true;
    }
    prime[1] = false;
    for(int i = 2; i < 2000001; i++) {
      if(prime[i]) {
        for(int j = (2 * i); j < 2000001; j += i) {
          prime[j] = false;
        }
      }
    }
    int ans = 0;
    for(int i = 2; i < 2000001; i++) {
      if((prime[i]) && (i >= x)) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}

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


Question:
import java.util.*;

public class Main {
  public static long MOD = (long)Math.pow(10, 9) + 7;
  public static long[] kai;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    long k = sc.nextLong();
    long ans = 0;

    kai = new long[200001];
    kai[0] = 1;
    for(long i = 1; i < 200001; i++) {
      kai[(int)i] = (kai[(int)i - 1] * i) % MOD;
    }

    for(long i = 1; i < n; i++) {
      long kosuu = ((n - i) * m) % MOD;
      kosuu = (kosuu * m) % MOD;
      kosuu = (kosuu * i) % MOD;
      kosuu = (kosuu * com((n * m - 2), k - 2)) % MOD;
      ans = (ans + kosuu) % MOD;
    }

    for(long i = 1; i < m; i++) {
      long kosuu = ((m - i) * n) % MOD;
      kosuu = (kosuu * n) % MOD;
      kosuu = (kosuu * i) % MOD;
      kosuu = (kosuu * com((n * m - 2), k - 2)) % MOD;
      ans = (ans + kosuu) % MOD;
    }

    System.out.println(ans);
  }

  public static long func(long a, long x) {
    if(x == 0) {
      return 1;
    } else if(x == 1) {
      return a % MOD;
    } else {
      if(x % 2 == 0) {
        return (func(a, x / 2) * func(a, x / 2)) % MOD;
      } else {
        return (a * func(a, x - 1)) % MOD;
      }
    }
  }

  public static long com(long s, long t) {
    if(s >= t) {
      long t1 = func(kai[(int)t], MOD - 2);
      long t2 = func(kai[(int)(s - t)], MOD - 2);
      long t3 = (kai[(int)s] * t1) % MOD;
      return (t3 * t2) % MOD;
    } else {
      return 0;
    }
  }
}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int c = sc.nextInt();
    int[] b = new int[m];
    for(int i = 0; i < m; i++) {
      b[i] = sc.nextInt();
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
      int p = 0;
      for(int j = 0; j < m; j++) {
        int a = sc.nextInt();
        p += (a * b[j]);
      }
      if(p > 0) ans++;
    }
    System.out.println(ans);
  }

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    ArrayList<Long> list = new ArrayList<Long>();
    list.add(s);
    int ans = 0;
    for(int i = 1; i <= 1000000; i++) {
      if((s % 2) == 0) {
        s /= 2;
      } else {
        s = 3 * s + 1;
      }
      if(list.contains(s)) {
        ans = i + 1;
        break;
      } else {
        list.add(s);
      }
    }
    System.out.println(ans);
  }
}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] h = new long[n];
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextLong();
    }
    System.out.println(func(h));
  }

  public static long func(long[] h) {
    long m = Long.MAX_VALUE;
    for(int i = 0; i < h.size; i++) {
      if(m > h[i]) m = h[i];
    }
    ArrayList<Integer> list = new ArrayList<Integer>();
    for(int i = 0; i < h.size; i++) {
      if(h[i] == m) list.add(i);
    }
    long ret = m;
    for(int i = 0; i < list.size(); i++) {
      int t1 = list.get(i) + 1;
      int t2 = 0;
      if(i < list.size() - 1) {
        t2 = list.get(i + 1) - 1;
      } else {
        t2 = h.size - 1;
      }
      if(t2 >= t1) {
        long[] s = new long[t2 - t1 + 1];
        for(int j = 0; j < (t2 - t1 + 1); j++) {
          s[j] = h[t1 + j];
        }
        ret += func(s);
      }
    }
    return ret;
  }
}

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


Question:
import java.util.*;

public class Main {
  static ArrayList[] edge;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    edge = new ArrayList[N + 1];
    for(int i = 1; i < N + 1; i++) {
      edge[i] = new ArrayList<Integer>();
    }
    for(int i = 0; i < N - 1; i++) {
      int x = sc.nextInt();
      int y = sc.nextInt();
      edge[x].add(y);
      edge[y].add(x);
    }
    String ans = "Alice";
    if(dfs(1, 0) == 0) ans = "Bob";
    System.out.println(ans);
  }

  public static int dfs(int v, int p) {
    ArrayList<Integer> list = edge[v];
    int ret = 0;
    for(int i = 0; i < list.size(); i++) {
      int u = list.get(i);
      if(u != p) {
        ret = (ret ^ (dfs(u, v) + 1));
      }
    }
  }
}

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


Question:
import java.util.Scanner;

/**
 *
ClassName:

 *
Description:

 *
Company:

 *
 * @author zhangyong
 * @version 1.0.0
 * @date 2019/12/10 22:39
 */
public class Solution {
    public static void main(String[] args) {
        String str = new Scanner(System.in).next();
        int count = 0;
        int left = 0, right = str.length() - 1;
        while (left < right) {
            if (str.charAt(left) == str.charAt(right)) {
                left += 1;
                right -= 1;
                continue;
            } else {
                left += 1;
                right -= 1;
                count += 1;
            }
        }
        System.out.println(count);
    }
}

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