Go: package main

import "fmt"

func isOrdered(a []int) bool {
	if len(a) <= 1 {
		return true
	}
	for i := 0; i+1 < len(a); i++ {
		if a[i] > a[i+1] {
			return false
		}
	}
	return true
}

func main() {
	// ボールの数がせいぜい10個しかないので、全てのボールの落とし方を全探索することが可能
	// Bit全探索を行う。右から見てj番目のビットが立っているときには左側の筒、立っていない時は右側の筒にいれる物とする。
	// 全てのボールを落とし終わった後に、それぞれの筒で昇順に並んでいるか調べることにする。
	var t int
	fmt.Scan(&t)
	ans := make([]bool, t)
	for i := 0; i < t; i++ {
		balls := make([]int, 10)
		for i := range balls {
			fmt.Scan(&balls[i])
		}
		ans[i] = false
		for bits := 0; bits < (1 << uint(10)); bits++ {
			pipeB := make([]int, 0)
			pipeC := make([]int, 0)
			for j := 0; j < 10; j++ {
				if (bits & (1 << uint(j))) != 0 {
					pipeB = append(pipeB, balls[j])
				} else {
					pipeC = append(pipeC, balls[j])
				}
			}
			if isOrdered(pipeB) && isOrdered(pipeC) {
				// fmt.Printf("test case %d - OK pattern - pipeB %v, pipec %v\n", i, pipeB, pipeC)
				ans[i] = true
				break
			}
		}
	}
	for i := range ans {
		if ans[i] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue>
using namespace std;

int arr[15],used[15];

void dfs(int pre,int cur)
{
    if(cur<10&&arr[pre]<arr[cur])
    {
        used[cur]=1;
        dfs(cur,cur+1);
    }
    else if(cur<10&&arr[pre]>=arr[cur])
        dfs(pre,cur+1);
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        bool judge=false;
        for(int i=0;i<10;i++)
            scanf("%d",&arr[i]);
        for(int i=0;i<10;i++)
        {
            memset(used,0,sizeof(used));
            used[i]=1;
            dfs(i,i+1);
            int pre=0;
            judge=false;
            for(int j=0;j<10;j++)
            {
                if(!used[j])
                {
                    if(pre>=arr[j])
                    {
                        judge=true;
                        break;
                    }
                    pre=arr[j];
                }
            }
            if(!judge)
            {
                printf("YES\n");
                break;
            }
        }
        if(judge) printf("NO\n");
    }
   return 0;
}

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

int ball[10];

bool dfs(int i = 0, int l = 0, int r = 0) {
	if(i == 10)
		return true;

	if(l < ball[i] && dfs(i + 1, ball[i], r))
		return true;

	if(r < ball[i] && dfs(i + 1, l, ball[i]))
		return true;

	return false;
}


int main() {
	cin.tie(false);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

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

		cout << (dfs() ? "YES" : "NO") << endl;
	}

	return EXIT_SUCCESS;
}

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

int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		int a=0, b=0;
		for(int j=0; j<10; j++){
			int m;
			cin >> m;
			if(m > a){
				a = m;
			}else if(m > b){
				b = m;
			}else{
				a = 100;
			}
		}
		if(a==100){
			cout << "NO" << endl;
		}else{
			cout << "YES" << endl;
		}
	}
    return 0;
}

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

using namespace std;

vector<int> a;
stack<int> b, c;

bool dfs(int i)
{
	if (i == 10) return true;

	bool res1 = false, res2 = false;

	if (b.empty() || b.top() < a[i]) {
		b.push(a[i]);
		res1 = dfs(i + 1);
		b.pop();
	}

	if (c.empty() || c.top() < a[i]) {
		c.push(a[i]);
		res2 = dfs(i + 1);
		c.pop();
	}

	return res1 || res2;
}

int main()
{
	int n; cin >> n;

	while (n--) {
		a.clear();
		while (b.size()) b.pop();
		while (c.size()) c.pop();

		for (int i = 0; i < 10; ++i) { int v; cin >> v; a.push_back(v); }

		if (dfs(0)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

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

int num[10];
bool chack;

void solve(int R, int L, int i){
    if(i==10) chack = true;
    if(chack == true) return;
    if(num[i]>R) solve(num[i], L, i+1);
    if(num[i]>L) solve(R, num[i], i+1);
    return;
}
int main(void){
    int N;
    cin >> N;
    while(N>0){
        chack = false;
        for(int i=0; i<10; i++)
            cin >> num[i];
        solve(0,0,0);
        if(chack)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
        N--;
    }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO 1

int Hoge[NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 11];
int Nubedyon(int n, int l, int r);

int main(void){
	int HogeHogePiypPiyo, Piyo;
	cin >> HogeHogePiypPiyo;
	for (int Nubesko = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1; Nubesko < HogeHogePiypPiyo; Nubesko++){
		for (int Dyon = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1; Dyon < NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 10; Dyon++){
			cin >> Hoge[Dyon];
		}
		Hoge[NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 10] = 0;
		Piyo = Nubedyon(NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1,
						NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1,
						NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1);
		if (Piyo == NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1){
			cout << "NO" << endl;
		}
		else{
			cout << "YES" << endl;
		}
	}
	return NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1;
}

int Nubedyon(int n, int l, int r){
	int ans = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1;
	if (n == NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 10){
		ans = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO;
	}
	if (l < Hoge[n]){
		ans = Nubedyon(n + NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO, Hoge[n], r);
	}
	if (r < Hoge[n]){
		ans = Nubedyon(n + NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO, l, Hoge[n]);
	}

	return ans;
}

C++: #include<cstdio>

int main(){
	int n, b, c, t, f;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		b = c = f = 0;
		for(int j = 0; j < 10; j++){
			scanf("%d", &t);
			if(b < t){
				b = t;
			}else{
				if(c < t){
					c = t;
					if(b < c){
						t = b;
						b = c;
						c = t;
					}
				}else{
					f = 1;
				}
			}
		}

		if(f){
			printf("NO\n");
		}else{
			printf("YES\n");
		}
	}
	return 0;
}

C++: #include <iostream>

int main() {
	int n;
	for (std::cin >> n; n > 0; --n) {
		int a = 0, b = 0;
		bool f = true;
		for (int i = 0; i < 10; ++i) {
			int x; std::cin >> x;
			if (x > a) { a = x; }
			else if (x > b) { b = x; }
			else { f = false; }
		}
		std::cout << (f ? "YES" : "NO") << std::endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int a[11];
bool dfs(int i, int b, int c) {
    if (i == 10) return true;
    if (b < a[i]) {
        if (dfs(i + 1, a[i], c)) return true;
    }
    if (c < a[i]) {
        if (dfs(i + 1, b, a[i])) return true;
    }
    return false;
}

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        rep(j, 10) cin >> a[j];
        cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
    }
}