Question:
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		double[] p = new double[N];
		for (int i = 0; i < N; i++) {
			double d = sc.nextDouble();
			p[i] = (d+1)/2;
		}
		double max = 0.0;
		double[] amounts = new double[N-K+1];
		for (int i = 0; i < K; i++) {
			max += p[i];
		}
		amounts[0] = max;
		for (int i = 0; i < N-K; i++) {
			amounts[i+1] = amounts[i] + p[i+K] - p[i];
			if (max < amounts[i+1]) {
				max = amounts[i+1];
			}
		}
		System.out.println(max);

	}
}

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


Question:
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();
		if (K <= A) {
			A -= K;
		} else if (A < K) {
			B -= (K - A);
			A = 0;
			if (B < 0) {
				B = 0;
			}
		}
		System.out.println(A + " " + B);
	}
}

Choices:
- Internal error
- Runtime Error
- No abnormally found
- 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 d[] = new int[n];
    int heal = 0;
    for(int i = 0; i < n; i++){
      d[i] = sc.nextInt();
    }
    for(int i = 0; i < n - 1; i++){
      for(int j = i + 1; j < n; j++){
        heal += d[i] * d[j];
      }
    }
    System.out.println(heal);
  }
}

Choices:
- Memory Limit Exceeded
- No abnormally found
- Compile Error
- 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();
    System.out.println(N * N * N);
  }
}

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


Question:
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();

		int a = sc.nextInt();
		int b = sc.nextInt();

		String u = sc.next();

		if (s.equals(u)) {
			System.out.println(a - 1);
			System.out.println(b);
		} else if (t.equals(u)) {
			System.out.println(a);
			System.out.println(b - 1);
		}

	}
}

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


Question:
import java.util.*;

public class Main {
    static final int MOD = 998244353;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int s = sc.nextInt();
		int[][] dp = new int[n + 1][s + 1];
		dp[0][0] = 1;
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    for (int j = s; j >= 0; j--) {
		        dp[i + 1][j] = dp[i][j] * 2 % MOD;
		        if (j - x >= 0) {
		            dp[i + 1][j] += dp[i][j - x];
		            dp[i + 1][j] %= MOD;
		        }
		    }
		}
	    System.out.println(dp[n][s]);
	}
}

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


Question:
import java.util.*;

public class Main {
    static final int MOD = 998244353;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int s = sc.nextInt();
		int[][] dp = new int[n + 1][s + 1];
		dp[0][0] = 1;
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    for (int j = s; j >= 0; j--) {
		        dp[i + 1][j] = dp[i][j] * 2 % MOD;
		        if (j - x >= 0) {
		            dp[i + 1][j] += dp[i][j - x];
		            dp[i + 1][j] %= MOD;
		        }
		    }
		}
	    System.out.println(dp[n][s]);
	}
}

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


Question:
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int date = sc.nextInt(); //整数の入力
		System.out.print("Christmas");
		for (int x = date; x < 25; x++) {
			System.out.print(" Eve");
		}
		System.out.println();
	}
}

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


Question:
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long count = 0;
		if (k % 2 == 0) {
			long x = n / k;
			count += (x * x * x);
			long y = (n + k / 2) / k;
			count += (y * y * y);
		} else {
			long x = n / k;
			count += (x * x * x);
		}
		System.out.println(count);
	}
}

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


Question:
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int length = x + y + z;
		Person[] persons = new Person[length];
		for (int i = 0; i < length; i++) {
		    persons[i] = new Person(i, sc.nextInt(), sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(persons, new Comparator<Person>() {
		    public int compare(Person p1, Person p2) {
		        return p2.xCount - p2.yCount - (p1.xCount - p1.yCount);
		    }
		});
		TreeSet<Person> xTree = new TreeSet<>(new Comparator<Person>() {
		    public int compare(Person p1, Person p2) {
		        int ret =  p2.zCount - p2.xCount - (p1.zCount - p1.xCount);
		        if (ret == 0) {
		            return p1.id - p2.id;
		        } else {
		            return ret;
		        }
		    }
		});
		long xSum = 0;
		for (int i = 0; i < x; i++) {
		    xTree.add(persons[i]);
		    xSum += persons[i].xCount;
		}
		TreeSet<Person> yTree = new TreeSet<>(new Comparator<Person>() {
		    public int compare(Person p1, Person p2) {
		        int ret = p2.zCount - p2.yCount - (p1.zCount - p1.yCount);
		        if (ret == 0) {
		            return p1.id - p2.id;
		        } else {
		            return ret;
		        }
		    }
		});
		long ySum = 0;
		for (int i = x; i < length; i++) {
		    yTree.add(persons[i]);
		    ySum += persons[i].yCount;
		}
		TreeSet<Person> zxTree = new TreeSet<>(new Comparator<Person>() {
		    public int compare(Person p1, Person p2) {
		        int ret = p1.zCount - p1.xCount - (p2.zCount - p2.xCount);
		        if (ret == 0) {
		            return p1.id - p2.id;
		        } else {
		            return ret;
		        }
		    }
		});
		TreeSet<Person> zyTree = new TreeSet<>(new Comparator<Person>() {
		    public int compare(Person p1, Person p2) {
		        int ret = p1.zCount - p1.yCount - (p2.zCount - p2.yCount);
		        if (ret == 0) {
		            return p1.id - p2.id;
		        } else {
		            return ret;
		        }
		    }
		});
		long zxSum = 0;
		long zySum = 0;
		for (int i = 0; i < z; i++) {
		    Person tmp = yTree.pollFirst();
		    zyTree.add(tmp);
		    ySum -= tmp.yCount;
		    zySum += tmp.zCount;
		}
		long max = xSum + ySum + zxSum + zySum;
		for (int i = 0; i < z; i++) {
		    Person tmp = persons[x + i];
		    if (yTree.contains(tmp)) {
		        ySum -= tmp.yCount;
		        yTree.remove(tmp);
		        Person tmp2 = zyTree.pollFirst();
		        zySum -= tmp2.zCount;
		        yTree.add(tmp2);
		        ySum += tmp2.yCount;
		    } else {
		        zyTree.remove(tmp);
		        zySum -= tmp.zCount;
		    }
		    xTree.add(tmp);
		    xSum += tmp.xCount;
		    Person tmp2 = xTree.pollFirst();
		    xSum -= tmp2.xCount;
		    zxTree.add(tmp2);
		    zxSum += tmp2.zCount;
		    max = Math.max(max, xSum + ySum + zxSum + zySum);
		}
	    System.out.println(max);
	}

	static class Person {
	    int id;
	    int xCount;
	    int yCount;
	    int zCount;

	    public Person (int id, int xCount, int yCount, int zCount) {
	        this.id = id;
	        this.xCount = xCount;
	        this.yCount = yCount;
	        this.zCount = zCount;
	    }

	    public int hashCode() {
	        return id;
	    }

	    public boolean equals(Object o) {
	        Person p = (Person)o;
	        return id == p.id && xCount == p.xCount && yCount == p.yCount && zCount == p.zCount;
	    }

	    public String toString() {
	        return "x:" + xCount + " y:" + yCount + " z:" + zCount;
	    }
	}
}

Choices:
- Memory Limit Exceeded
- No abnormally found
- Internal error
- 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();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int length = x + y + z;
		Person[] persons = new Person[length];
		for (int i = 0; i < length; i++) {
		    persons[i] = new Person(i, sc.nextInt(), sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(persons, new Comparator<Person>() {
		    public int compare(Person p1, Person p2) {
		        return p2.xCount - p2.yCount - (p1.xCount - p1.yCount);
		    }
		});
		TreeSet<Person> xTree = new TreeSet<>(new Comparator<Person>() {
		    public int compare(Person p1, Person p2) {
		        int ret =  p2.zCount - p2.xCount - (p1.zCount - p1.xCount);
		        if (ret == 0) {
		            return p1.id - p2.id;
		        } else {
		            return ret;
		        }
		    }
		});
		long xSum = 0;
		for (int i = 0; i < x; i++) {
		    xTree.add(persons[i]);
		    xSum += persons[i].xCount;
		}
		TreeSet<Person> yTree = new TreeSet<>(new Comparator<Person>() {
		    public int compare(Person p1, Person p2) {
		        int ret = p2.zCount - p2.yCount - (p1.zCount - p1.yCount);
		        if (ret == 0) {
		            return p1.id - p2.id;
		        } else {
		            return ret;
		        }
		    }
		});
		long ySum = 0;
		for (int i = x; i < length; i++) {
		    yTree.add(persons[i]);
		    ySum += persons[i].yCount;
		}
		TreeSet<Person> zxTree = new TreeSet<>(new Comparator<Person>() {
		    public int compare(Person p1, Person p2) {
		        int ret = p1.zCount - p1.xCount - (p2.zCount - p2.xCount);
		        if (ret == 0) {
		            return p1.id - p2.id;
		        } else {
		            return ret;
		        }
		    }
		});
		TreeSet<Person> zyTree = new TreeSet<>(new Comparator<Person>() {
		    public int compare(Person p1, Person p2) {
		        int ret = p1.zCount - p1.yCount - (p2.zCount - p2.yCount);
		        if (ret == 0) {
		            return p1.id - p2.id;
		        } else {
		            return ret;
		        }
		    }
		});
		long zxSum = 0;
		long zySum = 0;
		for (int i = 0; i < z; i++) {
		    Person tmp = yTree.pollFirst();
		    zyTree.add(tmp);
		    ySum -= tmp.yCount;
		    zySum += tmp.zCount;
		}
		long max = xSum + ySum + zxSum + zySum;
		for (int i = 0; i < z; i++) {
		    Person tmp = persons[x + i];
		    if (yTree.contains(tmp)) {
		        ySum -= tmp.yCount;
		        yTree.remove(tmp);
		        Person tmp2 = zyTree.pollFirst();
		        zySum -= tmp2.zCount;
		        yTree.add(tmp2);
		        ySum += tmp2.yCount;
		    } else {
		        zyTree.remove(tmp);
		        zySum -= tmp.zCount;
		    }
		    xTree.add(tmp);
		    xSum += tmp.xCount;
		    Person tmp2 = xTree.pollFirst();
		    xSum -= tmp2.xCount;
		    zxTree.add(tmp2);
		    zxSum += tmp2.zCount;
		    max = Math.max(max, xSum + ySum + zxSum + zySum);
		}
	    System.out.println(max);
	}

	static class Person {
	    int id;
	    int xCount;
	    int yCount;
	    int zCount;

	    public Person (int id, int xCount, int yCount, int zCount) {
	        this.id = id;
	        this.xCount = xCount;
	        this.yCount = yCount;
	        this.zCount = zCount;
	    }

	    public int hashCode() {
	        return id;
	    }

	    public boolean equals(Object o) {
	        Person p = (Person)o;
	        return id == p.id && xCount == p.xCount && yCount == p.yCount && zCount == p.zCount;
	    }

	    public String toString() {
	        return "x:" + xCount + " y:" + yCount + " z:" + zCount;
	    }
	}
}

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


Question:
import java.util.Scanner;

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

		if (K <= A) {
			A = A - K;
		} else if (K >= A + B) {
			A = 0;
			B = 0;
		} else {
			B = B - K + A;
			A = 0;
		}
		System.out.println(A + " " + B);
	}
}

Choices:
- Internal error
- No abnormally found
- 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 X = sc.nextInt();
		sc.close();
		int a = 1;

		while (a != 0) {
			a=0;
			for (int i = 2; i <= X / 2; i++) {
				if (X % i == 0) {
					a++;
				}
			}
			if (a != 0) {
				X++;
			}
		}
		System.out.println(X);
	}
}

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


Question:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        long[] x = new long[N];
		long[] y = new long[N];
    	for(int i = 0; i < N; i++){
    		x[i] = sc.nextLong();
			y[i] = sc.nextLong();
    	}

		long maxZ = Long.MIN_VALUE;
		long minZ = Long.MAX_VALUE;
		long maxW = Long.MIN_VALUE;
		long minW = Long.MAX_VALUE;

		for (int i = 0; i < N; i++) {
			long z = x[i] + y[i];
			long w = x[i] - y[i];

			if (maxZ < z) {
			    maxZ = z;
			}
			if (z < minZ) {
			    minZ = z;
			}
			if (maxW < w) {
			    maxW = w;
			}
			if (w < minW) {
			    minW = w;
			}
		}

		System.out.println(Math.max(maxZ - minZ, maxW - minW));
	}
}

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


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

class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int N = ni(), K = ni();
        int[] from = new int[N-1], to = new int[N-1];
        for(int i = 0; i< N-1; i++){
            from[i] = ni()-1;
            to[i] = ni()-1;
        }
        int[][] g = make(N, N-1, from, to, true);
        int ans = N;
        if(K%2 == 0){
            for(int i = 0; i< N; i++){
                int[] d = new int[N];
                mark(g, d, i, -1, 0);
                int cnt = 0;
                for(int j = 0; j< N; j++)if(d[j] > K/2)cnt++;
                ans = Math.min(ans, cnt);
            }
        }else{
            for(int i = 0; i< N-1; i++){
                int[] d = new int[N];
                mark(g, d, from[i], to[i], 0);
                mark(g, d, to[i], from[i], 0);
                int cnt = 0;
                for(int j = 0; j< N; j++)if(d[j] > K/2)cnt++;
                ans = Math.min(ans, cnt);
            }
        }
        pn(ans);
    }
    void mark(int[][] g, int[] d, int u, int p, int dep){
        d[u] = dep;
        for(int v:g[u])if(v != p)mark(g, d, v, u, dep+1);
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    void exit(boolean b){if(!b)System.exit(0);}
    static void dbg(Object... o){System.err.println(Arrays.deepToString(o));}
    final long IINF = (long)1e17;
    final int INF = (int)1e9+2;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;
    static boolean multipleTC = false, memory = true, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        long ct = System.currentTimeMillis();
        if (fileIO) {
            in = new FastReader("");
            out = new PrintWriter("");
        } else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = multipleTC? ni():1;
        pre();
        for (int t = 1; t <= T; t++) solve(t);
        out.flush();
        out.close();
        System.err.println(System.currentTimeMillis() - ct);
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    int[][] make(int n, int e, int[] from, int[] to, boolean f){
        int[][] g = new int[n][];int[]cnt = new int[n];
        for(int i = 0; i< e; i++){
            cnt[from[i]]++;
            if(f)cnt[to[i]]++;
        }
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< e; i++){
            g[from[i]][--cnt[from[i]]] = to[i];
            if(f)g[to[i]][--cnt[to[i]]] = from[i];
        }
        return g;
    }
    int[][][] makeS(int n, int e, int[] from, int[] to, boolean f){
        int[][][] g = new int[n][][];int[]cnt = new int[n];
        for(int i = 0; i< e; i++){
            cnt[from[i]]++;
            if(f)cnt[to[i]]++;
        }
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]][];
        for(int i = 0; i< e; i++){
            g[from[i]][--cnt[from[i]]] = new int[]{to[i], i, 0};
            if(f)g[to[i]][--cnt[to[i]]] = new int[]{from[i], i, 1};
        }
        return g;
    }
    int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}
    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object... o){for(Object oo:o)out.print(oo+" ");}
    void pn(Object... o){for(Object oo:o)out.print(oo+" ");out.println();}
    void pni(Object... o){for(Object oo:o)out.print(oo+" ");out.println();out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str;
            try{
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }
            return str;
        }
    }
}

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


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

class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int N = ni(), K = ni();
        int[] from = new int[N-1], to = new int[N-1];
        for(int i = 0; i< N-1; i++){
            from[i] = ni()-1;
            to[i] = ni()-1;
        }
        int[][] g = make(N, N-1, from, to, true);
        int ans = N;
        if(K%2 == 0){
            for(int i = 0; i< N; i++){
                int[] d = new int[N];
                mark(g, d, i, -1, 0);
                int cnt = 0;
                for(int j = 0; j< N; j++)if(d[j] > K/2)cnt++;
                ans = Math.min(ans, cnt);
            }
        }else{
            for(int i = 0; i< N-1; i++){
                int[] d = new int[N];
                mark(g, d, from[i], to[i], 0);
                mark(g, d, to[i], from[i], 0);
                int cnt = 0;
                for(int j = 0; j< N; j++)if(d[j] > K/2)cnt++;
                ans = Math.min(ans, cnt);
            }
        }
        pn(ans);
    }
    void mark(int[][] g, int[] d, int u, int p, int dep){
        d[u] = dep;
        for(int v:g[u])if(v != p)mark(g, d, v, u, dep+1);
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    void exit(boolean b){if(!b)System.exit(0);}
    static void dbg(Object... o){System.err.println(Arrays.deepToString(o));}
    final long IINF = (long)1e17;
    final int INF = (int)1e9+2;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;
    static boolean multipleTC = false, memory = true, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        long ct = System.currentTimeMillis();
        if (fileIO) {
            in = new FastReader("");
            out = new PrintWriter("");
        } else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = multipleTC? ni():1;
        pre();
        for (int t = 1; t <= T; t++) solve(t);
        out.flush();
        out.close();
        System.err.println(System.currentTimeMillis() - ct);
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    int[][] make(int n, int e, int[] from, int[] to, boolean f){
        int[][] g = new int[n][];int[]cnt = new int[n];
        for(int i = 0; i< e; i++){
            cnt[from[i]]++;
            if(f)cnt[to[i]]++;
        }
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< e; i++){
            g[from[i]][--cnt[from[i]]] = to[i];
            if(f)g[to[i]][--cnt[to[i]]] = from[i];
        }
        return g;
    }
    int[][][] makeS(int n, int e, int[] from, int[] to, boolean f){
        int[][][] g = new int[n][][];int[]cnt = new int[n];
        for(int i = 0; i< e; i++){
            cnt[from[i]]++;
            if(f)cnt[to[i]]++;
        }
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]][];
        for(int i = 0; i< e; i++){
            g[from[i]][--cnt[from[i]]] = new int[]{to[i], i, 0};
            if(f)g[to[i]][--cnt[to[i]]] = new int[]{from[i], i, 1};
        }
        return g;
    }
    int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}
    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object... o){for(Object oo:o)out.print(oo+" ");}
    void pn(Object... o){for(Object oo:o)out.print(oo+" ");out.println();}
    void pni(Object... o){for(Object oo:o)out.print(oo+" ");out.println();out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str;
            try{
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }
            return str;
        }
    }
}

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


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

class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int N = ni(), M = ni();
        int[] A = new int[M];
        for(int i = 0; i< M; i++)
            A[i] = ni();
        for(int i = 1; i+1 < M; i++){
            if(A[i]%2 == 1){
                if(A[0]%2 == 0){
                    int tmp = A[0];
                    A[0] = A[i];
                    A[i] = tmp;
                }else if(A[M-1]%2 == 0){
                    int tmp = A[M-1];
                    A[M-1] = A[i];
                    A[i] = tmp;
                }else{
                    pn("Impossible");
                    return;
                }
            }
        }
        if(M == 1){
            if(N == 1){
                pn(A[0]);
                pn(1);
                pn(A[0]);
            }else{
                pn(A[0]);
                pn(2);
                pn(A[0]-1, 1);
            }
            return;
        }
        ArrayList<Integer> list = new ArrayList<>();
        for(int i = 0; i< M; i++){
            if(i == 0)list.add(A[i]+1);
            else if(i+1 == M){if(A[i]>1)list.add(A[i]-1);}
            else list.add(A[i]);
        }
        for(int i:A)p(i);pn();
        pn(list.size());
        for(int i:list)p(i);pn();
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    void exit(boolean b){if(!b)System.exit(0);}
    static void dbg(Object... o){System.err.println(Arrays.deepToString(o));}
    final long IINF = (long)1e17;
    final int INF = (int)1e9+2;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;
    static boolean multipleTC = false, memory = true, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        long ct = System.currentTimeMillis();
        if (fileIO) {
            in = new FastReader("");
            out = new PrintWriter("");
        } else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = multipleTC? ni():1;
        pre();
        for (int t = 1; t <= T; t++) solve(t);
        out.flush();
        out.close();
        System.err.println(System.currentTimeMillis() - ct);
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    int[][] make(int n, int e, int[] from, int[] to, boolean f){
        int[][] g = new int[n][];int[]cnt = new int[n];
        for(int i = 0; i< e; i++){
            cnt[from[i]]++;
            if(f)cnt[to[i]]++;
        }
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< e; i++){
            g[from[i]][--cnt[from[i]]] = to[i];
            if(f)g[to[i]][--cnt[to[i]]] = from[i];
        }
        return g;
    }
    int[][][] makeS(int n, int e, int[] from, int[] to, boolean f){
        int[][][] g = new int[n][][];int[]cnt = new int[n];
        for(int i = 0; i< e; i++){
            cnt[from[i]]++;
            if(f)cnt[to[i]]++;
        }
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]][];
        for(int i = 0; i< e; i++){
            g[from[i]][--cnt[from[i]]] = new int[]{to[i], i, 0};
            if(f)g[to[i]][--cnt[to[i]]] = new int[]{from[i], i, 1};
        }
        return g;
    }
    int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}
    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object... o){for(Object oo:o)out.print(oo+" ");}
    void pn(Object... o){for(int i = 0; i< o.length; i++)out.print(o[i]+(i+1 < o.length?" ":"\n"));}
    void pni(Object... o){for(Object oo:o)out.print(oo+" ");out.println();out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str;
            try{
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }
            return str;
        }
    }
}

Choices:
- Internal error
- Memory Limit Exceeded
- 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 aMin = Long.MAX_VALUE, aMax = Long.MIN_VALUE;
        long bMin = Long.MAX_VALUE, bMax = Long.MIN_VALUE;
        for(int n=0; n<N; n++){
            long x = sc.nextLong();
            long y = sc.nextLong();

            long a = x-y, b = x+y;
            aMin = Math.min(aMin, a);
            aMax = Math.max(aMax, a);
            bMin = Math.min(bMin, b);
            bMax = Math.max(bMax, b);
        }

        System.out.println(Math.max(aMax-aMin, bMax-bMin));
    }
}

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


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

public class Main {
    static long f(long min, long max){
        if(min>max) return f(max,min);
        if(min+10>max){
            //System.err.println("simple");
            long ans = 0;
            for(long x=min; x<=max; x++) ans ^= x;
            return ans;
        }

        long ans = 0;
        if((min&1) != 0){
            //System.err.println("min is odd");
            ans ^= min;
            min++;
        }
        if((max&1) == 0){
            //System.err.println("max is even");
            ans ^= max;
            max--;
        }

        long pair = (max-min+1)/2;
        //System.err.println((pair + " pairs."));
        if(pair%2 != 0) ans ^= 1L;

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

        Scanner sc = new Scanner(System.in);
        long min = sc.nextLong();
        long max = sc.nextLong();
        System.out.println(f(min, max));
    }
}

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


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

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

        System.out.println((A-B)%2==0 ? "Alice" : "Borys");
    }
}

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


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

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

        System.out.println((A-B)%2==0 ? "Alice" : "Borys");
    }
}

Choices:
- No abnormally found
- Compile Error
- Runtime Error
- 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();
		int [] min = new int [n];
        int [] max = new int [n];
        for(int i=0;i<n;i++){min[i] = sc.nextInt();
                             max[i] = sc.nextInt();
                            }
	    Arrays.sort(min);
        Arrays.sort(max);
        if(n%2==0){System.out.println(max[n/2-1]+max[n/2]-min[n/2-1]-min[n/2]+1);}
        else{System.out.println(max[n/2]-min[n/2]+1);}
	}
}

Choices:
- No abnormally found
- Compile Error
- Memory 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 [] min = new int [n];
        int [] max = new int [n];
        for(int i=0;i<n;i++){min[i] = sc.nextInt();
                             max[i] = sc.nextInt();
                            }
	    Arrays.sort(min);
        Arrays.sort(max);
        if(n%2==0){System.out.println(max[n/2-1]+max[n/2]-min[n/2-1]-min[n/2]+1);}
        else{System.out.println(max[n/2]-min[n/2]+1);}
	}
}

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


Question:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] min = new int [n];
        int [] max = new int [n];
        for(int i=0;i<n;i++){min[i] = sc.nextInt();
                             max[i] = sc.nextInt();
                            }
	    Arrays.sort(min);
        Arrays.sort(max);
        if(n%2==0){System.out.println(max[n/2-1]+max[n/2]-min[n/2-1]-min[n/2]+1);}
        else{System.out.println(max[n/2]-min[n/2]+1);}
	}
}

Choices:
- No abnormally found
- 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);
		int a = sc.nextInt();
        int b = sc.nextInt();
		int c = -1;
        for(int i=1;i<=1000;i++){if((i*8)/100==a && (i*10)/100==b){c=i;break;}}
		System.out.println(c);
	}
}

Choices:
- Runtime 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 a = sc.nextInt();
        int b = 0;
        int c;
        int [][] in = new int [10][10];
        for(int i=1;i<=a;i++){if(i<10){c=i;}else{if(i<100){c=i/10;}
                                                else{if(i<1000){c=i/100;}
                                                    else{if(i<10000){c=i/1000;}
                                                        else{if(i<100000){c=i/10000;}
                                                            else{c=i/100000;}}}}}
        in[c][i%10]++;}
        for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){b+=in[i][j]*in[j][i];}}
		System.out.println(b);
	}
}

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


Question:
import java.util.*;

public class Main {
    public static Long gcd(Long x,Long y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    }
    public static Long lcm(Long x,Long y){
        return x*y/gcd(x,y);
    }
    public static Long df(Long x){
        if(x==0) return x+1;
        return 5*df(x-1);
    }
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long a = sc.nextLong();
        Long b = a-a;
        Long c = b;
        for (Long i=b;df(i+1)<=a/2;i++){c+=(a/2)/df(i+1);}
		System.out.println(c*((a+1)%2));
	}
}

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


Question:
import java.util.*;

public class Main {
    public static Long gcd(Long x,Long y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    }
    public static Long lcm(Long x,Long y){
        return x*y/gcd(x,y);
    }
    public static Long df(Long x){
        if(x==0) return x+1;
        return 5*df(x-1);
    }
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long a = sc.nextLong();
        Long b = a-a;
        Long c = b;
        for (Long i=b;df(i+1)<=a/2;i++){c+=(a/2)/df(i+1);}
		System.out.println(c*((a+1)%2));
	}
}

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


Question:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        long [] a = new long [n+1];
        long [] b = new long [n];
        long ans = 0;
		for(int i=0;i<n+1;i++){a[i] = sc.nextLong();
                              }
        for(int i=0;i<n;i++){b[i] = sc.nextLong();
                            }
        for(int i=0;i<n;i++){long c = Math.min(a[i],b[i]);ans+=c;a[i]-=c;b[i]-=c;
                            long d = Math.min(a[i+1],b[i]);ans+=d;a[i+1]-=d;b[i]-=d;
                            }
		System.out.println(ans);
	}
}

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


Question:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
        String t = "Good";
        for(int i=0;i<3;i++){if(s.charAt(i)==s.charAt(i+1)){t="Bad";break;
                                                 }
                            }
		System.out.println(t);
	}
}

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


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

class Solver {
  final int n;
  final long[] ss;
  List<Long> primes;
  Map<Long, Long> primeRootMap;

  Solver(int n, long[] ss) {
    this.n = n;
    this.ss = ss;
  }

  private boolean isPrime(long v) {
    for (long p : primes) {
      if (v % p == 0) {
        return false;
      }
      if (p * p > v) {
        return true;
      }
    }
    return true;
  }

  private long normalize(long v) {
    for (long p : primes) {
      long p3 = p * p * p;
      while (v % p3 == 0) {
        v /= p3;
      }
      if (p3 > v) {
        return v;
      }
    }
    return v;
  }

  private long calculateOppositve(long v) {
    long opposite = 1;
    for (long p : primes) {
      long p2 = p * p;
      if (v % p2 == 0) {
        opposite *= p;
        v /= p2;
      }
      if (10_000_000_000L < p * p * p) {
        break;
      }
    }
    if (primeRootMap.get(v) != null) {
      opposite *= primeRootMap.get(v);
    } else {
      opposite *= v;
      opposite *= v;
    }
    return opposite;
  }

  public int solve() {
    primes = new ArrayList<>();
    for (long i = 2; i < 100_000; i++) {
      if (isPrime(i)) {
        primes.add(i);
      }
    }

    primeRootMap = new HashMap<>();
    for (long p : primes) {
      primeRootMap.put(p * p, p);
    }

    Map<Long, Integer> counters = new HashMap<>();
    for (long s : ss) {
      long normS = normalize(s);
      counters.put(normS, counters.getOrDefault(normS, 0) + 1);
    }

    int answer = 0;
    for (Map.Entry<Long, Integer> entry : counters.entrySet()) {
      long s1 = entry.getKey();
      long c1 = entry.getValue();
      if (s1 == 1) {
        answer++;
        continue;
      }
      long s2 = calculateOppositve(s1);
      long c2 = counters.getOrDefault(s2, 0);
      if (c2 == 0) {
        answer += c1;
      } else if (s1 < s2) {
        answer += Math.max(c1, c2);
      }
    }

    return answer;
  }
}

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    long[] ss = reader.nextLong(n);
    out.println(new Solver(n, ss).solve());
  }

  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;

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

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

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

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

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

  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }

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

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

  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }

  public char[] nextCharArray() {
    return next().toCharArray();
  }

  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }

  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }

  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }

  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}

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


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

class Solver {
  final int n;
  final long[] ss;
  List<Long> primes;
  Map<Long, Long> primeRootMap;

  Solver(int n, long[] ss) {
    this.n = n;
    this.ss = ss;
  }

  private boolean isPrime(long v) {
    for (long p : primes) {
      if (v % p == 0) {
        return false;
      }
      if (p * p > v) {
        return true;
      }
    }
    return true;
  }

  private long normalize(long v) {
    for (long p : primes) {
      long p3 = p * p * p;
      while (v % p3 == 0) {
        v /= p3;
      }
      if (p3 > v) {
        return v;
      }
    }
    return v;
  }

  private long calculateOppositve(long v) {
    long opposite = 1;
    for (long p : primes) {
      long p2 = p * p;
      if (v % p2 == 0) {
        opposite *= p;
        v /= p2;
      }
      if (10_000_000_000L < p * p * p) {
        break;
      }
    }
    if (primeRootMap.get(v) != null) {
      opposite *= primeRootMap.get(v);
    } else {
      opposite *= v;
      opposite *= v;
    }
    return opposite;
  }

  public int solve() {
    primes = new ArrayList<>();
    for (long i = 2; i < 100_000; i++) {
      if (isPrime(i)) {
        primes.add(i);
      }
    }

    primeRootMap = new HashMap<>();
    for (long p : primes) {
      primeRootMap.put(p * p, p);
    }

    Map<Long, Integer> counters = new HashMap<>();
    for (long s : ss) {
      long normS = normalize(s);
      counters.put(normS, counters.getOrDefault(normS, 0) + 1);
    }

    int answer = 0;
    for (Map.Entry<Long, Integer> entry : counters.entrySet()) {
      long s1 = entry.getKey();
      long c1 = entry.getValue();
      if (s1 == 1) {
        answer++;
        continue;
      }
      long s2 = calculateOppositve(s1);
      long c2 = counters.getOrDefault(s2, 0);
      if (c2 == 0) {
        answer += c1;
      } else if (s1 < s2) {
        answer += Math.max(c1, c2);
      }
    }

    return answer;
  }
}

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    long[] ss = reader.nextLong(n);
    out.println(new Solver(n, ss).solve());
  }

  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;

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

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

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

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

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

  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }

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

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

  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }

  public char[] nextCharArray() {
    return next().toCharArray();
  }

  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }

  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }

  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }

  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}

Choices:
- Runtime Error
- Memory Limit Exceeded
- 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();
    int k = sc.nextInt();
    int index = -1;
    if(n == k){
      System.out.println(1);
      System.exit(0);
    }
    for(int i = 0; i < n; i++){
      if(sc.nextInt() == 1){
        index = i;
        break;
      }
    }
    //System.out.println(index);
    int ans = (int)Math.ceil((double)index / (k - 1));
    //System.out.println(ans);
    if(index == 0) ans = 1;
    if(k-1 != 1){
      index += (index > (k-1)) ? (k-1) - (index % (k-1)) : (k - 1) - index;
    }
    if(index > n - 1){
      System.out.println(ans);
      System.exit(0);
    }
    //System.out.println(index);
    ans += (int)Math.ceil((n - 1 - index) / (double)(k - 1));
    System.out.println(ans);
  }
}

Choices:
- No abnormally found
- 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 n = sc.nextInt();
        int m = sc.nextInt();
        int ans = 1000;
        int[] s = new int[m];
        int[] c = new int[m];
        for (int i=0;i<m;i++){
            s[i]=sc.nextInt();
            c[i]=sc.nextInt();
        }
        for (int i=0;i<1000;i++){
            boolean b = true;
            double log = Math.log10(i);
            if (i==0)log=0;
            if ((int)log+1!=n)b=false;
            if (b){
                String st = Integer.toString(i);
                for (int j=0;j<m;j++){
                    if (st.charAt(s[j]-1)-'0'!=c[j])b=false;
                }
            }
            if (b)ans=Math.min(ans,i);
        }
        if (ans==1000)System.out.println(-1);
        else System.out.println(ans);
    }
    static long factorial(long num){
        if (num<2)return 1;
        else return num*factorial(num-1);
    }
    static int arraySum(int[] array){
        int ans = 0;
        for (int value : array) ans += value;
        return ans;
    }
    static long combination(long a, long b){
        long data = 1;
        for (int i=0;i<b;i++){
            data*=a-i;
        }
        return data/factorial(b);
    }
    static double log(double base,double antilogarithm){
        return Math.log(antilogarithm)/Math.log(base);
    }

    static long gcd(long x,long y){
        if (y==0)return x;
        else return gcd(y,x%y);
    }
    static long lcm(long x,long y){
        return x/gcd(x,y)*y;
    }
    static HashMap<Long,Long> factorization(long num){
        HashMap<Long,Long> hash = new HashMap<>();
        long n = num;
        long count = 2;
        while (n>1){
            while (n%count==0){
                n/=count;
                if (hash.containsKey(count))hash.put(count,hash.get(count)+1);
                else hash.put(count,1L);
            }
            count++;
        }
        return hash;
    }

}

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


Question:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        boolean b = true;
        int count = x;
        while (b){
            boolean c = true;
            for (int i=2;i<=Math.sqrt(x)&&c;i++){
                    if (count%i==0){
                        c=false;
                        count++;
                    }
            }
            if (c){
                System.out.println(count);
                b=false;
            }
        }

    }

}

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


Question:
import java.util.*;
public class Main {
	static int N,u,v;
	static List<ArrayList<Integer>> ls = new ArrayList<ArrayList<Integer>>();
	static int t_dist[], a_dist[];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt(); u = sc.nextInt()-1; v = sc.nextInt()-1;
		for(int i=0;i<N;i++) ls.add(new ArrayList<Integer>());
		for(int i=0;i<N-1;i++) {
			int A = sc.nextInt()-1, B = sc.nextInt()-1;
			ls.get(A).add(B);
			ls.get(B).add(A);
		}
		sc.close();
		t_dist = new int[N];
		a_dist = new int[N];
		int dif[] = new int[N];
		dfs(u, 0,-1);
		adfs(v, 0, -1);
		for(int i=0;i<N;i++) {
			dif[i] = Math.max(a_dist[i]-t_dist[i], 0);
		}

		int max = 0;
		for(int i=0;i<N;i++) {
			if(dif[i]>0&&max<a_dist[i]) {
				max = a_dist[i];
			}
		}

		long ans = max - 1;

		System.out.println(ans);
	}
	static void dfs(int now, int cnt, int parent) {
		t_dist[now]=cnt;
		for(int i=0;i<ls.get(now).size();i++) {
			int next = ls.get(now).get(i);
			if(next == parent)continue;
			dfs(next, cnt+1, now);
		}
	}
	static void adfs(int now, int cnt, int parent) {
		a_dist[now]=cnt;
		for(int i=0;i<ls.get(now).size();i++) {
			int next = ls.get(now).get(i);
			if(next == parent)continue;
			adfs(next, cnt+1, now);
		}
	}
}

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


Question:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L[] = new int[N];
		int R[] = new int[N];
		ArrayList<int[]> q = new ArrayList<int[]>();
		for(int i=0;i<N;i++){
			L[i]=sc.nextInt();
			R[i]=sc.nextInt();
			int tmp[] = {L[i],R[i]};
			q.add(tmp);
		}
		sc.close();
		long ans = 0;

		//左端で降順にソート
		Collections.sort(q,(q1,q2)->q2[0]-q1[0]);
		int lmax[] = q.get(0);
		//右端で昇順にソート
		Collections.sort(q,(q1,q2)->q1[1]-q2[1]);
		int rmin[] = q.get(0);
		//幅で降順にソート
		Collections.sort(q,(q1,q2)->(q2[1]-q2[0])-(q1[1]-q1[0]));
		int wmax[] = q.get(0);
		//左端最大の区間と、右端最小の区間を同じコンテストに出題するとき
		if(N==2);//N=2なら何もしない
		else{
		int k=0;
		while(wmax==lmax|wmax==rmin){
			k++;
			wmax = q.get(k);
		}
		ans = Math.max((rmin[1]-lmax[0]+1),0) + (wmax[1]-wmax[0]+1);
		}
		//左端最大の区間と、右端最小の区間が異なるコンテストに出題するとき
		//左端で降順にソート
		Collections.sort(q,(q1,q2)->q2[0]-q1[0]);
		int remain_rmin = Integer.MAX_VALUE;
		int tmp_ans=0;
		for(int i=0;i<N;i++){
			int tmp[] = q.get(i);

			if(i<=1) remain_rmin = lmax[1] ;
			else{
				remain_rmin = Math.min(remain_rmin, q.get(i-1)[1]);
			}
			tmp_ans = Math.max((rmin[1]-tmp[0]+1),0) + Math.max((remain_rmin-lmax[0]+1),0);
			ans = Math.max(ans,tmp_ans);
 		}
		System.out.println(ans);
	}
}

Choices:
- Runtime Error
- No abnormally found
- 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 L[] = new int[N];
		int R[] = new int[N];
		ArrayList<int[]> q = new ArrayList<int[]>();
		for(int i=0;i<N;i++){
			L[i]=sc.nextInt();
			R[i]=sc.nextInt();
			int tmp[] = {L[i],R[i]};
			q.add(tmp);
		}
		sc.close();
		long ans = 0;

		//左端で降順にソート
		Collections.sort(q,(q1,q2)->q2[0]-q1[0]);
		int lmax[] = q.get(0);
		//右端で昇順にソート
		Collections.sort(q,(q1,q2)->q1[1]-q2[1]);
		int rmin[] = q.get(0);
		//幅で降順にソート
		Collections.sort(q,(q1,q2)->(q2[1]-q2[0])-(q1[1]-q1[0]));
		int wmax[] = q.get(0);
		//左端最大の区間と、右端最小の区間を同じコンテストに出題するとき
		if(N==2);//N=2なら何もしない
		else{
		int k=0;
		while(wmax==lmax|wmax==rmin){
			k++;
			wmax = q.get(k);
		}
		ans = Math.max((rmin[1]-lmax[0]+1),0) + (wmax[1]-wmax[0]+1);
		}
		//左端最大の区間と、右端最小の区間が異なるコンテストに出題するとき
		//左端で降順にソート
		Collections.sort(q,(q1,q2)->q2[0]-q1[0]);
		int remain_rmin = Integer.MAX_VALUE;
		int tmp_ans=0;
		for(int i=0;i<N;i++){
			int tmp[] = q.get(i);

			if(i<=1) remain_rmin = lmax[1] ;
			else{
				remain_rmin = Math.min(remain_rmin, q.get(i-1)[1]);
			}
			tmp_ans = Math.max((rmin[1]-tmp[0]+1),0) + Math.max((remain_rmin-lmax[0]+1),0);
			ans = Math.max(ans,tmp_ans);
 		}
		System.out.println(ans);
	}
}

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


Question:
import java.util.*;

public class Main {

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

		int score = 0;
		for(int i=0;i<S.length()-1;i++) {
			if(S.charAt(i)==S.charAt(i+1)) score++;
		}
		int ans = Math.min(score+2*K, N-1);

		System.out.println(ans);
	}
}

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


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

public class Main {
	static int mod = (int) 1e9 + 7;
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		long N = fs.nextInt(), M = fs.nextInt(), K = fs.nextInt();

		long sumM = (M-1)*M%mod*(M+1)%mod *((N*N)%mod);
		sumM %= mod;
		sumM = sumM * modpow(6, mod-2) % mod;

		long sumN = (N-1)*N%mod*(N+1)%mod *((M*M)%mod);
		sumN %= mod;
		sumN = sumN * modpow(6, mod-2) % mod;

		long comb = fermatComb(N*M-2, K-2);

		long ans = (sumM + sumN)%mod * comb %mod;
		System.out.println(ans);
	}

	//Fermat Combination
	static long fermatComb(long a, long b) {
		if (b > a - b)
			return fermatComb(a, a - b);
		long ansMul = 1, ansDiv = 1;
		for (int i = 0; i < b; i++) {
			ansMul *= (a - i);
			ansMul %= mod;
			ansDiv *= (i + 1);
			ansDiv %= mod;
		}
		long ans = ansMul * modpow(ansDiv, mod - 2) % mod;
		return ans;
	}

	//modの元での高速pow()
	static long modpow(long a, int p) {
		if (p == 0)
			return 1;
		if (p % 2 == 0) {
			int halfP = p / 2;
			long root = modpow(a, halfP);
			return root * root % mod;
		} else
			return a * modpow(a, p - 1) % mod;
	}

}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

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

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

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

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

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

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

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

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

Choices:
- Compile Error
- Time Limit Exceeded
- 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 T = sc.nextInt();
		int X = sc.nextInt();
		double ans = (double)T/X;
		System.out.println(ans);
	}
}

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


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

public class Main {
	static int mod = (int) 1e9 + 7;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = fs.nextIntArray(n);
//		int n = (int)1e5;
//		int a[] = new int[n];
//		Random random = new Random();
//		for(int i=0;i<n;i++) {
//			//a[i]=(int)1e9;
//			a[i] = random.nextInt((int)1e9);
//		}

		//iを取ろうとした時に、jが取られる確率

		int sum[] = new int[n];
		for(int i=1;i<n;i++) sum[i] = (int)plus(sum[i-1], div(1,i+1));

		long ans = 0;
		for(int i=0;i<n;i++) {
			int l = i;
			int r = n-1-i;
			long now = plus(sum[l], sum[r]);//i番目の箱が足される回数の期待値
			now = plus(now,1); //自分を取るときは確率1で取られる
			ans = plus(ans, mul(now, a[i]));
		}
		for(int i=1;i<=n;i++) {
			ans = mul(ans, i);
		}
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x + y) % mod;
		return res;
	}

	static long suv(long x, long y) {
		x %= mod;
		y %= mod;
		long res = (x - y + mod) % mod;
		return res;
	}

	static long mul(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * y % mod;
		return res;
	}

	static long div(long x, long y) {
		x %= mod;
		y %= mod;
		long res = x * modpow(y, mod - 2) % mod;
		return res;
	}

	//modの元での高速pow()
	static long modpow(long a, long p) {
		if (p == 0)
			return 1;
		if (p % 2 == 0) {
			long halfP = p / 2;
			long root = modpow(a, halfP);
			return root * root % mod;
		} else
			return a * modpow(a, p - 1) % mod;
	}

}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

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

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

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

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

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

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

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

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

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


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

public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      int N=sc.nextInt();
      int K=sc.nextInt();
      int R=sc.nextInt();
      int S=sc.nextInt();
      int P=sc.nextInt();
      String t=sc.next();
      int dp[]=new int[N+K];
      int ans=0;

      for(int i=0;i<N;i++){
          char op=t.charAt(i);
          int cand=0;
          switch (op) {
              case 'r':
                  cand=1;
                  break;
              case 's':
                  cand=2;
                  break;
              case 'p':
                  cand=3;
                  break;
          }
          if(dp[i]!=cand){
              dp[i+K]=cand;
              switch (cand) {
                  case 1:
                      ans+=P;
                      break;
                  case 2:
                      ans+=R;
                      break;
                  case 3:
                      ans+=S;
                      break;
              }
          }
      }

      out.println(ans);
      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
- Time Limit Exceeded
- No abnormally found
- Memory Limit Exceeded


Question:
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = Integer.parseInt(sc.next());
	int M = Integer.parseInt(sc.next());
	int C = Integer.parseInt(sc.next());
	int[] b = new int[M];
	for(int i = 0; i<M; i++) {
	    b[i] = Integer.parseInt(sc.next());
	}
	int cnt = 0;
	for(int i = 0; i<N; i++) {
	    int tmp = 0;
	    for(int j = 0; j<M; j++) {
		tmp += sc.nextInt() * b[j];
	    }
	    tmp += C;
	    if(tmp>0) cnt++;
	}
	System.out.println(cnt);
    }
}

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


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

public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<Key> keys = new ArrayList<>();
        for(int i = 0; i < m; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int t = 0;
            for(int j = 0; j < b; j++){
                t += 1 << (sc.nextInt()-1);
            }
            keys.add(new Key(a,b,t));
        }
        int[][] dp = new int[m+1][1 << n];
        for(int i = 0; i <= m; i++){
            Arrays.fill(dp[i],Integer.MAX_VALUE/2);
        }
        dp[0][0] = 0;
        for(int i = 0; i < m; i++){
            Key k = keys.get(i);
            for(int j = 0; j < (1 << n); j++){
                dp[i+1][j] = Math.min(dp[i+1][j],dp[i][j]);
                dp[i+1][j | k.t] = Math.min(dp[i+1][j | k.t], dp[i][j] + k.c);
            }
        }
        System.out.println(dp[m][(1 << n)-1] == Integer.MAX_VALUE/2 ? -1 : dp[m][(1 << n)-1]);
    }
}

class Key{
    int c, o, t;
    public Key(int c, int o, int t){
        this.c = c;
        this.o = o;
        this.t = t;
    }
}

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

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

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

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

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

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

    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

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

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

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


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

public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<Key> keys = new ArrayList<>();
        for(int i = 0; i < m; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int t = 0;
            for(int j = 0; j < b; j++){
                t += 1 << (sc.nextInt()-1);
            }
            keys.add(new Key(a,b,t));
        }
        int[][] dp = new int[m+1][1 << n];
        for(int i = 0; i <= m; i++){
            Arrays.fill(dp[i],Integer.MAX_VALUE/2);
        }
        dp[0][0] = 0;
        for(int i = 0; i < m; i++){
            Key k = keys.get(i);
            for(int j = 0; j < (1 << n); j++){
                dp[i+1][j] = Math.min(dp[i+1][j],dp[i][j]);
                dp[i+1][j | k.t] = Math.min(dp[i+1][j | k.t], dp[i][j] + k.c);
            }
        }
        System.out.println(dp[m][(1 << n)-1] == Integer.MAX_VALUE/2 ? -1 : dp[m][(1 << n)-1]);
    }
}

class Key{
    int c, o, t;
    public Key(int c, int o, int t){
        this.c = c;
        this.o = o;
        this.t = t;
    }
}

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

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

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

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

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

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

    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

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

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

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


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

public class Main {
	public static void main(String[] args) {
	    FastScanner sc = new FastScanner(System.in);
	    PrintWriter pw = new PrintWriter(System.out);
	    long mod = (long)1e9 + 7;
		char[] s = sc.next().toCharArray();
		int n = s.length;
		long[][] dp = new long[n + 1][4];
		dp[0][3] = 1;
		for(int i = n; i >= 0; --i){
            for(int j = 3; j >= 0; --j){
                if(i == n){
                    dp[i][j] = (j == 3 ? 1 : 0);
                }else{
                    dp[i][j] = dp[i+1][j] * (s[i] == '?' ? 3L : 1L);
                    if(j < 3 && (s[i] == '?' || s[i] == "ABC".charAt(j))){
                        dp[i][j] += dp[i+1][j+1];
                    }
                    dp[i][j] %= mod;
                }
            }
        }
        pw.println(dp[0][0]);
        pw.flush();
	}
}

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

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

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

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

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

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

    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

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

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

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


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

public class Main {
	public static void main(String[] args) {
	    FastScanner sc = new FastScanner(System.in);
	    PrintWriter pw = new PrintWriter(System.out);
	    long mod = (long)1e9 + 7;
		char[] s = sc.next().toCharArray();
		int n = s.length;
		long[][] dp = new long[n + 1][4];
		dp[0][3] = 1;
		for(int i = n; i >= 0; --i){
            for(int j = 3; j >= 0; --j){
                if(i == n){
                    dp[i][j] = (j == 3 ? 1 : 0);
                }else{
                    dp[i][j] = dp[i+1][j] * (s[i] == '?' ? 3L : 1L);
                    if(j < 3 && (s[i] == '?' || s[i] == "ABC".charAt(j))){
                        dp[i][j] += dp[i+1][j+1];
                    }
                    dp[i][j] %= mod;
                }
            }
        }
        pw.println(dp[0][0]);
        pw.flush();
	}
}

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

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

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

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

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

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

    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

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

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

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


Question:
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int a = s / 1000;
        int b = s / 100 - 10 * a;
        int c = s / 10 - s / 100 * 10;
        int d = s - s / 10 * 10 ;
        if(a == b || b == c || c == d){
            System.out.println("Bad");
        }else{
            System.out.println("Good");
        }
        sc.close();
    }
}

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


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

public class Main {

	class Node implements Comparable<Node>{
		int left, right;

		public Node(int left, int right) {
			this.left  = left;
			this.right = right;
		}

		@Override
		public int compareTo(Node o) {
			return right - o.right;
		}
	}

	public Main() {
		PrintWriter PW = new PrintWriter(System.out);
		FastScanner scanner = new FastScanner();
		int H = scanner.nextInt();
		int W = scanner.nextInt();

		TreeSet<Node>             nodeSet  = new TreeSet<>();
		TreeMap<Integer, Integer> costMap  = new TreeMap<>();

		for (int i = 1; i <= W; i++) {
			nodeSet.add(new Node(i, i));
		}
		costMap.put(0, W);

		Node A = new Node(0,0);
		Node B = new Node(0,0);
		for (int h = 1; h <= H; h++) {
			A.right = scanner.nextInt();
			B.right = scanner.nextInt() + 1;

			SortedSet<Node> sub = nodeSet.subSet(A, B);

			if (!sub.isEmpty()) {

				for (Node node : sub){
					int cost = node.right - node.left;
					int num  = costMap.get(cost);
					if (num != 1) {
						costMap.put(cost, num - 1);
					} else {
						costMap.remove(cost);
					}
				}

				Node node = sub.last();
				sub.clear();

				if (B.right != W+1) {
					node.right = B.right;
					if ( nodeSet.add(node) ) {
						int cost = node.right - node.left;
						costMap.put(cost, costMap.getOrDefault(cost,0)+1);
					}
				}

			}

			if (costMap.isEmpty()) {
				PW.println(-1);
			} else {
				PW.println(costMap.firstKey() + h);
			}
		}

		PW.close();
	}

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

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

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

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

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

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

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

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

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

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

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


Question:
public class Main {
    public static void main(String args[]) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        if ((B - A) % 2 == 0) {
            System.out.println("Alice");
        } else {
            System.out.println("Borys");
        }
    }
}

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


Question:
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();
        int N, K;
        {int[] a = r.ii(); N = a[0]; K = a[1];}
        int[] V = r.ii();
        int R = Math.min(N, K);
        int max = 0;
        for(int a = 0; a <= R; a++){
            for(int b = 0; b <= R-a; b++){
                int[] v = new int[a+b];
                for(int i = 0; i < a; i++)
                    v[i] = V[i];
                for(int i = N-b; i < N; i++)
                    v[a+i-(N-b)] = V[i];
                Arrays.sort(v);
                int lmt = Math.min(K-a-b,v.length);
                for(int i = 0; i < lmt && v[i] < 0; i++)
                    v[i] = 0;
                int sum = 0;
                for(int t : v)
                    sum += t;
                if(max < sum)
                    max = sum;
            }
        }
        println(max);
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);
            return ll;
        }
    }
}

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


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

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


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

public class Main {
  static Scanner sc = new Scanner(System.in);
  static long MOD = 998244353;
  static HashMap<Long, Long> memo = new HashMap<>();

  public static void main(String[] args) {
    char[] s = sc.next().toCharArray();
    int N = s.length;
    boolean[] S = new boolean[N];
    for (int i = 0; i < N; i++) {
      S[i] = s[i] == '1';
    }
    System.out.println(solve(S));
  }

  static long solve(boolean[] s) {
    int N = s.length;
    long key = 0;
    if (N < 50) {
      key |= (long)N << 55;
      for (int i = 0; i < N; i++) {
        if (s[i]) key |= (1L << i);
      }
      if (memo.containsKey(key)) return memo.get(key);
    }
    long[][] count = new long[N][N];
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        boolean[] cs = new boolean[j - i + 1];
        for (int k = i; k <= j; k++) {
          cs[k - i] = s[k];
        }
        count[i][j] = count(cs);
      }
    }
//    for (int i = 0; i < N; i++) {
//      for (int j = i + 1; j < N; j++) {
//        System.err.println("i:" + i + " j:" + j + " " + count[i][j]);
//      }
//    }
//    System.err.println("");
    long[] dp = new long[N + 1];
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
      dp[i] %= MOD;
      if (s[i]) {
        dp[i + 1] += dp[i] * 2;
      } else {
        dp[i + 1] += dp[i];
      }
      for (int j = i; j < N; j++) {
        dp[j + 1] += dp[i] * count[i][j] % MOD;
      }
//      System.err.println(Arrays.toString(dp));
    }
    dp[N] %= MOD;
    if (N < 50) {
      memo.put(key, dp[N]);
    }
    return dp[N];
  }

  static long count(boolean[] s) {
    long ret = 0;
    for (int i = 2; i <= s.length; i++) {
      if (s.length % i != 0) continue;
      boolean[] sub = new boolean[s.length / i];
      Arrays.fill(sub, true);
      for (int j = 0; j < s.length; j++) {
        sub[j % sub.length] &= s[j];
      }
      ret += solve(sub);
      if (ret >= MOD) ret -= MOD;
    }
    return ret;
  }
}

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


Question:
import java.util.*;
public class Main {
	public static long ans[];
	public static boolean ok[];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int sLen = s.length();
		int tLen = t.length();

		s = repeat(new StringBuilder(s), (int)Math.max(2, Math.ceil(tLen * 2.0 / sLen))).toString();

		ans = new long[sLen];
		Arrays.fill(ans, -1);
		ok = new boolean[sLen];
		Arrays.fill(ok, false);

		ArrayList<Integer> matchIndex = kmp(s, t);
		for(int i = 0; i < matchIndex.size(); i ++) {
			ok[matchIndex.get(i) % sLen] = true;
		}
		long max = 0;
		for(int i = 0; i < sLen; i ++) {
			max = Math.max(max, solve(i, sLen, tLen));
		}
		System.out.println(max);
	}

	static StringBuilder repeat(StringBuilder s, long y) {
		if (y == 0) {
			return new StringBuilder();
		} else if (y == 1) {
			return new StringBuilder(s);
		} else if (y % 2 == 0) {
			StringBuilder tmp = repeat(s, y / 2);
			tmp.append(tmp);
			return tmp;
		} else {
			StringBuilder tmp = repeat(s, y / 2);
			tmp.append(tmp);
			tmp.append(s);
			return tmp;
		}
	}

	static long solve(int i, int sLen, int tLen) {
		i %= sLen;
		if(ans[i] == -2) {
			System.out.println(-1);
			System.exit(0);
		}else if(ans[i] == -1) {
			ans[i] = -2;
			ans[i] = (ok[i] ? (solve(i + tLen, sLen, tLen) + 1) : 0);
		}
		return ans[i];
	}

	static ArrayList<Integer> kmp(String s, String p) {

		int sLen = s.length();
		int sInt[] = new int[sLen];
		for(int i = 0; i < sLen; i ++) {
			sInt[i] = s.charAt(i) - 'a';
		}
		int pLen = p.length();
		int pInt[] = new int[pLen];
		for(int i = 0; i < pLen; i ++) {
			pInt[i] = p.charAt(i) - 'a';
		}

		int sIndex = 1;
		int pIndex = 0;

		int skip[] = new int[pLen + 1];
		Arrays.fill(skip, 0);
		while(sIndex < pLen) {
			if(pInt[sIndex] == pInt[pIndex]) {
				sIndex ++;
				pIndex ++;
				skip[sIndex] = pIndex;
			}else if(pIndex == 0) {
				sIndex ++;
				skip[sIndex] = 0;
			}else {
				pIndex = skip[pIndex];
			}
		}

		ArrayList<Integer> matchIndex = new ArrayList<Integer>();
		sIndex = 0;
		pIndex = 0;
		end: while(true) {
			while(sIndex < sLen && pIndex < pLen && sInt[sIndex] == pInt[pIndex]) {
				sIndex ++;
				pIndex ++;
			}
			if(pIndex >= pLen) {
				matchIndex.add(sIndex - pLen);
				pIndex = skip[pIndex];
			}else if(pIndex == 0){
				sIndex ++;
			}else {
				pIndex = skip[pIndex];
			}
			if(sIndex >= sLen) { break end; }
		}
		return matchIndex;
	}
}

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


Question:
import java.util.*;
public class Main {
	public static long ans[];
	public static boolean ok[];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int sLen = s.length();
		int tLen = t.length();

		s = repeat(new StringBuilder(s), (int)Math.max(2, Math.ceil(tLen * 2.0 / sLen))).toString();

		ans = new long[sLen];
		Arrays.fill(ans, -1);
		ok = new boolean[sLen];
		Arrays.fill(ok, false);

		ArrayList<Integer> matchIndex = kmp(s, t);
		for(int i = 0; i < matchIndex.size(); i ++) {
			ok[matchIndex.get(i) % sLen] = true;
		}
		long max = 0;
		for(int i = 0; i < sLen; i ++) {
			max = Math.max(max, solve(i, sLen, tLen));
		}
		System.out.println(max);
	}

	static StringBuilder repeat(StringBuilder s, long y) {
		if (y == 0) {
			return new StringBuilder();
		} else if (y == 1) {
			return new StringBuilder(s);
		} else if (y % 2 == 0) {
			StringBuilder tmp = repeat(s, y / 2);
			tmp.append(tmp);
			return tmp;
		} else {
			StringBuilder tmp = repeat(s, y / 2);
			tmp.append(tmp);
			tmp.append(s);
			return tmp;
		}
	}

	static long solve(int i, int sLen, int tLen) {
		i %= sLen;
		if(ans[i] == -2) {
			System.out.println(-1);
			System.exit(0);
		}else if(ans[i] == -1) {
			ans[i] = -2;
			ans[i] = (ok[i] ? (solve(i + tLen, sLen, tLen) + 1) : 0);
		}
		return ans[i];
	}

	static ArrayList<Integer> kmp(String s, String p) {

		int sLen = s.length();
		int sInt[] = new int[sLen];
		for(int i = 0; i < sLen; i ++) {
			sInt[i] = s.charAt(i) - 'a';
		}
		int pLen = p.length();
		int pInt[] = new int[pLen];
		for(int i = 0; i < pLen; i ++) {
			pInt[i] = p.charAt(i) - 'a';
		}

		int sIndex = 1;
		int pIndex = 0;

		int skip[] = new int[pLen + 1];
		Arrays.fill(skip, 0);
		while(sIndex < pLen) {
			if(pInt[sIndex] == pInt[pIndex]) {
				sIndex ++;
				pIndex ++;
				skip[sIndex] = pIndex;
			}else if(pIndex == 0) {
				sIndex ++;
				skip[sIndex] = 0;
			}else {
				pIndex = skip[pIndex];
			}
		}

		ArrayList<Integer> matchIndex = new ArrayList<Integer>();
		sIndex = 0;
		pIndex = 0;
		end: while(true) {
			while(sIndex < sLen && pIndex < pLen && sInt[sIndex] == pInt[pIndex]) {
				sIndex ++;
				pIndex ++;
			}
			if(pIndex >= pLen) {
				matchIndex.add(sIndex - pLen);
				pIndex = skip[pIndex];
			}else if(pIndex == 0){
				sIndex ++;
			}else {
				pIndex = skip[pIndex];
			}
			if(sIndex >= sLen) { break end; }
		}
		return matchIndex;
	}
}

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


Question:
import java.util.*;
public class Main {
	public static long ans[];
	public static boolean ok[];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int sLen = s.length();
		int tLen = t.length();

		s = repeat(new StringBuilder(s), (int)Math.max(2, Math.ceil(tLen * 2.0 / sLen))).toString();

		ans = new long[sLen];
		Arrays.fill(ans, -1);
		ok = new boolean[sLen];
		Arrays.fill(ok, false);

		ArrayList<Integer> matchIndex = kmp(s, t);
		for(int i = 0; i < matchIndex.size(); i ++) {
			ok[matchIndex.get(i) % sLen] = true;
		}
		long max = 0;
		for(int i = 0; i < sLen; i ++) {
			max = Math.max(max, solve(i, sLen, tLen));
		}
		System.out.println(max);
	}

	static StringBuilder repeat(StringBuilder s, long y) {
		if (y == 0) {
			return new StringBuilder();
		} else if (y == 1) {
			return new StringBuilder(s);
		} else if (y % 2 == 0) {
			StringBuilder tmp = repeat(s, y / 2);
			tmp.append(tmp);
			return tmp;
		} else {
			StringBuilder tmp = repeat(s, y / 2);
			tmp.append(tmp);
			tmp.append(s);
			return tmp;
		}
	}

	static long solve(int i, int sLen, int tLen) {
		i %= sLen;
		if(ans[i] == -2) {
			System.out.println(-1);
			System.exit(0);
		}else if(ans[i] == -1) {
			ans[i] = -2;
			ans[i] = (ok[i] ? (solve(i + tLen, sLen, tLen) + 1) : 0);
		}
		return ans[i];
	}

	static ArrayList<Integer> kmp(String s, String p) {

		int sLen = s.length();
		int sInt[] = new int[sLen];
		for(int i = 0; i < sLen; i ++) {
			sInt[i] = s.charAt(i) - 'a';
		}
		int pLen = p.length();
		int pInt[] = new int[pLen];
		for(int i = 0; i < pLen; i ++) {
			pInt[i] = p.charAt(i) - 'a';
		}

		int sIndex = 1;
		int pIndex = 0;

		int skip[] = new int[pLen + 1];
		Arrays.fill(skip, 0);
		while(sIndex < pLen) {
			if(pInt[sIndex] == pInt[pIndex]) {
				sIndex ++;
				pIndex ++;
				skip[sIndex] = pIndex;
			}else if(pIndex == 0) {
				sIndex ++;
				skip[sIndex] = 0;
			}else {
				pIndex = skip[pIndex];
			}
		}

		ArrayList<Integer> matchIndex = new ArrayList<Integer>();
		sIndex = 0;
		pIndex = 0;
		end: while(true) {
			while(sIndex < sLen && pIndex < pLen && sInt[sIndex] == pInt[pIndex]) {
				sIndex ++;
				pIndex ++;
			}
			if(pIndex >= pLen) {
				matchIndex.add(sIndex - pLen);
				pIndex = skip[pIndex];
			}else if(pIndex == 0){
				sIndex ++;
			}else {
				pIndex = skip[pIndex];
			}
			if(sIndex >= sLen) { break end; }
		}
		return matchIndex;
	}
}

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


Question:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		prepareFact();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int sum = m * 3;
		long ans = combiMod(n - 1 + sum, n - 1);
		for(int i = m * 2 + 1; i <= sum; i ++) {
			long tmp = combiMod(n - 2 + (sum - i), n - 2);
			tmp = mod(tmp * (long)n);
			ans = mod(ans - tmp);
		}

		long minus = 0;
		for(int i = m + 2; i <= n; i += 2) {
			long tmp = permMod(n - 1 + (sum - i) / 2, n - 1);
			tmp = mod(tmp * combiMod(n, i));
			minus = mod(minus + tmp);
		}
		minus = mod(minus * invMod(factMod[n - 1]));
		ans = mod(ans - minus);
		System.out.println(ans);
	}

	static long MOD = 998244353;
	public static long mod(long i) {
		return i % MOD + ((i % MOD) < 0 ? MOD : 0);
	}

	static long powerMod(long x, long y) {
		if (y == 0) {
			return 1;
		} else if (y == 1) {
			return x;
		} else if (y % 2 == 0) {
			long tmp = powerMod(x, y / 2);
			return mod(tmp * tmp);
		} else {
			long tmp = powerMod(x, y / 2);
			return mod(mod(tmp * tmp) * x);
		}
	}

	static long invMod(long x) {
		return powerMod(x, MOD - 2);
	}

	static int MAX_FACT = 2_500_100;
	static long factMod[] = new long[MAX_FACT];
	static void prepareFact() {
		factMod[0] = 1;
		for(int i = 1; i < MAX_FACT; i ++) {
			factMod[i] = mod(factMod[i - 1] * i);
		}
	}

	static long combiMod(int n, int r) {
		if(n < 0 || n < r) { return 0; }
		if(r == 0 || r == n) { return 1; }
		return mod(mod(factMod[n] * invMod(factMod[r])) * invMod(factMod[n - r]));
	}

	static long permMod(int n, int r) {
		if(n < 0 || n < r) { return 0; }
		if(r == 0) { return 1; }
		return mod(factMod[n] * invMod(factMod[n - r]));
	}
}

Choices:
- No abnormally found
- Runtime 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);
		prepareFact();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int sum = m * 3;
		long ans = combiMod(n - 1 + sum, n - 1);
		for(int i = m * 2 + 1; i <= sum; i ++) {
			long tmp = combiMod(n - 2 + (sum - i), n - 2);
			tmp = mod(tmp * (long)n);
			ans = mod(ans - tmp);
		}

		long minus = 0;
		for(int i = m + 2; i <= n; i += 2) {
			long tmp = permMod(n - 1 + (sum - i) / 2, n - 1);
			tmp = mod(tmp * combiMod(n, i));
			minus = mod(minus + tmp);
		}
		minus = mod(minus * invMod(factMod[n - 1]));
		ans = mod(ans - minus);
		System.out.println(ans);
	}

	static long MOD = 998244353;
	public static long mod(long i) {
		return i % MOD + ((i % MOD) < 0 ? MOD : 0);
	}

	static long powerMod(long x, long y) {
		if (y == 0) {
			return 1;
		} else if (y == 1) {
			return x;
		} else if (y % 2 == 0) {
			long tmp = powerMod(x, y / 2);
			return mod(tmp * tmp);
		} else {
			long tmp = powerMod(x, y / 2);
			return mod(mod(tmp * tmp) * x);
		}
	}

	static long invMod(long x) {
		return powerMod(x, MOD - 2);
	}

	static int MAX_FACT = 2_500_100;
	static long factMod[] = new long[MAX_FACT];
	static void prepareFact() {
		factMod[0] = 1;
		for(int i = 1; i < MAX_FACT; i ++) {
			factMod[i] = mod(factMod[i - 1] * i);
		}
	}

	static long combiMod(int n, int r) {
		if(n < 0 || n < r) { return 0; }
		if(r == 0 || r == n) { return 1; }
		return mod(mod(factMod[n] * invMod(factMod[r])) * invMod(factMod[n - r]));
	}

	static long permMod(int n, int r) {
		if(n < 0 || n < r) { return 0; }
		if(r == 0) { return 1; }
		return mod(factMod[n] * invMod(factMod[n - r]));
	}
}

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


Question:
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (long n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void printArray(int[] a) {
		for(int i=0;i<a.length-1;i++) {
		System.out.print(a[i]+" ");
		}
		System.out.println(a[a.length-1]);
	}
	public static void main(String[] args) {
		String str=scan.next();
		long b=scan.nextLong();
		if(str.length()==1) {
			System.out.println(b/2);
			return;
		}
		if(str.length()==2) {
			if(str.charAt(0)==str.charAt(1)) {
				System.out.println(b);
			}
			else {
				System.out.println(0);
			}
			return;
		}
		long cnt=1;
		long ans=0;
		long sum=0;
		String fir="";
		fir+=str.charAt(0);
		str=str.substring(1,str.length());
		for(int i=0;i<str.length();) {
			if(str.charAt(0)==fir.charAt(fir.length()-1)) {
				fir+=str.charAt(0);
				str=str.substring(1,str.length());
			}
			else {
				break;
			}
		}
		String las="";
		if(str.length()>0) {
		las+=str.charAt(str.length()-1);
		str=str.substring(0,str.length()-1);
		}
		for(int i=str.length()-1;i>=0;) {
			if(str.charAt(i)==las.charAt(0)) {
				las+=str.charAt(i);
				str=str.substring(0,str.length()-1);
				i--;
			}
			else {
				break;
			}
		}
		for(int i=1;i<str.length();i++) {
			char ch=str.charAt(i-1);
			char ch2=str.charAt(i);
			if(ch==ch2) {
				cnt++;
			}
			else {
				sum+=cnt/2;
				cnt=1;
			}
		}
		sum+=cnt/2;
		ans+=sum*b;
		if(las.length()>0) {
			if(fir.charAt(0)==las.charAt(0)) {
			long uouo=0;
			uouo+=fir.length()/2;
			uouo+=las.length()/2;
			uouo+=(fir.length()+las.length())/2*(b-1);
			ans+=uouo;
		}
		else {
			long uouo=0;
			uouo+=fir.length()/2*b;
			uouo+=las.length()/2*b;
			ans+=uouo;
		}
		}
		else {
			ans+=fir.length()*b/2;
		}
		System.out.println(ans);
	}
}

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