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>

using namespace std;

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

    for( int iii=0; iii<n; ++iii ) {
        stack<int> p[2];
        bool succ = true;

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

            if ( p[0].size() == 0 ) {
                p[0].push( ball );

            } else {
                int diff = 999;
                int t;
                for( int j=0; j<2; ++j ) {
                    int r = 0;
                    if ( !p[j].size() == 0 )
                        r = ball - p[j].top();
                    if ( r < 0 )
                        continue;

                    if ( r < diff ) {
                        t = j;
                        diff = r;
                    }
                }

                if ( diff == 999 ) {
                    succ = false;
                } else {
                    p[t].push( ball );
                }

            }
        }

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

C++: // 
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int a[10], n;
bool bit(int n,vector<int>left,vector<int>right) {
	if (n == 10) {
		bool left_f = true;
		bool left_r = true;
		roop(i, left.size() - 1) { if (left[i + 1] <= left[i]) { return false; } }
		roop(i, right.size() - 1) { if (right[i + 1] <= right[i]) { return false; } }
		return true;
	}
	if (left[left.size() - 1] > a[n] && right[right.size() - 1] > a[n]) { return false; }
	vector<int>new_l = left;
	vector<int>new_r = right;
	
	new_l.push_back(a[n]);
	new_r.push_back(a[n]);
	return (bit(n + 1, new_l, right) || bit(n + 1, left, new_r));
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	vector<int>emptynow;
	roop(i, n) {
		roop(j, 10) {
			cin >> a[j];
		}
		if (bit(0, emptynow, emptynow)) { cout << "YES" << endl;}
		else { cout << "NO" << endl; }
	}
	return 0;
}

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

typedef long long ll;

using namespace std;

vector<int> balls(10);

bool flag;

void dfs(int i, int left, int right) {
    if (i == 10) {
        flag = true;
        return;
    }
    int num = balls[i];
    if (left < num) {
        dfs(i+1, num, right);
    }
    if (right < num) {
        dfs(i+1, left, num);
    }
}

void solve() {
    flag = false;
    for (int i = 0; i < 10; i++) {
        cin >> balls[i];
    }
    dfs(0, 0, 0);
    string ans = flag ? "YES": "NO";
    cout << ans << endl;
}

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

    int N = 0;
    cin >> N;

    for (int i = 0; i < N; i++) {
        solve();
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

	int a, b=0, i, N, x[10], end=0;

	cin >> N;
	for(; N!=0; N--) {
		for(i=0; i<10; i++)
			cin >> x[i];
		for(i=0; i<10; i++) {
			if(i==0) {
				a=x[i];
				i++;
			}
			if(a>x[i]&&b>x[i]) {
				end++;
				break;
			}
			if(a<x[i])
				a=x[i];
			else if(b<x[i])
				b=x[i];
		}

		if (end!=0)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
		end=0;
	}

	return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;

int main(void){
  int n,N;
  vector<int> v(10);
  cin >> N;
  REP(n,N){
    int i;
    bool flg = true;
    REP(i,v.size()) cin >> v[i];
    int max = 0,min = 0;
    REP(i,v.size()){
      if(max<v[i]) max = v[i];
      else if(min<v[i]) min = v[i];
      else{
        flg = false;
        break;
      }
    }
    if(flg) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

int balls[10];
bool drop(int pos, int left, int right) {
    if (pos == 10) return true;
    return balls[pos] > left && drop(pos+1, balls[pos], right) || balls[pos] > right && drop(pos+1, left, balls[pos]);
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 10; ++j) 
            cin >> balls[j];
        if (drop(0, 0, 0)) 
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int a[9]={};
		int b[9]={};
		int dat[9],o=0,s=0,f;
		for(int k=0;k<10;k++){
			cin>>f;
			dat[k]=f;
		}
		for(int j=0;j<=10;j++){
			if(j==10){
				cout<<"YES"<<endl;
				break;
						}					if(s==0 || dat[j]>a[s-1]){
				a[s]=dat[j];
				s++;
			}
			else if(o==0 || dat[j]>b[o-1]){
				b[o]=dat[j];
				o++;}
			else{
				cout<<"NO"<<endl;
			break;
			}
					}
	}
	return 0;
}

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

using namespace std;

int a[10];
int l[10],r[10],bl[10],br[10];
int main()
{
	int T;cin >> T;
	while(T--)
	{
		for(int i = 0;i < 10;++i)
			cin >> a[i];
		int flag = 0;
		for(int op = 0;op < 1 << 10;++op)
		{
			int lcnt = 0,rcnt = 0;
			for(int i = 0;i < 10;++i)
			{
				if(op >> i & 1)
					l[lcnt++] = a[i];
				else
					r[rcnt++] = a[i];
			}
			bool ok = 1;
			for(int i = 1;i < lcnt && ok;++i)
			{
				if(l[i] < l[i-1])
					ok = 0;
			}
			for(int i = 1;i < rcnt && ok;++i)
				if(r[i] < r[i-1])
					ok = 0;
			if(ok)
			{
				flag = 1;
				cout << "YES\n";
				break;
			}
		}
		if(!flag)
			cout << "NO\n";
	}
	return 0;
}

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

int main() {
	int n;
	int d[10];
	int va[10];
	int vb[10];
	int trush;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> d[i];
		}

		int ca = 0, cb = 0;
		va[0] = d[0];
		ca++;
		if (d[1] > va[0]) {
			va[1] = d[1];
			ca++;
		}

		else {
			vb[0] = d[1];
			cb++;
		}

	for (int j = 2; j < 10; j++) {

			if (d[j] > va[ca-1]) {
				va[ca] = d[j];
				ca++;
			}

			else if (d[j] > vb[cb-1]) {
				vb[cb] = d[j];
				cb++;
			}

			else {
				cout << "NO" << endl;
				goto FINLOOP;
			}

		}

	cout << "YES" << endl;
	FINLOOP:
		for (int i = 0; i < 10; i++) {
			va[i] = 0;
		}
		for (int i = 0; i < 10; i++) {
			vb[i] = 0;
		}
	}
	return 0;
}