Here's the plan:
Read (number of rooms).
Initialize count = 0.
For each of rooms, read occupancy and capacity.
If capacity - occupancy >= 2, increment count.
Print count. This is the filtering pattern. You stream items and count how many pass your test. Don't store items or remember decisions. Just maintain a running count. Each room passes or fails, update counter so. Notice you process data as you read it. Memory stays constant regardless of . Check 10 rooms or 100000 rooms, you only need one counter.