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

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
#define fi first
#define se second

int n;
int tb[7] = {0, 30, 60, 90, 120, 150, 180};
int rb[6] = {0, 100, 200, 300, 400, 500};

int main() {
  cin >> n;
  REP(i, n) {
    vector<int> ans, rr, tt;
    int r, t;
    cin >> r >> t;
    REP(j, 6) {
      if (rb[j] == r) {
        rr.push_back(j);
      } else if (j != 6 - 1) {
        if (rb[j] < r && rb[j + 1] > r) {
          rr.push_back(j);
          rr.push_back(j + 1);
        }
      }
    }
    REP(j, 7) {
      if (tb[j] == t) {
        tt.push_back(j);
      } else if (j != 7 - 1) {
        if (tb[j] < t && tb[j + 1] > t) {
          tt.push_back(j);
          tt.push_back(j + 1);
        }
      }
    }
    REP(j, rr.size()) {
      REP(k, tt.size()) { ans.push_back(rr[j] + tt[k] * 5); }
    }
    sort(ALL(ans));
    REP(j, ans.size()) {
      if (j == 0)
        cout << ans[j];
      else
        cout << " " << ans[j];
    }
    cout << endl;
  }
}

Error: WA

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
#define fi first
#define se second

int n;
int tb[7] = {0, 30, 60, 90, 120, 150, 180};
int rb[6] = {0, 100, 200, 300, 400, 500};

int main() {
  cin >> n;
  REP(i, n) {
    vector<int> ans, rr, tt;
    int r, t;
    cin >> r >> t;
    REP(j, 7) {
      if (rb[j] == r) {
        rr.push_back(j);
      } else if (j != 7 - 1) {
        if (rb[j] < r && rb[j + 1] > r) {
          rr.push_back(j);
          rr.push_back(j + 1);
        }
      }
    }
    // REP(j, rr.size()){
    //	cout << rr[j] << endl;
    // }
    REP(j, 6) {
      if (tb[j] == t) {
        tt.push_back(j);
      } else if (j != 6 - 1) {
        if (tb[j] < t && tb[j + 1] > t) {
          tt.push_back(j);
          tt.push_back(j + 1);
        }
      }
    }
    // REP(j, tt.size()){
    //	cout << tt[j] << endl;
    // }
    REP(j, rr.size()) {
      REP(k, tt.size()) { ans.push_back(rr[j] + tt[k] * 5); }
    }
    sort(ALL(ans));
    REP(j, ans.size()) { cout << ans[j] << " "; }
    cout << endl;
  }
}