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<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i, m) for(long long i=0; i<m; ++i)
#define FOR(i, n, m) for(long long i=n; i<m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vll;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	REP(roop,n) {
		vector<int> num(10);
		REP(i,10) cin>>num[i];
		bool d=false;
		REP(bit,(1<<10)) {
			vector<bool> used(10,false);
			ll buf=bit;
			REP(i,10) {
				if(buf%2==1) used[i]=true;
				buf/=2;
			}
			bool e=true;
			int an=0,bn=0;
			REP(i,10) {
				if(used[i]) {
					if(an>num[i]) e=false;
					an=num[i];
				} else {
					if(bn>num[i]) e=false;
					bn=num[i];
				}
			}
			d=d|e;
		}
		if(d) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <stack>
#include <sstream>
using namespace std;
int main(){
  int nlist[10],n;
  bool a,b;//a=ôÌ®,b=ïÌ®
  cin>>n;
  for(;n;n--){
    a=b=true;
    for(int i=0;i<10;i++)
      cin>>nlist[i];
    for(int j=2;j<10;j++)
      if(nlist[j-2]>nlist[j]){(j%2)?a=false:b=false;break;}
    (a&&b)?cout<<"YES"<<endl:cout<<"NO"<<endl;
  }
  return 0;
}

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

int data[10];

bool bt(int b, int c, int no) {
    if (no >= 10) return true;
    else if (data[no] < b && data[no] < c) return false;//どっちにも入れれない＞＜

    if (data[no] > b) return bt(data[no], c, no+1);
    else if (data[no] > c) return bt(b, data[no], no+1);
}

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

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

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int t,flag;
	//freopen("C:\\Users\\国民党\\Desktop\\text.txt", "r", stdin);
	cin >> t;
	while (t--)
	{
		flag = 1;
		int a, b = -1, c = -1;
		for (int i = 1; i <= 10; i++)
		{
			cin >> a;
			if (a > b)
			{
				b = a;
			}
			else if (a > c)
			{
				c = a;
			}
			else
				flag = 0;
		}
		cout << ((flag == 1) ? "Yes" : "No" )<< endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
int s[10]={0};
 
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        for(int i=0;i<10;i++)
            scanf("%d",&s[i]);
        int a=0,b=0;
        bool flag=0;
        for(int i=0;i<10;i++)
        {
            if(s[i]<a&&s[i]<b)
            {
                flag=1;
                break;
            }
            else if(s[i]<a&&s[i]>b)b=s[i];
            else if(s[i]>a&&s[i]<b)a=s[i];
            else
            {
                a=a>b?s[i]:a;
                b=a<b?s[i]:b;
                if(a==b)a=s[i];
            }
        }
        if(flag)printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}

C++: #include<cstdio>
#include<queue>
#include<set> 
#include<cstdlib> 
#include<cstring>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
const int inf = 0x3f3f3f3f;
using namespace std;

int ball[11], r[11], l[11];
int a, b;

bool DFS(int stp){
	if(stp == 10)
		return true;
	if(ball[stp] > l[a]){
		l[++a] = ball[stp]; 
		return DFS(stp + 1); 
	}
	if(ball[stp] > r[b]){
		r[++b] = ball[stp];
		return DFS(stp + 1);
	}
	return false;
}

int main()
{
	ios::sync_with_stdio(false);
	int t;
	cin >> t; 
	while(t--){
		a = 0;
		b = 0;
		for(int i = 0; i < 10; i++){
			cin >> ball[i];
		}
		l[a] = 0;
		r[b] = 0;
		cout << ((DFS(0) == 1)?"YES" : "NO") << endl;
//		for(int i = 0; i <= a; i++)
//			cout << l[i] << " ";
//		cout << endl;
//		for(int i = 0; i <= a; i++)
//			cout << r[i] << " ";
//		cout << endl;
		
	}
	
	return 0;
}

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

int main() {
	int n, x,a=0,b=0;
	bool f;
	cin >> n;
	for (int lop = 0,f=1,a=0,b=0; lop < n; lop++) {
		for (int i = 0; i < 10; i++) {
			cin >> x;
			if (f) {
				if (a < x) {
					a = x;
					continue;
				}
				if (b < x) {
					b = x;
					continue;
				}
				f = 0;
			}
		}

		cout << (f ? "YES" : "NO") << endl;
	}
	return 0;
}

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

int main(){
	int n,ball,tp[2],con;
	
	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{
				cout << "NO" << endl;
				break;
			}
			
			if(i == 9){
				cout << "YES" << endl;
			}
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	int N; cin >> N;
	while(N--) {
		int bend = 0, cend=0;
		bool f = true;
		rep(i,10) {
			int num; cin >> num;
			if(bend < num) bend = num;
			else if(cend < num) cend = num;
			else {
				f = false;
				break;
			}
		}
		cout << (f ? "YES" : "NO") << endl;
	}
	return 0;
}