Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	for i := 0; i < n; i++ {
		a := -1
		b := -1
		ans := true
		// それぞれの筒の一番上にあるたまの数字に着目すればよい
		for j := 0; j < 10; j++ {
			x := nextInt()
			if x > a {
				a = x
			} else if x > b {
				b = x
			} else {
				ans = false
			}
		}
		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include <stdio.h>

bool canOrder(int s[10], int index, int left_top, int right_top) {
  if (index == 10) {
    return true;
  }
  if (s[index] > left_top) {
    if (canOrder(s, index + 1, s[index], right_top)) {
      return true;
    }
  }
  if (s[index] > right_top) {
    if (canOrder(s, index + 1, left_top, s[index])) {
      return true;
    }
  }
  return false;
}

bool canOrder(int s[10]) {
  return canOrder(s, 0, 0, 0);
}

int main() {
  //freopen("Ball.in", "r", stdin);
  int test_count;
  scanf("%d", &test_count);
  for (int test = 0; test < test_count; ++test) {
    int s[10];
    for (int i = 0; i < 10; ++i) {
      scanf("%d", &s[i]);
    }
    bool result = canOrder(s);
    printf("%s\n", result ? "YES" : "NO");
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
void dfs(int, int, int);
int arr[10];
bool flag;
int main() {
  int n;
  cin >> n;
  while (n--) {
    for (int i = 0; i < 10; i++)
      cin >> arr[i];
    dfs(0, 0, 0);
    if (flag)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    flag = false;
  }
  return 0;
}

void dfs(int sta1, int sta2, int index) {
  if (index == 10) {
    flag = true;
    return;
  }
  if (sta1 < arr[index]) {
    sta1 = arr[index];
    dfs(arr[index], sta2, index + 1);
  }
  if (sta2 < arr[index]) {
    sta2 = arr[index];
    dfs(sta1, sta2, index + 1);
  }
}

C++: #include<cstdio>
#include<iostream>
#include<cstdlib>
using namespace std;
const int N =10;
int main()
{
	int n;
	scanf("%d",&n);
	while(n--){
		bool ans=true;
		int a,b=-1,c=-1;
		for(int i=0;i<N;i++)
		{
			scanf("%d",&a);
			if(ans){
				if(a>b)	b=a;
				else if(a>c)	c=a;
				else	ans=false;
			}
		}
		cout<<(ans ? "YES":"NO")<<endl;
	}




	
	return 0;
}

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

using namespace std;
int a[15], f;
void dfs(int x, int y, int step)
{
    if( step == 11)
{
     f = 1;
     return;
}    if(x < a[step]) dfs(a[step], y, step+1);
    else if(y < a[step]) dfs(x, a[step], step+1);
  else
    return ;
}
int main ()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        int i;
        f = 0;
        for(i = 1;i <= 10;i++)
            scanf("%d", &a[i]);
            dfs(0, 0, 1);
        if(f)
            printf("YES\n");
        else
            printf("NO\n");
    }
}

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

int main(){
	int c, tmp, d[2] = {0};
	bool res;

	scanf("%d", &c);

	while(c--){
		res = true;
		d[0] = d[1] = 0;

		for(int i = 0; i < 10; ++i){
			std::cin >> tmp;
		
			if( d[0] < tmp ){
				if(d[1] < tmp){
					*std::max_element(d, d + 1) = tmp;
				}else{
					d[0] = tmp;
				}
			}else if( d[1] < tmp ){
				d[1] = tmp;
			}else{
				res = false;
				//break;
			}
		}

		std::cout << (res ? "YES" : "NO") << std::endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <stack>
using namespace std;
int a[10];
bool ans;
void dfs(int i,int r,int l){
	if(i==10)return;
	if(ans==0)return;
	if(r<a[i])dfs(i+1,a[i],l);
	if(l<a[i])dfs(i+1,r,a[i]);
	ans=0;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		for(int i=0;i<10;i++)cin>>a[i];
		dfs(0,0,0);
	if(ans)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	}
}

C++: #include<iostream>
#include<stack>
using namespace std;
int main(){
  int N;
  cin >> N;
  int boll[10];
  stack<int> B,C;
  B.push(0); C.push(0);
  for(int i=0;i<N;i++){
    for(int i=0;i<10;i++) cin >> boll[i];
    for(int j=0;j<10;j++){
        if(boll[j]>B.top()) B.push(boll[j]);
        else if(boll[j]>C.top()) C.push(boll[j]);
        else{
          cout << "NO" << endl;
          break;
        }
        if(j==9) cout << "YES" << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    
    for(int i=0;i<N;i++){
        int ball[10];
        bool isYES=true;
        int b=0, c=0;

        for(int j=0;j<10;j++)cin>>ball[j];

        for(int j=0;j<10;j++){
            if(ball[j]>b){
                b=ball[j];
            }else if(ball[j]>c){
                c=ball[j];
            }else{
                isYES=false;
                break;
            }
        }

        cout<<(isYES?"YES":"NO")<<endl;
    }

    return 0;
}

C++: #include <iostream>  
  
using namespace std;  
  
const int N = 10;  
  
int main()  
{  
    int n;  
  
    cin >> n;  
    while(n--) {  
        bool ans = true;  
        int a, b=-1, c=-1;  
        for(int i=1; i<=N; i++) {  
            cin >> a;  
            if(ans) {  
                if(a > b)  
                    b = a;  
                else if(a > c)  
                    c = a;  
                else  
                    ans = false;  
            }  
        }  
  
        cout << (ans ? "YES" : "NO") << endl;  
    }  
  
    return 0;  
}

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

//定数
const int MAX_M=10;
//入力
int N;
int balls[MAX_M];

bool dfs(int i, int A, int B){
    if (i == 10){
        return true;
    }

    int value = balls[i];

    if (A >= value && B >= value){
        return false;
    }else if (A < value){
        return dfs(i+1, value, B);
    }else if (B < value){
        return dfs(i+1, A, value);
    }
}

string solve(){
    if (dfs(0, 0, 0)) return (string)"YES";
    else return (string)"NO"; 
}

int main(){
    queue<string> res;
    cin >> N;
    for (int i=0; i<N; i++){
        for (int j=0; j<10; j++){
            cin >> balls[j];
        }
        res.push(solve());
    }

    while (res.size()){
        cout << res.front() << endl;
        res.pop();
    }
    
    return 0;
}

C++: //能否成功地把球全部放入容器内 
#include<iostream>
#include<cstring>
using namespace std;
int a[100];
int aa[100],aaa[100];//分别表示两边的容器 
int main(){
	int t;
	cin>>t;
	while(t--){
		memset(a,0,sizeof(a));
		memset(aa,0,sizeof(aa));//左边 
		memset(aaa,0,sizeof(aaa));//右边 
		for(int i=1;i<=10;i++)
			cin>>a[i];
		aa[1]=a[1],aaa[0]=a[0];
		int p1=0,p2=0;//aa aaa的下标
		int i;
        for(i=2;i<=10;i++){
            if(a[i]>aa[p1])
                aa[++p1]=a[i];
            else if(a[i]>aaa[p2])
                aaa[++p2]=a[i];
            else{
                cout<<"NO"<<endl;
                break;
            }
        }
        if(i>10)
            cout<<"YES"<<endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
	ios :: sync_with_stdio(false);
	int t; cin >> t;
	while(t --) {
		int a[10];
		for(int i = 0; i < 10; i ++)
			cin >> a[i];
		bool f = false;
		auto check = [](auto v) {
			for(int i = 0; i + 1 < v.size(); i ++)
				if(v[i] > v[i + 1])
					return false;
			return true;
		};
		for(int k = 0; k < (1 << 10); k ++) {
			vector <int> u, v;
			for(int i = 0; i < 10; i ++)
				if((k >> i) & 1)
					u.push_back(a[i]);
				else
					v.push_back(a[i]);
			f |= check(u) && check(v);
		}
		cout << (f ? "YES\n" : "NO\n");
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define rep(i,j) for(int (i)=0;(i)<(int)(j);++(i))

int ball[10];

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

int main() {
    int n; cin >> n;
    while (n--) {
        rep(i, 10) cin >> ball[i];
        if (dfs(0, 0, 0)) puts("YES");
        else puts("NO");
    }
}