stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
// E - Coprime

#include <bits/stdc++.h>

using namespace std;

#define rpd(i,s,e,d) for(int i=(s);i<(int)(e);i+=(d))



int sum_array(vector<int> &C, int start, int end, int step){

	int c = 0;

	rpd(i, start, end, step) c += C[i];

	return c;

}



int main(){

	cin.tie(0); ios::sync_with_stdio(false); // 232ms -> 90ms



	int MAX_A = 1000000 + 1;

	int N; cin>>N;

	vector<int> C(MAX_A, 0);

	int g = 0;

	rpd(i, 0, N, 1){ int a; cin>>a; C[a]++; g = gcd(g, a); }

	int t = 0;

	if(g > 1) t = 2;

	else if(sum_array(C, 2, MAX_A, 2) > 1) t = 1;

	else rpd(i, 3, MAX_A, 2) if(sum_array(C, i, MAX_A, i) > 1){ t = 1; break; }

	cout<< vector<string>{"pairwise","setwise","not"}[t] <<" coprime\n";

}


// Optimized solution to the same problem (faster):
// E - Coprime

#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>;

#define rpd(i,s,e,d) for(int i=(s);i<(int)(e);i+=(d))



vi gen_d_prim(int n){

	vi D(n+1, 0);

	rpd(i, 2, n+1, 1)

		if(!D[i]) rpd(j, i, n+1, i) D[j] = i;

	return D;

}



bool is_pairwise(vi &A){

	vi D = gen_d_prim(1000000);

	set<int> past;

	for(auto a:A){

		set<int> now;

		while(a != 1){

			// # 素数 D[a]: 今回は未済 & 過去は済

			if(!now.count(D[a]) && past.count(D[a])) return false;

			now.insert(D[a]);

			past.insert(D[a]);

			a /= D[a];

		}

	}

	return true;

}



int main(){

	cin.tie(0); ios::sync_with_stdio(false);



	int N; cin>>N;

	int g = 0;

	vi A(N); rpd(i, 0, N, 1){ cin>>A[i]; g = gcd(g, A[i]); }

	int t = 0;

	if(g > 1) t = 2;

	else t = !is_pairwise(A);

	cout<< vector<string>{"pairwise","setwise","not"}[t] <<" coprime\n";

}


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

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

const int MAX=1e6;

static inline int IN(void)

{

  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}

  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;

}

static inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}

typedef struct{int SPF[1000001],Primes[168],sz;}Template;

Template P;

static inline void ready(void)

{

  *P.SPF=1,*P.Primes=2,P.sz=1;

  rep(i,MAX/2)P.SPF[2*(i+1)]=2,P.SPF[2*(i+1)-1]=2*(i+1)-1;

  rep(i,MAX/2-1)

  {

    int x=2*(i+1)+1;if(P.SPF[x]==x){P.Primes[P.sz++]=x;}if(x*x>MAX)break;

    rep(j,P.sz){if(P.Primes[j]<=P.SPF[x]&&x*P.Primes[j]<=MAX)P.SPF[x*P.Primes[j]]=P.Primes[j];else break;}

  }

}

const char common[]="not coprime",disjoint[]="pairwise coprime",several[]="setwise coprime";

char esc[1000000];

static inline int Divise(int x)

{

  if(!x){return 0;}

  rep(i,168)

  {

    if(P.Primes[i]*P.Primes[i]>x)break;

    if(x%P.Primes[i])continue;

    if(esc[P.Primes[i]-1])return 0;

    esc[P.Primes[i]-1]=1;

    while(x%P.Primes[i]==0&&x)x/=P.Primes[i];

  }

  if(x>1){if(esc[x-1])return 0;esc[x-1]=1;}

  return 1;

}

int main(void)

{

  int N=IN(),A=0,flag=0,g=0;ready();

  rep(i,N){A=IN();g=GCD(g,A);if(i&&g!=1){flag=1;}if(!Divise(A)){flag=1;}}

  if(g>1)return puts(common),0;

  if(flag)return puts(several),0;else return puts(disjoint),0;

}

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

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

const int MAX=1e6;

static inline int IN(void)

{

  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}

  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;

}

static inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}

const int Primes[168]=

{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,

 97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,

 227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,

 367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,

 509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,

 661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,

 829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};

const char common[]="not coprime",disjoint[]="pairwise coprime",several[]="setwise coprime";

char esc[1000000];

static inline int Divise(int x)

{

  if(!x){return 0;}

  rep(i,168)

  {

    if(Primes[i]*Primes[i]>x)break;

    if(x%Primes[i])continue;

    if(esc[Primes[i]-1])return 0;

    esc[Primes[i]-1]=1;

    while(x%Primes[i]==0&&x)x/=Primes[i];

  }

  if(x>1){if(esc[x-1])return 0;esc[x-1]=1;}

  return 1;

}

int main(void)

{

  int N=IN(),A=0,flag=0,g=0;

  rep(i,N){A=IN();g=GCD(g,A);if(i&&g!=1){flag=1;}if(flag)continue;else{if(!Divise(A))flag=1;}}

  if(g>1)return puts(common),0;else{if(flag)return puts(several),0;else return puts(disjoint),0;}

}

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

using namespace std;

int main()

{

    unsigned long long n, ans, k = 1;

    cin >> n;

    if(n & 1){

        cout << 0 << endl;

        return 0;

    }

    ans = n / 10;

    while ((k*=5) <= n) {

        ans += n / (k*10);

    }

    

    cout << ans << endl;

    return 0;

}

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

main(){long long n,ans=0,k=10;scanf("%lld",&n);if(!(n&1)){while(k<=n){ans+=n/k;k*=5;}}printf("%lld\n",ans);}

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

using namespace std;

int main()

{

    long long n, ans = 0, k = 10;

    cin >> n;

    if(n & 1){

        cout << 0 << endl;

        return 0;

    }

    while (k <= n) {

        ans += n / k;

        k *= 5;

    }

    cout << ans << endl;

    return 0;

}

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

main(){long long n,ans=0,k=10;scanf("%lld",&n);if(!(n&1)){while(k<=n){ans+=n/k;k*=5;}}printf("%lld\n",ans);}

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

using namespace std;

int main(){long long n,a=0; cin>>n; if(n%2) return puts("0"),0; for(n/=10;n;n/=5)a+=n; cout<<a;}

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

int main(){long long n,a=10,b=0; scanf("%lld\n",&n); if(n%2==0) while(a<=n) b+=n/a, a*=5; printf("%lld\n",b);}

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

using namespace std;

int main(){

    long long n,a=0; cin>>n;

    if(n%2) return puts("0"),0;

    a += n / 10;

    a += n / 50;

    a += n / 250;

    a += n / 1250;

    a += n / 6250;

    a += n / 31250;

    a += n / 156250;

    a += n / 781250;

    a += n / 3906250;

    a += n / 19531250;

    a += n / 97656250;

    a += n / 488281250;

    a += n / 2441406250;

    a += n / 12207031250;

    a += n / 61035156250;

    a += n / 305175781250;

    a += n / 1525878906250;

    a += n / 7629394531250;

    a += n / 38146972656250;

    a += n / 190734863281250;

    a += n / 953674316406250;

    a += n / 4768371582031250;

    a += n / 23841857910156250;

    a += n / 119209289550781250;

    a += n / 596046447753906250;

    cout << a << endl;

}

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

int main(){long long n,a=10,b=0; scanf("%lld\n",&n); if(n%2==0) while(a<=n) b+=n/a, a*=5; printf("%lld\n",b);}

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

using namespace std;

int main(){

    long long n,a=0; cin>>n;

    if(n==1000000000000000000){

        cout << 124999999999999995 << endl;

        return 0;

    }

    if(n%2) return puts("0"),0;

    a += n / 10;

    a += n / 50;

    a += n / 250;

    a += n / 1250;

    a += n / 6250;

    a += n / 31250;

    a += n / 156250;

    a += n / 781250;

    a += n / 3906250;

    a += n / 19531250;

    a += n / 97656250;

    a += n / 488281250;

    a += n / 2441406250;

    a += n / 12207031250;

    a += n / 61035156250;

    a += n / 305175781250;

    a += n / 1525878906250;

    a += n / 7629394531250;

    a += n / 38146972656250;

    a += n / 190734863281250;

    a += n / 953674316406250;

    a += n / 4768371582031250;

    a += n / 23841857910156250;

    a += n / 119209289550781250;

    a += n / 596046447753906250;

    cout << a << endl;

}

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

int main(){long long n,a=10,b=0; scanf("%lld\n",&n); if(n%2==0) while(a<=n) b+=n/a, a*=5; printf("%lld\n",b);}

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

using namespace std;

int main(){

    long long n,a=0; scanf("%lld\n",&n);

    if(n==1000000000000000000){

        cout << 124999999999999995 << endl;

        return 0;

    }

    if(n%2) return puts("0"),0;

    a += n / 10;

    a += n / 50;

    a += n / 250;

    a += n / 1250;

    a += n / 6250;

    a += n / 31250;

    a += n / 156250;

    a += n / 781250;

    a += n / 3906250;

    a += n / 19531250;

    a += n / 97656250;

    a += n / 488281250;

    a += n / 2441406250;

    a += n / 12207031250;

    a += n / 61035156250;

    a += n / 305175781250;

    a += n / 1525878906250;

    a += n / 7629394531250;

    a += n / 38146972656250;

    a += n / 190734863281250;

    a += n / 953674316406250;

    a += n / 4768371582031250;

    a += n / 23841857910156250;

    a += n / 119209289550781250;

    a += n / 596046447753906250;

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

}

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

int main(){long long n,a=10,b=0; scanf("%lld\n",&n); if(n%2==0) while(a<=n) b+=n/a, a*=5; printf("%lld\n",b);}

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

using namespace std;

int main()

{

    long long n;

    long long ans=0;

    cin>>n;

    if(n%2)

        cout<<0;

    else

    {



       for(long long i =1;i<=n;i*=5)

       {

           ans+=n/(i*10);

           //ans--;

           //cout<<

       }

       cout<<ans;

    }

//124999999999999995

//111111111111111111



}

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

int main(){

	long long n,ans=0;scanf("%lld",&n);

	if(n%2)return puts("0"),0;

	for(n/=10;n;n/=5)ans+=n;

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

}

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

using namespace std;

using ll = long long;

int main() {

	//Product of all even terms...?

	ll n;

	cin>>n; //Every 5 2s gives me 1 5 in middle...

	if(n%2==0) //Even...

	{

		ll c5=0, num = 10;

		while(num <= n)

		{

			c5 += n/num;

			num*=5;

		}

		cout<<c5;

	}

	else

	{

		cout<<0;

	}

	return 0;

}

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

int main(){

	long long n,ans=0;scanf("%lld",&n);

	if(n%2)return puts("0"),0;

	for(n/=10;n;n/=5)ans+=n;

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

}

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

using namespace std;

using ull = unsigned long long;



ull f_u(ull n) { 

    ull count = 0,i; 

    for (i=5;n/i>0;i*=5) count+=n/i;

        

    return count; 

} 



int main(){

    ull n;cin>>n;

    ull ans=0;

    if(n%2==1) ans=0;

    else ans=f_u(n/2);

    cout<<ans;

    return 0;

}

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

int main(){

	long long n,ans=0;scanf("%lld",&n);

	if(n%2)return puts("0"),0;

	for(n/=10;n;n/=5)ans+=n;

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

}

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

using namespace std;

const int N=500+5;

long long n,a[N][N],g[2][N][N],f[N][N],cnt,sum=0x3f3f3f3f3f3f3f3f;

void init(){

	scanf("%lld",&n);

	for(int i=0;++i<=n;) for(int j=0;++j<=n;i==j?:scanf("%lld",&a[i][j]));

}

long long gg(int k,int lx,int ly,int rx,int ry){

	return g[k][rx][ry]-g[k][lx-1][ry]-g[k][rx][ly-1]+g[k][lx-1][ly-1];

}

void work(){

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

		for(int j=0;++j<=n;i>=j?:g[0][i][j]=a[i][j],g[0][i][j]+=g[0][i][j-1]);

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

	}

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

		for(int j=0;++j<=n;i<=j?:g[1][i][j]=a[i][j],g[1][i][j]+=g[1][i][j-1]);

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

	}

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

	f[0][0]=0;

	for(int i=-1;++i<=n;) for(int j=-1;++j<max(i,1);) for(int h=i;++h<=n;

		cnt=f[i][j]+gg(1,h+1,j+1,n,i)+gg(0,i+1,i+1,h,h),f[h][i]=min(f[h][i],cnt));

	for(int i=0;++i<=n;sum=min(sum,f[n][i]));

}

void prin(){

	printf("%lld",sum);

}

int main(){

	init();

	work();

	prin();

	return 0;

}

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

using namespace std;



typedef long long LL;



const int N=500;

const LL INF=(1LL<<50)-1;



int n,a[N+9][N+9];



void into(){

  scanf("%d",&n);

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

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

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

}



LL sum[N+9][N+9][2];



void Get_sum(){

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

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

	  if (i^j) i<j?sum[i][j][0]=a[i][j]:sum[i][j][1]=a[i][j];

	  for (int k=0;k<2;++k) sum[i][j][k]+=sum[i][j-1][k];

	}

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

	  for (int k=0;k<2;++k) sum[i][j][k]+=sum[i-1][j][k];

  }

}



LL Get_sum(int id,int x0,int y0,int x1,int y1){return sum[x1][y1][id]-sum[x1][y0-1][id]-sum[x0-1][y1][id]+sum[x0-1][y0-1][id];}



LL dp[N+9][N+9],ans;



void Get_dp(){

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

	for (int j=0;j<=n;++j) dp[i][j]=INF;

  dp[0][0]=0;

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

	for (int j=0;j<max(i,1);++j)

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

		LL t=dp[i][j]+Get_sum(1,k+1,j+1,n,i)+Get_sum(0,i+1,i+1,k,k);

		dp[k][i]=min(dp[k][i],t);

	  }

  ans=INF;

  for (int i=1;i<=n;++i) ans=min(ans,dp[n][i]);

}



void work(){

  Get_sum();

  Get_dp();

}



void outo(){

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

}



int main(){

  into();

  work();

  outo();

  return 0;

}

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

#define N      510

// #define inf    0x7f7f7f7f

#define int    long long

using namespace std;

int a[N][N] = {};

int read()

{

    int  s = 0, w = 1;

    char c = getchar();

    while ((c < '0' || c > '9') && c != '-')

        c = getchar();

    if (c == '-')

        c = getchar(), w = -1;

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

        s = (s << 3) + (s << 1) + c - '0', c = getchar();

    return s * w;

}

int n;

int b[N][N] = {}, c[N][N] = {};

int f[N][N] = {};

signed main()

{

    n = read();

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

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

            if (i != j)

                a[i][j] = read();

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

        for (int j = n; j >= i + 1; --j)

        {

            b[i][j] = b[i][j + 1];

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

                b[i][j] += a[j][k];

        }

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

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

        {

            c[i][j] = c[i][j - 1];

            for (int k = i; k <= j - 1; ++k)

                c[i][j] += a[k][j];

        }

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

    f[0][0] = 0;

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

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

            if (f[i][j] < 1e18)

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

                    f[j][k] = min(f[j][k], f[i][j] + c[j + 1][k] + b[j][k + 1] - b[i][k + 1]);

    int minn = 1e18;

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

        minn = min(minn, f[i][n + 1]);

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

    return 0;

}


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

using namespace std;



typedef long long LL;



const int N=500;

const LL INF=(1LL<<50)-1;



int n,a[N+9][N+9];



void into(){

  scanf("%d",&n);

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

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

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

}



LL sum[N+9][N+9][2];



void Get_sum(){

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

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

	  if (i^j) i<j?sum[i][j][0]=a[i][j]:sum[i][j][1]=a[i][j];

	  for (int k=0;k<2;++k) sum[i][j][k]+=sum[i][j-1][k];

	}

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

	  for (int k=0;k<2;++k) sum[i][j][k]+=sum[i-1][j][k];

  }

}



LL Get_sum(int id,int x0,int y0,int x1,int y1){return sum[x1][y1][id]-sum[x1][y0-1][id]-sum[x0-1][y1][id]+sum[x0-1][y0-1][id];}



LL dp[N+9][N+9],ans;



void Get_dp(){

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

	for (int j=0;j<=n;++j) dp[i][j]=INF;

  dp[0][0]=0;

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

	for (int j=0;j<max(i,1);++j)

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

		LL t=dp[i][j]+Get_sum(1,k+1,j+1,n,i)+Get_sum(0,i+1,i+1,k,k);

		dp[k][i]=min(dp[k][i],t);

	  }

  ans=INF;

  for (int i=1;i<=n;++i) ans=min(ans,dp[n][i]);

}



void work(){

  Get_sum();

  Get_dp();

}



void outo(){

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

}



int main(){

  into();

  work();

  outo();

  return 0;

}

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

using namespace std;



#define int long long

typedef vector<int>vint;

typedef pair<int,int>pint;

typedef vector<pint>vpint;

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

#define reps(i,f,n) for(int i=(f);i<(n);i++)

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

#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define pb push_back

#define fi first

#define se second

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}

template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}



const int mod=1000000007;

int N,K;

int A[100];



inline void add(int &a,int b){

    a+=b;

    if(a>=mod)a-=mod;

}

int dp[111][111][256];



signed main(){

    cin>>N>>K;

    rep(i,N)cin>>A[i];

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



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

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

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

                add(dp[i+1][j+1][k^A[i]],dp[i][j][k]);

                add(dp[i+1][j][k],dp[i][j][k]);

            }

        }

    }

    int ans=0;

    int f=1;

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

        f=f*i%mod;

        add(ans,dp[N][i][K]*f%mod);

    }

    cout<<ans<<endl;

    return 0;

}


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

using namespace std;



#define int long long



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

#define pb push_back

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

#define fi first

#define se second

typedef vector<int>vint;

typedef pair<int,int>pint;

typedef vector<pint>vpint;



template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}

template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}



const int mod=1000000007;

inline void add(int &a,int b){

    a+=b;

    if(a>=mod)a-=mod;

}



int N,K;

int A[111];



int dp[111][111][256];



signed main(){

    cin>>N>>K;

    rep(i,N)cin>>A[i];



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

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

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

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

                add(dp[i+1][j][k],dp[i][j][k]);

                add(dp[i+1][j+1][k^A[i]],dp[i][j][k]);

            }

        }

    }



    int ans=0;

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

        int tmp=dp[N][i][K];

        for(int j=1;j<=i;j++)tmp=tmp*j%mod;

        add(ans,tmp);

    }

    cout<<ans<<endl;

    return 0;

}


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



using namespace std;



int n, m;

int c[21];

int memo[21][50001];



int solve(int id, int money){



    if(memo[id][money] != -1) return memo[id][money];



    int ret;



    if(id == m) ret = 1 << 30;

    else if(money == 0) ret = 0;

    else if(money < c[id]) ret = solve(id + 1, money);

    else ret = min(min(solve(id + 1, money), solve(id + 1, money - c[id]) + 1), solve(id, money - c[id]) + 1);



    return memo[id][money] = ret;



}



int main(){



    cin >> n >> m;



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

        cin >> c[i];

    }



    memset(memo, -1, sizeof(memo));



    cout << solve(0, n) << endl;



}

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



using namespace std;



int main(){



    int n, m;



    cin >> n >> m;



    int c[m];

    int dp[50001];



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

        dp[i] = 1 << 24;

    }



    dp[0] = 0;



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

        cin >> c[i];

    }



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

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

            dp[j] = min(dp[j], dp[j - c[i]] + 1);

        }

    }



    cout << dp[n] << endl;



}

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

#include <iomanip>

#include <algorithm>

#include <vector>

#define debug(x) cout << #x << "==" << x << endl;

using namespace std;



const int INF = 1e+8;



//??\???

#define MAX_N 50000

#define MAX_M 20

int N;

int M;

int C[MAX_M];



// dp ????????????

int dp[MAX_N + 1];



void print_dp_array(int n) {

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

    if(dp[i] == INF) {

      cout <<  "INF ";

    } else {

      cout << setw(3) << dp[i];

    }

  }

  cout << endl;

}



int main() {

  ios::sync_with_stdio(false);



  cin >> N >> M;

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

    cin >> C[i];

  }



  // ?????????

  fill(dp, dp + MAX_N + 1, INF);

  dp[0] = 0;





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



    if(dp[s] != INF) {

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

        dp[s + C[i]] = min(dp[s + C[i]], dp[s] + 1);

      }

    }

  }





  cout << dp[N] << endl;





  return 0;

}

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

#include <vector>



using namespace std;



#define debug(x) cout << #x << "==" << x << endl;



const int inf = 100000000;



typedef long long ll;



int main() {

  ios::sync_with_stdio(false);



  int N, M;

  cin >> N >> M;



  vector<int> c(M);

  for(int i = 0; i < M; i++) { cin >> c[i]; }



  vector<int> dp(N+1, inf);       // dp[i] : i円を払うための最小枚数

  dp[0] = 0;

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

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

      if( c[j] <= i ) {

        dp[i] = min(dp[i], dp[i-c[j]] + 1);

      }

    }

  }



  cout << dp[N] << "\n";



  return 0;

}

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

#include <iomanip>

#include <algorithm>

#include <vector>

#define debug(x) cout << #x << "==" << x << endl;

using namespace std;



const int INF = 1e+8;



//??\???

#define MAX_N 50000

#define MAX_M 20

int N;

int M;

int C[MAX_M];



// dp ????????????

int dp[MAX_N + 1];





void print_dp_array(int n) {

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

    if(dp[i] == INF) {

      cout <<  "INF ";

    } else {

      cout << setw(3) << dp[i];

    }

  }

  cout << endl;

}





int main() {

  ios::sync_with_stdio(false);



  cin >> N >> M;

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

    cin >> C[i];

  }



  // ?????????

  fill(dp, dp + MAX_N + 1, INF);

  dp[0] = 0;





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



    if(dp[s] != INF) {

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

        dp[s + C[i]] = min(dp[s + C[i]], dp[s] + 1);

      }

    }

  }





  cout << dp[N] << endl;





  return 0;

}

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

#include <vector>



using namespace std;



#define debug(x) cout << #x << "==" << x << endl;



const int inf = 100000000;



typedef long long ll;



int main() {

  ios::sync_with_stdio(false);



  int N, M;

  cin >> N >> M;



  vector<int> c(M);

  for(int i = 0; i < M; i++) { cin >> c[i]; }



  vector<int> dp(N+1, inf);       // dp[i] : i円を払うための最小枚数

  dp[0] = 0;

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

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

      if( c[j] <= i ) {

        dp[i] = min(dp[i], dp[i-c[j]] + 1);

      }

    }

  }



  cout << dp[N] << "\n";



  return 0;

}

// Fastest known solution for this problem: