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

#include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define eb emplace_back
// to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 1000
#define E5 10000
#define E6 1000000
#define inf 1001001001
#define longinf 2001001001001001001
#define pi 3.1415926535

#define rec2(i, a, b) for (lld i = a; i < b; i++)
#define rec(i, n) for (lld i = 0; i < n; i++)
#define rev(i, a, b) for (lld i = b - 1; i >= a; i--)
#define all(v) (v).begin(), (v).end()
#define large(v) *max_element(all(v))
#define small(v) *min_element(all(v))
#define v vector
const double EPS = 1e-6;
/*  //prime sieve if needed
//prime factors of number
int prime[E6+1];
void sieve(lld n)
{ rec(i,n+1)
    prime[i]=1;
   for(lld i=2;i*i<=n;i++)
     { if(prime[i]!=1)
          continue;
         for(lld j=i*i;j<=n;j=j+i)
          if(prime[i]==1)
           prime[j]=i;
      }
}
*/
lld gcd(lld a, lld b) {
  if (a == 0)
    return b;
  return gcd(b % a, a);
}
// fermat a^(m-2)%mod
lld binarymul(lld a, lld n, lld m) {
  lld res = 1;
  while (n) {
    if (n % 2) {
      res = (res * a) % m;
      n--;
    }
    a = (a * a) % m;
    n /= 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef PUNEET_GOEL
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
  // sieve(E6);
  lld n, k;
  cin >> n >> k;
  lld a[n];
  rec(i, n) cin >> a[i];
  int j = 0;

  for (int i = k; i < n; i++) {
    if (a[i] > a[j])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    j++;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
// #include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define eb emplace_back
// to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 1000
#define E5 10000
#define E6 1000000
#define inf 1001001001
#define longinf 2001001001001001001
#define pi 3.1415926535

#define rec2(i, a, b) for (lld i = a; i < b; i++)
#define rec(i, n) for (lld i = 0; i < n; i++)
#define rev(i, a, b) for (lld i = b - 1; i >= a; i--)
#define all(v) (v).begin(), (v).end()
#define large(v) *max_element(all(v))
#define small(v) *min_element(all(v))
#define v vector
const double EPS = 1e-6;
/*  //prime sieve if needed
//prime factors of number
int prime[E6+1];
void sieve(lld n)
{ rec(i,n+1)
    prime[i]=1;
   for(lld i=2;i*i<=n;i++)
     { if(prime[i]!=1)
          continue;
         for(lld j=i*i;j<=n;j=j+i)
          if(prime[i]==1)
           prime[j]=i;
      }
}
*/
lld gcd(lld a, lld b) {
  if (a == 0)
    return b;
  return gcd(b % a, a);
}
// fermat a^(m-2)%mod
lld binarymul(lld a, lld n, lld m) {
  lld res = 1;
  while (n) {
    if (n % 2) {
      res = (res * a) % m;
      n--;
    }
    a = (a * a) % m;
    n /= 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef PUNEET_GOEL
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
  // sieve(E6);
  lld n, k;
  cin >> n >> k;
  lld a[n];
  rec(i, n) cin >> a[i];

  rec(i, k - 1) a[k - 1] *= a[i];
  int j = 0;
  for (int i = k; i < n; i++) {
    a[i] = (a[i] * a[i - 1]) / a[j];
    j++;
  }

  for (int i = k; i < n; i++) {
    if (a[i] > a[i - 1])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}