stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#pragma region 

#include<iostream>

#include<algorithm>

#include<vector>

#include<stack>

#include<queue>

#include<map>

#include<cstring>

#include<string>

typedef long long ll;

template <typename T>void read(T &x){x=0;char ch=getchar();ll f=1;while(!isdigit(ch)){if(ch=='-')f*=-1;ch=getchar();}while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}x*=f;}

#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;

#pragma endregion

const int maxn = 1e5 + 5;

int h[maxn];

vector<int> g[maxn];



int main() {

    IO;

    int n, m;

    cin >> n >> m;

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

        cin >> h[i];

    while (m--) {

        int x, y;

        cin >> x >> y;

        g[x].push_back(y);

        g[y].push_back(x);

    }

    int ans = 0;

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

        int flag = 1;

        for (auto v:g[i]) {

            if (h[i]<=h[v]) {

                flag = 0;

                break;

            }

        }

        ans += (flag == 1);

    }

    cout << ans << endl;

}

// Optimized solution to the same problem (faster):
/*

         ██╗ ██████╗ ██╗███╗   ██╗    ██╗   ██╗███████╗

         ██║██╔═══██╗██║████╗  ██║    ██║   ██║██╔════╝

         ██║██║   ██║██║██╔██╗ ██║    ██║   ██║███████╗

    ██   ██║██║   ██║██║██║╚██╗██║    ██║   ██║╚════██║

    ╚█████╔╝╚██████╔╝██║██║ ╚████║    ╚██████╔╝███████║

     ╚════╝  ╚═════╝ ╚═╝╚═╝  ╚═══╝     ╚═════╝ ╚══════╝

*/

//password:+BdCHpO8dQvpo5fnV3/u

#include<bits/stdc++.h>



using namespace std;

typedef long long ll;

const int maxn = 5e5 + 5;

const int inf = 0x3f3f3f3f;





int main() {

    int n,m;

    cin>>n>>m;

    vector<int>h(n+1);

    for(int i=1;i<=n;i++) cin>>h[i];

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

    map<pair<int,int>,int>qaq;

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

    {

        int x,y;

        cin>>x>>y;

        qaq[make_pair(x,y)]++;

        qaq[make_pair(y,x)]++;

    }

    for(auto it:qaq) {

            if(h[it.first.first]>h[it.first.second]) good[it.first.second]=0;

            else if(h[it.first.first]<h[it.first.second]) good[it.first.first]=0;

            else good[it.first.first]=0,good[it.first.second]=0;

    }

    int ans=0;

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

        if(good[i]) ans++;

    }

    cout<<ans;

    return 0;

}

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

using namespace std;

#define int long long

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

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

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

#define P pair<int,int>

#define len(s) (int)s.size()

#define pb push_back



template<class T> inline bool chmin(T &a, T b) {

	if (a > b) {

		a = b;

		return true;

	}

	return false;

}

template<class T> inline bool chmax(T &a, T b) {

	if (a < b) {

		a = b;

		return true;

	}

	return false;

}

void cmps(vector<int>&v,int &i){

	i=lower_bound(all(v),i)-v.begin();

}

constexpr int mod = 1e9+7;

constexpr int inf = 3e18;



int N,M;

int A[100005];

vector<int>G[100005];

signed main(){

	cin>>N>>M;

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

	rep(i,M){

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

		G[a].pb(b);G[b].pb(a);

	}

	int ans=0;

	rep(i,N){

		bool flag=true;

		for(int j:G[i]){

			if(A[i]<=A[j])flag=false;

		}

		if(flag)ans++;

	}

	cout<<ans<<endl;

}


// 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 REP(i,n) for(int i=1;i<n;i++)

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

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

#define P pair<int,int>

#define len(s) (int)s.size()

#define pb push_back



template<class T> inline bool chmin(T &a, T b){

	if(a>b){a=b;return true;}

	return false;

}

template<class T> inline bool chmax(T &a, T b){

	if(a<b){a=b;return true;}

	return false;

}

constexpr int mod = 1e9+7;

constexpr int inf = 3e18;



int N,M,H[100005];

bool bad[100005];

signed main(){

	cin>>N>>M;

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

	while(M--){

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

		if(H[a]<=H[b])bad[a]=true;

		if(H[a]>=H[b])bad[b]=true;

	}

	int ans=0;

	rep(i,N)ans+=!bad[i];

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

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

#define lol long long

#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式

#define mp make_pair

#define fi first

#define se second

#define pu push_back

#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する

#define abs(x,y) max(x,y)-min(x,y)

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

#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 

const int INF = 0x3f3f3f3f;

const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

const int MOD=int(1e9)+7; 

using namespace std;

using pii = pair<int, int>;

typedef vector<int> vit;



//最大公約数

lol gcd(lol x, lol y){

  if(x < y) swap(x, y);

  lol r = x % y;

  while(r != 0){

    x = y;

    y = r;

    r = x % y;

  }

  return y;

}



//最小公倍数

lol lcm(lol x, lol y){

  lol a = x * y;

  return (a / gcd(x, y));

}



signed main(void){

  cin.tie(nullptr);

  ios_base::sync_with_stdio(false);



  int n, m;

  lol h[100005];

  cin >> n >> m;

  reps(i, n){

    cin >> h[i];

  }

  vit road[100005];

  int a, b;

  rep(i, m){

    cin >> a >> b;

    road[a].pu(b);

    road[b].pu(a);

  }

  bool out[100005] = {false};

  lol ans = 0;

  reps(i, n){

    if(out[i] == false){

      rep(j, road[i].size()){

	if(h[i] > h[road[i][j]]){

	  out[road[i][j]] = true;

	} else {

	  out[i] = true;

	}

      }

    }

  }

  int nasu = 0;

  reps(i, n){

    if(!out[i]){

      nasu ++;

    }

  }

  cout << nasu << '\n';

  return 0;

}


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



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

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

#define lol long long

#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式

#define mp make_pair

#define fi first

#define se second

#define pu push_back

#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する

#define abs(x,y) max(x,y)-min(x,y)

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

#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ

const int INF = 0x3f3f3f3f;

const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

const int MOD=int(1e9)+7; 

using namespace std;

using pii = pair<int, int>;

typedef vector<int> vit;

//八方向を見るのに使うと便利(楽)

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};



signed main(void){

  cin.tie(nullptr);

  ios_base::sync_with_stdio(false);

  int n, m;

  cin >> n >> m;

  int h[n + 5], highest[n + 5] = {};

  reps(i, 1, n){

    cin >> h[i];

  }

  int a, b;

  rep(i, 0, m){

    cin >> a >> b;

    highest[a] = max(highest[a], h[b]);

    highest[b] = max(highest[b], h[a]);

  }

  int ans = 0;

  reps(i, 1, n){

    if(highest[i] < h[i]){

      ans ++;

    }

  }

  cout << ans << '\n';

  return 0;

}


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

#define int long long

using namespace std;



int a[100001];



vector<int> e[100001];



signed main()

{

	int n,m;

	cin>>n>>m;

	

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

		cin>>a[i];

	

	int x,y;

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

	{

		cin>>x>>y;

		e[x].push_back(y);

		e[y].push_back(x);

	}



	int cnt=0;

	bool f;

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

	{

		f=true;

		for(int j=0;j<e[i].size();j++)

			if(a[i]<=a[e[i][j]])

				f=false;

		if(f) cnt++;

	}

		

	cout<<cnt<<endl;

	return 0;

}

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

using namespace std;



int a[100001],b[100001];



int main()

{

	int n,m;

	cin>>n>>m;

	

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

	{

		cin>>a[i];

		b[i]=0;

	}

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

	{

		int x,y;

		cin>>x>>y;

		b[x]=max(b[x],a[y]);

		b[y]=max(b[y],a[x]);

	}

	

	int ans=0;

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

		if(a[i]>b[i])

			ans++;

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

using namespace std;

typedef long long ll;



int main(){



int n, m;

cin >> n >> m;

int h[1000000]={0};

rep(i,n) cin >> h[i+1];

int good[1000000]={0};

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

    int a, b;

    cin >> a >> b;

    if(h[a]<=h[b]) good[a]++;

    if(h[b]<=h[a]) good[b]++;

}

int ans=0;

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

    if(good[i]==0) ans++;

}



cout << ans << endl;



}

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

#include<algorithm>

 using namespace std;

 #define N 100010

 int main(){

   //速さ比べ

 int n,m,h[N],ma[N];

 cin>>n>>m;

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

 cin>>h[i];

 ma[i]=0;

 }

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

int a,b;

 cin>>a>>b;

 ma[a]=max(ma[a],h[b]);

 ma[b]=max(ma[b],h[a]);

 }

 int ans=0;

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

 ans+=h[i]>ma[i];

 }

 cout<<ans<<endl;

 }

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

using namespace std;

typedef long long ll;



const int maxn=1e5+5;



int n,m;

ll pos[maxn],maxx[maxn];//记录本身权值和该点与相邻节点的最大权值 



signed main()

{

	while(cin>>n>>m){

		memset(pos,0,sizeof pos);

		memset(maxx,0,sizeof maxx);

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

		cin>>pos[i];

		ll x,y;

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

			cin>>x>>y;

			maxx[x]=max(maxx[x],pos[y]);

			maxx[y]=max(maxx[y],pos[x]);

		}

		int cnt=0;

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

		if(maxx[i]<pos[i])cnt++;

		cout<<cnt<<endl;

	}

	

	return 0;

}

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

using namespace std;

const int N = 2e5 + 5;



int n, m;

int height[N];

int maxHeight[N];



int main() {

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

    for (int i = 1; i <= n; ++i) scanf("%d", &height[i]);

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

        int u, v;

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

        maxHeight[u] = max(maxHeight[u], height[v]);

        maxHeight[v] = max(maxHeight[v], height[u]);

    }

    int cnt = 0;

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

        if (height[i] > maxHeight[i]) ++cnt;

    }

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

}

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

#define ll long long int

using namespace std;

ll a[200010], ans;

bool visited[200010];

vector<int>node[200010];

queue<int>qu;

map<pair<int,int>, bool>taken;

int main()

{

    int i, j, v, u, edges, nodes;

    cin  >> nodes >> edges;

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

    {

        cin >> a[i];

        visited[i] = true;

    }

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

    {

        cin >> u >> v;

        if(a[u]==a[v])

        {

            visited[u] = false;

            visited[v] = false;

        }

        else if(a[u]>a[v])

        {

            visited[v] = false;

        }

        else{

            visited[u] = false;

        }

    }

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

        ans += visited[i];

    cout << ans << endl;

    return 0;

}

/*8 9

1 2

1 3

2 5

2 4

4 5

5 6

6 8

6 7

3 7*/


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

#define ll long long int

using namespace std;

ll a[200010], ans;

bool visited[200010];

int main()

{

    int i, v, u, edges, nodes;

    cin  >> nodes >> edges;

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

    {

        cin >> a[i];

        visited[i] = true;

    }

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

    {

        cin >> u >> v;

        if(a[u]==a[v])

        {

            visited[u] = false;

            visited[v] = false;

        }

        else if(a[u]>a[v])

        {

            visited[v] = false;

        }

        else{

            visited[u] = false;

        }

    }

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

        ans += visited[i];

    cout << ans << endl;

    return 0;

}

/*8 9

1 2

1 3

2 5

2 4

4 5

5 6

6 8

6 7

3 7*/


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

using namespace std;

int main(){

	int n,m,a,b;

	int h[100010];

	set<int > v[100010];

	cin >> n >> m;

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

		cin >> h[i];

	}

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

		cin >> a >> b;

		v[a].insert(b);

		v[b].insert(a);

	}

	int cnt = 0;

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

		if(v[i].empty()){

			cnt++;

		}else{

			int flag = 1;

			for(auto x:v[i]){

				if(h[x] >= h[i]){

					flag = 0;

					break;

				}

			}

			if(flag)

				cnt++;

		}

	}

	cout << cnt << endl;

}


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

using namespace std;

int main(){

	int n,m,a,b;

	int h[100010];

	vector<int > v[100010];

	cin >> n >> m;

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

		cin >> h[i];

	}

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

		cin >> a >> b;

		v[a].push_back(b);

		v[b].push_back(a);

	}

	int cnt = 0;

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

		if(v[i].empty()){

			cnt++;

		}else{

			int flag = 1;

			for(auto x:v[i]){

				if(h[x] >= h[i]){

					flag = 0;

					break;

				}

			}

			if(flag)

				cnt++;

		}

	}

	cout << cnt << endl;

}


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

using namespace std;



#define chmin(a, b) (a = min(a, b))



const int INF = 1e9 + 10;



int n;

int a[10010];

int dp[2][5010][3];



int main()

{

	cin >> n;

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

		cin >> a[i];

	}

	

	fill_n(**dp, 2 * 5010 * 3, INF);

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

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

		int s = i & 1;

		int t = s ^ 1;

		fill_n(*dp[t], 5010 * 3, INF);

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

			chmin(dp[t][j + 1][0], dp[s][j][0] + a[i]);

			chmin(dp[t][j][0], dp[s][j][0] + a[i]);

			chmin(dp[t][j + 1][0], dp[s][j][1] + a[i]);

			chmin(dp[t][j][0], dp[s][j][2] + a[i]);

			chmin(dp[t][j + 1][1], dp[s][j][0]);

			chmin(dp[t][j + 1][1], dp[s][j][1]);

			chmin(dp[t][j][2], dp[s][j][0]);

			chmin(dp[t][j][2], dp[s][j][2]);

		}

	}



	cout << dp[n & 1][n / 2][0] << endl;

}

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

using namespace std;



#define chmin(x, y) (x = min(x, y))



int n;

int a[10000];

int dp[2][5010][2];



int main()

{

	scanf("%d", &n);

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

		scanf("%d", a + i);

	}



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

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

	}

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

		auto &src = dp[i & 1], &dst = dp[~i & 1];

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

			dst[j][0] = dst[j][1] = 1e9;

		}

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

			chmin(dst[j + 1][0], src[j][0]);

			chmin(dst[j + 1][1], src[j][0] + a[i]);

			chmin(dst[j][1], src[j][1]);

			chmin(dst[j][0], src[j][1] + a[i]);

		}

	}



	int res = min(dp[n & 1][n / 2][0], dp[n & 1][n / 2][1]);

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//Bokan ga bokka--nn!!

//Daily Lunch Special Tanoshii !!

#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <ctime>

#include <cassert>

#include <string>

#include <algorithm>

#include <vector>

#include <queue>

#include <stack>

#include <functional>

#include <iostream>

#include <map>

#include <set>

using namespace std;

typedef pair<int,int> P;

typedef pair<int,P> P1;

typedef pair<P,P> P2;

typedef long long ll;

#define pu push

#define pb push_back

#define mp make_pair

#define eps 1e-7

#define INF 2000000000

#define f first

#define s second

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

int cut[10005];

int dp[2][5005][2];

int main()

{

	srand((unsigned int)time(NULL));

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

	for(int i=1;i<n;i++) scanf("%d",&cut[i]);

	for(int i=0;i<2;i++)for(int j=0;j<5005;j++)for(int k=0;k<2;k++)dp[i][j][k]=1e8;

	dp[0][1][0]=0; int cur=0,nxt=1;

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

	{

		for(int j=0;j<5005;j++)for(int k=0;k<2;k++) dp[nxt][j][k]=1e8;

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

		{

			dp[nxt][j+1][0]=min(dp[nxt][j+1][0],dp[cur][j][0]);

			dp[nxt][j][1]=min(dp[nxt][j][1],dp[cur][j][0]+cut[i]);

			dp[nxt][j][1]=min(dp[nxt][j][1],dp[cur][j][1]);

			dp[nxt][j+1][0]=min(dp[nxt][j+1][0],dp[cur][j][1]+cut[i]);

		}

		swap(cur,nxt);

	}

	printf("%d\n",min(dp[cur][n/2][0],dp[cur][n/2][1]));

}

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

#include <algorithm>

using namespace std;

#define x 10001

int dp[x][2],num[x];

int main()

{

  int n;

  scanf("%d",&n);

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

  {

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

  }

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

  {

    dp[i][0]=x*x;

    dp[i][1]=x*x;

  }

  dp[1][0]=0;

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

  {

    for(int j=n/2;j>=1;j--)

    {

      dp[j][1]=min(dp[j][1],dp[j][0]+num[i]);

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

    }

  }

  printf("%d\n",min(dp[n/2][0],dp[n/2][1]));

  return 0;

}

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

#include <iostream>

#include <algorithm>



#pragma warning(disable : 4996)



#define INF (1 << 25)



using namespace std;



int main()

{

	int N;



	scanf("%d", &N);



	vector<int> D(N - 1);



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

	{

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

	}



	vector<vector<vector<int> > > dp(2, vector<vector<int> >(N / 2 + 1, vector<int>(2, INF)));



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



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

	{

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

		{

			dp[i % 2][j][0] = min(dp[(i - 1) % 2][j][0], dp[(i - 1) % 2][j][1] + D[i - 1]);

			

			if (j != 0)

			{

				dp[i % 2][j][1] = min(dp[(i - 1) % 2][j - 1][1], dp[(i - 1) % 2][j - 1][0] + D[i - 1]);

			}

		}

	}



	printf("%d\n", min(dp[1][N / 2][0], dp[1][N / 2][1]));



	return 0;

}

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

#include <algorithm>

using namespace std;

int n, a[10009], dp[5009][2];

int main() {

	scanf("%d", &n);

	for (int i = 0; i < n - 1; i++) scanf("%d", &a[i]);

	for (int i = 0; i <= n >> 1; i++) dp[i][0] = dp[i][1] = 999999999;

	dp[0][0] = 0;

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

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

			dp[j][0] = min(dp[j][0], dp[j][1] + a[i]);

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

		}

	}

	printf("%d\n", min(dp[n >> 1][0], dp[n >> 1][1]));

	return 0;

}

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

#include<cstring>

#include<algorithm>

using namespace std;



#define MAX_N 500000

#define INF 2000000000



int dp[2][MAX_N][2];//dp[????????????][???????????§??§A?????????????????????][??´???]

int n, a[MAX_N];



int main() {

	cin >> n;

	for (int i = 1; i < n; i++) { cin >> a[i]; }

	memset(dp, 127, sizeof(dp));

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

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

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

			if (dp[0][j][0] < INF) {

				dp[1][j + 1][0] = min(dp[1][j + 1][0], dp[0][j][0]);

				dp[1][j + 1][1] = min(dp[1][j + 1][1], dp[0][j][0] + a[i + 1]);

			}

			if (dp[0][j][1] < INF) {

				dp[1][j][1] = min(dp[1][j][1], dp[0][j][1]);

				dp[1][j][0] = min(dp[1][j][0], dp[0][j][1] + a[i + 1]);

			}

		}

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

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

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

			dp[1][j][0] = INF;

			dp[1][j][1] = INF;

		}

	}

	cout << min(dp[0][n / 2][0], dp[0][n / 2][1]) << endl;

	return 0;

}

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

#include<algorithm>

#include<vector>

using namespace std;

int n, a[100000], dp[5005][2];

int main() {

	cin >> n; for (int i = 0; i < n - 1; i++)cin >> a[i];

	for (int i = 0; i < 5005; i++) { dp[i][0] = 999999999; dp[i][1] = 999999999; }

	dp[n / 2][0] = 0; dp[n / 2][1] = 0;

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

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

			dp[j][0] = min(dp[j][0], dp[j][1] + a[i]);

			dp[j][1] = min(dp[j + 1][1], dp[j + 1][0] + a[i]);

		}

	}

	cout << min(dp[0][0], dp[0][1]) << endl;

	return 0;

}

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

#define ft first

#define sc second

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



ll gcd(ll a, ll b) {

  if(b==0) return a;

  else return gcd(b, a%b);

}



ll lcm(ll a, ll b) {

  return a*b/gcd(a, b);

}





int main(void) {

  ll N, M;

  cin >> N >> M;

  ll a[MAX], b[MAX];

  ll cnt[MAX]={};

  ll i;

  

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

    cin >> a[i];

    b[i]=a[i]/2;

    

    ll t=b[i];

    while(t%2==0) {

      cnt[i]++;

      t/=2;

    }

    

  }

  sort(b, b+N);

  

  sort(cnt, cnt+N);

  if(cnt[0]!=cnt[N-1]) {

    pt(0);

    return 0;

  }

  

  ll L=1;

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

    L=lcm(L, b[i]);

  }

  

  pt((M/L+1)/2);

  

}


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

#include <iostream>

#include <algorithm>

#include <cstring>

#include <queue> //priority_queue 优先队列

#include <map>

#include <set> //multiset  

#include <vector>

#include <stack>

#include <cmath>

#include <sstream>

#include <string>

#define mod 1000000007

typedef unsigned long long ull;

typedef long long ll;

typedef double db;

const db eps=1e-6;

const int INF=0x3f3f3f3f;

const int N=2e5+5;

using namespace std;



ll t=1,n,m;

ll s=0;

ll a[N]={0};

int main(){

	cin>>n>>m;

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

		cin>>a[i];

		a[i]/=2;

		t=a[i]/__gcd(a[i],t)*t;

	}

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

		if(t%(a[i]*2)==0){

			cout<<"0"<<endl;

			return 0;

		}

	}

	printf("%lld\n",(m/t+1)/2);

	return 0;

}

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

#include<iostream>

#include<algorithm>

#include<cstring>

using namespace std;

int main()

{

    char a, b;

    cin>>a>>b;

    if(a == b)cout<<"H";

    else cout<<"D";





    return 0;

}


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



int main(){

	char a, b;

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

	if (a==b) puts("H");

	else puts("D");

}

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

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<map>

using namespace std;

int main()

{

    char a,b;

    cin >> a >> b;

    if(a == b)cout << "H" << endl;

    else cout << "D" << endl;

    return 0;

}


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



int main(){

	char a, b;

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

	if (a==b) puts("H");

	else puts("D");

}

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

using namespace std;



int main(){

    string a,b;

    cin>>a>>b;

    if (a=="H"){

        if (b=="H"){

            cout<<"H";

        } else {

            cout<<"D";

        }

    } else {

        if (b=="H"){

            cout<<"D";

        } else {

            cout<<"H";

        }

    }

}

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



int main(){

	char a, b;

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

	if (a==b) puts("H");

	else puts("D");

}

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

using namespace std;

int main(){

	string a,b;

	cin>>a>>b;

	if(a=="H" && b=="H"){

	cout<<"H\n";

}

	else if(a=="D"&&b=="D"){

	cout<<"H\n";

}

	else{

	cout<<"D\n";

}

}

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



int main(){

	char a, b;

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

	if (a==b) puts("H");

	else puts("D");

}

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

using namespace std;

int main(){

	char a,b;

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

	if(a==b){

	  cout<<"H";

	  }

    else

       cout<<"D";

}

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



int main(){

	char a, b;

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

	if (a==b) puts("H");

	else puts("D");

}

// Fastest known solution for this problem: