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>
main(){
int n,i,A,B,C;
 for(std::cin>>n;n-->0;puts(C-11?"YES":"NO"))
 for(B=C=i=0;i++<10;){
  std::cin>>A;
  if(B<A)B=A;else C=C<A?A:11;
 }
}

C++: #include <iostream>
#include <stdlib.h>

using namespace std;

int main() {

	int n;
	int num[10];
	int pos;
	cin >> n;
	while (n-- > 0)
	{
		int min_A = 0, min_B = 0;
		for (int i = 0; i < 10; i++)
		{
			cin >> num[i];
		}
		for (pos = 0; pos < 10; pos++)
		{
			if (num[pos] > min_A)
			{
				min_A = num[pos];
			}
			else if (num[pos] > min_B)
			{
				min_B = num[pos];
			}
			else
			{
				break;
			}
		}
		if (pos == 10)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int ball[10];

bool dfs(int n, int b, int c) {
    if(n == 10) return true;
    if(b < ball[n]) return dfs(n + 1, b = ball[n], c);
    if(c < ball[n]) return dfs(n + 1, b, c = ball[n]);
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

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

C++: #include <iostream>

using namespace std;

int main()
{
  int n;
  int i;

  cin >> n;

  while (n--){
    int ai = 1, bi = 1;
    int ans = 0;
    int ball[10], a[10] = {0}, b[10] = {0};
    
    for (i = 0; i < 10; i++){
      cin >> ball[i];
    }
    for (i = 0; i < 10; i++){
      if (ball[i] > a[ai - 1]){
        ans++;
        a[ai++] = ball[i];
      }
      else if (ball[i] > b[bi - 1]){
        ans++;
        b[bi++] = ball[i];
      }
      else {
        cout << "NO" << endl;
        break;
      }
    }
    if (ans == 10) cout << "YES" << endl;
  }
}

C++: #include<iostream>
#include<algorithm>
#include<stack>
#include<vector>

using namespace std;


bool saiki(vector<int> ball,stack<int> B,stack<int> C){

    if(ball.size() == 0) return true;
    int temp = ball.front();
    bool flag1=false,flag2=false;
    ball.erase(ball.begin());
    if(temp > B.top()){
	B.push(temp);
       	flag1 = saiki(ball,B,C);
    }
    B.pop();
    if(temp > C.top()){
	C.push(temp);
	flag2 = saiki(ball,B,C);
    }
    return flag1 || flag2;
}


int main(){

    int N,temp;
    vector<int> ball;
    stack<int>B,C;
    B.push(0);
    C.push(0);
    cin >> N;
    for(int i=0;i<N;i++){
	for(int j=0;j<10;j++){
	    cin >> temp;
	    ball.push_back(temp);
	}
	if(saiki(ball,B,C)) cout << "YES" << endl;
	else cout << "NO" << endl;
	ball.clear();
    }
    return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int a[9]={};
		int b[9]={};
		int dat,o=0,s=0;
		for(int j=0;j<=10;j++){
			if(j==10){
				cout<<"YES"<<endl;
				break;
						}
			cin>>dat;
                        if(s==0||dat>a[s-1]){
				a[s]=dat;
				s++;
			}
			else if(o==0||dat>b[o-1]){
				b[o]=dat;
				o++;}
			else {
				cout<<"NO"<<endl;
			break;
			}
					}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>

#define bottom(v) v[v.size()-1]

using namespace std;

int main() {
  int n, t;
  vector<int> v1, v2;
  cin>>n;
  
  while(n--) {
    bool isOk = true;
    for(int i = 0; i < 10; i++) {
      cin>>t;
      if(v1.empty() || bottom(v1)<t) v1.push_back(t);
      else if(v2.empty() || bottom(v2)<t) v2.push_back(t);
      else isOk = false;
    }
    cout << (isOk ? "YES" : "NO") << endl;
    v1.clear(); v2.clear();
  }
  return 0;
}

C++: //-*-coding:utf-8-*-
//----------------------------------------------------------
// module: main
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0033
//----------------------------------------------------------
#include <algorithm>
#include <vector>
#include <deque>
#include <map>

#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int MAXL = 10;

int numbers[MAXL];

bool can_solve(int i, int a, int b){
    int v = numbers[i];
    if (i >= MAXL) return true;

    if (v > a && can_solve(i+1, v, b)) return true;
    if (v > b && can_solve(i+1, a, v)) return true;
    return false;
}

bool solve(){
    return can_solve(0, -1, -1);

    int a = -1;
    int b = -1;
    for (int i = 0; i < 10; ++i)
        {
            if (a > b && b > 0) {
                if (numbers[i] > a) { a = numbers[i]; }
                else if (numbers[i] > b) { b = numbers[i]; }
                else return false;
            }
            else if (b > a && a > 0){
                if (numbers[i] > b) { b = numbers[i]; }
                else if (numbers[i] > a) { a = numbers[i]; }
                else return false;
            }
                
            if(a < 0){a = numbers[i]; continue; };
            if(b < 0){b = numbers[i]; continue; };
        }
    return true;
};

int main(int argc, char *argv[])
{
    int c;
    scanf("%d", &c);
    for (int i = 0; i < c; ++i)
        {
            scanf("%d %d %d %d %d %d %d %d %d %d", &numbers[0], &numbers[1], &numbers[2], &numbers[3], &numbers[4], &numbers[5], &numbers[6], &numbers[7], &numbers[8], &numbers[9]);
            bool result = solve();
            if ( solve() ){ printf("YES\n"); }
            else { printf("NO\n"); }
        }
    return 0;
}

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

  int n,i;
  cin >> n;
  for(i=0;i<n;i++){
    int j;
    int tmp;
    int han=0;
    vector<int>in1;
    vector<int>in2;
    for(j=0;j<5;j++){
      cin >> tmp;
      in1.push_back(tmp);
      cin >> tmp;
      in2.push_back(tmp);
    }
    for(j=1;j<5;j++){
      if(in1[j-1]>in1[j])
	han=1;
      if(in2[j-1]>in2[j])
	han=1;
    }

    if(han==0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }


}