Getting runtime error

Hi, I tried solving Forest Gathering Practice Problem in Jump from 2* to 3* - CodeChef. But I am getting runtime error for subtask 2 and can’t figure out why.

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

long long func(vector<vector<int>>& trees, int h, int mid){
    long long sum = 0;
    for(auto tree : trees){
        if(tree[0] + (long long)mid * tree[1] >= h){
            sum += tree[0] + (long long)mid * tree[1];
        }
    }
    return sum;
}


int main() {
	// your code goes here
	int n, w, h;
	cin>>n>>w>>h;
	vector<vector<int>> trees(n);
	int hi = -1;
	for(int i =0;i<n;i++){
	    int x,y;
	    cin>>x>>y;
	    trees[i].push_back(x);
	    trees[i].push_back(y);
	    hi = max(hi, (h-x+1)/y);
	}
	int lo = 0;
	long long ans;
	while (lo <= hi) {
    int mid = lo + (hi - lo) / 2;
    long long total_height = func(trees, h, mid);

    if (total_height >= (long long)w) {
        ans = mid;
        hi = mid - 1;
    } else {
        lo = mid + 1;
    }
}
	cout<<ans;
	return 0;
}

Also for such errors, what do I look to debug them?