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 main(void)
{
    int bo[11],n,B[11],C[11],b1=0,c1=0,A=0,k=0,l=1;
    cin>>n;
    for(int i=0;i<n;i++){
            C[0]=11;k=0;l=0;B[0]=0;b1=0;c1=0;C[1]=13;
        for(int j=0;j<10;j++){
            cin>>bo[j];
        }
        for(int j=1;;j++){
                cout<<bo[j]<<" ";
            if(j==1)B[0]=bo[0];
        if(C[0]==11&&j==2){
            C[0]=bo[j];
            k++;
            cout<<"6\n";
        }else if(C[1]==13&&j>3&&C[0]<bo[j]){
            C[1]=bo[j];
            k++;
            c1=1;
            cout<<"7\n";
        }else if(B[l]<bo[j]){
            b1=1;
            B[l+1]=bo[l];
            l++;
            cout<<"1\n";
        }else if(C[0]==11){
            C[0]=bo[j];
            k++;
            cout<<"2\n";
        }else if(C[k-1]<bo[j]){
            c1=1;
            C[k+1]=bo[j];
            cout<<"3\n";
        }else if(B[l]<bo[j+1]){
            C[k+1]=bo[j];
            k++;
            cout<<"5\n";
        }else{
            B[l+1]=bo[j];
            l++;
            cout<<"4\n";
        }
        if(j==9||(b1==1&&c1==1))break;
    }
    if(b1==1&&c1==1)cout<<"YES\n";
    else cout<<"NO\n";
    for(int j=0;j<10;j++){
        B[j]=0;C[j]=0;
    }

}
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;

    for( int iii=0; iii<n; ++iii ) {
        stack<int> p[2];
        bool succ = true;

        for( int i=0; i<10; ++i ) {
            int ball;
            cin >> ball;

            if ( p[0].size() == 0 ) {
                p[0].push( ball );

            } else {
                int diff = 999;
                int t;
                for( int j=0; j<2; ++j ) {
                    int r = 0;
                    if ( !p[j].size() == 0 )
                        r = ball - p[j].top();
                    if ( r < 0 )
                        continue;

                    if ( r < diff ) {
                        t = j;
                        diff = r;
                    }
                }

                if ( diff == 999 ) {
                    succ = false;
                } else {
                    p[t].push( ball );
                }

            }
        }

        cout << ( succ ? "YES" : "NO" ) << endl;
    }
}

C++: // 
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int a[10], n;
bool bit(int n,vector<int>left,vector<int>right) {
	if (n == 10) {
		bool left_f = true;
		bool left_r = true;
		roop(i, left.size() - 1) { if (left[i + 1] <= left[i]) { return false; } }
		roop(i, right.size() - 1) { if (right[i + 1] <= right[i]) { return false; } }
		return true;
	}
	if (left[left.size() - 1] > a[n] && right[right.size() - 1] > a[n]) { return false; }
	vector<int>new_l = left;
	vector<int>new_r = right;
	
	new_l.push_back(a[n]);
	new_r.push_back(a[n]);
	return (bit(n + 1, new_l, right) || bit(n + 1, left, new_r));
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	vector<int>emptynow;
	roop(i, n) {
		roop(j, 10) {
			cin >> a[j];
		}
		if (bit(0, emptynow, emptynow)) { cout << "YES" << endl;}
		else { cout << "NO" << endl; }
	}
	return 0;
}

C++: 
#include <iostream>
#include <vector>
#include <string>

typedef long long ll;

using namespace std;

vector<int> balls(10);

bool flag;

void dfs(int i, int left, int right) {
    if (i == 10) {
        flag = true;
        return;
    }
    int num = balls[i];
    if (left < num) {
        dfs(i+1, num, right);
    }
    if (right < num) {
        dfs(i+1, left, num);
    }
}

void solve() {
    flag = false;
    for (int i = 0; i < 10; i++) {
        cin >> balls[i];
    }
    dfs(0, 0, 0);
    string ans = flag ? "YES": "NO";
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N = 0;
    cin >> N;

    for (int i = 0; i < N; i++) {
        solve();
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

	int a, b=0, i, N, x[10], end=0;

	cin >> N;
	for(; N!=0; N--) {
		for(i=0; i<10; i++)
			cin >> x[i];
		for(i=0; i<10; i++) {
			if(i==0) {
				a=x[i];
				i++;
			}
			if(a>x[i]&&b>x[i]) {
				end++;
				break;
			}
			if(a<x[i])
				a=x[i];
			else if(b<x[i])
				b=x[i];
		}

		if (end!=0)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
		end=0;
	}

	return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;

int main(void){
  int n,N;
  vector<int> v(10);
  cin >> N;
  REP(n,N){
    int i;
    bool flg = true;
    REP(i,v.size()) cin >> v[i];
    int max = 0,min = 0;
    REP(i,v.size()){
      if(max<v[i]) max = v[i];
      else if(min<v[i]) min = v[i];
      else{
        flg = false;
        break;
      }
    }
    if(flg) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

int balls[10];
bool drop(int pos, int left, int right) {
    if (pos == 10) return true;
    return balls[pos] > left && drop(pos+1, balls[pos], right) || balls[pos] > right && drop(pos+1, left, balls[pos]);
}

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

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int a[9]={};
		int b[9]={};
		int dat[9],o=0,s=0,f;
		for(int k=0;k<10;k++){
			cin>>f;
			dat[k]=f;
		}
		for(int j=0;j<=10;j++){
			if(j==10){
				cout<<"YES"<<endl;
				break;
						}					if(s==0 || dat[j]>a[s-1]){
				a[s]=dat[j];
				s++;
			}
			else if(o==0 || dat[j]>b[o-1]){
				b[o]=dat[j];
				o++;}
			else{
				cout<<"NO"<<endl;
			break;
			}
					}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int a[10];
int l[10],r[10],bl[10],br[10];
int main()
{
	int T;cin >> T;
	while(T--)
	{
		for(int i = 0;i < 10;++i)
			cin >> a[i];
		int flag = 0;
		for(int op = 0;op < 1 << 10;++op)
		{
			int lcnt = 0,rcnt = 0;
			for(int i = 0;i < 10;++i)
			{
				if(op >> i & 1)
					l[lcnt++] = a[i];
				else
					r[rcnt++] = a[i];
			}
			bool ok = 1;
			for(int i = 1;i < lcnt && ok;++i)
			{
				if(l[i] < l[i-1])
					ok = 0;
			}
			for(int i = 1;i < rcnt && ok;++i)
				if(r[i] < r[i-1])
					ok = 0;
			if(ok)
			{
				flag = 1;
				cout << "YES\n";
				break;
			}
		}
		if(!flag)
			cout << "NO\n";
	}
	return 0;
}