prithivMLmods/Coder-Stat huggingface dataset:
Problem p02758 (C++)

Buggy submission (status: Runtime Error):
// Date: 2020-03-08

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO                                                                    \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0)
#define rep(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for (int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 998244353;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {
  LL a = 1;
  while (y) {
    if (y & 1)
      a = a * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return a;
}

int n;
pii a[N];

int main() {
  scanf("%d", &n);
  rep(i, 1, n) scanf("%d%d", &a[i].fi, &a[i].se);
  sort(a + 1, a + 1 + n);
  LL ans = 1;
  vector<pii> v;
  v.pb(mk((int)2e9 + 1, 1));
  per(i, n, 1) {
    while (v.back().fi < a[i].fi + a[i].se)
      v.pop_back();
    ans = (ans + v.back().se) % mod;
    v.pb(mk(a[i].fi, ans));
  }
  printf("%lld\n", ans);

  return 0;
}

Fixed submission:
// Date: 2020-03-08

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO                                                                    \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0)
#define rep(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for (int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 998244353;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {
  LL a = 1;
  while (y) {
    if (y & 1)
      a = a * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return a;
}

int n;
pii a[N];

int main() {
  scanf("%d", &n);
  rep(i, 1, n) scanf("%d%d", &a[i].fi, &a[i].se);
  sort(a + 1, a + 1 + n);
  LL ans = 1;
  vector<pii> v;
  v.pb(mk((int)2e9 + 1, 1));
  per(i, n, 1) {
    while (v.back().fi < a[i].fi + a[i].se)
      v.pop_back();
    ans = (ans + v.back().se) % mod;
    v.pb(mk(a[i].fi, ans));
  }
  printf("%lld\n", ans);

  return 0;
}
Problem p02758 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair<int, int> pii;

const int mod = 998244353;

pii a[200010];
int nxt[200010];
int dp[200010];

struct Segment_tree {
  int maxj[200010];
  Segment_tree() { memset(maxj, 0, sizeof(maxj)); }
  void Update(int now, int l, int r, int pos, int x) {
    if (l == r) {
      maxj[now] = max(maxj[now], x);
      return;
    }
    int mid = l + r >> 1;
    if (pos <= mid)
      Update(now << 1, l, mid, pos, x);
    else
      Update(now << 1 | 1, mid + 1, r, pos, x);
    maxj[now] = max(maxj[now << 1], maxj[now << 1 | 1]);
  }
  int Query(int now, int l, int r, int L, int R) {
    if (l == L && r == R)
      return maxj[now];
    int mid = l + r >> 1;
    if (R <= mid)
      return Query(now << 1, l, mid, L, R);
    if (L > mid)
      return Query(now << 1 | 1, mid + 1, r, L, R);
    return max(Query(now << 1, l, mid, L, mid),
               Query(now << 1 | 1, mid + 1, r, mid + 1, R));
  }
} seg;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i].fi, &a[i].se);
  }
  sort(a, a + n);
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    int pos = lower_bound(a, a + n, mp(a[i].fi + a[i].se - 1, 0x3f3f3f3f)) - a;
    nxt[i] = max(i, seg.Query(1, 0, n - 1, i, pos - 1));
    seg.Update(1, 0, n - 1, i, nxt[i]);
    dp[i] = dp[nxt[i] + 1] + dp[i + 1];
    if (dp[i] >= mod)
      dp[i] -= mod;
  }
  printf("%d\n", dp[0]);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair<int, int> pii;

const int mod = 998244353;

pii a[200010];
int nxt[200010];
int dp[200010];

struct Segment_tree {
  int maxj[800010];
  Segment_tree() { memset(maxj, 0, sizeof(maxj)); }
  void Update(int now, int l, int r, int pos, int x) {
    if (l == r) {
      maxj[now] = max(maxj[now], x);
      return;
    }
    int mid = l + r >> 1;
    if (pos <= mid)
      Update(now << 1, l, mid, pos, x);
    else
      Update(now << 1 | 1, mid + 1, r, pos, x);
    maxj[now] = max(maxj[now << 1], maxj[now << 1 | 1]);
  }
  int Query(int now, int l, int r, int L, int R) {
    if (l == L && r == R)
      return maxj[now];
    int mid = l + r >> 1;
    if (R <= mid)
      return Query(now << 1, l, mid, L, R);
    if (L > mid)
      return Query(now << 1 | 1, mid + 1, r, L, R);
    return max(Query(now << 1, l, mid, L, mid),
               Query(now << 1 | 1, mid + 1, r, mid + 1, R));
  }
} seg;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i].fi, &a[i].se);
  }
  sort(a, a + n);
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    int pos = lower_bound(a, a + n, mp(a[i].fi + a[i].se - 1, 0x3f3f3f3f)) - a;
    nxt[i] = max(i, seg.Query(1, 0, n - 1, i, pos - 1));
    seg.Update(1, 0, n - 1, i, nxt[i]);
    dp[i] = dp[nxt[i] + 1] + dp[i + 1];
    if (dp[i] >= mod)
      dp[i] -= mod;
  }
  printf("%d\n", dp[0]);
  return 0;
}
Problem p02758 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
vector<pair<ll, ll>> v;
vector<int> x, d;
ll dp1[200010], dp[200010], sum = 0, mod = 998244353;
ll n, seg[200010], mx = 100000000000000;
void built() {
  for (int i = n - 1; i > 0; i--) {
    seg[i] = max(seg[i << 1], seg[i << 1 | 1]);
  }
}

void update(int p, ll a) {
  for (seg[p += n] = a; p > 1; p >>= 1) {
    seg[p >> 1] = max(seg[p], seg[p ^ 1]);
  }
}

ll query(int l, int r) {
  ll mn = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1)
      mn = max(mn, seg[l++]);
    if (r & 1)
      mn = max(mn, seg[--r]);
  }
  return mn;
}

int main() {
  ll i;
  cin >> n;
  for (i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    v.push_back({a, b});
  }
  sort(v.begin(), v.end());
  for (i = 0; i < n; i++) {
    x.push_back(v[i].first);
    d.push_back(v[i].second);
  }
  dp[n] = 1;
  for (i = n - 1; i >= 0; i--) {
    auto it = lower_bound(x.begin(), x.end(), x[i] + d[i]);
    int j = it - x.begin();
    dp1[i] = query(i, j);
    dp1[i] = max(dp1[i], i);
    update(i, dp1[i]);
    dp[i] = (dp[i + 1] + dp[dp1[i] + 1]) % mod;
  }
  cout << dp[0] << endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
vector<pair<ll, ll>> v;
vector<int> x, d;
ll dp1[200010], dp[200010], sum = 0, mod = 998244353;
ll n, seg[400010], mx = 100000000000000;
void built() {
  for (int i = n - 1; i > 0; i--) {
    seg[i] = max(seg[i << 1], seg[i << 1 | 1]);
  }
}

void update(int p, ll a) {
  for (seg[p += n] = a; p > 1; p >>= 1) {
    seg[p >> 1] = max(seg[p], seg[p ^ 1]);
  }
}

ll query(int l, int r) {
  ll mn = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1)
      mn = max(mn, seg[l++]);
    if (r & 1)
      mn = max(mn, seg[--r]);
  }
  return mn;
}

int main() {
  ll i;
  cin >> n;
  for (i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    v.push_back({a, b});
  }
  sort(v.begin(), v.end());
  for (i = 0; i < n; i++) {
    x.push_back(v[i].first);
    d.push_back(v[i].second);
  }
  dp[n] = 1;
  for (i = n - 1; i >= 0; i--) {
    auto it = lower_bound(x.begin(), x.end(), x[i] + d[i]);
    int j = it - x.begin();
    dp1[i] = query(i, j);
    dp1[i] = max(dp1[i], i);
    update(i, dp1[i]);
    dp[i] = (dp[i + 1] + dp[dp1[i] + 1]) % mod;
  }
  cout << dp[0] << endl;
}
Problem p02758 (C++)

Buggy submission (status: Runtime Error):
// by szh
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int, int>
#define mod 998244353
#define debug(x) cerr << #x << "=" << x << '\n'

const int maxn = 1e5 + 10;

int n;
pii a[maxn];
int r[maxn];
int mx[maxn][20];
int f[maxn];
int l0g[maxn];

int query(int x, int y) {
  int tmp = l0g[y - x + 1];
  return max(mx[x][tmp], mx[y - (1 << tmp) + 1][tmp]);
}

int main() {
  l0g[1] = 0;
  for (int i = 2; i < maxn; i++)
    l0g[i] = l0g[i / 2] + 1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d%d", &a[i].fi, &a[i].se);
  sort(a, a + n);
  f[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    int x = lower_bound(a, a + n, MP(a[i].fi + a[i].se, 0)) - a - 1;
    if (x > i)
      r[i] = query(i + 1, x);
    else
      r[i] = i + 1;
    mx[i][0] = r[i];
    for (int j = 1; i + (1 << j) <= n; j++)
      mx[i][j] = max(mx[i][j - 1], mx[i + (1 << (j - 1))][j - 1]);
  }
  for (int i = n - 1; i >= 0; i--) {
    f[i] = (f[i + 1] + f[r[i]]) % mod;
    ;
  }
  printf("%d", f[0]);
  return 0;
}


Fixed submission:
// by szh
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int, int>
#define mod 998244353
#define debug(x) cerr << #x << "=" << x << '\n'

const int maxn = 2e5 + 10;

int n;
pii a[maxn];
int r[maxn];
int mx[maxn][20];
int f[maxn];
int l0g[maxn];

int query(int x, int y) {
  int tmp = l0g[y - x + 1];
  return max(mx[x][tmp], mx[y - (1 << tmp) + 1][tmp]);
}

int main() {
  l0g[1] = 0;
  for (int i = 2; i < maxn; i++)
    l0g[i] = l0g[i / 2] + 1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d%d", &a[i].fi, &a[i].se);
  sort(a, a + n);
  f[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    int x = lower_bound(a, a + n, MP(a[i].fi + a[i].se, 0)) - a - 1;
    if (x > i)
      r[i] = query(i + 1, x);
    else
      r[i] = i + 1;
    mx[i][0] = r[i];
    for (int j = 1; i + (1 << j) <= n; j++)
      mx[i][j] = max(mx[i][j - 1], mx[i + (1 << (j - 1))][j - 1]);
  }
  for (int i = n - 1; i >= 0; i--) {
    f[i] = (f[i + 1] + f[r[i]]) % mod;
    ;
  }
  printf("%d", f[0]);
  return 0;
}
Problem p02758 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <stdio.h>
int n;
long long p = 998244353;
long long e = 1000000005;
long long x[200000];
long long d[200000];
long long h[200000];
long long m[200000];
long long dp[200001];
long long t[500];
long long y, l, r, lr;
long long rmq(long long ll, long long rr) {
  long long f = 0;
  long long i;
  i = ll;
  while (i % 400 && i <= rr) {
    if (f < m[i])
      f = m[i];
    i++;
  }
  i = rr;
  while ((i + 1) % 400 && i >= ll) {
    if (f < m[i])
      f = m[i];
    i--;
  }
  i = (ll + 399) / 400;
  while (i * 400 + 399 <= rr) {
    if (f < t[i])
      f = t[i];
  }
  return f;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", x + i, d + i);
    x[i] += e;
    h[i] = x[i] * e + d[i];
  }
  std::sort(h, h + n);
  for (int i = 0; i < n; i++) {
    d[i] = h[i] % e;
    x[i] = h[i] / e - e;
  }
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    y = x[i] + d[i];
    l = i;
    r = n;
    while (r - l > 1) {
      lr = (l + r) / 2;
      if (x[lr] >= y)
        r = lr;
      else
        l = lr;
    }
    r = rmq(i, l);
    if (r == 0)
      r = i;
    m[i] = r;
    if (t[i / 400] < r)
      t[i / 400] = r;
    dp[i] = dp[i + 1] + dp[r + 1];
    dp[i] %= p;
  }
  printf("%lld\n", dp[0]);
}

Fixed submission:
#include <algorithm>
#include <stdio.h>
int n;
long long p = 998244353;
long long e = 1000000005;
long long x[200000];
long long d[200000];
long long h[200000];
long long m[200000];
long long dp[200001];
long long t[500];
long long y, l, r, lr;
long long rmq(long long ll, long long rr) {
  long long f = 0;
  long long i;
  i = ll;
  while (i % 400 && i <= rr) {
    if (f < m[i])
      f = m[i];
    i++;
  }
  i = rr;
  while ((i + 1) % 400 && i >= ll) {
    if (f < m[i])
      f = m[i];
    i--;
  }
  i = (ll + 399) / 400;
  while (i * 400 + 399 <= rr) {
    if (f < t[i])
      f = t[i];
    i++;
  }
  return f;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", x + i, d + i);
    x[i] += e;
    h[i] = x[i] * e + d[i];
  }
  std::sort(h, h + n);
  for (int i = 0; i < n; i++) {
    d[i] = h[i] % e;
    x[i] = h[i] / e - e;
  }
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    y = x[i] + d[i];
    l = i;
    r = n;
    while (r - l > 1) {
      lr = (l + r) / 2;
      if (x[lr] >= y)
        r = lr;
      else
        l = lr;
    }
    r = rmq(i, l);
    if (r == 0)
      r = i;
    m[i] = r;
    if (t[i / 400] < r)
      t[i / 400] = r;
    dp[i] = dp[i + 1] + dp[r + 1];
    dp[i] %= p;
  }
  printf("%lld\n", dp[0]);
}
Problem p02759 (Python)

Buggy submission (status: Runtime Error):
#!/usr/bin/env python3


def main():
    N = map(int, open(0).read().split())
    print(-(-N // 2))


main()


Fixed submission:
#!/usr/bin/env python3


def main():
    N = int(input())
    print(-(-N // 2))


main()
Problem p02759 (Python)

Buggy submission (status: Runtime Error):
n = input()
paper = 0
if n % 2 == 0:
    paper = n / 2
else:
    paper = n / 2 + 1
print(paper)


Fixed submission:
n = int(input())
print((n + 1) // 2)
Problem p02759 (Python)

Buggy submission (status: Runtime Error):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

        a = int(sys.stdin.readline().rstrip())

    print(int(a // 2 if a % 2 == 0 else a // 2 + 1))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    a = int(sys.stdin.readline().rstrip())
    print(a // 2 if a % 2 == 0 else a // 2 + 1)


if __name__ == "__main__":
    main()
Problem p02759 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
  int N, M;
  bool f = true;
  cin >> N >> M;
  vector<int> s(M), c(M), ans(N);
  rep(i, M) {
    cin >> s.at(i) >> c.at(i);
    ans.at(s.at(i) - 1) = c.at(i);
  }
  rep(i, M) {
    rep(j, M) {
      if (s.at(i) == s.at(j) && c.at(i) != c.at(j)) {
        f = false;
        break;
      } else if (N != 1 && ans.at(0) == 0) {
        f = false;
        break;
      }
    }
    if (f == false) {
      break;
    }
  }
  if (f) {
    rep(i, N) { cout << ans.at(i); }
    cout << endl;
  } else {
    cout << "-1" << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  cout << (N + 1) / 2 << endl;
}
Problem p02759 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fr(i, a, b) for (int i = a; i < b; i++)
#define bfr(i, a, b) for (int i = a; i >= b; i--)
#define fio                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL), cout.tie(NULL);
#define tc                                                                     \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define mod 1000000007
#define all(vec) vec.begin(), vec.end()
#define ld long double

int main() {

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

  fio

      lli n;
  cin >> n;
  cout << (lli)(ceil(n / 2.000));

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fr(i, a, b) for (int i = a; i < b; i++)
#define bfr(i, a, b) for (int i = a; i >= b; i--)
#define fio                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL), cout.tie(NULL);
#define tc                                                                     \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define mod 1000000007
#define all(vec) vec.begin(), vec.end()
#define ld long double

int main() {

  fio

      lli n;
  cin >> n;
  cout << (lli)(ceil(n / 2.000));

  return 0;
}
Problem p02759 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>

int main() {
  int n;
  scanf("%d", n);
  printf("%d\n", n + 1 >> 1);
  return 0;
}


Fixed submission:
#include <cstdio>

int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", n + 1 >> 1);
  return 0;
}
Problem p02759 (C++)

Buggy submission (status: 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 P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int ans = (n + 1) / 2;
  return ans;
}

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 P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int ans = (n + 1) / 2;
  cout << ans << endl;
}
Problem p02759 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

typedef long long ll;

#define pb push_back
#define mp make_pair
#define rep(i, s, n) for (int i = s; i < n; i++)
#define repeq(i, s, n) for (int i = s; i <= n; i++)
#define MOD (int)10e9 + 7

template <typename T> void amax(T &a, T b) { a = a > b ? a : b; }
template <typename T> void amin(T &a, T b) { a = a < b ? a : b; }

using namespace std;

int n;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(nullptr);

#ifndef FLOSH
  freopen("helloin.txt", "r", stdin);
  freopen("helloout.txt", "w", stdout);
#endif

  int n;
  cin >> n;

  cout << ((n + 1) / 2) << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

typedef long long ll;

#define pb push_back
#define mp make_pair
#define rep(i, s, n) for (int i = s; i < n; i++)
#define repeq(i, s, n) for (int i = s; i <= n; i++)
#define MOD (int)10e9 + 7

template <typename T> void amax(T &a, T b) { a = a > b ? a : b; }
template <typename T> void amin(T &a, T b) { a = a < b ? a : b; }

using namespace std;

int n;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  cout << ((n + 1) / 2) << endl;
  return 0;
}
Problem p02760 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int marked[3][3];
int nums[3][3];

void mark(int num) {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j)
      marked[i][j] = (marked[i][j]) | (nums[i][j] == num);
  }
}

int main() {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j)
      scanf(" %d", &nums[i][j]);
  }
  int n;
  scanf(" %d", &n);
  while (n--) {
    int a;
    scanf(" %d", &a);
    mark(a);
  }
  bool yes = 0;
  for (int i = 0; i < 3 && !yes; ++i) {
    int sum = 0;
    for (int j = 0; j < 3; ++j)
      sum += marked[i][j];
    yes = (sum == 3);
  }
  for (int j = 0; j < 3 && !yes; ++j) {
    int sum = 0;
    for (int i = 0; i < 3; ++i)
      sum += marked[i][j];
    yes = (sum == 3);
  }
  int sum = 0;
  for (int i = 0; i < 3 && !yes; ++i)
    sum += marked[i][i];
  yes = yes | (sum == 3);
  sum = 0;
  for (int i = 0, j = 2; i > -1 && !yes; ++i, --j)
    sum += marked[i][j];
  yes = yes | (sum == 3);
  if (yes)
    puts("Yes");
  else
    puts("No");
}


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

int marked[3][3];
int nums[3][3];

void mark(int num) {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j)
      marked[i][j] = (marked[i][j]) | (nums[i][j] == num);
  }
}

int main() {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j)
      scanf(" %d", &nums[i][j]);
  }
  int n;
  scanf(" %d", &n);
  while (n--) {
    int a;
    scanf(" %d", &a);
    mark(a);
  }
  bool yes = 0;
  for (int i = 0; i < 3 && !yes; ++i) {
    int sum = 0;
    for (int j = 0; j < 3; ++j)
      sum += marked[i][j];
    yes = (sum == 3);
  }
  for (int j = 0; j < 3 && !yes; ++j) {
    int sum = 0;
    for (int i = 0; i < 3; ++i)
      sum += marked[i][j];
    yes = (sum == 3);
  }
  int sum = 0;
  for (int i = 0; i < 3 && !yes; ++i)
    sum += marked[i][i];
  yes = yes | (sum == 3);
  sum = 0;
  for (int i = 0, j = 2; i < 3 && !yes; ++i, --j)
    sum += marked[i][j];
  yes = yes | (sum == 3);
  if (yes)
    puts("Yes");
  else
    puts("No");
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      cin >> A[i][j];

  int M;
  cin >> M;
  for (int i = 0; i < M; ++i) {
    int a;
    cin >> a;
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 3; ++k)
        if (A[i][j] == a)
          A[i][j] = -1;
  }
  bool res = false;

  for (int i = 0; i < 3; ++i) {
    if (A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1)
      res = true;
    if (A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1)
      res = true;
  }
  if (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1)
    res = true;
  if (A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1)
    res = true;

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


Fixed submission:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      cin >> A[i][j];

  int M;
  cin >> M;
  for (int i = 0; i < M; ++i) {
    int a;
    cin >> a;
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 3; ++k)
        if (A[j][k] == a)
          A[j][k] = -1;
  }
  bool res = false;

  for (int i = 0; i < 3; ++i) {
    if (A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1)
      res = true;
    if (A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1)
      res = true;
  }
  if (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1)
    res = true;
  if (A[0][2] == -1 && A[1][1] == -1 && A[2][0] == -1)
    res = true;

  if (res)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int A[2][2];
  int B[2][2] = {0};
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  int b[N];
  int aa, bb, cc;
  for (int k = 0; k < N; ++k) {
    aa = k;
    cin >> b[k];
    for (int ii = 0; ii < 3; ++ii) {
      bb = ii;
      for (int jj = 0; jj < 3; ++jj) {
        cc = jj;
        if (A[bb][cc] == b[aa])
          B[bb][cc] = 1;
      }
    }
  }
  bool flag = false;
  int d;
  for (int kk = 0; kk < 3; ++kk) {
    d = kk;
    if (B[0][d] == 1 && B[1][d] == 1 && B[2][d] == 1)
      flag = true;
    if (B[d][0] == 1 && B[d][1] == 1 && B[d][2] == 1)
      flag = true;
  }
  if (B[0][0] == 1 && B[1][1] == 1 && B[2][2] == 1)
    flag = true;
  if (B[0][2] == 1 && B[1][1] == 1 && B[2][0] == 1)
    flag = true;
  if (flag)
    cout << "Yes";
  if (!flag)
    cout << "No";
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int A[3][3];
  int B[3][3] = {};
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  int b[N];
  int aa, bb, cc;
  for (int k = 0; k < N; ++k) {
    aa = k;
    cin >> b[k];
    for (int ii = 0; ii < 3; ++ii) {
      bb = ii;
      for (int jj = 0; jj < 3; ++jj) {
        cc = jj;
        if (A[bb][cc] == b[aa])
          B[bb][cc] = 1;
      }
    }
  }
  bool flag = false;
  int d;
  for (int kk = 0; kk < 3; ++kk) {
    d = kk;
    if (B[0][d] == 1 && B[1][d] == 1 && B[2][d] == 1)
      flag = true;
    if (B[d][0] == 1 && B[d][1] == 1 && B[d][2] == 1)
      flag = true;
  }
  if (B[0][0] == 1 && B[1][1] == 1 && B[2][2] == 1)
    flag = true;
  if (B[0][2] == 1 && B[1][1] == 1 && B[2][0] == 1)
    flag = true;
  if (flag)
    cout << "Yes";
  if (!flag)
    cout << "No";
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  vector<vector<int>> bingo;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> bingo.at(i).at(j);
    }
  }

  int n;
  cin >> n;

  int b;
  rep(i, n) {
    cin >> b;

    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (bingo.at(j).at(k) == b) {
          bingo.at(j).at(k) = 0;
        }
      }
    }
  }

  if ((bingo.at(0).at(0) == 0 && bingo.at(0).at(1) == 0 &&
       bingo.at(0).at(2) == 0) ||
      (bingo.at(1).at(0) == 0 && bingo.at(1).at(1) == 0 &&
       bingo.at(1).at(2) == 0) ||
      (bingo.at(2).at(0) == 0 && bingo.at(2).at(1) == 0 &&
       bingo.at(2).at(2) == 0) ||
      (bingo.at(0).at(0) == 0 && bingo.at(1).at(0) == 0 &&
       bingo.at(2).at(0) == 0) ||
      (bingo.at(0).at(1) == 0 && bingo.at(1).at(1) == 0 &&
       bingo.at(2).at(1) == 0) ||
      (bingo.at(0).at(2) == 0 && bingo.at(1).at(2) == 0 &&
       bingo.at(2).at(2) == 0) ||
      (bingo.at(0).at(0) == 0 && bingo.at(1).at(1) == 0 &&
       bingo.at(2).at(2) == 0) ||
      (bingo.at(2).at(0) == 0 && bingo.at(1).at(1) == 0 &&
       bingo.at(0).at(2) == 0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  vector<vector<int>> bingo(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> bingo.at(i).at(j);
    }
  }

  int n;
  cin >> n;

  int b;
  rep(i, n) {
    cin >> b;

    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (bingo.at(j).at(k) == b) {
          bingo.at(j).at(k) = 0;
        }
      }
    }
  }

  if ((bingo.at(0).at(0) == 0 && bingo.at(0).at(1) == 0 &&
       bingo.at(0).at(2) == 0) ||
      (bingo.at(1).at(0) == 0 && bingo.at(1).at(1) == 0 &&
       bingo.at(1).at(2) == 0) ||
      (bingo.at(2).at(0) == 0 && bingo.at(2).at(1) == 0 &&
       bingo.at(2).at(2) == 0) ||
      (bingo.at(0).at(0) == 0 && bingo.at(1).at(0) == 0 &&
       bingo.at(2).at(0) == 0) ||
      (bingo.at(0).at(1) == 0 && bingo.at(1).at(1) == 0 &&
       bingo.at(2).at(1) == 0) ||
      (bingo.at(0).at(2) == 0 && bingo.at(1).at(2) == 0 &&
       bingo.at(2).at(2) == 0) ||
      (bingo.at(0).at(0) == 0 && bingo.at(1).at(1) == 0 &&
       bingo.at(2).at(2) == 0) ||
      (bingo.at(2).at(0) == 0 && bingo.at(1).at(1) == 0 &&
       bingo.at(0).at(2) == 0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<int> vec(8);
  int N;

  for (int i = 0; i < 9; i++) {
    cin >> vec.at(i);
  }
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < 9; j++) {
      if (x == vec.at(j)) {
        vec.at(j) = 'a';
      }
    }
  }
  if (vec.at(0) == 'a' && vec.at(1) == 'a' && vec.at(2) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(3) == 'a' && vec.at(4) == 'a' && vec.at(5) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(6) == 'a' && vec.at(7) == 'a' && vec.at(8) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(0) == 'a' && vec.at(3) == 'a' && vec.at(6) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(1) == 'a' && vec.at(4) == 'a' && vec.at(7) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(2) == 'a' && vec.at(5) == 'a' && vec.at(8) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(0) == 'a' && vec.at(4) == 'a' && vec.at(8) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(2) == 'a' && vec.at(4) == 'a' && vec.at(6) == 'a') {
    cout << "Yes" << endl;
  }

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


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

int main() {
  vector<int> vec(9);
  int N;

  for (int i = 0; i < 9; i++) {
    cin >> vec.at(i);
  }
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < 9; j++) {
      if (x == vec.at(j)) {
        vec.at(j) = 'a';
      }
    }
  }
  if (vec.at(0) == 'a' && vec.at(1) == 'a' && vec.at(2) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(3) == 'a' && vec.at(4) == 'a' && vec.at(5) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(6) == 'a' && vec.at(7) == 'a' && vec.at(8) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(0) == 'a' && vec.at(3) == 'a' && vec.at(6) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(1) == 'a' && vec.at(4) == 'a' && vec.at(7) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(2) == 'a' && vec.at(5) == 'a' && vec.at(8) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(0) == 'a' && vec.at(4) == 'a' && vec.at(8) == 'a') {
    cout << "Yes" << endl;
  }

  else if (vec.at(2) == 'a' && vec.at(4) == 'a' && vec.at(6) == 'a') {
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<vector<int>> a(3, vector<int>(3, 0));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a.at(i).at(j);
    }
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    for (int j = 0; j < 3; j++) {
      for (int l = 0; l < 3; l++) {
        if (b == a.at(i).at(j)) {
          a.at(i).at(j) = 0;
        }
      }
    }
  }
  string k = "No";
  for (int i = 0; i < 3; i++) {
    if (a.at(i).at(0) == 0 && a.at(i).at(1) == 0 && a.at(i).at(2) == 0) {
      k = "Yes";
    } else if (a.at(0).at(i) == 0 && a.at(1).at(i) == 0 && a.at(2).at(i) == 0) {
      k = "Yes";
    }
  }
  if (a.at(0).at(0) == 0 && a.at(1).at(1) == 0 && a.at(2).at(2) == 0) {
    k = "Yes";
  }
  if (a.at(2).at(0) == 0 && a.at(1).at(1) == 0 && a.at(0).at(2) == 0) {
    k = "Yes";
  }
  cout << k << endl;
  return 0;
}


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

int main() {
  vector<vector<int>> a(3, vector<int>(3, 0));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a.at(i).at(j);
    }
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    for (int j = 0; j < 3; j++) {
      for (int l = 0; l < 3; l++) {
        if (b == a.at(j).at(l)) {
          a.at(j).at(l) = 0;
        }
      }
    }
  }
  string k = "No";
  for (int i = 0; i < 3; i++) {
    if (a.at(i).at(0) == 0 && a.at(i).at(1) == 0 && a.at(i).at(2) == 0) {
      k = "Yes";
    } else if (a.at(0).at(i) == 0 && a.at(1).at(i) == 0 && a.at(2).at(i) == 0) {
      k = "Yes";
    }
  }
  if (a.at(0).at(0) == 0 && a.at(1).at(1) == 0 && a.at(2).at(2) == 0) {
    k = "Yes";
  }
  if (a.at(2).at(0) == 0 && a.at(1).at(1) == 0 && a.at(0).at(2) == 0) {
    k = "Yes";
  }
  cout << k << endl;
  return 0;
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {

  int a[3][3], N, b[N];

  cin >> a[0][0] >> a[0][1] >> a[0][2];
  cin >> a[1][0] >> a[1][1] >> a[1][2];
  cin >> a[2][0] >> a[2][1] >> a[2][2];
  cin >> N;

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

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (b[i] == a[j][k]) {
          a[i][k] = 0;
        }
      }
    }
  }

  if (a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0)
    cout << "Yes"
         << "\n";
  else if (a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0)
    cout << "Yes"
         << "\n";
  else if (a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0)
    cout << "Yes"
         << "\n";
  else if (a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0)
    cout << "Yes"
         << "\n";
  else if (a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0)
    cout << "Yes"
         << "\n";
  else if (a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0)
    cout << "Yes"
         << "\n";
  else if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
    cout << "Yes"
         << "\n";
  else if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)
    cout << "Yes"
         << "\n";
  else
    cout << "No"
         << "\n";
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {

  int a[3][3], N, b[N];

  cin >> a[0][0] >> a[0][1] >> a[0][2];
  cin >> a[1][0] >> a[1][1] >> a[1][2];
  cin >> a[2][0] >> a[2][1] >> a[2][2];
  cin >> N;

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

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (b[i] == a[j][k]) {
          a[j][k] = 0;
        }
      }
    }
  }

  if (a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0)
    cout << "Yes"
         << "\n";
  else if (a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0)
    cout << "Yes"
         << "\n";
  else if (a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0)
    cout << "Yes"
         << "\n";
  else if (a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0)
    cout << "Yes"
         << "\n";
  else if (a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0)
    cout << "Yes"
         << "\n";
  else if (a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0)
    cout << "Yes"
         << "\n";
  else if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
    cout << "Yes"
         << "\n";
  else if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)
    cout << "Yes"
         << "\n";
  else
    cout << "No"
         << "\n";
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main(void) {
  int A[3][3], B[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
      B[i][j] = 0;
    }
  }
  int N;
  cin >> N;
  for (int t = 0; t < N; t++) {
    int b;
    cin >> b;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 3; j++) {
        if (A[i][j] == b) {
          B[i][j] = 1;
        }
      }
    }
  }
  if (B[0][0] == 1 && B[1][0] == 1 && B[2][0] == 1)
    cout << "Yes";
  else if (B[0][1] == 1 && B[1][1] == 1 && B[2][1] == 1)
    cout << "Yes";
  else if (B[0][2] == 1 && B[1][2] == 1 && B[2][2] == 1)
    cout << "Yes";
  else if (B[0][0] == 1 && B[0][1] == 1 && B[0][2] == 1)
    cout << "Yes";
  else if (B[1][0] == 1 && B[1][1] == 1 && B[1][2] == 1)
    cout << "Yes";
  else if (B[2][0] == 1 && B[2][1] == 1 && B[2][2] == 1)
    cout << "Yes";
  else if (B[0][0] == 1 && B[1][1] == 1 && B[2][2] == 1)
    cout << "Yes";
  else if (B[2][0] == 1 && B[1][1] == 1 && B[0][2] == 1)
    cout << "Yes";
  else
    cout << "No";

  return 0;
}

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

int main(void) {
  int A[3][3], B[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
      B[i][j] = 0;
    }
  }
  int N;
  cin >> N;
  for (int t = 0; t < N; t++) {
    int b;
    cin >> b;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (A[i][j] == b) {
          B[i][j] = 1;
        }
      }
    }
  }
  if (B[0][0] == 1 && B[1][0] == 1 && B[2][0] == 1)
    cout << "Yes";
  else if (B[0][1] == 1 && B[1][1] == 1 && B[2][1] == 1)
    cout << "Yes";
  else if (B[0][2] == 1 && B[1][2] == 1 && B[2][2] == 1)
    cout << "Yes";
  else if (B[0][0] == 1 && B[0][1] == 1 && B[0][2] == 1)
    cout << "Yes";
  else if (B[1][0] == 1 && B[1][1] == 1 && B[1][2] == 1)
    cout << "Yes";
  else if (B[2][0] == 1 && B[2][1] == 1 && B[2][2] == 1)
    cout << "Yes";
  else if (B[0][0] == 1 && B[1][1] == 1 && B[2][2] == 1)
    cout << "Yes";
  else if (B[2][0] == 1 && B[1][1] == 1 && B[0][2] == 1)
    cout << "Yes";
  else
    cout << "No";

  return 0;
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  vector<vector<bool>> B(3, vector<bool>(3, false));
  for (vector<int> &i : A)
    for (int &j : i)
      cin >> j;
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int j;
    cin >> j;
    for (int k = 0; k < 3; k++)
      for (int l = 0; l < 3; l++)
        if (A[k][l] == j)
          B[k][l] = true;
  }
  for (int i = 0; i < N; i++) {
    if (B[i][0] && B[i][1] && B[i][2]) {
      cout << "Yes" << endl;
      return 0;
    }
    if (B[0][i] && B[1][i] && B[2][i]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if ((B[0][0] && B[1][1] && B[2][2]) || (B[0][2] && B[1][1] && B[2][0])) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}

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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  vector<vector<bool>> B(3, vector<bool>(3, false));
  for (vector<int> &i : A)
    for (int &j : i)
      cin >> j;
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int j;
    cin >> j;
    for (int k = 0; k < 3; k++)
      for (int l = 0; l < 3; l++)
        if (A[k][l] == j)
          B[k][l] = true;
  }
  for (int i = 0; i < 3; i++) {
    if (B[i][0] && B[i][1] && B[i][2]) {
      cout << "Yes" << endl;
      return 0;
    }
    if (B[0][i] && B[1][i] && B[2][i]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if ((B[0][0] && B[1][1] && B[2][2]) || (B[0][2] && B[1][1] && B[2][0])) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  int b[N];
  for (int k = 0; k < N; k++) {
    cin >> b[k];
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (b[k] == A[i][j]) {
          A[i][j] = 0;
        }
      }
    }
  }
  bool can = false;
  for (int i = 0; i < 3; i++) {
    if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) {
      can = true;
    }
    if (A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0) {
      can = true;
    }
    if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) {
      can = true;
    }
    if (A[1][3] == 0 && A[2][2] == 0 && A[3][1] == 0) {
      can = true;
    }
  }
  if (can) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}

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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  int b[N];
  for (int k = 0; k < N; k++) {
    cin >> b[k];
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (b[k] == A[i][j]) {
          A[i][j] = 0;
        }
      }
    }
  }
  bool can = false;
  for (int i = 0; i < 3; i++) {
    if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) {
      can = true;
    }
    if (A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0) {
      can = true;
    }
    if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) {
      can = true;
    }
    if (A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) {
      can = true;
    }
  }
  if (can) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {

  vector<vector<int>> a(3, vector<int>(3));
  vector<vector<int>> A(3, vector<int>(3));

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {

      cin >> a.at(i).at(j);
    }
  }

  int N;
  cin >> N;
  vector<int> b(N);

  for (int k = 0; k < N; k++) {
    cin >> b.at(k);
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (a.at(i).at(j) == b.at(k))
          A.at(i).at(j) = 1;
      }
    }
  }
  bool tf = false;
  int sum = 0;

  for (int i = 0; i < 3; i++) {
    sum = A.at(i).at(0) + A.at(i).at(1) + A.at(i).at(2);
    if (sum == 3)
      tf = true;
  }

  sum = 0;
  for (int i = 0; i < 3; i++) {
    sum = A.at(0).at(i) + A.at(1).at(i) + A.at(3).at(i);
    if (sum == 3)
      tf = true;
  }

  sum = 0;
  for (int i = 0; i < 3; i++)
    sum += A.at(i).at(i);
  if (sum == 3)
    tf = true;

  sum = 0;
  sum = A.at(0).at(2) + A.at(1).at(1) + A.at(2).at(0);
  if (sum == 3)
    tf = true;

  if (tf == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main() {

  vector<vector<int>> a(3, vector<int>(3));
  vector<vector<int>> A(3, vector<int>(3));

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {

      cin >> a.at(i).at(j);
    }
  }

  int N;
  cin >> N;
  vector<int> b(N);

  for (int k = 0; k < N; k++) {
    cin >> b.at(k);
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (a.at(i).at(j) == b.at(k))
          A.at(i).at(j) = 1;
      }
    }
  }
  bool tf = false;
  int sum = 0;

  for (int i = 0; i < 3; i++) {
    sum = A.at(i).at(0) + A.at(i).at(1) + A.at(i).at(2);
    if (sum == 3)
      tf = true;
  }

  sum = 0;
  for (int i = 0; i < 3; i++) {
    sum = A.at(0).at(i) + A.at(1).at(i) + A.at(2).at(i);
    if (sum == 3)
      tf = true;
  }

  sum = 0;
  for (int i = 0; i < 3; i++)
    sum += A.at(i).at(i);
  if (sum == 3)
    tf = true;

  sum = 0;
  sum = A.at(0).at(2) + A.at(1).at(1) + A.at(2).at(0);
  if (sum == 3)
    tf = true;

  if (tf == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A[3][3];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> A[i][j];
    }
  }

  vector<vector<bool>> ok(3, vector<bool>(3, false));

  int N;
  cin >> N;
  for (int k = 0; k < N; ++k) {
    int b;
    cin >> b;

    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (A[i][j] == b) {
          ok[i][j] = true;
        }
      }
    }
  }

  bool ans = false;
  for (int i = 0; i < N; ++i) {
    ans = ans || (ok[i][0] && ok[i][1] && ok[i][2]) ||
          (ok[0][i] && ok[1][i] && ok[2][i]);
  }

  ans = ans || (ok[0][0] && ok[1][1] && ok[2][2]) ||
        (ok[0][2] && ok[1][1] && ok[2][0]);

  cout << (ans ? "Yes" : "No") << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A[3][3];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> A[i][j];
    }
  }

  vector<vector<bool>> ok(3, vector<bool>(3, false));

  int N;
  cin >> N;
  for (int k = 0; k < N; ++k) {
    int b;
    cin >> b;

    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (A[i][j] == b) {
          ok[i][j] = true;
        }
      }
    }
  }

  bool ans = false;
  for (int i = 0; i < 3; ++i) {
    ans = ans || (ok[i][0] && ok[i][1] && ok[i][2]) ||
          (ok[0][i] && ok[1][i] && ok[2][i]);
  }

  ans = ans || (ok[0][0] && ok[1][1] && ok[2][2]) ||
        (ok[0][2] && ok[1][1] && ok[2][0]);

  cout << (ans ? "Yes" : "No") << endl;
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<int> s(9);
  for (int i = 0; i < 9; i++) {

    cin >> s.at(i);
  }
  int n;
  cin >> n;
  vector<int> m(n);
  for (int i = 0; i < n; i++) {
    cin >> m.at(i);
    for (int j = 0; j < 9; j++) {
      if (m.at(i) == s.at(j))
        s.at(i) = 0;
    }
  }
  bool e = false;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == 0 && s.at(i + 3) == 0 && s.at(i + 6) == 0) {
      e = true;
      break;
    }
  }
  if (s.at(0) == 0 && s.at(1) == 0 && s.at(2) == 0) {
    e = true;
  }
  if (s.at(3) == 0 && s.at(4) == 0 && s.at(5) == 0) {
    e = true;
  }
  if (s.at(6) == 0 && s.at(7) == 0 && s.at(8) == 0) {
    e = true;
  }
  if (s.at(0) == 0 && s.at(4) == 0 && s.at(8) == 0) {
    e = true;
  }
  if (s.at(2) == 0 && s.at(4) == 0 && s.at(6) == 0) {
    e = true;
  }
  if (e == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
  vector<int> s(9);
  for (int i = 0; i < 9; i++) {

    cin >> s.at(i);
  }
  int n;
  cin >> n;
  vector<int> m(n);
  for (int i = 0; i < n; i++) {
    cin >> m.at(i);
    for (int j = 0; j < 9; j++) {
      if (m.at(i) == s.at(j))
        s.at(j) = 0;
    }
  }
  bool e = false;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == 0 && s.at(i + 3) == 0 && s.at(i + 6) == 0) {
      e = true;
      break;
    }
  }
  if (s.at(0) == 0 && s.at(1) == 0 && s.at(2) == 0) {
    e = true;
  }
  if (s.at(3) == 0 && s.at(4) == 0 && s.at(5) == 0) {
    e = true;
  }
  if (s.at(6) == 0 && s.at(7) == 0 && s.at(8) == 0) {
    e = true;
  }
  if (s.at(0) == 0 && s.at(4) == 0 && s.at(8) == 0) {
    e = true;
  }
  if (s.at(2) == 0 && s.at(4) == 0 && s.at(6) == 0) {
    e = true;
  }
  if (e == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p02760 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<int> A(9);
  for (int i = 0; i < 9; i++)
    cin >> A.at(i);
  int N;
  cin >> N;
  vector<int> B(N);
  for (int i = 0; i < N; i++)
    cin >> B.at(i);

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A.at(i) == B.at(j))
        A.at(i) = 0;
    }
  }

  if (A.at(0) + A.at(1) + A.at(2) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(3) + A.at(4) + A.at(5) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(6) + A.at(7) + A.at(8) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(0) + A.at(3) + A.at(6) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(1) + A.at(4) + A.at(7) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(2) + A.at(5) + A.at(8) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(0) + A.at(4) + A.at(8) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(2) + A.at(4) + A.at(6) == 0)
    return cout << "Yes"
                << "\n",
           0;

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

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

int main() {
  vector<int> A(9);
  for (int i = 0; i < 9; i++)
    cin >> A.at(i);
  int N;
  cin >> N;
  vector<int> B(N);
  for (int i = 0; i < N; i++)
    cin >> B.at(i);

  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < N; j++) {
      if (A.at(i) == B.at(j))
        A.at(i) = 0;
    }
  }

  if (A.at(0) + A.at(1) + A.at(2) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(3) + A.at(4) + A.at(5) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(6) + A.at(7) + A.at(8) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(0) + A.at(3) + A.at(6) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(1) + A.at(4) + A.at(7) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(2) + A.at(5) + A.at(8) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(0) + A.at(4) + A.at(8) == 0)
    return cout << "Yes"
                << "\n",
           0;
  if (A.at(2) + A.at(4) + A.at(6) == 0)
    return cout << "Yes"
                << "\n",
           0;

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