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

#include <bits/stdc++.h>

using namespace std;
/*---------------------SAUGATA KUNDU---------------------------*/

#define int long long int
#define INF (int)1e9 + 5
#define MoD (int)1e9 + 7
#define debug(a) cerr << '[' << a << ']' << '\\n'

#define clear(a) memset(a, 0, sizeof(a))
#define fo(i, a, b) for (int i = a; i < b; i++)
#define fos(i, b) for (int i = 0; i < b; i++)
#define foe(i, a) for (auto &i : a)
#define re(i, a, b) for (int i = b; i > a; i--)
#define pb push_back
#define all(c) c.begin(), c.end()
#define sz(x) (int)(x).size()
#define Fast                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0)
// data_structures
#define vt vector
#define que queue
#define sta stack
#define pque priority_queue
#define dque deque

#define point(pt) vt<int>::iterator pt
template <typename T> void read(vt<T> &a) { fos(i, sz(a)) cin >> a[i]; }

#define endl '\\n'
template <typename T> void write(vt<T> a) {
  fos(i, sz(a)) cout << a[i] << ' ';
  cout << endl;
}
int primes[] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31, 37,
                41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89};
string alpha = "abcdefghijklmnopqrstuvwxyz";
void solve() {
  int n, a, b, ans = 0;
  pque<int> nn;
  nn.push(0);

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a == b)
      ans++;
    else {
      nn.push(ans);
      ans = 0;
    }
  }
  if (ans)
    nn.push(ans);

  cout << ((nn.top() >= 3) ? "Yes" : "No") << endl;
} /*5
 1 1
 2 2
 3 4
 5 5
 6 6*/

int32_t main() {
  Fast;

  int t = 1;
  for (int i = 1; i <= t; ++i) {
    solve();
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
/*---------------------SAUGATA KUNDU---------------------------*/

#define int long long int
#define INF (int)1e9 + 5
#define MoD (int)1e9 + 7
#define debug(a) cerr << '[' << a << ']' << '\\n'

#define clear(a) memset(a, 0, sizeof(a))
#define fo(i, a, b) for (int i = a; i < b; i++)
#define fos(i, b) for (int i = 0; i < b; i++)
#define foe(i, a) for (auto &i : a)
#define re(i, a, b) for (int i = b; i > a; i--)
#define pb push_back
#define all(c) c.begin(), c.end()
#define sz(x) (int)(x).size()
#define Fast                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0)
// data_structures
#define vt vector
#define que queue
#define sta stack
#define pque priority_queue
#define dque deque

#define point(pt) vt<int>::iterator pt
template <typename T> void read(vt<T> &a) { fos(i, sz(a)) cin >> a[i]; }

#define endl '\\n'
template <typename T> void write(vt<T> a) {
  fos(i, sz(a)) cout << a[i] << ' ';
  cout << endl;
}
int primes[] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31, 37,
                41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89};
string alpha = "abcdefghijklmnopqrstuvwxyz";
void solve() {
  int n, a, b, ans = 0;
  pque<int> nn;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a == b)
      ans++;
    else {
      nn.push(ans);
      ans = 0;
    }
  }

  cout << ((nn.top() >= 3) ? "Yes" : "No") << endl;
} /*5
 1 1
 2 2
 3 4
 5 5
 6 6*/

int32_t main() {
  Fast;

  int t = 1;
  for (int i = 1; i <= t; ++i) {
    solve();
  }
}