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

#include<set>

#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i,a) loop(i,0,a)

#define INF 1e8

using namespace std;

int n,m,k,a,b,c,alt,p,q,r;

long long cost[101][101],tm[101][101],d[101];

bool used[101];



void dfunc(int s,int r){

	rep(i,101){

		used[i]=true;

		d[i]=INF;

	}

	d[s]=0;

	while(1){

		int mem=INF,now=-1;

		rep(i,101){

			if(used[i] && mem>d[i]){

				now=i;

				mem=d[i];

			}

		}

		if(now==-1)break;

		used[now]=false;

		rep(i,101){

			if(r==0){

				if(cost[now][i]!=INF)d[i]=min(d[i],d[now]+cost[now][i]);

			}else{

				if(tm[now][i]!=INF)d[i]=min(d[i],d[now]+tm[now][i]);

			}

		}

	}

}



int main(){

	while(cin>>n>>m,n||m){

		rep(i,101)rep(j,101){

			cost[i][j]=INF;

			tm[i][j]=INF;

		}

		rep(i,n){

			cin>>a>>b>>c>>alt;

			a--;

			b--;

			cost[b][a]=cost[a][b]=c;

			tm[b][a]=tm[a][b]=alt;

		}

		cin>>k;

		rep(i,k){

			cin>>p>>q>>r;

			dfunc(p-1,r);

			cout<<d[q-1]<<endl;

		}

	}

	return 0;

}

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

#define loop(i,a,b) for(int i=a;i<b;i++)

#define rep(i,a) loop(i,0,a)

#define INF 1e9

using namespace std;

typedef long long ll;



ll min(ll a,ll b){

	if(a>b)return b;

	else return a;

}





int main(){

	int n,m,a,b,cost,time,l,p,q,r;

	while(cin>>n>>m,n||m){

		ll mt[m][m],mc[m][m];

		rep(i,m)rep(j,m)mt[i][j]=mc[i][j]=INF;

		rep(i,n){

			cin>>a>>b>>cost>>time;

			mt[a-1][b-1]=mt[b-1][a-1]=time;

			mc[a-1][b-1]=mc[b-1][a-1]=cost;

		}

		rep(k,m){

			rep(i,m){

				rep(j,m){

					mt[i][j]=min(mt[i][j],mt[i][k]+mt[k][j]);

					mc[i][j]=min(mc[i][j],mc[i][k]+mc[k][j]);

				}

			}

		}

		cin>>l;

		rep(i,l){

			cin>>p>>q>>r;

			if(r==0)cout<<mc[p-1][q-1]<<endl;

			else cout<<mt[p-1][q-1]<<endl;

		}

	}

	return 0;

}

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

using namespace std;

typedef long long LL;

const int INF = 0x3f3f3f3f;

const LL mod = 1e9 + 7;

const int N = 200005;



struct Seg {

    int val[N << 2], lazy[N << 2];

    void init(int n) {

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

            val[i] = n;

            lazy[i] = INF;

        }

    }

    void push_up(int u) {

        val[u] = min(val[u << 1], val[u << 1 | 1]);

    }

    void push_down(int u) {

        if (lazy[u] != INF) {

            val[u << 1] = min(val[u << 1], lazy[u]);

            val[u << 1 | 1] = min(val[u << 1 | 1], lazy[u]);

            lazy[u << 1] = min(lazy[u << 1], lazy[u]);

            lazy[u << 1 | 1] = min(lazy[u << 1 | 1], lazy[u]);

            lazy[u] = INF;

        }

    }

    void update(int u, int l, int r, int x, int y, int v) {

        if (x <= l && r <= y) {

            val[u] = min(val[u], v);

            lazy[u] = min(lazy[u], v);

            return;

        }

        int mid = l + r >> 1;

        push_down(u);

        if (x <= mid) update(u << 1, l, mid, x, y, v);

        if (y > mid) update(u << 1 | 1, mid + 1, r, x, y, v);

        push_up(u);

    }

    int query(int u, int l, int r, int x) {

        if (l == r) return val[u];

        int mid = l + r >> 1;

        push_down(u);

        if (x <= mid)

            return query(u << 1, l, mid, x);

        else

            return query(u << 1 | 1, mid + 1, r, x);

    }

} T1, T2;



int a[N];

int main() {

    int n, q;

    cin >> n >> q;

    T1.init(n);

    T2.init(n);

    LL ans = (n - 2LL) * (n - 2);

    while (q--) {

        int op, x;

        cin >> op >> x;

        if (op == 1) {

            int g = T2.query(1, 1, n, x);

            ans -= g - 2;

            T1.update(1, 1, n, 1, g, x);



        } else {

            int g = T1.query(1, 1, n, x);

            ans -= g - 2;

            T2.update(1, 1, n, 1, g, x);

        }

    }

    cout << ans << endl;

    return 0;

}


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

using namespace std;

typedef long long LL;

const int INF = 0x3f3f3f3f;

const LL mod = 1e9 + 7;

const int N = 200005;



int n, q;

struct Node {

    int c[N];

    int sum(int x) {

        int res = n;

        while (x) {

            res = min(res, c[x]);

            x -= x & -x;

        }

        return res;

    }

    void add(int x, int d) {

        while (x <= n) {

            c[x] = min(c[x], d);

            x += x & -x;

        }

    }

} T1, T2;

int main() {

    cin >> n >> q;

    LL ans = (n - 2LL) * (n - 2);

    for (int i = 1; i <= n; i++) T1.c[i] = T2.c[i] = n;

    while (q--) {

        int op, x;

        cin >> op >> x;

        if (op == 1) {

            int z = T1.sum(n - x + 1);

            T2.add(n - z + 1, x);

            ans -= z - 2;

        } else {

            int z = T2.sum(n - x + 1);

            T1.add(n - z + 1, x);

            ans -= z - 2;

        }

    }

    cout << ans << endl;

    return 0;

}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define srep(i,s,t) for(int i = s; i < t; ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

using namespace std;

typedef long long int ll;

typedef pair<int,int> P;

#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005



int main() {

    int x[MAX_N] = {}, y[MAX_N] = {};

    int n, q;

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

    ll ans = (ll)(n-2)*(n-2);

    srep(i,2,n){

        x[i] = n;

        y[i] = n;

    }

    int xx = n;

    int yy = n;

    while(q--){

        int t, z;

        scanf("%d%d", &t,&z);

        if(t == 1){

            if(z < xx){

                ans -= yy - 2;

                srep(i,z,xx) x[i] = yy;

                xx = z;

            }else{

                ans -= x[z] - 2;

            }

        }else{

            if(z < yy){

                ans -= xx - 2;

                srep(i,z,yy) y[i] = xx;

                yy = z;

            }else{

                ans -= y[z] - 2;

            }

        }

    }

    cout << ans << endl;

    return 0;

}






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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define srep(i,s,t) for(int i = s; i < t; ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

using namespace std;

typedef long long int ll;

typedef pair<int,int> P;

#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005



#define ch() getchar()

#define pc(x) putchar(x)

template<typename T>inline void read(T&x){

	int f;char c;

	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;

	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;

}



int x[MAX_N], y[MAX_N];



int main() {

    int n, q;

    read(n); read(q);

    ll ans = (ll)(n-2)*(n-2);

    int xx = n;

    int yy = n;

    while(q--){

        int t, z;

        read(t), read(z);

        if(t == 1){

            if(z < xx){

                ans -= yy - 2;

                srep(i,z+1,xx) x[i] = yy;

                xx = z;

            }else{

                ans -= x[z] - 2;

            }

        }else{

            if(z < yy){

                ans -= xx - 2;

                srep(i,z+1,yy) y[i] = xx;

                yy = z;

            }else{

                ans -= y[z] - 2;

            }

        }

    }

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

    return 0;

}






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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define srep(i,s,t) for(int i = s; i < t; ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

using namespace std;

typedef long long int ll;

typedef pair<int,int> P;

#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005

int main() {

    int x[MAX_N] = {}, y[MAX_N] = {};

    int n, q;

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

    ll ans = (ll)(n-2)*(n-2);

    srep(i,2,n){

        x[i] = n;

        y[i] = n;

    }

    int xx = n;

    int yy = n;

    while(q--){

        int t, z;

        scanf("%d%d", &t,&z);

        if(t == 1){

            if(z < xx){

                ans -= yy - 2;

                srep(i,z+1,xx) x[i] = yy;

                xx = z;

            }else{

                ans -= x[z] - 2;

            }

        }else{

            if(z < yy){

                ans -= xx - 2;

                srep(i,z+1,yy) y[i] = xx;

                yy = z;

            }else{

                ans -= y[z] - 2;

            }

        }

    }

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

    return 0;

}






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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define srep(i,s,t) for(int i = s; i < t; ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

using namespace std;

typedef long long int ll;

typedef pair<int,int> P;

#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005



#define ch() getchar()

#define pc(x) putchar(x)

template<typename T>inline void read(T&x){

	int f;char c;

	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;

	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;

}



int x[MAX_N], y[MAX_N];



int main() {

    int n, q;

    read(n); read(q);

    ll ans = (ll)(n-2)*(n-2);

    int xx = n;

    int yy = n;

    while(q--){

        int t, z;

        read(t), read(z);

        if(t == 1){

            if(z < xx){

                ans -= yy - 2;

                srep(i,z+1,xx) x[i] = yy;

                xx = z;

            }else{

                ans -= x[z] - 2;

            }

        }else{

            if(z < yy){

                ans -= xx - 2;

                srep(i,z+1,yy) y[i] = xx;

                yy = z;

            }else{

                ans -= y[z] - 2;

            }

        }

    }

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

    return 0;

}






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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define srep(i,s,t) for(int i = s; i < t; ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

using namespace std;

typedef long long int ll;

typedef pair<int,int> P;

#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005



#define ch() getchar()

#define pc(x) putchar(x)

template<typename T>inline void read(T&x){

	int f;char c;

	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;

	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;

}



int main() {

    int x[MAX_N] = {}, y[MAX_N] = {};

    int n, q;

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

    ll ans = (ll)(n-2)*(n-2);

    srep(i,2,n){

        x[i] = n;

        y[i] = n;

    }

    int xx = n;

    int yy = n;

    while(q--){

        int t, z;

        // scanf("%d%d", &t,&z);

        read(t), read(z);

        if(t == 1){

            if(z < xx){

                ans -= yy - 2;

                srep(i,z+1,xx) x[i] = yy;

                xx = z;

            }else{

                ans -= x[z] - 2;

            }

        }else{

            if(z < yy){

                ans -= xx - 2;

                srep(i,z+1,yy) y[i] = xx;

                yy = z;

            }else{

                ans -= y[z] - 2;

            }

        }

    }

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

    return 0;

}






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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define srep(i,s,t) for(int i = s; i < t; ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

using namespace std;

typedef long long int ll;

typedef pair<int,int> P;

#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005



#define ch() getchar()

#define pc(x) putchar(x)

template<typename T>inline void read(T&x){

	int f;char c;

	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;

	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;

}



int x[MAX_N], y[MAX_N];



int main() {

    int n, q;

    read(n); read(q);

    ll ans = (ll)(n-2)*(n-2);

    int xx = n;

    int yy = n;

    while(q--){

        int t, z;

        read(t), read(z);

        if(t == 1){

            if(z < xx){

                ans -= yy - 2;

                srep(i,z+1,xx) x[i] = yy;

                xx = z;

            }else{

                ans -= x[z] - 2;

            }

        }else{

            if(z < yy){

                ans -= xx - 2;

                srep(i,z+1,yy) y[i] = xx;

                yy = z;

            }else{

                ans -= y[z] - 2;

            }

        }

    }

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

    return 0;

}






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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define srep(i,s,t) for(int i = s; i < t; ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

using namespace std;

typedef long long int ll;

typedef pair<int,int> P;

#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005



#define ch() getchar()

#define pc(x) putchar(x)

template<typename T>inline void read(T&x){

	int f;char c;

	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;

	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;

}



int main() {

    int x[MAX_N] = {}, y[MAX_N] = {};

    int n, q;

    // scanf("%d%d", &n,&q);

    read(n); read(q);

    ll ans = (ll)(n-2)*(n-2);

    srep(i,2,n){

        x[i] = n;

        y[i] = n;

    }

    int xx = n;

    int yy = n;

    while(q--){

        int t, z;

        // scanf("%d%d", &t,&z);

        read(t), read(z);

        if(t == 1){

            if(z < xx){

                ans -= yy - 2;

                srep(i,z+1,xx) x[i] = yy;

                xx = z;

            }else{

                ans -= x[z] - 2;

            }

        }else{

            if(z < yy){

                ans -= xx - 2;

                srep(i,z+1,yy) y[i] = xx;

                yy = z;

            }else{

                ans -= y[z] - 2;

            }

        }

    }

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

    return 0;

}






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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define srep(i,s,t) for(int i = s; i < t; ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

using namespace std;

typedef long long int ll;

typedef pair<int,int> P;

#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005



#define ch() getchar()

#define pc(x) putchar(x)

template<typename T>inline void read(T&x){

	int f;char c;

	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;

	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;

}



int x[MAX_N], y[MAX_N];



int main() {

    int n, q;

    read(n); read(q);

    ll ans = (ll)(n-2)*(n-2);

    int xx = n;

    int yy = n;

    while(q--){

        int t, z;

        read(t), read(z);

        if(t == 1){

            if(z < xx){

                ans -= yy - 2;

                srep(i,z+1,xx) x[i] = yy;

                xx = z;

            }else{

                ans -= x[z] - 2;

            }

        }else{

            if(z < yy){

                ans -= xx - 2;

                srep(i,z+1,yy) y[i] = xx;

                yy = z;

            }else{

                ans -= y[z] - 2;

            }

        }

    }

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

    return 0;

}






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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define srep(i,s,t) for(int i = s; i < t; ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

using namespace std;

typedef long long int ll;

typedef pair<int,int> P;

#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005



#define ch() getchar()

#define pc(x) putchar(x)

template<typename T>inline void read(T&x){

	int f;char c;

	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;

	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;

}



int main() {

    int x[MAX_N] = {}, y[MAX_N] = {};

    int n, q;

    // scanf("%d%d", &n,&q);

    read(n); read(q);

    ll ans = (ll)(n-2)*(n-2);

    /*

    srep(i,2,n){

        x[i] = n;

        y[i] = n;

    }

    */

    int xx = n;

    int yy = n;

    while(q--){

        int t, z;

        // scanf("%d%d", &t,&z);

        read(t), read(z);

        if(t == 1){

            if(z < xx){

                ans -= yy - 2;

                srep(i,z+1,xx) x[i] = yy;

                xx = z;

            }else{

                ans -= x[z] - 2;

            }

        }else{

            if(z < yy){

                ans -= xx - 2;

                srep(i,z+1,yy) y[i] = xx;

                yy = z;

            }else{

                ans -= y[z] - 2;

            }

        }

    }

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

    return 0;

}






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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define srep(i,s,t) for(int i = s; i < t; ++i)

#define drep(i,n) for(int i = (n)-1; i >= 0; --i)

using namespace std;

typedef long long int ll;

typedef pair<int,int> P;

#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005



#define ch() getchar()

#define pc(x) putchar(x)

template<typename T>inline void read(T&x){

	int f;char c;

	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;

	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;

}



int x[MAX_N], y[MAX_N];



int main() {

    int n, q;

    read(n); read(q);

    ll ans = (ll)(n-2)*(n-2);

    int xx = n;

    int yy = n;

    while(q--){

        int t, z;

        read(t), read(z);

        if(t == 1){

            if(z < xx){

                ans -= yy - 2;

                srep(i,z+1,xx) x[i] = yy;

                xx = z;

            }else{

                ans -= x[z] - 2;

            }

        }else{

            if(z < yy){

                ans -= xx - 2;

                srep(i,z+1,yy) y[i] = xx;

                yy = z;

            }else{

                ans -= y[z] - 2;

            }

        }

    }

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

    return 0;

}






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

using namespace std;

#define ll long long

const int maxn = 2e5 + 5;

int minTA[maxn] , minPA[maxn];

int minTB[maxn] , minPB[maxn];

int lowbit (int x) {return x & -x;}

void modify (int x , int c , int n , int minn[]){

    while (x <= n){

        minn[x] = min (minn[x] , c);

        x += lowbit(x);

    }

}

int ask (int x , int n , int minn[]){

    int ans = 1e9;

    while (x){

        ans = min (ans , minn[x]);

        x -= lowbit(x);

    }

    return ans;

}

int main()

{

    ios::sync_with_stdio(false);

    ll n , q; cin >> n >> q;

    // 初始化

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

        minTA[i] = minTB[i] = minPA[i] = minPB[i] = 1e9;

    }

    ll ans = (n - 2) * (n - 2);

    for (int g = 1 ; g <= q ; g++){

        int op , x; cin >> op >> x;

        if (op == 1){

            int res = ask(x , n , minTA);

            if (res == 1e9) res = g - 1;

            int res2 =  minPB[res];

            if (res2 == 1e9) ans -= n - 2;

            else ans -= res2 - 2;

            modify( x , g , n , minTA );

            minPA[g] = x;

        }else {

            int res = ask(x , n , minTB);

            if (res == 1e9) res = g - 1;

            int res2 =  minPA[res];

            if (res2 == 1e9) ans -= n - 2;

            else ans -= res2 - 2;

            modify( x , g , n , minTB );

            minPB[g] = x;

        }

        minPB[g] = min (minPB[g] , minPB[g - 1]);

        minPA[g] = min (minPA[g] , minPA[g - 1]);

    }

    cout << ans << endl;

    return 0;

}


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

using namespace std;

#define ll long long

const int maxn = 2e5 + 5;

int l[maxn] , h[maxn];

int main()

{

    ios::sync_with_stdio(false);

    ll n , q; cin >> n >> q;

    ll ans = (n - 2) * (n - 2) , maxl = n , maxh = n;

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

        l[i] = n;

        h[i] = n;

    }

    while (q--){

        int op , x; cin >> op >> x;

        if (op == 1){

            if (x < maxl){

                for (int i = x ; i <= maxl - 1 ; i++) l[i] = maxh;

                maxl = x;

            }

            ans -= l[x] - 2;

        }else {

            if (x < maxh){

                for (int i = x ; i <= maxh - 1 ; i++) h[i] = maxl;

                maxh = x;

            }

            ans -= h[x] - 2;

        }

    }

    cout << ans << endl;

    return 0;

}


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

#define REP(i, n) for(int i=0; i<(int)(n); i++)

#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)

#define ALL(x) begin(x),end(x)

#define PB push_back

using namespace std;

typedef int64_t LL;

typedef vector<int> VI;

typedef pair<int,int> PII;



template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }

template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }

template<class T> using MaxHeap = priority_queue<T>;

template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {

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

    v.resize(unique(begin(v),end(v))-begin(v));

}



const int N=55,MOD=1e9+7;

LL dp[N][N][N*N]; // dp(i,j,k): i之前保留j個空格分數為k



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    int n,k;

    cin >> n >> k;

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

    REP(i,n) REP(j,n+1) REP(k,n*n) {

        // i-i

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

        // i-x i-x

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

        // i-j i-x

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

        // i-j i-j

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

    }



    cout << dp[n][0][k] << '\n';

    return 0;

}


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

#define REP(i, n) for(int i=0; i<(int)(n); i++)

#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)

#define ALL(x) begin(x),end(x)

#define PB push_back

using namespace std;

typedef int64_t LL;

typedef vector<int> VI;

typedef pair<int,int> PII;



template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }

template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }

template<class T> using MaxHeap = priority_queue<T>;

template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {

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

    v.resize(unique(begin(v),end(v))-begin(v));

}



const int N=51,MOD=1e9+7;

LL dp[N][N][N*N]; // dp(i,j,k): i之前,保留j個,分數為k



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    int n,K;

    cin >> n >> K;

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

    REP(i,n) REP1(j,0,i) REP1(k,0,K) {

        // i-i

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

        // i-x i-x

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

        // i-j i-x

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

        // i-j i-j

        if ( j ) {

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

        }

    }



    cout << dp[n][0][K] << '\n';

    return 0;

}


// Fastest known solution for this problem: