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

/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int, long long int> ii;          // Pair of integers
typedef vector<long long int> vi;                       // Vector of integers
typedef vector<vector<long long int>> vvi;              // Vector of vi
typedef vector<pair<long long int, long long int>> vii; // Vector of ii

#define pb push_back                  // Push back to vectors
#define mp make_pair                  // For pairs
#define ff first                      // For pairs
#define ss second                     // For pairs
#define all(c) (c).begin(), (c).end() // Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i, x, y)                                                           \\
  for (long long int i = (x); i <= (y); ++i) // Loop to go forward
#define reb(i, x, y)                                                           \\
  for (long long int i = (x); i >= (y); --i) // Loop to go backward
#define trf(c, it)                                                             \\
  for (auto it = (c).begin(); it != (c).end();                                 \\
       it++) // Remember it is an iterator
#define trb(c, it)                                                             \\
  for (auto it = (c).end() - 1; it != (c).begin() - 1;                         \\
       it--) // Remember it is an iterator
#define tc(t)                                                                  \\
  long long int(t);                                                            \\
  cin >> (t);                                                                  \\
  while ((t)--) // Test cases
// fill (dist,dist+110000,pinf);							// For
// setting default

const long long int mod = 1e9 + 7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

lli n, k, a[210000];

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

  cin >> n >> k;

  ref(i, 1, n) cin >> a[i];

  ref(i, k + 1, n) {
    if (a[i] > a[i - k])
      cout << "Yes" << endl;

    else
      cout << "No" << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int, long long int> ii;          // Pair of integers
typedef vector<long long int> vi;                       // Vector of integers
typedef vector<vector<long long int>> vvi;              // Vector of vi
typedef vector<pair<long long int, long long int>> vii; // Vector of ii

#define pb push_back                  // Push back to vectors
#define mp make_pair                  // For pairs
#define ff first                      // For pairs
#define ss second                     // For pairs
#define all(c) (c).begin(), (c).end() // Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i, x, y)                                                           \\
  for (long long int i = (x); i <= (y); ++i) // Loop to go forward
#define reb(i, x, y)                                                           \\
  for (long long int i = (x); i >= (y); --i) // Loop to go backward
#define trf(c, it)                                                             \\
  for (auto it = (c).begin(); it != (c).end();                                 \\
       it++) // Remember it is an iterator
#define trb(c, it)                                                             \\
  for (auto it = (c).end() - 1; it != (c).begin() - 1;                         \\
       it--) // Remember it is an iterator
#define tc(t)                                                                  \\
  long long int(t);                                                            \\
  cin >> (t);                                                                  \\
  while ((t)--) // Test cases
// fill (dist,dist+110000,pinf);							// For
// setting default

const long long int mod = 1e9 + 7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

lli n, k, arr[210000], pro[210000], ans[210000], top = 0;

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

  cin >> n >> k;

  ref(i, 0, n - 1) {
    cin >> arr[i];

    if (i == 0)
      pro[i] = arr[i];

    else
      pro[i] = arr[i] * pro[i - 1];
  }

  ref(i, k - 1, n - 1) {
    if (i == k - 1) {
      ans[top] = pro[i];
      top++;
    }

    else {
      ans[top] = pro[i] / pro[i - k];
      top++;
    }
  }

  ref(i, 1, top - 1) {
    if (ans[i] > ans[i - 1])
      cout << "Yes\\n";

    else
      cout << "No\\n";
  }

  return 0;
}