output_description: If the state where p_i=i for every i can be reached by performing the
  operation, print `Yes`; otherwise, print `No`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      p_1
      :
      p_N
attempt: #include <cstdio>
  #include <cstring>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <bitset>
  #include <vector>
  #include <map>
  #include <set>
  #include <queue>
  #include <deque>
  #include <algorithm>
  #include <complex>
  #include <unordered_map>
  #include <unordered_set>
  #include <random>
  #include <cassert>
  #include <fstream>
  #include <utility>
  #include <functional>
  #include <time.h>
  #include <stack>
  #include <array>
  #define popcount __builtin_popcount
  using namespace std;
  typedef long long int ll;
  typedef pair<int, int> P;
  
  int main()
  {
      int n;
  	cin>>n;
  	int p[300030];
  	for(int i=0; i<n; i++){
  		cin>>p[i];
  		p[i]--;
  	}
  	for(int i=0; i<n; i++){
  		if((p[i]&1)!=(i&1)){
  			cout<<"No"<<endl;
  			return 0;
  		}
  	}
  	set<int> st[2];
  	for(int i=0; i<n; i++) st[i&1].insert(i);
  	int x[2]={}, y[2]={};
  	for(int i=0; i<n; i++){
  		int a=*st[i&1].begin();
  		if(p[i]==a){
  			st[i&1].erase(st[i&1].begin());
  			continue;
  		}
  		if(p[i]<x[i&1]){
  			cout<<"No"<<endl;
  			return 0;
  		}
  		st[i&1].erase(p[i]);
  		x[(i&1)^1]=max(x[(i&1)^1], p[i]+3);
  		x[i&1]=max(x[i&1], p[i]+2);
  		y[(i&1)^1]=max(y[(i&1)^1], p[i]+1);
  	}
  	cout<<"Yes"<<endl;
  	return 0;
  }
  
problem_description: Statement
  
  You are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the
  state where p_i=i for every i can be reached by performing the following
  operation any number of times:
  
    * Choose three elements p_{i-1},p_{i},p_{i+1} (2\leq i\leq N-1) such that p_{i-1}>p_{i}>p_{i+1} and reverse the order of these three.
samples: [{"input": "5\n    5\n    2\n    1\n    4\n    3", "output": "Yes\n    \n\nThe state where p_i=i for every i can be reached as follows:\n\n  * Reverse the order of p_1,p_2,p_3. The sequence p becomes 1,2,5,4,3.\n  * Reverse the order of p_3,p_4,p_5. The sequence p becomes 1,2,3,4,5.\n\n* * *"}, {"input": "4\n    3\n    2\n    4\n    1", "output": "No\n    \n\n* * *"}, {"input": "7\n    3\n    2\n    1\n    6\n    5\n    4\n    7", "output": "Yes\n    \n\n* * *"}, {"input": "6\n    5\n    3\n    4\n    1\n    2\n    6", "output": "No"}]