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 <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

using namespace std;

int main(){
	int n;

	cin >> n;

	while(n--){
		int tmp = 0;
		vector<int> b, c;
		bool limitB = false, limitC = false;

		for(int i = 0; i < 10; i++){
			limitB = false;
			limitC = false;
			cin >> tmp;

			if(b.size() == 0){
				b.push_back(tmp);
				continue;
			}
			else if(b.size() != 0 && c.size() == 0){
				if(b[b.size() - 1] < tmp){
					b.push_back(tmp);
					continue;
				}
				else{
					limitB = true;
				}
			}
			
			if(c.size() == 0){
				c.push_back(tmp);
				continue;
			}
			
			if(b[b.size() - 1] < tmp){
				b.push_back(tmp);
				continue;
			}
			else{
				limitB = true;
			}
		
			if(c[c.size() - 1] < tmp){
				c.push_back(tmp);
				continue;
			}
			else{
				limitC = true;
			}

			if(limitB && limitC){
				cout << "NO" << endl;
				break;
			}

		}
		if(!limitB || !limitC){
			cout << "YES" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int a[10];

bool dfs(int i, int left, int right){
	cout << left << " " << right << " " << i << endl;
	if(i == 10) return true;
	bool answer = false;
	if(left < a[i]){
		answer = dfs(i+1, a[i], right);
	}
	if(right < a[i]){
		answer = dfs(i+1, left, a[i]);
	}

	return answer;
}


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

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

int n;
int a[10];
int r, l;

bool dfs(int i) {
    if (i == 9) return a[i] > r || a[i] > l;
    if (a[i] > r) {
        r = a[i];
    }
    if (a[i] > l) {
        l = a[i];
    }
    if (dfs(i+1)) return true;
    return false;
}

void solve() {
    if (dfs(0)) cout << "YES" << endl;
    else cout << "NO" << endl;
    r = 0; l = 0;
}

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

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

int main(){
  int N,t,B,C;
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    B = C = 0;
    for(int j = 0; j < 10; j++){
      cin >> t;
      if(B >= t && C >= t){
	cout << "NO" << endl;
	break;
      }
      else if(B < t && C < t){
	if(B < C) C = t;
	else B = t;
      }
      else if(B < t) B = t;
      else if(C < t) C = t;
      //      cout << B << " ";
      if(j == 9) cout << "YES" << endl;
    }
  }
  return 0;
}

C++: #include <cstdio>

using namespace std;

bool is_satisfiable(const int balls[], int left_top, int right_top) {
  if (*balls == 0) { return true; }
  return (*balls > left_top &&
          is_satisfiable(balls + 1, *balls, right_top)) ||
         (*balls > right_top &&
          is_satisfiable(balls + 1, left_top, *balls));
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int balls[11];
    for (int j = 0; j < 10; ++j) { scanf("%d", balls + j); }
    balls[10] = 0;
    puts(is_satisfiable(balls, 0, 0) ? "YES" : "NO");
  }

  return 0;
}

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

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

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  REP(v,n)
  {
    vector<int> a, b;
    int m = 0;
    REP(i,10)
    {
      int t; cin >> t;
      if(t > m)
      {
        m = t;
        a.push_back(t);
      }
      else b.push_back(t);
    }
    int i = 0;
    while(i<b.size()-1)
    {
      if(b[i] > b[++i])
      {
        cout << "NO" << "\n";
        break;
      }
    }
    if(i==b.size()-1) cout << "YES" << "\n";
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  int n, s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a = 0, b = 0;
    bool key = 1;
    for (int j = 0; j < 10; j++) {
      cin >> s;
      if (s > a)
        a = s;
      else if (s > b)
        b = s;
      else
        key = 0;
    }
    cout << (key ? "YES" : "NO") << endl;
  }
  return 0;
}

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

int main()
{
    int ball[10],index=0;
    for(int i=0;i<10;++i) {
        scanf("%d",&ball[i]);
    }
    while(index+2 <= 9) {
        if(ball[index] < ball[index+1]) {
            ++index;
            continue;
        } else if (ball[index] < ball[index+2]) {
            ++index;
            continue;
        } else {
            puts("NO");
            return -1;
        }
    }
    puts("YES");
    return 0;
}

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

int n,count=0;
int input[10];
bool res;

bool dfs(int x,int ltop,int rtop){
    cout<<x<<","<<ltop<<","<<rtop<<endl;
    if(x==10) return true;
    if(ltop<input[x]){
        if(dfs(x+1,input[x],rtop)) return true;}
    if(rtop<input[x]){
        if(dfs(x+1,ltop,input[x])) return true;}

    return false;
}

int main(){ 
    cin>>n; 
    while(count<n){
        res=false;
        for(int i=0;i<10;i++){
            cin>>input[i];
        }       
        if(dfs(0,0,0)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        count++;
    }
    return 0;
}