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 <stdio.h>

int main(void)
{
	int tubeM[10];
	int tube1[10], tube2[9];
	int i, j, k;
	int n;
	int ans;
	
	for (i = 0; i < 9; i++){
		tube2[i] = 0;
	}
	
	scanf("%d", &n);
	
	while(n){
		for (i = 0; i < 10; i++){
			scanf("%d", &tubeM[i]);
		}
		
		tube1[0] = tubeM[0];
		for (i = 1, j = 0, k = 0; i < 10; i++){
			if (tubeM[i] > tube1[j]){
				j++;
			}
			else {
				tube2[k] = tubeM[i];
				k++;
			}
		}
		
		ans = 0;
		for (i = 1; tube2[i] != 0; i++){
			if (tube2[i - 1] > tube2[i]){
				ans = 1;
				break;
			}
		}
		
		if (ans == 0){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		
		n--;
	}
	
	return (0);
}

C++: //AC
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0033
//dfs
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int res = 0;
int num[11];
int T;
int B = 0, C = 0;
void d(int i) {
	if (i == 10) return;
	if (num[i] > B) {
		 B = num[i];
		res++;
	}else if(num[i] > C){
		C = num[i];
		res++;
	}
	d(i + 1);
}
int main() {
	
	while (scanf("%d", &T)!= EOF) {
		
		while (T--) {
			C=B=res = 0;
			for (int i = 0; i < 10; i++) {
				scanf("%d", &num[i]);
			}
			d(0);
			
			printf("%s\n", res==10?"YES":"NO");
		}
	}
	return 0;
}

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

int n;
vector<int> a(10), b, c;

void solve(vector<int> a){
	b.push_back(a[0]);
	c.push_back(0);
	for(int i = 1; i < 10; i++){
		if(a[i] - b[b.size() - 1] > 0 && a[i] - c[c.size() - 1] > 0){
			if(a[i] - b[b.size() - 1] < a[i] - c[c.size() - 1]){
				b.push_back(a[i]);
			}else{
				c.push_back(a[i]);
			}
		}else if(a[i] - b[b.size() - 1] > 0 && a[i] - c[c.size() - 1] < 0){
			b.push_back(a[i]);
		}else if(a[i] - b[b.size() - 1] < 0 && a[i] - c[c.size() - 1] > 0){
			c.push_back(a[i]);
		}else{
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 10; j++){
			cin >> a[j];
		}
		solve(a);
	}
}

C++: #include <stack>
#include <cstdio>
using namespace std;
  int main(){
    int a,b,n,i,j,x[10];
    scanf("%d",&n);
for(j=0;j<n;j++){
    for(i=0;i<10;i++){
       scanf("%d",&x[i]);
}
stack<int> B;
stack<int> C;
B.push(x[0]);
C.push(x[1]);
for(i=1;i<9;i++){
if(B.top()<x[i+1]){
B.push(x[i+1]);
}else if(C.top()<x[i+1]){
	C.push(x[i+1]);
}else{
	printf("NO\n");
	goto aaa;
}
}
printf("YES\n");
aaa:;
}
return 0;
  }

C++: #include <iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	while(N--){
		int pipe[2] = {0};
		int i=0;
		bool f=false;
		for(; i < 10; i++){
			int num;
			cin >> num;
			if(pipe[1] > pipe[0]){
				
				if(num > pipe[1]){
					pipe[1] = num;
				}else if(num > pipe[0]){
					pipe[0] = num;
				}else{
					f=true;
					break;
				}
				
			}else{
				if(num > pipe[0]){
					pipe[0] = num;
				}else if(num>pipe[1]){
					pipe[1] = num;
				}else{
					f=true;
					break;
				}
			}
			
		}
		if(!f) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int t,n,i,j,mmax;
	int a[11];
	cin>>t;
	while(t--) {
		for(i=1;i<=10;i++) cin>>a[i];
		mmax=a[1];
		a[1]=-1;
		for(i=2;i<=10;i++) {
			if(a[i]>mmax) {
				mmax=a[i];
				a[i]=-1;
			}
		}
		mmax=-1;
		for(i=1;i<=10;i++) {
			if(a[i]==-1) continue;
			if(a[i]<mmax) break;
			mmax=a[i];
		}
		if(i==11) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n; cin>>n;
    while(n--){
        int amin = 0;
        int bmin = 0;
        int tmp;
        bool ans = true;
        for(int i=0;i<10;++i){
            cin>>tmp;
            if(tmp <= amin && tmp <= bmin){
                ans = false;
            }
            if(!ans) continue;
            if(tmp > amin && tmp > bmin){
                if(bmin > amin)
                    bmin = tmp;
                else
                    amin = tmp;
            }else if(tmp > amin)
                amin = tmp;
            else
                bmin = tmp;
        }
        if(ans) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

C++: #include <cstdio>
using namespace std;
int n, arr[15];
bool flag;
void dfs(int x1, int x2, int y1, int y2, int cnt)
{
    if (x2 < x1 || y2 < y1)
        return;
    if (cnt == 10)
    {
        flag = true;
        return;
    }
    dfs(x2, arr[cnt], y1, y2, cnt + 1);
    dfs(x1, x2, y2, arr[cnt], cnt + 1);
}
int main()
{
    scanf("%d", &n);
    while (n--)
    {
        for (int i = 0; i < 10; i++)
            scanf("%d", &arr[i]);
        flag = false;
        dfs(0, 0, 0, 0, 0);
        if (flag)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<bitset>
#include<queue>
#include<string>
#include<vector>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,n,a) for(int i=n;i>a;i--)
#define mem0(x) memset(x,0,sizeof(x))
#define memff(x) memset(x,INF,sizeof(x))
#define INF 100000000
using namespace std;
typedef pair<int,int> p;
typedef long long LL;
int aa[15];
int main()
{
    //freopen("input.in","r",stdin);
    int n;
    bitset<10> dis;
    while(cin>>n)
    {
        for(int i=1;i<=10;i++)
        cin>>aa[i];
        int all=1024;
        while(all>0)
        {
            dis=static_cast<bitset<10> >(all);
            bool flag=true;
            int left=0,right=0;
            for(int i=1;i<=10;i++)
            {
                if(dis[i-1])
                {
                    if(aa[i]>left)
                    {
                         left=aa[i];
                    }
                    else
                    {
                        flag=false;
                        break;
                    }
                }
                else
                {
                    if(aa[i]>right)
                    {
                        right=aa[i];
                    }
                    else
                    {
                        flag=false;
                        break;
                    }
                }
            }
            if(flag)
            {
                break;
            }
            else all--;
        }
        if(all>0)
        cout<<"YES"<<endl;
        else
        cout<<"NO"<<endl;
    }
    return 0;
}