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++: #include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int N, H[10];

void solve() {
	int big=0, small=0;
	for (int i = 0; i < 10; i++) {
		if (big < small) swap(big, small);
		if (H[i] < small) {
			printf("NO\n");
			goto JUMP;
		}

		if (H[i] > big) big = H[i];
		else if (H[i] > small) small = H[i];

	}
	printf("YES\n");
JUMP:
	;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> H[j];
		}
		solve();
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main( void )
{
	int N; // f[^ZbgÌÂ
	cin >> N;

	for ( int lpc = 0; lpc < N; lpc++ )
	{
		int a = 0;
		int b = 0;
		int cnt = 0;
		for ( int i = 0; i < 10; i++ )
		{
			int c;
			cin >> c;

			bool ok = false;
			if ( a < c )
			{
				if ( b < c && b > a )
					b = c;
				else
					a = c;
				ok = true;
			}
			else if ( b < c )
			{
				if ( a < c && a > b )
					a = c;
				else
					b = c;
				ok = true;
			}

			if ( ok == false )
			{
				while ( i+1 < 10 )
				{
					cin >> c;
					i++;
				}
				break;
			}

			cnt++;

		}

		cout << cnt << endl;
		if ( cnt == 10 )
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}

	}

	return 0;
}

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

using namespace std;

int main() {
	vector<int> left;
	vector<int> right;
	vector<int> all;

	bool flag = true;

	int n;
	cin >> n;
	if (n == 0) return -1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			int temp;
			cin >> temp;
			all.push_back(temp);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			if (left.size() > 0) {
				if (all[10 * i + j] > left[left.size() - 1]) {
					left.push_back(all[10 * i + j]);
				}
				else {
					if (right.size() > 0) {
						if (all[10 * i + j] > right[right.size() - 1])
							right.push_back(all[10 * i + j]);
						else
							flag = false;
					}
					else {
						right.push_back(all[10 * i + j]);
					}
				}
			}
			else {
				left.push_back(all[10 * i + j]);
			}
		}

		if (flag)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		flag = true;
	}

	return 0;
}

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;
}