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 <stack>
#include <algorithm>

using namespace std;

struct Channel{
	int channels[2];
	Channel(){
		channels[0] = -1;
		channels[1] = -1;
	}
	bool update(int index, int number){
		if(number > channels[index]){
			channels[index] = number;
			return true;
		}
		else
			return false;
	}
};

int number[10];
int n;

bool dfs(Channel c, int depth){
	if(depth == 10)
			return true;
	Channel c_tmp = c;
	return (c.update(0, number[depth]) && dfs(c, depth+1))
			|| (c_tmp.update(1, number[depth]) && dfs(c_tmp, depth+1));

}

void solve(){
	if(dfs(Channel(), 0))
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

int main(){
	cin >> n;
	while(n--){		
		for(int i=0; i<10; ++i){
			cin >> number[i];
		}
		solve();
	}
	return 0;
}

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

using namespace std;

int n;
vector<int> vec;
int lcount, rcount, l, r;

bool dfs(int i)
{
	if(i == 10) return true;
	if(lcount < 10 && l < vec[i]){ l = vec[i]; if(dfs(i + 1)) return true; }
	if(rcount < 10 && r < vec[i]){ r= vec[i]; if(dfs(i + 1)) return true; }
	return false;
}

int main()
{
	cin >> n;
	lcount = 0; rcount = 0; l = 0; r = 0;
	vec.resize(10);
	for (int j = 0; j < n; j++)
	{

		for (int i = 0; i < 10; i++)
		{
			cin >> vec[i];
		}	
		cout << (dfs(0) ? "YES" : "NO") << endl;
	}
	return 0;
}

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

int B[11]={0};
int C[11]={0};

bool DFS(int *a,int i=0,int b=1,int c=1)
{
	bool judge=true;

	if(i==10)
		return judge;

	judge=false;

	if(B[b-1]<a[i]){
		B[b]=a[i];
		judge=DFS(a,i+1,b+1,c);
		
	}
	if(C[c-1]<a[i]){
		C[c]=a[i];
		judge=DFS(a,i+1,b,c+1);
		
	}

	return judge;
}        

int main()
{
        int N;
		int i=0;
        cin>>N;

		while(i<N){
			int A[10]={0};
			for(int i=0;i<10;i++)
				cin>>A[i];

            if(DFS(A)==true)
                cout<<"YES"<<endl;
            else
				cout<<"NO"<<endl;



		for(int i=1;i<=10;i++){
			cout<<"??????B["<<i<<"]="<<B[i]<<' ';
		}
		cout<<endl;

		for(int i=1;i<=10;i++){
			cout<<"??????C["<<i<<"]="<<C[i]<<' ';
		}
		cout<<endl;




			i++;
        }
                
		while(1);

        return 0;
}

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

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int a = 0, b = 0;
		int num[10];
		for(int j = 0; j < 10; j++){
			cin >> num[j];
		}
		for(int j = 0; j < 10; j++){
			if(a < b){
				swap(a,b);
			}
			if(num[j] > a){
				a = num[j];
			}
			else if(num[j] > b){
				b = num[j];
			}
			else{
				cout << "NO" << endl;
				break;
			}
			if(j == 9){
				cout << "YES" << endl;
			}
		}
	}
}

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

using namespace std;

int a[10];

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

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

    return false;
}

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

    while (n--) {
        for (int i = 0; i < 10; ++i) cin >> a[i];
        cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
    }
}

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

int main(){
	int B, C;
	int N;
	int ball[10];
	bool bo;
	
	scanf("%d", &N);
	while(N--){
		for(int i = 0; i < 10; i++) scanf("%d", &ball[i]);
		
		B = 0; C = 0;
		
		bo = true;
		for(int i = 0; i < 10; i++){
			if(ball[i] > B) B = ball[i];
			else if(ball[i] > C) C = ball[i];
			else{
				bo = false;
				break;
			}
		}
		
		if(bo) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int N,temp;
	int b,tempb,tempc,ch;
	
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		tempb=0;
		tempc=0;
		ch=0;
		for(int j=0;j<10;j++){
			scanf("%d",&temp);
			if(tempb<temp)
			tempb=temp;
			else if(tempc<temp)
			tempc=temp;
			else{
				ch=1;
			}
		}
		if(ch==0)
		printf("YES\n");
		else
		printf("NO\n");
	}
}

C++: #include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
	int N,pre,current,second_pre;
	bool NO_FLG;

	scanf("%d",&N);
	for(int i=0;i<N;i++){
		pre = -1;
		second_pre = -1;
		NO_FLG = false;
		for(int k = 0; k < 10; k++){
			scanf("%d",&current);
			if(k == 0){
				pre = current;
			}else{
				if(pre > current){
					if(second_pre == -1){
						second_pre = pre;
					}else{
						if(second_pre > pre){
							printf("NO\n");
							NO_FLG = true;
							break;
						}else{
							second_pre = pre;
						}
					}
				}
				pre = current;
			}
		}
		if(!NO_FLG)printf("YES\n");

	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(void) {
    int N, a, b, c;
    cin >> N;
    for (; N--; ) {
        b = c = 0;
        bool ok = true;
        for (int i = 0; i < 10; i++) {
            cin >> a;
            if (a > b) {
                b = a;
            } else if (a > c) {
                c = a;
            } else {
                ok = false;
                break;
            }
        }
        cout << (ok ? "YES" : "NO") << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main() {

	stack<int> B, C;
	int n,ball;

	cin >> n;

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

			if (i == 0)
				B.push(ball);

			else if (B.top() > ball)
				if (C.empty())
					C.push(ball);
				else if (C.top() < ball)
					C.push(ball);
				else {
					cout << "NO" << endl;
					break;
				}

			else {
				if (B.top() < ball)
					B.push(ball);
				else {
					cout << "NO" << endl;
					break;
				}
			}

			if (i == 9)
				cout << "YES" << endl;
		}
		n--;
	}
	return 0;
}

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

int B[11]={0};
int C[11]={0};

bool DFS(int *a,int i=0,int b=1,int c=1)
{
	bool judge=true;

	if(i==10)
		return judge;

	judge=false;

	if(B[b-1]<a[i]){
		B[b]=a[i];
		judge=DFS(a,i+1,b+1,c);
		
	}
	if(C[c-1]<a[i]){
		C[c]=a[i];
		judge=DFS(a,i+1,b,c+1);
		
	}

	return judge;
}        

int main()
{
        int N;
	int i=0;
        cin>>N;

	while(i<N){
          int A[10];
          for(int i=0;i<10;i++){
           cin>>A[i];
          }

          if(DFS(A)==true){
           cout<<"YES"<<endl;
          }
          else{
           cout<<"NO"<<endl;
          }

          i++;
        }
                
        return 0;
}