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<vector>
#include<string>
#pragma region defins
#define ll long long
#define loop(i,n) for (int i = 0; i < n; i++)
#define loops(i,f,n) for (int i = (f); i < n; i++)
#define INF 100000000000000
#define sort(a) sort(a.begin(),a.end())
#define rsort(a) sort(a.rbegin(),a.rend())
using namespace std;
#pragma endregion
vector<int> balls(10);
bool dfs(int now, int btop, int ctop)
{
	if (now == 10)return true;
	if (balls[now] > btop)dfs(now + 1, balls[now], ctop);
	else if (balls[now] > ctop)dfs(now + 1, btop, balls[now]);
	else return false;
}

int main()
{
	int n; cin >> n;
	loop(i, n)
	{
		loop(i, 10)cin >> balls[i];
		cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
	}
}

C++: #include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
    int N,pre,current,second_pre;
    bool NO_FLG;

    scanf("%d",&N);
    for(int i=0;i<N;i++){
        pre = -1;
        second_pre = -1;
        NO_FLG = false;
        for(int k = 0; k < 9; k++){
            scanf("%d",&current);	//????????????????????????
            if(k == 0){	//??????????????????????????´?????????????????????
                pre = current;
            }else{
                if(pre > current){	//1?????????????????????????????§????????´???,current?????????1????????????????§????
                    if(second_pre == -1){	//?°?????????°????????\?????????????§????
                        second_pre = current;
                    }else{
                        if(second_pre > current){ //2????????????????????°??????current???????????§????????´???
                            printf("NO\n");
                            NO_FLG = true;
                            break;
                        }else{	//2????????????????????°??????current??????????°?????????´???
                            second_pre = current;
                        }
                    }
                }else{ //pre < current
                	pre = current;
                }
            }
        }
        if(!NO_FLG)printf("YES\n");

    }
    return 0;
}

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


bool saiki(int ball[],int ttB,int ttC,int res){
	if(res==10)return true;
	if(ball[res]>ttB){
		return saiki(ball,ball[res],ttC,res+1);
	}
	if(ball[res]>ttC){
		return saiki(ball,ttB,ball[res],res+1);
	}
	return false;
}

int main(void){
	int a,b;
	int ball[11];
	int ttB=0,ttC=0;
	int res=0;
	int n;
	scanf("%d",&n);
	for(a=0;a<n;a++){
		memset(ball,0,sizeof(ball));
		ttB=0;
		ttC=0;
		res=0;
		for(b=0;b<10;b++){
			scanf("%d",&ball[b]);
		}
		if(saiki(ball,ttB,ttC,res)==true)printf("Yes\n");else printf("No\n");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int X,Y;
const int N=10;
int D,ball[N];

bool solve(int i){
	if(i==N)return true;//iがボールの個数に追いついたら終了
	if(X<ball[i]){//入るボールが入ってるボールより大きければ
	X=ball[i];//ボールを入れる
		if(solve(i+1))return true;
	
	}
	if(Y<ball[i]){
	Y=ball[i];
		if(solve(i+1))return true;
	}
	return false;

}
//solve関数　終わる条件→
//solve関数に入った初めの処理→
//solve関数に入って２回目の処理→


int main(){
	cin>>D;
	for(int l=0;l<D;l++){
		for(int i=0;i<N;i++)cin>>ball[i];
		X=ball[0];//一つ目のボールを右に入れておく
			if(solve(1))cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
}	

return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int kaizyo(int x){
    if(x==1)return x;
    else return x*kaizyo(x-1);
}

vector<int> v(10);
bool f=true;
bool dfs(int i,int top1,int top2){
    if(!f)return false;
    if(i==10)return true;
    
    
    if(top1>v[i]&&top2>v[i]){
        f=false;
        //return false;
    }
    else if(top1<v[i]&&top2>v[i]) {
        if(!dfs(i+1,v[i],top2))f= false;
        //return true;
    }
    else if(top1>v[i]&&top2<v[i]){
        if(!dfs(i+1,top1,v[i]))f= false;
        //return true;
    }
    else if(top1<v[i]&&top2<v[i]){
        if(top1<top2){if(!dfs(i+1,top1,v[i]))f=false;}
        else if(!dfs(i+1,v[i],top2))f= false;
        //return true;
    }
    if(f)return true;
    else return false;
}
int main() {
    int n;
    cin>>n;
    rep(i,0,n){
        rep(i,0,10){
            cin>>v[i];
        }
        if(dfs(0,0,0))cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

C++: #include <iostream>
#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  if (all.size() == (i+1)*(j+1)) {

						}
						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++: using System;
class _0033
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            string[] data = Console.ReadLine().Split();
            Console.WriteLine(Judge(data) ? "YES" : "NO");
        }
    }
    public static bool Judge(string[] data)
    {
        int right = 0;
        int left = 0;
        for (int i = 0; i < data.Length; i++)
        {
            if (right < int.Parse(data[i])) right = int.Parse(data[i]);
            else if (left < int.Parse(data[i])) left = int.Parse(data[i]);
            else return false;
        }
        return true;
    }
}