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

#include<map>

#include<algorithm>

#include<queue>

#include<vector>

using namespace std;



typedef pair<int,int> P;

typedef pair<int,P> P2;



int n,m,l,k;

int u,v,c;

int s,g,t;

int b[7];



int dis[51][1<<7][10],vis[51][1<<7];

vector<P> G[51];

const int INF = 100000000;



int main(){

  while(cin >> n >> m >> l >> k,n+m+l+k){

    for(int i=1;i<=n;i++)G[i].clear();

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

      cin >> u >> v >> c;

      G[u].push_back(P(c,v));

      G[v].push_back(P(c,u));

    }

    cin >> s >> g;

    for(int i=0;i<l;i++)cin >> b[i];



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

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

	for(int x=0;x<k;x++)dis[i][j][x] = INF;

	vis[i][j] = 0;

      }



    int st = 0;

    for(int i=0;i<l;i++)if(s==b[i])st |= 1<<i;



    priority_queue< P2,vector<P2>,greater<P2> > q;

    q.push(P2(0,P(s,st)));

    

    while(q.size()){

      P2 p = q.top(); q.pop();

      int dist = p.first, pos = p.second.first, state = p.second.second;



      if(vis[pos][state] < k){

	dis[pos][state][vis[pos][state]] = dist;

	vis[pos][state]++;

      }else continue;



      for(int i=0;i<G[pos].size();i++){

	int cost = G[pos][i].first, nxt = G[pos][i].second;

	int nstate = state;

	for(int j=0;j<l;j++)if(nxt==b[j])nstate |= 1<<j;



	if(vis[nxt][nstate] < k)q.push(P2(dist+cost,P(nxt,nstate)));

      }

    }

    int res = dis[g][(1<<l)-1][k-1];

    if(res==INF)cout << "NA\n";

    else cout << res << endl;

  }

}

      

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

#include<map>

#include<algorithm>

#include<queue>

#include<vector>

using namespace std;



typedef pair<int,int> P;

typedef pair<int,P> P2;



int n,m,l,k;

int u,v,c;

int s,g,t;

int b[7];



int dis[51][1<<7][10],vis[51][1<<7];

vector<P> G[51];

const int INF = 100000000;



int main(){

  while(cin >> n >> m >> l >> k,n+m+l+k){

    for(int i=1;i<=n;i++)G[i].clear();

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

      cin >> u >> v >> c;

      G[u].push_back(P(c,v));

      G[v].push_back(P(c,u));

    }

    cin >> s >> g;

    for(int i=0;i<l;i++)cin >> b[i];



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

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

	for(int x=0;x<k;x++)dis[i][j][x] = INF;

	vis[i][j] = 0;

      }



    int st = 0;

    for(int i=0;i<l;i++)if(s==b[i])st |= 1<<i;



    priority_queue< P2,vector<P2>,greater<P2> > q;

    q.push(P2(0,P(s,st)));

    

    while(q.size()){

      P2 p = q.top(); q.pop();

      int dist = p.first, pos = p.second.first, state = p.second.second;



      if(vis[pos][state] < k){

	dis[pos][state][vis[pos][state]] = dist;

	vis[pos][state]++;

	if(pos==g && state==(1<<l)-1 && vis[pos][state]==k)break;

      }else continue;



      for(int i=0;i<G[pos].size();i++){

	int cost = G[pos][i].first, nxt = G[pos][i].second;

	int nstate = state;

	for(int j=0;j<l;j++)if(nxt==b[j])nstate |= 1<<j;



	if(vis[nxt][nstate] < k)q.push(P2(dist+cost,P(nxt,nstate)));

      }

    }

    int res = dis[g][(1<<l)-1][k-1];

    if(res==INF)cout << "NA\n";

    else cout << res << endl;

  }

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

#include<cstdio>

#include<queue>

#include<cmath>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

long long read(){

	long long f=1,x=0;

	char c=getchar();

	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}

	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}

	return f*x;

}

int main(){

	long long  a=read(),b=read();

	if((a*b)%2==0)

		printf("Even\n");

	else

		printf("Odd\n");

	return 0;

}


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

#include<algorithm>

using namespace std;

int main()

{

	#ifdef LOACL

	freopen("in.txt","r",stdin);

	freopen("out.txt","w",stdout);

	#endif

	int a,b;

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

	if((a*b)%2==0)printf("Even\n");

	else printf("Odd\n");

	return 0;

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

#include<string>

#include<cstdio>

#include<algorithm>

using namespace std;

int a,b;

int main()

{

	cin>>a>>b;

	if(a*b&1)cout<<"Odd";

	else

	cout<<"Even";

}

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

using namespace std;

int main(void)

{

	int a,b;

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

	printf("%s\n",(a*b)&1?"Odd":"Even");

	return 0;

}

/*

#include<stdio.h>

using namespace std;

int main(void)

{

	int left=1,right=100000000,mid,a,b;

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

	while(left<=right)

	{

		mid=(left+right)/2;

		if(mid==a*b)

			break;

		else if(mid>a*b)

			right=mid;

		else

			left=mid;

	}

	printf("%s\n",mid&1?"Odd":"Even");

	return 0;

}

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

//#include<cstdio>

//#include<string>

//#include<string>

//#include<algorithm>

//#include<ctime> printf("\n%lldms",clock());

//#include<cmath>

//#include<vector>

//#include<queue>

#include <bits/stdc++.h>

#define lijyya 300010

#define oo 0x3f3f3f3f

#define emmm 100003

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

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

#define f3(i,a,b) for (register int i=a;i>=b;--i)

#define f4(i,a,b) for (register int i=a;i>b;--i)

using namespace std;

typedef long long ll;

template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}

template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}

inline int read(){

    int f=1,x=0;char ch;

    do{

        ch=getchar();if(ch=='-') f=-1;

    }while(ch<'0'||ch>'9');

    do{

        x=x*10+ch-'0';ch=getchar();

    }while(ch>='0'&&ch<='9');

    return f*x;

}



int n,a;

int main(){

    n=read();

    a=read();

    if(n*a%2==0) printf("Even");

    else printf("Odd");

    return 0;

}


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

using namespace std;

int main(void)

{

	int a,b;

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

	printf("%s\n",(a*b)&1?"Odd":"Even");

	return 0;

}

/*

#include<stdio.h>

using namespace std;

int main(void)

{

	int left=1,right=100000000,mid,a,b;

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

	while(left<=right)

	{

		mid=(left+right)/2;

		if(mid==a*b)

			break;

		else if(mid>a*b)

			right=mid;

		else

			left=mid;

	}

	printf("%s\n",mid&1?"Odd":"Even");

	return 0;

}

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

using namespace std;

int main()

{

	int a,b;

	cin>>a>>b;

	if((a*b)%2==0){

		cout<<"Even";

	}

	else{

		cout<<"Odd";

	}

	return 0;	

} 

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

int main()

{

    int a,b;

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

    if((a*b)%2==0)printf("Even\n");

    else

        printf("Odd\n");

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



using namespace std;



int main(){

  int a, b;

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

  if(a & 1 && b & 1) printf("Odd\n");

  else printf("Even\n");

  

  return 0;

}

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

int main()

{

    int a,b;

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

    if((a*b)%2==0)printf("Even\n");

    else

        printf("Odd\n");

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

using namespace std;



int main () {

  int a, b;

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

  if (a*b % 2 == 0) printf("Even\n");

  else printf("Odd\n");

  return 0;

}

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

int main()

{

    int a,b;

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

    if((a*b)%2==0)printf("Even\n");

    else

        printf("Odd\n");

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

namespace chtholly{

typedef long long ll;

#define re0 register int

#define rec register char

#define rel register ll

#define gc getchar

#define pc putchar

#define p32 pc(' ')

#define pl puts("")

/*By Citrus*/

inline int read(){

  re0 x=0,f=1;rec c=gc();

  for (;!isdigit(c);c=gc()) f^=c=='-';

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return f?x:-x;

  }

inline void read(rel &x){

  x=0;re0 f=1;rec c=gc();

  for (;!isdigit(c);c=gc()) f^=c=='-';

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  x=f?x:-x;

  }

template <typename mitsuha>

inline int write(mitsuha x){

  if (!x) return pc(48);

  if (x<0) x=-x,pc('-');

  re0 bit[20],i,p=0;

  for (;x;x/=10) bit[++p]=x%10;

  for (i=p;i;--i) pc(bit[i]+48);

  }

inline char fuhao(){

  rec c=gc();

  for (;isspace(c);c=gc());

  return c;

  }

}using namespace chtholly;

using namespace std;



int main(){

puts(read()*read()&1?"Odd":"Even");

}

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

int main()

{

    int a,b;

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

    if((a*b)%2==0)printf("Even\n");

    else

        printf("Odd\n");

}
// Slower C++ solution:
// CodeForces - 1A

#include<bits/stdc++.h>

using namespace std;



int main(){

    ios_base::sync_with_stdio(false);

    int a, b;

    cin >> a >> b;

    

    if((a % 2 == 0) || (b % 2 == 0))    cout << "Even";

    else    cout << "Odd";

    

    return 0;

}

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

int main()

{

    int a,b;

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

    if((a*b)%2==0)printf("Even\n");

    else

        printf("Odd\n");

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

#include <cstring>

#include <cstdlib>

#include <algorithm>

#include <utility>

#include <vector>

#include <tuple>

#include <cmath>



using namespace std;



int main() {

  int a, b, c;



  #ifdef DEBUG

  freopen("5-08-a.txt", "r", stdin);

  #endif



  while (cin >> a >> b) {

    c = a * b;

    cout << (c % 2 == 0 ? "Even" : "Odd") << endl;

  }



  return 0;

}


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

int main()

{

    int a,b;

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

    if((a*b)%2==0)printf("Even\n");

    else

        printf("Odd\n");

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

using namespace std;

int main(){

	int a,b;

	while(cin>>a>>b){

		if((a*b)%2==0)

		cout<<"Even"<<endl;

		else

		cout<<"Odd"<<endl;

	}

	return 0;

}

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

int main()

{

    int a,b;

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

    if((a*b)%2==0)printf("Even\n");

    else

        printf("Odd\n");

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

#include <iostream>

#include <vector>

#include <map>

#include <set>

#include <list>

#include <cmath>

#include <cstring>

#include <algorithm>

using namespace std;

/*#define fast ios_base::sync_with_stdio(0); cin.tie(0)*/

#define ff first

#define ss second

#define pb push_back

#define mp make_pair

const double pi = acos(-1);

typedef long long ll;

int main()

{

	//fast;

	

	ll a,b,c,x;

	cin>>a>>b;

	((a*b)%2)?cout<<"Odd":cout<<"Even";

}

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

int main()

{

    int a,b;

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

    if((a*b)%2==0)printf("Even\n");

    else

        printf("Odd\n");

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

using namespace std;

#define  ll long long int

main()

{

    ll a,b;

    cin>>a>>b;

    if((a*b)%2==0)

        cout<<"Even"<<endl;

    else

        cout<<"Odd"<<endl;

}


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

int main()

{

    int a,b;

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

    if((a*b)%2==0)printf("Even\n");

    else

        printf("Odd\n");

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

using namespace std;

typedef long long ll;



const ll MOD = 1e9+7;



const int MAX=100010;



vector<ll> fac(MAX), finv(MAX), inv(MAX);



void cmbInit() {

    fac[0]=fac[1]=1;

    finv[0]=finv[1]=1;

    inv[1]=1;

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

        fac[i]=(fac[i-1]*i)%MOD;

        inv[i]=MOD-(inv[MOD%i]*(MOD/i))%MOD;

        finv[i]=(finv[i-1]*inv[i])%MOD;

    }

}



int main() {

    int n;

    cin >> n;

    vector<ll> x(n);

    ll xin,oxin;

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

        cin >> xin;

        if (i>0) x[i]=xin-oxin;

        oxin = xin;

    }

    vector<ll> p(n), sump(n);

    cmbInit();

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

        p[i]=(fac[n-1]*inv[i])%MOD;

        if (i==1) sump[i]=p[i];

        else sump[i]=(p[i]+sump[i-1])%MOD;

    }

    

    ll ans=0;

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

        ans+=(x[i]*sump[i])%MOD;

        ans=ans%MOD;

    }

    cout << ans << endl;

}

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

typedef long long ll;

using namespace std;

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

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

#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)

#define invrep(i,n) invrepr(i,0,n)

#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)

#define P pair<int,int>

const ll MOD=1e9+7;

const ll INF=1e9;

const double PI=acos(-1);

const int MAX=100010;



ll fac[MAX], finv[MAX], inv[MAX];



void cmbInit() {

    fac[0]=fac[1]=1;

    finv[0]=finv[1]=1;

    inv[1]=1;

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

        fac[i]=fac[i-1]*i%MOD;

        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;

        finv[i]=finv[i-1]*inv[i]%MOD;

    }

}





ll cmb(int n, int k){

    if (n<k) return 0;

    if (n<0 || k<0) return 0;

    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;

}





int main() {

    ios_base::sync_with_stdio(false); 



    int n;

    cin >> n;

    vector<ll> x(n),p(n);

    rep(i,n) cin >> x[i];

    cmbInit();

    rep(i,n-1) p[i+1]=((fac[n-1]*inv[i+1])%MOD+p[i])%MOD;

    ll ans=0;

    rep(i,n-1) ans=(ans+((x[i+1]-x[i])*p[i+1])%MOD)%MOD;

    cout << ans << endl;



    return 0;

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



using namespace std;

const int mod = 1e9 + 7;

int qs[(int)1e5 + 5], inv[(int)1e5 + 5];

int pow(int val, int idx){

    if(idx == 0) return 1;

    if(idx == 1) return val;

    int k = pow(val, idx >> 1);

    k = (1LL * k * k) %  mod;

    if(idx & 1) k = (1LL * k * val) % mod;

    return k;

}

int main(){

    int n, pre, x;

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

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

        scanf("%d", &x);

        qs[i] = qs[i-1] + x - pre;

        pre = x;

    }

    int fac = 1;

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

        fac = (1LL * fac * i) % mod;

        inv[i] = i == 1 ? 1 : pow(i, mod - 2);

    }

    int ans = 0;

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

        ans += (1LL * (qs[n - 1] - qs[i-1]) * (1LL * fac * inv[i] % mod)) % mod;

        ans = ans >= mod ? ans - mod : ans;

    }

    printf("%d",ans);







}


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



using namespace std;

const int mod = 1e9 + 7;

int qs[(int)1e5 + 5], inv[(int)1e5 + 5];

int pow(int val, int idx){

    if(idx == 0) return 1;

    if(idx == 1) return val;

    int k = pow(val, idx >> 1);

    k = (1LL * k * k) %  mod;

    if(idx & 1) k = (1LL * k * val) % mod;

    return k;

}

int main(){

    int n, pre, x;

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

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

        scanf("%d", &x);

        qs[i] = qs[i-1] + x - pre;

        pre = x;

    }

    int fac = 1;

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

        fac = (1LL * fac * i) % mod;

        inv[i] = i == 1 ? 1 : pow(i, mod - 2);

    }

    int ans = 0;

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

        ans += (1LL * (qs[n - 1] - qs[i-1]) * (1LL * fac * inv[i] % mod)) % mod;

        ans = ans >= mod ? ans - mod : ans;

    }

    printf("%d",ans);







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

using namespace std;

const double EPS = 1E-9;

const long long INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;

#define pb push_back

#define ll long long

int n;

int a[100000] , b[100000];

map<int , int> g;

int main()

{

	scanf("%d" , &n);

	ll ans = 0;

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

	{

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

		g[a[i]] = i % 2;

		b[i] = a[i];

	}

	sort(b , b + n);

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

	{

		if(g[b[i]] != i % 2)

		{

			ans++;

		}

	}

	cout << ans / 2;

}


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

#include<algorithm>

using namespace std;

const int maxn = 100000;

int num[maxn + 10];

int ji[maxn + 10];

int ou[maxn + 10];

int n;

int main()

{

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

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

	scanf("%d",&n);

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

	{

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

		if(i & 1)

		{

			ji[(i + 1) / 2] = num[i];

		}

		else

		{

			ou[i / 2] = num[i];

		}

	}

	sort(ji + 1,ji + 1 + (n + 1) / 2);

	sort(ou + 1,ou + 1 + n / 2);

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

	int ans = 0;

	if(n & 1)

	{

		int p = 1;

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

		{

			while(num[i] > ji[p] && p < (n + 1) / 2)

				++p;

			if(num[i] != ji[p])

				++ans;

			while(ji[p] < num[i] && p < (n + 1) / 2)

				++p;

		}

	}

	else

	{

		int p = 1;

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

		{

			while(num[i] > ji[p] && p < n  / 2)

				++p;

			if(num[i] != ji[p])

				++ans;

			while(ji[p] < num[i] && p < n  / 2)

				++p;

		}

	}

	printf("%d",ans);

	return 0;

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

#include <istream>

#include <cstdio>

#include <vector>

#include <cmath>

#include <algorithm>

#include <map>

#include <set>

//#include <unordered_map>

#include <cstring>

#include <string.h>

#include <iomanip>

#include <queue>

#include <stack>

#include <list>

#include <sstream>

//#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef unsigned long long ull;

typedef pair<int,int> ii;

typedef vector<int> vi;

typedef long double ld;



#define ALL(V) V.begin(), V.end()

#define SZ(V) (int)V.size()

#define pb push_back

#define mp make_pair

#define f first

#define s second



#define fopen freopen("substrcmp.in", "r", stdin); freopen("substrcmp.out","w", stdout)

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

#define FORR(i, b, a) for(int i = (b) - 1; i >= (a); --i)

#define FILL(A,value) memset(A,value,sizeof(A))

#define IOSFAST ios::sync_with_stdio(false); cin.tie(0)



const ll MOD = 1000LL * 1000 * 1000 + 7;

const int INF = 1e9;

const ll base = 1e18;

const int MAX = 1000;

const double EPS = 1e-9;

const double PI = acos(-1.);



int n;

pair<int,int> a[200000];

int main()

{

	IOSFAST;

	cin >> n;

	FOR(i,0,n)

	{

		cin >> a[i].f;

		a[i].s = i;

	}

	sort(a,a+n);

	int res = 0;

	FOR(i,0,n)

	{

		if (abs(a[i].s-i)%2)

		{

			res++;

		}

	}

	cout << res/2;

	return 0;

}


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

#include<algorithm>

using namespace std;

const int maxn = 100000;

int num[maxn + 10];

int ji[maxn + 10];

int ou[maxn + 10];

int n;

int main()

{

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

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

	scanf("%d",&n);

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

	{

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

		if(i & 1)

		{

			ji[(i + 1) / 2] = num[i];

		}

		else

		{

			ou[i / 2] = num[i];

		}

	}

	sort(ji + 1,ji + 1 + (n + 1) / 2);

	sort(ou + 1,ou + 1 + n / 2);

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

	int ans = 0;

	if(n & 1)

	{

		int p = 1;

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

		{

			while(num[i] > ji[p] && p < (n + 1) / 2)

				++p;

			if(num[i] != ji[p])

				++ans;

			while(ji[p] < num[i] && p < (n + 1) / 2)

				++p;

		}

	}

	else

	{

		int p = 1;

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

		{

			while(num[i] > ji[p] && p < n  / 2)

				++p;

			if(num[i] != ji[p])

				++ans;

			while(ji[p] < num[i] && p < n  / 2)

				++p;

		}

	}

	printf("%d",ans);

	return 0;

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

#include <ext/algorithm>

#include <ext/numeric>



using namespace std;

using namespace __gnu_cxx;



int main()

{

	ios_base::sync_with_stdio(0);

	cin.tie(0);



/**************************************************************/



	int N;

	cin >> N;

	pair<int,int> array[N];



	int count;

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

	{

		cin >> count;

		array[i] = {count,i};

	}



	sort(array, array+N);

	count = 0;

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

		if(i%2 != array[i].second%2)

			count++;



	cout << count/2 << endl;

}

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

#include<algorithm>

using namespace std;

const int maxn = 100000;

int num[maxn + 10];

int ji[maxn + 10];

int ou[maxn + 10];

int n;

int main()

{

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

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

	scanf("%d",&n);

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

	{

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

		if(i & 1)

		{

			ji[(i + 1) / 2] = num[i];

		}

		else

		{

			ou[i / 2] = num[i];

		}

	}

	sort(ji + 1,ji + 1 + (n + 1) / 2);

	sort(ou + 1,ou + 1 + n / 2);

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

	int ans = 0;

	if(n & 1)

	{

		int p = 1;

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

		{

			while(num[i] > ji[p] && p < (n + 1) / 2)

				++p;

			if(num[i] != ji[p])

				++ans;

			while(ji[p] < num[i] && p < (n + 1) / 2)

				++p;

		}

	}

	else

	{

		int p = 1;

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

		{

			while(num[i] > ji[p] && p < n  / 2)

				++p;

			if(num[i] != ji[p])

				++ans;

			while(ji[p] < num[i] && p < n  / 2)

				++p;

		}

	}

	printf("%d",ans);

	return 0;

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



using namespace std;



pair<int, int> A[100010];



int main(){



	ios::sync_with_stdio(0);

	cin.tie(0);



	int n, input;

	cin >> n;

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

		cin >> input;

		A[i] = make_pair(input, i);

	}

	sort(A, A+n);



	int counter = 0;

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

		if((A[i].second-i)&1) 

			counter++;

	

	cout << counter/2 << '\n';

	

	return 0;

} // br1


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

#include<algorithm>

using namespace std;

const int maxn = 100000;

int num[maxn + 10];

int ji[maxn + 10];

int ou[maxn + 10];

int n;

int main()

{

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

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

	scanf("%d",&n);

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

	{

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

		if(i & 1)

		{

			ji[(i + 1) / 2] = num[i];

		}

		else

		{

			ou[i / 2] = num[i];

		}

	}

	sort(ji + 1,ji + 1 + (n + 1) / 2);

	sort(ou + 1,ou + 1 + n / 2);

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

	int ans = 0;

	if(n & 1)

	{

		int p = 1;

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

		{

			while(num[i] > ji[p] && p < (n + 1) / 2)

				++p;

			if(num[i] != ji[p])

				++ans;

			while(ji[p] < num[i] && p < (n + 1) / 2)

				++p;

		}

	}

	else

	{

		int p = 1;

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

		{

			while(num[i] > ji[p] && p < n  / 2)

				++p;

			if(num[i] != ji[p])

				++ans;

			while(ji[p] < num[i] && p < n  / 2)

				++p;

		}

	}

	printf("%d",ans);

	return 0;

}