Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		  ArrayList<String> s = nextCharArray();
		  HashMap<String, Integer> map = new HashMap<String, Integer>();
		  for(var i = 0; i < 4; i++){
		    if(!map.containsKey(s.get(i))){
		      map.put(s.get(i), 0);
		    }
		    map.put(s.get(i), map.get(s.get(i)) + 1);
		  }
		  Iterator keys = map.keySet().iterator();
		  while(keys.hasNext()){
		  	String k = (String)keys.next();
		  	if(map.get(k) != 2){
		  		myout("No");
		  		return;
		  	}
		  }
		  myout((keys.size() != 2) ? "No" : "Yes");
	}
	//Method addition frame start

	//Method addition frame end
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		  int N = nextInt();
		  ArrayList<Integer> list = nextIntArray();
		  int count = 0;
		  for(int i = 1; i < N - 1; i++){
		    if((list.get(i - 1) < list.get(i) && list.get(i) < list.get(i + 1)) || (list.get(i - 1) > list.get(i) && list.get(i) > list.get(i + 1)){
		      count++;
		    }
		  }
		  myout(count);
	}
	//Method addition frame start

	//Method addition frame end
}

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


Question:
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
  //↓見なくていいよ！ここから------------------------------------------
  static public class InputIterator{
    ArrayList<String> inputLine = new ArrayList<String>(1024);
    int index = 0; int max;
    InputIterator(){
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      while(true){
        String read;
        try{
          read = br.readLine();
        }catch(IOException e){
          read = null;
        }
        if(read != null){
          inputLine.add(read);
        }else{
          break;
        }
      }
      max = inputLine.size();
    }
    public boolean hasNext(){return (index < max);}
    public String next(){
      if(hasNext()){
        String returnStr = inputLine.get(index);
        index++;
        return returnStr;
      }else{
        throw new IndexOutOfBoundsException("これ以上入力はないよ。");
      }
    }
  }

  static InputIterator ii = new InputIterator();//リアクティブでは使えないので諦めてScanner使うこと
  static PrintWriter out = new PrintWriter(System.out);
  static void flush(){out.flush();}
  static void myout(Object t){out.println(t);}
  static void myerr(Object t){System.err.println(t);}
  static String next(){return ii.next();}
  static int nextInt(){return Integer.parseInt(next());}
  static long nextLong(){return Long.parseLong(next());}
  static ArrayList<String> nextStrArray(){return myHanSpSplit(next());}
  static ArrayList<String> myHanSpSplit(String str){return new ArrayList<String>(Arrays.asList(str.split(" ")));}
  static ArrayList<String> nextCharArray(){return mySingleSplit(next());}
  static ArrayList<String> mySingleSplit(String str){return new ArrayList<String>(Arrays.asList(str.split("")));}
  static ArrayList<Integer> nextIntArray(){
    ArrayList<Integer> ret = new ArrayList<Integer>();
    ArrayList<String> input = nextStrArray();
    for(int i = 0; i < input.size(); i++){
      ret.add(Integer.parseInt(input.get(i)));
    }
    return ret;
  }
  static ArrayList<Long> nextLongArray(){
    ArrayList<Long> ret = new ArrayList<Long>();
    ArrayList<String> input = nextStrArray();
    for(int i = 0; i < input.size(); i++){
      ret.add(Long.parseLong(input.get(i)));
    }
    return ret;
  }
  static String kaigyoToStr(String[] list){return String.join("\n",list);}
  static String kaigyoToStr(ArrayList<String> list){return String.join("\n",list);}
  static String hanSpToStr(String[] list){return String.join(" ",list);}
  static String hanSpToStr(ArrayList<String> list){return String.join(" ",list);}
  public static void main(String[] args){
    solve();
    flush();
  }
  //↑見なくていいよ！ここまで------------------------------------------
  static public void solve(){//ここがメイン関数代わり
    ArrayList<Integer> one = nextIntArray();
    int N = one.get(0);
    int K = one.get(1);
    int mod = 1000000007;
    for(int i = 1; i <= K; i++){
      myout(originComb(N - K + 1, i, mod) * originComb(K - 1, i - 1, mod) % mod);
    }
  }
  //Method addition frame start
static long originPow(long x, long n) {return originPow(x,n,-1);}
static long originPow(long x, long n, long m) {
        long ans = 1;
        while (n > 0) {
                if ((n & 1) == 1){
                  ans = ans * x;
                  if(m != -1){ans %= m;}
                }
                x = x * x;
                if(m != -1){x %= m;}
                n >>= 1;
        }
        return ans;
}
public static long originComb(long n, long k, long m){
  long ret = 1;
  for(int i = 0; i < k; i++){
    ret = (ret * (n - i)) % m;
    ret = (ret * originPow(i + 1, m - 2, m)) % m;
  }
  return ret;
}
  //Method addition frame end
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      Node[] list = new Node[N];
      for(int i = 0; i < N; i++){
        Arraylist<Integer> tmp = nextIntArray();
        list[i] = new Node(tmp.get(0), tmp.get(1));
      }
      Arrays.sort(list, new originComparator());
      int sum = 0;
      for(int i = 0; i < N; i++){
        if(sum + list[i].A <= list[i].B){
          sum += list[i].A;
        }else{
          myout("No");
          return;
        }
      }
      myout("Yes");
	}
	//Method addition frame start

static class Node{
  int A;
  int B;
  Node(int a, int b){
  	A = a;
    B = b;
  }
}

static class originComparator implements Comparator<Node>{
  public int compare(Node mae, Node ato){
    return mae.B - ato.B;
  }
}

	//Method addition frame end
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");

		solve();flush();

	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<String> one = nextIntArray();
		int N = one.get(0);
		int M = one.get(1);
		int L = 1;
		int R = N;
		for(int i = 0; i < M; i++){
			ArrayList<String> tmp = nextIntArray();
			L = Math.max(L, tmp.get(0));
			R = Math.min(R, tmp.get(1));
		}
		myout(Math.max(R - L + 1, 0));
	}
	//Method addition frame start

	//Method addition frame end
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");

		solve();flush();

	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<String> one = nextIntArray();
		int N = one[0];
		int M = one[1];
		int L = 1;
		int R = N;
		for(int i = 0; i < M; i++){
			ArrayList<String> tmp = nextIntArray();
			L = Math.max(L, tmp[0]);
			R = Math.min(R, tmp[1]);
		}
		myout(Math.max(R - L + 1, 0));
	}
	//Method addition frame start

	//Method addition frame end
}

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


Question:
import java.util.*;
public class Main {
	public static void myout(Object text){//standard output
		System.out.println(text);
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
      int N = sc.nextInt();
      int M = sc.nextInt();
      Long output = new Long(0);
      for(int i = 0; i < N; i++){
        pq.add(sc.nextInt());
      }

      int[][] bc = new int[M][2];
      for(int i = 0; i < M; i++){
        bc[i][0] = sc.nextInt();
        bc[i][1] = sc.nextInt();
      }
      Arrays.sort(bc,Comparator.comparingInt(o -> o[1]));

      for(int i = 0; i < M; i++){
        int b = bc[i][0];
        int c = bc[i][1];
          for(int j = 0; j < b; j++){
            if(pq.peek() < c){
              pq.poll();
              pq.add(c);
            }else{
              break;
            }
          }
      }

      Iterator it = pq.iterator();
      //myout(it);
      while(it.hasNext()){
        int tmp = (Integer)it.next();
        //myout(tmp);
        output = output + tmp;
      }
      myout(output);
	}
}

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


Question:
import java.util.*;
public class Main {
	public static void myout(Object text){//standard output
		System.out.println(text);
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
      int N = sc.nextInt();
      int M = sc.nextInt();
      Long output = new Long(0);
      for(int i = 0; i < N; i++){
        pq.add(sc.nextInt());
      }

      int[][] bc = new int[M][2];
      for(int i = 0; i < M; i++){
        bc[i][0] = sc.nextInt();
        bc[i][1] = sc.nextInt();
      }
      Arrays.sort(bc,Comparator.comparingInt(o -> o[1]));

      for(int i = 0; i < M; i++){
        int pqMin = pq.peek();
        int b = bc[i][0];
        int c = bc[i][1];
        if(pqMin < c){
          for(int j = 0; j < b; j++){
            int pqMin2 = pq.poll();
            if(pqMin2 < c){
              pq.add(c);
            }else{
              pq.add(pqMin2);
              break;
            }
          }
        }

      }

      Iterator it = pq.iterator();
      //myout(it);
      while(it.hasNext()){
        int tmp = (Integer)it.next();
        //myout(tmp);
        output = output + tmp;
      }
      myout(output);
	}
}

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


Question:
import java.util.*;
public class Main {
	public static void myout(Object text){//standard output
		System.out.println(text);
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
      int N = sc.nextInt();
      int M = sc.nextInt();
      Long output = new Long(0);
      for(int i = 0; i < N; i++){
        pq.add(sc.nextInt());
      }

      //myout(pq);
      for(int i = 0; i < M; i++){
        int pqMin = pq.peek();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(pqMin < c){
          for(int j = 0; j < b; j++){
            int pqMin2 = pq.poll();
            if(pqMin2 < c){
              pq.add(c);
            }else{
              pq.add(pqMin2);
              break;
            }
          }
        }

      }

      Iterator it = pq.iterator();
      //myout(it);
      while(it.hasNext()){
        int tmp = (Integer)it.next();
        //myout(tmp);
        output = output + tmp;
      }
      myout(output);
	}
}

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


Question:
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean hasNext(){return sc.hasNext();}
        static char[] mySplit(String str){return str.toCharArray();}
        public static void main(String[] args){
          int a = getInt();
          int b = getInt();
          int c = getInt();
          int k = getInt();
          ArrayList<Long> alist = new ArrayList<Long>(1000);
          ArrayList<Long> blist = new ArrayList<Long>(1000);
          ArrayList<Long> clist = new ArrayList<Long>(1000);
          for(int i = 0; i < a; i++){
            alist.add(getLong());
          }
          for(int i = 0; i < b; i++){
            blist.add(getLong());
          }
          for(int i = 0; i < c; i++){
            clist.add(getLong());
          }
          ArrayList<Long> maeList = new ArrayList<Long>(1000);
          for(int i = 0; i < a; i++){
            for(int j = 0; j < b; j++){
              maeList.add(alist.get(i) + blist.get(j));
            }
          }
          Collections.sort(maeList,Collections.reverseOrder());
          ArrayList<Long> atoList = new ArrayList<Long>(1000);
          for(int i = 0; i < Math.min(k,maeList.size()); i++){
            for(int j = 0; j < c; j++){
              atoList.add(maeList.get(i) + clist.get(j));
            }
          }
          Collections.sort(atoList,Collections.reverseOrder());
          for(int i = 0; i < k; i++){
            myout(atoList.get(i));
          }
        }
        //Method addition frame start

        //Method addition frame end
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		int N = nextInt();
		int mod = 1000000007;
		int[] dp = new int[N + 1];
		dp[0] = 1;
		int mae = 0;
		for(int i = 0; i < N; i++){
			int C = nextInt();
			if(C == mae){
				continue;
			}
			dp[C] = (int)(((long)dp[C] + dp[mae]) % mod);
			mae = C;
		}
		myout(dp[mae]);
	}
	//Method addition frame start

	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	@SuppressWarnings("unchecked")
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		int N = nextInt();
		int mod = 1000000007;
		int[] dp = new int[N + 1];
		dp[0] = 1;
		int mae = 0;
		for(int i = 0; i < N; i++){
			int C = nextInt();
			if(C == mae){
				continue;
			}
			dp[C] = ((long)dp[C] + dp[mae]) % mod;
			mae = C;
		}
		myout(dp[mae]);
	}
	//Method addition frame start

	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	@SuppressWarnings("unchecked")
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		int N = nextInt();
		int mod = 1000000007;
		int[] dp = new int[N + 1];
		dp[0] = 1;
		int mae = 0;
		for(int i = 0; i < N; i++){
			int C = nextInt();
			if(C == mae){
				continue;
			}
			dp[C] = (dp[C] + dp[mae]) % mod;
			mae = C;
		}
		myout(dp[mae]);
	}
	//Method addition frame start

	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	@SuppressWarnings("unchecked")
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<Integer> list = nextIntArray();
      TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
      for(int i = 0; i < N; i++){
        if(map.containsKey(list.get(i))){
          map.put(list.get(i), map.get(list.get(i)) + 1);
        }else{
          map.put(list.get(i), 1);
        }
      }
      Collections.sort(list, Comparator.reverseOrder());
      int count = 0;
      for(int i = 0; i < N; i++){
        int Ai = list.get(i);
        if(!map.containsKey(Ai)){
          continue;
        }
        int beki = 0;
        while(Ai >= Math.pow(2, beki)){
          beki++;
        }
        int check = (int)Math.pow(2, beki) - Ai;
        if(map.containsKey(check)){
          map.put(check, map.get(check) - 1);
          map.put(Ai, map.get(Ai) - 1);
          count++;
          if(map.get(Ai) == 0){
            map.remove(Ai);
          }
          if(map.get(check) == 0){
            map.remove(check);
          }
        }
      }
      myout(count);
	}
	//Method addition frame start

	//Method addition frame end
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int N = one.get(0);
		int T = one.get(1);
		TreeSet<Integer> set = new TreeSet<Integer>();
		for(int i = 0; i < N; i++){
			ArrayList<Integer> tmp = nextIntArray();
			if(tmp.get(1) <= T){
				set.add(tmp.get(0));
			}
		}
		myout(set.first());
	}
	//Method addition frame start

	//Method addition frame end
}

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


Question:
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],2);
  var oddlist = {};
  var evenlist = {};
  for(var i = 0; i < N; i++){
    //偶奇が一致するところだけ関係する
    if(i % 2 == 0){
       if(oddlist[list[i]] == null){
     	  oddlist[list[i]] = 1;
    	}else{
    	   	oddlist[list[i]]++;
    	}
    }else{
       if(evenlist[list[i]] == null){
     	  evenlist[list[i]] = 1;
  	  }else{
   	  	 evenlist[list[i]]++;
  	  }
    }
  }

  var output = 0;
  var oddSet = Object.keys(oddlist);
  var evenSet = Object.keys(evenlist);
  if(oddSet.length == 1 && evenSet.length == 1){
    if(evenSet[0] == oddSet[0]){
       myout(N/2);
    	return;
    }else{
       myout(0);
      return;
    }

  }
  var tmp = 0;
  var lastSelect = "";
  oddSet.sort(function(a,b){
  	return oddlist[b] - oddlist[a];
  });
  evenSet.sort(function(a,b){
  	return evenlist[b] - evenlist[a];
  });
  myerr(oddSet);
  myerr(evenSet);
  if(oddSet[0] == evenSet[0]){
    var mae = 10000000;
    var ato = 10000000;
     if(oddSet[1] != null){
        mae = (N / 2 - oddlist[oddSet[1]]) + (N / 2 - evenlist[evenSet[0]]);
     }
     if(evenSet[1] != null){
        ato = (N / 2 - oddlist[oddSet[0]]) + (N / 2 - evenlist[evenSet[1]]);
     }
    output = Math.min(mae,ato);
  }else{
     output = (N / 2 - oddlist[oddSet[0]]) + (N / 2 - evenlist[evenSet[0]]);
  }
  myout(output);

}
Main(myin());

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
    static HashMap<Integer, Integer> oddlist = new HashMap<>();
    static HashMap<Integer, Integer> evenlist = new HashMap<>();
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<Integer> list = nextIntArray();

      for(int i = 0; i < N; i++){
        if(i % 2 == 0){
          if(oddlist.containsKey(list.get(i))){
            oddlist.put(list.get(i), oddlist.get(list.get(i)) + 1);
          }else{
            oddlist.put(list.get(i), 1);
          }
        }else{
          if(evenlist.containsKey(list.get(i))){
            evenlist.put(list.get(i), evenlist.get(list.get(i)) + 1);
          }else{
            evenlist.put(list.get(i), 1);
          }
        }
      }
      int output = 0;
      ArrayList<Integer> oddSet = new ArrayList<>();
      ArrayList<Integer> evenSet = new ArrayList<>();
      Iterator it1 = oddlist.keySet().iterator();
      while(it1.hasNext()){
        oddSet.add((int)it1.next());
      }
      Iterator it2 = oddlist.keySet().iterator();
      while(it2.hasNext()){
        evenSet.add((int)it2.next());
      }

      if(oddSet.size() == 1 && evenSet.size() == 1){
        if(oddSet.get(0) == evenSet.get(0)){
          myout(N / 2);
        }else{
          myout(0);
        }
        return;
      }

      Collections.sort(oddSet, new originComparator1());
      Collections.sort(evenSet, new originComparator2());
      if(oddSet.get(0) == evenSet.get(0)){
        int mae = 1 << 20;
        int ato = 1 << 20;
        if(oddSet.size() > 1){
          mae = (N / 2 - oddlist.get(oddSet.get(1))) + (N / 2 - evenlist.get(evenSet.get(0)));
        }
        if(evenSet.size() > 1){
          ato = (N / 2 - oddlist.get(oddSet.get(0))) + (N / 2 - evenlist.get(evenSet.get(1)));
        }
        output = Math.min(mae, ato);
      }else{
        output = (N / 2 - oddlist.get(oddSet.get(0))) + (N / 2 - evenlist.get(evenSet.get(0)));
      }
      myout(output);
	}
	//Method addition frame start

static class originComparator1 implements Comparator<Integer>{
  public int compare(Integer mae, Integer ato){
    return oddlist.get(ato) - oddlist.get(mae);
  }
}

static class originComparator2 implements Comparator<Integer>{
  public int compare(Integer mae, Integer ato){
    return evenlist.get(ato) - evenlist.get(mae);
  }
}

	//Method addition frame end
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      int output = 0;
      for(int i = 1; i <= N; i++){
        Arraylist<Long> list = getDivisorList(i);
        if(list.size() == 8){
          output++;
        }
      }
      myout(output);
	}
	//Method addition frame start

public static ArrayList<Long> getDivisorList(long val){
        ArrayList<Long> list = new ArrayList<Long>(1024);
        for(long i = 1; i * i <= val; i++){
                if(val % i == 0){
                        list.add(i);
                        if(i * i != val){
                                list.add(val / i);
                        }
                }
        }
        Collections.sort(list);
        return list;
}

	//Method addition frame end
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
	ArrayList<String> list = nextCharArray();
	String[] ch = "abcdefghijklmnopqrstuvwxyz".split("");
	if(list.size() != 26){
		for(int i = 0; i < 26; i++){
			if(list.indexOf(ch[i]) == -1){
				list.add(ch[i]);
				break;
			}
		}
	}else{
		ArrayList<String> tmpList = new ArrayList<String>();
		while(list.size() > 0){
			tmpList.add(list.get(list.size() - 1));
          	list.remove(list.size() - 1);
			Collections.sort(tmpList);
			boolean isOK = false;
			for(int i = 0; i < tmpList.size(); i++){
				if(list.get(list.size() - 1).compareTo(tmpList.get(i)) < 1){
                  	list.remove(list.size() - 1);
					list.add(tmpList.get(i));
					isOK = true;
					break;
				}
			}
			if(isOK){
				break;
			}
		}
	}
	if(list.size() == 0){
		myout(-1);
	}else{
		myout(myconv(list,0));
	}
	}
	//Method addition frame start

	//Method addition frame end
}

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


Question:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
  ArrayList<Integer> one = nextIntArray();
  int ai = one[0];
  int ao = one[1];
  int at = one[2];
  int aj = one[3];
  int al = one[4];
  int as = one[5];
  int az = one[6];
  int output1 = Math.floor(ai / 2) * 2 + Math.floor(aj / 2) * 2 + Math.floor(al / 2) * 2;
  int output2;
  if(ai >= 1 && aj >= 1 && al >= 1){
    output2= Math.floor((ai - 1) / 2) * 2 + Math.floor((aj - 1) / 2) * 2 + Math.floor((al - 1) / 2) * 2 + 3;
  }else{
    output2 = 0;
  }
  myout(Math.max(output1, output2) + ao);
	}
	//Method addition frame start

	//Method addition frame end
}

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


Question:
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	final int MOD = (int)1e9+7;

	//System.out.println();はつかわない！！
	void solve() throws Exception{
		CombCalculator cc = new CombCalculator();
		int N = in.nextInt(), K = in.nextInt(), M = N - K;
		for(int i = 1; i <= K; i++){
			int k = K - i, m = M - (i - 1);
			long res = (cc.modComb(k + i - 1, k) * cc.modComb(m + i+1 - 1, m)) % MOD;
			out.println(res);
		}
	}

	public static void main(String[] args) throws Exception {
		new Main().m();
	}

	void m() throws Exception {
		solve();
		out.flush();
	}

	class FastScanner {
		Reader input;

		FastScanner() {this(System.in);}
		FastScanner(InputStream stream) {this.input = new BufferedReader(new InputStreamReader(stream));}

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

		long nextLong() {
			try {
				int sign = 1;
				int b = input.read();
				while ((b < '0' || '9' < b) && b != '-' && b != '+') {
					b = input.read();
				}
				if (b == '-') {
					sign = -1;
					b = input.read();
				} else if (b == '+') {
					b = input.read();
				}
				long ret = b - '0';
				while (true) {
					b = input.read();
					if (b < '0' || '9' < b) return ret * sign;
					ret *= 10;
					ret += b - '0';
				}
			} catch (IOException e) {
				e.printStackTrace();
				return -1;
			}
		}

		double nextDouble() {
			try {
				double sign = 1;
				int b = input.read();
				while ((b < '0' || '9' < b) && b != '-' && b != '+') {
					b = input.read();
				}
				if (b == '-') {
					sign = -1;
					b = input.read();
				} else if (b == '+') {
					b = input.read();
				}
				double ret = b - '0';
				while (true) {
					b = input.read();
					if (b < '0' || '9' < b) break;
					ret *= 10;
					ret += b - '0';
				}
				if (b != '.') return sign * ret;
				double div = 1;
				b = input.read();
				while ('0' <= b && b <= '9') {
					ret *= 10;
					ret += b - '0';
					div *= 10;
					b = input.read();
				}
				return sign * ret / div;
			} catch (IOException e) {
				e.printStackTrace();
				return Double.NaN;
			}
		}

		char nextChar() {
			try {
				int b = input.read();
				while (Character.isWhitespace(b)) {
					b = input.read();
				}
				return (char) b;
			} catch (IOException e) {
				e.printStackTrace();
				return 0;
			}
		}

		String nextStr() {
			try {
				StringBuilder sb = new StringBuilder();
				int b = input.read();
				while (Character.isWhitespace(b)) {
					b = input.read();
				}
				while (b != -1 && !Character.isWhitespace(b)) {
					sb.append((char) b);
					b = input.read();
				}
				return sb.toString();
			} catch (IOException e) {
				e.printStackTrace();
				return "";
			}
		}

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

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

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

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

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

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

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

class CombCalculator{
	//引数の最大値、MOD、階乗・MODの逆元・階乗の逆元のテーブル
	static int MAX_FAC = 510000;
	static int MOD = (int)1e9+7;
	static long[] fac = new long[MAX_FAC+1];
	static long[] finv = new long[MAX_FAC+1];
	static long[] inv = new long[MAX_FAC+1];

	public CombCalculator(){
		this(510000, (int)1e9+7);
	}

	public CombCalculator(int max, int mod){
		MAX_FAC = max; MOD = mod;
		initComb();
	}

	//テーブルの初期化
	void initComb(){
		fac[0] = finv[0] = inv[0] = fac[1] = finv[1] = inv[1] = 1;
		for (int i = 2; i <= MAX_FAC; ++i) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - (MOD / i) * inv[(int) (MOD % i)] % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

	//nPk % MOD
	public long modPerm(int n, int k){
		return fac[n] * finv[n - k] % MOD;
	}

	//nCk % MOD
	public long modComb(int n, int k){
		return fac[n] * finv[k] % MOD * finv[n - k] % MOD;
	}

	//n! % MOD
	public long modFact(int n){
		return fac[n];
	}

	//(n!)^-1 % MOD
	public long modFactInv(int n){
		return finv[n];
	}

	//n^-1 % MOD
	public long modInv(int n){
		return inv[n];
	}

	/*
	 * MOD付きpowをlog(n)で計算
	 */
	static long modPow(long a, long n, int mod){
		long res = 1;
		while(n > 0){
			if((n & 1) == 1) res = (res * a) % mod;
			a = (a * a) % mod;
			n = n >> 1;
		}
		return res;
	}
}
/* end Main */

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


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

import javax.swing.plaf.synth.SynthOptionPaneUI;

@SuppressWarnings("unused")
public class Main {

	//final boolean isDebug = true;
	final boolean isDebug = false;
	String fileName = "input.txt";
	FastScanner sc;
	PrintWriter out;
	final int MOD = (int)1e9+7;
	//final int INF = Integer.MAX_VALUE / 2;
	final long INF = Long.MAX_VALUE / 2;

	void solve() throws Exception{
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) A[i] = sc.nextInt();
		int[][] BC = new int[M][2];
		for(int i = 0; i < M; i++){
			BC[i][0] = sc.nextInt();
			BC[i][1] = sc.nextInt();
		}
		Arrays.sort(A);
		Arrays.sort(BC, (e1, e2)->Integer.compare(e2[1], e1[1]));

		int index = 0;
		long sum = 0;
		LOOP:for(int i = 0; i < M; i++){
			for(int j = 0; j < BC[i][0]; j++){
				if(A[index] < BC[i][1]){
					A[index] = BC[i][1];
					index++;
					if(index == N) break LOOP;
				}
			}
		}

		for(int e : A) sum += e;
		System.out.println(sum);
	}

	/* end solve */

	/* main */
	public static void main(String[] args) throws Exception {
		new Main().m();
	}

	void m() throws Exception {
		long S = System.currentTimeMillis();
		sc = (isDebug) ? new FastScanner(new FileInputStream(fileName)) : new FastScanner(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
		long G = System.currentTimeMillis();
		if(isDebug){
			System.out.println("---Debug---");
			System.out.printf("%8d ms\n", (G-S));
		}
	}
	/* end main */
}
/* end Main */

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    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 String nextLine() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(b != 10) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

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


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

public class Main {

	final boolean isDebug = false;
	String fileName = "input.txt";
	FastScanner sc;
	//PrintWriter out;
	final int MOD = (int)1e9+7;
	final int INF = Integer.MAX_VALUE / 2;

	/* solve */
	void solve() throws Exception{
		int N = sc.nextInt();
		long[] C = new long[N+1];
		long[] sumC = new long[N+1];
		long sumAll = 0;
		long[] dp = new long[N+1];
		dp[0] = 1;

		for(int i = 1; i <= N; i++){
			int c = sc.nextInt();
			dp[i] = dp[i-1];
			if(sumC[c] > 0 && C[i-1] != c){
				dp[i] += sumC[c];
				dp[i] %= MOD;
			}
			if(C[i-1] != c){
				sumC[c] += dp[i-1];
				sumC[c] %= MOD;
			}
			C[i] = c;
			//System.out.println(dp[i]);
		}

		System.out.println(dp[N]);
 	}

	/* end solve */

	/* main */
	public static void main(String[] args) throws Exception {
		new Main().m();
	}

	void m() throws Exception {
		long S = System.currentTimeMillis();
		sc = (isDebug) ? new FastScanner(new FileInputStream(fileName)) : new FastScanner(System.in);
		//out = new PrintWriter(System.out);
		solve();
		//out.flush();
		long G = System.currentTimeMillis();
		if(isDebug){
			System.out.println("---Debug---");
			System.out.printf("%8d ms", (G-S));
		}
	}
	/* end main */
}
/* end Main */

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

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


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

public class Main {

	final boolean isDebug = false;
	String fileName = "input.txt";
	FastScanner sc;
	//PrintWriter out;
	final int MOD = (int)1e9+7;
	final int INF = Integer.MAX_VALUE / 2;

	/* solve */
	void solve() throws Exception{
		int N = sc.nextInt();
		int[] C = new int[N+1];
		int[] sumC = new int[N+1];
		long sumAll = 0;
		int[] dp = new int[N+1];
		dp[0] = 1;

		for(int i = 1; i <= N; i++){
			int c = sc.nextInt();
			dp[i] = dp[i-1];
			if(sumC[c] > 0 && C[i-1] != c){
				dp[i] += sumC[c];
				dp[i] %= MOD;
			}
			if(C[i-1] != c){
				sumC[c] += dp[i-1];
				sumC[c] %= MOD;
			}
			C[i] = c;
			//System.out.println(dp[i]);
		}

		System.out.println(dp[N]);
 	}

	/* end solve */

	/* main */
	public static void main(String[] args) throws Exception {
		new Main().m();
	}

	void m() throws Exception {
		long S = System.currentTimeMillis();
		sc = (isDebug) ? new FastScanner(new FileInputStream(fileName)) : new FastScanner(System.in);
		//out = new PrintWriter(System.out);
		solve();
		//out.flush();
		long G = System.currentTimeMillis();
		if(isDebug){
			System.out.println("---Debug---");
			System.out.printf("%8d ms", (G-S));
		}
	}
	/* end main */
}
/* end Main */

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

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


Question:
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] rel_even = new int[100000];
		int[] rel_odd = new int[100000];

		for(int i = 0; i < n; i++){
			int v = sc.nextInt();
			if(i % 2 == 0) rel_odd[v]++;
			else rel_even[v]++;
		}

		int max_even_num1 = 0, max_even_num2 = 0, max_odd_num1 = 0, max_odd_num2 = 0;
		int max_even_index1 = 0, max_even_index2 = 0, max_odd_index1 = 0, max_odd_index2 = 0;

		for(int i = 0; i < 100000; i++){
			if(rel_odd[i] > max_odd_num2 && rel_odd[i] > max_odd_num1){
				max_odd_num1 = rel_odd[i];
				max_odd_index1 = i;
			}else if(rel_odd[i] > max_odd_num2 && rel_odd[i] < max_odd_num1){
				max_odd_num2 = rel_odd[i];
				max_odd_index2 = i;
			}
		}

		for(int i = 0; i < 100000; i++){
			if(rel_even[i] > max_even_num2 && rel_even[i] > max_even_num1){
				max_even_num1 = rel_even[i];
				max_even_index1 = i;
			}else if(rel_even[i] > max_even_num2 && rel_even[i] < max_even_num1){
				max_even_num2 = rel_even[i];
				max_even_index2 = i;
			}
		}

		if(max_odd_index1 != max_even_index1){
			System.out.println(n - max_even_num1 - max_odd_num1);
		}else{
			int diff1 = max_even_num1 + max_odd_num2;
			int diff2 = max_even_num2 + max_odd_num1;
			if(diff1 > diff2) System.out.println(n - diff1);
			else System.out.println(n - diff2);
		}
	}
}

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


Question:
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.Map.Entry;
import java.util.NoSuchElementException;

public class Main {

	//MOD、階乗・MODの逆元・階乗の逆元のテーブル
	static int MAX_FAC = 510000;
	static int MOD = 1000000007;
	static long[] fac = new long[MAX_FAC];
	static long[] finv = new long[MAX_FAC];
	static long[] inv = new long[MAX_FAC];

	public static void main(String[] args) throws IOException {
		File file = new File("input.txt");
		Scanner in = new Scanner(file);

		//Scanner in = new Scanner(System.in);
		FastScanner sc = new FastScanner();

		long N = sc.nextLong();//in.nextLong();
		long M = sc.nextLong();
		long ans = 1;

		//初期化
		initComb();

		long m = M;
		for (int i = 2; i * i <= m; i++) {
			if (m % i == 0) {
				int count = 0;
				while (m % i == 0) {
					m /= i;
					count++;
				}
				//System.out.println(i + " ^ " + count);
				//N-1+count C count
				ans = (ans * comb((int)N-1+count, count)) % MOD;
			}
		}
		if(m > 1){
			//System.out.println(n + " ^ " + 1);
			ans = (ans * N) % MOD;
		}

		System.out.println(ans);
	}

	//テーブルの初期化
	public static void initComb(){
		fac[0] = finv[0] = inv[0] = fac[1] = finv[1] = inv[1] = 1;
		for (int i = 2; i < MAX_FAC; ++i) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - (MOD / i) * inv[(int) (MOD % i)] % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

	//nCk % MOD
	public static long comb(int n, int k){
		return fac[n] * finv[k] % MOD * finv[n - k] % MOD;
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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


Question:
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] xp = new int[N+1];
		for(int i = 0; i < N; i++) xp[i] = sc.nextInt();
		xp[N] = X;

		Arrays.sort(xp);
		//for(int i : xp) System.out.println(i);
		int[] dist = new int[N];
		for(int i = 0; i < N; i++) dist[i] = xp[i+1] - xp[i];
		int distMax = dist[N-1];

		int ans = 1;
		for(int i = 2; i <= distMax; i++){
			boolean tf = true;
			for(int j = 0; j < N; j++){
				if(dist[j] % i != 0){
					tf = false;
					break;
				}
			}
			if(tf) ans = i;
		}

		System.out.println(ans);
	}
}

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


Question:
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.Scanner;

import javax.swing.plaf.synth.SynthSeparatorUI;

public class Main {

	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int Q = sc.nextInt();

		int[][] LR = new int[M][2];
		for(int i = 0; i < M; i++){
			LR[i][0] = sc.nextInt();
			LR[i][1] = sc.nextInt();
		}

		for(int i = 0; i < Q; i++){
			int p = sc.nextInt();
			int q = sc.nextInt();
			int ans = 0;

			for(int j = 0; j < M; j++){
				if(LR[j][0] < p) continue;
				if(LR[j][1] > q) continue;
				ans++;
			}

			System.out.println(ans);
		}
	}
}

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


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

public class Main {
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		ArrayList<int[]> ab = new ArrayList<int[]>();
		for(int i = 0; i < M; i++){
			int[] edge = {sc.nextInt(), sc.nextInt()};
			ab.add(edge);
		}

		Collections.sort(ab, new edgeComparator());

		/*
		for(int i = 0; i < M; i++){
			int[] edge = ab.get(i);
			int a = edge[0];
			int b = edge[1];
			System.out.println(a + " " + b);
		}
		*/

		int ans = 0;
		int preVisitedIndex = 0;

		for(int i = 0; i < M; i++){
			int[] edge = ab.get(i);
			int a = edge[0];
			int b = edge[1];

			if(preVisitedIndex >= a && preVisitedIndex < b)
				continue;

			preVisitedIndex = b - 1;
			ans++;
		}

		System.out.println(ans);
	}

	public static class edgeComparator implements Comparator<int[]> {

		@Override
		public int compare(int[] e1, int[] e2) {
			return e1[1] < e2[1] ? -1 : 1;
		}
	}
}

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


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

public class Main {
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] ab = new int[M][2];
		for(int i = 0; i < M; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			ab[i][0] = a;
			ab[i][1] = b;
		}

		Arrays.sort(ab, new edgeComparator());

		/*
		for(int i = 0; i < M; i++){
			System.out.println(ab[i][0] + " " + ab[i][1]);
		}
		*/

		int ans = 0;
		int preVisitedIndex = 0;

		for(int i = 0; i < M; i++){
			int a = ab[i][0];
			int b = ab[i][1];

			if(preVisitedIndex >= a && preVisitedIndex < b)
				continue;

			preVisitedIndex = b - 1;
			ans++;
		}

		System.out.println(ans);
	}

	public static class edgeComparator implements Comparator<int[]> {

		@Override
		public int compare(int[] e1, int[] e2) {
			return e1[1] < e2[1] ? -1 : 1;
		}
	}
}

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


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

public class Main {
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] ab = new int[M][2];
		for(int i = 0; i < M; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			ab[i][0] = a;
			ab[i][1] = b;
		}

		Arrays.sort(ab, new edgeComparator());

		/*
		for(int i = 0; i < M; i++){
			System.out.println(ab[i][0] + " " + ab[i][1]);
		}
		*/

		int ans = 0;
		int preVisitedIndex = -1;

		for(int i = 0; i < M; i++){
			int a = ab[i][0] - 1;
			int b = ab[i][1] - 1;

			if(preVisitedIndex >= a && preVisitedIndex < b)
				continue;

			preVisitedIndex = b - 1;
			ans++;
		}

		System.out.println(ans);
	}

	public static class edgeComparator implements Comparator<int[]> {

		@Override
		public int compare(int[] e1, int[] e2) {
			return e1[1] < e2[1] ? -1 : 1;
		}
	}
}

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


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

public class Main {
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] ab = new int[M][2];
		for(int i = 0; i < M; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			ab[i][0] = a;
			ab[i][1] = b;
		}

		Arrays.sort(ab, new edgeComparator());

		/*
		for(int i = 0; i < M; i++){
			System.out.println(ab[i][0] + " " + ab[i][1]);
		}
		*/

		int ans = 0;
		int preVisitedIndex = -1;

		for(int i = 0; i < M; i++){
			int a = ab[i][0] - 1;
			int b = ab[i][1] - 2;

			if(preVisitedIndex >= a && preVisitedIndex <= b)
				continue;

			preVisitedIndex = b;
			ans++;
		}

		System.out.println(ans);
	}

	public static class edgeComparator implements Comparator<int[]> {

		@Override
		public int compare(int[] e1, int[] e2) {
			return e1[1] < e2[1] ? -1 : 1;
		}
	}
}

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


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

public class Main {
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] ab = new int[M][2];
		for(int i = 0; i < M; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			ab[i][0] = a;
			ab[i][1] = b;
		}

		Arrays.sort(ab, new edgeComparator());
		/*
		for(int i = 0; i < M; i++){
			System.out.println(ab[i][0] + " " + ab[i][1]);
		}
		*/

		int ans = 0;
		boolean[] visited = new boolean[N];

		for(int i = 0; i < M; i++){
			int a = ab[i][0] - 1;
			int b = ab[i][1] - 2;

			boolean tf = true;
			for(int j = a; j <= b; j++){
				if(visited[j]){
					tf = false;
					break;
				}
			}

			if(tf){
				visited[b] = true;
				ans++;
			}
		}

		/*
		System.out.print("〇");
		for(int i = 0; i < N; i++){
			System.out.print(visited[i] ? "1" : "0");
			System.out.print("〇");
		}
		System.out.println();
		*/

		System.out.println(ans);
	}

	public static class edgeComparator implements Comparator<int[]> {

		@Override
		public int compare(int[] e1, int[] e2) {
			return e1[1] < e2[1] ? -1 : 1;
		}
	}
}

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


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

public class Main {

	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) A[i] = sc.nextInt() - i - 1;

		Arrays.sort(A);
		ArrayList<Integer[]> AA = new ArrayList<Integer[]>();
		Integer[] a = {A[0], 1};
		AA.add(a);
		for(int i = 1; i < N; i++){
			if(AA.get(AA.size()-1)[0] == A[i]){
				Integer[] newa = {A[i], AA.get(AA.size()-1)[1]+1};
				AA.remove(AA.size()-1);
				AA.add(newa);
			}else{
				Integer[] newa = {A[i], 1};
				AA.add(newa);
			}
		}

		int min = 0;
		int b = AA.get(0)[0];
		for(int i = 1; i < AA.size(); i++){
			min += (int)(Math.abs(b - AA.get(i)[0])) * AA.get(i)[1];
		}

		for(int i = 1; i < AA.size(); i++){
			int bb = AA.get(i)[0];
			int num = 0;
			for(int j = 0; j < AA.size(); j++){
				if(i != j) num += (int)(Math.abs(bb - AA.get(j)[0])) * AA.get(j)[1];
			}
			if(num < min) min = num;
		}

		System.out.println(min);
	}
}

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


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

public class Main {

	public static void main(String[] args) throws IOException {
		File file = new File("input.txt");
		Scanner sc = new Scanner(file);

		//Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) A[i] = sc.nextInt() - (i + 1);
		Arrays.sort(A);

		int ans = 0;
		for(int i = 0; i < A.length; i++){
			ans += A[A.length-1] + 1 - A[i];
		}

		int min = A[0], max = A[A.length-1];
		for(int b = max; b >= min; b--){
			int diff = 0;
			for(int j = 0; j < A.length; j++){
				if(b < A[j]) diff++;
				else diff--;
			}
			if(diff < 0){
				ans += diff;
			}else{
				break;
			}
		}

		System.out.println(ans);
	}
}

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


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

public class Main {

	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) A[i] = sc.nextInt() - (i + 1);
		Arrays.sort(A);

		int ans = 0;
		for(int i = 0; i < A.length-1; i++){
			ans += A[A.length-1] - A[i];
		}

		int min = A[0], max = A[A.length-1];
		for(int b = min; b <= max; b++){
			int sum = 0;
			for(int j = 0; j < A.length; j++){
				sum += Math.abs(A[j] - b);
			}
			if(sum < ans) ans = sum;
		}

		System.out.println(ans);
	}
}

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


Question:
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

/*
 * メモ
 * Scanner:nextは空白か改行までの単語
 * String[][] c = new String[h][w];
 * TemplateMain,"template_input.txt"
 * 0.5 == 1.0/2
 * Integer.valueOf(char)はダメ、(String)
 */

public class Main {

	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

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

		int min = N + 1;
		int indexMin = 0;
		for(int i = 0; i < N; i++)
			if(A[i] < min){
				min = A[i];
				indexMin = i;
			}

		int left = indexMin;
		int right = N - left - 1;

		if(left <= right) System.out.println(calc(K, left, right));
		else System.out.println(calc(K, right, left));
	}

	public static int calc(int K, int left, int right){
		int numLeft = 0;
		int numRight = 0;

		if(numLeft == 0){
			numRight = right / (K - 1);
			if(right % (K - 1) != 0) numRight++;
			return numRight;
		}

		if(left + 1 <= K){
			numLeft = 1;
			right -= K - (left + 1);
		}else{
			numLeft = left / (K - 1);
			if(left % (K - 1) != 0) numLeft++;
		}

		if(right + 1 <= K){
				numRight = 1;
				if(right <= 0) numRight = 0;
		}else{
			numRight = right / (K - 1);
			if(right % (K - 1) != 0) numRight++;
		}

		return numLeft + numRight;
	}
}

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


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

public class Main {

	final boolean isDebug = false;
	String fileName = "input.txt";
	FastScanner sc;
	//PrintWriter out;
	final int MOD = (int)1e9+7;
	final int INF = Integer.MAX_VALUE / 2;

	/* solve */
	void solve(){
		int N = sc.nextInt();
		int[] num = new int[N];
		int[] s = new int[N+1];
		int[] p = new int[N];
		Arrays.fill(s, -1);
		int max = 0;
		for(int i = 0; i < N; i++){
			p[i] = sc.nextInt();
			if(s[p[i]-1] != -1){
				s[p[i]] = s[p[i]-1];
			}else{
				s[p[i]] = p[i];
			}
			num[s[p[i]]]++;
			max = Math.max(max, num[s[p[i]]]);
		}

		System.out.println(N-max);
 	}

	/* end solve */

	/* main */
	public static void main(String[] args) throws IOException {
		new Main().m();
	}

	void m() throws IOException {
		long S = System.currentTimeMillis();
		sc = (isDebug) ? new FastScanner(new FileInputStream(fileName)) : new FastScanner(System.in);
		//out = new PrintWriter(System.out);
		solve();
		//out.flush();
		long G = System.currentTimeMillis();
		if(isDebug){
			System.out.println("---Debug---");
			System.out.printf("%8d ms", (G-S));
		}
	}
	/* end main */
}
/* end Main */

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

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