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 <iostream>
using namespace std;

enum {B, C};

int main() {
	int n; cin >> n;  // ???????????????????????°
	
	while(n--){
		int balls[10] = {0};
		for(int i = 0; i < 10; i++){
			cin >> balls[i];
		}
		
		bool isYES = true;
		int top[2] = {0}; // ???B?????????C???????????¨????????????
		for(int i = 0; i < 10; i++){
			if (top[B] < balls[i]){
				top[B] = balls[i];
			} else if (top[C] < balls[i]) {
				top[C] = balls[i];
			} else {
				isYES = false;
				break;
			}
		}
		cout << (isYES ? "YES" : "NO") << endl;
	}
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;


bool f=false;

void dfs(int depth , int b , int c , int* a){
	if(depth==10) return;
	if(f) return;
	if(a[depth]>b) dfs(depth+1 , a[depth] , c , a);
	else if (a[depth]>c) dfs(depth+1 , b , a[depth] , a);
	else {
		f=true; 
		return;
	}
}


int main(){
	int a[10];
	int b[10],c[10];
	int n;
	cin >> n;
	for(int i=0;i<n ; ++i){
		for(int j=0;j<10;++j){
			cin >> a[j];
		}
		dfs(0 , 0 , 0 , a);
		cout << ( !f ? "YES" : "NO" ) << endl;
	}
	return 0; 
}

C++: #include<cstdio>

int a[10];

bool is_ok(int n){
  int right = 0;
  int left = 0;
  for(int i=0;i<10;i++){
    if(n%2==1&&right<a[i]) right = a[i];
    else if(n%2==0&&left<a[i]) left = a[i];
    else return false;
    n/=2;
  }
  return true;
}

void solve(){
  for(int i=0;i<10;i++) scanf("%d",a+i);
  for(int i=0;i<1024;i++){
    if(is_ok(i)){
      printf("YES\n");
      return;
    }
  }
  printf("NO\n");
}


int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++) solve();
  return 0;
}

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

int main() {
	int n, x, z;
	cin >> n;

	for (int i = 0; i < n; i++) {
		vector< vector<int> > v(3, {0});
		z = 1;
		for (int j = 0; j < 10; j++) {
			cin >> x;
			for (int k = 0; k < z; k++) {
				if (v[k].back() < x) {
					v[k].push_back(x);
					break;
				}

				if (k == z - 1) {
					v[z].push_back(x);
					z++;
					break;
				}
			}

			if (z == 3) {
				x = -1;
				break;
			}
		}

		if (x == -1) {
			cout << "NO";
		}
		else {
			cout << "YES";
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define INF INT_MAX/3
#define vc vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define ll long long
#define eps 1e-14
int dx[] = { 1,-1,0,0,0 };
int dy[] = { 0,0,1,-1,0 };


int x[10];

void solve() {
	int left, r;
	left = x[0];
	r = 0;
	//?????¨?????§??§??????????????§?????¶??????????????´???????????\??????
	for (int i = 1; i < 10; i++) {
		//???????????¶??????????????????
		if (left > x[i] && r > x[i]) {
			cout << "NO" << endl;
			return;
		}
		//?????????????????¶????????????
		if (x[i] < left && r < x[i]){
			r = x[i];
			continue;
		}
		else if (x[i] < r&&left < x[i]) {
			left = x[i];
			continue;
		}
		else { //???????????????????????´???
			if (r < left) {
				left = x[i];
				continue;
			}
			else {
				r = x[i];
				continue;
			}
		}
		
	}
	cout << "Yes" << endl;
}

int main() {
	int n;
	cin >> n;
	REP(i, n) {
		REP(j, 10)
			cin >> x[j];
		solve();
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define pr(x) cout<<#x<<" "<<x;
#define pl(x) cout<<#x<<" "<<x<<endl;
#include<math.h>
#include<algorithm>
using namespace std;
int num[10];
bool dfs(int step,int btop,int ctop){
    if(step==9){
        if(num[step]>btop||num[step]>ctop){
            return true;
        }
        else return false;
    }
    bool b = false;
    bool c = false;
    if(num[step]>btop){b = dfs(step+1,num[step],ctop);}
    if(num[step]>ctop){c = dfs(step+1,btop,num[step]);}

    return (b||c);

}

int main(){
    int t;
    cin>>t;
    while(t--){
      memset(num,0,sizeof(num));
      for(int i = 0;i<10;i++){
        cin>>num[i];
      }
      bool ans = dfs(0,0,0);
      if(ans){cout<<"YES"<<endl;continue;}
      else{cout<<"NO"<<endl;continue;}


    }

}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  cin>>n;
  rep(j,n){
    bool ok=true;
    int a,b=0,c=0;
    rep(i,10){
      cin>>a;
      if(a>b)b=a;
      else if(a>c)c=a;
      else ok=false;
    }
    if(ok)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

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

int main(void){
  int N,temp,flag;
  vector<int> A,B(1,0),C(1,0);
  cin >> N;
  for(int i=0; i<N; ++i){
    for(int j=0; j<10; ++j){
	cin >> temp;
	A.push_back(temp);
      }
    while(!A.empty()){
      temp = A.front();
      if(temp>=B.back()) B.push_back(temp);
      else if(temp>=C.back()) C.push_back(temp);
      else{
	cout << "NO" << endl;
	flag = 1;
	break;
      }
      A.erase(A.begin());
    }
    if(flag!=1)
      cout << "YES" << endl;
    flag=0;
    A.clear(); B.clear(); C.clear();
  }
}

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

int main(){
	int n, a;
	vector<int> A;
	cin >> n;
	
	for(int i=0 ; i<n ; i++){
		A.clear();
		for(int j=0 ; j<10 ; j++){
			cin >> a;
			A.push_back(a);
		}
		stack<int> B, C;
		bool flag = true;
		B.push(0);
		C.push(0);
		for(int j=0 ; j<10 ; j++){
			a = A[j];
			if( B.top() == 0 ){
				B.push( a );
			}else{
				if( B.top() > a ){
					if( C.top() > a ){
						cout << "NO" << endl;
						flag = false;
						break;
					}else{
						C.push(a);
					}
				}else{
					if( C.top() > a ){
						B.push(a);
					}else{
						( a-B.top() < a-C.top() )? B.push(a) : C.push(a) ;
					}
				}
			}
		}
		if( flag ){
			cout << "YES" << endl;
		}
	}
}

C++: #include <cstdio>

int a[10];


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