Question:
import java.util.Scanner;

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

        if(N == M){
          System.out.println("yes");
        }
        else{
          System.out.println("No");
        }
      }
 }

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


Question:
import java.util.Scanner;

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

        if(N == M){
          System.out.println("yes");
        }
        else{
          System.out.println("No");
        }
      }
 }

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


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

public class Main{
    private static FastScanner fs = new FastScanner();
    public static void main(String[] args) {

       int n = fs.nextInt();
       boolean hasD = false;
       int arr[] = new int[101];
       for(int i=3;i<(n+3);i++)
       {
           int a = fs.nextInt();
           int b = fs.nextInt();
           if(a==b) arr[i] =1;
       }
       boolean hasY = false;
       for(int i=3;i<=98;i++)
       {
           if(arr[i]==1 && arr[i+1]==1 && arr[i+2]==1)
           {
               hasY = true;
               break;
           }
       }
       if(hasY) System.out.println("Yes");
       else System.out.println("No");
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

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

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

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

        long nextLong() {
            return Long.parseLong(next());
        }
        int  gcd(int a,int b)
        {
            while (b > 0)
            {
                int  temp = b;
                b = a % b;
                a = temp;
            }
            return a;
        }
        private int upper(int arr[],int key){
            int low = 0;
            int high = arr.length-1;
            while(low < high){
                int mid = low + (high - low+1)/2;
                if(arr[mid] <= key){
                    low = mid;
                }
                else{
                    high = mid-1;
                }
            }
            return low;
        }
        public int lower(int arr[],int key){
            int low = 0;
            int high = arr.length-1;
            while(low < high){
                int mid = low + (high - low)/2;
                if(arr[mid] >= key){
                    high = mid;
                }
                else{
                    low = mid+1;
                }
            }
            return low;
        }
    }
}

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


Question:
        import java.util.*;
        class Main{
          public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();

            long x = a * c;
            long y = a * d;
            long z = b * c;
            long w = b * d;
            long[] aa = new long[4];

            aa[0] = x;
            aa[1] = y;
            aa[2] = z;
            aa[3] = w;
            int max = x;

            for(int i = 0; i < 4; i++){
              if(aa[i] > max){
                max = aa[i];
              }
            }
            System.out.println(max);
          }
        }

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


Question:
        import java.util.*;
        class Main{
          public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();

            long x = a * c;
            long y = a * d;
            long z = b * c;
            long w = b * d;
            int[] aa = new int[4];

            aa[0] = x;
            aa[1] = y;
            aa[2] = z;
            aa[3] = w;
            int max = x;

            for(int i = 0; i < 4; i++){
              if(aa[i] > max){
                max = aa[i];
              }
            }
            System.out.println(max);
          }
        }

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


Question:
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    int x = a * c;
    int y = a * d;
    int z = b * c;
    int w = b * d;
    int[] aa = new int[4];

    aa[0] = x;
    aa[1] = y;
    aa[2] = z;
    aa[3] = w;
    int max = x;

    for(int i = 0; i < 4; i++){
      if(aa[i] => max){
        max = aa[i];
      }
    }
    System.out.print(max);
  }
}

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


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

    if(A == B && A != C){
    	System.out.println("Yes");
    }
    else if(A == C && A != B){
    	System.out.println("Yes");
    }
    if(C == B && A != C){
    	System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

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


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

    if(A == B && A != C){
    	System.put.println("Yes");
    }
    else if(A == C && A != B){
    	System.put.println("Yes");
    }
    if(C == B && A != C){
    	System.put.println("Yes");
    }
    else{
      System.put.println("No");
    }
  }
}

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


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

Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
 System.out.println(a*a);
  }
}

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


Question:
class Circle {

  public static void main(String[] args){
    int r = 5;
  int ratio = r * r;
  System.out.println(ratio);
  }
}

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


Question:
class Circle {

  public static void main(String[] args){
    int r = 5;
  int ratio = r * r;
  Systam.out.println(ratio);
  }
}

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


Question:
class Circle {

  public static void main(String[] args){
    int r;
  int ratio = r * r;
  System.out.println(ratio);
  }
}

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


Question:
class Circle {

  public static void main(String[] args){
    int r;
  int ratio = r * r;
  Systam.out.println(ratio);
  }
}

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


Question:
class Circle {

  public static void main(String[] args)
    int r;
  int ratio = r * r;
  Systam.out.println(ratio);

}

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


Question:
import java.util.*;
public class shimu{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a >= 13){
            System.out.println(b);
        }
        if (6 <= a && a <= 12){
            System.out.println(b/2);
        }
        if (a<6){
            System.out.println(0);
        }
        sc.close();
    }
}

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


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

public class B_ {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

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

    public static void main(String[] args) throws IOException {
        char[] S = readToken().toCharArray();
        char[] T = readToken().toCharArray();

        int count = 0;
        for (int i = 0; i < S.length; i++) {
            if (S[i] != T[i]) count++;
        }
        pw.println(count);
        pw.close();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

public class Main {
    static In in = new In();
    static Out out = new Out();
    static final long mod = 1000000007;
    static final long inf = 0x1fffffffffffffffL;
    static final int iinf = 0x3fffffff;
    static final int[] da = {-1, 0, 1, 0, -1, 1, 1, -1, -1};

    void solve() {
        int n = in.nextInt();
        long[] pow = new long[n + 1];
        pow[0] = 1;
        for (int i = 1; i <= n; i++) {
            pow[i] = pow[i - 1] * 2 % mod;
        }
        Map<Pair, Integer> neg = new HashMap<>();
        Map<Pair, Integer> pos = new HashMap<>();
        for (int i = 0; i < n; i++) {
            long a = in.nextLong();
            long b = in.nextLong();
            long gcd = gcd(Math.abs(a), Math.abs(b));
            a /= gcd;
            b /= gcd;
            if (a < 0 == b < 0) {
                pos.merge(new Pair(Math.abs(a), Math.abs(b)), 1, Integer::sum);
            } else {
                neg.merge(new Pair(Math.abs(b), Math.abs(a)), 1, Integer::sum);
            }
        }
        long ans = 1;
        for (Map.Entry<Pair, Integer> entry : neg.entrySet()) {
            if (pos.containsKey(entry.getKey())) {
                int a = pos.get(entry.getKey());
                int b = entry.getValue();
                ans = ans * (((pow[a] + pow[b]) % mod + mod - 1) % mod) % mod;
            } else {
                int a = entry.getValue();
                ans = ans * pow[a] % mod;
            }
        }
        for (Map.Entry<Pair, Integer> entry : pos.entrySet()) {
            if (!neg.containsKey(entry.getKey())) {
                int a = entry.getValue();
                ans = ans * pow[a] % mod;
            }
        }
        out.println((ans + mod - 1) % mod);
    }

    long gcd(long a, long b) {
        return 0 < b ? gcd(b, a % b) : a;
    }

    long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class Pair {
    long a;
    long b;

    public Pair(long a, long b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Pair pair = (Pair)o;

        if (a != pair.a) {
            return false;
        }
        return b == pair.b;
    }

    @Override
    public int hashCode() {
        int result = (int)(a ^ (a >>> 32));
        result = 31 * result + (int)(b ^ (b >>> 32));
        return result;
    }

    @Override
    public String toString() {
        return "Pair{" + "a=" + a + ", b=" + b + '}';
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

import static com.yu212.Utils.println;

public class Main {
    static In in = new In();
    static Out out = new Out();
    static final long mod = 1000000007;
    static final long inf = 0xfffffffffffffffL;
    static final int iinf = 0xfffffff;

    void solve() {
        int n = in.nextInt();
        String s = in.next();
        int[][] sum = new int[n + 1][3];
        for (int i = 0; i < n; i++) {
            sum[i]["RGB".indexOf(s.charAt(i))]++;
        }
        for (int i = n; i > 0; i--) {
            for (int j = 0; j < 3; j++) {
                sum[i - 1][j] += sum[i][j];
            }
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (s.charAt(i) != s.charAt(j)) {
                    int ci = "RGB".indexOf(s.charAt(i));
                    int cj = "RGB".indexOf(s.charAt(j));
                    int ck = 3 - ci - cj;
                    int nk = j + j - i;
                    ans += sum[j][ck];
                    if (nk < n && "RGB".indexOf(s.charAt(nk)) == ck) {
                        ans--;
                    }
                }
            }
        }
        out.println(ans);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

import static com.yu212.Utils.println;

public class Main {
    static In in = new In();
    static Out out = new Out();
    static final long mod = 1000000007;
    static final long inf = 0xfffffffffffffffL;
    static final int iinf = 0xfffffff;

    void solve() {
        int n = in.nextInt();
        String s = in.next();
        int[][] sum = new int[n + 1][3];
        for (int i = 0; i < n; i++) {
            sum[i]["RGB".indexOf(s.charAt(i))]++;
        }
        for (int i = n; i > 0; i--) {
            for (int j = 0; j < 3; j++) {
                sum[i - 1][j] += sum[i][j];
            }
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (s.charAt(i) != s.charAt(j)) {
                    int ci = "RGB".indexOf(s.charAt(i));
                    int cj = "RGB".indexOf(s.charAt(j));
                    int ck = 3 - ci - cj;
                    int nk = j + j - i;
                    ans += sum[j][ck];
                    if (nk < n && "RGB".indexOf(s.charAt(nk)) == ck) {
                        ans--;
                    }
                    println(i, j, nk, ci, cj, ck, sum[j][ck]);
                }
            }
        }
        out.println(ans);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

public class Main {
    static In in = new In();
    static Out out = new Out();
    static final long mod = 1000000007;
    static final long inf = 0xfffffffffffffffL;
    static final int iinf = 0xfffffff;
    static final int[] da = {-1, 0, 1, 0, -1, 1, 1, -1, -1};

    int[] p, b;
    int n, m, y, z;
    void solve() {
        n = in.nextInt();
        m = in.nextInt();
        y = in.nextInt();
        z = in.nextInt();
        StringBuilder c = new StringBuilder();
        p = new int[m];
        for (int i = 0; i < m; i++) {
            c.append(in.next());
            p[i] = in.nextInt();
        }
        String d = c.toString();
        b = new int[n];
        String s = in.next();
        for (int i = 0; i < n; i++) {
            b[i] = d.indexOf(s.charAt(i));
        }
        int[][] dp1 = new int[n + 1][1 << m];
        int[][] dp2 = new int[1 << m][m + 1];
        int[] last = new int[m];
        Arrays.fill(last, -1);
        Arrays.fill(dp1[0], -iinf);
        for (int i = 0; i < 1 << m; i++) {
            Arrays.fill(dp2[i], -iinf);
        }
        dp1[0][0] = 0;
        dp2[0][m] = 0;
        for (int i = 0; i < n; i++) {
            Arrays.fill(dp1[i + 1], -iinf);
            for (int j = 0; j < 1 << m; j++) {
                int f = j | (1 << b[i]);
                for (int k = 0; k <= m; k++) {
                    if (k != b[i]) {
                        dp1[i + 1][f] = Math.max(dp1[i + 1][f], dp2[j][k] + p[b[i]]);
                    }
                }
                if (last[b[i]] != -1 && j == f) {
                    dp1[i + 1][f] = Math.max(dp1[i + 1][f], dp1[last[b[i]]][j] + p[b[i]] + y);
                }
            }
            for (int j = 0; j < 1 << m; j++) {
                dp2[j][b[i]] = Math.max(dp2[j][b[i]], dp1[i + 1][j]);
            }
            last[b[i]] = i + 1;
        }
        int ans = 0;
        for (int i = 0; i < 1 << m; i++) {
            for (int j = 0; j < m; j++) {
                if (i == (1 << m) - 1) {
                    ans = Math.max(ans, dp2[i][j] + z);
                } else {
                    ans = Math.max(ans, dp2[i][j]);
                }
            }
        }
        out.println(ans);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int p = in.nextInt();
        String s = new StringBuilder(in.next()).reverse().toString();
        if (p == 2 || p == 5) {
            long ans = 0;
            for (int i = 0; i < n; i++) {
                if ((s.charAt(i) - '0') % p == 0) {
                    ans += n - i;
                }
            }
            out.println(ans);
            throw new RuntimeException();
        }
        int[] a = new int[n];
        int[] pow = new int[n + 2];
        pow[0] = 1;
        for (int i = 1; i < n + 2; i++) {
            pow[i] = pow[i - 1] * 10 % p;
        }
        int[] count = new int[p];
        a[0] = (s.charAt(0) - '0') % p;
        count[a[0]]++;
        for (int i = 1; i < n; i++) {
            a[i] = (a[i - 1] + pow[i] * (s.charAt(i) - '0')) % p;
            count[a[i]]++;
        }
        long ans = 0;
        for (int i = 0; i < p; i++) {
            ans += count[i] * (count[i] - 1) / 2;
        }
        ans += count[0];
        if (s.matches("0+")) {
            out.println((long)n * (n + 1) / 2);
        } else {
            throw new RuntimeException();
        }
    }

    static long pow(long a, long b) {
        if (a == 0) {
            return 0;
        }
        long x = 1;
        while (b > 0) {
            if (b % 2 == 1) {
                x = x * a % mod;
                b--;
            } else {
                a = a * a % mod;
                b /= 2;
            }
        }
        return x;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int p = in.nextInt();
        String s = new StringBuilder(in.next()).reverse().toString();
        if (p == 2 || p == 5) {
            long ans = 0;
            for (int i = 0; i < n; i++) {
                if ((s.charAt(i) - '0') % p == 0) {
                    ans += n - i;
                }
            }
            out.println(ans);
            throw new RuntimeException();
        }
        int[] a = new int[n];
        int[] pow = new int[n + 2];
        pow[0] = 1;
        for (int i = 1; i < n + 2; i++) {
            pow[i] = pow[i - 1] * 10 % p;
        }
        int[] count = new int[p];
        a[0] = (s.charAt(0) - '0') % p;
        count[a[0]]++;
        for (int i = 1; i < n; i++) {
            a[i] = (a[i - 1] + pow[i] * (s.charAt(i) - '0')) % p;
            count[a[i]]++;
        }
        long ans = 0;
        for (int i = 0; i < p; i++) {
            ans += count[i] * (count[i] - 1) / 2;
        }
        ans += count[0];
        if (s.matches("0+")) {
            out.println(n * (n + 1) / 2);
        } else {
            out.println(ans - 1);
        }
    }

    static long pow(long a, long b) {
        if (a == 0) {
            return 0;
        }
        long x = 1;
        while (b > 0) {
            if (b % 2 == 1) {
                x = x * a % mod;
                b--;
            } else {
                a = a * a % mod;
                b /= 2;
            }
        }
        return x;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int p = in.nextInt();
        String s = new StringBuilder(in.next()).reverse().toString();
        if (p == 2 || p == 5) {
            long ans = 0;
            for (int i = 0; i < n; i++) {
                if ((s.charAt(i) - '0') % p == 0) {
                    ans += n - i;
                }
            }
            out.println(ans);
            throw new RuntimeException();
        }
        int[] a = new int[n];
        int[] pow = new int[n + 2];
        pow[0] = 1;
        for (int i = 1; i < n + 2; i++) {
            pow[i] = pow[i - 1] * 10 % p;
        }
        int[] count = new int[p];
        a[0] = (s.charAt(0) - '0') % p;
        count[a[0]]++;
        for (int i = 1; i < n; i++) {
            a[i] = (a[i - 1] + pow[i] * (s.charAt(i) - '0')) % p;
            count[a[i]]++;
        }
        long ans = 0;
        for (int i = 0; i < p; i++) {
            ans += count[i] * (count[i] - 1) / 2;
        }
        ans += count[0];
        out.println(ans - 1);
    }

    static long pow(long a, long b) {
        if (a == 0) {
            return 0;
        }
        long x = 1;
        while (b > 0) {
            if (b % 2 == 1) {
                x = x * a % mod;
                b--;
            } else {
                a = a * a % mod;
                b /= 2;
            }
        }
        return x;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int p = in.nextInt();
        String s = new StringBuilder(in.next()).reverse().toString();
        if (p == 2 || p == 5) {
            long ans = 0;
            for (int i = 0; i < n; i++) {
                if ((s.charAt(i) - '0') % p == 0) {
                    ans += n - i;
                }
            }
            out.println(ans);
            throw new RuntimeException();
        }
        int[] a = new int[n];
        int[] pow = new int[n + 2];
        pow[0] = 1;
        for (int i = 1; i < n + 2; i++) {
            pow[i] = pow[i - 1] * 10 % p;
        }
        int[] count = new int[p];
        a[0] = (s.charAt(0) - '0') % p;
        count[a[0]]++;
        for (int i = 1; i < n; i++) {
            a[i] = (a[i - 1] + pow[i] * (s.charAt(i) - '0')) % p;
            count[a[i]]++;
        }
        long ans = 0;
        for (int i = 0; i < p; i++) {
            ans += count[i] * (count[i] - 1) / 2;
        }
        ans += count[0];
        out.println(ans);
    }

    static long pow(long a, long b) {
        if (a == 0) {
            return 0;
        }
        long x = 1;
        while (b > 0) {
            if (b % 2 == 1) {
                x = x * a % mod;
                b--;
            } else {
                a = a * a % mod;
                b /= 2;
            }
        }
        return x;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int p = in.nextInt();
        if (p == 2 || p == 5) {
            throw new RuntimeException();
        }
        String s = new StringBuilder(in.next()).reverse().toString();
        int[] a = new int[n];
        int[] pow = new int[n + 2];
        pow[0] = 1;
        for (int i = 1; i < n + 2; i++) {
            pow[i] = pow[i - 1] * 10 % p;
        }
        int[] count = new int[p];
        a[0] = (s.charAt(0) - '0') % p;
        count[a[0]]++;
        for (int i = 1; i < n; i++) {
            a[i] = (a[i - 1] + pow[i] * (s.charAt(i) - '0')) % p;
            count[a[i]]++;
        }
        long ans = 0;
        for (int i = 0; i < p; i++) {
            ans += count[i] * (count[i] - 1) / 2;
        }
        ans += count[0];
        out.println(ans);
    }

    static long pow(long a, long b) {
        if (a == 0) {
            return 0;
        }
        long x = 1;
        while (b > 0) {
            if (b % 2 == 1) {
                x = x * a % mod;
                b--;
            } else {
                a = a * a % mod;
                b /= 2;
            }
        }
        return x;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    long[] fac, inv;
    void solve() {
        int n = in.nextInt();
        int k = in.nextInt();

        fac = new long[n + 1];
        inv = new long[n + 1];
        fac[0] = inv[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = powAndMod(fac[i], mod - 2);
        }

        if (n <= k) {
            out.println(comb(n + n - 1, n));
        } else {
            long ans = 0;
            for (int i = 0; i <= k; i++) {
                ans = (ans + comb(n, i) * comb(n - 1, i) % mod) % mod;
            }
            out.println(ans);
        }
    }

    long comb(int n, int r) {
        return fac[n] * inv[r] % mod * inv[n - r] % mod;
    }

    static long powAndMod(long a, long b) {
        long x = 1;
        while (b > 0) {
            if (b % 2 == 1) {
                x = x * a % mod;
                b--;
            } else {
                a = a * a % mod;
                b /= 2;
            }
        }
        return x;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int k = in.nextInt();
        if (n <= k) {
            out.println(comb(n + n - 1, n));
        } else {
            long ans = 0;
            for (int i = 0; i <= k; i++) {
                ans = (ans + comb(n, i) * comb(n - 1, i) % mod) % mod;
            }
            out.println(ans);
        }
    }

    static long comb(long n, long r) {
        r = Math.min(r, n - r);
        long x = 1, y = 1;
        for (long i = 1; i <= r; i++) {
            x = x * (n - r + i) % mod;
            y = y * i % mod;
        }
        return x * powAndMod(y, mod - 2) % mod;
    }

    static long powAndMod(long a, long b) {
        long x = 1;
        while (b > 0) {
            if (b % 2 == 1) {
                x = x * a % mod;
                b--;
            } else {
                a = a * a % mod;
                b /= 2;
            }
        }
        return x;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.function.IntConsumer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    int n;
    List<List<Integer>> edges;
    void solve() {
        n = in.nextInt();
        edges = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            edges.add(new ArrayList<>());
        }
        for (int i = 1; i < n; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            edges.get(a).add(b);
            edges.get(b).add(a);
        }
        sort();
        int m = in.nextInt();
        Set<Integer>[] req = new Set[m];
        int[] u = new int[m];
        int[] v = new int[m];
        for (int i = 0; i < m; i++) {
            u[i] = in.nextInt() - 1;
            v[i] = in.nextInt() - 1;
            Set<Integer> set = new HashSet<>();
            dfs(u[i], u[i], v[i], set::add);
            req[i] = set;
        }
        long[][] dp = new long[n][1 << m];
        dp[0][0] = 1;
        int last = 0;
        int index = 0;
        for (int a = 0; a < n; a++) {
            for (int b : edges.get(a)) {
                int i = ids[a];
                int j = ids[b];
                if (a > b) {
                    continue;
                }
                if (last + 1 != j) {
                    throw new RuntimeException();
                }
                last = j;
                int mask = 0;
                for (int k = 0; k < m; k++) {
                    if (req[k].contains(i) && req[k].contains(j)) {
                        mask |= 1 << k;
                    }
                }
                for (int flags = 0; flags < 1 << m; flags++) {
                    dp[index + 1][flags | mask] += dp[index][flags];
                    dp[index + 1][flags] += dp[index][flags];
                }
                index++;
            }
        }
        out.println(dp[n - 1][(1 << m) - 1]);
    }

    int[] ids;
    void sort() {
        ids = new int[n];
        boolean[] visited = new boolean[n];
        int id = 0;
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(0);
        visited[0] = true;
        while (!deque.isEmpty()) {
            int v = deque.poll();
            ids[v] = id++;
            for (int u : edges.get(v)) {
                if (!visited[u]) {
                    visited[u] = true;
                    deque.add(u);
                }
            }
        }
    }

    boolean dfs(int parent, int node, int goal, IntConsumer action) {
        if (node == goal) {
            action.accept(node);
            return true;
        }
        boolean result = false;
        for (int u : edges.get(node)) {
            if (u != parent) {
                result |= dfs(node, u, goal, action);
            }
        }
        if (result) {
            action.accept(node);
            return true;
        }
        return false;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}

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


Question:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.function.IntConsumer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    int n;
    List<List<Integer>> edges;
    void solve() {
        n = in.nextInt();
        edges = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            edges.add(new ArrayList<>());
        }
        for (int i = 1; i < n; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            edges.get(a).add(b);
            edges.get(b).add(a);
        }
        sort();
        int m = in.nextInt();
        Set<Integer>[] req = new Set[m];
        int[] u = new int[m];
        int[] v = new int[m];
        for (int i = 0; i < m; i++) {
            u[i] = in.nextInt() - 1;
            v[i] = in.nextInt() - 1;
            Set<Integer> set = new HashSet<>();
            dfs(u[i], u[i], v[i], set::add);
            req[i] = set;
        }
        long[][] dp = new long[n][1 << m];
        dp[0][0] = 1;
        int last = 0;
        for (int a = 0; a < n; a++) {
            for (int b : edges.get(a)) {
                int i = ids[a];
                int j = ids[b];
                if (a > b) {
                    continue;
                }
                if (last + 1 != j) {
                    throw new RuntimeException();
                }
                last = j;
                int mask = 0;
                for (int k = 0; k < m; k++) {
                    if (req[k].contains(i) && req[k].contains(j)) {
                        mask |= 1 << k;
                    }
                }
                for (int flags = 0; flags < 1 << m; flags++) {
                    dp[j][flags | mask] += dp[j - 1][flags];
                    dp[j][flags] += dp[j - 1][flags];
                }
            }
        }
        out.println(dp[n - 1][(1 << m) - 1]);
    }

    int[] ids;
    void sort() {
        ids = new int[n];
        boolean[] visited = new boolean[n];
        int id = 0;
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(0);
        visited[0] = true;
        while (!deque.isEmpty()) {
            int v = deque.poll();
            ids[v] = id++;
            for (int u : edges.get(v)) {
                if (!visited[u]) {
                    visited[u] = true;
                    deque.add(u);
                }
            }
        }
    }

    boolean dfs(int parent, int node, int goal, IntConsumer action) {
        if (node == goal) {
            action.accept(node);
            return true;
        }
        boolean result = false;
        for (int u : edges.get(node)) {
            if (u != parent) {
                result |= dfs(node, u, goal, action);
            }
        }
        if (result) {
            action.accept(node);
            return true;
        }
        return false;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}

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


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

class Main {
    static Scanner scanner = new Scanner();
    static int mod = 1000000007;
    static int inf = 0x7ffffff;

    void solve() {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        char[] s = scanner.next().toCharArray();
        int[] prev = new int[n + 1];
        for (int l = 0, r = 0; r <= n; r++) {
            while (s[l] == '1' || r - l > m) {
                l++;
            }
            prev[r] = l;
        }
        int now = n;
        List<Integer> list = new ArrayList<>();
        while (now > 0) {
            list.add(now - prev[now]);
            now = prev[now];
        }
        for (int i = list.size() - 1; i >= 0; i--) {
            System.out.println(list.get(i));
        }
    }

    public static void main(String[]$) throws Exception {
        new Main().solve();
        System.out.flush();
    }
}

class System {
    static PrintWriter out = new PrintWriter(java.lang.System.out);

    static void exit() {
        java.lang.System.exit(0);
    }
}

class Scanner {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

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


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

class Main {
    static Scanner scanner = new Scanner();
    static int mod = 1000000007;
    static int inf = 0x7ffffff;

    void solve() {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        char[] s = scanner.next().toCharArray();
        List<Integer>[] dp = new List[n + 1];
        dp[0] = new ArrayList<>();
        int[] prev = new int[n + 1];
        for (int l = 0, r = 0; r <= n; r++) {
            while (s[l] == '1' || r - l > m) {
                l++;
            }
            prev[r] = l;
        }
        for (int i = 1; i <= n; i++) {
            if (dp[prev[i]] == null) {
                System.out.println(-1);
                return;
            }
            dp[i] = new ArrayList<>(dp[prev[i]]);
            dp[i].add(i - prev[i]);
        }
        dp[n].forEach(System.out::println);
    }

    public static void main(String[]$) throws Exception {
        new Main().solve();
        System.out.flush();
    }
}

class System {
    static PrintWriter out = new PrintWriter(java.lang.System.out);

    static void exit() {
        java.lang.System.exit(0);
    }
}

class Scanner {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 0x10000);
    private StringTokenizer tokenizer;

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

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

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

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

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

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


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

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;
    static int inf = 0x7ffffff;

    public static void main(String[]$) throws Exception {
        long n = scanner.nextLong();
        long min = 10000000000000L;
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                println(i, n, n / i, n % i);
                min = Math.min(min, i + n / i - 2);
            }
        }
        System.out.println(min);
    }

    static class System {
        static PrintWriter out = new PrintWriter(java.lang.System.out);

        static {
            Runtime.getRuntime().addShutdownHook(new Thread(System.out::flush));
        }
    }

    static class Scanner {
        BufferedInputStream reader = new BufferedInputStream(java.lang.System.in);
        byte[] buffer = new byte[0x10000];
        int i = 0;
        int length = 0;

        int read() {
            if (i == length) {
                i = 0;
                try {
                    length = reader.read(buffer);
                } catch (IOException ignored) {
                }
                if (length == -1) {
                    return -1;
                }
            }
            return buffer[i++];
        }

        String next() {
            StringBuilder builder = new StringBuilder();
            int b = read();
            while (b < '!' || '~' < b) {
                b = read();
            }
            while ('!' <= b && b <= '~') {
                builder.appendCodePoint(b);
                b = read();
            }
            return builder.toString();
        }

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

        long nextLong() {
            int b = read();
            while (b < '!' || '~' < b) {
                b = read();
            }
            int i = 0;
            if (b == '-') {
                i = 1;
                b = read();
            }
            long n = 0;
            while ('0' <= b && b <= '9') {
                n = n * 10 + b - '0';
                b = read();
            }
            return i == 0 ? n : -n;
        }

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

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

        int[] nextIntArray(int n, IntUnaryOperator op) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = op.applyAsInt(nextInt());
            }
            return a;
        }

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

        long[] nextLongArray(int n, LongUnaryOperator op) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = op.applyAsLong(nextLong());
            }
            return a;
        }
    }
}

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


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

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;
    static long inf = 1L << 60;

    static int n, m, l;
    public static void main(String[]$) throws Exception {
        n = scanner.nextInt();
        m = scanner.nextInt();
        l = scanner.nextInt();
        List<List<Grid>> edges = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            edges.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;
            long c = scanner.nextLong();
            if (c <= l) {
                edges.get(a).add(new Grid(b, c));
                edges.get(b).add(new Grid(a, c));
            }
        }
        long[][] dist = new long[n][n];
        for (int i = 0; i < n; i++) {
            dist[i] = dijkstra(edges, i);
        }
        int q = scanner.nextInt();
        for (int i = 0; i < q; i++) {
            int s = scanner.nextInt() - 1;
            int t = scanner.nextInt() - 1;
            if (dist[s][t] >= inf) {
                System.out.println(-1);
            } else {
                System.out.println((dist[s][t] - 1) / l);
            }
        }
    }

    static long[] dijkstra(List<List<Grid>> edges, int start) {
        long[] cost = new long[edges.size()];
        Arrays.fill(cost, inf);
        cost[start] = 0;

        Queue<Grid> queue = new PriorityQueue<>();
        queue.add(new Grid(start, 0));

        while (!queue.isEmpty()) {
            Grid grid = queue.poll();
            if (cost[grid.to] >= grid.cost) {
                for (Grid g : edges.get(grid.to)) {
                    long c;
                    long mod = cost[grid.to] % l;
                    if (mod + g.cost > l) {
                        c = cost[grid.to] - mod + l + g.cost;
                    } else {
                        c = cost[grid.to] + g.cost;
                    }
                    if (cost[g.to] > c) {
                        cost[g.to] = c;
                        queue.add(new Grid(g.to, cost[g.to]));
                    }
                }
            }
        }
        return cost;
    }

    static class Grid implements Comparable<Grid> {
        int to;
        long cost;

        Grid(int to, long cost) {
            this.to = to;
            this.cost = cost;
        }

        @Override
        public int compareTo(Grid o) {
            return Long.compare(this.cost, o.cost);
        }

        @Override
        public String toString() {
            return String.format("[%s, %s]", to, cost);
        }
    }

    static class System {
        static PrintWriter out = new PrintWriter(java.lang.System.out);

        static {
            Runtime.getRuntime().addShutdownHook(new Thread(System.out::flush));
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

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

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

        int[] nextIntArray(int n, java.util.function.IntUnaryOperator op) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = op.applyAsInt(nextInt());
            }
            return a;
        }

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

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

        long[] nextLongArray(int n, java.util.function.LongUnaryOperator op) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = op.applyAsLong(nextLong());
            }
            return a;
        }
    }
}

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


Question:
10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

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


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

class Main {
    static Scanner scanner = new Scanner();
    static long inf = 0x7fffffffffL;

    public static void main(String[]$) throws IOException {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int p = scanner.nextInt();
        Edge[] edges = new Edge[m];
        for (int i = 0; i < m; i++) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;
            int c = scanner.nextInt();
            edges[i] = new Edge(a, b, p - c);
        }
        long[] d = new long[n];
        Arrays.fill(d, inf);
        d[0] = 0;

        Set<Integer> loop = new HashSet<>();

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (d[edges[j].to] > d[edges[j].from] + edges[j].cost) {
                    d[edges[j].to] = d[edges[j].from] + edges[j].cost;
                    if (i == n - 1) {
                        loop.add(edges[j].from);
                        loop.add(edges[j].to);
                    }
                }
            }
        }
        if (loop.contains(n - 1)) {
            throw new RuntimeException();
        } else {
            System.out.println(Math.max(0, -d[n - 1]));
        }
    }

    static class Edge implements Comparable<Edge> {
        int from;
        int to;
        long cost;

        Edge(int from, int to, long cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }

        @Override
        public int compareTo(Edge o) {
            return Long.compare(this.cost, o.cost);
        }

        @Override
        public String toString() {
            return String.format("[%s, %s, %s]", from, to, cost);
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

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

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

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

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

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


Question:
import java.util.*;
class Main{
	static int a,b;
	static boolean s;
	public static void main(String[]$){
		Scanner c=new Scanner(System.in);
		int k=c.nextInt(),x=c.nextInt(),y=c.nextInt();
		x*=a=x<0?-1:1;
		y*=b=y<0?-1:1;
		if(s=x<y)x^=y^(y=x);
		int n=(x+y+k-1)/k;
		if(k%2==0&&(x+y)%2==1){
			System.out.println(-1);
			return;
		}else if(x+y<k)if((x+y)%(n=2)==1){
			System.out.println(3);
			p(x,x-k);
			p(x+(k+x-y)/2,x-k+(k-x+y)/2);
			p(x,y);
			return;
		}else if((k-(x+y)%k)%k%2==1)n++;
		System.out.println(n);
		int m=(k*n-x-y)/2,i=0;
        for (int i = 1; i <= n; i++) {
            if (m > k * i) {
                p(0, -k * i);
            } else if (x + m > k * i) {
                p(k * i - m, -m);
            } else {
                p(x, k * i - 2 * m - x);
            }
        }
	}
	static void p(int x,int y){
		System.out.println(a*(s?y:x)+" "+b*(s?x:y));
	}
}

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


Question:
import java.util.*;
class Main{
	static int a,b;
	static boolean s;
	public static void main(String[]$){
		Scanner c=new Scanner(System.in);
		int k=c.nextInt(),x=c.nextInt(),y=c.nextInt();
		x*=a=x<0?-1:1;
		y*=b=y<0?-1:1;
        if (x < y) {
            swap = true;
            int t = x;
            x = y;
            y = t;
        }
		int n=(x+y+k-1)/k;
		if(k%2==0&&(x+y)%2==1){
			System.out.println(-1);
			return;
		}else if(x+y<k)if((x+y)%(n=2)==1){
			System.out.println(3);
			p(x,x-k);
			p(x+(k+x-y)/2,x-k+(k-x+y)/2);
			p(x,y);
			return;
		}else if((k-(x+y)%k)%k%2==1)n++;
		System.out.println(n);
		int m=(k*n-x-y)/2,i=0;
		while(++i<=n)if(m>k*i)p(0,-k*i);
			else if(x+m>k*i) p(k*i-m,-m);
			else p(x,k*i-2*m-x);
	}
	static void p(int x,int y){
		System.out.println(a*(s?y:x)+" "+b*(s?x:y));
	}
}

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


Question:
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] v = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = scanner.nextInt();
        }

        long ans = Integer.MIN_VALUE;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j <= i; j++) {
                List<Integer> list = new ArrayList<>();
                for (int l = 0; l < j; l++) {
                    list.add(v[l]);
                }
                for (int l = 0; l < i - j; l++) {
                    list.add(v[n - l - 1]);
                }
                Collections.sort(list);
                long sum = 0;
                int r = k - i;
                for (int l : list) {
                    if (l < 0 && r > 0) {
                        r--;
                    } else {
                        sum += l;
                    }
                }

                ans = Math.max(ans, sum);
            }
        }
        System.out.println(ans);
    }
}

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


Question:
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), q = scanner.nextInt();
        String s = scanner.next();
        List<Integer> ac = new ArrayList<>();
        for (int i = 1; i < n; i++)
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C')
                ac.add(i);
        for (int i = 0; i < q; i++) {
            int l = scanner.nextInt(), r = scanner.nextInt();
            int l1 = IntStream.range(0, ac.size())
                    .filter(j -> l <= ac.get(j))
                    .findFirst()
                    .orElse(ac.size());
            int r1 = IntStream.range(l1, ac.size())
                    .filter(j -> r <= ac.get(j))
                    .findFirst()
                    .orElse(ac.size());
            System.out.println(r1 - l1);
        }
    }
}

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


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

public class AtCoder {
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt(), m = scanner.nextInt(), a[] = new int[m], b[] = new int[m], num[] = new int[n + 1];
        long[] ans = new long[m];
        fa = IntStream.rangeClosed(0, n).toArray();
        for (int i = 0; i < m; i++) {
            a[i] = scanner.nextInt();
            b[i] = scanner.nextInt();
        }
        Arrays.fill(num, 1);
        ans[m - 1] = (long)n * (n - 1) / 2;
        for (int i = m - 1; i > 0; i--) {
            ans[i - 1] = ans[i];
            if (fd(a[i]) != fd(b[i])) {
                ans[i - 1] -= num[fa[a[i]]] * num[fa[b[i]]];
                num[fa[b[i]]] += num[fa[a[i]]];
                fa[fa[a[i]]] = fa[b[i]];
            }
        }
        Arrays.stream(ans).forEach(System.out::println);
    }

    static int[] fa;
    static int fd(int a) {
        return fa[a] == a ? a : (fa[a] = fd(fa[a]));
    }
}

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


Question:
import java.util.*;

public class Main {
  	static Scanner scanner = new Scanner(System.in);

	public static void main(String[]$) {
    	System.out.println("Christmas" + String.format("%0" + (25 - scanner.nextInt()) + "d", 0).replace("0", " Eve"));
    }
}

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


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

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int[] u1 = new int[n / 2], u2 = new int[n / 2], count1 = new int[100000], count2 = new int[100000];
        for (int i = 0; i < n / 2; i++) {
            count1[u1[i] = scanner.nextInt()]++;
            count2[u2[i] = scanner.nextInt()]++;
        }

        int max1 = IntStream.range(0, 100000)
                .boxed()
                .max(Comparator.comparingInt(i -> count1[i]))
                .orElse(0);
        int max2 = IntStream.range(0, 100000)
                .boxed()
                .max(Comparator.comparingInt(i -> count2[i]))
                .orElse(0);
        if (max1 == max2) {
            int next1 = IntStream.range(0, 100000)
                    .filter(i -> i != max1)
                    .boxed()
                    .max(Comparator.comparingInt(i -> count1[i]))
                    .orElse(0);
            int next2 = IntStream.range(0, 100000)
                    .filter(i -> i != max2)
                    .boxed()
                    .max(Comparator.comparingInt(i -> count2[i]))
                    .orElse(0);
            System.out.println(n - Math.min(count1[next1] + count2[max2], count1[max1] + count2[next2]));
        } else {
            System.out.println(n - count1[max1] - count2[max2]);
        }
    }
}

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


Question:
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int mod = (int)1e9 + 7;
        Map<Integer, Integer> primeFactors = new HashMap<>();
        for (int i = 2; i * i <= m; i++) {
            while (m % i == 0) {
                m /= i;
                primeFactors.put(i, primeFactors.getOrDefault(i, 0) + 1);
            }
        }
        if (!primeFactors.isEmpty() && m != 1) {
            primeFactors.put(m, primeFactors.getOrDefault(m, 0) + 1);
        }

        System.out.println(primeFactors);
        long ans = 1;
        for (int i : primeFactors.values()) {
            Util.println(n + i - 1, i, combinationAndMod(n + i - 1, i));
            ans = ans * combinationAndMod(i + n - 1, i) % mod;
        }
        System.out.println(ans);
    }

    static long combinationAndMod(long n, long r) {
        r = Math.min(r, n - r);
        long x = 1, y = 1;
        for (long i = 1; i <= r; i++) {
            x = x * (n - r + i) % 1000000007;
            y = y * i % 1000000007;
        }
        return x * powAndMod(y, 1000000005) % 1000000007;
    }

    static long powAndMod(long a, long b) {
        if (b == 0)
            return 1;
        if ((b & 1) == 1)
            return a * powAndMod(a, b - 1) % 1000000007;
        return powAndMod(a * a % 1000000007, b / 2);
    }
}

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


Question:
import java.util.*;

public class main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int mod = (int)1e9 + 7;
        Map<Integer, Integer> primeFactors = new HashMap<>();
        for (int i = 2; i * i <= m; i++) {
            while (m % i == 0) {
                m /= i;
                primeFactors.put(i, primeFactors.getOrDefault(i, 0) + 1);
            }
        }
        if (!primeFactors.isEmpty() && m != 1) {
            primeFactors.put(m, primeFactors.getOrDefault(m, 0) + 1);
        }

        System.out.println(primeFactors);
        long ans = 1;
        for (int i : primeFactors.values()) {
            Util.println(n + i - 1, i, combinationAndMod(n + i - 1, i));
            ans = ans * combinationAndMod(i + n - 1, i) % mod;
        }
        System.out.println(ans);
    }

    static long combinationAndMod(long n, long r) {
        r = Math.min(r, n - r);
        long x = 1, y = 1;
        for (long i = 1; i <= r; i++) {
            x = x * (n - r + i) % 1000000007;
            y = y * i % 1000000007;
        }
        return x * powAndMod(y, 1000000005) % 1000000007;
    }

    static long powAndMod(long a, long b) {
        if (b == 0)
            return 1;
        if ((b & 1) == 1)
            return a * powAndMod(a, b - 1) % 1000000007;
        return powAndMod(a * a % 1000000007, b / 2);
    }
}

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


Question:
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        long n = scanner.nextLong();
        long k = scanner.nextLong();
        long a = n / k;
        long b = n / (k / 2) - a;
        System.out.println(a * a * a + ((k & 1) == 0 ? b * b * b : 0));
    }
}

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


Question:
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        long a = n / k;
        long b = n / (k / 2) - a;
        System.out.println(a * a * a + ((k & 1) == 0 ? b * b * b : 0));
    }
}

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


Question:
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int q = scanner.nextInt();

        int[][] a = new int[n][n];
        for (int i = 0; i < m; i++) {
            int l = scanner.nextInt() - 1;
            int r = scanner.nextInt() - 1;
            for (int j = 0; j <= l; j++) {
                for (int k = r; k < n; k++) {
                    a[j][k]++;
                }
            }
        }
        for (int i = 0; i < q; i++) {
            System.out.println(a[scanner.nextInt() - 1][scanner.nextInt() - 1]);
        }
    }
}

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


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

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) {
        int n = scanner.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = b[i] = scanner.nextInt();
            if (i > 0) {
                b[i] += b[i - 1];
            }
        }
        int i = 0;
        long min = Integer.MAX_VALUE;
        while (++i < n && b[i] * 2 <= b[n - 1]);
        i++;
        for (int c = 0; c < 3; c++, i--) {
            int j = 0, k = i;
            while (++j <= i && b[j] * 2 <= b[i]);
            while (++k < n && (b[k] - b[i]) * 2 <= b[n - 1] - b[i]);
            for (int j1 = j - 1, l = 0; l < 3; j1++, l++) {
                for (int k1 = k - 1, m = 0; m < 3; k1++, m++) {
                    min = Math.min(min, f(b, j1, i, k1));
                }
            }
        }
        System.out.println(min);
    }

    static long f(long[] array, int i, int j, int k) {
        if (i < j && j < k && 0 < i && k < array.length) {
            long a = array[i - 1];
            long b = array[j - 1] - array[i - 1];
            long c = array[k - 1] - array[j - 1];
            long d = array[array.length - 1] - array[k - 1];
            return Math.max(Math.max(Math.max(a, b), c), d) - Math.min(Math.min(Math.min(a, b), c), d);
        }
        return Integer.MAX_VALUE;
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

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

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


Question:
import java.util.*;

public class Main {
  public static void main(String[]$) {
    Scanner s=new Scanner(System.in);
    System.out.println(-(s.nextInt()-s.nextInt())*(s.nextInt()*0+s.nextInt()%2*2-1));
  }
}

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