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<vector>
#include<stdlib.h>
using namespace std;
vector<int> balls;
bool dfs(int i,int left,int right,int len)
{
	if(i==len&&(balls[i-1]>left||balls[i-1]>right))return 1;
	if(balls[i-1]<left&&balls[i-1]<right)return 0;
	if(balls[i-1]>left){
		return dfs(i+1,balls[i-1],right,len);
	}
	if(balls[i-1]>right){
		return dfs(i+1,left,balls[i-1],len);
	}
	
}
int main()
{
	int T;
	cin>>T;
	while(T--){
		int x;
		while(cin>>x){
			balls.push_back(x);
		}
		int len=balls.size();
		if(dfs(1,-1,-1,len)){
			cout<<"YES"<<endl;
		}else cout<<"NO"<<endl;
	}
}

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] && d[j] < vb[cb - 1]) {
			cout << "NO" << endl;
			goto FINLOOP;
		}

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

			else if (d[j] > vb[cb - 1]) {
				vb[cb] = d[j];
				cb++;
			}
			
		}
		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;
}

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

int main(){
    int n,s;
    cin >> n;
    for (int i=-; i < n; i++){
        int a=0, b=0, flg=0;
        for (int j = 0; j < 10; j++)}{
            cin >> s;
            if (s > a) a=s;
            else (s > b) b=s;
            else flg = 1;
        }
        printf("%s\n", flg==0? "YES": "NO");
    }
}

C++: #include<iostream>
int topA=-1, topB=-1,B;
int times;
int main(){
	std::cin >> times;
	for (int j = 0; j < times; j++){
		for (int i = 0; i < 10; i++){
			std::cin >> B;
			if (topA == -1 && topB == -1){
				topA = B;
			}
			else if (topA != -1 && topB == -1){
				topB = B;
			}
				else if (topA < B){
					topA = B;
				}
				else if (topB < B){
					topB = B;
				}
				else{
					std::cout << "NO\n";
					goto rip;
				}
			}
		std::cout << "YES\n";
	rip:;
		topA = -1,topB=-1;
		}

}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int n,a;
  srand((unsigned)time(NULL));
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin>>a;
    }
    if(rand()%2==0){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}

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


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

    int b[n][10];
    

    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin >> b[i][j];
        }
    }

    bool check[n];
    for(int i=0;i<n;i++){
        check[i]=true;
    }

    for(int i=0;i<n;i++){
        vector<int> x,y;
        x.push_back(0);
        y.push_back(0);
        x.push_back(b[i][0]);
        
        
        for(int j=1;j<10;j++){
            int pa = x[x.size()-1];
            int pb = y[y.size()-1];

            int p = b[i][j];

            if(p<pa&&p<pb){
                check[i] = false;
            }else if(p<pa&&p>pb){
                y.push_back(p);
            }else if(p>pa&&p<pb){
                x.push_back(p);
            }else{
                if(pa<pb){
                    y.push_back(p);
                }else{
                    x.push_back(p);
                }
            }
        }
    }


    for(int i=0;i<n;i++){
        if(check[i]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    
    return 0;
}

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

int a[10];

int main() {
    int n, x, y, f;
    cin >> n;
    while (n--) {
        for (int i = 0; i < 10; i++) cin >> a[i];
        x = y = f = 0;
        for (int i = 0; i < 10; i++) {
            if (a[i] > x)
                x = a[i];
            else if (a[i] > y)
                y = a[i];
            else {
                f = 1;
                break;
            }
        }
        if (f)
            cout << "NO\n";
        else
            cout << "YES\n";
    }
}

C++: 
#include<cstdio>
using namespace std;
const static int MAX_N = 12;
static int num[12], left[12], right[12];
static bool ret = false;
void dfs(int cur, int n, int num[], int left[],int l, int right[],int r) {
	if (cur == n) {
		for (int i = 0; i < l-1; i++) {
			if (left[i] > left[i + 1])
				return;
		}
		for (int j = 0; j < r - 1; j++) {
			if (right[j] > right[j + 1])
				return;
		}
		ret = true;
	} else {
		left[l] = num[cur];
		dfs(cur + 1, n, num, left, l + 1, right, r);
		right[r] = num[cur];
		dfs(cur + 1, n, num,left, l, right, r + 1);
	}
}

int main() {
	int n;
	for (scanf("%d ", &n); n; n--) {
		for (int i = 0; i < 10; i++) {
			scanf("%d", &num[i]);
		}
		dfs(0, 10, num, left, 0, right, 0);
		if (ret)printf("YES\n");
		else printf("NO\n");
		ret = false;
	}
}

C++: #include <cstdio>
#include <algorithm>
#define HEIGHT 10

using namespace std;

int a[HEIGHT];

void solve(){
	bool f=true;
	int right,left;
	right = left = 0;
	for(int i=0;i<HEIGHT;i++){
		if(right<a[i] && left<a[i]){
			if(right<left){
				left = a[i];
			} else {
				right = a[i];
			}
		} else if(right<a[i]){
			right = a[i];
		} else if(left<a[i]){
			left = a[i];
		} else {
			f = false;
			break;	
		}
	}
	if(f){
		printf("YES\n");
	} else {
		printf("NO\n");
	}
}
			
int main(){
	
	int lp;
	scanf("%d",&lp);
	
	for(int i=0;i<lp;i++){
		for(int j=0;j<HEIGHT;j++){
			scanf(" %d",&a[j]);
		}
		solve();	
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
    int n; cin >> n;
    while(n--){
        vector<int> v(10);
        rep(i,10) cin >> v[i];
        int a=0, b=0;
        bool is = true;
        for(int i=0; i< 10; i++){
            if(v[i] < a && v[i] < b){is = false; break;}
            if(a < b) (b<v[i]?b:a) = v[i];
            else (a<v[i]?a:b) = v[i];
        }
        cout << (is?"YES":"NO") << endl;
    }
}