George has recently entered the bsucp (berland State University for cool programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory.
George and Alex want to live in the same room. The dormitory hasNRooms in total. At the momentI-Th room hasPIPeople living in it and the room can accommodateQIPeople in total (PI? ≤?QI). Your task is to count how many rooms has free place for both George and Alex.
Input
The first line contains a single integerN(1? ≤?N? ≤? 100)-the number of rooms.
TheI-Th of the nextNLines contains two integersPIAndQI(0? ≤?PI? ≤?QI? ≤? 100)-the number of people who already live inI-Th room and the room's capacity.
Output
Print a single integer-the number of rooms where George and Alex can move in.
Sample test (s) Input
31 12 23 3
Output
0
Input
31 100 1010 10
Output
2. I have n dormitories, I can have a total of Qi and PI, and I can have two more dormitories. My thoughts are: directly calculate the big questions.#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main() {int n;scanf("%d", &n);int p, q, ans = 0;for (int i = 0; i < n; i++) {scanf("%d%d", &q, &p);if (p - q >= 2)ans++;}printf("%d\n", ans);return 0;}
Codeforces round #267 (Div. 2) A. George and accommodation