Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var num int
	fmt.Scan(&num)

	for i := 0; i < num; i++ {
		sc.Scan()
		line := sc.Text()

		insertCheck(line)
	}
}

func insertCheck(line string) {
	var B, C []int

	for _, v := range strings.Split(line, " ") {
		ball, _ := strconv.Atoi(v)
		switch {
		case len(B) == 0:
			B = append(B, ball)
		case B[len(B)-1] < ball:
			B = append(B, ball)
		case B[len(B)-1] >= ball:
			switch {
			case len(C) == 0:
				C = append(C, ball)
			case C[len(C)-1] < ball:
				C = append(C, ball)
			case C[len(C)-1] >= ball:
				fmt.Println("NO")
				return
			}
		}
	}
	fmt.Println("YES")
}

C++: // g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define For(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Rep(i,n) For(i,0,n)
#define Each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

int N;
vector<int> in, h1, h2;

/*
bool sorter(const A& x, const A& y){
	return x.a < y.a;
}

int gcd(int a, int b){
	if(b == 0) return a;
	return gcd(b, a%b);
}

int lcm(int a, int b){
	if(a == 0 || b == 0) return 0;
	return a*b/gcd(a,b);
}
*/
bool dfs(int n){
	bool flag = false;
	if(n == 10) return true;
	else{
		if(h1.size() == 0 || h1[h1.size()-1] < in[n]){
			h1.pb(in[n]);
			if(dfs(n+1)) flag = true;
			h1.pop_back();
		}
		if(h2.size() == 0 || h2[h2.size()-1] < in[n]){
			h2.pb(in[n]);
			if(dfs(n+1)) flag = true;
			h2.pop_back();
		}
	}
	return flag;
}

int main(){
	scanf("%d", &N);
	Rep(i,N){
		in.clear();
		Rep(j,10){
			int ball;	
			scanf("%d", &ball);
			in.pb(ball);
		}
		h1.clear();
		h2.clear();
		if(dfs(0)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int a[10]={0};
bool right(){
    for(int i=0;i<10;i++){
        if(*max_element(a,a+i)>*max_element(a+i,a+10)) return false;
    }
    return true;
}
int main(void){
    int n;
    cin>>n;
    while(n--){
        for(int i=0;i<10;i++) cin>>a[i];
        if(right()) cout<<"YES\n";
        else cout<<"NO\n";
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int a[10];
int b[10];
int ball[20];
bool ans;
void dfs(int k,int ca,int cb)
{
	if(k==10)
	{
		ans = 1;
		return;
	}
	if(ball[k] > a[ca-1])
	{
		a[ca] = ball[k];
		dfs(k+1,ca+1,cb);
		a[ca] = 0;
	}
	if(ball[k] > b[cb-1])
	{
		b[cb] = ball[k];
		dfs(k+1,ca,cb+1);
		b[cb] = 0;
	}
	return;
}
int main()
{
	int n;
	cin >> n;
	while(n--)
	{
		ans = 0;
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		for(int i = 0;i<10;i++)
		{
			cin >> ball[i];
		}
		dfs(0,1,1);
		if(ans == 1)
		cout << "Yes" << endl;
		else
		cout << "No" << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;

int ball[10];

//ball[m]?????\????????±b,c???????????????ball???????????????left,right
bool dfs(int m,int left, int right){
    if(m==10) return true;
    if(ball[m]>left){
        return dfs(m+1,ball[m],right);
    }
    if(ball[m]>right){
        return dfs(m+1,left,ball[m]);
    }
    return false;
}

void solve(){
    for(int i=0;i<10;i++){
        cin>>ball[i];
    }
    if(dfs(0,0,0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

int main(){
    int n;cin>>n;
    for(int i=0;i<2;i++){
        solve();
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <functional>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-10;

bool dfs(int* a, vector<int> &b, vector<int> &c, int n) {
    if(n == 10) return true;

    bool ok = false;
    if(b.empty() || b.back() < a[n]) {
        b.push_back(a[n]);
        ok |= dfs(a, b, c, n+1);
        b.pop_back();
    }
    if(c.empty() || c.back() < a[n]) {
        c.push_back(a[n]);
        ok |= dfs(a, b, c, n+1);
        c.pop_back();
    }
    return ok;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    int a[10];
    REP(i,N) {
        REP(j,10) cin >> a[j];
        vector<int> b, c;
        if(dfs(a, b, c, 0)) cout << "YES";
        else cout << "NO";
        cout << '\n';
    }
    return 0;
}

C++: #include <iostream>
using namespace std;

int main()
{
	int n,A,B,f,ball;
	cin >> n;
	
	for(int i=0;i<n;i++){
		A=0;
		B=0;
		f=0;
		for(int j=0;j<10;j++){
			cin >> ball;
			if(ball<A && ball<B) {
				f=1;
				break;
			} else if(A<ball && ball<B){
				A=ball;
			} else if(ball<A && B<ball){
				B=ball;
			} else if(A>B){
				A=ball;
			} else {
				B=ball;
			}
		}
		
		if(f==0) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
        int n;
        int b[6], c[6];

        b[5] = c[5] = 0;

        cin >> n;
        for (int i = 0; i < n; i++) {
                int ib = 0, ic = 0;

                for (int j = 0; j < 10; j++) {
                        if (j % 2) {
                                cin >> c[ic++];
                        }
                        else {
                                cin >> b[ib++];
                        }
                }
                int cnt = 0;
                while (b[cnt] < b[cnt + 1] && c[cnt] < c[cnt + 1]) {
                        cnt++;
                }

                cnt == 4 ? cout << "YES" : cout << "NO";
                cout << endl;
        }

        return 0;
}

C++: #include <iostream>

using namespace std;
const int kBalln = 10;
int ball[kBalln];

bool ExistAsceOrder(int i, int a, int b){
  // 終了条件
  if (i == kBalln)  return true;

  // ボールiを筒Bに入れる場合
  if (a < ball[i] && ExistAsceOrder(i+1,ball[i],b)) return true;

  // ボールiを筒Cに入れる場合
  if (b < ball[i] && ExistAsceOrder(i+1,a,ball[i])) return true;

  // どちらの筒に入れても昇順にならない場合
  return false;
}

int main(){
  int n;

  cin >> n;
  for (int j = 0; j < n; ++j)
    {
      for (int i = 0; i < kBalln; ++i)
        {
          cin >> ball[i];
        }

      if(ExistAsceOrder(0,0,0))
        {
          cout << "Yes" << endl;
        }
      else
        {
          cout << "No" << endl;
        }
    }
  return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
	int N;
	int A[11];
	int cnt1=0;
	cin>>N;
	while(1){
		
		if(cnt1==N){
			break;
		}
		cnt1++;
		for(int i=1;i<=10;i++){
			cin>>A[i];
		}
		int B=A[1];
		int Z[11];
		for(int i=1;i<=10;i++){
			Z[i]=0;
		}
		int C=0;
		int cnt2=0;
		int su=0;
		for(int i=2;i<=10;i++){
			if((B+1==A[i])/*||((su==1)&&(B<A[i]))*/){
				B=A[i];
				cnt2++;
				//cout<<"1"<<A[i]<<endl;
			}
			else if((C+1==A[i])/*||((su==1)&&(B<A[i]))*/){
				C=A[i];
				cnt2++;
				Z[i]=C;
				su=0;
//cout<<"2"<<A[i]<<endl;
			}
			else if(B<A[i]){
				B=A[i];
				//Z[i]=C;
				//su=0;
				cnt2++;
//cout<<"3"<<A[i]<<endl;
			}
			else if(C<A[i]){
				C=A[i];
				Z[i]=C;
				su=0;
				cnt2++;
//cout<<"4"<<A[i]<<endl;
			}
			//CにB＋1がはいっていたらsu=1にすること
			for(int q=1;q<=10;q++){
				if(B+1==Z[q]){
					su=1;
				}
			}
			
		}
		if(cnt2==9){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	return 0;	
}