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

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

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	vector<bool>b;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int o[10];
		for (int i = 0; i < 10; i++){
			cin >> o[i];
		}
		bool bo = true;
		int l = o[0], r = 0;
		for (int i = 1; i < 10; i++){
			if (l >= r){
				if (o[i] >= l) {
					l = o[i];
					goto cont;
				}
				else{
					goto L;
				}
			}
			else{
			L:
				if (o[i] >= r){
					r = o[i];
					goto cont;
				}
				else{
					bo = false;
				}
			}
		cont:;
		}
		b.push_back(bo);
	}
	for (bool i : b) {
		if (i)cout << "YES"; else cout << "NO";
		cout << endl;
	}
	char ch;
	cin >> ch;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_N = 10;
const int n = MAX_N;
int t;
int a, b, c;

int main()
{
  cin >> t;

  while(t--){
    bool ok = true;
    b = c = 0;
    rep(i, n){
      cin >> a;
      if(b > c) swap(b, c);
      if(a > c){ c = a;  continue; }
      if(a > b){ b = a;  continue; }
      ok = false;
      break;
    }
    puts(ok ? "YES" : "NO");
  }

  return 0;
}

C++: #include <cstdio>


int balls[12];

bool DFS(int cur,int left,int right){
    if (cur > 10) return true;
    auto val=balls[cur];
    return (val>left&&DFS(cur+1,val,right))||(val>right&&DFS(cur+1,left,val));
}

int main(){

    int N;
    scanf("%d",&N);

    for(int i=0;i<N;i++){
        for(int i=1;i<=10;i++) scanf("%d",balls+i);
        if (DFS(1,0,0)) puts("YES");
        else puts("NO");
    }

    return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  REP(t,N){
	int a[10]; REP(i,10) cin >> a[i];
	bool flag = true;
	for(int d=0;d<=1;++d)
	  for(int i=2;i<10;i+=2)
		if(a[i-2+d] >= a[i+d]) flag = false;
	cout << (flag? "YES": "NO") << endl;
  }
  
  return 0;
}

C++: #include<iostream>
using namespace std;
int n, cnt, G[15], L[15];
int main()
{
    cin >> n;
    for(int w = 0; w < n; w++)
    {
        cnt = 0;
        for(int i = 0; i < 15; i++) L[i] = 15;
        for(int i = 1; i <= 10; i++)
        {
            cin >> G[i];
            if(G[i] <= L[cnt]) L[++cnt] = G[i];
            else
            {
                for(int j = cnt - 1; j >= 0; j--)
                    if(G[i] < L[j]) {L[j + 1] = G[i]; break;}
            }
        }
        cout << (cnt > 2 ? "NO" : "YES") << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
#define NUM 10
int main(){
  int n;
  int ball[NUM];
  int b[NUM];
  cin>>n;
  for(int c=0;c<n;c++){
    for(int i=0;i<NUM;i++){
      cin>>ball[i];
      b[i]=-1;
    }
    int x=0;
    for(int j=0;j<NUM-1;j++){
      int t=ball[j];
      while(j<NUM-1 && t>=ball[j+1]){
	b[x]=ball[j+1];
	x++;
	j++;
      }
    }
    int f=true;
    for(int j=1;j<NUM && b[j]>0;j++){
      if(b[j]<=b[j-1]){
        f=false;
	break;
      }
    }
    if(f)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
 
using namespace std;
 
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
 
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
 
int N;
vector<int>a;
 
int dfs(int n, int b, int c){
  if(n == 10) return 1;
 
  if(b < a[n] && dfs(n+1, a[n], c)) return 1;
  if(c < a[n] && dfs(n+1, b, a[n])) return 1;
  return 0;
}
 
int main(){
  scanf("%d", &N);
  rep(i, N){
    a.clear();
    int b;
    rep(i, 10){
      scanf("%d", &b);
      a.PB(b);
    }
 
    printf("%s\n", dfs(0, 0, 0)?"YES":"NO");
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int a[10];

bool dfs(int d, int left, int right) {
    if (d == 10) {
        return true;
    }
    if (a[d] > left) {
        return dfs(d + 1, a[d], right);
    }
    if (a[d] > right) {
        return dfs(d + 1, left, a[d]);
    }
    return false;
}

int main() {
    int n;
    cin >> n;
    while (n--) {
        for (int i = 0; i < 10; i++) {
            cin >> a[i];
        }
        if (dfs(0, 0, 0) == true) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }

    return 0;
}