stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <vector>

using namespace std;

typedef long long ll;



int a[200005];

vector<int> v[200005];

int l[200005];

int re[200005];

int cnt[200005];

int c[200005];



int main()

{

    ll n, k;

    cin >> n >> k;

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

        cin >> a[i];

        cnt[a[i]]++;

        re[i] = cnt[a[i]];

        v[a[i]].push_back(i);

    }

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

        l[a[i]] = v[a[i]].size();

    }

    int now = 0;

    int i;

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

        while(l[a[now]] != re[now]){

            now = v[a[now]][re[now]] + 1;

            if(now == n){

                break;

            }

        }

        c[i] = now;

//        cout << i << " " << c[i] << endl;

        if(l[a[now]] == 1 && now == n - 1){

            i++;

            c[i] = n;

            break;

        }

        if(now == n) break;

        now = (v[a[now]][0] + 1) % n;

    }

    int cir = i + 1;

//    cout << cir << endl;

    int p = (k + cir - 1) % cir;

    for(int i = c[p]; i < n; i++){

        while(l[a[i]] != re[i]){

            i = v[a[i]][re[i]] + 1;

            if(i == n){

                break;

            }

        }

        if(i >= n) break;

        cout << a[i] << " ";

    }

    cout << endl;

}

// Faster C++ solution for the same problem (measured speedup: 3.4482139025488845x):
#include <algorithm>

#include <iostream>

using namespace std;

typedef long long ll;



int main()

{

    ll n, k;

    cin >> n >> k;

    int a[200005], r[200005], b[200005];

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

    for(int i = 0; i <= 200000; i++) b[i] = -1;

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

        cin >> a[i];

        if(b[a[i]] != -1){

            r[b[a[i]]] = i;

        }

        b[a[i]] = i;

    }

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

        if(r[b[a[i]]] == -1) r[b[a[i]]] = i;

        b[a[i]] = i;

    }

    int u = 0;

    ll s = 0;

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

        if(r[u] == u) s += n + 1;

        else s += (r[u] + n - u) % n + 1;

        u = (r[u] + 1) % n;

        if(u == 0) break;

    }

    k = k * n % s;

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

        ll c;

        if(r[u] == u) c = n + 1;

        else c = (r[u] + n - u) % n + 1;

        if(k >= c){

            k -= c;

            u = (r[u] + 1) % n;

        }

        else{

            int ans[200005];

            int l = 0;

            while(k){

                ll c;

                if(r[u] == u) c = n + 1;

                else c = (r[u] + n - u) % n + 1;

                if(k >= c){

                    k -= c;

                    u = (r[u] + 1) % n;

                }

                else{

                    k--;

                    ans[l] = a[u];

                    u = (u + 1) % n;

                    l++;

                }

            }

            for(int j = 0; j < l; j++) cout << ans[j] << " ";

            cout << endl;

            return 0;

        }

    }

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cmath>

#include <vector>

#include <string>

#include <iomanip>

//#include <string.h>

#include <bits/stdc++.h>

#define INF 999999999

using namespace std;

#define ll long long

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct shi

{

    int x=0;

    int T;

}s[1000000];

int cmd(shi a,shi b)

{

    return a.x<b.x;

}

/*long long cmd(long long a, long long  b)

{

    return a > b;

}*/



int main()

{

    boost;

    int N;

    cin >>N;

    int   hh[100000];

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

        cin >>hh[i];

    }

    sort(hh,hh+N);

    int kk[105000];

    int ma=0;

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

        if(i!=0&&i!=N-1){

            kk[i]+=abs(hh[i]-hh[N-1])*2;

            kk[i]+=abs(hh[i]-hh[0]);

        }

        else

            kk[i]+=abs(hh[0]-hh[N-1]);



    }



    sort(kk,kk+N);

    cout<<kk[0]<<endl;

    return 0;



}


// Faster C++ solution for the same problem (measured speedup: 9.428641558979963x):
#include<bits/stdc++.h>

#define LL long long

#define L(x) x<<1    //左儿子 x*2

#define R(x) x<<1|1 //右儿子  x*2+1

using namespace std;

int a[105];

int main() {

    int n;

    cin>>n;

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

        cin>>a[i];

    sort(a,a+n);

    cout<<a[n-1]-a[0]<<endl;

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cmath>

#include <vector>

#include <string>

#include <iomanip>

//#include <string.h>

#include <bits/stdc++.h>

#define INF 999999999

using namespace std;

#define ll long long

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct shi

{

    int x=0;

    int T;

}s[1000000];

int cmd(shi a,shi b)

{

    return a.x<b.x;

}

/*long long cmd(long long a, long long  b)

{

    return a > b;

}*/



int main()

{

    boost;

    int N;

    cin >>N;

    int   hh[100000];

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

        cin >>hh[i];

    }

    sort(hh,hh+N);

    int kk[105000];

    int ma=0;

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

        if(i!=0&&i!=N-1){

            kk[i]+=abs(hh[i]-hh[N-1])*2;

            kk[i]+=abs(hh[i]-hh[0]);

        }

        else

            kk[i]+=abs(hh[0]-hh[N-1]);



    }



    sort(kk,kk+N);

    cout<<kk[0]<<endl;

    return 0;



}


// Faster C++ solution for the same problem (measured speedup: 9.436116691442738x):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n,maxi=0, mini=1000;

    cin>>n;

    while(n--)

    {

        int num;

        cin>>num;



        if(num>maxi)

            maxi=num;

        if(num<mini)

            mini=num;

    }

    cout<<maxi-mini<<endl;

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cmath>

#include <vector>

#include <string>

#include <iomanip>

//#include <string.h>

#include <bits/stdc++.h>

#define INF 999999999

using namespace std;

#define ll long long

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct shi

{

    int x=0;

    int T;

}s[1000000];

int cmd(shi a,shi b)

{

    return a.x<b.x;

}

/*long long cmd(long long a, long long  b)

{

    return a > b;

}*/



int main()

{

    boost;

    int N;

    cin >>N;

    int   hh[100000];

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

        cin >>hh[i];

    }

    sort(hh,hh+N);

    int kk[105000];

    int ma=0;

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

        if(i!=0&&i!=N-1){

            kk[i]+=abs(hh[i]-hh[N-1])*2;

            kk[i]+=abs(hh[i]-hh[0]);

        }

        else

            kk[i]+=abs(hh[0]-hh[N-1]);



    }



    sort(kk,kk+N);

    cout<<kk[0]<<endl;

    return 0;



}


// Faster C++ solution for the same problem (measured speedup: 9.330522964489374x):
#include<iostream>

#include<algorithm>

#include<vector>

using namespace std;

int main()

{

    int n,i,x;

    vector<int>v;

    cin>>n;

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

    {

        cin>>x;

        v.push_back(x);

    }

    if(n==1)

    {

        cout<<"0"<<endl;

    }

    else

    {

    sort(v.begin(),v.end());

        cout<<v[v.size()-1]-v[0]<<endl;

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cmath>

#include <vector>

#include <string>

#include <iomanip>

//#include <string.h>

#include <bits/stdc++.h>

#define INF 999999999

using namespace std;

#define ll long long

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct shi

{

    int x=0;

    int T;

}s[1000000];

int cmd(shi a,shi b)

{

    return a.x<b.x;

}

/*long long cmd(long long a, long long  b)

{

    return a > b;

}*/



int main()

{

    boost;

    int N;

    cin >>N;

    int   hh[100000];

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

        cin >>hh[i];

    }

    sort(hh,hh+N);

    int kk[105000];

    int ma=0;

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

        if(i!=0&&i!=N-1){

            kk[i]+=abs(hh[i]-hh[N-1])*2;

            kk[i]+=abs(hh[i]-hh[0]);

        }

        else

            kk[i]+=abs(hh[0]-hh[N-1]);



    }



    sort(kk,kk+N);

    cout<<kk[0]<<endl;

    return 0;



}


// Faster C++ solution for the same problem (measured speedup: 9.444705269547251x):
#include <bits/stdc++.h>

using namespace std;

int main()

{

   int x;

   cin>>x;

    int a[x];

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

        cin>>a[i];

    sort(a,a+x);

    cout<<a[x-1]-a[0];

   return 0;

   }
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cmath>

#include <vector>

#include <string>

#include <iomanip>

//#include <string.h>

#include <bits/stdc++.h>

#define INF 999999999

using namespace std;

#define ll long long

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct shi

{

    int x=0;

    int T;

}s[1000000];

int cmd(shi a,shi b)

{

    return a.x<b.x;

}

/*long long cmd(long long a, long long  b)

{

    return a > b;

}*/



int main()

{

    boost;

    int N;

    cin >>N;

    int   hh[100000];

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

        cin >>hh[i];

    }

    sort(hh,hh+N);

    int kk[105000];

    int ma=0;

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

        if(i!=0&&i!=N-1){

            kk[i]+=abs(hh[i]-hh[N-1])*2;

            kk[i]+=abs(hh[i]-hh[0]);

        }

        else

            kk[i]+=abs(hh[0]-hh[N-1]);



    }



    sort(kk,kk+N);

    cout<<kk[0]<<endl;

    return 0;



}


// Faster C++ solution for the same problem (measured speedup: 9.2203048628455x):
#include <iostream>

#include<cmath>

#include<math.h>

#include<algorithm>

#include<fstream>

#include<queue>

using namespace std;

void ll(){

	std::ios_base::sync_with_stdio(0);

	cin.tie(NULL);

	cout.tie(0);

}

int main()

{

	ll();



	vector<int> v;

	int arr[1000];

	int n,d=0,t=0;

	cin >> n;

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

	{

		cin >> arr[i];

		v.push_back(arr[i]);

	}



		sort(v.begin(), v.end());



		d = v[n - 1] - v[0];

	cout << d << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace std;

using namespace __gnu_pbds;



#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define fbo find_by_order

#define ook order_of_key



typedef long long ll;

typedef pair<ll,ll> ii;

typedef vector<int> vi;

typedef long double ld; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

typedef set<int>::iterator sit;

typedef map<int,int>::iterator mit;

typedef vector<int>::iterator vit;

const int MOD = 1e9 + 7;

int dp[3011][3011][2];



void add(int &a, int b)

{

	a+=b;

	while(a>=MOD) a-=MOD;

}



int main()

{

	ios_base::sync_with_stdio(0); cin.tie(0);

	ll n, m; cin>>n>>m;

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

	{

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

	}

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

	{

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

		{

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

			{

				int v=dp[i][j][k];

				if(v==0) continue;

				//RR

				if(j>=1)

				{

					add(dp[i+1][j-1][k|(j-1==0)],v);

				}

				//BB

				if(j+1<=n)

				{

					add(dp[i+1][j+1][k|(j==0)],v);

				}

				//RB

				if(j-1>=0)

				{

					add(dp[i+1][j][k|(j-1==0)],v);

				}

				//BR

				if(j+1<=n)

				{

					add(dp[i+1][j][k|(j==0)],v);

				}

			}

		}

	}

	int ans=0;

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

	{

		add(ans,dp[m][i][1]);

	}

	cout<<ans<<'\n';

}


// Faster C++ solution for the same problem (measured speedup: 2.946331496315071x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

const int MAXN=3005,MOD=1e9+7;

int n,m;

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

int main()

{

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

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

	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];

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

				}

				if(j>0)

				{

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

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

				}

				if(j<n)

				{

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

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

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

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

				}

			}

		}

	}

	int ans=0;

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

	{

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

		ans%=MOD;

	}

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

	fclose(stdin);

	fclose(stdout);

}
// Slower C++ solution:
//#pragma GCC optimize(3)

#include<iostream>

#include<iomanip>

#include<stack>

#include<queue>

#include<list>

#include<vector>

#include<set> 

#include<map>

#include<string>

#include<algorithm>

#include<cmath>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<ctime>

#define ll unsigned long long

#define db double

#define inf 3001

#define INF (int)1e8 

#define mod (int)(1e9+7)

#define pi acos(-1)

#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}

using namespace std;

int f[2][inf*2];



int DP(int n,int m){

    memset(f,0,sizeof(f));

	int now=0;

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

		f[now][i]=1;

	}

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

		now^=1;

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

			f[now][j]=0;

		}

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

			if(j>0){

                f[now][j-1]=(f[now][j-1]+f[now^1][j])%mod;

                f[now][j]=(f[now][j]+f[now^1][j])%mod;

            }

            if(j<n){

                f[now][j+1]=(f[now][j+1]+f[now^1][j])%mod;

                f[now][j]=(f[now][j]+f[now^1][j])%mod;

            }

		}

	}

	int ans=0;

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

		ans=(ans+f[now][i])%mod;

	}

	return ans;

}



int n,m;



int main(){

	rd(n) rd(m)

	printf("%d\n",(DP(n,m)-DP(n-1,m)+mod)%mod);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.292886703778496x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 2.995973423632944x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 1.2211040144262653x):
#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);

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 4.160396500502369x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 3.266762657460307x):
#include <cstdio>

#define N 3010

#define mod 1000000007

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

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=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][k|(j==1)]=(f[i+1][j-1][k|(j==1)]+f[i][j][k])%mod;

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

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

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

			}

		}

	}

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

	printf("%d",ans);

	return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.310446676256131x):
#include <cstdio>

int main(){

    int n,l,r,ans=0;

    scanf("%d",&n);

    for(int i=0;i<n;++i) scanf("%d %d",&l,&r),ans+=r-l+1;

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

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.234364703097581x):
#include <cstdio>

int main(){

    int n,l,r,ans=0;

    scanf("%d",&n);

    for(int i=0;i<n;++i) scanf("%d %d",&l,&r),ans+=r-l+1;

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

}