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>
#define INF -99999999

using namespace std;

int N;
int a[10];

bool solve()
{
	bool flag = true;
	int b[11], c[11];
	b[0] = INF + 1;
	c[0] = INF;
	int p1 = 0,p2 = 0;
	for(int i = 0; i < 10; i++){
		if(a[i] > b[p1]){
			if(a[i] > c[p2]){
				if(b[p1] > c[p2])
					b[++p1] = a[i];
				else
					c[++p2] = a[i];
			}
			b[++p1] = a[i];
		}
		else if(a[i] > c[p2])
			c[++p2] = a[i];
		else{
			flag = false;
			break;
		}
	}
	return flag;
}

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

C++: #include<iostream>
using namespace std;
int A[10];
bool dfs(int start, int topB, int topC){
	if(start == 9){
		if(A[start] > topB || A[start] > topC){
			return true;
		}
		else{
			return false;
		}
	}
	bool b1 = false, b2 = false;
	if(A[start] > topB){
		b1 = dfs(start+1, A[start], topC);
	}
	if(A[start] > topC){
		b2 = dfs(start+1,topB,A[start]);
	}
	return (b1 || b2 );
}
int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; ++i){
		for(int j = 0; j < 10; ++j){
			cin >> A[j];
		}
		bool result = dfs(0,0,0);
		if(result == true){
			cout << "YES" << endl; 
		}
		else{
			cout << "NO" <<endl; 
		}
	}
	return 0;
}

C++: #include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

string solve(){
    vector<int> a(10,0);
    rep(i,10){
        cin>>a[i];
    }
    for(int bit = 0; bit < (1<<11);++bit){
        vector<int> bv,cv;
        int b=0,c=0;
        bool is = true;
        rep(i,10){
            if(bit & (1<<i)){
                if(b<a[i]) b = a[i];
                else is = false;
            }else{
               if(c<a[i])c = a[i];
               else is = false;
            }
        }
        if(is) return "YES";
    }
    return "NO";

}

int main(){
    int n;
    cin >> n;
    rep(i,n){
        cout<<solve()<<endl;
    }

    return 0;
}

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

using namespace std;
int a[10];
bool dfs(int k,int B,int C)
{
    if(k==10)
        return true;
    if(a[k]>B)
    {
        if(dfs(k+1,a[k],C))
            return true;
    }
    if(a[k]>C)
    {
        if(dfs(k+1,B,a[k]))
            return true;
    }
    return false;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        for(int i=0;i<10;i++)
            cin>>a[i];
        if(dfs(0,0,0))
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){
	
	int n;
	cin >> n;
	while(n--){
		int l = 0, r = 0;
		bool flag = true;
		rep(i, 10){
			int a;
			cin >> a;
			if(a > l) l = a;
			else if(a > r) r = a;
			else flag = false;
		}
		if(flag) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

C++: #include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define SC(x) scanf("%d",&x);
#define pr(x)  cout << x << endl;
#define mem(arr,v) memset(arr,v,sizeof arr);
#define bug(x) cout << "#x = " << x <<endl;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
typedef long long ll;
using namespace std;
int a[maxn];
stack<int> s[2];

bool dfs(int pos) {
//	bug(pos)
	if(pos == 10) return true;
	int cur = a[pos];
	for(int i = 0; i < 2 ; i++) {
		if(s[i].empty() || s[i].top() <= cur) {
			s[i].push(cur);
			if(dfs(pos + 1)) return true;
			s[i].pop();
		}
	}
	return false;
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		for(int i =0 ; i < 2; i++)
			while(!s[i].empty())
				s[i].pop();
		for(int i = 0 ; i < 10 ; i++)
			cin >> a[i];
		if(dfs(0))
			puts("YES");
		else
			puts("NO");
	}
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;cin >> n;
  while(n--){
    int r=0,l=0,d;
    bool f=false;
    for(int i=0;i<10;i++){
      cin >> d;
      //cout << d << endl;
      if(r<d){
	if(r<l&&l<d) l=d;
	else r=d;
      }else if(l<d){
	l=d;
      }else{
	f=true;
	break;
      }
      //cout << l << ":" << r << endl;
    }
    if(f) cout << "NO" << endl;
    else cout << "YES" << endl;
  }  
}

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

int l=0, r=0;
bool flag=true;

void solve(int N) {
	int a = 0;
	while (N > 0) {
		for (int i = 0; i < 10; i++) {
			cin >> a;
			if (a > l)
				l = a;
			else if (a > r)
				r = a;
			else {
				flag = false;
			}
		}
		if (flag == true)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		N--;
	}
}
int main() {
	int n = 0;
	cin >> n;
	solve(n);
	return 0;
}

C++: #include<stdio.h>
main(){
    int x[10],y[10],z[10],i,j,n,cz,cy,tmp;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        tmp=0;
        cy=0;cz=0;
        for(j=0;j<10;j++){
        scanf("%d",&x[j]);
        z[j]=0;y[j]=0;
        }
        for(j=0;j<10;j++){
        if(x[j]>=y[cy-1*cy>0])
        y[cy++]=x[j];
        else if(x[j]>=z[cz-1*cz>0])
        z[cz++]=x[j];
        else
        tmp=1;
        }
        if(tmp==1)
        printf("No\n");
        else
        printf("Yes\n");
    }
}

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

int main(){
	int n,ball,tp[2],con,bad;
	
	cin >> n;
	
	for(; n > 0; n--){
		
		tp[0] = tp[1] = 0;
		
		for(int i = 0; i < 10; i++){
			cin >> ball;
			
			if(tp[0] > tp[1]){
				con = 0;
			}else{
				con = 1;
			}
			
			if(ball > tp[con]){
				tp[con] = ball;
			}else if(ball > tp[!con]){
				tp[!con] = ball;
			}else{
				bad = 1;
			}
		}
		
		if(bad){
			cout << "NO" << endl;
			bad = 0;
		}else{
			cout << "YES" << endl;
		}
	}
	
	return 0;
}