alexjercan/bugnet huggingface dataset:
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> A(N);
  rep(i, N) cin >> A.at(i);
  long long sum1 = 0, sum2 = 0;

  rep(j, K) {
    sum1 += A.at(K - j - 1);
    sum2 += A.at(K - j);
  }
  if (sum1 < sum2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  for (int i = 0; i < N - K - 1; i++) {
    sum1 = sum1 - A.at(i) + A.at(i + K);
    sum2 = sum2 - A.at(i + 1) + A.at(i + K + 1);

    if (sum1 < sum2)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> A(N);
  rep(i, N) cin >> A.at(i);
  long long sum1 = 0, sum2 = 0;

  rep(i, N - K) {

    sum1 += A.at(K + i - 1) + A.at(K + i - 2) + A.at(K + i - 3);
    sum2 += A.at(K + i) + A.at(K + i - 1) + A.at(K + i - 2);

    if (sum1 < sum2)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    sum1 = 0;
    sum2 = 0;
  }
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define MOD (ll)(1e9 + 7)
int main() {
  ll n, k;
  cin >> n >> k;
  ll ar[n];
  for (ll i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (ll i = k; i < n; i++) {
    if (ar[i] > ar[i - k]) {
      cout << "Yes\\n";
    } else {
      cout << "No\\n";
    }
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define MOD (ll)(1e9 + 7)
ll modulom(ll a, ll b, ll mod) {
  ll res = 0;
  a %= mod;
  while (b) {
    if (b & 1)
      res = (res + a) % mod;

    a = (2 * a) % mod;

    b >>= 1; // b = b / 2
  }
  return res;
}
int main() {
  ll n, k;
  cin >> n >> k;
  ll ar[n];
  vector<ll> comp;
  for (ll i = 0; i < n; i++) {
    cin >> ar[i];
  }
  comp.push_back(ar[0]);
  for (ll i = 1; i < n; i++) {
    ll val = modulom(ar[i], comp[i - 1], 10005412336548794);
    comp.push_back(val);
  }
  vector<ll> ans;
  ans.push_back(comp[k - 1]);
  for (ll i = k; i < n; i++) {
    ll xx = comp[i] / (comp[i - k]);
    ans.push_back(xx);
  }
  ll vv = ans.size();
  for (ll p = 1; p < vv; p++) {
    if (ans[p] > ans[p - 1]) {
      cout << "Yes\\n";
    } else {
      cout << "No\\n";
    }
  }
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

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

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

Error: 0

Fixed submission:

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

int main() {
  long long n;
  cin >> n;
  long long k;
  cin >> k;
  vector<long long> a(n);
  vector<long long> prod(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0) {
      prod[i] = a[i];
    } else {
      prod[i] = a[i] * prod[i - 1];
    }
  }
  for (long long i = k; i < n; i++) {
    long long s1 = prod[i] / prod[i - k];
    long long ps;
    if (ps < k)
      ps = 0;
    else
      ps = prod[i - 1];
    if (i - 1 - k >= 0)
      ps /= prod[i - 1 - k];
    if (s1 > ps) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[200001];
ll msa[200002];
vector<ll> ans;
ll sum = 0;
int main() {
  int n, k;
  cin >> n >> k;

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

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[200001];
ll msa[200002];
vector<ll> ans;

int main() {
  int n, k;
  cin >> n >> k;
  msa[0] = 1;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    msa[i] = arr[i] * msa[i - 1];
  }

  int c = 0;
  for (int i = k; i <= n; ++i) {
    ans.push_back(floor(msa[i] / msa[c]));
    c++;
  }

  for (int i = 0; i < ans.size() - 1; ++i) {
    if (ans[i] < ans[i + 1])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;
int main() {
  long N;
  cin >> N;
  long K;
  cin >> K;
  vector<long> avec;
  vector<long> zeros;
  for (long i = 0; i < N; ++i) {
    long a;
    cin >> a;
    avec.emplace_back(a);
    if (a == 0) {
      zeros.emplace_back(i);
    }
  }

  unsigned int currentZeroIdx = 0u;
  int currentZero = -1;
  if (zeros.size() > 0) {
    currentZero = zeros[currentZeroIdx];
  }
  for (long i = K; i < N; ++i) {
    if ((zeros.size() > 0) && currentZero < i - K + 1) {
      currentZeroIdx++;
      if (zeros.size() - 1 < currentZeroIdx) {
        currentZero = -1;
      } else {
        currentZero = zeros[currentZeroIdx];
      }
    }

    if ((currentZero != -1) && (i - K + 1 <= currentZero && currentZero < i)) {
      cout << "No" << endl;
    } else {
      if (avec[i] > avec[i - K]) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
}

Error: -11

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  long N;
  cin >> N;
  long K;
  cin >> K;
  vector<long> avec;
  vector<long> zeros;
  for (long i = 0; i < N; ++i) {
    long a;
    cin >> a;
    avec.emplace_back(a);
    if (a == 0) {
      zeros.emplace_back(i);
    }
  }

  unsigned int currentZeroIdx = 0u;
  int currentZero = -1;
  if (zeros.size() > 0) {
    currentZero = zeros[currentZeroIdx];
  }
  for (long i = K; i < N; ++i) {
    if (currentZero < i - K + 1) {
      currentZeroIdx++;
      if (zeros.size() - 1 < currentZeroIdx) {
        currentZero = -1;
      } else {
        currentZero = zeros[currentZeroIdx];
      }
    }

    if ((currentZero != -1) && (i - K + 1 <= currentZero && currentZero < i)) {
      cout << "No" << endl;
    } else {
      if (avec[i] > avec[i - K]) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
long long N, K, A[1 << 18];
int main() {
  cin >> N >> K;
  for (int i = 1; i <= N; i++)
    cin >> A[i];
  for (int i = K + 1; i <= N; i++) {
    if (A[i - K] < A[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main(void)

{
  long long n, k, i, j, a, b, s;
  cin >> n >> k;
  s = n - k;
  long long ara[n + 1], ara2[s + 1];
  for (i = 1; i <= n; i++)
    cin >> ara[i];
  for (i = 1; i <= k + 2; i++) {
    a = 1;
    for (j = i; j < k + i; j++) {
      a *= ara[j];
    }
    ara2[i] = a;
  }
  for (i = 2; i <= n - k + 1; i++) {
    if (ara2[i - 1] < ara2[i])
      cout << "Yes\\n";
    else
      cout << "No\\n";
  }
  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
using namespace std;
signed main() {
  ll n, k, a[1000000];
  cin >> n >> k;

  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

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

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
signed main() {
  ll n, k, a;
  ll mol[1000000] = {1};
  cin >> n >> k;

  for (int i = 1; i <= n; i++) {
    cin >> a;
    mol[i] = mol[i - 1] * a;
  }

  ll j = 0;
  for (int i = k; i < n; i++) {
    if (mol[i] / mol[j] < mol[i + 1] / mol[j + 1]) {
      cout << "Yes\\n";
    } else {
      cout << "No\\n";
    }
    j++;
  }
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  int n, k;
  cin >> n >> k;
  V<ll> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = k; i < n; i++) {
    if (a[i - k] < a[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  int n, k;
  cin >> n >> k;
  V<ll> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  V<ll> sums(n + 2, 1);
  for (int i = 0; i < n; i++) {
    sums[i + 2] = sums[i + 1] * a[i];
  }
  V<ll> ans;
  for (int i = k + 1; i <= n + 1; i++) {
    ans.push_back(sums[i] / sums[i - k]);
  }
  for (int i = 1; i < (int)ans.size(); i++) {
    if (ans[i - 1] < ans[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

#define pb push_back
#define ff first
#define ss second
#define INF int(3e9)
#define BIG_INF ll(9e18)
#define SIZE 200001
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define len(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout);

ll binpow(ll a, ll b, ll MOD = BIG_INF) {
  ll res = 1;

  while (b) {
    if (b & 1)
      res *= a;
    a *= a;
    b >>= 1;
    a %= MOD;
    res %= MOD;
  }

  return res % MOD;
}

const ll mod = 1e9 + 7;

int T = 1;
int n, k;
ll a[SIZE];

void solve() {
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> a[i];

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

  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  //    filein;fileout;

  //    cin >> T;

  while (T--) {
    solve();
  }
  return 0;
}


Error: 0

Fixed submission:

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

#define pb push_back
#define ff first
#define ss second
#define INF int(3e9)
#define BIG_INF ll(9e18)
#define SIZE 200001
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define len(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout);

ll binpow(ll a, ll b, ll MOD = BIG_INF) {
  ll res = 1;

  while (b) {
    if (b & 1)
      res *= a;
    a *= a;
    b >>= 1;
    a %= MOD;
    res %= MOD;
  }

  return res % MOD;
}

const ll mod = 1e9 + 7;

int T = 1;
int n, k;
ll a[SIZE];

void solve() {
  cin >> n >> k;

  for (int i = 0; i < n; i++)
    cin >> a[i];

  vector<ll> pref(n, 0);
  vector<ll> ans(n, 0);
  pref[0] = a[0];
  ans[0] = a[0];
  for (int i = 1; i < n; i++) {
    pref[i] = pref[i - 1] * a[i];
    ans[i] = pref[i];
  }

  for (int i = k; i < n; i++) {
    int id = i - k;
    ans[i] /= pref[id];
    if (ans[i] > ans[i - 1])
      cout << "Yes\\n";
    else
      cout << "No\\n";
  }

  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  //    filein;fileout;

  //    cin >> T;

  while (T--) {
    solve();
  }
  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
  int k, n;
  cin >> n >> k;
  int a[200001];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = k + 1; i <= n; i++) {
    if (a[i] > a[i - k]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[201];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int b[201] = {1};
  for (int i = k; i <= n; i++) {
    b[i] = 1;
  }
  for (int i = k; i <= n; i++) {
    for (int j = 0; j < k; j++) {
      b[i] *= a[i - j];
    }
  }
  for (int i = 1; i <= n - k; i++) {
    if (b[k + i] > b[k + i - 1]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  for (int i = K; i < vec.size(); i++) {
    if (vec[i - K] < vec[i]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Error: -6
malloc(): corrupted top size


Fixed submission:

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

int main() {
  int N, K;
  cin >> N >> K;
  int input;
  vector<long long> result(N - K + 1, 1);
  for (int x = 0; x < N; x++) {
    cin >> input;
    for (int i = x - K + 1; i < x + 1; i++) {
      if (i < 0) {
        continue;
      }
      if (i == N) {
        break;
      } else {
        result[i] *= input;
      }
    }
  }
  for (int i = 1; i < result.size(); i++) {
    if (result[i] > result[i - 1]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  deque<ll> inter;
  for (int i = 0; i < K; ++i) {
    inter.push_back(A[i]);
  }
  for (int i = K; i < N; ++i) {
    ll first = inter.front();
    inter.pop_front();
    ll last = A[i];
    inter.push_back(A[i]);
    if (first < last)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Error: 0

Fixed submission:

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  deque<ll> inter;
  for (int i = 0; i < K; ++i) {
    inter.push_back(A[i]);
  }
  for (int i = K; i < N; ++i) {
    ll first = inter.front();
    inter.pop_front();
    ll last = A[i];
    if (first < last)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n - k) {
    if (a[i] < a[i + k])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n), sum(n + 1, 1), sum2(n - k + 1);
  rep(i, n) {
    cin >> a[i];
    sum[i + 1] = sum[i] * a[i];
  }
  rep(i, n - k + 1) { sum2[i] = sum[k + i] / sum[i]; }
  rep(i, n - k) {
    if (sum2[i] < sum2[i + 1])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;

const ll INF = 1LL << 62;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  for (int i = K; i < N; i++) {
    if (A[i] > A[i - K]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;

const ll INF = 1LL << 62;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  vector<ll> cum(N + 1, 1);
  rep(i, N) { cum[i + 1] = cum[i] * A[i]; }

  for (int i = K; i < N; i++) {
    ll current = cum[i + 1] / cum[i + 1 - K];
    ll prev = cum[i] / cum[i - K];
    if (current > prev) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}
Problem p02602 (C++) — buggy submission, verdict: Time Limit Exceeded

/**
 *    author:  yuya1234
 *    created: 25.07.2020 21:08:29
 **/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

#define SORT(x) sort(x.begin(), x.end())
#define SORTD(x) sort(x.rbegin(), x.rend())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

  ll n, k;
  cin >> n >> k;

  ll a[n];
  REP(i, n) cin >> a[i];

  REP(i, n - k) {
    if (a[i] < a[i + k])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

/**
 *    author:  yuya1234
 *    created: 25.07.2020 21:08:29
 **/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

#define SORT(x) sort(x.begin(), x.end())
#define SORTD(x) sort(x.rbegin(), x.rend())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

  ll n, k;
  cin >> n >> k;

  ll a[n + k], tmp;
  REP(i, n + k) { a[i] = 1; }

  REP(i, n) {
    cin >> tmp;
    REP(j, k) { a[i + j] *= tmp; }
  }

  REP(i, n - k) {
    // cout<<a[i+k-1]<<" "<<a[i+k+1-1]<<endl;
    if (a[i + k - 1] < a[i + k + 1 - 1])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {

  long long int n, k;
  scanf("%lld", &n);
  scanf("%lld", &k);

  long long int a[200000];
  for (long long int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  for (long long int j = 0; j < n - k; j++) {
    if (a[k + j] > a[j]) {
      printf("Yes\\n");
    } else
      printf("No\\n");
  }

  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>
int main() {

  long long int n, k;
  scanf("%lld", &n);
  scanf("%lld", &k);

  long long int a[100];
  for (long long int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  for (long long int j = 0; j < n - k; j++) {
    if (a[k + j] > a[j]) {
      printf("Yes\\n");
    } else
      printf("No\\n");
  }

  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main() {
  int n, k;
  cin >> n >> k;
  vl a(n + 1);
  a[0] = 1;
  for (int i = 1; i <= n; i++) {
    ll x;
    cin >> x;
    a[i] = x;
  }
  for (int i = k + 1; i <= n; i++) {
    if (a[i] > a[i - k])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main() {
  int n, k;
  cin >> n >> k;
  vl a(n + 1);
  vl p(n + 1);
  a[0] = 1;
  for (int i = 1; i <= n; i++) {
    ll x;
    cin >> x;
    a[i] = a[i - 1] * x;
    if (i >= k) {
      p[i] = a[i] / a[i - k];
    }
  }

  for (int i = k + 1; i <= n; i++) {
    if (p[i] > p[i - 1])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int lt[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &lt[i]);
  }
  int c = n - k;
  for (int i = 0; i < c; i++) {
    if (lt[i] < lt[i + k]) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int lt[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &lt[i]);
  }
  int c = n - k;
  for (int i = 0; i < c; i++) {
    if (lt[i] < lt[i + c]) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
  return 0;
}