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

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long &e : a)
    cin >> e;
  for (int i = k; i < n; ++i)
    cout << (a[i - k] < a[i] ? "Yes" : "No") << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> sum(n + 1);
  sum[0] = 1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    sum[i + 1] = sum[i] * a;
  }
  for (int i = k; i < n; ++i)
    cout << (sum[i] / sum[i - k] < sum[i + 1] / sum[i + 1 - k] ? "Yes" : "No")
         << endl;

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

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pf(n) printf("%d\\n", n)
#define pff(a, b) printf("%d  %d\\n", a, b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
  ll n;
  cin >> n;
  ll k;
  cin >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

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

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pf(n) printf("%d\\n", n)
#define pff(a, b) printf("%d  %d\\n", a, b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
  ll n;
  cin >> n;
  ll k;
  cin >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<__int128> b(n);
  rep(i, n) {
    if (i == 0) {
      b[i] = a[i];
    } else {
      b[i] = b[i - 1] * a[i];
    }
  }
  __int128 h = b[k - 1];

  for (ll i = k; i < n; i++) {
    __int128 g = b[i] / b[i - k];
    // cout<<h<<" ";
    // cout<<g<<endl;

    if (g > h) {
      cout << "Yes\\n";
    } else {
      cout << "No\\n";
    }
    h = g;
  }

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

/* Simplicity and Goodness */

#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 tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template <typename Arg, typename... Args> void my_dbg(Arg A, Args... B) {
  cout << ' ' << A;
  my_dbg(B...);
}
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\\n", n)
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9 + 7;
const int maxN = 2e5 + 2;

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

  vl pref(n, 0), a(n);

  rep(i, 0, n) cin >> a[i];

  pref[0] = a[0];

  rep(i, 1, n) pref[i] = a[i] + pref[i - 1];

  ll last = pref[k - 1];

  int c = 0;

  rep(i, k, n) {
    ll now = pref[i] - pref[c++];
    puts(now > last ? "Yes" : "No");

    last = now;
  }
}

int main() {
  int t = 1;
  // scn(t);
  while (t--) {
    solve();
  }
  return 0;
}

Error: 0

Fixed submission:

/* Simplicity and Goodness */

#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 tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template <typename Arg, typename... Args> void my_dbg(Arg A, Args... B) {
  cout << ' ' << A;
  my_dbg(B...);
}
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\\n", n)
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9 + 7;
const int maxN = 2e5 + 2;

void solve() {
  int n, k;
  scn(n);
  scn(k);

  vl pref(n, 1), a(n);

  rep(i, 0, n) lscn(a[i]);

  pref[0] = a[0];

  rep(i, 1, n) pref[i] = a[i] * pref[i - 1];

  ll last = pref[k - 1];

  int c = 0;

  rep(i, k, n) {
    ll now = pref[i] / pref[c++];
    puts(now > last ? "Yes" : "No");

    last = now;
  }
}

int main() {
  int t = 1;
  // scn(t);
  while (t--) {
    solve();
  }
  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

/*
 * Project: M-SOLUTIONS プロコンオープン 2020 C - Marks
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/25
 * Copyright (c) 2020 toms74209200
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <vector>
using namespace std;

int n;
int k;
vector<int> a;

void solve() {

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

int main() {

  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    a.push_back(tmp);
  }

  solve();
}

Error: 0

Fixed submission:

/*
 * Project: M-SOLUTIONS プロコンオープン 2020 C - Marks
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/25
 * Copyright (c) 2020 toms74209200
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;

int n;
int k;
int a[20000];

void solve() {

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

int main() {

  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  solve();
}
Problem p02602 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;
using vi = vector<int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int64_t> Ai(n);
  rep(i, n) { cin >> Ai.at(i); }
  vector<int64_t> vec(n - k + 1);
  int64_t sum = 0;
  for (int i = 0; i < k; i++) {
    sum += Ai.at(i);
  }
  vec.at(0) = sum;
  for (int i = 1; i < n - k + 1; i++) {
    sum = vec.at(i - 1);
    sum = sum - Ai.at(i - 1) + Ai.at(i - 1 + k);
    vec.at(i) = sum;
  }

  for (int i = 1; i < n - k + 1; i++) {
    if (vec.at(i) > vec.at(i - 1))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;
using vi = vector<int>;

int main() {
  int n, k;
  cin >> n >> k;
  vi Ai(n);
  rep(i, n) { cin >> Ai.at(i); }
  vi vec(n - k + 1);
  for (int i = 0; i < n - k + 1; i++) {
    int sum = 0;
    for (int j = i; j < i + k; j++) {
      sum += Ai.at(j);
    }
    vec.at(i) = sum;
  }
  for (int i = k; i < n; i++) {
    if (vec.at(i - k + 1) > vec.at(i - k))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

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

#include <bits/stdc++.h>
#define ford(i, a, b) for (int i = (a); i >= b; i--)
#define rep1(i, a, b) for (int i = (a); (i) <= (b); (i)++)
#define rep(i, a, b) for (int i = (a); (i) < (b); (i)++)
#define ll long long
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rev(a, n) reverse(a, a + n)
using namespace std;
int n, k, a[N];
int main() {
  cin >> n >> k;
  rep1(i, 1, n) {
    cin >> a[i];
    if (i > k) {
      if (a[i - k] < a[i])
        cout << "Yes\\n";
      else
        cout << "No\\n";
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ford(i, a, b) for (int i = (a); i >= b; i--)
#define rep1(i, a, b) for (int i = (a); (i) <= (b); (i)++)
#define rep(i, a, b) for (int i = (a); (i) < (b); (i)++)
#define ll long long
#define N 105
#define pql priority_queue<ll>
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rev(a, n) reverse(a, a + n)
using namespace std;
int n, k, a[N];
int main() {
  cin >> n >> k;
  rep1(i, 1, n) {
    cin >> a[i];
    if (i > k) {
      if (a[i - k] < a[i])
        cout << "Yes\\n";
      else
        cout << "No\\n";
    }
  }
  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

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

  long long n, k;
  cin >> n >> k;
  vector<long long> v(n + 1), ans(n + 1);
  v[0] = 1;
  for (int i = 1; i <= n; i++)
    cin >> v[i];

  for (int i = 1; i <= n; i++) {
    ans[i] += v[i] + ans[i - 1];
  }

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

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

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

  long long n, k;
  cin >> n >> k;
  vector<long long> v(n + 1), pref(n + 1), aa;
  for (int i = 1; i <= n; i++)
    cin >> v[i];
  v[0] = 1;
  pref[0] = 1;
  for (int i = 1; i <= n; i++)
    pref[i] = pref[i - 1] * v[i];

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

  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;

int main() {
  int 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 - k] < a[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

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;

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> s(n + 1);
  s[0] = 1;
  rep(i, n) s[i + 1] = s[i] * a[i];
  for (int i = k + 1; i <= n; i++) {
    if (s[i] / s[i - k] > s[i - 1] / s[i - k - 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;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main() {
  long long N, K;
  cin >> N >> K;
  vector<int> A(N + 1, 0);
  for (int i = 1; i <= N; i++)
    cin >> A[i];

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

Error: 0

Fixed submission:

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

int main() {
  long long N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];

  vector<ll> s(N + 1, 1);
  for (ll i = 0; i < N; i++)
    s[i + 1] = s[i] * A[i];

  for (int i = 1; i < N - (K - 1); i++) {
    ll left = i;
    ll right = K + i;
    if ((s[right - 1] / s[left - 1]) < (s[right] / s[left]))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

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


Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a[100], i, n, k;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (i = 1; i <= n - k; i++) {
    if (a[i] < a[k + i]) {
      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, o;
  scanf("%lld %lld", &n, &o);
  long long int a[n];
  for (long long int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  for (long long int i = o; i < n; i++) {
    if (a[i - o] < a[i]) {
      printf("Yes\\n");
    } else {
      printf("No\\n");
    }
  }
  return 0;
}


Error: WA

Fixed submission:

#include <stdio.h>
int main() {
  int N, K;
  scanf("%d %d", &N, &K);
  int total[N];
  int i;
  for (i = 0; i < N; i++) {
    scanf("%d", &total[N]);
  }
  for (i = K; K < N; K++) {
    if (total[i - K] < total[i]) {
      printf("Yes\\n");
    } else {
      printf("No\\n");
    }
  }

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

#include <stdio.h>

int main() {
  int a, b;

  scanf("%d %d", &a, &b);

  int c[200000];

  for (int i = 0; i < a; i++) {

    scanf("%d", &c[i]);
  }

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

  return 0;
}


Error: 0

Fixed submission:

#include <stdio.h>

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  long long int data[100000] = {0};
  for (int i = 0; i < n; i++) {
    scanf("%d", &data[i]);
  }
  bool fr = false;
  for (int j = k - 1; j < n; j++) {
    if (!fr) {
      fr = true;
      continue;
    }
    if (data[j] > data[j - k]) {
      printf("Yes\\n");
    } else {
      printf("No\\n");
    }
  }
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  long long int input[n];
  for (int i = 0; i < n; i++) {
    scanf("%lld", &input[i]);
  }

  for (int i = 0; i < n - k; i++) {
    if (input[i] < input[i + k]) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int angka[10000] = {0};

  for (int i = 0; i < n; i++) {
    scanf("%d", &angka[i]);
  }
  int flag = 0;
  for (int i = 0; i < n - k; i++) {
    if (angka[i] < angka[k + i]) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  long long int score[n];

  for (int i = 0; i < n; i++) {
    scanf("%lld", &score[i]);
  }

  for (int i = 0, j = k; i < n - k; i++, j++) {
    if (score[j - k] < score[j]) {
      printf("Yes\\n");
    } else if (score[j - k] >= score[j]) {
      printf("No\\n");
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>

int main() {

  int n, k;
  scanf("%d %d", &n, &k);
  int arrInput[100] = {0};
  for (int i = 0; i < n; i++) {
    scanf("%d", &arrInput[i]);
  }
  for (int j = 0; j < n; j++) {
    if (arrInput[j + k] == '\\0') {
      break;
    }
    if (arrInput[j] >= arrInput[j + k]) {
      printf("No\\n");
    } else if (arrInput[j] < arrInput[j + k]) {
      printf("Yes\\n");
    }
  }

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

#include <stdio.h>

#define ll long long

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int arr[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  for (int j = 0; j < n - k; j++) {
    //		printf("compare %d < %d (?)\\n", arr[j], arr[j + k]);
    if (arr[j] < arr[j + k]) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>

#define ll long long

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  ll arr[n];
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
  }
  ll grade[k];
  for (int i = 0; i < k; i++) {
    grade[i] = arr[i];
    for (int j = i + 1; j < i + k; j++) {
      // printf("arr[j] %lld\\n", arr[j]);
      if (j == n) {
        j == 0;
        grade[i] *= arr[j];
      } else {
        grade[i] *= arr[j];
      }
    }
    // printf("grade %lld\\n", grade[i]);
  }
  // for(int i = 0; i < k; i++){
  // 	printf("%lld ", grade[i]);
  // }
  for (int i = 0; i < n - k; i++) {
    // printf("banding %lld %lld\\n", grade[i + 1], grade[i]);
    if (grade[i + 1] <= grade[i]) {
      puts("No");
    } else {
      puts("Yes");
    }
  }
  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k;
ll a[200005];
int main() {
  int i, j, k;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i + k < n; i++) {
    if (a[i] < a[i + k])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int main() {
  int n, m, i, j;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (j = m + 1; j <= n; j++) {
    if (a[j] > a[j - m])
      printf("Yes\\n");
    else
      printf("No\\n");
  }
  return 0;
}
Problem p02602 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define PI 3.14159265359
#define rep(i, a, n) for (int i = a; i < (int)n; ++i)
#define SZ(x) ((int)(x).size()) // size() unsigned -> int
#define descSort(a) sort(a.begin(), a.end(), std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void) {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, 0, n) { 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>

#define PI 3.14159265359
#define rep(i, a, n) for (int i = a; i < (int)n; ++i)
#define SZ(x) ((int)(x).size()) // size() unsigned -> int
#define descSort(a) sort(a.begin(), a.end(), std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void) {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  vector<ll> num(n + 1);
  num[0] = 1;
  rep(i, 0, n) {
    cin >> a[i];
    num[i + 1] = num[i] * a[i];
  }

  ll x = num[k];
  for (int i = k + 1; i <= n; i++) {
    ll y = num[i] / num[i - k];
    if (x < y)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    x = y;
  }

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

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
  int n, k;
  cin >> n >> k;

  vector<ll> a(n);
  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" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
  int n, k;
  cin >> n >> k;

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

  vector<ll> mul(n + 2, 1LL);
  for (int i = 0; i < n; ++i) {
    mul[i + 1] = mul[i] * a[i];
  }

  ll prev = mul[k];
  int cnt = 1;
  for (int i = k + 1; i <= n; ++i) {
    ll tmp = mul[i] / mul[cnt];

    if (prev < tmp)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

    cnt++;
    prev = tmp;
  }

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

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

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> data(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> data[i];
  }

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

Error: -8

Fixed submission:

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

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> data(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> data[i];
  }
  vector<int> T(K, 0);
  for (int i = 0; i < K; i++) {
    T[i] = data[i];
  }
  int temp1 = 1;
  for (int i = 0; i < K; i++) {
    temp1 *= T[i];
  }
  for (int i = K; K < N; i++) {
    int temp2 = temp1;
    temp2 /= data[i - K];
    temp2 *= data[i];
    if (temp1 < temp2)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    temp1 = temp2;
  }
}
Problem p02602 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  int n, m;

  scanf("%d %d", &n, &m);

  int arr[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  int term = n - m;
  for (int i = 0; i < term; i++) {
    int flag = 0;
    if (arr[i] < arr[i + m]) {
      flag = 1;
    }
    if (flag == 1) {
      printf("Yes\\n");
    } else {
      printf("No\\n");
    }
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int n, m;

  scanf("%d %d", &n, &m);

  int term = n - m;
  long long ans[n];
  int samp[n];

  for (int i = 0; i < n; i++) {
    scanf("%d", &samp[i]);
  }
  for (int i = 0; i < n; i++) {
    long long sum = 1, temp = m;
    for (int j = i; j < n; j++) {
      sum *= samp[j];
      --temp;
      if (temp <= 0) {
        break;
      }
    }
    ans[i] = sum;
  }

  for (int i = 1; i <= term; i++) {
    if (ans[i] > ans[i - 1]) {
      printf("Yes\\n");
    } else {
      printf("No\\n");
    }
  }
}