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<string.h>
using namespace std;
int main(void)
{
  int n;
  cin>>n;
 
  for(int i=0;i<n;i++)
    {
      int num1[10];
      int count=0;
      for(int j=0;j<10;j++)
	{
	  cin>>num1[j];
	}
      for(int k=0;k<10-1;k++)
	{
	  int num2[10];
	  if(num1[k]>num1[k+1])
	    {
	      int l=0;
	      num2[l]=num1[k];
	      l++;
	    }
	  if(num1[k]>num1[k+1] && num2[k]>num2[k+1] && num2[k+1]!=0)count++;
	}
      if(count>0)cout<<"NO"<<endl;
      else cout<<"YES"<<endl;
      
    }
  return 0;
}

C++: public class Main {
	void run() {
		scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] boll = new int[10];
		for(int k = 0; k < n; k++) {
			for(int i = 0; i < 10; i++) {
				boll[i] = scan.nextInt();
			}
			int judg = 0;
			for(int i = 0; i < n; i++) {
				int right,left;
				right = boll[0];
				left = 0;
				for(int m = 1; m < 10; m++) {
					if(right > boll[m]) {
						if(left < boll[m]) {
							left = boll[m];
						}
						else {
							judg = 0;
							break;
						}
					}
					else if(right < boll[m]) {
						right = boll[m];
					}
					judg = 1;
				}
				if(judg == 0) {
					System.out.println("NO");
				}
				else {
					System.out.println("YES");
				}
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

C++: #include<iostream>
using namespace std;
int main(void)
{
int n;
cin>>n;
int b[10]={0};
int c[10]={0};
for(int i=0;i<n;i++)
{
	int a[10];
	for(int j=0;j<10;j++)
	{
	int x;
	cin>>x;
	a[j]=x;
	}
	int k=0;
	for(int j=0;j<10-1;j++)
	{
	
	if(a[j]>a[j+1])
		{
		b[k]=a[j];
		k++;
		}
	else c[j]=a[j];
	}
	for(int i=0;i<10-1;i++)
	{
	if(b[i]>b[i+1] && b[i+1]!=0 || c[i]>c[i+1] && c[i+1]!=0)
	{
	cout<<"NO"<<endl;
	break;
	}
	else 
	{
	cout<<"YES"<<endl;
	break;
	}
	}
}
return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,s;
  cin >> n;
  for(int i=0;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 if(s > b) b=s;
      else flg=1;
    }
    printf("%s\n",flg==0?"YES":"NO");
  }
}

C++: #include<iostream>
main(){
int n,i,A,B,C,f;
for(std::cin>>n;n-->0;puts(f?"NO":"YES"))
  for(B=C=f=i=0;std::cin>>A,i<10;i++){
  if(B<A)B=A;else C<A?C=A:f=1;
 }
}

C++: #include <stdio.h>

int main(void)
{
	int tubeM[10];
	int tube1[10], tube2[10];
	int i, j, k;
	int n;
	int ans;
	
	for (i = 0; i < 10; i++){
		tube2[i] = 0;
	}
	
	scanf("%d", &n);
	
	while(n){
		for (i = 0; i < 10; i++){
			scanf("%d", &tubeM[i]);
		}
		
		tube1[0] = tubeM[0];
		for (i = 1, j = 0, k = 0; i < 10; i++){
			if (tubeM[i] > tube1[j]){
				tube1[j + 1] = tubeM[i];
				j++;
			}
			else {
				tube2[k] = tubeM[i];
				k++;
			}
		}
		
		ans = 0;
		for (i = 1; tube2[i] != 0; i++){
			if (tube2[i - 1] > tube2[i]){
				ans = 1;
				break;
			}
		}
		
		if (ans == 0){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		
		n--;
	}
	
	return (0);
}

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

int balls[10];
int b[10];
int c[10];
int b_size;
int c_size;

bool isAscending() {
    for (int i = 0; i < b_size - 1; i++) {
        if (b[i] > b[i + 1]) {
            return false;
        }
    }
    for (int i = 0; i < c_size - 1; i++) {
        if (c[i] > c[i + 1]) {
            return false;
        }
    }
    return true;
}

bool dfs(int k, bool isB) {
    if (isB == true) {
        b[b_size++] = balls[k];
    } else {
        c[c_size++] = balls[k];
    }
    bool res = false;
    if (k == 9) {
        if (isAscending() == true) {
            res = true;
        }
    } else {
        if (dfs(k + 1, true) == true) {
            res = true;
        } else if (dfs(k + 1, false) == true) {
            res = true;
        }
    }
    if (isB == true) {
        b[--b_size] = 0;
    } else {
        c[--c_size] = 0;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    while (n--) {
        fill_n(balls, 10, 0);
        fill_n(b, 10, 0);
        fill_n(c, 10, 0);
        b_size = c_size = 0;
        for (int i = 0; i < 10; i++) {
            cin >> balls[i];
        }
        bool res = dfs(0, true);
        if (res == true) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

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

using namespace std;

typedef unsigned long long ull;

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

int main(){
    int n;
    cin >> n;
    rep(p, 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;
    }
}

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

int BALLNUM = 10;

	static int data[10];
class balldata
{
private:
	//static std::vector <int> data;
	//int ballnum;
public:
	balldata(int datanum);
	static void enter();
	static void answer();
	static bool check();
	static bool check(int num,int right,int left);
};




int main()
{
	balldata ball(BALLNUM);

int N;
	std::cin >> N;
	for (int i = 0; i < N; i++)
	{
		ball.enter();
		ball.answer();
	}
}


balldata::balldata(int datanum)
{
	//ballnum = datanum;
	//data.resize(datanum);
}



void balldata::enter()
{
	for (int i = 0; i < 10; i++)
	{
		std::cin >> data[i];
	}
	return;
}

bool balldata::check(int num,int right,int left)
{
	//if (num == data.size())return true;
	if (num == 10)return true;
	if (balldata::check(num + 1, right, data[num])&&left<data[num]){ return true; }
	if (balldata::check(num + 1, data[num], left)&&right<data[num]){ return true; }

	return false;
}
bool check()
{
	return balldata::check(0, 0, 0);
}

void balldata::answer()
{ 
	if (balldata::check(0, 0, 0))
	{
		std::cout << "YES" << std::endl;
	}
	else
	{
		std::cout << "NO" << std::endl;
	}
}

C++: #include<cstdio>
int main()
{
  int n;
  scanf("%d",&n);
  int a[n][10];
  for(int i=0;i<n;i++)
  {
  	for(int j=0;j<10;j++)
	  {
	  	scanf("%d",&a[i][j]);
	  	
			}  	
   }
   
    for(int i=0;i<n;i++)
  {
  	int k=a[i][0];
  	a[i][0]=0;
  	for(int j=0;j<10;j++)
	  {
	    if(a[i][j]>k)
	    {
	    	k=a[i][j];
	    	a[i][j]=0;
		}
			}  	
   }
   int ins;
       for(int i=0;i<n;i++)
  {
  	int count=0;
  	int judge=1;
  	for(int j=0;j<10;j++)
	  {
      if(a[i][j]==0)continue;
      if(count==0)
      {
      	ins=a[i][j];
      	count++;
	  }
      else
      {
      	if(a[i][j]<ins) {
		  judge=0;break;
	}
      	count++;
	  }
		}
		if(judge)printf("YES");
		else printf("NO");
		if(i!=n-1)printf("\n");
			}  	
   }