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;

int num[10];
bool chack;

void solve(int R, int L, int i){
    if(i==10) chack = true;
    if(chack == true) return;
    if(num[i]>R) solve(num[i], L, i+1);
    if(num[i]>L) solve(R, num[i], i+1);
    return;
}
int main(void){
    int N;
    cin >> N;
    while(N>0){
        chack = false;
        for(int i=0; i<10; i++)
            cin >> num[i];
        solve(0,0,0);
        if(chack)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
        N--;
    }
}

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

using namespace std;

#define NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO 1

int Hoge[NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 11];
int Nubedyon(int n, int l, int r);

int main(void){
	int HogeHogePiypPiyo, Piyo;
	cin >> HogeHogePiypPiyo;
	for (int Nubesko = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1; Nubesko < HogeHogePiypPiyo; Nubesko++){
		for (int Dyon = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1; Dyon < NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 10; Dyon++){
			cin >> Hoge[Dyon];
		}
		Hoge[NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 10] = 0;
		Piyo = Nubedyon(NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1,
						NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1,
						NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1);
		if (Piyo == NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1){
			cout << "NO" << endl;
		}
		else{
			cout << "YES" << endl;
		}
	}
	return NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1;
}

int Nubedyon(int n, int l, int r){
	int ans = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO - 1;
	if (n == NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO * 10){
		ans = NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO;
	}
	if (l < Hoge[n]){
		ans = Nubedyon(n + NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO, Hoge[n], r);
	}
	if (r < Hoge[n]){
		ans = Nubedyon(n + NUBEDYONNNUZODYONNBERUMITTEXISUMOGERONNBOXYO, l, Hoge[n]);
	}

	return ans;
}

C++: #include<cstdio>

int main(){
	int n, b, c, t, f;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		b = c = f = 0;
		for(int j = 0; j < 10; j++){
			scanf("%d", &t);
			if(b < t){
				b = t;
			}else{
				if(c < t){
					c = t;
					if(b < c){
						t = b;
						b = c;
						c = t;
					}
				}else{
					f = 1;
				}
			}
		}

		if(f){
			printf("NO\n");
		}else{
			printf("YES\n");
		}
	}
	return 0;
}

C++: #include <iostream>

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

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int a[11];
bool dfs(int i, int b, int c) {
    if (i == 10) return true;
    if (b < a[i]) {
        if (dfs(i + 1, a[i], c)) return true;
    }
    if (c < a[i]) {
        if (dfs(i + 1, b, a[i])) return true;
    }
    return false;
}

int main() {
    int n;
    cin >> n;
    rep(i, n) {
        rep(j, 10) cin >> a[j];
        cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
    }
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

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

bool solve(const VI v){
  int head = v[0];
  int right_head = -1;
  REP(i, 1, 10){
    if(head >= v[i]){
      if(right_head < v[i]){
        right_head = v[i];
      } else {
        return false;
      }
    } else {
      head = v[i];
    }
  }

  return true;
}

int main(){
  int num;

  scanf("%d\n", &num);

  REP(i, 0, num){
    VI v;
    REP(j, 0, 10){
      int tmp;
      scanf("%d ", &tmp);
      v.push_back(tmp);
    }
    if(solve(v)){
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }  

  return 0;
}

C++: #include <iostream>

using namespace std;

const int STOP = 100;

bool search(int l, int r, int* a){
	bool f = false;
	int buf = *a;
	if(buf == STOP) return true;
	if(buf < l && buf < r) return false;
	if(buf > l) f = f || search(buf, r, a + 1);
	if(buf > r) f = f || search(l, buf, a + 1);
	return f;
}

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int l[11];
		for (int j = 0; j < 10; j++) {
			cin >> l[j];
		}
		l[10] = STOP;
		if(search(0, 0, l)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

C++: #include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
#include <sstream>
using namespace std;
int ball[10];
bool dfs(int i,int b,int c);
int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int s=0;s<10;s++){
            cin>>ball[s];
        }
        if(dfs(0,0,0))cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}
bool dfs(int i,int b,int c){
    if(i==10)return true;
    if(b<ball[i]){
        if(dfs(i+1,ball[i],c))return true;
    }
    if(c<ball[i]){
        if(dfs(i+1,b,ball[i]))return true;
    }
    return false;
}

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

int main() {
	int n;
	int d[10];
	int va[10];
	int vb[10];

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

		int ca = 0, cb = 0;
		va[0] = d[0];
		ca++;
		if (d[1] > va[0]) {
			va[1] = d[1];
			ca++;
		}

		else {
			vb[0] = d[1];
			cb++;
		}

	for (int j = 2; j < 10; j++) {

			if (d[j] > va[ca-1]) {
				va[ca] = d[j];
				ca++;
			}

			else if (d[j] > vb[cb-1]) {
				vb[cb] = d[j];
				cb++;
			}

			else {
				cout << "NO" << endl; 
				goto FINLOOP;
			}

		}
		cout << "YES" << endl;

	FINLOOP:

		for (int i = 0; i < 10; i++) {
			va[i] = 0;
		}
		for (int i = 0; i < 10; i++) {
			vb[i] = 0;
		}
	}
	return 0;
}