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 <stdio.h>
#include <vector>


using namespace std;

int main() {
	vector<int> left;
	vector<int> right;
	vector<int> all;

	bool flag = true;

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			int temp;
			cin >> temp;
			all.push_back(temp);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			if (left.size() > 0) {
				if (all[10 * i + j] > left[left.size() - 1]) {
					left.push_back(all[10 * i + j]);
				}
				else {
					if (right.size() > 0) {
						if (all[10 * i + j] > right[right.size() - 1])
							right.push_back(all[10 * i + j]);
						else
							flag = false;
					}
					else {
						right.push_back(all[10 * i + j]);
					}
				}
			}
			else {
				left.push_back(all[10 * i + j]);
			}
		}

		if (flag)
			cout << "YES" << endl;
		else
			cout << "NO"<<endl;
		flag = true;
	}

	return 0;
}

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

int main() {
	int n;
	int d[10];
	vector<int>va;
	vector<int>vb;
	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.push_back(d[j]);
				ca++;
			}

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

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

		}
		cout << "YES" << endl;

	FINLOOP:

		va.erase(va.begin(), va.end());
		vb.erase(vb.begin(), vb.end());
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<string>
#include<cstring>
#include<math.h>
#include<algorithm>
#include<map>

#include<sstream>
#include<ctype.h>

#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
 
typedef long long ll;
using namespace std;
 
const int INF = 0x7f7f7f7f;
const double PI = acos(-1.0);
const int maxn = 1005;
const int MOD = (int)1e9+7;
#define LOCAL 0
#define MOD 1000000007

int a[15],l[15],r[15];
bool res;

bool dfs(int apos,int lpos,int rpos){
	
	if(apos == 11)	return true;
	if(a[apos] > l[lpos-1]){
		l[lpos] = a[apos];
		if(dfs(apos+1,lpos+1,rpos)) return true;
	} 
	if(a[apos] > r[rpos-1]){
		r[rpos] = a[apos];
		if(dfs(apos+1,lpos,rpos+1)) return true;
	} 
	return false;
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		memset(a,0,sizeof(a));
		memset(l,0,sizeof(l));
		memset(r,0,sizeof(r));
		for(int i = 1 ; i <= 10 ; i ++) 	scanf("%d",&a[i]);		
		if(dfs(1,1,1)){
			cout << "YES" << endl;	
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
	int n,i,memo,flag,box1,box2,ball[11];
	scanf("%d",&n);
	while(n--){
		for(i=1;i<=10;i++){scanf("%d",&ball[i]);}
		flag=0;box1=0;box2=0;
		for(i=1;i<10;i++){
			if(ball[i]>box1){box1=ball[i];}
			else if(ball[i]>box2){box2=ball[i];}
			else {flag++;break;}
		}
		if(flag)printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100010;
int t,ok,l[15],r[15],a[15];
void dfs(int i,int x,int y){
	if(i==11){ok=1;return;}
	if(a[i]>l[x]){
		l[x+1]=a[i];
		dfs(i+1,x+1,y);
	}
	if(a[i]>r[y]){
		r[y+1]=a[i];
		dfs(i+1,x,y+1);
	}
}
int main()
{
	cin>>t;
	while(t--){
		memset(l,0,sizeof(l));
		memset(r,0,sizeof(r));
		for(int i=1;i<=10;i++)cin>>a[i];
		ok=0;
		dfs(1,0,0);
		if(ok==1)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>
#include <cstring>
#include <cstdlib>

typedef long long ll;

using namespace std;

struct ToLower {    char operator()(char c) { return tolower(c); }};

int main(void){
	int N;
	cin >> N;

	int ball[10];
	int a=0, b=0;
	int check = 0;

	for(int i=0; i<N; ++i){
		a=0, b=0, check=0;

		for(int j=0; j<10; j++){
			cin >> ball[j];
		}
		for(int j=0; j<10; ++j){
			if(ball[j] > a && ball[j] > b){
				(a > b ? a : b) = ball[j];
				continue;
			} else if(ball[j] < a && ball[j] < b){
				cout << "NO" << endl;
				check = 1;
				break;
			} else {	
				(a < b ? a : b) = ball[j];
			}
		}
		if(check == 0) cout << "YES" << endl;

	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>

#define numof(array) (sizeof (array) / sizeof *(array))
using namespace std;

int A[10] = {};
int B[10] = {0};
int C[10] = {0};



bool check(void)
{
    for (int i = 1; B[i] != 0; i++) {
        if (B[i-1] > B[i]) return false;
    } 
    
    for (int i = 1; C[i] != 0; i++) {
        if (C[i-1] > C[i]) return false;
    } 

    return true;
}

bool dfs(int i, int b)
{
    if (i == 10) return check();

    //Bにいれる
    B[b] = A[i];
    if (dfs(i+1, b+1)) return true;
    B[b] = 0;

    //Cに入れる
    C[i-b] = A[i];
    if (dfs(i+1, b)) return true; 
    C[i-b] = 0;

    return false;
}

int main(void)
{
    int N;
    cin >> N;
    while (N--) {
        for (int i = 0; i < 10; i++) {
            cin >> A[i];
        }    
        if (dfs(0,0)) cout << "YES" << endl;
        else cout << "NO" << endl;

    }
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(void)
{
int n;
cin>>n;

for(int i=0;i<n;i++)
{
	int a[10]={0};
	for(int j=0;j<10;j++)
	{
	int x;
	cin>>x;
	a[j]=x;
	}
	int b=a[0],c=a[1],k;
		for(k=2;k<10;k++)
		{
			if(b<a[k])b=a[k];
			else if(c<a[k])c=a[k];
			else 
			{
			cout<<"NO"<<endl;
			break;
			}
		}
		if(k==10)cout<<"YES"<<endl;
	/*for(int i=0;i<10;i++)
	{
	cout<<b[i]<<" ";

	}
	cout<<endl;
	for(int i=0;i<10;i++)
	{
	cout<<c[i]<<" ";
	}
	for(int i=0;i<10-1;i++)
	{
		if(b[i]>b[i+1] && b[i+1]!=0 || c[i]>c[i+1] && c[i+1]!=0)
		{
		cout<<"NO"<<endl;
		break;
		}
	else 
		{
		cout<<"YES"<<endl;
		break;
		}
	}*/
}
return 0;
}

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

int N, H[10];

void solve()
{
  int big=0, small=0;
  bool flag = true;
  for (int i = 0; i < 10; i++)
  {
    if (H[i] > big) big = H[i];
    else if (H[i] > small) small = H[i];
    else
    {
      flag = false;
      break;
    }
  }
  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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