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++: //aoj 0033 Ball
//10个球下落，分2个管道走，要求2个管道里面自底向上数字要??
#include<cstdio>
using namespace std;

int boll[15];
int dig[2];

//bool dfs(int d)//dfs的参数越少越好，不用考?管道分支
//{
//    if(d==10) return true;//放完了
//    int tmp;
//    for(int i=0; i<2; ++i)
//    {
//        if(boll[d]>dig[i])
//        {
//            tmp = dig[i];
//            dig[i] = boll[d];
//            if(dfs(d+1)) return true;
//            dig[i] = tmp;
//        }
//    }
//    return false;
//}

bool dfs(int bi, int di)//?里是考?了管道分支的
{
    if(bi==10) return true;//放完了
    int tmp = dig[di];
    if(boll[bi]>dig[di]) dig[di] = boll[bi];
    else return false;
    for(int i=0; i<2; ++i)
    {
        if(dfs(bi+1,i)) return true;
    }
    dig[di] = tmp;
    return false;
}

void solve()
{
    dig[0] = dig[1] = -1;
    //少参数版
    //bool ans = dfs(0);
    
    //多参数版
    bool ans = false;
    for(int i=0; i<2; ++i) ans |= dfs(0,i);
    
    printf("%s\n", ans?"YES":"NO");
}

int main()
{
    int n;
    scanf("%d\n", &n);
    while(n--)
    {
        for(int i=0; i<10; ++i) scanf("%d", &boll[i]);
        solve();
    }
    return 0;
}

C++: // 0033.cpp : コン

#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;
	}
	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<cstdio>
#include<stack>
using namespace std;
int x[15],l[15],r[15];

bool dfs(int i,int j,int k){
    if(i>=10)return true;

    if(x[i]>l[j-1]){
        l[j]=x[i];
        return dfs(i+1,j+1,k);
    }
    if(x[i]>r[k-1]){
        r[k]=x[i];
        return dfs(i+1,j,k+1);
    }
    return false;
}


int main(){
int t;
scanf("%d",&t);
while(t--){
    for(int i=1;i<=10;i++)scanf("%d",&x[i]);
    if(dfs(1,0,0))printf("YES\n");
    else printf("NO\n");
}
    return 0;
}

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

int main() {
	int n, x, a, b;
	cin >> n;

	for (int i = 0; i++ < n;) {
		int hole[2] = { 0 };
		for (int j = 0; j < 10; j++) {
			cin >> x;

			a = x - hole[0];
			b = x - hole[1];
			if (a < 0 && b < 0) {
				cout << "NO";
				break;
			}

			if (a < 0) {
				hole[1] = x;
			}
			else if (b < 0) {
				hole[0] = x;
			}else if (a < b) {
				hole[0] = x;
			}else {
				hole[1] = x;
			}

			if (j == 9) {
				cout << "YES";
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  while (N-- > 0) {
    vector<int> balls(10);
    for (int i = 0; i < 10; i++) {
      cin >> balls[i];
    }

    for (int i = 0; i < 1024; i++) {
      int b = 0, c = 0;
      int j;
      for (j = 0; j < 10; j++) {
        if (i & (1<<j)) {
          if (b < balls[j]) {
            b = balls[j];
          } else {
            break;
          }
        } else {
          if (c < balls[j]) {
            c = balls[j];
          } else {
            break;
          }
        }
      }
      if (j == 10) {
        cout << "YES" << endl;
        goto NEXT;
      }
    }
    cout << "NO" << endl;
NEXT:
    ;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  while(N--){
    int B=0,C=0,i=0,b[10];
    bool f=true;
    cin>>b[0]>>b[1]>>b[2]>>b[3]>>b[4]>>b[5]>>b[6]>>b[7]>>b[8]>>b[9];
    while(i<10){
      cout << b[i] << endl;
      if(B<b[i]){
	if(B<C&&C<b[i])C=b[i];
	else B=b[i];
      }else if(C<b[i]){
	C=b[i];
      }else{
	f=false;
      }
      i++;
    }
    cout<<(f?"YES":"NO")<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
static const int MAX_N = 10;
int a[MAX_N] = {0};

bool dfs(int a[],vector<int> r,vector<int> l,i){
	if(i==MAX_N)return true;
	if(r.size()==0 || r[r.size()-1]<a[i]){
		r.push_back(a[i]);
		return solve(a,r,l,i+1);
	}
	if(l.size()==0 || l[l.size()-1]<a[i]){
		l.push_back(a[i]);
		return solve(a,r,l,i+1);
	}
	return false;
}


int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){//input
			cin>>a[j];
		}
		vector<int> r;
		vector<int> l;
		if dfs(a,r,l,0){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
}

C++: #include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int A[13] = { 0 };

bool solve(int a, int b,int c) {
	if (++c == 10)
		return true;
	else {
		bool r = false;
		if (a < A[c])
			r = solve(A[c], b, c);
		if (b < A[c] && r == false)
			r = solve(a,A[c], c);
		
		return r;
	}
}

int main(void) {
	A[10] = A[11] = A[12] = 100;
	int n = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++)
			scanf("%d", &A[j]);
		if (solve(A[0], 0, 0))
			printf("YES\n");
		else
			printf("NO\n");
	}
}

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

int main()
{
     int count;
     cin >> count;
     while(count--) {
          int num[10];
          for (int i = 0; i < 10; i++) cin >> num[i];
          int max = num[0];
          num[0] = 0;
          for (int i = 1; i < 10; i++) {
               if (num[i] > max) {
                    max = num[i];
                    num[i] = 0;
               }
          }
          max = 0;
          int flag = 1;
          for (int i = 0; i < 10; i++) {
               if (max <= num[i]) max = num[i];
               else if (num[i] != 0) {
                    cout << "NO" << endl;
                    flag = 0;
                    break;
               }
          }
          if (flag) cout << "YES" << endl;
     }

     return 0;
}

C++: #include <iostream>

using namespace std;

int main(void) {
    int N, a, b, c, x[10];
    cin >> N;
    for (; N--; ) {
        bool ok = true;
        for (int i = 0; i < 10; i++) {
            cin >> x[i];
        }
        b = c = 0;
        for (int i = 0; i < 10; i++) {
            a = x[i];
            if (a < b && a < c) {
                ok = false;
                break;
            } else if (a < b) {
                c = a;
            } else if (a < c) {
                b = a;
            } else if (b < c) {
                c = a;
            } else {
                b = a;
            }
        }
        if (ok) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}