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;
#define MAX_N 100
#define MIN_N -10000000
int N;
int A[MAX_N][10];
int B = MIN_N, C = MIN_N;
int count;
bool b;

void solve(int i){ 
    if(count >= 10){//结束条件 
        return;
	}
	if(B > A[i][count] && C > A[i][count]){//不满足条件 
		b = false;
		return;
	}
	if(B < A[i][count] && C > A[i][count]){//大于B小于C 
		B = A[i][count];
		count++;
		solve(i);
	}
	if(B > A[i][count] && C < A[i][count]){//大于C小于B 
		C = A[i][count];
		count++;
		solve(i);
	}
	if(B <= A[i][count] && C <= A[i][count]){//比B和C任意中数字还要大 ，放在数字大的那边 
		if(B >= C){
			B = A[i][count];
		}
		else{
			C = A[i][count];
		}
		count++;
		solve(i);
	}
}
int main(){
	while(cin>>N && N != 0){
		for(int i = 0;i < N;i++){
			for(int j = 0;j < 10;j++){
				cin>>A[i][j];
			}
		}
		for(int i = 0;i < N;i++){
			b = true;
			count = 0;
		    solve(i); 
		    if(b){
			    cout<<"YES"<<endl; 
		    }
	    	else{
			    cout<<"NO"<<endl;
		    }
    	}
	}
}

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


int res=0;

int saiki(int ball[],int ttB,int ttC,int res){
	if(res==10)return res;
	if(ball[res]>ttB){
		return saiki(ball,ball[res],ttC,res+1);
	}
	if(ball[res]>ttC){
		return saiki(ball,ttB,ball[res],res+1);
	}
	return res;
}

int main(void){
	int a,b;
	int ball[11];
	int ttB=0,ttC=0;
	int n;
	scanf("%d",&n);
	for(a=0;a<n;a++){
		for(b=0;b<10;b++){
			ball[b]=0;
		}
		ttB=0;
		ttC=0;
		res=0;
		for(b=0;b<10;b++){
			scanf("%d",&ball[b]);
		}
		res=max(res,saiki(ball,ttB,ttC,res));
		if(res==10)printf("YES\n");else printf("NO\n");
	}
	return 0;
}

C++: #include <stdio.h>
int main(void)
{
	int a,b,c[10]={0},d,e[10]={0},f,g,i;
	scanf("%d",&a);
	for (b=0;b<a;b++)
	{
		for (i=0;i<10;i++)
		{
			scanf("%d",&f);
			c[i]=f;
		}
		for (g=1;g<8;g++)
		{
			if (c[g-1]<c[g]||c[g-1]<c[g+1])
			{
				e[g-1]=0;
			}
			else 
			{
				e[g-1]=1;
			}
		}
		if (e[0]==0&&e[1]==0&&e[2]==0&&e[3]==0&&e[4]==0&&e[5]==0&&e[6]==0&&e[7]==0&&e[8]==0&&e[9]==0)
		{
			printf("YES\n");
		}
		else 
		{
			printf("NO\n");
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string.h>

using namespace std;

int a[12];
int n;

bool dfs(int i, int left, int right){
    if(i == 10){
        return true;
    }

    if(a[i] > left && dfs(i + 1, a[i], right)){
        return true;
    }
    if(a[i] > right && dfs(i + 1, left, a[i])){
        return true;
    }
    return false;
}

void solve(){
    for(int i = 0; i < 10; ++i){
        cin>>a[i];
    }

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

int main(){
    cin>>n;
    while(n--){
        solve();
    }
    return 0;
}

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

string solve(int a, int b, int f) {
	if (f == 11) return "YES";
	
	int x;
	cin >> x;
	
	if (x > a) return solve(x, b, f + 1);
	if (x > b) return solve(a, x, f + 1);

	return "NO";
}

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

	for (int i = 0; i++ < n;) {
		cout << solve(0, 0, 0) << endl;
	}
	return 0;
}

C++: #include<stdio.h> 
#include<string.h>
int s[12];
bool p[12];
int flag,flag1,A;
void dfs(int com,int cur)
{
	if(cur==10)
	return;
	if(s[com]<=s[cur] && !p[cur])
		p[com]=true,p[cur]=true,dfs(cur,cur+1);
	else
		{
			if(flag1)
			flag1=0,A=cur;
	    	dfs(com,cur+1);	
		}
}
int main()
{
	int n;
	scanf("%d",&n);
	while(n--)
	{
		flag=1,flag1=1;
		memset(p,false,sizeof(p));
		for(int i=0;i<10;i++)
		scanf("%d",&s[i]);
		dfs(0,1);
		dfs(A,A+1);
		for(int i=0;i<10;i++)
			if(!p[i])
				flag=0;
		if(flag)
		printf("YES");
		else
		printf("NO");
		printf("\n");
	 } 
	return 0;
 }

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

int main(void)
{
	int n;
	cin >> n;
	while(n--)
	{
		const int N =10;
		int a[10];
		int i;
		for(i = 0; i < N; i++)
			cin >> a[i];

		int left = 0, right = 0;
		int *pMin = NULL, *pMax = NULL;
		bool result = true;
		for(i = 0; i < N; i++)
		{
			pMin = &(left < right ? left : right);
			pMax = &(left < right ? right : left);

			if(*pMin > a[i])
			{
				result = false;
				break;
			}
			else if(*pMax < a[i])
				*pMax = a[i];
			else
				*pMin = a[i];
		}
		cout << (result ? "YES" : "NO") << endl;;
	}
	return 0;
}

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

int main(){
  int n;
  int tmp[10];

  cin >> n;
  for(int i = 0 ; i < n ; i++){
    int cnt;
    for(int j = 0 ; j < 10 ; j++){
      cin >> tmp[j];
    }
    
    cnt = 0;

    for(int j = 0 ; j < 9 ; j++){
      if(!(tmp[j] < tmp[j+1])) cnt++;
    }
    
    //cout << cnt << endl;

    if(cnt <= 2) cout << "YES" << endl;
    else cout << "NO" <<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;
int numofbits(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

// BEGIN //////////////////////////////////////////////////////////////
int main() {
  int N = nextInt();
  REP(i, N) {
    stack<int> bs, cs;
    bool flag = true;
    bs.push(0);
    cs.push(0);
    REP(j, 9) {
      int a = nextInt();
      if (bs.top() < a) {
        if (cs.top() < a) {
          if (bs.top() > cs.top()) {
            bs.push(a);
          } else {
            cs.push(a);
          }
        } else {
          bs.push(a);
        }
      } else if (cs.top() < a) {
        cs.push(a);
      } else {
        flag = false;
        break;
      }
    }
    if (flag) {
      PRINT("YES");
    } else {
      PRINT("NO");
    }
  }
	return 0;
}
// END   //////////////////////////////////////////////////////////////

C++: #include <iostream>
#define _for(i,a,b) for(int i = (a); i < b; ++i)
#define _rep(i,a,b) for(int i = (a); i <= b; ++i)
using namespace std;
int a[10+2];
bool flag = 0;
void dfs(int i, int l, int r){
    if(flag) return;
    if(i == 10) {
        flag = 1;
        return;
    }
    if(a[i] > l) dfs(i+1, a[i], r);
    if(a[i] > r) dfs(i+1, l, a[i]);
}
int main(){
    int n;
    cin>>n;
    _for(len,0,n){
        _for(i,0,10) cin>>n;
    }
    dfs(0,0,0);
    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}