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>
#include <string>
#include <algorithm>
using namespace std;

int B[12], C[12], num[12], b, c;

bool dfs(int b, int c, int i){
    if(i == 10) return true;
    B[b+1] = num[i];
    C[c+1] = num[i];
    if(B[b]<num[i] && dfs(b+1, c, i+1)){
        return true;
    }
    if(C[c]<num[i] && dfs(b, c+1, i+1)){
        return true;
    }
    return false;
}

int main(void){
  int N;
  cin >> N;
  for(int j=0; j<N; j++){
  B[0] = 0;
  C[0] = 0;
  for(int i=0; i<10; i++){
    cin >> num[i];
  }
  dfs(0, 0, 0);
  if(dfs(0, 0, 0))  cout << "YES" << endl;
  else cout << "NO" << endl;
  }
  return 0;
}

C++: #include<stdio.h>
int a[10],b=0,c=0;
bool tube[10];
bool dfs(int i){
    if(i==10) return true;
    bool flagb,flagc;
    if(b>=a[i]&&c>=a[i]) return false;
    if(b<a[i]){
        int oldb=b;
        b=a[i];
        flagb=dfs(i+1);
        b=oldb;
        if(flagb) return true;
    }
    if(c<a[i]){
        int oldc=c;
        c=a[i];
        flagc=dfs(i+1);
        c=oldc;
        if(flagc) return true;
    }
    return flagb||flagc;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            scanf("%d",a+j);
        }
        if(dfs(0)) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

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

stack<int> array1,array2;
int Balls[10];

bool DFS(int number,stack<int> s1,stack<int> s2){
  if(number > 9) return true;
  if(s1.top() < Balls[number]){
    s1.push(Balls[number]);
    if(DFS(number+1,s1,s2)){
      return true;
    }
    s1.pop();
  }
  if(s2.top() < Balls[number]){
    s2.push(Balls[number]);
    if(DFS(number+1,s1,s2)){
      return true;
    }
    s2.pop();
  }
  return false;
}

int main(){

    int N;

    cin >> N;

    for(int i=0;i<N;i++){
      for(int i=0;i<10;i++){
        cin >> Balls[i];
      }
      array1.push(0);
      array2.push(0);

      if(DFS(0,array1,array2)){
        cout << "YES" << endl;
      }
      else{
        cout << "NO" << endl;
      }
      while (!array1.empty()) {
        array1.pop();
      }
      while (!array2.empty()) {
        array2.pop();
      }
    }
    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int n, ball[10];
  vector<string> result;

  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++)
      cin >> ball[j];
    int j, a = 0, b = 0;
    for (j = 0; j < 10; j++) {
      if (ball[j] > a)
        a = ball[j];
      else if (ball[j] > b)
        b = ball[j];
      else
        break;
    }
    if (j == 10)
      result.push_back("YES");
    else
      result.push_back("NO");
  }

  for (int i = 0; i < n; i++)
    cout << result[i] << endl;
  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;
    int c1=0,c2=0;
    in1.push_back(0);
    in2.push_back(0);
    for(j=0;j<10;j++){
      cin >> tmp;
      if(in1[c1]<tmp){
	in1.push_back(tmp);
	c1++;
      }else{
	in2.push_back(tmp);
	c2++;

      }
    }
    
    
    
    for(j=1;j<c2;j++){
      if(in2[j-1]>in2[j])
	han=1;
    }

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


}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define range(i,b) rep(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
	int a,b;
	int n;
	int input;
	bool check;

	while(cin >> n){
		range(i,n){
			a = b = 0;
			check = true;
			range(i,10){
				cin >> input;
				if(input > a && input > b){
					if(a > b)
						a = input;
					else
						b = input;
				}else if(input > a){
					a = input;
				}else if(input > b){
					b = input;
				}else{
					check = false;
				}
			}
			if(check) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}
}

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

using namespace std;

bool search(int l, int r, int n)
{
  if (n == 10) {
    return true;
  }

  if (l < ball[n]) {
    if (search(ball[n], r, n + 1)) {return true;}
  } 
  if (r < ball[n]) {
    if (search(l, ball[n], n + 1)) {return true;}
  }
  return false;
}

vector<int> ball;
int main()
{
  int N;
  scanf("%d ", &N);
  
  for (int i = 0; i < N; i++) {
    ball.clear();
    ball.resize(10);
    for (int i = 0; i < 10; i++) {
      scanf("%d ", &ball[i]);
    }
    if (search(ball[0], 0, 1)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<climits>
#include<algorithm>
#include<functional>
#include<iomanip>
#define LL long long
using namespace std;

int T,a[15];

int main(void){
    scanf("%d",&T);
    while(T--){
        int i;
        for(i=1;i<=10;i++) scanf("%d",&a[i]);
        bool can=true;
        int l=0,r=0;
        for(i=1;i<=10;i++){
            if(a[i]<l && a[i]<r){
                can=false;
                break;
            }
            if(l<r){
                if(a[i]>r) r=a[i];
                else l=a[i];
            }
            else{
                if(a[i]>l) l=a[i];
                else r=a[i];
            }
        }
        if(can) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

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

int main(){
	int N;
	int A[11];
	int cnt1=0;
	cin>>N;
	while(1){
		
		if(cnt1==N){
			break;
		}
		cnt1++;
		for(int i=1;i<=10;i++){
			cin>>A[i];
		}
		int B=A[1];
		int Z[11];
		for(int i=1;i<=10;i++){
			Z[i]=0;
		}
		int C=0;
		int cnt2=0;
		int su=0;
		for(int i=2;i<=10;i++){
			if((B+1==A[i])/*||((su==1)&&(B<A[i]))*/){
				B=A[i];
				cnt2++;
				cout<<"1"<<A[i]<<endl;
			}
			else if((C+1==A[i])/*||((su==1)&&(B<A[i]))*/){
				C=A[i];
				cnt2++;
				Z[i]=C;
				su=0;
//cout<<"2"<<A[i]<<endl;
			}
			else if(B<A[i]){
				B=A[i];
				//Z[i]=C;
				//su=0;
				cnt2++;
//cout<<"3"<<A[i]<<endl;
			}
			else if(C<A[i]){
				C=A[i];
				Z[i]=C;
				su=0;
				cnt2++;
//cout<<"4"<<A[i]<<endl;
			}
			//CにB＋1がはいっていたらsu=1にすること
			for(int q=1;q<=10;q++){
				if(B+1==Z[q]){
					su=1;
				}
			}
			
		}
		if(cnt2==9){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	return 0;	
}

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

using namespace std;

void solve() {
  int a = 0, b = 0, c;
  bool f = true;
  for (int i = 0; i < 10; ++i) {
    cin >> c;
    if (c < a) f = false;
    else if (c < b) a = c;
    else b = c;
  }
  cout << (f ? "YES" : "NO") << endl;
}

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) solve();
}