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>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
int d[11];
bool ans=false;
bool rec(int i,int a,int b){
  //cout<<"ball["<<i<<"]"<<d[i]<<" a:"<<a<<" b:"<<b<<endl;
  if(10==i)ans=true;
  if(a<d[i]){
    a=d[i];
    rec(i+1,a,b);
  }
  else if(b<d[i]){
    b=d[i];
    rec(i+1,a,b);
  }
  else return false;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    ans=false;
    for(int j=0;j<10;j++){
      cin>>d[j];
    }
    //    cout<<(rec(0,0,0)?"YES":"No")<<endl;
    rec(0,0,0);

    cout<<(ans?"YES":"NO")<<endl;
  }
  return 0;
}

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

int main()
{
    int balls[10];
    int out[2][10];
    int outCount[2]={0};
    int num;
    cin>>num;
    while(num!=0){
        bool flag=false;
        int a[10]={0};
        for(int i=0;i<10;i++){
            cin>>balls[i];
        }
        for(a[0]=0;a[0]<2;a[0]++){
            for(a[1]=0;a[1]<2;a[1]++){
                for(a[2]=0;a[2]<2;a[2]++){
                    for(a[3]=0;a[3]<2;a[3]++){
                        for(a[4]=0;a[4]<2;a[4]++){
                            for(a[5]=0;a[5]<2;a[5]++){
                                for(a[6]=0;a[6]<2;a[6]++){
                                    for(a[7]=0;a[7]<2;a[7]++){
                                        for(a[8]=0;a[8]<2;a[8]++){
                                            for(a[9]=0;a[9]<2;a[9]++){
                                                for(int i=0;i<10;i++){
                                                    out[a[i]][outCount[a[i]]]=balls[i];
                                                    if(out[a[i]][outCount[a[i]]-1]>balls[i]&&outCount[a[i]]!=0){
                                                        break;
                                                    }
                                                    if(i==9){
                                                        count++;
                                                        flag=true;
                                                    }
                                                    outCount[a[i]]++;
                                                }
                                                for(int i=0;i<10;i++){
                                                    out[0][i]=0;
                                                    out[1][i]=0;
                                                }
                                                outCount[0]=0;
                                                outCount[1]=0;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if(flag){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
        num--;
    }
    return 0;
}

C++: 
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>
#include <climits>
#include <set>
#include <numeric>

using namespace std;

double sq(double x){return x*x;}

int main(){
	int t;
	cin>>t;
	while(t--){
		int a[10];
		bool t[10];
		for (int i = 0; i < 10; i++)
		{
			cin>>a[i];
		}
		memset(t,0,10);
		int b;
		for (int i = 0; i < 2; i++)
		{
			b = 0;
			for (int j = 0; j < 10; j++)
			{
				if(t[j])continue;
				if(b < a[j]){
					b = a[j];
					t[j] = true;
				}
			}
		}
		int s = accumulate(t,t+10,0);
		if(s == 10)
			puts("YES");
		else 
			puts("NO");
	}

	return 0;
}

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

vector<int> l, r, balls;
int lp, rp;

bool search(int n){
	bool isl = false, isr = false;
	if( n==10 ) return true;
	if( balls[n] > l[lp] ){
		l[++lp] = balls[n];
		isl = search(n+1);
		lp--;
	}
	if( balls[n] > r[rp] && !isl ){
		r[++rp] = balls[n];
		isr = search(n+1);
		rp--;
	}
	return isl || isr;
}

int main(){
	int n;
	cin >> n;
	l.resize(10); r.resize(10);
	balls.resize(10);
	for( int i=0; i<n; i++ ){
		lp = rp = 0;
		for( int j=0; j<10; j++ ){
			int b;
			cin >> b;
			balls[j] = b;
		}
		cout << (search(0)?"YES":"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;
	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  if (all.size() == (i+1)*(j+1)) {

						}
						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<memory.h>
using namespace std;
int arr[10],used[10];
void DFS(int pre,int cur)
{
   if(cur<10&&arr[pre]<arr[cur])
   {
       used[cur]=1;
       DFS(cur,cur+1);
   }
   else if(cur<10&&arr[pre]>=arr[cur])
       DFS(pre,cur+1);
}
int main()
{
   int T,pre;
   bool judge;
   cin>>T;
   while(T--)
   {
     for(int i=0;i<10;i++)
         cin>>arr[i];
     for(int i=0;i<10;i++)
     {
         memset(used,0,sizeof(used));
         used[i]=1;
         DFS(i,i+1);
         judge=false;
         pre=0;
         for(int j=0;j<10;j++)
            if(used[j]==0)
                if(pre>=arr[j])
            {
                judge=true;
                break;
            }else pre=arr[j];
         if(!judge)
         {
             cout<<"YES"<<endl;
             break;
         }
     }
     if(judge)cout<<"NO"<<endl;
   }

}

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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int a[10];
bool ans;

void dfs(int idx, int l, int r) {
   if (idx == 10) {
      ans = true;
      return;
   }

   int val = a[idx];
   if (l < val) dfs(idx+1, val, r);
   if (r < val) dfs(idx+1, l, val);
}

int main() {
   int N;
   cin >> N;
   while (N--) {
      for (int i = 0; i < 10; i++) cin >> a[i];
      ans = false;
      dfs(0, -1, -1);
      puts(ans ? "YES" : "NO");
   }

   return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
signed main(void){
	ios::sync_with_stdio(false);
	int T,in[10],a,b,flag;
	cin>>T;
	while(T--){
		a=b=flag=0;
		for(int i=0;i<10;i++)
			cin>>in[i];
		for(int i=0;i<10;i++){
			int x=in[i];
			if(x>a&&x>b){
				if(a>b)	a=x;
				else	b=x;
			}
			else if(x<a&&x<b){
				flag=1;
				break;	
			}
			else if(x>a)
				a=x;
			else if(x>b)
				b=x;
		}
		if(flag)	cout<<"NO"<<endl;
		else 		cout<<"YES"<<endl;
	}
}