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

#include <algorithm>



using namespace std; 



int arr[1005];



void findMaxHappy(int n , int x){

    int count = 0;

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

        if(x >= arr[i]){

            if(i == n - 1 && (x - arr[i])!=0){

                cout << count << endl;

                exit(0);

            }

            else{

                count++; 

                x = x - arr[i]; // Update x value

            }

        }

    }

    cout << count << endl;

}



int main(){

    int n , x; 

    cin >> n >> x;



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

        cin >> arr[i];

    }

    sort(arr , arr + n); // Sort array



    findMaxHappy(n , x);

}

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

#include <algorithm>

using namespace std;

int a[101];

int main(void)

{

	int n, x;

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

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

		scanf("%d", &a[i]);

	sort(a + 1, a + n + 1);

	int ans = 0;

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

	{

		if (x < a[i])

		{

			printf("%d", ans);

			return 0;

		}

		++ans;

		x -= a[i];

	}

	if (x) --ans;

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

	return 0;

}

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

#include<algorithm>

#include<cstdio>

#include<cstring>

#include<string>

#include<vector>

using namespace std;



const int maxn = 100;

vector<int>g[maxn];

int vis[maxn];

int n,m;

int num,tot;

void dfs(int t)

{	

	int j;

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

	{

		if(vis[j]!=1)

			break;

	}

	if(j==n+1)

	{

		num++;

		return;

	}

	for(int i=0;i<g[t].size();i++)

	{

		int x = g[t][i];

		if(vis[x]==0)

		{

			vis[x]=1;

			dfs(x);

			vis[x]=0;

		}

	}

	return ;

}

int main()

{

	memset(vis,0,sizeof(vis));

	cin>>n>>m;

	tot=0;

	num=0;

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

	{

		g[i].clear();

	}

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

	{

		int a,b;

		cin>>a>>b;

		g[a].push_back(b);

		g[b].push_back(a);

	}

	vis[1]=1;

	num=0;

	for(int i=0;i<g[1].size();i++)

	{

		int x=g[1][i];

		vis[x]=1;

		dfs(x);

		vis[x]=0;

	}

	cout<<num<<endl;

	

	return 0;

}


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

#include <algorithm>

int s[10][10],v,e,t1,t2;

using namespace std;

main()

{

    scanf("%d %d",&v,&e);

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

    {

        scanf("%d %d",&t1,&t2);

        s[t1][t2]=1;

        s[t2][t1]=1;

    }

    int arr[v];

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

    {

        arr[i]=i+1;

    }

    bool p=true;

    int cnt=0;

    do

    {

        p=true;

        if(arr[0]!=1) break;

        for (int i=0;i<v-1;i++)

        {

            if(s[arr[i]][arr[i+1]]==1);

            else

            {

                p=false;

                break;

            }

        }

        if(p==true) cnt++;

    }while (next_permutation(arr,arr+v));

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

}


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

#include <algorithm>

#include <list>

using namespace std;

list <int> to[9];

int arr[9];

int node,edge;

int ans=0;

int where(int in,int what)

{

    for (list<int>::iterator it = to[in].begin();it!=to[in].end();it++)

    {

        if (*it == what)

        {

            return 1;

        }

    }

    return 0;

}

void calcu(int arr[])

{

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

    {

        if (where(arr[i],arr[i+1])==0)

        {

            return;

        }

    }

    ans++;

    return;

}

main()

{

    scanf("%d %d",&node,&edge);

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

    {

        int one,two;

        scanf("%d %d",&one,&two);

        to[one].push_back(two);

        to[two].push_back(one);

    }

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

    {

        arr[i]=i;

    }

    do

    {

        calcu(arr);

    }

    while (next_permutation(arr+2,arr+node+1));

    printf("%d",ans);

}


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

#include <algorithm>

int s[10][10],v,e,t1,t2;

using namespace std;

main()

{

    scanf("%d %d",&v,&e);

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

    {

        scanf("%d %d",&t1,&t2);

        s[t1][t2]=1;

        s[t2][t1]=1;

    }

    int arr[v];

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

    {

        arr[i]=i+1;

    }

    bool p=true;

    int cnt=0;

    do

    {

        p=true;

        if(arr[0]!=1) break;

        for (int i=0;i<v-1;i++)

        {

            if(s[arr[i]][arr[i+1]]==1);

            else

            {

                p=false;

                break;

            }

        }

        if(p==true) cnt++;

    }while (next_permutation(arr,arr+v));

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

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

#define pp pair<int,int>

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

#define ll long long

#define ld long double

#define al(a) (a).begin(),(a).end()

#define mk make_pair

ll MOD=1000000007;

ll mod=998244353;

int inf=1000001000;

ll INF=1e18+5;



int main() {

  int n,m,ans=0; cin>>n>>m;

  vector<vector<int>> path(n);

  vector<int> p;

  rep(i,n) p.push_back(i);

  rep(i,m){

    int a,b; cin>>a>>b;

    a--; b--;

    path[a].push_back(b);

    path[b].push_back(a);

  }

    do{

      if(p[0]!=0) break;

      

      int ju=0;

      rep(i,n-1){

        ju=0;

        for(auto q : path[p[i]]) if(q==p[i+1]) ju=1;

        if(ju!=1) break; 

        if(i==n-2) ans++;

      }

    } while(next_permutation(al(p)));

  

  cout<<ans<<endl;

}


// Optimized solution to the same problem (faster):
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define pp pair<int,int>

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

#define ld long double

#define al(a) (a).begin(),(a).end()

#define mk make_pair

#define check cout<<"?"<<endl;



ll MOD=1000000007;

ll mod=998244353;

int inf=1000001000;

ll INF=1e18+5;



int main(){

    int n,m,ans=0; cin>>n>>m;

    set<pp> path;

    rep(i,m){

        int a,b; cin>>a>>b;

        a--; b--;

        path.insert(mk(a,b));

        path.insert(mk(b,a));

    }

    vector<int> v(n,0);

    rep(i,n) v[i]=i+1;

    do{

        if(v[0]!=1) break;

        int d=1;

        rep(i,n-1){

            if(!(path.count(mk(v[i]-1,v[i+1]-1)))) d=0;

        }

        if(d) ans++;

    }while(next_permutation(al(v)));

    cout<<ans<<endl;

}

// 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++)



using namespace std;

typedef long long ll;



using Graph = vector<vector<int>>;

typedef pair<int, int> P;



int N,M;



bool check(Graph G, vector<int> v){

    rep(i,N-1){

        if(!G[v[i]][v[i+1]]){

            return false;

        }

    }

    return true;

}



int main(){

    cin >> N >> M;

    Graph G(N,(vector<int>(N,0)));

    rep(i,M) {

        int a,b;

        cin >> a >> b;

        a--;b--;

        G[a][b] = G[b][a] = 1;

    }

    vector<int> v(N);

    rep(i,N) v[i] = i;

    long long ans = 0;

    do{

        if(v[0]==0 && check(G, v)) ans++;

    }while(next_permutation(v.begin(), v.end()));

    cout << ans << endl;

}




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

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

using namespace std;





int main() {

    int N, M;

    cin >> N >> M;

    vector<vector<bool>> path(N, vector<bool>(N, false));



    rep(i, M){

        int x, y;

        cin >> x >> y;

        x--; y--;

        path[x][y] = path[y][x] = true;

    }

    vector<int> v(N);

    rep(i, N) v[i] = i;



    int ans = 0;



    do{

        

        if (v[0]!=0) continue;

        bool flag = true;

        rep(i, N-1) {

            if (!path[v[i]][v[i+1]]) {

                flag = false;

                break;

            }

        }

        if(flag) ans++;

    }while(next_permutation(v.begin(), v.end()));



    cout << ans << endl;

}


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

#include <string>

#include <cstring>

#include <stdlib.h>

#include <math.h>

#include <algorithm>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <iterator>

#pragma warning(disable:4996)

 

typedef long long ll;

#define MIN(a, b) ((a)>(b)? (b): (a))

#define MAX(a, b) ((a)<(b)? (b): (a))

#define LINF 9223372036854775807

#define INF 2147483647

#define MOD 1000000007

using namespace std;



long n,m;

vector<vector<long> > z;

long vis[10];

long cnt;

ll   ans;



void dfs( long curr )

{

    if(cnt==n) {

        ans++;

        return;

    }



    long i;

    for(i=0; i<(long)z[curr].size(); i++) {

        if(!vis[z[curr][i]]) {

            vis[z[curr][i]]=1;

            cnt++;

            dfs( z[curr][i] );

            vis[z[curr][i]]=0;

            cnt--;

        }

    }

    return;

}



int main(int argc, char* argv[])

{

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



    z.resize(n);

    long i;

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

        long a, b;

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

        z[a-1].push_back(b-1);

        z[b-1].push_back(a-1);

    }



    ans=0;

    vis[0]=1;

    cnt = 1;

    dfs( 0 );



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



    return 0;

}


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

#include <string>

#include <cstring>

#include <stdlib.h>

#include <math.h>

#include <algorithm>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <list>

#include <iterator>

#include <assert.h>

#pragma warning(disable:4996) 



typedef long long ll;

#define MIN(a, b) ((a)>(b)? (b): (a))

#define MAX(a, b) ((a)<(b)? (b): (a))

#define LINF 9223300000000000000

#define INF 2140000000

const long long MOD = 1000000007;

using namespace std;



ll dp[1<<8][8];



int main(int argc, char* argv[])

{

    int n,m;

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



    int g[8][8]={0};

    int i;

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

        int a,b;

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

        g[a-1][b-1]=1;

        g[b-1][a-1]=1;

    }



    dp[1][0]=1;

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

        int k;

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

            if(i & (1<<k)) {

                int prev = (i & ~(1<<k));

                int j;

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

                    if(dp[prev][j] && (prev & (1<<j)) && g[k][j]) {

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

                    }

                }

            }

        }

    }

    ll ans=0;

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

        ans += dp[(1<<n)-1][i];

    }

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



    return 0;

}


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

#include <vector>

#include <algorithm>

#include <cmath>

#include <queue>

#include <limits>

#include <map>

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

#define IREP(i,j,n) for(int (i)=(j);(i)<(n);(i)++)

#define INF numeric_limits<double>::infinity()

constexpr long MOD = 1e9 + 7;

using namespace std;



int n, m;

vector<int> adj[10];



bool connected(int i, int j) {

    int f = false;

    REP(k,adj[i].size()) {

        if (adj[i][k] == j) f = true;

    }

    return f;

}



int main() {

    cin >> n >> m;

    int a, b;

    REP(i,m) {

        cin >> a >> b;

        a--;

        b--;

        adj[a].push_back(b);

        adj[b].push_back(a);

    }

    

    int cnt = 0;

    vector<int> v;

    REP(i,n) {

        v.push_back(i);

    }

    

    do {

        int c = true;

        REP(i,v.size()-1) {

            if (!connected(v[i], v[i+1])) {

                c = false;

            }

        }

        if (v[0] == 0 && c) cnt++;

    } while (next_permutation(v.begin(), v.end()));

    

    cout << cnt << endl;

}


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

using namespace std;



int main() {

    int n, m;

    cin >> n >> m;

    set<pair<int, int>> edges;

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

        int a, b;

        cin >> a >> b;

        edges.insert({min(a, b), max(a, b)});

    }



    int cnt = 0;

    vector<int> perm(n - 1);

    iota(perm.begin(), perm.end(), 2);



    do {

        bool ok = true;

        vector<int> path = {1};

        for (int v : perm) {

            path.push_back(v);

        }

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

            int a = path[i], b = path[i + 1];

            if (edges.count({min(a, b), max(a, b)}) == 0) {

                ok = false;

                break;

            }

        }

        if (ok) cnt++;

    } while (next_permutation(perm.begin(), perm.end()));



    cout << cnt << '\n';

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

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

#define all(v) v.begin(), v.end()

using ll = long long;

using vi = vector<int>;

using pii = pair<int, int>;



int main()

{

    int n, m;

    cin >> n >> m;

    vector<vi> g(n, vi(n));

    rep(i, m)

    {

        int a, b;

        cin >> a >> b;

        a--;

        b--;

        g[a][b] = g[b][a] = 1;

    }

    vi p(n);

    rep(i, n)

    {

        p[i] = i + 1;

    }

    int ans = 0;

    do

    {

        if (p[0] != 1)

            break;

        bool flag = true;

        rep(i, n - 1)

        {

            if (g[p[i] - 1][p[i + 1] - 1] == 0)

                flag = false;

        }

        if (flag)

            ans++;

    } while (next_permutation(all(p)));

    cout << ans << endl;

}

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

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

using namespace std;

using ll = long long;

using P = pair<int, int>;



int main()

{

  int n, m;

  cin >> n >> m;

  vector<vector<int>> vec(n + 1, vector<int>(n + 1));

  rep(i, m)

  {

    int a, b;

    cin >> a >> b;

    vec[a][b] = 1;

    vec[b][a] = 1;

  }

  vector<int> v(n);

  rep(i, n) v[i] = i + 1;

  int ans = 0;

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

  do

  {

    if (v[0] != 1)

      break;

    bool ok = true;

    rep(i, n - 1)

    {

      if (vec[v[i]][v[i + 1]] == 0)

        ok = false;

    }

    if (ok)

      ans++;

  } while (next_permutation(v.begin(), v.end()));

  cout << ans << endl;

  return 0;

}

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

#include <iostream>



using namespace std;



int N, M;

bool e[8][8];

int ans = 0;

int p[8];



void dfs(int pos, int mask) {

		if (pos == N) {

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

						if (p[0] != 0) return;

						else if (!e[p[i]][p[i+1]]) return;

				}

				ans++;

				return;

		}



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

				if (mask & (1<<i)) {

						p[pos] = i;

						dfs(pos+1, (mask^(1<<i)));

				}

		}

}



int main() {

		cin >> N >> M;

		vector<int> v[N];

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

				int a, b;

				cin >> a >> b;

				a--; b--;

				e[a][b] = true;

				e[b][a] = true;

		}



		dfs(0, (1<<N) - 1);

		cout << ans << endl;

		return 0;

}


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

#include <vector>



using namespace std;



int N, M;

vector<int> e[8];

int ans = 0;



void dfs(int pos, int visited) {

		visited |= (1<<pos);

		if (__builtin_popcount(visited) == N) {

				ans++;

				return;

		}



		for (auto itr = e[pos].begin(); itr < e[pos].end(); itr++) {

				if (visited & (1<<(*itr))) continue;

				dfs(*itr, visited);

		}

}



int main() {

		cin >> N >> M;

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

				int a, b;

				cin >> a >> b;

				a--; b--;

				e[a].push_back(b);

				e[b].push_back(a);

		}



		dfs(0, 0);



		cout << ans << endl;



		return 0;

}


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

#include<cstdio>

#include<cstring>

#include <cstdlib>  

#include <cmath>   

#include<cctype>

#include<string>

#include <map>

#include<algorithm>

#include <functional>

#include<vector>

#include<climits>

#include<stack>

#include<queue>

#include <deque>

#include <utility> 



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

using namespace std;

using ll = long long;

using R = double;

const ll inf = 1LL << 50;

const ll MOD = 1e9 + 7;











int main(){

	vector< pair<int, int> > edge;

	

	int n, m;

	cin >> n >> m;



	

	rep(i, 0, m) {

		int a, b;

		cin >> a >> b;

		auto p1 = make_pair(a, b);

		auto p2 = make_pair(b, a);

		edge.push_back(p1);

		edge.push_back(p2);



	}



	vector<int> node;

	rep(i, 1, n + 1) {

		node.push_back(i);

	}





	int ans = 0;

	do {

		int match = 0;

		rep(i, 0, n - 1) {

			int from = node[i];

			int to = node[i + 1];

			for (auto x : edge) {

				if (from == x.first && to == x.second) {

					match++;

				}

			}

		}

		if (match == n - 1 && node[0]==1)ans++;

	} while (next_permutation(node.begin(), node.end()));



	cout << ans << endl;

	









	return 0;

}

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

#include<cstdio>

#include<cstring>

#include <cstdlib>  

#include <cmath>   

#include<cctype>

#include<string>

#include <map>

#include<algorithm>

#include <functional>

#include<vector>

#include<climits>

#include<stack>

#include<queue>

#include <deque>

#include <utility> 



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

using namespace std;

using ll = long long;

using R = double;

const ll inf = 1LL << 50;

const ll MOD = 1e9 + 7;





bool graph[8][8];





int dfs(int v, int n, bool visited[8]) {

	bool all_visited = true;

	rep(i, 0, n) {

		if (visited[i] == false)

			all_visited = false;

	}



	if (all_visited)return 1;





	int ret=0;

	rep(i, 0, n) {

		if (visited[i] == true)continue;

		if (graph[v][i] == false)continue;



		visited[i] = true;

		ret += dfs(i,n,visited);

		//次の頂点に移る前にvisitedを初期化

		visited[i] = false;

	}



	return ret;



}





int main(){

	int n, m;

	cin >> n >> m;



	rep(i, 0, m) {

		int a, b;

		cin >> a >> b;

		graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;

	}



	bool visited[8];

	rep(i, 0, n)visited[i] = false;



	visited[0] = true;

	cout << dfs(0, n, visited) << endl;

	return 0;

}




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

using namespace std;

#define ll long long

#define all(x) (x).begin(),(x).end()

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

const ll INF = 100100100100;





ll combination(ll n, ll r){

    if(n < r) return 0;

    if(r == 0||r == n) return 1;

    else if(r == 1) return n;

    return (combination(n - 1, r - 1) + combination(n - 1, r));

}



bool checkKaibun(string str){

    string checkStr = str;

    reverse(checkStr.begin(), checkStr.end());

    if(str == checkStr) return true;

    else return false;

}



int keta(ll num){

    int digits = 0;

    while(num > 0){

        num /= 10;

        digits++;

    }

    return digits;

}





int main(){

    int N, M;

    cin >> N >> M;

    vector<int> a(2 * M), b(2 * M);

    rep(i, M) cin >> a.at(i) >> b[i];

    rep(i, M) a.at(i + M) = b.at(i);

    rep(i, M) b.at(i + M) = a.at(i);

    vector<int> order(N);

    rep(i, N) order[i] = i + 1;

    int ans = 0;

    do{//すべての周り方を調べて道がつながっているのか調べる。

        bool flag = true;

        rep(i, N - 1){

            auto itr = a.begin();

            while(1){

                itr = find(itr, a.end(), order[i]);

                if(itr == a.end()){

                    flag = false;

                    break;

                }

                int index = itr - a.begin();

                if(b[index] == order[i + 1]){

                    break;

                }

                itr++;

            }

        }

        if(flag == true && order[0] == 1){

            ans++;

        }

    }while(next_permutation(all(order)));

    cout << ans << endl;

}

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

#include<unordered_map>

using namespace std;

using Graph = vector<vector<int>>;

#define ll long long

#define all(x) (x).begin(),(x).end()

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

const ll INF = 1LL << 60;



vector<bool> seen;

int ans = 0;



void dfs(Graph &G, int v){

    seen[v] = true;

    int test = 0;

    rep(i, seen.size())if(seen[i] == true) test++;

    if(test == seen.size())ans++;

    for(auto x: G[v]){

        if(seen[x] == true)continue;

        dfs(G, x);

        seen[x] = false;

    }

}



int main(){

    int N, M;

    cin >> N >> M;

    Graph g(N);

    rep(i, M){

        int a, b;

        cin >> a >> b;

        a--;

        b--;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    for(auto x: g[0]){

        seen.assign(N, false);

        seen[0] = true;

        dfs(g, x);

    }

    cout << ans << endl;



}


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

#include <vector>

#include <algorithm>



using namespace std;



bool check_edge(vector<int> vv, int i, vector<int> e) {

    if(min(vv[i], vv[i+1])==e[0] && max(vv[i], vv[i+1])==e[1]) return true;

    else return false;

}



int main() {

    int N, M;

    cin >> N >> M;

    vector<vector<int> > edge(M, vector<int>(2));

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

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

            cin >> edge[i][j];

        }

    }

    

    vector<int> v(N);

    

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

        v[i] = i+1;

    }



    int ans=0;

    bool flag;



    do {

        if(v[0]!=1) continue;

        for(int j=0; j<N-1; j++) {

            flag=false;

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

                if(check_edge(v, j, edge[k])) {

                    flag=true;

                    break;

                }

            }

            if(flag) continue;

            else break;

        }

        

        if(flag) ans++;



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

        //     cout << v[i] << " ";

        // }

        // cout << endl;



        

        

    } while(next_permutation(v.begin(), v.end()));



    cout << ans << endl;



    return 0;

    

}

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

#include <vector>

#include <algorithm>



using namespace std;



typedef vector<vector<int> > Graph;

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



int main() {

    int N, M;

    cin >> N >> M;

    

    Graph G(N, vector<int>(N, 0));

    rep(i, M) {

        int u, v;

        cin >> u >> v;

        u--;

        v--;

        

        G[u][v] = 1;

        G[v][u] = 1;

    }

    

    int array[N-1];

    rep(i, N-1) {

        array[i] = i+1;

    }



    int ans=0;

    

    do {

        int st = 0;

        bool flag;

        

        rep(i, N-1) {

            flag=false;

            if(G[st][array[i]]) flag=true;

            if(!flag) break;

            st = array[i];

        }

        

        if(flag) ans++;

        

    } while(next_permutation(array, array+N-1));



    cout << ans << endl;



    return 0;

    

}

// Fastest known solution for this problem: