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<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(o) {cerr<<#o<<" "<<o<<endl;}
#define DUMPC(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int N; cin >> N;
	REP(i, N) {
		vector<int> a(10);
		REP(j, 10)cin >> a[j];
		REP(j, 2) {
			int M = 0;
			REP(k, 10) {
				if (M < a[k]) {
					M = a[k];
					a[k] = 0;
				}
			}
		}
		if (*max_element(ALL(a)) == 0)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

int Balls[10];

bool fork(int balls[], int i, int b, int c) {
  if (i == 10) return true;
  if (b > balls[i] && c > balls[i]) return false;
  if (b < balls[i] && fork(balls, i + 1, balls[i], c)) return true;
  if (c < balls[i] && fork(balls, i + 1, b, balls[i])) return true;
}

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

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    int n; cin >> n;
    int x;
    for(int k = 0; k < n; k++) {
        int a = 0, b = 0;
        bool can = true;
        rep(k,0,10) {
            cin >> x;
            if(a < x) a = x;
            else if(b < x) b = x;
            else {cout << "NO" << endl; can = false; break;}
        }
        if(can) cout << "YES" << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<string>
#include<cstring>
#include<math.h>
#include<algorithm>
#include<map>

#include<sstream>
#include<ctype.h>

#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
 
typedef long long ll;
using namespace std;
 
const int INF = 0x7f7f7f7f;
const double PI = acos(-1.0);
const int maxn = 1005;
const int MOD = (int)1e9+7;
#define LOCAL 0
#define MOD 1000000007

int a[15],l[15],r[15];
bool res;

bool dfs(int apos,int lpos,int rpos){
	
	if(apos == 11)	return true;
	if(a[apos] > l[lpos-1]){
		l[lpos] = a[apos];
		if(dfs(apos+1,lpos+1,rpos)) return true;
	} 
	if(a[apos] > r[rpos-1]){
		r[rpos] = a[apos];
		if(dfs(apos+1,lpos,rpos+1)) return true;
	} 
	return false;
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		memset(a,0,sizeof(a));
		memset(l,0,sizeof(l));
		memset(r,0,sizeof(r));
		for(int i = 1 ; i <= 10 ; i ++) 	scanf("%d",&a[i]);		
		if(dfs(1,1,1)){
			cout << "YES" << endl;	
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
    int n; cin >> n;
    while(n--){
        vector<int> v(10);
        for(int i=0; i< 10; i++) cin >> v[i];
        int a=0, b=0;
        bool is = true;
        for(int i=0; i< 10; i++){
            if(v[i] < a && v[i] < b){is = false; break;}
            if(a < b) (b<v[i]?b:a) = v[i];
            else (a<v[i]?a:b) = v[i];
        }
        cout << (is?"YES":"NO") << endl;
    }
}

C++: #include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF 100000



int main(){
	int b,c;
	int a;
	int n;
	bool ans;
	cin>>n;
	while(n--){
		ans=true;
		b=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;
			}
		}
		if(ans){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n;
  bool dropped[10];

  for(int i=0; i<10; i++)
    dropped[i] = false;

  cin >> n;
  while(n--){
    int b = 0, c = 0;
    int a[10];
    for(int i=0; i<10; i++){
      cin >> a[i];
    }

    for(int i=0; i<10; i++){
      if(b < a[i] && c < a[i]){
        if(b < c)
          c = a[i];
        else
          b = a[i];
      }
      else if(b < a[i]){
        if(a[i] != b + 1){
          cout << "NO" << endl;
          break;
        }
        else
          b = a[i];
      }
      else if(c < a[i]){
        if(a[i] != c + 1){
          cout << "NO" << endl;
          break;
        }
        else
          c = a[i];
      }

      if(i == 9)
        cout << "YES" << endl;
    }
  }
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int n;
const int m = 10;
int *data;
int *lp;
int *rp;

//return...fail:0, success:1
bool dfs(int i, int l, int r)
{
	if (i == m)
		return true;

	if (i<m && l<m && lp[l-1]<data[i]) {
		lp[l] = data[i];
		if (dfs(i+1, l+1, r))
			return true;
	}

	if (i<m && r<m && rp[l-1]<data[i]) {
		rp[r] = data[i];
		if (dfs(i+1, l, r+1))
			return true;
	}

	return false;
}

int main()
{
	int i, j;
	data = (int *)calloc(m, sizeof(int));
	lp = (int *)calloc(m, sizeof(int));
	rp = (int *)calloc(m, sizeof(int));
	memset(lp, 0, sizeof(int));
	memset(rp, 0, sizeof(int));
	
	scanf("%d ", &n);
	for (i=0; i<n; i++) {
		for (j=0; j<m; j++)
			scanf("%d ", &(data[j]));

	lp[0] = data[0];
	if (dfs(1, 1, 0))
		puts("YES");
	else
		puts("NO");

/*
		//check input
		for (j=0; j<m; j++)
			printf("%d ", data[j]);
		puts("");
*/
	}

	free(data);
	free(lp);
	free(rp);
	return 0;
}

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

int main(){
  int n,date;
  int sta[2];
  cin >> n;

  while(n--){
    bool f = true;
    sta[0] = 0;
    sta[1] = 0;
    for(int i = 0;i < 10 ; i++){
      cin >> date;

      if(date > sta[0])sta[0] = date;
      else if(date > sta[1])sta[1] = date;
      else f = false;

    }
    if(f)puts("YES");
    else puts("NO");


  }
  return 0;
}