Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    scn.nextLine();

    long anagCombi = 0;

    ArrayList<String> sorted = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      String s = scn.nextLine();
      Character[] chars = new Character[10];
      for (int j = 0; j < 10; j++) {
        chars[j] = s.charAt(j);
      }

      Arrays.sort(chars, new Comparator<Character>() {
        public int compare(Character c1, Character c2) {
          int cmp = Character.compare(Character.toLowerCase(c1.charValue()), Character.toLowerCase(c2.charValue()));
          if (cmp != 0)
            return cmp;
          return Character.compare(c1.charValue(), c2.charValue());
        }
      });
      StringBuilder sb = new StringBuilder(chars.length);
      for (char c : chars) {
        sb.append(c);
      }
      sorted.add(sb.toString());

    }

    Collections.sort(sorted);
    sorted.add("dummy");
    String prev = sorted.get(0);
    long sameCount = 1L;
    for (int i = 1; i < sorted.size(); i++) {
      if (sorted.get(i).equals(prev)) {
        sameCount++;
      } else {
        if (sameCount == 2) {
          anagCombi += 1;
        }
        if (sameCount > 2) {
          anagCombi += fact(sameCount) / (2L * fact(sameCount - 2L));
        }
        prev = sorted.get(i);
        sameCount = 1L;

      }
    }

    System.out.println(anagCombi);

  }

  public static long fact(long a) {
    if (a == 0) {
      return 1L;
    }
    return a * fact(a - 1);
  }

}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    scn.nextLine();

    long anagCombi = 0;

    ArrayList<String> sorted = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      String s = scn.nextLine();
      Character[] chars = new Character[10];
      for (int j = 0; j < 10; j++) {
        chars[j] = s.charAt(j);
      }

      Arrays.sort(chars, new Comparator<Character>() {
        public int compare(Character c1, Character c2) {
          int cmp = Character.compare(Character.toLowerCase(c1.charValue()), Character.toLowerCase(c2.charValue()));
          if (cmp != 0)
            return cmp;
          return Character.compare(c1.charValue(), c2.charValue());
        }
      });
      StringBuilder sb = new StringBuilder(chars.length);
      for (char c : chars) {
        sb.append(c);
      }
      sorted.add(sb.toString());

    }

    Collections.sort(sorted);
    sorted.add("dummy");
    String prev = sorted.get(0);
    long sameCount = 1L;
    for (int i = 1; i < sorted.size(); i++) {
      if (sorted.get(i).equals(prev)) {
        sameCount++;
      } else {
        if (sameCount > 1) {
          anagCombi += fact(sameCount) / (2L * fact(sameCount - 2L));
        }
        prev = sorted.get(i);
        sameCount = 1L;

      }
    }

    System.out.println(anagCombi);

  }

  public static long fact(long a) {
    if (a == 0) {
      return 1L;
    }
    return a * fact(a - 1);
  }

}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    scn.nextLine();

    long anagCombi = 0;

    ArrayList<String> sorted = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      String s = scn.nextLine();
      Character[] chars = new Character[10];
      for (int j = 0; j < 10; j++) {
        chars[j] = s.charAt(j);
      }

      Arrays.sort(chars, new Comparator<Character>() {
        public int compare(Character c1, Character c2) {
          int cmp = Character.compare(Character.toLowerCase(c1.charValue()), Character.toLowerCase(c2.charValue()));
          if (cmp != 0)
            return cmp;
          return Character.compare(c1.charValue(), c2.charValue());
        }
      });
      StringBuilder sb = new StringBuilder(chars.length);
      for (char c : chars) {
        sb.append(c);
      }
      sorted.add(sb.toString());

    }

    Collections.sort(sorted);
    sorted.add("dummy");
    String prev = sorted.get(0);
    long sameCount = 1L;
    for (int i = 1; i < sorted.size(); i++) {
      if (sorted.get(i).equals(prev)) {
        sameCount++;
      } else {
        if (sameCount > 1) {
          anagCombi += fact(sameCount) / (2L * fact(sameCount - 2L));
        }
        prev = sorted.get(i);
        sameCount = 1L;

      }
    }

    System.out.println(anagCombi);

  }

  public static long fact(long a) {
    if (a == 0) {
      return 1;
    }
    return a * fact(a - 1);
  }

}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    scn.nextLine();

    long anagCombi = 0;

    ArrayList<String> sorted = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      String s = scn.nextLine();
      Character[] chars = new Character[10];
      for (int j = 0; j < 10; j++) {
        chars[j] = s.charAt(j);
      }

      Arrays.sort(chars, new Comparator<Character>() {
        public int compare(Character c1, Character c2) {
          int cmp = Character.compare(Character.toLowerCase(c1.charValue()), Character.toLowerCase(c2.charValue()));
          if (cmp != 0)
            return cmp;
          return Character.compare(c1.charValue(), c2.charValue());
        }
      });
      StringBuilder sb = new StringBuilder(chars.length);
      for (char c : chars) {
        sb.append(c);
      }
      sorted.add(sb.toString());

    }

    Collections.sort(sorted);
    sorted.add("dummy");
    String prev = sorted.get(0);
    long sameCount = 1L;
    for (int i = 1; i < sorted.size(); i++) {
      if (sorted.get(i).equals(prev)) {
        sameCount++;
      } else {
        if (sameCount > 1) {
          anagCombi += fact(sameCount) / (2L * fact(sameCount - 2L));
        }
        prev = sorted.get(i);
        sameCount = 1;

      }
    }

    System.out.println(anagCombi);

  }

  public static long fact(long a) {
    if (a == 0) {
      return 1;
    }
    return a * fact(a - 1);
  }

}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int M = scn.nextInt();

    ArrayList<Data> data = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      int A = scn.nextInt();
      int B = scn.nextInt();
      data.add(new Data(A, B));
    }

    Collections.sort(data, new DataComparator());

    int expense = 0;
    int drinkCount = 0;
    for (Data d : data) {
      drinkCount += d.stock;
      expense += d.stock * d.price;

      if (drinkCount >= M) {
        int excess = drinkCount - M;
        expense -= excess * d.price;
        break;
      }
    }

    System.out.println(expense);
  }

  public static class Data {
    private int price;
    private int stock;

    Data(int a, int b) {
      this.price = a;
      this.stock = b;
    }

    @Override
    public String toString() {
      return String.valueOf(this.price) + ":" + String.valueOf(this.stock);
    }
  }

  public static class DataComparator implements Comparator<Data> {
    @Override
    public int compare(Data d1, Data d2) {
      return d1.price < d2.price ? -1 : 1;
    }
  }

}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int M = scn.nextInt();

    ArrayList<Data> data = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      int A = scn.nextInt();
      int B = scn.nextInt();
      data.add(new Data(A, B));
    }

    Collections.sort(data, new DataComparator());

    int expense = 0;
    int drinkCount = 0;
    for (Data d : data) {
    drinkCount += d.stock;
    expense += d.stock * d.price;

    if (drinkCount >= M) {
        int excess = drinkCount - M;
        expense -= excess * d.price;
        break;
      }
    }

    System.out.println(expense);
  }

  public static class Data {
    private int price;
    private int stock;

    Data(int a, long b) {
      this.price = a;
      this.stock = b;
    }

    @Override
    public String toString() {
      return String.valueOf(this.price) + ":" + String.valueOf(this.stock);
    }
  }

  public static class DataComparator implements Comparator<Data> {
    @Override
    public int compare(Data d1, Data d2) {
      return d1.price < d2.price ? -1 : 1;
    }
  }

}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    long N = scn.nextLong();
    long M = scn.nextLong();

    ArrayList<Data> data = new ArrayList<>();
    for (long i = 0; i < N; i++) {
      long A = scn.nextLong();
      long B = scn.nextLong();
      data.add(new Data(A, B));
    }

    Collections.sort(data, new DataComparator());

    long expense = 0;
    // long drinkCount = 0;
    // for (Data d : data) {
    // drinkCount += d.stock;
    // expense += d.stock * d.price;

    // if (drinkCount >= M) {
    // long excess = drinkCount - M;
    // expense -= excess * d.price;
    // break;
    // }
    // }

    System.out.println(expense);
  }

  public static class Data {
    private long price;
    private long stock;

    Data(long a, long b) {
      this.price = a;
      this.stock = b;
    }

    @Override
    public String toString() {
      return String.valueOf(this.price) + ":" + String.valueOf(this.stock);
    }
  }

  public static class DataComparator implements Comparator<Data> {
    @Override
    public int compare(Data d1, Data d2) {
      return d1.price < d2.price ? -1 : 1;
    }
  }

}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    long N = scn.nextLong();
    long M = scn.nextLong();

    ArrayList<Data> data = new ArrayList<>();
    for (long i = 0; i < N; i++) {
      long A = scn.nextLong();
      long B = scn.nextLong();
      data.add(new Data(A, B));
    }

    Collections.sort(data, new DataComparator());

    long expense = 0;
    long drinkCount = 0;
    for (Data d : data) {
      drinkCount += d.stock;
      expense += d.stock * d.price;

      if (drinkCount >= M) {
        long excess = drinkCount - M;
        expense -= excess * d.price;
        break;
      }
    }

    System.out.println(expense);
  }

  public static class Data {
    private long price;
    private long stock;

    Data(long a, long b) {
      this.price = a;
      this.stock = b;
    }

    @Override
    public String toString() {
      return String.valueOf(this.price) + ":" + String.valueOf(this.stock);
    }
  }

  public static class DataComparator implements Comparator<Data> {
    @Override
    public int compare(Data d1, Data d2) {
      return d1.price < d2.price ? -1 : 1;
    }
  }

}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    long N = scn.nextInt();
    long M = scn.nextInt();

    ArrayList<Data> data = new ArrayList<>();
    for (long i = 0; i < N; i++) {
      long A = scn.nextInt();
      long B = scn.nextInt();
      data.add(new Data(A, B));
    }

    Collections.sort(data, new DataComparator());

    long expense = 0;
    long drinkCount = 0;
    for (Data d : data) {
      drinkCount += d.stock;
      expense += d.stock * d.price;

      if (drinkCount >= M) {
        long excess = drinkCount - M;
        expense -= excess * d.price;
        break;
      }
    }

    System.out.println(expense);
  }

  public static class Data {
    private long price;
    private long stock;

    Data(long a, long b) {
      this.price = a;
      this.stock = b;
    }

    @Override
    public String toString() {
      return String.valueOf(this.price) + ":" + String.valueOf(this.stock);
    }
  }

  public static class DataComparator implements Comparator<Data> {
    @Override
    public int compare(Data d1, Data d2) {
      return d1.price < d2.price ? -1 : 1;
    }
  }

}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    HashMap<Integer, Integer> oddMap = new HashMap<>();
    HashMap<Integer, Integer> evenMap = new HashMap<>();

    for (int i = 0; i < import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    HashMap<Integer, Integer> oddMap = new HashMap<>();
    HashMap<Integer, Integer> evenMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      int v = scn.nextInt();
      if (i % 2 == 0) {
        if (!evenMap.containsKey(v)) {
          evenMap.put(v, 1);
        } else {
          evenMap.put(v, evenMap.get(v) + 1);
        }
      } else {
        if (!oddMap.containsKey(v)) {
          oddMap.put(v, 1);
        } else {
          oddMap.put(v, oddMap.get(v) + 1);
        }
      }
    }

    ArrayList<Map.Entry<Integer, Integer>> evenMapList = new ArrayList<>(evenMap.entrySet());
    Collections.sort(evenMapList, new Comparator<Map.Entry<Integer, Integer>>() {
      public int compare(Map.Entry<Integer, Integer> e1, Map.Entry<Integer, Integer> e2) {
        if (e1.getValue() == e2.getValue()) {
          return 0;
        }
        return (e1.getValue() < e2.getValue()) ? 1 : -1;
      }
    });

    ArrayList<Map.Entry<Integer, Integer>> oddMapList = new ArrayList<>(oddMap.entrySet());
    Collections.sort(oddMapList, new Comparator<Map.Entry<Integer, Integer>>() {
      public int compare(Map.Entry<Integer, Integer> e1, Map.Entry<Integer, Integer> e2) {
        if (e1.getValue() == e2.getValue()) {
          return 0;
        }
        return (e1.getValue() < e2.getValue()) ? 1 : -1;
      }
    });

    int evenMostFrequent = evenMapList.get(0).getKey();
    int oddMostFrequent = oddMapList.get(0).getKey();
    int ans = 0;
    if (evenMostFrequent != oddMostFrequent) {
      evenMapList.get(0).setValue(0);
      oddMapList.get(0).setValue(0);
      for (Map.Entry<Integer, Integer> entry : evenMapList) {
        ans += entry.getValue();
      }

      for (Map.Entry<Integer, Integer> entry : oddMapList) {
        ans += entry.getValue();
      }

    } else {
      int ans1 = 0;
      int ans2 = 0;

      if (evenMapList.size() >= 2) {
        evenMapList.get(1).setValue(0);
        oddMapList.get(0).setValue(0);
        for (Map.Entry<Integer, Integer> entry : evenMapList) {
          ans1 += entry.getValue();
        }

        for (Map.Entry<Integer, Integer> entry : oddMapList) {
          ans1 += entry.getValue();
        }
      }
      if (oddMapList.size() >= 2) {

        oddMapList.get(1).setValue(0);
        evenMapList.get(0).setValue(0);
        for (Map.Entry<Integer, Integer> entry : evenMapList) {
          ans2 += entry.getValue();
        }

        for (Map.Entry<Integer, Integer> entry : oddMapList) {
          ans2 += entry.getValue();
        }
      }

      ans = Math.min(ans1, ans2);
      if (oddMapList.size() == 1 & evenMapList.size() == 1) {
        ans = N / 2;
      }
    }

    System.out.println(ans);
  }

}
N; i++) {
      int v = scn.nextInt();
      if (i % 2 == 0) {
        if (!evenMap.containsKey(v)) {
          evenMap.put(v, 1);
        } else {
          evenMap.put(v, evenMap.get(v) + 1);
        }
      } else {
        if (!oddMap.containsKey(v)) {
          oddMap.put(v, 1);
        } else {
          oddMap.put(v, oddMap.get(v) + 1);
        }
      }
    }

    ArrayList<Map.Entry<Integer, Integer>> evenMapList = new ArrayList<>(evenMap.entrySet());
    Collections.sort(evenMapList, new Comparator<Map.Entry<Integer, Integer>>() {
      public int compare(Map.Entry<Integer, Integer> e1, Map.Entry<Integer, Integer> e2) {
        if (e1.getValue() == e2.getValue()) {
          return 0;
        }
        return (e1.getValue() < e2.getValue()) ? 1 : -1;
      }
    });

    ArrayList<Map.Entry<Integer, Integer>> oddMapList = new ArrayList<>(oddMap.entrySet());
    Collections.sort(oddMapList, new Comparator<Map.Entry<Integer, Integer>>() {
      public int compare(Map.Entry<Integer, Integer> e1, Map.Entry<Integer, Integer> e2) {
        if (e1.getValue() == e2.getValue()) {
          return 0;
        }
        return (e1.getValue() < e2.getValue()) ? 1 : -1;
      }
    });

    int mostFrequent = evenMapList.get(0).getKey();
    evenMapList.get(0).setValue(0);
    int ans = 0;
    for (Map.Entry<Integer, Integer> entry : evenMapList) {
      ans += entry.getValue();
    }

    for (Map.Entry<Integer, Integer> entry : oddMapList) {
      if (entry.getKey() != mostFrequent) {
        entry.setValue(0);
        break;
      }
    }

    for (Map.Entry<Integer, Integer> entry : oddMapList) {
      ans += entry.getValue();
    }

    System.out.println(ans);
  }

}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    HashMap<Integer, Integer> oddMap = new HashMap<>();
    HashMap<Integer, Integer> evenMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      int v = scn.nextInt();
      if (i % 2 == 0) {
        if (!evenMap.containsKey(v)) {
          evenMap.put(v, 1);
        } else {
          evenMap.put(v, evenMap.get(v) + 1);
        }
      } else {
        if (!oddMap.containsKey(v)) {
          oddMap.put(v, 1);
        } else {
          oddMap.put(v, oddMap.get(v) + 1);
        }
      }
    }

    ArrayList<Map.Entry<Integer, Integer>> evenMapList = new ArrayList<>(evenMap.entrySet());
    Collections.sort(evenMapList, new Comparator<Map.Entry<Integer, Integer>>() {
      public int compare(Map.Entry<Integer, Integer> e1, Map.Entry<Integer, Integer> e2) {
        return (e1.getValue() < e2.getValue()) ? 1 : -1;
      }
    });

    ArrayList<Map.Entry<Integer, Integer>> oddMapList = new ArrayList<>(oddMap.entrySet());
    Collections.sort(oddMapList, new Comparator<Map.Entry<Integer, Integer>>() {
      public int compare(Map.Entry<Integer, Integer> e1, Map.Entry<Integer, Integer> e2) {
        return (e1.getValue() < e2.getValue()) ? 1 : -1;
      }
    });

    int mostFrequent = evenMapList.get(0).getKey();
    evenMapList.get(0).setValue(0);
    long ans = 0L;
    for (Map.Entry<Integer, Integer> entry : evenMapList) {
      ans += entry.getValue();
    }

    for (Map.Entry<Integer, Integer> entry : oddMapList) {
      if (entry.getKey() != mostFrequent) {
        entry.setValue(0);
        break;
      }
    }

    for (Map.Entry<Integer, Integer> entry : oddMapList) {
      ans += entry.getValue();
    }

    System.out.println(ans);
  }

}

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


Question:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    HashMap<Integer, Integer> oddMap = new HashMap<>();
    HashMap<Integer, Integer> evenMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      int v = scn.nextInt();
      if (i % 2 == 0) {
        if (!evenMap.containsKey(v)) {
          evenMap.put(v, 1);
        } else {
          evenMap.put(v, evenMap.get(v) + 1);
        }
      } else {
        if (!oddMap.containsKey(v)) {
          oddMap.put(v, 1);
        } else {
          oddMap.put(v, oddMap.get(v) + 1);
        }
      }
    }

    ArrayList<Map.Entry<Integer, Integer>> evenMapList = new ArrayList<>(evenMap.entrySet());
    Collections.sort(evenMapList, new Comparator<Map.Entry<Integer, Integer>>() {
      public int compare(Map.Entry<Integer, Integer> e1, Map.Entry<Integer, Integer> e2) {
        return (e1.getValue() < e2.getValue()) ? 1 : -1;
      }
    });

    ArrayList<Map.Entry<Integer, Integer>> oddMapList = new ArrayList<>(oddMap.entrySet());
    Collections.sort(oddMapList, new Comparator<Map.Entry<Integer, Integer>>() {
      public int compare(Map.Entry<Integer, Integer> e1, Map.Entry<Integer, Integer> e2) {
        return (e1.getValue() < e2.getValue()) ? 1 : -1;
      }
    });

    int mostFrequent = evenMapList.get(0).getKey();
    evenMapList.get(0).setValue(0);
    int ans = 0;
    for (Map.Entry<Integer, Integer> entry : evenMapList) {
      ans += entry.getValue();
    }

    for (Map.Entry<Integer, Integer> entry : oddMapList) {
      if (entry.getKey() != mostFrequent) {
        entry.setValue(0);
        break;
      }
    }

    for (Map.Entry<Integer, Integer> entry : oddMapList) {
      ans += entry.getValue();
    }

    System.out.println(ans);
  }

}

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


Question:
import java.util.Scanner;

public class SelectionDemo {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();

		if(T*S >= D) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

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


Question:
import java.util.Scanner;

public class SelectionDemo {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();

		if(T*S >= D) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}

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


Question:
import org.junit.Test;

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

public class Main {
    static int n;
    static boolean[][] connected;

    static public int countPattern(int pos, Set<Integer> visited) {
        if (visited.size() == n) return 1;

        int count = 0;
        for (int i = 0; i < n; i++) {
            if (connected[pos][i] && !visited.contains(i)) {
                visited.add(i);
                count += countPattern(i, visited);
                visited.remove(i);
            }
        }
        return count;
    }

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

        connected = new boolean[n][n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;

            connected[a][b] = true;
            connected[b][a] = true;
        }

        Set<Integer> visited = new HashSet<>();
        visited.add(0);
        int count = countPattern(0, visited);
        System.out.println(count);
    }

    @Test
    public void test() {
        Main m = new Main();
    }
}

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


Question:
import org.junit.Test;

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

public class Main {
    static int n;
    static boolean[][] connected;

    static public int countPattern(int pos, Set<Integer> visited) {
        if (visited.size() == n) return 1;

        int count = 0;
        for (int i = 0; i < n; i++) {
            if (connected[pos][i] && !visited.contains(i)) {
                visited.add(i);
                count += countPattern(i, visited);
                visited.remove(i);
            }
        }
        return count;
    }

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

        connected = new boolean[n][n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;

            connected[a][b] = true;
            connected[b][a] = true;
        }

        Set<Integer> visited = new HashSet<>();
        visited.add(0);
        int count = countPattern(0, visited);
        System.out.println(count);
    }

    @Test
    public void test() {
        Main m = new Main();
    }
}

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


Question:
package atcoder.beginnercontest.abc054.c;

import org.junit.Test;

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

public class Main {
    static int n;
    static boolean[][] connected;

    static public int countPattern(int pos, Set<Integer> visited) {
        if (visited.size() == n) return 1;

        int count = 0;
        for (int i = 0; i < n; i++) {
            if (connected[pos][i] && !visited.contains(i)) {
                visited.add(i);
                count += countPattern(i, visited);
                visited.remove(i);
            }
        }
        return count;
    }

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

        connected = new boolean[n][n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;

            connected[a][b] = true;
            connected[b][a] = true;
        }

        Set<Integer> visited = new HashSet<>();
        visited.add(0);
        int count = countPattern(0, visited);
        System.out.println(count);
    }

    @Test
    public void test() {
        Main m = new Main();
    }
}

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


Question:
import java.util.Scanner;

/**
 * Created by sonetsuyoshi on 2016/07/31.
 */
public class Main {

    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] chs = sc.nextLine().toCharArray();
        chs[5] = ' ';
        chs[13] = ' ';

        for(char ch: chs) System.out.print(ch);
        System.out.println();
    }

    @Test
    public void test() {
        Main m = new Main();
    }
}

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


Question:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long a,b;
        a = scanner.nextLong();
        b = scanner.nextLong();
        if (b == 1) {
            System.out.println(0);
            return;
        }
        if (a < Math.abs(a - b)) {
            System.out.println(a);
            return;
        }
        long temp;
        while (true) {
            temp = Math.abs(a - b);
            if (temp >= a) {
                System.out.println(a);
                return;
            }
            a = temp;
        }
    }

}

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


Question:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        // aC2
        long c = (a * (a-1)) /kaijo(a);
        long d = (b * (b-1)) /kaijo(b);
        System.out.println(c + d);
    }

    static long kaijo(long n){
        if(n == 0){
            return 1;
        }
        return n * kaijo(n-1);
    }
}

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


Question:
import java.util.*;
    class Berg {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int counter =0;

        String S = input.next();
        String T = input.next();

        char[] first  = S.toLowerCase().toCharArray();
        char[] second = T.toLowerCase().toCharArray();

        int minLength = Math.min(first.length, second.length);

        for(int i = 0; i < minLength; i++)
        {
            if (first[i] != second[i])
            {
                counter++;
            }
        }
        System.out.println(counter);
    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Queue;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.LinkedList;
import java.io.InputStream;

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

    static class APondSkater {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int k = sc.nextInt();
            int[][] grid = new int[n][m];
            int[][] dist = new int[n][m];
            for (int[] x : dist) Arrays.fill(x, 1000000);
            int[] dx = {-1, 0, 1, 0};
            int[] dy = {0, -1, 0, 1};
            int x1 = sc.nextInt() - 1;
            int y1 = sc.nextInt() - 1;
            int x2 = sc.nextInt() - 1;
            int y2 = sc.nextInt() - 1;
            for (int i = 0; i < n; i++) {
                char[] tmp = sc.nextLine().toCharArray();
                for (int j = 0; j < m; j++) {
                    grid[i][j] = (tmp[j] == '@' ? 1 : 0);
                }
            }
            Queue<pair> q = new LinkedList<>();
            q.add(new pair(x1, y1));
            dist[x1][y1] = 0;
            while (q.size() > 0) {
                pair cur = q.poll();
                for (int i = 0; i < 4; i++) {
                    for (int c = 1; c <= k; c++) {
                        if (valid(cur.a + c * dx[i], cur.b + c * dy[i], n, m) && grid[cur.a + c * dx[i]][cur.b + c * dy[i]] == 0) {
                            if (1 + dist[cur.a][cur.b] < dist[cur.a + c * dx[i]][cur.b + c * dy[i]]) {
                                dist[cur.a + c * dx[i]][cur.b + c * dy[i]] = 1 + dist[cur.a][cur.b];
                                q.add(new pair(cur.a + c * dx[i], cur.b + c * dy[i]));
                            }

                        } else break;
                    }
                }
            }
            int ans = dist[x2][y2];
            pw.println(ans == 1000000 ? -1 : ans);

        }

        boolean valid(int i, int j, int n, int m) {
            if (i < 0) return false;
            if (i >= n) return false;
            if (j < 0) return false;
            if (j >= m) return false;
            return true;
        }

        public class pair {
            int a;
            int b;

            public pair(int a, int b) {
                this.a = a;
                this.b = b;
            }

        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

        public String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

    }
}

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


Question:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Queue;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.LinkedList;
import java.io.InputStream;

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

    static class APondSkater {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int k = sc.nextInt();
            int[][] grid = new int[n][m];
            int[][] dist = new int[n][m];
            for (int[] x : dist) Arrays.fill(x, 1000000);
            int[] dx = {-1, 0, 1, 0};
            int[] dy = {0, -1, 0, 1};
            int x1 = sc.nextInt() - 1;
            int y1 = sc.nextInt() - 1;
            int x2 = sc.nextInt() - 1;
            int y2 = sc.nextInt() - 1;
            for (int i = 0; i < n; i++) {
                char[] tmp = sc.nextLine().toCharArray();
                for (int j = 0; j < m; j++) {
                    grid[i][j] = (tmp[j] == '@' ? 1 : 0);
                }
            }
            //    boolean [][] vis = new boolean[n][m];
            Queue<pair> q = new LinkedList<>();
            q.add(new pair(x1, y1));
            dist[x1][y1] = 0;
            //  vis[x1][y1] = true;
            int ans = Integer.MAX_VALUE;
            while (q.size() > 0) {
                pair cur = q.poll();
                if (cur.a == x2 && cur.b == y2) {
                    ans = Math.min(ans, dist[x2][y2]);
                }
                for (int i = 0; i < 4; i++) {
                    for (int c = 1; c <= k; c++) {
//                    if(cur.a ==0&&cur.b==3){
//                        pw.println(cur.a+c*dx[i]+" "+(cur.b+c*dy[i]));
//                    }
                        if (valid(cur.a + c * dx[i], cur.b + c * dy[i], n, m) && grid[cur.a + c * dx[i]][cur.b + c * dy[i]] == 0) {

                            if (1 + dist[cur.a][cur.b] < dist[cur.a + c * dx[i]][cur.b + c * dy[i]]) {
                                //   vis[cur.a+c*dx[i]][cur.b+c*dy[i]] = true;
                                dist[cur.a + c * dx[i]][cur.b + c * dy[i]] = 1 + dist[cur.a][cur.b];
                                q.add(new pair(cur.a + c * dx[i], cur.b + c * dy[i]));
                            }
                        } else break;
                    }
                }
            }
//        for(int []x:dist){
//            for(int y :x){
//                pw.print((y==1000000?-1:y)+" ");
//            }pw.println();
//        }
            pw.println(ans == Integer.MAX_VALUE ? -1 : ans);

        }

        boolean valid(int i, int j, int n, int m) {
            if (i < 0) return false;
            if (i >= n) return false;
            if (j < 0) return false;
            if (j >= m) return false;
            return true;
        }

        public class pair implements Comparable<pair> {
            int a;
            int b;

            public pair(int a, int b) {
                this.a = a;
                this.b = b;
            }

            public int compareTo(pair pair) {
                return a - pair.a == 0 ? b - pair.b : a - pair.a;
            }

        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

        public String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

    }
}

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


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

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int h = sc.nextInt(), w = sc.nextInt(), k = sc.nextInt(), x1 = sc.nextInt() - 1, y1 = sc.nextInt() - 1,
				x2 = sc.nextInt() - 1, y2 = sc.nextInt() - 1;
		char[][] grid = new char[h][];
		for (int i = 0; i < grid.length; i++) {
			grid[i] = sc.next().toCharArray();
		}
		int[][] dist = new int[h][w];
		for (int[] x : dist)
			Arrays.fill(x, -1);
		Queue<int[]> q = new LinkedList<int[]>();
		q.add(new int[] { x1, y1 });
		dist[x1][y1] = 0;
		int[] dx = { 0, 0, -1, 1 };
		int[] dy = { 1, -1, 0, 0 };
		while (!q.isEmpty()) {
			int[] cur = q.poll();
			int curdist = dist[cur[0]][cur[1]];
			for (int j = 0; j < 4; j++) {
				for (int i = 1; i <= k; i++) {
					int nxtx = cur[0] + i * dx[j];
					int nxty = cur[1] + i * dy[j];
					if (nxtx >= h || nxtx < 0 || nxty < 0 || nxty >= w || grid[nxtx][nxty] == '@'
							|| (dist[nxtx][nxty] != -1 && dist[nxtx][nxty] <= curdist))
						break;
					dist[nxtx][nxty] = curdist + 1;
					q.add(new int[] { nxtx, nxty });
				}
			}
		}
		pw.println(dist[x2][y2]);
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

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

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

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

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

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

	}

}

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


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

public class Abc170f {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int h = sc.nextInt(), w = sc.nextInt(), k = sc.nextInt(), x1 = sc.nextInt() - 1, y1 = sc.nextInt() - 1,
				x2 = sc.nextInt() - 1, y2 = sc.nextInt() - 1;
		char[][] grid = new char[h][];
		for (int i = 0; i < grid.length; i++) {
			grid[i] = sc.next().toCharArray();
		}
		int[][] dist = new int[h][w];
		for (int[] x : dist)
			Arrays.fill(x, -1);
		Queue<int[]> q = new LinkedList<int[]>();
		q.add(new int[] { x1, y1 });
		dist[x1][y1] = 0;
		int[] dx = { 0, 0, -1, 1 };
		int[] dy = { 1, -1, 0, 0 };
		while (!q.isEmpty()) {
			int[] cur = q.poll();
			int curdist = dist[cur[0]][cur[1]];
			for (int j = 0; j < 4; j++) {
				for (int i = 1; i <= k; i++) {
					int nxtx = cur[0] + i * dx[j];
					int nxty = cur[1] + i * dy[j];
					if (nxtx >= h || nxtx < 0 || nxty < 0 || nxty >= w || grid[nxtx][nxty] == '@'
							|| (dist[nxtx][nxty] != -1 && dist[nxtx][nxty] <= curdist))
						break;
					dist[nxtx][nxty] = curdist + 1;
					q.add(new int[] { nxtx, nxty });
				}
			}
		}
		pw.println(dist[x2][y2]);
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

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

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

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

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

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

	}

}

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


Question:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;

public class COVID {

	static int[] fac;
	static int mod=(int)1e9+7;
	static ArrayList<Integer>[] adjList;
	static int dfs_num[],dfs_low[],timer;
	static boolean[] vis;
	static int r,c,k;
	static int x,y;
	static char[][] grid;
	static int[] dx={1,-1,0,0};
	static int[] dy={0,0,1,-1};
	static int INF=(int)1e9;

	public static void main(String[] args) throws Exception {

		Scanner	sc = new Scanner(System.in);
		PrintWriter	pw =new PrintWriter(System.out);
		r=sc.nextInt();
		c=sc.nextInt();
		k=sc.nextInt();
		int sx=sc.nextInt()-1;
		int sy=sc.nextInt()-1;
		x=sc.nextInt()-1;
		y=sc.nextInt()-1;
		grid=new char[r][c];
		boolean[][] done=new boolean[r][c];
		for(int i=0;i<r;i++)
			grid[i]=sc.next().toCharArray();

		Queue<Pair> q= new LinkedList();
		int[][] dist=new int[r][c];

		for(int[] arr:dist)
			Arrays.fill(arr, INF);

		q.add(new Pair(sx,sy,-1,0));
		dist[sx][sy]=0;

		while(!q.isEmpty()) {
			Pair node =q.poll();

			done[node.x][node.y]=true;
			int tmp=node.dist;
			for(int p=0;p<dx.length;p++) {
				int nx=node.x+dx[p];
				int ny=node.y+dy[p];
				if(nx<0||nx>=r||ny<0||ny>=c||grid[nx][ny]=='@'||done[nx][ny])continue;
				int nxt=0;
				if(p==node.z) {
					 nxt=tmp+1;

				}else {
					 nxt=1+k*((tmp+k-1)/k);
				}
				 if(nxt<=dist[nx][ny])
						q.add(new Pair(nx,ny,p,dist[nx][ny]=nxt));

			}

		}
		if(dist[x][y]==INF)pw.println(-1);
		else
			pw.println((dist[x][y]+k-1)/k);

		pw.flush();
		pw.close();

	}

	static long gcd(long a, long b) {
		return (b==0)?a:gcd(b,a%b);
	}
	static long lcm(long a, long b) {
		return a/gcd(a,b)*b;
	}
	public static int log(int n , int base) {
		int ans=0;
		while(n+1>base) {
			ans++;
			n/=base;
		}
		return ans;
	}
	static long square(long l) {
		return l*l;
	}
	static int pow(int b,long e) {
		int ans=1;
		while(e>0) {
			if((e&1)==1)
				ans=(int)((ans*1l*b));
			e>>=1;{

			}
			b=(int)((b*1l*b));
		}
		return ans;
	}
	static int powmod(int b,long e, int mod) {
		int ans=1;
		b%=mod;
		while(e>0) {
			if((e&1)==1)
				ans=(int)((ans*1l*b)%mod);
			e>>=1;
			b=(int)((b*1l*b)%mod);
		}
		return ans;
	}
	public static long add(long a, long b) {
		return (a+b)%mod;
	}
	public static long mul(long a, long b) {
		return ((a%mod)*(b%mod))%mod;
	}

	static class Pair implements Comparable<Pair>{
		int  x;int y;int z,dist;

		public Pair(int a,int b, int c,int w) {
			this.x=a;y=b;z=c;dist=w;
		}

		public int compareTo(Pair o) {
			//			return (x==o.x)?((y>o.y)?1:(y==o.y)?0:-1):((x>o.x)?1:-1);
			return dist-o.dist;
		}

		@Override

		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + x;
			result = prime * result + y;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (x != other.x)
				return false;
			if (y != other.y)
				return false;
			return true;
		}

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String s) throws FileNotFoundException{	br = new BufferedReader(new FileReader(s));}

		public long[] nextLongArr(int n) throws IOException {
			long[] arr=new long[n];
			for(int i=0;i<n;i++)
				arr[i]=nextLong();
			return arr;
		}
		public int[] nextIntArr(int n) throws IOException {
			int[] arr=new int[n];
			for(int i=0;i<n;i++)
				arr[i]=nextInt();
			return arr;
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine()," ,");
			return st.nextToken();
		}

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

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

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

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++) {
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
				if (sb.length() == 18) {
					res += Long.parseLong(sb.toString()) / f;
					sb = new StringBuilder("0");
				}
			}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

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

	}

	public static void shuffle(int[] a) {
		int n = a.length;
		for (int i = 0; i < n; i++) {
			int r = i + (int) (Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
	}
}

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


Question:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;

public class COVID {

	static int[] fac;
	static int mod=(int)1e9+7;
	static ArrayList<Integer>[] adjList;
	static int dfs_num[],dfs_low[],timer;
	static boolean[] vis;
	static int r,c,k;
	static int x,y;
	static char[][] grid;
	static int[] dx={1,-1,0,0};
	static int[] dy={0,0,1,-1};
	static int INF=(int)1e7;

	public static void main(String[] args) throws Exception {

		Scanner	sc = new Scanner(System.in);
		PrintWriter	pw =new PrintWriter(System.out);
		r=sc.nextInt();
		c=sc.nextInt();
		k=sc.nextInt();
		int sx=sc.nextInt()-1;
		int sy=sc.nextInt()-1;
		x=sc.nextInt()-1;
		y=sc.nextInt()-1;
		grid=new char[r][c];
		for(int i=0;i<r;i++)
			grid[i]=sc.next().toCharArray();

		PriorityQueue<Pair> q= new PriorityQueue<>();
		int[][] dist=new int[r][c];

		for(int[] arr:dist)
			Arrays.fill(arr, INF);

		q.add(new Pair(sx,sy,-1,0));
		dist[sx][sy]=0;

		while(!q.isEmpty()) {
			Pair node =q.poll();
			if(dist[node.x][node.y]<node.dist)continue;
			//		System.out.println(node.x+" "+node.y+" "+node.z+" "+ node.dist);
			dist[node.x][node.y]=node.dist;

			int tmp=node.dist;

			for(int p=0;p<dx.length;p++) {
				int nx=node.x+dx[p];
				int ny=node.y+dy[p];
				if(nx<0||nx>=r||ny<0||ny>=c||grid[nx][ny]=='@')continue;

				if(p==node.z) {
					q.add(new Pair(nx,ny,p,tmp+1));

				}else {
					q.add(new Pair(nx,ny,p,1+k*((tmp+k-1)/k)));
				}
			}

		}
		if(dist[x][y]==INF)pw.println(-1);
		else
			pw.println((dist[x][y]+k-1)/k);

		pw.flush();
		pw.close();

	}

	static long gcd(long a, long b) {
		return (b==0)?a:gcd(b,a%b);
	}
	static long lcm(long a, long b) {
		return a/gcd(a,b)*b;
	}
	public static int log(int n , int base) {
		int ans=0;
		while(n+1>base) {
			ans++;
			n/=base;
		}
		return ans;
	}
	static long square(long l) {
		return l*l;
	}
	static int pow(int b,long e) {
		int ans=1;
		while(e>0) {
			if((e&1)==1)
				ans=(int)((ans*1l*b));
			e>>=1;{

			}
			b=(int)((b*1l*b));
		}
		return ans;
	}
	static int powmod(int b,long e, int mod) {
		int ans=1;
		b%=mod;
		while(e>0) {
			if((e&1)==1)
				ans=(int)((ans*1l*b)%mod);
			e>>=1;
			b=(int)((b*1l*b)%mod);
		}
		return ans;
	}
	public static long add(long a, long b) {
		return (a+b)%mod;
	}
	public static long mul(long a, long b) {
		return ((a%mod)*(b%mod))%mod;
	}

	static class Pair implements Comparable<Pair>{
		int  x;int y;int z,dist;

		public Pair(int a,int b, int c,int w) {
			this.x=a;y=b;z=c;dist=w;
		}

		public int compareTo(Pair o) {
			//			return (x==o.x)?((y>o.y)?1:(y==o.y)?0:-1):((x>o.x)?1:-1);
			return dist-o.dist;
		}

		@Override

		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + x;
			result = prime * result + y;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (x != other.x)
				return false;
			if (y != other.y)
				return false;
			return true;
		}

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String s) throws FileNotFoundException{	br = new BufferedReader(new FileReader(s));}

		public long[] nextLongArr(int n) throws IOException {
			long[] arr=new long[n];
			for(int i=0;i<n;i++)
				arr[i]=nextLong();
			return arr;
		}
		public int[] nextIntArr(int n) throws IOException {
			int[] arr=new int[n];
			for(int i=0;i<n;i++)
				arr[i]=nextInt();
			return arr;
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine()," ,");
			return st.nextToken();
		}

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

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

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

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++) {
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
				if (sb.length() == 18) {
					res += Long.parseLong(sb.toString()) / f;
					sb = new StringBuilder("0");
				}
			}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

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

	}

	public static void shuffle(int[] a) {
		int n = a.length;
		for (int i = 0; i < n; i++) {
			int r = i + (int) (Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
	}
}

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


Question:
//package com.company;

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

public class Giveaway {
    public class Main {
//    public static boolean getSum(int n)
    {
        int sum = 0;

        while (n != 0)
        {
            sum = n % 10;
            n = n/10;
            if(sum==7)
                return true;
        }

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

        out = new PrintWriter(new BufferedOutputStream(System.out));
        MyScanner sc = new MyScanner();//start
        out.println(getSum(sc.nextInt())?"Yes":"No");
        out.close();
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

    }
//--------------------------------------------------------

}

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


Question:
import java.util.*;
class A-Poor
{

	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
         Scanner sc=new Scanner(System.in);
         int array[]=new int[3];
         for(int i=0;i<3;i++)
        	 array[i]=sc.nextInt();
         find(array);
	}

	private static void find(int[] array)
	{
		int count=0;
		for(int i=0;i<2;i++)
		{
			for(int j=i+1;j<3;j++)
			{
				if(array[i]==array[j])
					count++;
			}
		}
		if(count==1)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

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


Question:
import java.util.*;
class A-Poor {

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

	private static void find(int[] array)
	{
		int count=0;
		for(int i=0;i<2;i++)
		{
			for(int j=i+1;j<3;j++)
			{
				if(array[i]==array[j])
					count++;
			}
		}
		if(count==1)
			System.out.println("Yes");
		else
			System.out.println("No");

	}

}

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


Question:
Import java.util.*;
Class Triple{
          Public static void main(String[] args){
             Scanner scanner = new Scanner(System.in);
              int A = scanner.nextInt();
              int B = scanner.nextInt();
              int C = scanner.nextInt();
              if(A==B){
                             if(B==C) System.out.println("No");
                             else System.out.println("Yes");
               }
              else if(A==C){
                             if(B==C) System.out.println("No");
                             else System.out.println("Yes");
               }
              else if(B==C){
                             if(A==C) System.out.println("No");
                             else System.out.println("Yes");
               }
              else System.out.println("No");
}
}

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


Question:
import java.util.Scanner;

class PoorNumber {
	static boolean check(int a, int b, int c) {
		if((a==b&&b!=c)||(a==c&&a!=b)||(b==c&&a!=b))
			return true;
		return false;
	}
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();

		if(check(a, b, c))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

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


Question:
import java.util.Scanner;

public class PoorNumber {
	static boolean check(int a, int b, int c) {
		if((a==b&&b!=c)||(a==c&&a!=b)||(b==c&&a!=b))
			return true;
		return false;
	}
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();

		if(check(a, b, c))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

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


Question:
import java.util.*;
public class poor{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		boolean poor = false;
		if (!(a==b & b==c)) {
			if (a==b || b==c || a==c) {
				poor = true;
			}
		}
		if (poor) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}

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


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

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

        System.out.print("Input first number: ");
        int x = in.nextInt();
        System.out.print("Input second number: ");
        int y = in.nextInt();
        System.out.print("Input third number: ");
        int z = in.nextInt();

        if (x == y && x == z)
        {
            System.out.println("All numbers are equal");
        }
        else if ((x == y) || (x == z) || (z == y))
        {
            System.out.println("Neither all are equal or different");
        }
        else
        {
            System.out.println("All numbers are different");
        }
    }

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


Question:
public class Main {

	public static void main(String[] args) {
		int n = Integer.parseInt(args[0]);
		int m = Integer.parseInt(args[0]);
		if (n >=1 || n<= 100) {
			if (m >= 0 || m <= n) {
				if (m== n) {
					System.out.println("yes");
				}
			}
		}
		else {
			System.out.println("no");
		}
	}

}

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


Question:
import java.util.*;

class Solution {
	public static boolean contest (int required, int accepted) {
		if (required == accepted) {
			return true;
		}
		else return false;
	}

	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		int required = input.nextInt();
		int accepted = input.nextInt();
		if (contest(required, accepted) == true) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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


Question:
import java.util.*;

class Solution {
	public static boolean contest (int required, int accepted) {
		if (required == accepted) {
			return true;
		}
		else return false;
	}

	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		int required = input.nextInt();
		int accepted = input.nextInt();
		System.out.println (contest(required, accepted));
	}
}

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


Question:
import java.util.Scanner;

public class EjerB {

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

		String[] in = sc.nextLine().split(" ");

		if(in[0].equals(in[1])) {
			System.out.println("Yes");
		}else System.out.println("No");
	}
}

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


Question:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import java.util.Scanner;

/**
 *
 * @author Nour
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
 //S is SUN, MON, TUE, WED, THU, FRI, or SAT.
 Scanner input=new Scanner(System.in);
 String S =input.next();
 if (S.equals("SUN")){
     System.out.println(7);}
 else if(S.equals("MON")){
     System.out.println(6);}
 else if(S.equals("TUE")){
     System.out.println(5);}
else if(S.equals("WED")){
     System.out.println(4);}
 else if(S.equals("THU")){
     System.out.println(3);}
 else if(S.equals("FRI")){
     System.out.println(2);}
 else if(S.equals("SAT")){
     System.out.println(1);
    }}

}

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


Question:
import java.util.*;
public class Content1 {
    public static void main(String[] args) {
        String[] WeekDAYS = new String[]{"SUN","MON","TUE","WED","THU","FRI","SAT"};
        Scanner obj1=new Scanner(System.in);
        String str = obj1.nextLine();
        if (str.equals("SUN"))
            System.out.println(7);
        else if(str.equals("MON"))
            System.out.println(6);
        else if(str.equals("TUE"))
            System.out.println(5);
        else if(str.equals("WED"))
            System.out.println(4);
        else if(str.equals("THU"))
            System.out.println(3);
        else if(str.equals("FRI"))
            System.out.println(2);
        else if(str.equals("SAT"))
            System.out.println(1);

    }

}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.ArrayList;
public class Pr_5 {

    public static void main(String[] args) {
        FastReader f = new FastReader();

     long n = f.nextLong();
     long q=(long)Math.sqrt(n);
     ArrayList<Long> a1 = new ArrayList<Long>();

     for(long i = 1 ;i <= q ; i++){
         if(n%i==0){
         a1.add(i);
        // long x =(long)(n/i);
         a1.add((long)(n/i));

         }
     }

        long [] arr = new long[a1.size()];
        for(int i= 0;i<arr.length;i++){
            arr[i]=a1.get(i);
        }
     Arrays.sort(arr);
     int mid=(int)arr.length/2;

       System.out.println((arr[mid] + arr[mid-1])-2);

    }
 }

class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

        byte nextByte()
        {
            return Byte.parseByte(next());
        }

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

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

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

}

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


Question:
import java.util.Scanner;

public class Test
{
    public static void main(String[] args)
    {
        Scanner in1 = new Scanner(System.in);
        int N = in1.nextInt();
        int D[]=new int [N];
        Scanner d = new Scanner(System.in);
        int sum=0;
        for (int x=0;x<N;x++)
        {
            D[x]=d.nextInt();
        }
        for (int y=0;y<N-1;y++)
        {
            for (int x=y+1;x<N;x++)
            {
                sum+=D[x]*D[y];
            }
        }
        System.out.print(sum);
    }
}

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


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

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

      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();

      int[] order = new int[n];

      /*for(int i = 0; i < n; i++) {
          order[i] = 0;
      }*/

      for(int i = 1; i <= n; i++) {
          int num = sc.nextInt();

          order[num-1] = i;
      }

      String output = "";

      for(int i = 0; i < n; i++) {
          output += order[i];
          output += " ";
      }

      System.out.print(output);

    }
}

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


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

	public static void main(String[] args) {
		String S, T;
		int count= 0;
		Scanner scan = new Scanner(System.in);
		S=scan.nextLine();
		T=scan.nextLine();
		for (int i= 0; i<S.length();i++) {
			if(S.charAt(i)==T.charAt(i)) {
				++count;
			}
		}
		System.out.println(count);

	}

}

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


Question:
		String S, T;
		int count= 0;
		Scanner scan = new Scanner(System.in);
		S=scan.nextLine();
		T=scan.nextLine();
		for (int i= 0; i<S.length();i++) {
			if(S.charAt(i)==T.charAt(i)) {
				++count;
			}
		}
		System.out.println(count);

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


Question:
import java.util.*;
public class atCoder1
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.nextLine();
		if(a < 3200)
		{
			System.out.println("red");
		}
		else if(a >= 3200)
			System.out.println(s);
	}
}

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


Question:
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

char s[1000000];
int arr;
int main(){
	scanf("%d%s",&arr,&s);
	if(arr>=3200){
		cout <<s<<endl;
	}else{
		cout <<"red"<<endl;
	}
	return 0;
}

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


Question:
public class Main{

     public static void main(String[] args){

                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                String s = sc.next();
                if (n >= 3200) {
                    System.out.println(s);
                } else {
                    System.out.printf("red");
                }

     }

}

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


Question:
import java.util.Scanner;

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

        int n=sc.nextInt();
        String str;
        long arr[]=new long[n];
        int num=0;
        for(int i=0;i<n;i++) {
        	str=sc.next();
        	for(int j=0;j<str.length();j++) {
        		num+=(int)str.charAt(j)%5*2%10*4;
        	}
        	arr[i]=num;
        	num=0;
        }

        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<arr.length;i++) {
        	for(int j=i+1;j<arr.length;j++) {
        		if(arr[j]>arr[i]) {
        			break;
        		}
        		if(arr[i]==arr[j]) {
        			sum++;
        		}
        	}
        }
//        for(long i:arr) {
//        	System.out.println(i);
//        }

        System.out.println(sum);
    }
}

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


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

public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		List<char[]> list=new ArrayList<>();
		for(int i=0;i<n;i++){
			String data=in.next();
			char[] arr=data.toCharArray();
			Arrays.sort(arr);
			list.add(arr);
		}
		int sum=0;
		for (int i = 0; i < list.size(); i++) {
			for (int j = 0; j < list.size(); j++) {
				if(i!=j){
					if(Arrays.equals(list.get(i), list.get(j))){
						sum++;
					}
				}
			}
		}
		sum=sum/2;
		System.out.println(sum);

	}
}

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


Question:
package sd;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		List<char[]> list=new ArrayList<>();
		for(int i=0;i<n;i++){
			String data=in.next();
			char[] arr=data.toCharArray();
			Arrays.sort(arr);
			list.add(arr);
		}
		int sum=0;
		for (int i = 0; i < list.size(); i++) {
			for (int j = 0; j < list.size(); j++) {
				if(i!=j){
					if(Arrays.equals(list.get(i), list.get(j))){
						sum++;
					}
				}
			}
		}
		sum=sum/2;
		System.out.println(sum);

	}
}

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


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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int a=0,b=0,n1=0,n2=0,p1=0,p2=0,i=0,j=0,k=1;
	Scanner scan=new Scanner(System.in);
	while (k!=0) {
		k++;
	 a=scan.nextInt();
	 b=scan.nextInt();
    i=b-a;
    if(i%2==0) {
    k=b-i/2;
    System.out.println(k);
   }
   else
   System.out.println("IMPOSSIBLE");

	   }

	 }
}

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


Question:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner  input = new Scanner(System.in);

        int A = input.nextInt();
        int B = input.nextInt();

        int count = 0; int i ;
        if(A>B){

            for ( i = 0; i >= 0; i++) {
                int x= Math.abs(A - i);
                int y = Math.abs(B - i);
                Math.abs(x);
                Math.abs(y);
                System.out.println(x+" "+y);
                if (x == y){
                count ++;
                break;
                }
            }
            if (count > 0 ){
            System.out.println(i); }
            else{
                System.out.println("IMPOSSIBLE");
            }
        }
            if (count > 0 ){
            System.out.println(i); }
            else{
                System.out.println("IMPOSSIBLE");
            }
        }

    }
}

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


Question:
package sd;

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

public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		String arr=in.next();
		Map<Character, Integer> map=new HashMap<Character, Integer>();
		for (int i = 0; i <arr.length(); i++) {
			if(map.get(arr.charAt(i))==null){
				map.put(arr.charAt(i), 1);
			}else{
				map.put(arr.charAt(i), map.get(arr.charAt(i))+1);
			}
		}
		if(map.size()==2){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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


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

public class lt {
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int h = in.nextInt(), w = in.nextInt();
        char[][] areaCharred = new char[h][w];
        int[][] horizontalLight = new int[h][w];
        int[][] verticalLight = new int[w][h];
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < h; i++){
            areaCharred[i] = in.next().toCharArray();
        }
        for (int i = 0; i < h; i++){
            int prevH = 0;
            for (int j = 0; j < w; j++){
                if (areaCharred[i][j] == '#'){
                    Arrays.fill(horizontalLight[i], prevH, j, j - prevH);
                    prevH = j + 1;
                }
            }
            Arrays.fill(horizontalLight[i], prevH, w, w - prevH);
        }
        for (int i = 0; i < w; i++){
            int prevV = 0;
            for (int j = 0; j < h; j++){
                if (areaCharred[j][i] == '#') {
                    Arrays.fill(verticalLight[i], prevV, j, j - prevV);
                    prevV = j + 1;
                }
            }
            Arrays.fill(verticalLight[i], prevV, h, h - prevV);
        }
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                max = Math.max(horizontalLight[i][j] + verticalLight[j][i] - 1, max);
            }
        }
        System.out.println(max);
    }
}

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


Question:
package maratonas;

import java.util.Scanner;

public class Maratonas {

    public static void main(String[] args) {
        Scanner t = new Scanner(System.in);
        int a = t.nextInt();
        int b = t.nextInt();
        int sum = 0;
        if (a>=b){
            sum+=a;
            a--;
        } else {
            sum+=b;
            b--;
        }
        if (a>=b){
            sum+=a;
            a--;
        } else {
            sum+=b;
            b--;
        }
        System.out.println(sum);
    }
}

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


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

	int a,b;
	a=input.nextInt();
	b=input.nextInt();

	int x=a-1;
	int y=b-1;
	int p=Math.max(a*2-1,b*2-1);
	int q=Math.max(p,x+b);
	int m=Math.max(q, y+a);
	int n=Math.max(m, a+b);
			System.out.println(n);
}
}

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


Question:
import java.util.*;
class AT4246{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		switch(n){
			case 1:
				System.out.println("Hello World");
				break;
			case 2:
				System.out.println(sc.nextInt()+sc.nextInt());
		}
	}
}

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


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

public class JavaApplication2 {

    public static void main (String[] args) {
        Scanner key = new Scanner(System.in);
        int A = key.nextInt();
        int B = key.nextInt();
        int C = key.nextInt();
        int maximum = A+B*10+C;
        System.out.println(maximum);
    }
}

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


Question:
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuffer str1=new StringBuffer(sc.nextLine());
		StringBuffer str2=new StringBuffer(sc.nextLine());
		int len=str1.length();
		if(len!=str2.length()){
			System.out.println("No");
			return;
		}
		while(len-->0){
			StringBuffer sb=new StringBuffer();
			char c=str1.charAt(0);
			sb.append(str1.substring(1));
			sb.append(c);
			str1=sb;
			//System.out.println(str1);
			if(str1.toString().equals(str2.toString())){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

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


Question:
// The following implementation assumes that the activities
// are already sorted according to their finish time
import java.util.*;
import java.lang.*;
import java.io.*;

class ActivitySelection
{
    // Prints a maximum set of activities that can be done by a single
    // person, one at a time.
    //  n   -->  Total number of activities
    //  s[] -->  An array that contains start time of all activities
    //  f[] -->  An array that contains finish time of all activities
    public static void printMaxActivities(int s[], int f[], int n)
    {
    int i, j;

    System.out.print("Following activities are selected : n");

    // The first activity always gets selected
    i = 0;
    System.out.print(i+" ");

    // Consider rest of the activities
    for (j = 1; j < n; j++)
    {
         // If this activity has start time greater than or
         // equal to the finish time of previously selected
         // activity, then select it
         if (s[j] >= f[i])
         {
              System.out.print(j+" ");
              i = j;
          }
     }
    }

    // driver program to test above function
    public static void main(String[] args)
    {
    int s[] =  {1, 3, 0, 5, 8, 5};
    int f[] =  {2, 4, 6, 7, 9, 9};
    int n = s.length;

    printMaxActivities(s, f, n);
    }

}

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


Question:
public static void main(String[] args) {
		// TODO Auto-generated method stub
		long x,bal1,bal2,bal3,ans,kk;
		int n;
		Scanner in =new Scanner(System.in);
		n=in.nextInt();x=in.nextLong();
		long []  a=new long[n+1000];
		for(int i=1;i<=n;i++) {
			a[i]=in.nextLong();
		}
		ans=0;kk=-1;
		for(int i=1;i<=n;i++) {
			bal1=a[i];bal2=0;bal3=a[i];
			for(int k=1;k<n;k++) {
				int pi=((i-k) + n) % n;
				if(pi==0)pi=n;

				if(bal1>a[pi] + ((long)k)*x) {
					bal1=a[pi]+(k)*x;bal2=k;bal3=a[pi];
				}
			}
			if(bal2>kk)kk=bal2;
			ans+=bal3;

		}
		System.out.println(ans+(kk)*x);
	}

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


Question:
import java.util.Scanner;

public class BBBBBBBBBB {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		long x,bal1,bal2,bal3,ans,kk;
		int n;
		Scanner in =new Scanner(System.in);
		n=in.nextInt();x=in.nextLong();
		long []  a=new long[n+1000];
		for(int i=1;i<=n;i++) {
			a[i]=in.nextLong();
		}
		ans=0;kk=-1;
		for(int i=1;i<=n;i++) {
			bal1=a[i];bal2=0;bal3=a[i];
			for(int k=1;k<n;k++) {
				int pi=((i-k) + n) % n;
				if(pi==0)pi=n;

				if(bal1>a[pi] + ((long)k)*x) {
					bal1=a[pi]+(k)*x;bal2=k;bal3=a[pi];
				}
			}
			if(bal2>kk)kk=bal2;
			ans+=bal3;

		}
		System.out.println(ans+(kk)*x);
	}

}

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


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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
int n=s.nextInt();
long a=s.nextLong();long b=s.nextLong();
if(a<0&&b<0) {
	System.out.println("Positive");
	return;
}
else if(a>0&&b>0) {
	System.out.println("Positive");
}else {
	System.out.println("Zero");
}
	}

}

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


Question:
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;

public class Main{

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

		LinkedList<Integer> tar = new LinkedList<Integer>();
		tar.add(0);
		for(int i=1;i<=N;i++) {
			tar.add(i, 1);
		}
		LinkedList<Integer> ls = new LinkedList<Integer>();
		ls.add(1);
		for(int i=0;i<M;i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			int numx = (int) tar.get(x)-1;
			int numy = (int) tar.get(y)+1;

			tar.remove(x);
			tar.add(x, numx);
			tar.remove(y);
			tar.add(y, numy);

			if(ls.contains(x)&&(!ls.contains(y))) {
				ls.add(y);
			}
			if(numx==0&&ls.contains(x)) {
				Iterator<Integer> iter = ls.iterator();
			    while (iter.hasNext()) {
			        int item = iter.next();
			        if (item==x) {
			            iter.remove();
			        }
			    }
			}

//			Iterator<Integer> iter = tar.iterator();
//			int k=0;
//			while (iter.hasNext()) {
//				int item = iter.next();
//				System.out.print("No"+k+" "+item+" ");
//				k++;
//			}
//			System.out.println();
		}
		System.out.println(ls.size());
	}

}

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


Question:
import java.util.*;
public class Main {
    public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);
      int H = sc.nextInt(), W = nextInt();
      int ans = (H-1)*(W-1);

      System.out.println(ans);
    }
}

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


Question:
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in) ;
        int n = sc.nextInt() ;
        BigInteger ans = BigInteger.ONE ;
        for (int i = 0 ; i < n ; i ++) {
            BigInteger tm = sc.nextBigInteger() ;
            ans = ans.multiply(tm) ;
        }
        BigInteger cmp = new BigInteger("1000000000000000000") ;
        if(ans.compareTo(cmp) == 1) System.out.println("-1");
        else System.out.println(ans);
    }
}

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


Question:
import java.util.*;

 public class forcaste {
   	public static void main (String arg[]){
      	Scanner in = new Scanner (System.in);
       	String s = in.nextLine();
      	String t = in.nextLine();

       int count =0;
      for(int i =0; i<3; i++)
      	if (s.charAt(i)==t.charAt(i)){
          count++;
        }

      System.out.println(count);

    }

 }

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


Question:
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		int[] Y = new int[N];
		int[] H = new int[N];
		for(int i=0,l=N; i<l; i++){
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
			H[i] = sc.nextInt();
		}
		for(int cH=1; true; cH++){
			for(int cX=0; cX<=100; cX++){
				for(int cY=0; cY<=100; cY++){
					boolean flag = true;
					for(int i=0,l=N; i<l; i++){
						if(!check(cH, cX, cY, H[i], X[i], Y[i])){
							flag = false;
							break;
						}
					}
					if(flag){
						System.out.println(cX+" "+cY+" "+cH);
						return;
					}
				}
			}
		}
	}
	public static boolean check(int cH, int cX, int cY, int H, int X, int Y){
		int ponH = Math.max(cH - Math.max(X-cX,cX-X) - Math.max(Y-cY,cY-Y), 0);
		if(ponH == H){
			return true;
		}else{
			return false;
		}
	}
}

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


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

class Main
{
    static int MAX = 5_000_05;
    static FastReader fs = new FastReader();
    static int block_size;

    static class Query implements Comparable<Query>
    {
        int l, r, idx;
        Query(int l,int r,int i){
        	this.l = l;
        	this.r = r;
        	this.idx = i;
        }
        public int compareTo(Query other) {
        	return r - other.r;
        }
    }

    static void update(int idx, int val,
                        int bit[], int n)
    {
        for (; idx <= n; idx += idx & -idx)
            bit[idx] += val;
    }

    static int query(int idx, int bit[], int n)
    {
        int sum = 0;
        for (; idx > 0; idx -= idx & -idx)
            sum += bit[idx];
        return sum;
    }

    static void answeringQueries(int[] arr, int n,
                                Query[] queries, int q)
    {

        int[] bit = new int[n + 1];
        Arrays.fill(bit, 0);

        int[] last_visit = new int[MAX];
        Arrays.fill(last_visit, -1);

        int[] ans = new int[q];
        int query_counter = 0;
        for (int i = 0; i < n; i++)
        {

            if (last_visit[arr[i]] != -1)
                update(last_visit[arr[i]] + 1, -1, bit, n);

            last_visit[arr[i]] = i;
            update(i + 1, 1, bit, n);

            while (query_counter < q && queries[query_counter].r == i)
            {
                ans[queries[query_counter].idx] =
                        query(queries[query_counter].r + 1, bit, n)
                        - query(queries[query_counter].l, bit, n);
                query_counter++;
            }
        }

        for (int i = 0; i < q; i++)
            System.out.println(ans[i]);
    }
    public static void main(String[] args) {
		int n = fs.nextInt(),q = fs.nextInt();
		block_size = (int) Math.sqrt(n);
		int c [] = new int [n];
		for(int i = 0; i<n; i++)c[i] = fs.nextInt();
		Query[] queries = new Query[q];

		for(int i = 0; i<q; i++) {
			int l = fs.nextInt()-1,r = fs.nextInt()-1;
			queries[i] = new Query(l,r,i);
		}
		Arrays.sort(queries);
        answeringQueries(c, n, queries, q);
	}

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

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

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

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


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

class Main
{
    static int MAX = 1000001;
    static FastReader fs = new FastReader();
    static int block_size;

    static class Query implements Comparable<Query>
    {
        int l, r, idx;
        Query(int l,int r,int i){
        	this.l = l;
        	this.r = r;
        	this.idx = i;
        }
        public int compareTo(Query other) {
        	return r - other.r;
        }
    }

    static void update(int idx, int val,
                        int bit[], int n)
    {
        for (; idx <= n; idx += idx & -idx)
            bit[idx] += val;
    }

    static int query(int idx, int bit[], int n)
    {
        int sum = 0;
        for (; idx > 0; idx -= idx & -idx)
            sum += bit[idx];
        return sum;
    }

    static void answeringQueries(int[] arr, int n,
                                Query[] queries, int q)
    {

        int[] bit = new int[n + 1];
        Arrays.fill(bit, 0);

        int[] last_visit = new int[MAX];
        Arrays.fill(last_visit, -1);

        int[] ans = new int[q];
        int query_counter = 0;
        for (int i = 0; i < n; i++)
        {

            if (last_visit[arr[i]] != -1)
                update(last_visit[arr[i]] + 1, -1, bit, n);

            last_visit[arr[i]] = i;
            update(i + 1, 1, bit, n);

            while (query_counter < q && queries[query_counter].r == i)
            {
                ans[queries[query_counter].idx] =
                        query(queries[query_counter].r + 1, bit, n)
                        - query(queries[query_counter].l, bit, n);
                query_counter++;
            }
        }

        for (int i = 0; i < q; i++)
            System.out.println(ans[i]);
    }
    public static void main(String[] args) {
		int n = fs.nextInt(),q = fs.nextInt();
		block_size = (int) Math.sqrt(n);
		int c [] = new int [n];
		for(int i = 0; i<n; i++)c[i] = fs.nextInt();
		Query[] queries = new Query[q];

		for(int i = 0; i<q; i++) {
			int l = fs.nextInt()-1,r = fs.nextInt()-1;
			queries[i] = new Query(l,r,i);
		}
		Arrays.sort(queries);
        answeringQueries(c, n, queries, q);
	}

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

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

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

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


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

class Main
{
    static int MAX = 1000001;
    static FastReader fs = new FastReader();

    static class Query
    {
        int l, r, idx;
        Query(int l,int r,int i){
        	this.l = l;
        	this.r = r;
        	this.idx = i;
        }
    }

    static void update(int idx, int val,
                        int bit[], int n)
    {
        for (; idx <= n; idx += idx & -idx)
            bit[idx] += val;
    }

    static int query(int idx, int bit[], int n)
    {
        int sum = 0;
        for (; idx > 0; idx -= idx & -idx)
            sum += bit[idx];
        return sum;
    }

    static void answeringQueries(int[] arr, int n,
                                Query[] queries, int q)
    {

        int[] bit = new int[n + 1];
        Arrays.fill(bit, 0);

        int[] last_visit = new int[MAX];
        Arrays.fill(last_visit, -1);

        int[] ans = new int[q];
        int query_counter = 0;
        for (int i = 0; i < n; i++)
        {

            if (last_visit[arr[i]] != -1)
                update(last_visit[arr[i]] + 1, -1, bit, n);

            last_visit[arr[i]] = i;
            update(i + 1, 1, bit, n);

            while (query_counter < q && queries[query_counter].r == i)
            {
                ans[queries[query_counter].idx] =
                        query(queries[query_counter].r + 1, bit, n)
                        - query(queries[query_counter].l, bit, n);
                query_counter++;
            }
        }

        for (int i = 0; i < q; i++)
            System.out.println(ans[i]);
    }
    public static void main(String[] args) {
		int n = fs.nextInt(),q = fs.nextInt();
		int c [] = new int [n];
		for(int i = 0; i<n; i++)c[i] = fs.nextInt();
		Query[] queries = new Query[q];

		for(int i = 0; i<q; i++) {
			int l = fs.nextInt()-1,r = fs.nextInt()-1;
			queries[i] = new Query(l,r,i);
		}
		Arrays.sort(queries, new Comparator<Query>()
        {
            public int compare(Query x, Query y)
            {
                if (x.r < y.r)
                    return -1;
                else if (x.r == y.r)
                    return 0;
                else
                    return 1;
            }
        });
        answeringQueries(c, n, queries, q);
	}

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

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

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

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


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

public class Main
{
    static int MAX = 1000001;
    static FastReader fs = new FastReader();

    static class Query
    {
        int l, r, idx;
    }

    static void update(int idx, int val,
                        int bit[], int n)
    {
        for (; idx <= n; idx += idx & -idx)
            bit[idx] += val;
    }

    static int query(int idx, int bit[], int n)
    {
        int sum = 0;
        for (; idx > 0; idx -= idx & -idx)
            sum += bit[idx];
        return sum;
    }

    static void answeringQueries(int[] arr, int n,
                                Query[] queries, int q)
    {

        int[] bit = new int[n + 1];
        Arrays.fill(bit, 0);

        int[] last_visit = new int[MAX];
        Arrays.fill(last_visit, -1);

        int[] ans = new int[q];
        int query_counter = 0;
        for (int i = 0; i < n; i++)
        {

            if (last_visit[arr[i]] != -1)
                update(last_visit[arr[i]] + 1, -1, bit, n);

            last_visit[arr[i]] = i;
            update(i + 1, 1, bit, n);

            while (query_counter < q && queries[query_counter].r == i)
            {
                ans[queries[query_counter].idx] =
                        query(queries[query_counter].r + 1, bit, n)
                        - query(queries[query_counter].l, bit, n);
                query_counter++;
            }
        }

        for (int i = 0; i < q; i++)
            System.out.println(ans[i]);
    }
    public static void main(String[] args) {
		int n = fs.nextInt(),q = fs.nextInt();
		int c [] = new int [n];
		for(int i = 0; i<n; i++)c[i] = fs.nextInt();
		Query[] queries = new Query[q];
        for (int i = 0; i < q; i++)
            queries[i] = new Query();

		for(int i = 0; i<q; i++) {
			int l = fs.nextInt()-1,r = fs.nextInt()-1;
			queries[i].l = l;
			queries[i].r = r;
			queries[i].idx = i;
		}
		Arrays.sort(queries, new Comparator<Query>()
        {
            public int compare(Query x, Query y)
            {
                if (x.r < y.r)
                    return -1;
                else if (x.r == y.r)
                    return 0;
                else
                    return 1;
            }
        });
        answeringQueries(c, n, queries, q);
	}

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

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

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

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