https://www.spoj.com/problems/ACTIV/

My code produces SIGSEGV runtime error. Can someone help me find the error?

@ssjgz @galencolin @everule1

```
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define all(x) begin(x), end(x)
const int MOD = 1e8;
int bsearch(vector<pii> &t, int st, int end, int x) {
int ind = -1;
while(st <= end) {
int mid = (st + end) / 2;
if(t[mid].ss <= x) {
ind = mid;
st = mid + 1;
}
else {
end = mid - 1;
}
}
return ind;
}
int main() {
int n;
while(cin >> n) {
if(n == -1) {
break;
}
vector<pii> t;
for(int i = 0; i < n; ++i) {
int x, y;
cin >> x >> y;
t.pb({x, y});
}
sort(all(t), [](pii x, pii y) {
if( x.ss < y.ss) {
return true;
}
return (x.ss == y.ss && x.ff <= y.ff);
});
vector<ll> dp(n, 1);
dp[1] = 1;
for(int i = 1; i < n; ++i) {
int ind = bsearch(t, 0, i -1, t[i].ff);
if(ind != -1) {
dp[i] = (dp[i] * dp[ind] + dp[i]) % MOD;
}
dp[i] += dp[i - 1];
dp[i] %= MOD;
}
string fin = to_string(dp[n - 1]);
fin = string(8 - fin.size(), '0') + fin;
cout << fin << "\n";
}
return 0;
}
```