<s>[INST] Problem Statement

Write a C++ function called `countNegatives` that takes a 2D grid (a 2D vector of integers) as input and returns the number of negative integers in the grid.

Constraints

 The input grid will always be non-empty.
 The grid will always have at least one row and one column.
 All elements in the grid will be integers.
 Negative numbers will always be negative (i.e., no zero or positive values will be passed as negative inputs).

Example Input/Output

 Input: grid = [[3,-1,0],[1,-4,-4],[-1,-2,0]]
 Output: 4

Hint: You can use a simple loop to iterate over each element in the grid.

Additional Note: You should not use any standard library functions that operate on the entire grid at once, such as `std::count_if`. You must use a loop to iterate over each element in the grid.

Here is the code you can use as a starting point:
```cpp
#include <vector>
#include <iostream>

int countNegatives(std::vector<std::vector<int>>& grid) {
    // TODO: implement the function
}

int main() {
    std::vector<std::vector<int>> grid = {{3,-1,0},{1,-4,-4},{-1,-2,0}};
    int result = countNegatives(grid);
    std::cout << "Number of negative integers: " << result << std::endl;
    return 0;
}
```
Grading Criteria

 Correctness: Does the function correctly count the number of negative integers in the grid?[/INST]