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

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

		slover();
		out.flush();
	}
	static FastScanner sc = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);
	//StringBuffer S = new StringBuffer(sc.next());
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)
	//Map<Integer, Integer> map = new HashMap<Integer, Integer>(N);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );

		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek BFSは前から実行される
	//Deque<String> dd=new ArrayDeque<>();//push後ろに入れる,poll(pop)後ろからとる,peek addは先頭に入るからバグ注意
	//stackdfsは後ろから実行される
	//ArrayList<Integer> cc = new ArrayList<>(N);
	//cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5

	private static void slover() {
	int a=sc.nextInt();
	int b=sc.nextInt();
	p((a-1)*(b-1));
	}

	static long Nsin(long t) {
		long sum=0;
		long v=1;
		long tt=1;
		for(long k=0;k<(t+"").length();k++) {
			sum+=(t%(tt*10)-t%tt)/tt*v;
			v*=t;
			tt*=10;
		}
		return sum;
	}

	static long so(long n) {
		for(long i=2;i*i<=n;i++) {
			if(n%i==0) {
				return i;
			}
		}
		return 0;

	}

	     static void nibun(int a,int b,int target) {

	    	 int ok=a;
	    	 int ng=b;

	    	 int t=2;

	    	 while(a<b) {
	    		 int G=(ok+ng)/2;
	    		 if(t==target) {
	    			 break;
	    		 }
	    		 if(t>ok) {

	    		 }
	    		 if(t>ng) {

	    		 }

	    	 }

	     }

		//StringBuffer str = new StringBuffer(sc.nextInt());
		//for(int i=0;i<N;i++) {}

			//	p("===================");
				//for(int f:gyo.keySet()){
				    //p(gyo.get(f));
			//	}
			//	p("===================");

	static void p(String ans) {out.println(ans);};
	static void p(int ans) {out.println(ans);};
	static void p() {out.println();};
	static void p(long ans) {out.println(ans);};
	static void p(double ans) {out.println(ans);};

	static void pn(String ans) {out.print(ans);};
	static void pn(int ans) {out.print(ans);};
	static void pn() {out.print("");};
	static void pn(long ans) {out.print(ans);};
	static void pn(double ans) {out.print(ans);};

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

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

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

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

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

	    public boolean hasNext() {
	      skipUnprintable();
	      return hasNextByte();
	    }

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

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

	    public int nextInt() {
	      return (int) nextLong();
	    }

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

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

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

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


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

public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );

		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);

	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];

			int N=sc.nextInt();

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

			long sum=0;

			for(int i=N-1;i>=0;i--) {
				a[i]=a[i]-sum%b[i];
				if(a[i]<0) {
					a[i]+=b[i];

				}
				a[i]%=b[i];
				//p(sum);
				sum+=a[i];
			}

			p(sum);
		}

	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long lcm(long n, long m) {
        return n / gcd(n, m) * m;
}

	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};

}

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


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

	static int r;
	static int s;
	static int p;

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

		int n = sc.nextInt();
		int k = sc.nextInt();

		r = sc.nextInt();
		s = sc.nextInt();
		p = sc.nextInt();

		char []hand = sc.next().toCharArray();

		int [][]dp = new int [n+1][2];

		for(int i = 0 ; i < n ;i++) {
			if(i - k < 0) {
				dp[i][1] += jdg(hand[i]);
			}
			else {
				if(hand[i] != hand[i-k]) {
					dp[i][1] += jdg(hand[i]) + Math.max(dp[i-k][0], dp[i-k][1]);
				}
				else{
					dp[i][1] += dp[i-k][0] + jdg(hand[i]);
					dp[i][0] += dp[i-k][1];
				}
			}
		}

		int ans = 0;

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

		System.out.println(ans);

	}
	static int jdg(char k) {
		if(k == 'r') {
			return p;
		}
		if(k == 's') {
			return r;
		}
			return s;
	}

}

Choices:
- Runtime Error
- Compile 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);

		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		int []a = new int [n];

		for(int i = 0 ; i < m ;i++) {
			int p = Integer.parseInt(sc.next())-1;
			int q = Integer.parseInt(sc.next())-1;
			a[p]++;
			a[q]++;
		}

		for(int i = 0 ; i < n ;i++) {
			if(a[i] % 2 == 1) {
				System.out.println("NO");
				return;
			}
		}

		System.out.println("YES");

	}

}

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


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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt();
        initFac(n * m);
        long choose = nck(n * m - 2, k - 2);
        long first = m * ((long) m * (m - 1)) / 2;
        first %= mod;
        first = (first - (((long)m - 1) * m * (2 * m - 1)) / 6);
        if (first < 0) first += mod;
        first = (first * ((long) n * n)) % mod;
        long second = n * ((long) n * (n - 1)) / 2;
        second %= mod;
        second = (second - (((long)n - 1) * n * (2 * n - 1)) / 6);
        if (second < 0) second += mod;
        second = (second * ((long) m * m)) % mod;
        long res = (choose * ((first + second) % mod)) % mod;
        res %= mod;
        if (res < 0) res += mod;
        out.println(res);
        out.close();
    }

    static long[] fac;
    static long mod = (long) 1e9 + 7;

    static void initFac(long n) {
        fac = new long[(int)n + 1];
        fac[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = (fac[i - 1]  * i) % mod;
        }
    }

    static long nck(int n, int k) {
        if (n < k)
            return 0;
        long den = inv((int) (fac[k] * fac[n - k] % mod));
        return fac[n] * den % mod;
    }

    static long pow(long b, long e) {
        long ans = 1;
        while (e > 0) {
            if (e % 2 == 1)
                ans = ans * b % mod;
            e >>= 1;
            b = b * b % mod;
        }
        return ans;
    }

    static long inv(long x) {
        return pow(x, mod - 2);
    }

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


Question:
import java.util.*;

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

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

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

    Arrays.sort(a);
    int ans = 0;

    for (int i = 0; i < N; i++) {
      x -= a[i];

      if (x < 0) {
        ans = i;
        break;
      } else if (x == 0) {
        ans = i+1;
      }
    }

    if (x > 0) {
      ans = N - 1;
    }

    System.out.println(ans);
  }
}

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


Question:
import java.math.*;
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
	  Scanner in=new Scanner(System.in);
    BigInteger b=in.nextBigInteger();
    if(b.isProbablePrime(70)==true)
    {
      System.out.println(b);
    }
    else
    {
      System.out.println(b.nextProbablePrime());
    }
  }
}

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


Question:
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;
import java.awt.*;

public class Main{

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

        int n = sc.nextInt();
        PriorityQueue<Long> pribig = new PriorityQueue<>(Comparator.naturalOrder());
        PriorityQueue<Long> prismall = new PriorityQueue<>(Comparator.reverseOrder());
        long big = 0;
        long small = 0;
        long b = 0;
        long ans;
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            if (tmp == 1) {
                // koushin
                long a = sc.nextLong();
                long bb = sc.nextLong();
                b += bb;
                if (prismall.isEmpty() || prismall.peek() >= a) {
                    // prismall.peek -> pribig, a -> prismall
                    prismall.add(a);
                    small+=a;
                    if (!prismall.isEmpty() && prismall.size() > pribig.size() + 1 ) {
                        long change = prismall.poll();
                        pribig.add(change);
                        small -= change;
                        big += change;
                    }
                }else{
                    pribig.add(a);
                    big += a;
                    if (pribig.size() > prismall.size()) {
                        long odsends = pribig.poll();
                        prismall.add(odsends);
                        big -= odsends;
                        small += odsends;
                    }
                }
            }else if(tmp == 2){
                // hanbetsu
                // small = big or small = big + 1
                ans = prismall.peek();
                System.out.println(ans + " " + (-small+big +prismall.size() * ans - pribig.size()* ans + b));
            }

        }

        sc.close();
    }

}

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


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

public class Main
{

    public static void process()throws IOException
    {
        int n=ni(),d=ni(),x[][]=new int[n][d];

        for(int i=0;i<n;i++)
            for(int j=0;j<d;j++)
                x[i][j]=ni();

        double dist;
        int res=0;

        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                dist=0.0d;

                for(int k=0;k<d;k++){
                    dist+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
                }

                dist=Math.sqrt(dist);
                if(dist-(long)dist==0)
                    res++;
            }
        }
        pn(res);
    }

    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();

        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();

        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
        System.out.close();
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;
    static long mod=(long)1e9+7l;

    static<T> void r_sort(T arr[],int n){
        Random r = new Random();
        for (int i = n-1; i > 0; i--){
            int j = r.nextInt(i+1);

            T temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
        Arrays.sort(arr);
    }

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            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();
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

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


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

public class Main {
    public static PrintWriter out;

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

    private static void run() {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        Scanner sc = new Scanner(System.in);
        int s = Integer.parseInt(sc.next());
        ArrayList<Integer> list = new ArrayList<>();
        list.add(s);
        for (int i = 1, answer = 0;; i++) {
            answer = Main.calcF(list.get(i - 1));
            if (list.contains(answer)) {
                out.println(i + 1);
                break;
            }
            list.add(answer);
        }
        out.close();
        sc.close();
    }

    private static int calcF(int pnum) {
        int n = pnum;
        if (n % 2 == 0) {
            return n / 2;
        } else {
            return 3 * n + 1;
        }
    }
}

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


Question:
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int[][] point = new int[N][D];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < D; j++) {
				point[i][j] = Integer.parseInt(sc.next());
			}
		}
		int count = 0;
		for (int i = 1; i < N; i++) {
			for (int j = 0; j < i; j++) {
				int distance_square = 0;
				for (int k = 0; k < D; k++) {
					int distance = point[i][k] - point[j][k];
					distance_square += distance * distance;
				}
				int distance_sqrt = (int) Math.sqrt(distance_square);
				if(distance_sqrt * distance_sqrt == distance_square) {
					count++;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}
}

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


Question:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int B[] = new int[N];
		int C[] = new int[N - 1];
		int answer = 0;

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

		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
			answer += B[i];
		}

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

		for (int i = 1; i < N; i++) {
			if (A[i - 1] + 1 == A[i]) {
				answer += C[A[i - 1] - 1];
			}
		}

		System.out.println(answer);
	}
}

Choices:
- Compile Error
- No abnormally found
- Internal 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 q=sc.nextInt();
		int h=n,w=n;
		int row[]=new int[h+1];
		int col[]=new int[w+1];
		Arrays.fill(row,w);
		Arrays.fill(col,h);
		long ans=(long)(n-2)*(n-2);
		while(q-->0) {
			int x=sc.nextInt();
			int y=sc.nextInt();
			if(x==1) {
				if(y<w) {
					for(int i=y;i<w;i++)
						col[i]=h;
					w=y;
				}
				ans-=(col[y]-2);
			}
			else {
				if(y<h) {
					for(int i=y;i<h;i++)
						row[i]=w;
					h=y;
				}
				ans-=(row[y]-2);
			}
		}
		System.out.println(ans);
	}
}

Choices:
- Compile 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 q=sc.nextInt();
		int h=n,w=n;
		int row[]=new int[h+1];
		int col[]=new int[w+1];
		Arrays.fill(row,w);
		Arrays.fill(col,h);
		long ans=(long)(n-2)*(n-2);
		while(q-->0) {
			int x=sc.nextInt();
			int y=sc.nextInt();
			if(x==1) {
				if(y<w) {
					for(int i=y;i<w;i++)
						col[i]=h;
					w=y;
				}
				ans-=(col[y]-2);
			}
			else {
				if(y<h) {
					for(int i=y;i<h;i++)
						row[i]=w;
					h=y;
				}
				ans-=(row[y]-2);
			}
		}
		System.out.println(ans);
	}
}

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


Question:
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

import java.util.*;
import java.util.Collections; // sorting use
import java.io.*;
import static java.lang.System.*;

public class Main{
	public static void main(String[] args){
	  int tmp;
		ArrayList<Integer> clz = new ArrayList<Integer>(203);
		Scanner sc = new Scanner(System.in);
		clz.add(sc.nextInt());

		for (int i = 1; i <= 200; ++i){
		  tmp = clz.get(i - 1);
		  if(tmp % 2 == 0) clz.add(tmp / 2);
		  else clz.add(3 * tmp + 1);

			if(clz.size() >= 4){
			  if(clz.get(i - 3) == clz.get(i)){
  				out.println(i + 1);
  				break;
			  }
			}
		}
	}
}

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


Question:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[n+1];
		int[] c = new int[n];
		int sum=0;
		for(int i=1;i<=n;i++) {
			a[i]=sc.nextInt();
		}
		for(int i=1;i<=n;i++) {
			b[i]=sc.nextInt();
		}
		for(int i=1;i<=n-1;i++) {
			c[i]=sc.nextInt();
		}
		for(int i=1;i<n;i++) {
			if(a[i+1]-a[i]==1) {
				sum=sum+b[a[i]]+c[a[i]];
			//	System.out.println(sum);
			}
			else {
				sum=sum+b[a[i]];
			//	System.out.println(sum);
			}
		}
		sum=sum+b[a[n]];
		System.out.println(sum);
	}

}

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


Question:
import java.util.*;

public class Main {
    public static int N;
    public static int M;
    public static List<Integer> k;
    public static List<List<Integer>> s;
    public static List<Integer> p;
    public static void main (String args[]){
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        M = scanner.nextInt();
        k = new ArrayList();
        s = new ArrayList();
        p = new ArrayList();
        for(int i=0; i<M; i++){
            int ki = scanner.nextInt();
            k.add(ki);
            List<Integer> si = new ArrayList();
            for(int j=0; j<ki; j++){
                si.add(scanner.nextInt());
            }
            s.add(si);
        }
        for(int i=0; i<M; i++){
            p.add(scanner.nextInt());
        }
        int numOK = 0;
        List<Integer> switches = new ArrayList();
        Queue<List<Integer>> queue = new ArrayDeque();
        List<Integer> states = new ArrayList(Arrays.asList(0,1));
        queue.add(switches);
        while( queue.size()>0 ){
            List<Integer> now = queue.poll();

            if(now.size() == N){
                int numOnBulb = 0;
                for(int i=0; i<M; i++){
                    int numOnSwitch = 0;
                    for(Integer sij:s.get(i)){
                        numOnSwitch = numOnSwitch + now.get(sij-1);
                    }
                    if(numOnSwitch%2 == p.get(i)){
                        numOnBulb++;
                    }
                }
                if(numOnBulb==M){
                    numOK++;
                }
            }
            else{
                for(Integer nextState:states){
                    List<Integer> next = new ArrayList(now);
                    next.add(nextState);
                    if(isOK(next)){
                        queue.offer(next);
                    }
                }
            }
        }
        System.out.println(numOK);
    }

    public static boolean isOK(List<Integer> next){
        // for(int i=0; i<M; i++){
        //     int maxS = Math.max(s.get(i));
        //     if(maxS <= next.size()){
        //         int sum = 0;
        //         for(int state:next){
        //             sum = sum + state;
        //         }
        //         if()
        //         return false;
        //     }
        // }
        return true;
    }
}

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


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

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

    static class ECellDistance {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), m = s.nextInt(), k = s.nextInt();
            long ans = 0, mod = (long) 1e9 + 7, n1 = (n * n) % mod, m1 = (m * m) % mod, fac[] = new long[n * m - 1];
            fac[0] = 1;
            for (int i = 1; i < m * n - 1; i++) {
                fac[i] = (fac[i - 1] * i) % mod;
            }
            long com = (fac[m * n - 2] * ((func.power(fac[k - 2], mod - 2, mod) * func.power(fac[m * n - k], mod - 2, mod)) % mod)) % mod;
            for (long i = 1; i < n; i++) {
                ans = (ans + (((i * (i + 1) >> 1) * m1) % mod)) % mod;
            }
            for (long i = 1; i < m; i++) {
                ans = (ans + (((i * (i + 1) >> 1) * n1) % mod)) % mod;
            }
            w.println((ans * com) % mod);
        }

    }

    static class func {
        public static long power(long x, long y, long p) {
            long res = 1;
            x = x % p;
            while (y > 0) {
                if ((y & 1) == 1)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

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

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

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


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

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


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

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

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


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

	static int MOD = 1000000007;

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

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

}

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


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

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

}

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


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

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

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

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

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

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


Question:
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int M=stdIn.nextInt();
		int k[][]=new int[M][N];
		int p[]=new int[M];
		int med[]=new int[N];
		String a="";
		int z=0,y=0,x=0,sum=0,ans=0;
		int fin=0;
		while(z<M){
			y=stdIn.nextInt();
			while(x<y){
				k[z][x]=stdIn.nextInt();
				x++;
			}x=0;
			z++;
		}z=0;y=0;
		while(z<M){
			p[z]=stdIn.nextInt();
			z++;
		}z=0;
		while(z<Math.pow(2,N)){
			a=Integer.toBinaryString(z);
			while(y<N){
				if(y>=a.length())
					med[y]=0;
				else
					if(a.charAt(a.length()-y-1)=='1')
						med[y]=1;
				y++;
			}y=0;
			while(y<M){
				while(x<N){
					if(k[y][x]==0)
						break;
					if(med[k[y][x]-1]==1)
						sum++;
					x++;
				}
				if(sum%2==p[y])
					fin++;
				if(fin!=y+1)
					break;
				y++;x=0;sum=0;
			}y=0;
			if(fin==M){
				ans++;
			}
			while(y<N){
				med[y]=0;
				y++;
			}y=0;
			z++;x=0;sum=0;fin=0;
		}
		System.out.println(ans);
	}
}

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


Question:
import java.util.Scanner;
import java.util.function.Function;

public class Main {
    private static final char[] MOVE = {'L', 'U', 'R', 'D'};

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

        final String s = scanner.next();
        final String t = scanner.next();

        final int[] initialValues = {sc, sr};
        final Function<Integer, Integer> decrement = i -> i - 1;
        final Function<Integer, Integer> increment = i -> i + 1;
        final Function[] operators = {decrement, decrement, increment, increment};
        final int[] limits = {w, h};
        for (int i = 0; i < MOVE.length; i++) {
            if (!isYes(initialValues[i % 2], operators[i], operators[(i + 2) % 4], n, limits[i % 2], s, t, i)) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }

    private static boolean isYes(final int initialValue, final Function<Integer, Integer> expression1, final Function<Integer, Integer> expression2, final int n, final int limit, final String s, final String t, final int tSelect) {
        int tmp = initialValue;
        for (int i = 0; i < n; i++) {
            final char si = s.charAt(i);
            if (si == MOVE[tSelect]) {
                tmp = expression1.apply(tmp);
            }
            if (!isInside(tmp, limit)) {
                return false;
            }
            final char ti = t.charAt(i);
            if (ti == MOVE[(tSelect + 2) % 4] && isInside(expression2.apply(tmp), limit)) {
                tmp = expression2.apply(tmp);
            }
        }
        return true;
    }

    private static boolean isInside(final int position, final int limit) {
        return 1 <= position && position <= limit;
    }
}

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


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

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


Question:
import java.util.*;

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

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

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


Question:
import java.util.*;

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

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

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


Question:
import java.util.*;

public class Main {
  static ArrayList[] edge;

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

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

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


Question:
import java.util.Scanner;

public class Main {

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

	}

}

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


Question:
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int D = in.nextInt();
            int[][] X = new int[N][D];
            for (int n = 0; n < N; n++) {
                for (int d = 0; d < D; d++) {
                    X[n][d] = in.nextInt();
                }
            }

            int count = 0;
            for (int n = 0; n < N; n++) {
                for (int n2 = n + 1; n2 < N; n2++) {
                    if (is(n, n2, X, D)) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }

    private static boolean is(int n, int n2, int[][] x, int D) {
        int sum = 0;
        for (int d = 0; d < D; d++) {
            int diff = x[n][d] - x[n2][d];
            sum += diff * diff;
        }

        for (int i = 0; i * i <= sum; i++) {
            if (i * i == sum) {
                return true;
            }
        }

        return false;
    }
}

Choices:
- Compile Error
- Internal 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 m = sc.nextInt();
    int[] box = new int[n];
    int[] red = new int[n];
    for(int i = 0;i<n;i++){
      box[i] = 1;
    }
    red[0]++;
    for(int i = 0;i<m;i++){
      int x = sc.nextInt()-1,y = sc.nextInt()-1;
      if(red[x]==1)red[y]=1;
      box[x]--;
      box[y]++;
      if(box[x]==0){
        red[x]=0;
      }
    }
    int count = 0;
    for(int i:red){
      if(i == 1)count++;
    }
    System.out.println(count);
  }
}

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


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

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int K = Integer.parseInt(sc.get());
		var mod = 1000000007;
		long sum = 0;
		var ints = new long[K];
		for (int i = K; i >= 1; i--) {
			int count = 0;
			long minus = 0;
			for (int j = i; j <= K; j+=i) {
				if (j % i != 0) continue;
				count += 1;
				minus = (minus + ints[j - 1]) % mod;
			}
			long pow = (modpow(count, N, mod) - minus) % mod;
			ints[i - 1] = pow = pow < 0 ? pow + mod : pow;
			sum = (sum + ((i * pow) % mod)) % mod;
		}
		System.out.println(sum % mod);
	}

	int gcd(int a, int b) {
	    return b == 0 ? a : gcd(b, a % b);
	}

	long modpow(long a, long n, long mod) {
		long res = 1;
		while (n > 0) {
			if ((n & 1) == 1) res = res * a % mod;
			a = a * a % mod;
			n >>= 1;
		}
		return res;
	}
}

class Main {
	public static void main(String... args) {
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			private StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}

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


Question:
import java.util.Scanner;

class Solver {
    void solve(Scanner sc) {
        String s = sc.next();

        int sum = 1;
        int head = 0, tail = 1;
        for (int i = 1; i < s.length(); i++) {
            int h = tail, t = i + 1;
            if (tail - head == t - h && s.charAt(i - h + head) == s.charAt(i)) continue;

            sum += 1;
            head = h;
            tail = t;
        }

        System.out.println(sum);
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);

        new Solver().solve(in);

        in.close();
    }
}

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


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

import static java.lang.System.in;

class Main{
    static int N;
    static long[] sum;
    public static void main(String[] args)throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String temp = reader.readLine();
        N = Integer.parseInt(temp.split(" ")[0]);
        sum = new long[N+1];
        temp = reader.readLine();
        String[] buf = temp.split(" ");
        for(int i=1;i<=N;i++) sum[i] = sum[i-1]+Long.parseLong(buf[i-1]);
        long ans = Long.MAX_VALUE;
        for(int i=2;i<=N-2;i++){
            long difLeft = halfClo(1,i);
            long P = (sum[i]+difLeft)/2;
            long Q = (sum[i]-difLeft)/2;
            long difRight = halfClo(i+1,N);
            long R = (sum[N]-sum[i]+difRight)/2;
            long S = (sum[N]-sum[i]-difRight)/2;
            long[] cur = new long[]{P,Q,R,S};
            Arrays.sort(cur);
            ans = Math.min(ans,cur[3]-cur[0]);
        }
        System.out.println(ans);
    }
    static long halfClo(int left, int right){
        long hi = sum[right]-sum[left-1];
        long lo = 0;
        while(hi-lo>1){
            long mid = (hi+lo)/2;
            if(check(left,right,mid)) hi = mid;
            else lo = mid;
        }
        return hi;
    }
    static boolean check(int left, int right, long target){
        long all = sum[right]-sum[left-1];
        int hi = right-1;
        int lo = left;
        while(hi-lo>1){
            int mid = (hi+lo)/2;
            long cur = sum[mid]-sum[left-1];
            if(2*cur>=all-target&&2*cur<=all+target) return true;
            if(2*cur<all-target) lo = mid;
            else hi = mid;
        }
        boolean b1 = 2*(sum[hi]-sum[left-1])>=all-target&&2*(sum[hi]-sum[left-1])<=all+target;
        boolean b2 = 2*(sum[lo]-sum[left-1])>=all-target&&2*(sum[lo]-sum[left-1])<=all+target;
        return b1||b2;
    }
}

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


Question:
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] dic = new String[H];
        for(int i=0;i<H;i++) dic[i]=sc.next();
        int end = -1;
        for(int i=0;i<H;i++){
            int left = 0;
            while(left<H&&dic[i].charAt(left)=='.') left++;
            if(end>left){
                System.out.println("Impossible");
                System.exit(0);
            }
            end = W-1;
            while(end>=0&&dic[i].charAt(end)=='.') end--;
        }
        System.out.println("Possible");
    }
}

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


Question:
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] dic = new String[H];
        for(int i=0;i<H;i++) dic[i]=sc.next();
        int end = -1;
        for(int i=0;i<H;i++){
            int left = 0;
            while(left<H&&dic[i].charAt(left)=='.') left++;
            if(end>left){
                System.out.println("Impossible");
                System.exit(0);
            }
            end = W-1;
            while(end>=0&&dic[i].charAt(end)=='.') end--;
        }
        System.out.println("Possible");
    }
}

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


Question:
// package agc.agc027;

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

public class Main {
    static long __startTime = System.currentTimeMillis();

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

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

        long total = T * n;
        for (int i = 0; i < n ; i++) {
            total += x[i] * 5;
        }
        total += T * n;

        long best = total;
        int L = 1;
        int R = n;
        for (int cur = 0 ; cur < 60 ; cur++) {
            int m1 = (L * 2 + R) / 3;
            int m2 = (L + R * 2) / 3;
            long c1 = canMakeHead(m1, x, T);
            long c2 = canMakeHead(m2, x, T);
            best = Math.min(best, total-c1);
            best = Math.min(best, total-c2);
            if (c1 < c2) {
                L = m1;
            } else {
                R = m2;
            }
        }
        for (int f = Math.max(1, L-5) ; f <= Math.min(n, R+5) ; f++) {
            best = Math.min(best, total-canMakeHead(f, x, T));
        }
        out.println(best);
        out.flush();
    }

    private static long canMakeHead(int head, long[] x, long t) {
        int n = x.length;
        long dec = t * (n - head);
        long additionalCost = 0;

        long[] col = new long[head];
        for (int i = 0 ; i < n ; i++) {
            int cur = i / head;
            if (cur >= 2) {
                col[i%head] += x[i-2*head];
                additionalCost += col[i%head] * 2;
            }
        }
        return dec-additionalCost;
    }

    private static void printTime(String label) {
        debug(label, System.currentTimeMillis() - __startTime);
    }

    private static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

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

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

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

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

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


Question:
// package atcoder.agc.agc018;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.PriorityQueue;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int x = in.nextInt();
        int y = in.nextInt();
        int z = in.nextInt();
        int n = x + y + z;
        long[][] abc = in.nextLongTable(n, 3);

        Arrays.sort(abc, (u, v) -> Long.compare(u[1]-u[0], v[1]-v[0]));

        long[] bestGold = new long[n];
        long[] bestSilver = new long[n];

        {
            PriorityQueue<Long> q = new PriorityQueue<>();
            long sumGold = 0;
            for (int i = 0 ; i < n ; i++) {
                sumGold += abc[i][0];
                q.add(abc[i][0]-abc[i][2]);
                if (i >= x) {
                    long be = q.poll();
                    sumGold -= be;
                }
                bestGold[i] = sumGold;
            }
        }

        {
            PriorityQueue<Long> q = new PriorityQueue<>();
            long sumSilver = 0;
            for (int i = n-1 ; i >= 0 ; i--) {
                sumSilver += abc[i][1];
                q.add(abc[i][1]-abc[i][2]);
                if ((n-1)-i >= y) {
                    long be = q.poll();
                    sumSilver -= be;
                }
                bestSilver[i] = sumSilver;
            }
        }

        long max = 0;
        for (int i = x-1 ; i <= n-y-1 ; i++) {
            max = Math.max(max, bestGold[i] + bestSilver[i+1]);
        }
        out.println(max);
        out.flush();
    }

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

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

        private int[] nextInts(int n) {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }

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

        private long[] nextLongs(int n) {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }

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

        private double[] nextDoubles(int n) {
            double[] ret = new double[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextDouble();
            }
            return ret;
        }

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

        public char nextChar() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            if ('a' <= c && c <= 'z') {
                return (char) c;
            }
            if ('A' <= c && c <= 'Z') {
                return (char) c;
            }
            throw new InputMismatchException();
        }

        public String nextToken() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res*sgn;
        }

        public long nextLong() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res*sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}

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


Question:
import java.util.*;

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

    int n = sc.nextInt();//スイッチ
    int m = sc.nextInt();//電球
    int[] ak = new int[m];//電球に繋がっているスイッチの個数
    int[][] sw = new int[m][n];//電球mに接続しているスイッチの情報
    int[] ju = new int[m]; //電球に繋がっているスイッチ%2が配列内の値の時点灯
    int ans = 0;//条件合致数

    for(int i=0; i<m; i++){
      ak[i] = sc.nextInt();//電球i+1に繋がっているスイッチ個数
      for(int j=0; j<ak[i]; j++){
        sw[i][j] = sc.nextInt(); //繋がるスイッチ番号入力
      }
    }

    for(int k=0; k<m;k++){
      ju[k] = sc.nextInt();//1or0を入力
    }

    for(int i=0; i< (1<<n); i++){//スイッチの全ビット探索
      int[] swon = new int[m];//電球に繋がっているonの数
      for(int j=0; j<n;j++){//jビット左論理シフト

        if((1&i>>j)==1){//スイッチj+1がonかoffか
          for(int k=0; k<m;k++){//k+1=電球番号
            for(int l=0; l<ak[k];l++){
              if(sw[k][l]==j+1){
                swon[k] = swon[k] + 1;
              }
            }
          }

        }

      }
      // for(int p=0; p<m;p++){
      //   System.out.println("*"+swon[p]);
      // }
      //全ての電球が点灯したかの判定
      boolean judge = false;
      int count=0;
      for(int p=0;p<m;p++){
        if(swon[p]%2 == ju[p]){
          count +=1;
        }
      }
      if(count==m){
        ans += 1;
      }

    }

    System.out.println(ans);

  }
}

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


Question:
import java.util.*;

/*
問題文
東西に N 個の山が連なっており、西の果てには広大な海が広がっています。
各山頂には旅館があり、あなたは海を眺められる旅館を選ぶことにしました。

西から i 番目の山の高さは Hi です。
西から 1 番目の山頂にある旅館からは必ず海を眺めることができます。

西から i (i=2,3,...,N) 番目の山頂にある旅館については、
H1≤Hi,H2≤Hi,..., かつ Hi−1≤Hi のとき、その旅館から海を眺めることができます。

これら N 個の旅館のうち、海を眺められる旅館はいくつあるでしょうか。

制約
入力は全て整数である。
1≤N≤20
1≤Hi≤100
*/

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

        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int mounts[] = new int[a];

        int max = 0;
        int count = 0;
        for (int i = 0; i < a; i++) {
          mounts[i] = s.nextInt();
          if (mounts[i] >= max) {
            max = mounts[i];
            count++;
          }
        }

        System.out.println(count);
    }
}

Choices:
- Memory Limit Exceeded
- Time Limit Exceeded
- 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);

		int n=Integer.parseInt(sc.next());
		int h[]=new int[100];
		int sum=0;
		int j;

		for(int i=0;i<n;i++){
			h[i]=Integer.parseInt(sc.next());
			for(j=i;j>=0;j--){
				if(i!=0&&h[i]<h[j]){
					break;
				}
			}
			if(j==-1)sum+=1;

		}
		System.out.println(sum);
	}

}

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


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

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

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

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

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

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

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

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

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

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

public class Main {
    // static int MOD = 1000000007;

    // public static class Mas {
    // int x;
    // int y;
    // int step;

    // Mas(int x, int y, int step) {
    // this.x = x;
    // this.y = y;
    // this.step = step;
    // }
    // }

    static long pow(long l, long i) {
        if (i == 0)
            return 1;
        else {
            if (i % 2 == 0) {
                long val = pow(l, i / 2);
                return val * val % 2019;
            } else {
                return pow(l, i - 1) * l % 2019;
            }
        }
    }

    private static final int[] vX = { 1, 0, 0, -1 };
    private static final int[] vY = { 0, 1, -1, 0 };

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
        int M = fs.nextInt();
        int[] x = new int[M];
        int[] y = new int[M];
        for (int i = 0; i < M; i++) {
            x[i] = fs.nextInt() - 1;
            y[i] = fs.nextInt() - 1;
        }
        int[] nums = new int[N];
        boolean[] red = new boolean[N];
        Arrays.fill(nums, 1);
        red[0] = true;
        for (int i = 0; i < M; i++) {
            if (red[x[i]]) {
                red[y[i]] = true;
            }
            nums[x[i]]--;
            nums[y[i]]++;
            if (nums[x[i]] == 0) {
                red[x[i]] = false;
            }
        }
        int count = 0;
        for (boolean flag : red) {
            if (flag)
                count++;
        }
        System.out.println(count);
    }
}

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


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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), X = sc.nextInt();
		int[] a = new int[n + 1];
		long[] sum = new long[n + 1];
		for (int i = 1; i <= n; i++) {
			sum[i] = a[i] = sc.nextInt();
			sum[i] += sum[i - 1];
		}
		BigInteger ans = null;

		for (int k = 1; k <= n; k++) {
			BigInteger curr = BigInteger.ZERO;
			for (int i = n, c = 1; i > 0; i -= k, c++) {

				long rangeSum = sum[i];
				if (i >= k) {
					rangeSum -= sum[i - k];
				}

				int coeff = c == 1 ? 5 : (2 * c + 1);
				curr = curr.add(BigInteger.valueOf(coeff).multiply(BigInteger.valueOf(rangeSum)));
			}
			curr = curr.add(BigInteger.valueOf(k).multiply(BigInteger.valueOf(X)));
			if (ans == null || curr.compareTo(ans) < 0)
				ans = curr;
//			ans = Math.min(ans, curr + k * 1L * X);
		}
		out.println(ans.add(BigInteger.valueOf(n * 1L * X)));
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

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

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

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

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

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

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

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

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


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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), X = sc.nextInt();
		int[] a = new int[n + 1];
		long[] sum = new long[n + 1];
		for (int i = 1; i <= n; i++) {
			sum[i] = a[i] = sc.nextInt();
			sum[i] += sum[i - 1];
		}
		BigInteger ans = null;

		for (int k = 1; k <= n; k++) {
			BigInteger curr = BigInteger.ZERO;
			for (int i = n, c = 1; i > 0; i -= k, c++) {

				long rangeSum = sum[i];
				if (i >= k) {
					rangeSum -= sum[i - k];
				}

				int coeff = c == 1 ? 5 : (2 * c + 1);
				curr = curr.add(BigInteger.valueOf(coeff).multiply(BigInteger.valueOf(rangeSum)));
			}
			curr = curr.add(BigInteger.valueOf(k).multiply(BigInteger.valueOf(X)));
			if (ans == null || curr.compareTo(ans) < 0)
				ans = curr;
//			ans = Math.min(ans, curr + k * 1L * X);
		}
		out.println(ans.add(BigInteger.valueOf(n * 1L * X)));
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

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

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

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

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

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

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

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

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


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

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

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

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

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

			long[] h = new long[n];
			for (int i = 1; i < n; i++) {
				h[i] = (h[i - 1] + inv[i + 1]) % MOD;
			}

			long ans = 0;
			for (int i = 0; i < n; i++) {
				ans = (ans + a[i] * (1 + h[i] + h[n - i - 1])) % MOD;
			}
			ans = ans * fact[n] % MOD;

			out.println(ans);
		}

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

	}

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

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

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

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

	}
}

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


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

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

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

class Reader {
  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  StringTokenizer s = new StringTokenizer("");
  Reader () {}
  String nextLine() {
    try {
      return in.readLine();
    } catch (Exception e) {
      e.printStackTrace();
      return "Error";
    }
  }
  String next() {
    while(!s.hasMoreTokens()) {
      s = new StringTokenizer(nextLine());
    }
    return s.nextToken();
  }
  int nextInt() {
    return Integer.parseInt(next());
  }
}

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


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

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

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

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


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

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

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

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

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

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


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

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

public class Main {

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

            public TaskE.Vertex getRoot() {
                if (parent == null) return this;
                parent = parent.getRoot();
                return parent;
            }

        }

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

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

        }

    }

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

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

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

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

    }
}

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


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

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

    static class TaskE {
        static TaskE.Vertex[] dest;
        static int[] next;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            TaskE.Vertex[] vs = new TaskE.Vertex[n];
            for (int i = 0; i < n; ++i) vs[i] = new TaskE.Vertex();
            TaskE.Vertex us = vs[in.nextInt() - 1];
            TaskE.Vertex root = vs[in.nextInt() - 1];
            dest = new TaskE.Vertex[4 * (n - 1)];
            next = new int[4 * (n - 1)];
            int ptr = 0;
            for (int i = 0; i < n - 1; ++i) {
                TaskE.Vertex a = vs[in.nextInt() - 1];
                TaskE.Vertex b = vs[in.nextInt() - 1];
                next[ptr] = a.firstUs;
                dest[ptr] = b;
                a.firstUs = ptr++;
                next[ptr] = b.firstUs;
                dest[ptr] = a;
                b.firstUs = ptr++;
            }
            for (int i = 0; i < n - 1; ++i) {
                TaskE.Vertex a = vs[in.nextInt() - 1];
                TaskE.Vertex b = vs[in.nextInt() - 1];
                next[ptr] = a.firstThey;
                dest[ptr] = b;
                a.firstThey = ptr++;
                next[ptr] = b.firstThey;
                dest[ptr] = a;
                b.firstThey = ptr++;
            }
            root.fillWhenThey(0);
            us.fillWhenUs(0);

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

        static class Vertex {
            int whenThey = -1;
            int whenUs = -1;
            int firstUs = -1;
            int firstThey = -1;
            TaskE.Vertex parentThey;

            public void fillWhenThey(int val) {
                whenThey = val;
                int tmp = firstThey;
                while (tmp >= 0) {
                    TaskE.Vertex v = dest[tmp];
                    if (v.whenThey < 0) v.fillWhenThey(val + 1);
                    else parentThey = v;
                    tmp = next[tmp];
                }
            }

            public void fillWhenUs(int val) {
                if (val >= whenThey) return;
                whenUs = val;
                int tmp = firstUs;
                while (tmp >= 0) {
                    TaskE.Vertex v = dest[tmp];
                    if (v.whenUs < 0) v.fillWhenUs(val + 1);
                    tmp = next[tmp];
                }
            }

        }

    }

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

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

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

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

    }
}

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


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

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

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

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

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

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


Question:
import java.util.Scanner;

/**
 * Created by srikanth on 04-02-2017.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int even=0,odd=0;
        int N=scan.nextInt();
        while(N-->0){
            int i=scan.nextInt();
            if(i%2==0){
                even++;

            }
            else{
                odd++;
            }
        }
        if(odd%2==1 && even>0)
            System.out.println("NO");
        else{
            System.out.println("YES");
        }
    }
}

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