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++: // 2012/03/02 Tazoe

#include <iostream>
using namespace std;

bool DFS(int A[10], int i, int B, int C){
	if(i==10)
		return true;

	if(A[i]>B&&DFS(A, i+1, A[i], C))
		return true;

	if(A[i]>C&&DFS(A, i+1, B, A[i]))
		return true;

	return false;
}

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

	for(int i=0; i<N; i++){
		int A[10];
		for(int j=0; j<10; j++){
			cin >> A[j];
		}

		if(DFS(A, 0, 0, 0)){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>

using namespace std;

int x[10];

bool check( int i, int l, int r )
{
  bool retl = false, retr = false;
  
  if ( i == 10 )
    return true;

  if ( x[i] > l )
    retl = check( i+1, x[i], r );
  
  if ( x[i] > r )
    retr =  check( i+1, l, x[i] );

  return ( retl || retr );
}

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

C++: #include <iostream>
using namespace std;
int ch[12],one,two,g,q;

int DFS(int g){
if(g == 10)
    {
        q=0;
        return 1;
    }
else
{
    for(int i = g; i < 10; i++){
        for(int k = 1; k >= 0; k--)
        {
            if(q == 0) return 1;
            if(k && ch[i] > one)
                {
                    one = ch[i];
                    DFS(i+1);
                }
            else if(!k && ch[i] > two)
                {
                    two = ch[i];
                    DFS(i+1);
                }
            else if(ch[i] < two &&ch[i] < one)
                {
                    return 0;
                }
        }
    }
}
return 0;
}
int main()
{
    int n;
    cin >> n;
    while(n--){
     for(int i = 0; i < 10; i++)
        cin >> ch[i];
     one = ch[0];
     two = 0;
     q=1;
     if(DFS(1)) cout << "YES" << endl;
     else cout << "NO" << endl;
    }
    return 0;
}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>
#include <cstring>
#include <cstdlib>

typedef long long ll;

using namespace std;

struct ToLower {    char operator()(char c) { return tolower(c); }};

int main(void){
	int N;
	cin >> N;

	int ball[10];
	int a=0, b=0;
	int check = 0;

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

		for(int j=0; j<10; j++){
			cin >> ball[j];
		}
		for(int j=0; j<10; ++j){
			if(ball[j] > a && ball[j] > b){
				(a > b ? a : b) = ball[j];
				continue;
			} else if(ball[j] < a && ball[j] < b){
				cout << "NO" << endl;
				check = 1;
				break;
			} else {	
				(a < b ? a : b) = ball[j];
			}
		}
		if(check == 0) cout << "YES" << endl;



	}
	return 0;
}

C++: #include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* ?????° {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int l, r, n = in();
  bool f;
  while (n--){
    l = r = 0;
    f = true;
    REP(i, 10){
      int a = in();
      if (a > l) l = a;
      else if (a > r) r = a;
      else f = false;
      if (l < r) swap(l, r);
    }
    (f)?cout << "YES" << endl:cout << "NO" << endl;
  }

  return (0);
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main () {
    int b[10];
    int l=0,r=0;

    int x;
    cin>>x;
    
    while(cin>>b[0]>>b[1]>>b[2]>>b[3]>>b[4]>>b[5]>>b[6]>>b[7]>>b[8]>>b[9]){
        int flag=0;
        for(int i=0; i<10; i++){
            if(l<b[i]&&r<b[i]){
                if(l<r){
                    r=b[i];
                }else{
                    l=b[i];
                }
            }else if(l>b[i]&&r<b[i]){
                r=b[i];
            }else if(l<b[i]&&r>b[i]){
                l=b[i];
            }else{
                flag++;;
                break;
            }
        }
        
        if(flag){
            cout<<"NO"<<endl;
        }else{
            cout<<"YES"<<endl;
        }

    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  while(cin>>n){
    bool ok=true;
    int a,b=0,c=0;
    rep(i,10){
      cin>>a;
      if(a>b)b=a;
      else if(a>c)c=a;
      else ok=false;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}