stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

using namespace std;

#define MOD 1000000007

#define MAX 3030

void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}

int n,m,ans,f[MAX][MAX][2];

int main()

{

	scanf("%d%d",&n,&m);f[0][0][1]=1;

	for(int i=1;i<=n;++i)f[0][i][0]=1;

	for(int i=1;i<=m;++i)

		for(int j=0;j<=n;++j)

			for(int k=0;k<=1;++k)

			{

				if(j)add(f[i][j][k|(j==1)],f[i-1][j][k]),add(f[i][j-1][k|(j==1)],f[i-1][j][k]);

				if(n-j)add(f[i][j+1][k],f[i-1][j][k]),add(f[i][j][k],f[i-1][j][k]);

			}

	for(int i=0;i<=n;++i)add(ans,f[m][i][1]);

	printf("%d\n",ans);return 0;

}


// Optimized solution to the same problem (faster):
#include<cmath>

#include<cstdio>

#include<cstring>

#include<algorithm>

#define gt getchar()

#define ll long long

#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)

typedef std::pair<int,int> P;

#define mk std::make_pair

#define fr first

#define sc second

inline int in()

{

	int k=0;char ch=gt;bool p=1;

	while(ch<'-')ch=gt;if(ch=='-')ch=gt,p=0;

	while(ch>'-')k=k*10+ch-'0',ch=gt;

	return p?k:-k;

}

const int N=3005,YL=1e9+7;

inline int MO(const int &x){return x>=YL?x-YL:x;}

inline void add(int &x,int y){if((x+=y)>=YL)x-=YL;}

int f[2][N][2],now;

int main()

{

	int n=in(),m=in();f[now][0][1]=1;

	for(int i=1;i<=n;++i)f[now][i][0]=1;

	for(int i=1;i<=m;++i)

	{

		now^=1;memset(f[now],0,sizeof f[now]);

		for(int j=1;j<=n;++j)add(f[now][j][0],f[now^1][j-1][0]);//WW

		for(int j=1;j<=n;++j)add(f[now][j][1],f[now^1][j-1][1]);

		for(int j=1;j< n;++j)add(f[now][j][0],f[now^1][j+1][0]);//BB

		for(int j=1;j< n;++j)add(f[now][j][1],f[now^1][j+1][1]);

		add(f[now][0][1],f[now^1][1][1]),add(f[now][0][1],f[now^1][1][0]);

		for(int j=0;j< n;++j)add(f[now][j][0],f[now^1][j][0]);//WB

		for(int j=0;j< n;++j)add(f[now][j][1],f[now^1][j][1]);

		for(int j=2;j<=n;++j)add(f[now][j][0],f[now^1][j][0]);//BW

		for(int j=2;j<=n;++j)add(f[now][j][1],f[now^1][j][1]);

		add(f[now][1][1],f[now^1][1][1]),add(f[now][1][1],f[now^1][1][0]);

	}

	int ans=0;

	for(int i=0;i<=n;++i)add(ans,f[now][i][1]);

	printf("%d\n",ans);

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

const int MAXN=3005,MOD=1000000007;



int N,M;

int dp[MAXN][MAXN][2];



int main()

{

	scanf("%d%d",&N,&M);

	dp[0][0][1]=1;

	for(int i=1;i<=N;i++)

		dp[0][i][0]=1;

	for(int i=0;i<M;i++)

		for(int j=0;j<=N;j++)

			for(int k=0;k<2;k++)

			{

				if(j>0)

				{

					(dp[i+1][j-1][k|(j==1)]+=dp[i][j][k])%=MOD;

					(dp[i+1][j][k|(j==1)]+=dp[i][j][k])%=MOD;

				}

				if(j<N)

				{

					(dp[i+1][j+1][k]+=dp[i][j][k])%=MOD;

					(dp[i+1][j][k]+=dp[i][j][k])%=MOD;

				}

			}

	int ans=0;

	for(int j=0;j<=N;j++)

		(ans+=dp[M][j][1])%=MOD;

	printf("%d\n",ans);

	

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<deque>

using namespace std;

const int N=3000+5;

const int mod=1e9+7;

int d[N][N][2];

int n,m;

int main()

{

    scanf("%d%d",&n,&m);

    d[0][0][1]=1;

    for(int i=1;i<=n;i++)

        d[0][i][0]=1;

    for(int i=0;i<m;i++)

        for(int j=0;j<=n;j++)

            for(int k=0;k<2;k++)

                if(d[i][j][k]){

                    if(j){

                        d[i+1][j-1][k|(j==1)]+=d[i][j][k];

                        d[i+1][j-1][k|(j==1)]%=mod;

                        d[i+1][j][k|(j==1)]+=d[i][j][k];

                        d[i+1][j][k|(j==1)]%=mod;

                    }

                    if(j<n){

                        d[i+1][j][k]+=d[i][j][k];

                        d[i+1][j][k]%=mod;

                        d[i+1][j+1][k]+=d[i][j][k];

                        d[i+1][j+1][k]%=mod;

                    }

                }

    int ans=0;

    for(int i=0;i<=n;i++){

        ans+=d[m][i][1];

        ans%=mod;

    }

    printf("%d\n",ans);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int f[3005][3005][2],ms=1e9+7;

int main(){

	int n,m;

	scanf("%d%d",&n,&m);

	f[0][0][1]=1;

	for (int i=1;i<=n;i++)

	f[0][i][0]=1;

	for (int i=0;i<=m;i++)

	for (int j=0;j<=n;j++)

	for (int k=0;k<=1;k++){

		if (j) (f[i+1][j-1][!(j-1)|k]+=f[i][j][k])%=ms;

		if (n-j) (f[i+1][j+1][k]+=f[i][j][k])%=ms;

		if (j) (f[i+1][j][k|(j==1)]+=f[i][j][k])%=ms;

		if (n-j) (f[i+1][j][k]+=f[i][j][k])%=ms;

	}

	int ans=0;

	for (int i=0;i<=n;i++)

	(ans+=f[m][i][1])%=ms;

	printf("%d\n",ans);

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



int read()

{

  int x=0,f=1;

  char ch=getchar();

  while((ch<'0')||(ch>'9'))

    {

      if(ch=='-')

        {

          f=-f;

        }

      ch=getchar();

    }

  while((ch>='0')&&(ch<='9'))

    {

      x=x*10+ch-'0';

      ch=getchar();

    }

  return x*f;

}



const int maxn=3000;

const int mod=1000000007;



int n,k,f[maxn+10][maxn+10][2],ans;



int main()

{

  n=read();

  k=read();

  for(int i=0; i<=n; ++i)

    {

      f[0][i][(i==0)]=1;

    }

  for(int i=0; i<k; ++i)

    {

      for(int j=0; j<=n; ++j)

        {

          for(int sta=0; sta<2; ++sta)

            {

              if(j>0)

                {

                  f[i+1][j-1][sta|(j==1)]+=f[i][j][sta];

                  if(f[i+1][j-1][sta|(j==1)]>=mod)

                    {

                      f[i+1][j-1][sta|(j==1)]-=mod;

                    }

                  f[i+1][j][sta|(j==1)]+=f[i][j][sta];

                  if(f[i+1][j][sta|(j==1)]>=mod)

                    {

                      f[i+1][j][sta|(j==1)]-=mod;

                    }

                }

              if(j<n)

                {

                  f[i+1][j+1][sta]+=f[i][j][sta];

                  if(f[i+1][j+1][sta]>=mod)

                    {

                      f[i+1][j+1][sta]-=mod;

                    }

                  f[i+1][j][sta]+=f[i][j][sta];

                  if(f[i+1][j][sta]>=mod)

                    {

                      f[i+1][j][sta]-=mod;

                    }

                }

            }

        }

    }

  for(int i=0; i<=n; ++i)

    {

      ans+=f[k][i][1];

      if(ans>=mod)

        {

          ans-=mod;

        }

    }

  printf("%d\n",ans);

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <iomanip>

#include <cmath>

#include <string>

#include <cstring>

#include <algorithm>

#include <vector>

#include <sstream>

#include <set>

#include <queue>

#include <stack>

#include <cctype>

#include <map>

#include <climits>

#include <bitset>

using namespace std;

#define MATH_PI 3.14159265358979323846

int main(){

	ios::sync_with_stdio(false);

	int nCount,iStart,iEnd;

	register int i,nTotal=0;

	cin >> nCount;

	for (i = 1; i <= nCount; ++i){

		cin >> iStart >> iEnd;

		nTotal += iEnd - iStart + 1;

	}

	cout << nTotal << endl;

endapp:

	//system("pause > nul");

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int l,r,n,ans=0,i;

	scanf("%d",&n);

	for(i=0;i<n;i++)

		scanf("%d %d",&l,&r),ans+=r-l+1;

	printf("%d",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<iomanip>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

using namespace std;

int main(){

	long long n,a,b,ans=0;

	cin>>n;

	while(n--){

		cin>>a>>b;

		ans+=b-a+1;

	}

	cout<<ans;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int l,r,n,ans=0,i;

	scanf("%d",&n);

	for(i=0;i<n;i++)

		scanf("%d %d",&l,&r),ans+=r-l+1;

	printf("%d",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std; //头文件和命名空间

int main(){

    ios::sync_with_stdio(false); //输入输出加速

    int nCount,iStart,iEnd; //nCount-团体个数；iStart-座位号起始；iEnd-座位号结束

    register int i,nTotal=0; //循环计数器和总和

    cin >> nCount; //读入团体数

    for (i = 1; i <= nCount; ++i){ //读入每个团体占用的座位

        cin >> iStart >> iEnd; //读入起始和结束

        nTotal += iEnd - iStart + 1; //计算占用了多少个座位，加总

    }

    cout << nTotal << endl; //输出，勿忘换行

    return 0; //结束

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int l,r,n,ans=0,i;

	scanf("%d",&n);

	for(i=0;i<n;i++)

		scanf("%d %d",&l,&r),ans+=r-l+1;

	printf("%d",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

long long z,a,b,n;

int main()

{

	cin>>n;

	for(int i=1;i<=n;i++)

	{

		cin>>a>>b;

		z+=b-a+1;

	}

	cout<<z<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int l,r,n,ans=0,i;

	scanf("%d",&n);

	for(i=0;i<n;i++)

		scanf("%d %d",&l,&r),ans+=r-l+1;

	printf("%d",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

	int n,ans=0;

	cin>>n;

	while(n--)

	{

		int l,r;

		cin>>l>>r;

		ans+=r-l+1;

	}

	cout<<ans<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int l,r,n,ans=0,i;

	scanf("%d",&n);

	for(i=0;i<n;i++)

		scanf("%d %d",&l,&r),ans+=r-l+1;

	printf("%d",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#include<cmath>

using namespace std;

int main()

{

	int n,l,r,ans;

	cin>>n;

	for(int i=1;i<=n;i++)

	{

		cin>>l>>r;

		ans+=r-l+1;

	}

	cout<<ans<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int n,a,b,ans;

int main()

{

  scanf("%d",&n);

  for(int i=1;i<=n;i++)

    scanf("%d%d",&a,&b),ans=ans+b-a+1;

  printf("%d\n",ans);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

using namespace std;

int n;

long long ans,a,b;

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

        scanf("%lld%lld",&a,&b);

        ans+=b-a;

    }

    printf("%lld\n",ans+n);

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int n,a,b,ans;

int main()

{

  scanf("%d",&n);

  for(int i=1;i<=n;i++)

    scanf("%d%d",&a,&b),ans=ans+b-a+1;

  printf("%d\n",ans);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main(){

    int n,a,b,ans=0;

    cin>>n;

    for(int i=1;i<=n;i++){

        cin>>a>>b;

        ans+=b-a+1;

    }

    cout<<ans<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int n,a,b,ans;

int main()

{

  scanf("%d",&n);

  for(int i=1;i<=n;i++)

    scanf("%d%d",&a,&b),ans=ans+b-a+1;

  printf("%d\n",ans);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<cstdio>

using namespace std;

int n,a,b;

int ans;

int main()

{

    cin>>n;

    for(int i=1;i<=n;i++)

    {

        cin>>a>>b;

        ans+=b-a+1;

    }

    cout<<ans<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int n,a,b,ans;

int main()

{

  scanf("%d",&n);

  for(int i=1;i<=n;i++)

    scanf("%d%d",&a,&b),ans=ans+b-a+1;

  printf("%d\n",ans);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	int n,i,l,r,ans=0;

	scanf("%d",&n);

	for(i=1;i<=n;i++)

	{

		scanf("%d %d",&l,&r);

		ans+=r-l+1;

    }

    printf("%d",ans);

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int n,a,b,ans;

int main()

{

  scanf("%d",&n);

  for(int i=1;i<=n;i++)

    scanf("%d%d",&a,&b),ans=ans+b-a+1;

  printf("%d\n",ans);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int n,a,b,ans;

int main()

{

	cin>>n;

	for(int i=1;i<=n;i++)

	{

		cin>>a>>b;

		ans+=b-a+1;

	}

	cout<<ans;



	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int n,a,b,ans;

int main()

{

  scanf("%d",&n);

  for(int i=1;i<=n;i++)

    scanf("%d%d",&a,&b),ans=ans+b-a+1;

  printf("%d\n",ans);

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main(){

	int a,i,j,s=0,b;

	cin>>a;

	for(b=1;b<=a;b++){

		cin>>i>>j;

		s=s+(j-i)+1;

	}

	cout<<s;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int main()

{

    int a,b,ans,ci;

    scanf("%d",&ci);

    for(int i=0;i<ci;i++)

    {

        scanf("%d%d",&a,&b);

        ans+=b-a+1;

    }

    printf("%d",ans);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <algorithm>

using namespace std;



int N,L,R,ans;



int main()

{

	scanf("%d",&N);

	for (int i=1; i<=N; i++)

	{

		scanf("%d %d",&L,&R);

		ans+=R-L+1;

	}

	printf("%d",ans);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int main()

{

    int a,b,ans,ci;

    scanf("%d",&ci);

    for(int i=0;i<ci;i++)

    {

        scanf("%d%d",&a,&b);

        ans+=b-a+1;

    }

    printf("%d",ans);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <iostream>

#include <cstdlib>

using namespace std;

int main()

{

int n,k,i,j,t;

int a,b;

cin>>n;

t=0;

for (i=1; i<=n; i++)

  {

  cin>>a>>b;

  t=t+b-a+1;

  }

cout<<t<<endl;

return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int main()

{

    int a,b,ans,ci;

    scanf("%d",&ci);

    for(int i=0;i<ci;i++)

    {

        scanf("%d%d",&a,&b);

        ans+=b-a+1;

    }

    printf("%d",ans);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int n,a[1005],b[1005],ans=0;

int main()

{

    cin>>n;

    for(int i=0; i<n; i++)

    {    

        cin>>a[i]>>b[i];

        ans+=b[i]-a[i]+1;

    }

    cout<<ans<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int main()

{

    int a,b,ans,ci;

    scanf("%d",&ci);

    for(int i=0;i<ci;i++)

    {

        scanf("%d%d",&a,&b);

        ans+=b-a+1;

    }

    printf("%d",ans);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cmath>

#include<iostream>

using namespace std;

long long ans=0,n,x,y;

int main()

{

	cin>>n;

	for(int i=1;i<=n;i++)

	{

		cin>>x>>y;

		ans+=y-x+1;

	}

	cout<<ans<<endl;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int n,r,l,a;

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

	scanf("%d%d",&l,&r);

    a+=r-l+1;

	}

    printf("%d\n",a);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cmath>

#include<algorithm>

#include<cctype>

#include<cstring>

#include<queue>

#include<iostream>

#include<map>

using namespace std;

typedef long long ll;

typedef double lf;

typedef unsigned un;

typedef int in;

#define mian main

#define maxn 10000+10

#define maxm 10000+10

#define _(a) read(a)

#define non void

#define inf 2147483647

#define bre break

#define con continue

#define prq priority_queue

#define re register

#define bu bool

#define cz char

#define cst const

#define ope operator

#define inl inline

#define upp upper_bound

#define low lower_bound

#define next_per next_permutation

inl cz gc(){static cz buf[100000],*L=buf,*R=buf;return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;}

template<typename T>inl T Max(T a,T b){return a>b?a:b;}

template<typename T>inl T Min(T a,T b){return a<b?a:b;}

template<typename T>inl T Abs(T a){return a<0?-a:a;}

template<typename T>inl non read(T &a){a=0;T k=1;char c=gc();while(c<'0'||c>'9')k=c=='-'?-1:k,c=gc();while(c>='0'&&c<='9')a=a*10+(c^48),c=gc();if(c!='.'){a*=k;return;}T t=0.1;while(c<'0'||c>'9')c=gc();while(c>='0'&&c<='9')a+=t*(c^48),c=gc(),t*=0.1;a*=k;}

template<typename T>non write(T a,cz t='\n'){if(a==0){putc(48,stdout),putc(t,stdout);return;}if(a<0){a=-a;putc('-',stdout);}cz c[30];in le=0;while(a){c[++le]=a%10+48;a/=10;}for(re in i=le;i>=1;--i)putc(c[i],stdout);putc(t,stdout);}

in n,l,r,sum;

in main()

{

	read(n);

	for(re in i=1;i<=n;++i)read(l),read(r),sum+=r-l+1;

	write(sum);

	//freopen(".in","r",stdin);

	//freopen(".out","w",stdout);

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

int n,r,l,a;

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

	scanf("%d%d",&l,&r);

    a+=r-l+1;

	}

    printf("%d\n",a);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main()

{

	int n;

	cin>>n;

	int ans=0;

	int ai,bi;

	for (int i=1;i<=n;i++)

	{

		cin>>ai>>bi;

		ans+=(bi-ai+1);

	}

	cout<<ans;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int n,r,l,a;

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

	scanf("%d%d",&l,&r);

    a+=r-l+1;

	}

    printf("%d\n",a);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	int ans=0;

	int l,r;

	int n;

	cin>>n;

	for(int i=1;i<=n;i++)

	{

		scanf("%d%d",&l,&r);

		ans+=r-l+1;

	}

	cout<<ans<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int n,r,l,a;

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

	scanf("%d%d",&l,&r);

    a+=r-l+1;

	}

    printf("%d\n",a);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	int n,x,y,ans=0,i;

	cin>>n;

	for (i=1;i<=n;i++)

	{

		cin>>x>>y;

		ans+=(y-x+1);

	}

	cout<<ans;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int n,r,l,a;

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

	scanf("%d%d",&l,&r);

    a+=r-l+1;

	}

    printf("%d\n",a);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int n;

int li,ri,ans;

int main()

{

    cin>>n;

    for(int i=1;i<=n;i++)

	{

        cin>>li>>ri;

        ans+=ri-li+1;

    }

    cout<<ans<<endl;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int n,r,l,a;

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

	scanf("%d%d",&l,&r);

    a+=r-l+1;

	}

    printf("%d\n",a);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

int main()

{

	int n,sum=0;

	scanf("%d",&n);

	int l,r;

	for(int i=1;i<=n;i++)

	{

		scanf("%d%d",&l,&r);

		sum+=r-l+1;

	}

	printf("%d",sum);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int n,r,l,a;

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

	scanf("%d%d",&l,&r);

    a+=r-l+1;

	}

    printf("%d\n",a);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int l[100000],r[100000];

int main() {

	int n,i,sum=0;

	cin>>n;

	for(i=0;i<n;i++){

		cin>>l[i]>>r[i];

	}

	for(i=0;i<n;i++){

		sum+=r[i]-l[i]+1;

	}

	cout<<sum;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int n,r,l,a;

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

	scanf("%d%d",&l,&r);

    a+=r-l+1;

	}

    printf("%d\n",a);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

long long n,l,r,s;   

int main()

{

    cin>>n;

    for(int i=1;i<=n;i++)

    {

        cin>>l>>r;

        s+=r-l+1;    

    }

    cout<<s<<endl;

    return 0;

}

 

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std; 

int main(){

	int n;

	scanf("%d",&n);

	int ans=0;

	while(n--){

		int a,b;

		scanf("%d%d",&a,&b);

		ans=ans+b-a+1;

	}

	printf("%d\n",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cmath>

#include<algorithm>

#include<string>

#include<cstring>

#include<cstdlib>

using namespace std;

long long a,b,n,ans;

int main()

{

  scanf("%lld",&n);

  for(int i=0;i<n;i++)

  {

    scanf("%lld%lld",&a,&b);

    ans+=b-a+1;

  }

  printf("%lld\n",ans);

  return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std; 

int main(){

	int n;

	scanf("%d",&n);

	int ans=0;

	while(n--){

		int a,b;

		scanf("%d%d",&a,&b);

		ans=ans+b-a+1;

	}

	printf("%d\n",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main(){

    int n;

    int l,r,ans;

    cin>>n;

    for(int i=1;i<=n;i++){

        cin>>l>>r;

        ans+=r-l+1;

    }

    cout<<ans<<endl;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std; 

int main(){

	int n;

	scanf("%d",&n);

	int ans=0;

	while(n--){

		int a,b;

		scanf("%d%d",&a,&b);

		ans=ans+b-a+1;

	}

	printf("%d\n",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main(){

	int n, i, sum = 0, a, b;

	cin >> n;

	for(i = 0; i < n; i++){

		cin >> a >> b;

		sum += (b-a+1);

	}

	cout << sum << endl;

	return 0;

} 

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int main()

{

    int n;

    long long int a,b;

    long long int sum=0;

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

        scanf("%lld %lld",&a,&b);

        sum+=(b-a+1);

    }

    printf("%lld\n",sum);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<iostream>

using namespace std;

int a[100000],b[100000];

int main()

{

	int n,x=0;

	cin>>n;

	for(int i=0;i<n;i++)

	   cin>>a[i]>>b[i];

	for(int j=0;j<n;j++)

	{

		x+=b[j]-a[j];

	}

	cout<<x+n<<endl;

	return 0;

} 

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int main()

{

    int n;

    long long int a,b;

    long long int sum=0;

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

        scanf("%lld %lld",&a,&b);

        sum+=(b-a+1);

    }

    printf("%lld\n",sum);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>



using namespace std;



int main(){



    int n;

    int l,r;

    int sum = 0;

    cin >> n;

    for(int i=0;i<n;i++){

        cin >> l >> r;

        sum += (r-l+1);

    }

    cout << sum << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int main()

{

    int n;

    long long int a,b;

    long long int sum=0;

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

        scanf("%lld %lld",&a,&b);

        sum+=(b-a+1);

    }

    printf("%lld\n",sum);

}


// Fastest known solution for this problem: