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<bits/stdc++.h>
using namespace std;
main(){
  int n,a;
  srand((unsigned)time(NULL));
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin>>a;
    }
    if(rand()%2==0){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}

C++: #include<iostream>
#include<string>
using namespace std;
bool a[15]; 
int d[15];
string b,c;
int judge=0; 
void dfs(int n){
	if(n==10){
		for(int i=0;i<10;i++){
			if(a[i]==false){//进c 
				c.push_back('0'+d[i]);
			}
			else{
				b.push_back('0'+d[i]);
			}
		}
		int ok=1;
		for(int j=0;j<b.size()-1;j++){
			if(b[j]>b[j+1]){
				ok=0;
				break;
			}
		}
		for(int j=0;j<c.size()-1;j++){
			if(c[j]>c[j+1]){
				ok=0;
				break;
			}
		}
		if(ok)judge=1;
		b.clear();c.clear();
		return;
	}
	else{
		a[n]=true;
		dfs(n+1);
		a[n]=false;
		dfs(n+1);
		return;
	}
}
/*void ddfs(int n){
	cout<<n<<endl;
	if(n==10){
		judge=0;
		dfs(0);
		for(int i=0;i<n;i++){
			cout<<d[i]<<' ';
		}
		cout<<endl;
		if(judge){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
		return;
	}
	for(int i=1;i<=10;i++){
		int ok=1;
		for(int j=0;j<n;j++){
			if(d[j]==i){
				ok=0;break;
			}
		}
		if(ok){
			d[n]=i;
			ddfs(n+1);
		}
	}
}*/
int main(){
	int n;
	cin>>n;
	while(n--){
		b.clear();c.clear(); 
		judge=0;
		for(int i=0;i<10;i++){
			cin>>d[i];
		}
		dfs(0);
		if(judge){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int b[10];
int bt, ct, tmp;
bool check(int i){
  if( i==10 )
    return true;

  if( bt<b[i] ){
    tmp=bt; bt=b[i];
    if( check(i+1) )
      return true;
    bt=tmp;
  }
  if( ct<b[i] ){
    tmp=ct; ct=b[i];
    if( check(i+1) )
      return true;
    ct=tmp;
  }
  return false;
}

int main(){
  int n;
  cin >> n;
  for( int lp=0;lp<n;lp++ ){
    for( int i=0;i<10;i++ )
      cin >> b[i];

    bt=-1, ct=-1;
    if( check(0) )
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <stack>

using namespace std;
const int maxn = 11;
int num[maxn];

int main()
{
    int ite;
    scanf("%d", &ite);
    while(ite--)
    {
        for(int i=0; i<10; ++i)
        {
            scanf("%d", &num[i]);
        }

        stack<int> a, b;

        a.push(0);
        b.push(0);
        for(int i=0; i<10; ++i){
            int dif1 = num[i] - a.top(), dif2 = num[i]-b.top();
            if(dif1<0 && dif2<0) {
                printf("NO\n");
                return 0;
            }
            else if(dif1>0 && dif2>0){
                if(dif1>dif2) b.push(num[i]);
                else a.push(num[i]);
            }
            else{
                if(dif1>0) a.push(num[i]);
                else b.push(num[i]);
            }
        }

        printf("YES\n");
    }
    return 0;
}

C++: iint main(){
return 0;
}

C++: #include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
#define L 0
#define R 1
int B[10+5];
vector <int > T[2];
bool flag;
void solve(int i){
	if(flag)return;
	if(i==10){flag=1;return;}
	for(int C=0;C<2;C++){
//	cout<<i<<flag<<endl;
//	cout<<T[C].back()<<endl;
//	cout<<B[i]<<endl;
	if(T[C].back()<B[i]){
		T[C].push_back(B[i]);
		solve(i+1);
		T[C].pop_back();
//		for(int x:T[C]){
//			cout<<x<<' ';
//		}
//		cout<<endl;
	}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	while(n--){
		for(int i=0;i<=9;i++){
			scanf("%d",B+i);
		}
		flag=0;
		T[R].push_back(0);
		T[L].push_back(0);
		solve(0);
		puts(flag?"YES":"NO");
	}
	return 0;
}
//aoj0033.cc
//generated automatically at Thu Sep  8 18:32:18 2016
//by xsthunder

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

int main(){
  bool ans;
  int n;
  int a[10],b,c;
  cin>>n;
  for(int i=0;i<n;i++){
    ans=true;
    for(int j=0;j<10;j++)cin>>a[j];
    b=c=0;

    for(int j=0;j<10;j++){
      if(a[j]<b&&a[j]<c){ans=false;break;
      }else if(b<a[j]&&c<a[j]){
	if(b>c)b=a[j];
	else c=a[j];
      }
      else if(b<a[j]&&c>a[j])b=a[j];
      else if(b>a[j]&&c<a[j])c=a[j];
    if(b>c)b=a[j];
    else c=a[j];
    }	
    
    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;  
  }
  
}

C++: #include<iostream>
using namespace std;
int a[10],bo;
void dfs(int x,int l,int r)
{
    if(x==10)
        return ;
    if(bo)
        return ;
    if(a[x]>l)
        dfs(x+1,a[x],r);
    else if(a[x]>r)
        dfs(x+1,l,a[x]);
    else
    {
        bo=1;
        return ;
    }
}
    int main()
    {

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

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
typedef long long ll;

int n;
int a[10];
int b=-1, c=-1;
string solve(){
	REP(i, 10)
	{
		cin >> a[i];
	}
	REP(i,8)
	{
		if (a[i]>a[i+1]&&a[i]>a[i+2]&&a[i+1]>a[i+2])
		{
			return "NO";
		}
	}
	return "YES";
}

int main()
{
	cin >> n;
	REP(i, n){
		cout << solve() << endl;
		
	}
	

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
	int n, a;
	vector<int> A;
	vector<vector<int>> AA;
	cin >> n;
	bool check[100] = { 1 };
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> a;
			A.push_back(a);
		}
		AA.push_back(A); A.clear();
	}
	for (int i = 0; i < AA.size(); i++) {
		int b = 0, c = 0;
		for (int j = 0; j < AA[i].size(); j++) {
			if (b >= c) {
				if (AA[i][j] > b)b = AA[i][j];
				else {
					if (AA[i][j] > c)c = AA[i][j];
					else {
						check[i] = 0; break;
					}
				}
			}
			else {
				if (AA[i][j] > c)c = AA[i][j];
				else {
					if (AA[i][j] > b)b = AA[i][j];
					else {
						check[i] = 0; break;
					}
				}
			}
		}
	}
	for (int i = 0; i < AA.size(); i++) {
		if (check[i])cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

C++: #include <iostream>

#define reep(i,n,m) for(int i=(n);i<(m);i++)
#define rep(i,n) reep(i,0,n)

using namespace std;

int a[10];
int r[10];
int r_i;
int l[10];
int l_i;

bool is_greater(int array[],int n){
	reep(i,1,n){
		if(array[i]<array[i-1]){
			return false;
		}
	}
	return true;
}

bool dfs(int n){
	if(n==10){
		if(is_greater(r,r_i)&&is_greater(l,l_i)){
			return true;
		}else{
			return false;
		}
	}

	r[r_i++] = a[n];
	if(dfs(n+1)){
		return true;
	}
	r_i--;

	l[l_i++] = a[n];
	if(dfs(n+1)){
		return true;
	}
	l_i--;
	return false;
}

int main(){
	int N;
	cin >> N;
	while(N--){
		rep(i,10){
			cin >> a[i];
		}
		r_i = l_i = 0;
		if(dfs(0)){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}