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>
using namespace std;

int main() {
	int n;
	int d[10];
	int va[10];
	int vb[10];
	int trush;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> d[i];
		}

		int ca = 0, cb = 0;
		va[0] = d[0];
		ca++;
		if (d[1] > va[0]) {
			va[1] = d[1];
			ca++;
		}

		else {
			vb[0] = d[1];
			cb++;
		}

	for (int j = 2; j < 10; j++) {

			if (d[j] > va[ca-1]) {
				va[ca] = d[j];
				ca++;
			}

			else if (d[j] > vb[cb-1]) {
				vb[cb] = d[j];
				cb++;
			}

			else {
				cout << "NO" << endl;
				goto FINLOOP;
			}

		}

	cout << "YES" << endl;
	FINLOOP:
		for (int i = 0; i < 10; i++) {
			va[i] = 0;
		}
		for (int i = 0; i < 10; i++) {
			vb[i] = 0;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n, count;
  int ball_list[10];
  int max_val;

  cin >> n;

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

    for(int j = 0; j < 10; j++){
      count = 0;
      max_val = ball_list[j];
      for(int k = j; k >= 0; k--){
        if(max_val < ball_list[k]){
          max_val = ball_list[k];
          count++;
        }
      }

      if(count >= 2){
        cout << "NO" << endl;
        break;
      }else if(j == 9){
        cout << "YES" << endl;
      }
    }
  }

  return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,a[10],b,c;
	cin >> n;
	rep(kk, n){
		rep(i, 10)
			cin >> a[i];
			b = c = 0;
		rep(i, 10){
			if (a[i] > b && b >= c){ b = a[i];}
			else if (a[i] > c){ c = a[i]; }
			else { cout << "NO" << endl; break; }
			if (i == 9){ cout << "YES" << endl; break; }
		}
	}
}

C++: #include<stdio.h>
#include<stack>
using namespace std;
stack<int>ss;
stack<int>ss2;
int main()
{
	int t,n,a;
	scanf("%d",&t);
	while (t--)
	{
		n=10;
		int f=0;
		while(n--)
		{
			scanf("%d",&a);
			if (ss.empty())
			{
				ss.push(a);
			}
			else if (ss.top()<a)
			{
				ss.push(a);
			}
			else if (ss2.empty())
			{
				ss2.push(a);
			}
			else if (ss2.top()<a)
			{
				ss2.push(a);
			}
			else
			{
				f=1;
				break; 
			}
		}
		if (f==1)
		{
			printf("NO\n");
		}
		else
		{
			printf("YES\n");
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  for(int z=0; z<N; z++){
    vector<int> v(10);
    for(int i=0; i<10; i++) cin >> v[i];
    int m,n;
    if(v[0] < v[1]) m = v[0], n = v[1];
    else m = v[1], n = v[0];
    int i;
    for(i=2; i<10; i++){
      if(v[i] < m) break;
      else if(v[i] < n) m = v[i];
      else n = v[i];
    }
    if(i >= 10) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  int a[10];
  int b[11];
  int c[11];
  int k=0;
  int k2=0;
  int out=0;
  cin>>n;
  b[0]=0;
  c[0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin>>a[j];
      if(b[k]<a[j] ){
	b[k+1]=a[j];
	k++;
      }
      else if(c[k2]<a[j]){
	c[k2+1]=a[j];
	k2++;
      }
      else{
	out=1;
	break;
      }
    }
    if(out==0) cout << "YES" << endl;    
    else if(out==1) cout << "NO" <<endl;
  }
}

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;
        flag = 0;
    }
    return 0;
}

C++: #include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
#include <sstream>
using namespace std;
int ball[10];
bool dfs(int i,int b,int c);
int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int s=0;s<10;s++){
            cin>>ball[s];
        }
        if(dfs(0,0,0))cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}
bool dfs(int i,int b,int c){
    if(i==9)return true;
    if(b<ball[i]){
        if(dfs(i+1,ball[i],c))return true;
    }
    if(c<ball[i]){
        if(dfs(i+1,b,ball[i]))return true;
    }
    return false;
}

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

using namespace std;

int N;
int l[15];
int b,c;
//int res[1000000000000];


void solve(int k){
  for(int i=0;i<10;i++){
    if(b<l[i] && c<l[i]){
      if(l[i]-b < l[i]-c) b=l[i];
      else c=l[i];
    }
    else if(b<l[i] && c>l[i]) b=l[i];
    else if(b>l[i] && c<l[i]) c=l[i];
    else{
  //    res[k]=0;
      printf("NO");
      return;
    }
  }
  printf("YES");
  return;
}


int main(){
  scanf("%d",&N);

  for(int i=0;i<N;i++){
    b=0;
    c=0;
    scanf("%d%d%d%d%d%d%d%d%d%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9]);
    solve(i);
  }

  /*for(int i=0;i<N;i++){
    if(res[i]==0) printf("NO\n");
    else printf("YES\n");
  }
*/

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
  int N,t,B,C,i,j;
  cin >> N;
  for(i = 0 ; i < N ; i++){
    bool is = true;
    for( B = 0, C = 0, j = 0; j < 10; j++){
      cin >> t;
      if(B >= t && C >= t) is = false;
      if(is){
	if(B < t && C < t){
	  if(B < C) C = t;
	  else B = t;
	}
	else if(B < t) B = t;
	else if(C < t) C = t;
      }
    }
    if(is) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;

int main(){
	int n;
	cin>>n;
	rep(k,0,n){
		int d[10]={},a[11]={},b[11]={},at=0,bt=0;
		rep(i,0,10) cin>>d[i];
		bool f=1;
		rep(i,0,10){
			if(a[at]<d[i]){
				a[at+1]=d[i]; at++;
			}else if(b[bt]<d[i]){
				b[bt+1]=d[i]; bt++;
			}else{
				f=0; break;
			}
		}
		cout<<(f?"YES":"NO")<<endl;
	}
}

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


bool saiki(int ball[],int ttB,int ttC,int res){
	if(res==10)return true;
	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 false;
}

int main(void){
	int a,b;
	int ball[11];
	int ttB=0,ttC=0;
	int res=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]);
		}
		if(saiki(ball,ttB,ttC,res)==true)printf("Yes\n");else printf("No\n");
	}
	return 0;
}

C++: #include<stdio.h>
int i,b[11],x;
void dfs(int i,int left,int right)
{
	if(i==10)
	{
		x=1;
		return;
	}
	if(x)
	{
		return;
	} 
	if(b[i]>left)
	{	
		dfs(i+1,b[i],right);
	}
	if(b[i]>right)
	{
		dfs(i+1,left,b[i]);
	}
}
int main()
{
	int a;
	while(scanf("%d",&a)!=EOF)
	{
		while(a--)
		{
			x=0;
			for(i=0;i<10;i++)
			{
				scanf("%d",&b[i]);
			}
			dfs(0,0,0);
			if(x==1)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
	}
	return 0;	
}