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

/* HARE KRSNA HARE KRSNA KRSNA KRSNA HARE HARE
    HARE RAMA HARE RAMA RAMA RAMA HARE HARE  */

#include <bits/stdc++.h>
using namespace std;

#define nl "\\n"
#define ff first
#define ss second
#define pp pop_back
#define pf pop_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define b_s binary_search
#define all(x) x.begin(), x.end()
#define test                                                                   \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  while (t--)
#define loop(i, s, n) for (ll i = s; i < n; i++)
#define rloop(i, s, n) for (ll i = s; i >= n; i--)
#define fill(a, value) memset(a, value, sizeof(a))

#define debug2(a)                                                              \\
  for (auto x : a)                                                             \\
    cout << x << " ";                                                          \\
  cout << nl;
#define debug4(a)                                                              \\
  for (auto x : a)                                                             \\
    cout << x.ff << " " << x.ss << nl;
#define debug1(a, n)                                                           \\
  loop(i, 0, n) cout << a[i] << " ";                                           \\
  cout << nl;
#define debug3(a, n, m)                                                        \\
  loop(i, 0, n) {                                                              \\
    loop(j, 0, m) cout << a[i][j] << " ";                                      \\
    cout << nl;                                                                \\
  }

typedef long long ll;
typedef long double ld;

typedef stack<ll> sll;
typedef queue<ll> qll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<ll, pll> ppll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<ll> pqll;

const ll mod = 1000000007;  // 998244353;
const ld pi = acos((ld)-1); // 3.1415926535;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll num_generator() { return rand() % 1000; }
void array_generator(ll a[], ll n) { loop(i, 0, n) a[i] = rand() % 100; }

void solve() {
  ll n, k;
  cin >> n >> k;
  ll a[n];
  loop(i, 0, n) cin >> a[i];
  loop(i, k, n) {
    if (a[i] > a[i - k])
      cout << "Yes";
    else
      cout << "No";
    cout << nl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  // test
  solve();

  return 0;
}

Error: -11

Fixed submission:

/* HARE KRSNA HARE KRSNA KRSNA KRSNA HARE HARE
    HARE RAMA HARE RAMA RAMA RAMA HARE HARE  */

#include <bits/stdc++.h>
using namespace std;

#define nl "\\n"
#define ff first
#define ss second
#define pp pop_back
#define pf pop_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define b_s binary_search
#define all(x) x.begin(), x.end()
#define test                                                                   \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  while (t--)
#define loop(i, s, n) for (ll i = s; i < n; i++)
#define rloop(i, s, n) for (ll i = s; i >= n; i--)
#define fill(a, value) memset(a, value, sizeof(a))

#define debug2(a)                                                              \\
  for (auto x : a)                                                             \\
    cout << x << " ";                                                          \\
  cout << nl;
#define debug4(a)                                                              \\
  for (auto x : a)                                                             \\
    cout << x.ff << " " << x.ss << nl;
#define debug1(a, n)                                                           \\
  loop(i, 0, n) cout << a[i] << " ";                                           \\
  cout << nl;
#define debug3(a, n, m)                                                        \\
  loop(i, 0, n) {                                                              \\
    loop(j, 0, m) cout << a[i][j] << " ";                                      \\
    cout << nl;                                                                \\
  }

typedef long long ll;
typedef long double ld;

typedef stack<ll> sll;
typedef queue<ll> qll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<ll, pll> ppll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<ll> pqll;

const ll mod = 1000000007;  // 998244353;
const ld pi = acos((ld)-1); // 3.1415926535;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll num_generator() { return rand() % 1000; }
void array_generator(ll a[], ll n) { loop(i, 0, n) a[i] = rand() % 100; }

void solve() {
  ll n, k;
  cin >> n >> k;
  ll a[n];
  loop(i, 0, n) cin >> a[i];
  ll pre[n + 2];
  loop(i, 0, n) pre[i] = 1;
  loop(i, 0, n) {
    pre[i + 1] = a[i];
    pre[i + 1] *= pre[i];
  }
  loop(i, k, n) {
    // cout << pre[i + 1] / pre[i - k + 1] << " " << pre[i] / pre[i - k] << nl;
    if (pre[i + 1] / pre[i - k + 1] > pre[i] / pre[i - k])
      cout << "Yes";
    else
      cout << "No";
    cout << nl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  // test
  solve();

  return 0;
}