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

C++: #include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<queue>
#include<algorithm>

using namespace std;

int t;
int s[15];
int a[15],b[15];
int la,lb;
bool ok;

void DFS(int index){
	if(ok){
		return;
	}
	if(index==10){
		ok=true;
		return;
	}
//	cout<<"a:"<<endl;
//		for(int i=0;i<la;i++){
//			cout<<a[i]<<' ';
//		}
//		cout<<endl;
//	cout<<"b:"<<endl;
//		for(int i=0;i<lb;i++){
//			cout<<b[i]<<' ';
//		}
//		cout<<endl;
	if(la==0||s[index]>a[la-1]){
		a[la++]=s[index];
		DFS(index+1);
		la--;
	}
	if(lb==0||s[index]>b[lb-1]){
		b[lb++]=s[index];
		DFS(index+1);
		lb--;
	}
}

int main(){
	cin>>t;
	while(t--){
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		la=lb=0;
		ok=false;
		for(int i=0;i<10;i++){
			cin>>s[i];
		}
		DFS(0);
		if(ok){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
//		for(int i=0;i<la;i++){
//			cout<<a[i]<<' ';
//		}
//		cout<<endl;
//		for(int i=0;i<lb;i++){
//			cout<<b[i]<<' ';
//		}
//		cout<<endl;
	}
	return 0;
}

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

int main(){
int a[10];
int n,b=0,c=0;
cin>>n;
for(int i=0;i<n;i++){
for(int j=0;j<10;j++){
cin>>a[j];
if(a[j]>b){b=a[j];}
if(a[j]<b&&a[j]>c){c=a[j];}
if(a[j]<b&&a[j]<c){
cout<<"NO"<<endl;
break;}
if(j==9){
cout<<"YES"<<endl;
break;}
}
}}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int a[15],r[15],l[15],lcnt,rcnt,cnt;
bool flag;
bool solve(){
	for(int i=0;i<1024;++i){
		memset(l,0,sizeof(l));
		memset(r,0,sizeof(r));
		lcnt=rcnt=0;
		for(int cnt=0,j=i;cnt<10;cnt++,j>>=1){
			if(j&1)l[lcnt++]=a[cnt];
			else r[rcnt++]=a[cnt];
		}
		flag=true;
		for(int j=1;j<lcnt;j++){
			if(l[j]<l[j-1]){
				flag=false;
				break;
			}
		}
		if(flag){
			for(int j=1;j<rcnt;j++){
				if(r[j]<r[j-1]){
					flag=false;
					break;
				}
			}
		}
		if(flag)return true;//只要能找出就返回true 
	}
	return false;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		for(int i=0;i<10;i++)cin>>a[i];
		puts(solve()?"YES":"NO");
	}
	return 0;
}