I had thought that the following code would append an element to row i of the 2D triangle vector: triangle[i].push_back(v), but this seems to be where the error lies. Any help would be much appreciated.
At line 15, triangle is initialized as an empty vector-of-vectors. It has 0 elements.
Accessing triangle[0] is undefined behavior. First, in your outer loop, do triangle.push_back(vector<int>(i+1))