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>

int main(){
	int c, tmp, d[2] = {0};
	bool res;

	scanf("%d", &c);

	while(c--){
		res = true;
		d[0] = d[1] = 0;

		for(int i = 0; i < 10; ++i){
			std::cin >> tmp;
		
			if( d[0] < tmp ){
				if(d[1] < tmp){
					*std::max_element(d, d + 1) = tmp;
				}else{
					d[0] = tmp;
				}
			}else if( d[1] < tmp ){
				d[1] = tmp;
			}else{
				res = false;
				//break;
			}
		}

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

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <stack>
using namespace std;
int a[10];
bool ans;
void dfs(int i,int r,int l){
	if(i==10)return;
	if(ans==0)return;
	if(r<a[i])dfs(i+1,a[i],l);
	if(l<a[i])dfs(i+1,r,a[i]);
	ans=0;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		for(int i=0;i<10;i++)cin>>a[i];
		dfs(0,0,0);
	if(ans)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	}
}

C++: #include<iostream>
#include<stack>
using namespace std;
int main(){
  int N;
  cin >> N;
  int boll[10];
  stack<int> B,C;
  B.push(0); C.push(0);
  for(int i=0;i<N;i++){
    for(int i=0;i<10;i++) cin >> boll[i];
    for(int j=0;j<10;j++){
        if(boll[j]>B.top()) B.push(boll[j]);
        else if(boll[j]>C.top()) C.push(boll[j]);
        else{
          cout << "NO" << endl;
          break;
        }
        if(j==9) cout << "YES" << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    
    for(int i=0;i<N;i++){
        int ball[10];
        bool isYES=true;
        int b=0, c=0;

        for(int j=0;j<10;j++)cin>>ball[j];

        for(int j=0;j<10;j++){
            if(ball[j]>b){
                b=ball[j];
            }else if(ball[j]>c){
                c=ball[j];
            }else{
                isYES=false;
                break;
            }
        }

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

    return 0;
}

C++: #include <iostream>  
  
using namespace std;  
  
const int N = 10;  
  
int main()  
{  
    int n;  
  
    cin >> n;  
    while(n--) {  
        bool ans = true;  
        int a, b=-1, c=-1;  
        for(int i=1; i<=N; i++) {  
            cin >> a;  
            if(ans) {  
                if(a > b)  
                    b = a;  
                else if(a > c)  
                    c = a;  
                else  
                    ans = false;  
            }  
        }  
  
        cout << (ans ? "YES" : "NO") << endl;  
    }  
  
    return 0;  
}

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

//定数
const int MAX_M=10;
//入力
int N;
int balls[MAX_M];

bool dfs(int i, int A, int B){
    if (i == 10){
        return true;
    }

    int value = balls[i];

    if (A >= value && B >= value){
        return false;
    }else if (A < value){
        return dfs(i+1, value, B);
    }else if (B < value){
        return dfs(i+1, A, value);
    }
}

string solve(){
    if (dfs(0, 0, 0)) return (string)"YES";
    else return (string)"NO"; 
}

int main(){
    queue<string> res;
    cin >> N;
    for (int i=0; i<N; i++){
        for (int j=0; j<10; j++){
            cin >> balls[j];
        }
        res.push(solve());
    }

    while (res.size()){
        cout << res.front() << endl;
        res.pop();
    }
    
    return 0;
}

C++: //能否成功地把球全部放入容器内 
#include<iostream>
#include<cstring>
using namespace std;
int a[100];
int aa[100],aaa[100];//分别表示两边的容器 
int main(){
	int t;
	cin>>t;
	while(t--){
		memset(a,0,sizeof(a));
		memset(aa,0,sizeof(aa));//左边 
		memset(aaa,0,sizeof(aaa));//右边 
		for(int i=1;i<=10;i++)
			cin>>a[i];
		aa[1]=a[1],aaa[0]=a[0];
		int p1=0,p2=0;//aa aaa的下标
		int i;
        for(i=2;i<=10;i++){
            if(a[i]>aa[p1])
                aa[++p1]=a[i];
            else if(a[i]>aaa[p2])
                aaa[++p2]=a[i];
            else{
                cout<<"NO"<<endl;
                break;
            }
        }
        if(i>10)
            cout<<"YES"<<endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
	ios :: sync_with_stdio(false);
	int t; cin >> t;
	while(t --) {
		int a[10];
		for(int i = 0; i < 10; i ++)
			cin >> a[i];
		bool f = false;
		auto check = [](auto v) {
			for(int i = 0; i + 1 < v.size(); i ++)
				if(v[i] > v[i + 1])
					return false;
			return true;
		};
		for(int k = 0; k < (1 << 10); k ++) {
			vector <int> u, v;
			for(int i = 0; i < 10; i ++)
				if((k >> i) & 1)
					u.push_back(a[i]);
				else
					v.push_back(a[i]);
			f |= check(u) && check(v);
		}
		cout << (f ? "YES\n" : "NO\n");
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define rep(i,j) for(int (i)=0;(i)<(int)(j);++(i))

int ball[10];

bool dfs(int n, int a, int b) {
    if (n == 10) return true;
    if (ball[n] > a && dfs(n+1, ball[n], b)) return true;
    if (ball[n] > b && dfs(n+1, a, ball[n])) return true;
    return false;
}

int main() {
    int n; cin >> n;
    while (n--) {
        rep(i, 10) cin >> ball[i];
        if (dfs(0, 0, 0)) puts("YES");
        else puts("NO");
    }
}

C++: #include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int n = 10;
int t;
int a, b, c;

int main()
{
  cin >> t;

  while(t--){
    bool ok = true;
    b = c = 0;
    rep(i, n){
      cin >> a;
      //if(b > c) swap(b, c);
      if(a > c){ c = a;  continue; }
      if(a > b){ b = a;  continue; }
      ok = false;
      break;
    }
    puts(ok ? "YES" : "NO");
  }

  return 0;
}