Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define uint unsigned int
#define alloc(n, type) (type *)calloc(n, sizeof(type))
#define MODULE 1
#define RAND(min, max) (rand() % (max - min + 1) + min)
#define repeat(i, condition) for (int i = 0; condition; i++)
#define LOG(log) cout << #log << " : " << log << '\\n'
#define DEBUG()                                                                \\
  {                                                                            \\
    cout << "DEBUG " << num_debug << '\\n';                                     \\
    num_debug++;                                                               \\
  }
int num_debug = 0;
bool *IsPrime;
vector<int> Prime;

int compare_int(const void *a, const void *b);
class Math {
public:
  template <typename T> static T Fac(int n) {
    T ans = 1;
    for (int i = 2; i <= n; i++) {
      ans *= i;
    }
    return ans;
  }

public:
  template <typename T> static T P(int n, int r) {
    T ans = 1;
    for (int i = 0; i < r; i++) {
      ans *= n - i;
    }
    return ans;
  }

public:
  template <typename T> static T C(int n, int r) {
    T nmr = 1;
    T dnm = 1;
    if (n - r < r)
      r = n - r;
    for (int i = 0; i < r; i++) {
      nmr *= n - i;
      dnm *= r - i;
    }
    return nmr / dnm;
  }
};
class Module_int {
public:
  static const int mod = MODULE;

public:
  static int add(int a, int b) {
    int ans = a + b;
    if (ans < 0)
      ans += mod;
    ans %= mod;
    return ans;
  }

public:
  static int mult(int a, int b) { return (a * b) % mod; }

public:
  static int Pow(int a, int b) {
    int base = a % mod;
    if (mod / 2 < abs(base))
      if (base < 0) {
        base += mod; // negative
      } else {
        base -= mod; // positive
      }

    return pow(base, b);
  }
};

int main(void) {
  srand((unsigned)time(NULL));

  int N, K;
  int *A;
  cin >> N;
  cin >> K;
  A = alloc(N, int);
  repeat(i, i < N) { scanf("%d", &A[i]); }

  // DEBUG();
  for (int i = 0; i < N - K; i++) {
    // printf("%d %d", A[i], A[K + i]);
    if (A[i] < A[K + i]) {
      cout << "Yes\\n";
    } else {
      cout << "No\\n";
    }
  }

  free(A);
  return 0;
}

int compare_int(const void *a, const void *b) { return *(int *)a - *(int *)b; }
void PrimeEnable(int n) {
  // initialize IsPrime
  IsPrime = (bool *)calloc(n + 1, sizeof(bool));
  for (int i = 0; i <= n; i++)
    IsPrime[i] = true;

  // IsPrime
  IsPrime[0] = IsPrime[1] = false;
  for (int i = 2; i * i <= n; i++) {
    if (IsPrime[i])
      for (int j = i; i * j <= n; j++) {
        IsPrime[i * j] = false;
      }
  }

  // push back to Prime
  for (int i = 0; i <= n; i++) {
    if (IsPrime[i])
      Prime.push_back(i);
  }
}


Error: WA

Fixed submission:

#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define uint unsigned int
#define alloc(n, type) (type *)calloc(n, sizeof(type))
#define MODULE 1
#define RAND(min, max) (rand() % (max - min + 1) + min)
#define repeat(i, condition) for (int i = 0; condition; i++)
#define LOG(log) cout << #log << " : " << log << '\\n'
#define DEBUG()                                                                \\
  {                                                                            \\
    cout << "DEBUG " << num_debug << '\\n';                                     \\
    num_debug++;                                                               \\
  }
int num_debug = 0;
bool *IsPrime;
vector<int> Prime;

int compare_int(const void *a, const void *b);
class Math {
public:
  template <typename T> static T Fac(int n) {
    T ans = 1;
    for (int i = 2; i <= n; i++) {
      ans *= i;
    }
    return ans;
  }

public:
  template <typename T> static T P(int n, int r) {
    T ans = 1;
    for (int i = 0; i < r; i++) {
      ans *= n - i;
    }
    return ans;
  }

public:
  template <typename T> static T C(int n, int r) {
    T nmr = 1;
    T dnm = 1;
    if (n - r < r)
      r = n - r;
    for (int i = 0; i < r; i++) {
      nmr *= n - i;
      dnm *= r - i;
    }
    return nmr / dnm;
  }
};
class Module_int {
public:
  static const int mod = MODULE;

public:
  static int add(int a, int b) {
    int ans = a + b;
    if (ans < 0)
      ans += mod;
    ans %= mod;
    return ans;
  }

public:
  static int mult(int a, int b) { return (a * b) % mod; }

public:
  static int Pow(int a, int b) {
    int base = a % mod;
    if (mod / 2 < abs(base))
      if (base < 0) {
        base += mod; // negative
      } else {
        base -= mod; // positive
      }

    return pow(base, b);
  }
};

int main(void) {
  srand((unsigned)time(NULL));

  int N, K;
  int *A;
  cin >> N;
  cin >> K;
  A = alloc(N, int);
  repeat(i, i < N) { scanf("%d", &A[i]); }

  ll *score;
  score = alloc(N - K + 1, ll);
  score[0] = 1;

  // DEBUG();
  repeat(i, i < K) { score[0] *= A[i]; }
  for (int i = 1; i < N - K + 1; i++) {
    // DEBUG();
    score[i] = score[i - 1];
    // LOG(score[i]);
    score[i] /= A[i - 1];
    // DEBUG()
    score[i] *= A[K + i - 1];
  }

  // DEBUG();
  for (int i = 1; i < N - K + 1; i++) {
    if (score[K + i - 1] < score[K + i]) {
      cout << "Yes\\n";
    } else {
      cout << "No\\n";
    }
  }

  // repeat(i, i < N - K + 1) { cout << score[i]<<"\\n"; }

  free(score);
  free(A);
  return 0;
}

int compare_int(const void *a, const void *b) { return *(int *)a - *(int *)b; }
void PrimeEnable(int n) {
  // initialize IsPrime
  IsPrime = (bool *)calloc(n + 1, sizeof(bool));
  for (int i = 0; i <= n; i++)
    IsPrime[i] = true;

  // IsPrime
  IsPrime[0] = IsPrime[1] = false;
  for (int i = 2; i * i <= n; i++) {
    if (IsPrime[i])
      for (int j = i; i * j <= n; j++) {
        IsPrime[i * j] = false;
      }
  }

  // push back to Prime
  for (int i = 0; i <= n; i++) {
    if (IsPrime[i])
      Prime.push_back(i);
  }
}