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 main(void)
{
    int bo[11],n,B[11],C[11],b1=0,c1=0,A=0,k=0,l=1;
    cin>>n;
    for(int i=0;i<n;i++){
            C[0]=11;k=0;l=0;B[0]=0;b1=0;c1=0;C[1]=13;
        for(int j=0;j<10;j++){
                //srand(time(NULL));
           cin>>bo[j];
           /*bo[j]=6-5+rand()%10;
            for(int m=0;m<j;m++){
                if(bo[j]==bo[m]){
                    --j;break;
                }
            }*/
        }
        for(int j=0;j<10;j++)cout<<bo[j]<<" ";
        cout<<"\n";
        for(int j=1;;j++){
                cout<<bo[j]<<" ";
            if(j==1)B[0]=bo[0];
        if(C[0]==11&&j==2){
            C[0]=bo[j];
            k++;
           // cout<<"6\n";
        }else if(C[1]==13&&j>3&&C[0]<bo[j]){
            C[1]=bo[j];
            k++;
            c1=1;
            //cout<<"7\n";
        }else if(B[l]<bo[j]){
            b1=1;
            B[l+1]=bo[l];
            l++;
            //cout<<"1\n";
        }else if(C[0]==11){
            C[0]=bo[j];
            k++;
            //cout<<"2\n";
        }else if(C[k-1]<bo[j]){
            c1=1;
            C[k+1]=bo[j];
            //cout<<"3\n";
        }else if(B[l]<bo[j+1]){
            C[k+1]=bo[j];
            k++;
            if(C[k]>C[k-1])c1=1;
            //cout<<"5\n";
        }else if(C[1]==13&&j>3){
            C[1]=bo[j];
            k++;
           // cout<<"7\n";
        }else{
            B[l+1]=bo[j];
            l++;
           // cout<<"4\n";
        }
        if(j==9||(b1==1&&c1==1))break;
    }
    if(b1==1&&c1==1)cout<<"YES\n";
    else cout<<"NO\n";
    for(int j=0;j<10;j++){
        B[j]=0;C[j]=0;
    }

}
}

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 n = 10;
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<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
bool sf;
int T,st1,st2,x;
    int a[20],b[20],s[20];
void dfs(int i)
{
    if(i==10)
    {
        sf=1;
        return ;
    }
    if(sf)return ;
    if(a[st1]<s[i])
    {
        a[++st1]=s[i];
        dfs(i+1);
    }
    if(b[st2]<s[i])
    {
        b[++st2]=s[i];
        dfs(i+1);
    }

}
int main()
{
   // freopen("input.txt","r",stdin);

    cin>>T;
    while(T--)
    {
        for(int i=0;i<10;i++)
            cin>>s[i];
        sf=0;
        dfs(0);
        if(sf)cout<<"YES\n";
        else cout<<"NO\n";

    }





    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;

int n;
vi A(10);
string ret;

void dfs(int k, int b, int c) {
	if (k > 9) {
		ret = "YES";
		return;
	}
	int a = A[k];
	if (a > b) dfs(k + 1, a, c);
	if (a > c) dfs(k + 1, b, a);
}

void solve() {
	ret = "NO";
	dfs(1, A[0], 0);
	cout << ret << endl;
}

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

C++: #include<stdio.h>
bool tansaku(int count,int n1,int n2,int ans[],int a[],int b[],bool flg)
{
	if (count == 10)
	{
		return true;
	}
	if (flg == false)
	{
		if (a[n1] < ans[count])
		{
			n1++;					
			a[n1] = ans[count];
			count++;
			bool hozon = tansaku(count,n1,n2,ans,a,b,flg);
			if (hozon == true)
			{
				flg = true;
			}
		}
		if (b[n2] < ans[count])
		{
			n2++;
			b[n2] = ans[count];
			count++;
			bool hozon = tansaku(count,n1,n2,ans,a,b,flg);
			if (hozon == true)
			{
				flg = true;
			}
		}
	}
	return flg;
}
int main(void)
{
	int n = 0;
	int a[10] = {0};
	int damy[20] = {0};
	bool ans_flg[100] = {false};
	scanf("%d",&n);
	for (int i = 0;i < n;i++)
	{
		scanf("%d %d %d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);
		if (tansaku(0,0,0,a,damy,damy,false) == true)
		{
			ans_flg[i] = true;
		}
	}
	for (int i = 0;i < n;i++)
	{
		if (ans_flg[i] == true)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

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

int main(){

int N,x,y,n;

scanf("%d",&N);

for(int i=0;i<N;i++){
x=n=0;
y=-1;
	for(int j=0;j<10;j++){
		scanf("%d",&n);
		if(x>n && y>n){
			printf("NO\n");
			break;
		}
		else if(/**(x>n &&**/ n>y)//||(n>y && y>x))
			y=n;
		else if(/**(y>n &&**/ n>x)//||(n>x && x>y))
			x=n;
		if(j==9)
			printf("YES\n");
	}			
}
return 0;
}

C++: #include<cstdio>
#include<algorithm>

using namespace std;

int N;
int l[15];
int b,c;
int res[100000];


void solve(int k){
  for(int i=0;i<10;i++){
    if(b<l[i] && c<l[i]){
      if(l[i]-b < l[i]-c) b=l[i];
      else c=l[i];
    }
    else if(b<l[i] && c>l[i]) b=l[i];
    else if(b>l[i] && c<l[i]) c=l[i];
    else{
      res[k]=0;
      return;
    }
  }
  res[k]=1;
  return;
}


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

  for(int i=0;i<N;i++){
    b,c=0;
    scanf("%d%d%d%d%d%d%d%d%d%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9]);
    solve(i);
  }

  for(int i=0;i<N;i++){
    if(res[i]==0) printf("NO\n");
    else printf("YES\n");
  }


  return 0;
}