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++: bool tansaku(vector<int> list,int index,int b,int c)
{
	if (index<10)
	{
		if (b < list[index])
		{
			if (tansaku(list, index + 1, list[index], c))
				return true;
		}
		if (c < list[index])
		{
			if (tansaku(list, index + 1, b, list[index]))
				return true;
		}
	}
	else
	{
		return true;
	}
	return false;
}
int main()
{
	vector<int> s(10);
	int b;

	cin >> b;
	for (int i = 0; i < b; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			cin >> s[j];
		}
		if (tansaku(s, 0, 0, 0))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <stack>
#include <sstream>
using namespace std;
int main(){
  int nlist[10],n,a;
  stack<int> b,c;
  bool f;
  cin>>n;
  for(;n;n--){
    f=true,b.push(0),c.push(0);
    for(int i=0;i<10;i++)
      cin>>nlist[i];
    for(int j=0;j<10;j++){
      a=nlist[j];
      if(!b.top())b.push(a);
      else{
	if(b.top()>a){
	  if(c.top()>a){f=false;break;}
	  else{c.push(a);}
	}
	else{b.push(a);}
      }
    }
    (f)?cout<<"YES"<<endl:cout<<"NO"<<endl;
    while(1){
      if(!b.empty())b.pop();
      if(!c.empty())c.pop();
      if(b.empty()&&c.empty())break;
    }
  }
  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]; cout << "B:" << b; }
			else if (a[i] > c){ c = a[i]; cout << "A:" << c; }
			else { cout << "NO" << endl; break; }
			if (i == 9){ cout << "YES" << endl; break; }
		}
	}
}

C++: #include <iostream>

using namespace std;
const int kBalln = 10;
int main(){
  int n;
  int ball;
  int b, c;
  bool ans;
  cin >> n;
  for (int j = 0; j < n; ++j)
    {
      b = 0; c = 0;ans = true;
      for (int i = 0; i < kBalln; ++i)
        {
          cin >> ball;
          if (b < ball)
            {
              b = ball;
            }
          else if (c < ball)
            {
              c = ball;
            }
          else
            {
              ans = false;
              // cout << "NO" << endl;
              // break;
            }
        }
      cout << (ans ? "YES" : "NO") << endl;
    }
  return 0;
}

C++: #include <stdio.h>  
  
#define N 10  
  
int main(void)  
{  
    int n, ans, i;  
  
    scanf("%d", &n);  
    while(n--) {  
        ans = 1;  
        int a, b=-1, c=-1;  
        for(i=1; i<=N; i++) {  
            scanf("%d", &a);  
            if(ans) {  
                if(a > b)  
                    b = a;  
                else if(a > c)  
                    c = a;  
                else  
                    ans = 0;  
            }  
        }  
  
        printf("%s\n", ans ? "YES" : "NO");  
    }  
  
    return 0;  
}

C++: /*
100
1 2 4 6 7 8 9 10
3 5
NO
*/
#include<cstdio>
int n,j,lj,F;
int a[15],f[15];
int main()
{
	scanf("%d",&n);
	while(n--)
	{
		j=0;F=0;lj=0;
		for(int i=1;i<=20;i++)
		f[i]=0,a[i]=0; 
		for(int i=1;i<=10;i++)
		scanf("%d",&a[i]);
		lj=1;
		for(int i=1;i<=9;i++)
		if(a[i+1]>a[lj]) f[lj]=1,lj=i+1;
		if(a[10]>f[lj]) f[lj]=1;
	//	for(int i=1;i<=10;i++)
	//	printf("%d ",f[i]);
		lj=0;
		a[0]=0;
		for(int i=1;i<=10;i++)
		if(!f[i])
		{
			if(a[i]>a[lj]) lj=i;
			else {printf("NO\n");F=1;break;}
		}
		if(!F) 
		printf("YES\n");
	}
}
/*
#include <iostream>  
  
using namespace std;  
  
const int N = 10;  
  
int main()  
{  
    int n;  
  
    cin >> n;  
    while(n--) {  
        bool ans = true;  
        int a, b=-1, c=-1;  
        for(int i=1; i<=N; i++) {  
            cin >> a;  
            if(ans) {  
                if(a > b)  
                    b = a;  
                else if(a > c)  
                    c = a;  
                else  
                    ans = false;  
            }  
        }  
  
        cout << (ans ? "YES" : "NO") << endl;  
    }  
  
    return 0;  
}  
*/

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

using namespace std;

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

C++: //Ball

#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;

int main(void){
    int n;
    
    cin >> n;
    
    for(int i = 0; i < n; i++){
        
        int j;
        stack<int> Q1;
        stack<int> Q2;
        Q1.push(0);
        Q2.push(0);
        
        for( j = 0; j < 10; j++){
            int x;
            cin >> x;
            
            if(Q1.top() < x)        Q1.push(x);
            else if(Q2.top() < x)   Q2.push(x);
            else {
                printf("NO\n");
                break;
            }
        }
        if(j == 10) printf("YES\n");    
    }
    
    return 0;
}

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

bool ball(int left, int right, int i, vector<int> &stack) {
    if (i == 10)
        return true;

    if (stack[i] > left)
        return ball(stack[i], right, i + 1, stack);

    if (stack[i] > right)
        return ball(left, stack[i], i + 1, stack);

    return false;
}

int main()
{
    int n;
    cin >> n;
    vector<int> stack(10);

    while (n--) {
        for (int i = 0; i < 10; i++)
            cin >> stack[i];
        cout << (ball(0, 0, 0, stack) ? "YES" : "NO") << endl;
    }

    return 0;
}

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

int num[10];
int left_num[10], right_num[10];
int l, r;

bool dfs(int i) {
	if (i == 10) {
		return true;
	}
	if (i == 0) {
		left_num[l] = num[i];
		return dfs(i + 1);
	}
	if (left_num[l] < num[i]) {
		l++;
		left_num[l] = num[i];
		return dfs(i + 1);
	}
	if (right_num[r] < num[i]) {
		if (r == 0) {
			right_num[r] = num[i];
			return dfs(i + 1);
		} else {
			r++;
			right_num[r] = num[i];
			return dfs(i + 1);
		}
	}
	return false;
}

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

	while (N--) {
		l = 0, r = 0;
		for (i = 0; i < 10; i++) {
			cin >> num[i];
			left_num[i] = 0;
			right_num[i] = 0;
		}
		if (dfs(0)) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int balls[10];

bool dfs(int i, int a, int b)
{
	if (i == 10) return true;
	bool ans = false;
	if (a < balls[i]) ans = dfs(i + 1, balls[i], b);
	if (b < balls[i]) ans = dfs(i + 1, a, balls[i]);
	return ans;
}

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