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<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {

  int n;
  cin >> n;
  while(n != 0){
    n--;
    int l = 0;
    int r = 0;
    int tmp;
    bool f = true;
    for(int i=0; i<10; i++){
      cin >> tmp;
      if( l < tmp ) l = tmp;
      else if( r < tmp ) r = tmp;
      else f = false;
    }
    cout << ( f ? "YES" : "NO" ) << endl;
  }


  return 0;
}


// EOF

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

int n;
int a[10];
vector<int> l, r;
vector<int> emp;

bool dfs(int p){
//	printf("p=%d\n", p);
	/*
	printf("l ");
	for(int i=0; i<l.size(); i++){
		printf("%d ", l[i]);
	}
	printf("\nr ");
	for(int i=0; i<r.size(); i++){
		printf("%d ", r[i]);
	}
	printf("\n");
*/
	if(p == 10) return true;
	l.push_back(a[p]);
	if(l.size() == 1 || l[l.size() - 2] < l[l.size() - 1]){
		return dfs(p+1);
	}else{
		l.pop_back();
		r.push_back(a[p]);
		if(r.size() == 1 || r[r.size() - 2] < r[r.size() - 1]){
			return dfs(p+1);
		}else{
			r.pop_back();
			return false;
		}
	}
}

int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		l = emp;
		r = emp;
		for(int j=0; j<10; j++){
			scanf("%d", &a[j]);
		}
		if(dfs(0)) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

int balls[10];

bool dfs(int i=0,int b_top=0,int c_top=0){
  //10個のボールを落とせたらtrue
  if(i == 10) return true;
  
  //Bのほうに入れる
  if(balls[i] > b_top && dfs(i+1,balls[i],c_top))
    return true;

  //Cの方に入れる
  if(balls[i] > c_top && dfs(i+1,b_top,balls[i]))
    return true;

  return false
}

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

C++: #include <iostream>
#define CAPACITY 9
using namespace std;
int b, c;

bool dfs(int pos, int ary[], bool flag) {
    cout << "B = " << b << "C = " << c << endl;
    if(pos < 0) {
        return(false);
    }

    flag = dfs(pos - 1, ary, flag);
    
    if(ary[pos] > b) {
        b = ary[pos];
    } else if(ary[pos] > c) {
        c = ary[pos];
    } else {
        return(false);
    }
    
    if(pos == CAPACITY) {
        flag = true;
    }
    
    return(flag);
}

int main(void) {
    int num;
    
    cin >> num;
    int ary[10];
    
    for(int r = 0; r < num; r++) {
        for(int c = 0; c < 10; c++) {
            cin >> ary[c];
        }
        b = ary[0];
        c = INT_MIN;
        if(dfs(CAPACITY, ary, true)) {
            cout << "YES";
        } else {
            cout << "NO";
        }
        cout << endl;
    }
    
    return(0);
}

C++: int main (){
       int N,a[20]={0},b[20]={0},t;
       int ac=0,bc=0;
       cin>>N;
       for(int j=0;j<N;j++){
       for(int i=0;i<10;i++){
              cin>>t;
              if(a[ac]<t){
                 a[ac+1]=t;
                 ac++;
               }
               else if(b[bc]<t){
                  b[bc+1]=t;
                  bc++;
                }
                else break;
           }
           if(ac+bc==10){
                 cout<<"YES"<<endl;
            }
           else cout<<"NO"<<endl;
           }
return 0;
}

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

using namespace std;


int q;
int Ball[10];
bool flag;
vector<string> log;

bool is_satisfies(vector<int> a) {
    vector<int> copy = a;
    sort(a.begin(), a.end());
    return a == copy;
}

void bfs(int i, vector<int> B, vector<int> C) {
    if (i == 9) {
        if (is_satisfies(B) && is_satisfies(C))
            flag = true;
        else
            flag = flag == true ? true : false;
    } else {
        vector<int> temp;

        temp = B;
        temp.push_back(Ball[i]);
        bfs(i + 1, temp, C);

        temp = C;
        temp.push_back(Ball[i]);
        bfs(i + 1, B, temp);
    }
}

void solve() {
    vector<int> B, C;
    flag = false;

    bfs(0, B, C);

    if (flag)
        log.push_back("YES");
    else
        log.push_back("NO");
}

int main() {
    cin >> q;
    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < 10; ++j)
            scanf("%d", &Ball[j]);

        solve();
    }

    for (int i = 0; i < log.size(); ++i) {
        cout << log[i] << endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
signed main(void){
	ios::sync_with_stdio(false);
	int T;
	cin>>T;
	for(int t=1;t<=T;t++){
		int a=0,b=0,ok=true;
		for(int i=1,x;i<=10;i++){
			cin>>x;
			if(!ok)continue;
			if(x<a&&x<b){
				cout<<"NO"<<endl;
				ok=false;
				continue;
			}
			else if(x>a&&x>b){
				if(a>b)	a=x;
				else	b=x;
			}
			else if(x<a&&x>b){
				b=x;
			}
			else if(x>a&&x<b){
				a=x;
			}
			if(i==10)
				cout<<"YES"<<endl;
		}
	}
}

C++: #include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>

#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<sstream>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  int c;
  string s;

  cin >> c;
  cin.ignore();
  for (int i = 0; i < c; ++i){
    bool success = true;
    int l,r,in;
    l = r = 0;
    for(int i = 0;i < 10;i++){
      cin >> in;
      if(in > r)r = in;
      else if(in > l)l = in;
      else success = false;
    }
    cout << (success ? "YES" : "NO") << endl;
  }
  return 0;
}