#include <iostream>                                                                                                                                                                                         
#include <algorithm>                                                                                                                                                                                        
#include <cstring>                                                                                                                                                                                          
#include <vector>                                                                                                                                                                                           
using namespace std;                                                                                                                                                                                        
                                                                                                                                                                                                            
typedef long long ll;                                                                                                                                                                                       
                                                                                                                                                                                                            
int main()                                                                                                                                                                                                  
{                                                                                                                                                                                                           
    ll N;                                                                                                                                                                                                   
    cin >> N;                                                                                                                                                                                               
                                                                                                                                                                                                            
    ll sum = 0;                                                                                                                                                                                             
    for (int i = 0; i<N; ++i) {                                                                                                                                                                             
        ll l, r;                                                                                                                                                                                            
        cin >> l >> r;                                                                                                                                                                                      
        sum +=  r - l + 1;                                                                                                                                                                                  
    }                                                                                                                                                                                                       
    cout << sum << endl;                                                                                                                                                                                    
}   

Measured memory_bytes: 256