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>
using namespace std;
int ball[10];
bool flag;  //true??????YES???false??????NO
//?????°??§?§£????????????
void search(int left,int right,int d){//1??????????????°????????´?????????????????????????????????
                                      //2??????????????°????????´?????????????????????????????????
                                      //3??????????????°?????±???

  if(d==10){ //???????????????????????§??\???????????????
    flag=true;
    return;
  }
  if(left<ball[d]) //????????????????????\????????¨????????¶??????????????????
    search(ball[d],right,d+1);
  if(right<ball[d])//????????????????????\????????¨????????¶??????????????????
    search(left,ball[d],d+1);
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    flag=false;//????????°????????????
    for(int j=0;j<10;j++)
      cin>>ball[j];
    search(ball[0],0,1);//????????????????????\??????????????????
                        //3??????????????°?????±???
                        //?????????????????\?????????????????\???????????????????????§
                        //????????\?????????????????????????????????
    if(flag)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}

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

int A[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int B[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

bool isSorted(void)
{
	int i = 1;
	while(A[i]!=0 && i<=9)
	{
		if(A[i] < A[i-1]) return false;
		i++;
	}

	i = 1;
	while(B[i]!=0 && i<=9)
	{
		if(B[i] < B[i-1]) return false;
		i++;
	}

	return true;
}

int main(void)
{
	int n;
	cin >> n;
	bool enable = false;
	for(int i=0; i<n; i++)
	{
		int X[10];
		for(int j=0; j<10; j++)
			cin >> X[j];

		for(int j=0; j<1024; j++)
		{
			int a = 0, b = 0;
			int e = 1;
			for(int k=0; k<10; k++)
			{
				if( (j & e) == e)
				{
					A[a] = X[k];
					a++;
				}
				else
				{
					B[b] = X[k];
					b++;
				}
				e *= 2;
			}
			if(isSorted())
			{
				enable = true;
			}

			//initialize
			for(int j=0; j<10; j++)
			{
				A[j] = 0; B[j] = 0;
			}
		}
		if(enable) cout << "YES" << endl;
		else cout << "NO" << endl;
		enable = false;
	}
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	for(int l=0; l < n; l++){
		bool isLined = true;
		int num[10];
		int b = -1, c = -1;
		for(int i=0; i < 10; i++){
			cin >> num[i];
		}

		for(int i=0; i < 10; i++){
			if(num[i] < b && num[i] < c){
				isLined = false;
				break;
			}
			else if(b < num[i] && c < num[i]){
				if(b < c) c = num[i];
				else b = num[i];
			}
			else if(b < num[i]){
				b = num[i];
			}
			else c = num[i];
		}
		if(isLined) cout << "YES" << endl;
		else cout << "NO" << endl;

	}
}

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

using std::cout;
using std::endl;

int main()
{
    int data_num;
    scanf("%d", &data_num);

    while (data_num--) {
        std::array<int, 10> balls;
        for (auto i = 0; i < 10; i++) {
            std::cin >> balls.at(i);
        }

        std::vector<int> b(1, 0), c(1, 0);
        b.push_back(balls.at(0));

        for (auto i = 1; i < 10; i++) {
            int b_end = b.at(b.size() - 1);
            int c_end = c.at(c.size() - 1);
            int ball = balls.at(i);

            if (b_end > ball && c_end > ball) {
                cout << "NO" << endl;
                break;
            } else if (b_end < ball && c_end > ball) {
                b.push_back(ball);
            } else if (b_end > ball && c_end < ball) {
                c.push_back(ball);
            } else {
                if (b_end > c_end) {
                    b.push_back(ball);
                } else {
                    c.push_back(ball);
                }
            }

            if (i == 9) {
                cout << "YES" << endl;
            }
        }
    }

    return 0;
}

C++: #include <stdio.h>

int a[11];

bool dfs(int i, int L, int R){
    if (i == 10) return true;
    if (dfs(i+1, a[i], R) && a[i] > L)
		return true;
    if (dfs(i+1, L, a[i]) && a[i] > R)
		return true;
    return false;
}

void solve(){
	for (int i=0; i<10; ++i){
		scanf("%d", &a[i]);
	}
	printf("%sn", dfs(0, 0, 0)?"YES":"NO");
}

int main (){
	int t;
	scanf("%d", &t);
	while (t --){
		solve();
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  cin>>n;
  rep(i,n){
    vector<int>a,b;
    int tmp;
    cin>>tmp;
    pb(a,tmp);
    rep(j,9){
      cin>>tmp;
      if(a[a.size()-1]<tmp)pb(a,tmp);
      else pb(b,tmp);
    }
    bool han=true;
    rep(j,b.size()-1)if(b[j]>b[j+1])han=false;
    if(han)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int n, a, b;
int data[10] = { 0 };

int main() {
	cin >> n;

	for (int i = 0; i < n; ++i) {
		int boxa = 0, boxb = 0;
		bool flag = false;
		for (int j = 0; j < 10; ++j) {
			cin >> data[j];
		}
		for (int j = 0; j < 10; ++j) {
			if (boxa > boxb && boxa < data[j]) {
				boxa = data[j];
			} else if (boxb < data[j]) {
				boxb = data[j];
			} else if (boxa < data[j]) {
				boxa = data[j];
			} else {
				cout << "NO" << endl;
				flag = true;
				break;
			}
		}
		if (!flag)cout << "YES" << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <stack>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(void)
{
    int s[10], n, b, c;
    bool flag;

    cin >> n;
    rep(i, n) {
        b = 0, c = 0, flag = true;
        rep(i, 10)
            cin >> s[i];
        rep(i, 10) {
            if (s[i] > b)
                b = s[i];
            else if (s[i] > c)
                c = s[i];
            else
                flag = false;
        }
        
        cout << (flag ? "YES" : "NO") << endl;
    }
    return 0;
}

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<iostream>
using namespace std;main(){int N,i,O=0,B=0,C=0,A;cin>>N;for(i=0;i<N;i++){for(int i=0;i<10;i++){cin>>A;if(!O)A>B?B=A:A>C?C=A:O=true;}cout<<(O?"NO":"YES")<<endl;}}