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++: // AOJ 0033
#include<cstdio>
#define rep( i, a ) for( int i = 0; i != (a); ++i )

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

	rep( i, N )
	{
		int l = 0, r = 0;
		bool fl = true;

		rep( j, 10 )
		{
			int a;
			scanf( "%d", &a );

			if( a > l && a > r )
			{
				if( l > r )
					l = a;
				else
					r = a;
			}
			else if( a > l )
				l = a;
			else if( a > r )
				r = a;
			else
			{
				fl = false;
				break;
			}
		}

		puts( fl ? "YES" : "NO" );
	}

	return 0;
}

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(i,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<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
int a,b,temp,n;
int main()
{
    int n;
    cin>>n;
    while(n--){
        int flag=1;
        a=0,b=0;
        queue<int>que;
        while(que.size())que.pop();
        for(int i=0;i<10;i++){
            cin>>temp;
            que.push(temp);
        }
        while(que.size()){
            temp=que.front();
            que.pop();
            if(temp<=a&&temp<=b){
                cout<<"NO\n";
                flag=0;
                break;
            }
            else if(temp<=a&&temp>b)b=temp;
            else if(temp<=b&&temp>a)a=temp;
            else {
                if(a>=b)a=temp;
                else b=temp;
            }
        }
        if(flag)cout<<"YES\n";
    }

    return 0;
}

C++: #include <iostream>

using namespace std;


int main(){

	int n, A, B, C;
	bool ans;

	cin >> n;

	while (n--){
		ans = true;
		B = 0;
		C = 0;

		for (int i = 0; i < 10; i++){
			cin >> A;

			if (A > B){
				B = A;
			}
			else if(A > C){
				C = A;
			}
			else{
				ans = false;
			}
		}

		cout << (ans ? "YES" : "NO") << endl;

	}


	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int b[10];
  int t;
  cin>>t;
  while(t--){
    for(int i=0;i<10;i++)
      cin>>b[i];
    int now=b[0];
    b[0]=0;
    for(int i=1;i<10;i++)
      if(b[i]>now){
	now=b[i];
	b[i]=0;
      }
    for(int i=0;i<10;i++)
      if(b[i]>0){
	now=i;
	break;
      }
    bool flag=true;
    for(int i=now;i<10;i++)
      if(b[i]>0&&b[i]<b[now])
	flag=false;
    if(flag)cout<<"YES\n";
    else cout<<"NO\n";
  }
}

C++: #include <stdio.h>

int main(void)
{
	int tubeM[10];
	int tube1[10], tube2[9];
	int i, j, k;
	int n;
	int ans;
	
	scanf("%d", &n);
	
	while(n){
		for (i = 0; i < 9; i++){
			tube2[i] = 0;
		}
		
		for (i = 0; i < 10; i++){
			scanf("%d", &tubeM[i]);
		}
		
		tube1[0] = tubeM[0];
		for (i = 1, j = 0, k = 0; i < 10; i++){
			if (tubeM[i] > tube1[j]){
				j++;
			}
			else {
				tube2[k] = tubeM[i];
				k++;
			}
		}
		
		ans = 0;
		for (i = 1; tube2[i] != 0; i++){
			if (tube2[i - 1] > tube2[i]){
				ans = 1;
				break;
			}
		}
		
		if (ans == 0){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		
		n--;
	}
	
	return (0);
}

C++: #include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
 
int main(){
  int n;
  cin>>n;
  while(n--){
    int left=-1,right=-1;
    bool flag = true;
    REP(i,10){
      int x;
      cin>>x;
      if(x>right){
        right = x;
      }else if(x>left){
        left = x;
      }else{
        flag = false;
      }
    }
    if(flag){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		vector<int> pile1;
		vector<int> pile2;
		pile2.push_back(0);
		int num[10];
		cin>>num[0]>>num[1]>>num[2]>>num[3]>>num[4]>>num[5]>>num[6]>>num[7]>>num[8]>>num[9];
		pile1.push_back(num[0]);
		for(int j=1;j<=9;j++){
			if(pile1[pile1.size()-1]<num[j]) pile1.push_back(num[j]);
			else if(pile2[pile2.size()-1]<num[j]) pile2.push_back(num[j]);
			else{
				cout<<"NO"<<endl;
				break;
			}
			if(j==9) cout<<"YES"<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int B,C; int N; int A[10];
bool dfs(int i){
  if(i==10) return true;
  if(A[i]>max(B,C)){
    if(B>C){B=A[i];}else{C=A[i];} dfs(i+1);
  }else if(A[i]<max(B,C)&&A[i]>min(B,C)){
    if(B>C){C=A[i];}else{B=A[i];} dfs(i+1);
  }else{
    return false;
  }
 }
void solve(){
  B=0; C=0;
  for(int i=0; i<10; i++){
      cin>>A[i];
    }
  if(dfs(0)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
    }
  }
int main() {
  cin>>N;
  for(int i=0; i<N; i++){
  solve();
  }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void){
	int n,a,b,c;
	bool f;
	cin>>n;
	for(int i=0;i<n;i++){
		f=true;b=0;c=0;
		for(int j=0;j<10;j++){
			cin>>a;
			if(b>a&&c>a){
				f=false;
				break;
			}else if(b<a && c<a){
				if(b>=c)b=a;
				else c=a;
			}else if(b<a){
				b=a;
			}else if(c<a){
				c=a;
			}
		}
		if(f)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

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

int n;
int ball[10];
int r, l;
int now;

bool dfs(int r, int l, int now);

int main(){

	cin >> n;

	for(int i=0; i<n; i++){
		r = 0;
		l = 0;
		now = 0;

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

		if(dfs(0, 0, 0)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

bool dfs(int right, int left, int now){
	if(now == 10) return true;
	if(right < ball[now]) return dfs(ball[now], left, now+1);
	if(left < ball[now]) return dfs(right, ball[now], now+1);
	return false;
}