Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var num int
	fmt.Scan(&num)

	for i := 0; i < num; i++ {
		sc.Scan()
		line := sc.Text()

		insertCheck(line)
	}
}

func insertCheck(line string) {
	var B, C []int

	for _, v := range strings.Split(line, " ") {
		ball, _ := strconv.Atoi(v)
		switch {
		case len(B) == 0:
			B = append(B, ball)
		case B[len(B)-1] < ball:
			B = append(B, ball)
		case B[len(B)-1] >= ball:
			switch {
			case len(C) == 0:
				C = append(C, ball)
			case C[len(C)-1] < ball:
				C = append(C, ball)
			case C[len(C)-1] >= ball:
				fmt.Println("NO")
				return
			}
		}
	}
	fmt.Println("YES")
}

C++: #include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int a[10];
        for (int j=0;j<10;j++)
            cin >> a[j];
        int left,right;
        left = a[0];
        right = 0;
        for (int j=1;j<10;j++){
            if(a[j]<left && a[j]<right){
                cout << "NO" << endl;
                break;
            }
            else{
                if(j==9){
                    cout << "YES" << endl;
                    break;
                }
                else{
                if(a[j]>left && a[j]<right)
                    left = a[j];
                else{
                    if(a[j]<left && a[j]>right)
                        right = a[j];
                    else{
                        if(left<right)
                            right = a[j];
                        else
                            left = a[j];
                    }
                }
            }
        }
        }
    }
}

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

int main() {
	int n, x;
	cin >> n;
	for (int lop = 0, a = 0, b = 0; lop < n; lop++) {
		bool f = true;
		for (int i = 0; i < 10; i++) {
			cin >> x;
			if (f) {
				if (a < x && b < x) {
					if (a < b) {
						b = x;
						continue;
					}
					a = x;
					continue;
				}
				if (a < x) {
					a = x;
					continue;
				}
				if (b < x) {
					b = x;
					continue;
				}
				f = false;
			}
		}
		cout << (f ? "YES\n" : "NO\n");
	}
	return 0;
}

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

int main() {

  int n;
  cin >> n;

  int b = 0;
  int c = 0;
  int input;

  for ( int i = 0; i < n; i++ ) {

    bool flag = false;
    for ( int j = 0; j < 10; j++ ) {
      cin >> input;

      if ( input < b && input < c ) flag = true;
      if ( flag ) continue;

      if ( input < b ) {
	c = input;
      }else if ( input < c ) {
	b = input;
      }else {
	if ( b < c ) {
	  c = input;
	}else {
	  b = input;
	}
      }

    }

    if ( flag ) {
      cout << "NO" << endl;
    }else {
      cout << "YES" << endl;
    }

  }

  return 0;

}

C++: #include<iostream>

using namespace std;

int tama[10],n;

bool Haireruka(int i,int left,int right){
	if(i==9)return true;
	if(tama[i]>left){
		if(Haireruka(i+1,tama[i],right))return true;
	}
	if(tama[i]>right){
		if(Haireruka(i+1,left,tama[i]))return true;
	}
	return false;
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		for(int i=0;i<10;i++){
			cin>>tama[i];
		}
		if(Haireruka(0,0,0))cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

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

int main(void)
{
	int N;
	cin >> N;

	while(N > 0){
		int data[10];
		int a=0,b=-1;
		for(int i = 0; i < 10; i++){
			cin >> data[i];

		}

		for(int i = 0; i < 10; i++){
			if(a > data[i] && b > data[i]){
				a = -1;
				break;
			}
			if(data[i] > a && a > b)
				a = data[i];
			else if(a > data[i] && data[i] > b)
				b = data[i];


		}

		if(a < 0)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;

		N--;
	}

	return 0;

}

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

int n;
int a[11];
//int r, l;

// bool dfs(int i) {
//     if (i == 9) return a[i] > r || a[i] > l;
//     if (a[i] > r) {
//         r = a[i];
//     }
//     if (a[i] > l) {
//         l = a[i];
//     }
//     if (dfs(i+1)) return true;
//     return false;
// }

bool dfs(int i, int r, int l) {
    if (i == 9) return a[i] > a[r] || a[i] > a[l];
    if (dfs(i+1, max(a[i+1], r), l)) return true;
    if (dfs(i+1, r, max(a[i+1], l))) return true;
    return false;
}

void solve() {
    if (dfs(0,0,0)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> a[j];
        }
        solve();
    }
}

C++: #include <iostream>
using namespace std;
 
int a[10];
int n;
 
bool dfs(int i,int left,int right){
    if(i==10) return true;
    if(a[i]>left){
        if(dfs(i+1,a[i],right)) return true;
    }
    if(a[i]>right){
        if(dfs(i+1,left,a[i])) return true;
    }
    return false;
}
 
void solve(){
    for(int i=0;i<10;i++) cin >> a[i];
    if(dfs(0,0,0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return;
}
 
int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        solve();
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int bfs(int, int, int);
int a[10];
int main(void){

	int n;

	cin >> n;
	for (int n_count = 0; n_count < n; n_count++){

		for (int i = 0; i < 10; i++){

			cin >> a[i];
		}

		if (bfs(0, 0, 0) == 1)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

int bfs(int i, int l, int r){

	int ans = 0;

	if (i == 10)
		ans = 1;

	if (l < a[i])
		ans = bfs(i + 1, a[i], r);

	if (r < a[i])
		ans = bfs(i + 1, l, a[i]);

	return ans;
}

C++: //???1601-2 ????±????(616342287) 12:28:09
#include <iostream>
#include <fstream>
#include <stack>
#include <vector>
#include <cstring>
using namespace std;
int a[11];
int b[11];
int c[11];
int flag;
void dfs(int x,int y,int z)
{
  if(x==10)
  {
    flag=1;
    return;
  }
  if(a[x]<b[y]&&a[x]<c[z])
      return;
  if(a[x]>b[y])
  {
      b[y+1]=a[x];
      dfs(x+1,y+1,z);
      b[y+1]=0; 
  }
  if(a[x]>c[z])
  {
      c[z+1]=a[x];
      dfs(x+1,y,z+1);
      c[z+1]=0; 
  }
}
int main()
{
//  freopen("3.txt","r",stdin);
  int n;
  cin >> n;
  while(n--)
  {
  flag=0;
  memset(b,0,sizeof(b));
  memset(c,0,sizeof(c));
  for(int i=0;i<10;i++)
      cin >> a[i];
  dfs(0,0,0);
  if(flag)
      cout << "YES" << endl;
  else
      cout << "NO" << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n, num, count, before;

  cin >> n;

  for(int i = 0; i < n; i++){
    count = 0;
    before = 0;
    for(int j = 0; j < 10; j++){
      cin >> num;
      if(num < before){
        count++;
        if(count >= 2){
          cout << "NO" << endl;
          break;
        }
      }else{
        count = 0;
      }
      before = num;
    }
    if(count < 2) 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 bTop = 0, cTop = 0;
        for (int j = 0; j < 10; j++) {
            int input;
            cin >> input;
            if (bTop >= cTop) {
                if (input > bTop) {
                    bTop = input;
                } else if (input > cTop) {
                    cTop = input;
                } else {
                    cout << "NO" << endl;
                    break;
                }
            } else {
                if (input > cTop) {
                    cTop = input;
                } else if (input > bTop) {
                    bTop = input;
                } else {
                    cout << "NO" << endl;
                    break;
                }
            }
            if (j == 9) {
                cout << "YES" << endl;
            }
        }
    }
}