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<cstdio>
#include<queue>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
int a[10];
int main(){
    int n;
    scanf("%d",&n);
    while(n--){
        for(int i=0;i<10;i++){
            scanf("%d",&a[i]);
        }
        int w=0;
        int now=0;
        for(int i=0;i<10;i++){
            if(a[i]>now){
                now=a[i];
                a[i]=0;
                w++;
            }
        }
        now=0;
        for(int i=0;i<10;i++){
            if(a[i]>now){
                now=a[i];
                a[i]=0;
                w++;
            }
        }
        printf("%s\n",w==10?"YES":"NO");
    }
    return 0; 
}

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


bool vis[15];
int a[15];

bool ok = false;


void dfs(int cnt, int last){
	if(cnt == 9){
		vector<int> ver;
		for (int i = 0; i < 10; i++){
			if(!vis[i]){
				ver.push_back(a[i]);
			}
		}
		bool flag = true;
		for (int i = 1; i < ver.size(); i++){
			if(ver[i] < ver[i - 1]){
				flag = false;
			}
		}
		if(flag){
			ok = true;
		}
		return;
	}
	for (int i = cnt; i < 10; i++){
		if(a[i] > last){
			vis[i] = true;
			dfs(i + 1, a[i]);
			vis[i] = false;
		}
	}
	return;
}
 





int main(){
	int n;
	cin >> n;
	while(n--){
		ok = false;
		memset(a, 0, sizeof(a));
		memset(vis, 0, sizeof(vis));
		for (int i = 0; i < 10; i++){
			cin >> a[i];
		}
		
		dfs(0, 0);
		if(ok){
			cout << "YES" << endl;
		}else cout << "NO" << endl; 
		
		
		
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  int ball[100][10],count=0;
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin >> ball[i][j];
    }
    for(int j=0;j<6;j++){
      if(ball[i][j] > ball[i][j+2] || ball[i][j+1] > ball[i][j+3]){
	cout << "NO" << endl;
	  count++;
	  break;
      }
    }
    if(count == 0){
      cout << "YES" << endl;
    }
  }
}

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

int a[10];

int main() {
	int T;
	cin >> T;
	while (T--) {
		bool ans = true;
		for (int i = 0; i < 10; ++i) {
			cin >> a[i];
		}
		int l, r;
		l = r = 0;
		for (int i = 0; i < 10; ++i) {
			if (a[i] > l) {
				l = a[i];
			} else if (a[i] > r) {
				r = a[i];
			} else {
				and = false;
				break;
			}
		}
		cout << (ans ? "YES" : "NO") << endl;
	}
}

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

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		bool flag = false;
		int prev;
		int in[10];
		int used[10];
		for (int j = 0; j < 10; j++)
		{
			cin >> in[j];
		}
		prev = in[0];
		vector<int> B;
		vector<int> C;
		for (int j = 0; j < 10; j++)
		{
			if (prev > in[j])
			{
				C.push_back(in[j]);
				used[j] = false;
				continue;
			}
			else
			{
				prev = in[j];
				B.push_back(in[j]);
				used[j] = true;
			}
		}
		prev = C[0];
		for (int j = 0; j < C.size(); j++)
		{
			if (prev > C[j])
			{
				flag = true;
				break;
			}
			else
			{
				prev = C[j];
			}
		}
		if (flag) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define MP(X,Y) make_pair(X,Y)
#define PB(X) push_back(X)
#define REP(X,N) for(int X=0;X<N;X++)
#define REP2(X,L,R) for(int X=L;X<=R;X++)
#define DEP(X,R,L) for(int X=R;X>L;X--)
#define DEP2(X,R,L) for(int X=R;X>=L;X--)
#define CLR(A,X) memset(A,X,sizeof(A))
#define IT iterator
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef vector<PII> VII;
typedef vector<int> VI;
#define X first
#define Y second
#define lson(X) ((X)<<1)
#define rson(X) ((X)<<1|1)
const int maxn=1e5+5;

int n,m,a[maxn];
int b[maxn],c[maxn];
int main(){
	int t;
	cin>>t;
	while(t--)
	{
		int n=10;
		REP(i,n) cin>>a[i];
		CLR(b,0);CLR(c,0);
		b[0]=a[0];
		int p=0,q=0,i=1;
		for(i=1;i<n;i++){
			int num=a[i];
			if(b[p]>=c[q]){
				if(num>b[p] && num>c[q]) b[++p]=num;
				else if(num>c[q] && num<b[p]) c[++q]=num;	
				else break;
			}
			
			else{
				if(num>b[p] && num>c[q]) c[++q]=num;
				else if(num>b[p] && num<c[q]) b[++p]=num;	
				else break;				
			}
		}
		if(i==n) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n, num, right, left;
  bool flag;

  cin >> n;

  for(int i = 0; i < n; i++){
    right = 0;
    left = 0;
    flag = true;
    for(int j = 0; j < 10; j++){
      cin >> num;

      if(right < num){
        right = num;
      }else{
        left = num;
      }

      if(20 - (right + left) < 10 - j + 1) flag = false;
    }

    if(flag){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }

  return 0;
}

C++: //AOJ0033
#include<iostream>
using namespace std;
int table[10];

bool ok(int i,int left,int right){
	if(i>=9){
		return true;
	}
	if(left<table[i]){
		if(ok(i+1,table[i],right))return true;
	}
	
	if(right<table[i]){
		if(ok(i+1,left,table[i]))return true;
	}
	return false;
}
int main(){
	int n;
	cin>>n;
	for(int set=0;set<n;set++){
		for(int i=0;i<10;i++)cin>>table[i];
		if(ok(0,0,0))cout<<"YES\n";
		else cout<<"NO\n";
	
	}
	return 0;
}

C++: #include<stdio.h>
int a[10];
int bstack[10];
int btop;
int cstack[10];
int ctop;
bool dfs(int i)
{
    bool b1=false,b2=false;
    if(i==10)
        return true;
    if(btop==-1 || bstack[btop]<a[i])
    {
        btop++;
        bstack[btop]=a[i];
        i++;
        b1=dfs(i);
        btop--;
    }
    if(ctop==-1 || cstack[ctop]<a[i])
    {
        ctop++;
        cstack[ctop]=a[i];
        i++;
        b2=dfs(i);
        ctop++;
    }
    return b1|b2;
}
int main()
{
    int n;
    while(n--)
    {
        for(int i=0;i<10;i++)
        {
            scanf("%d",&a[i]);
        }
        btop=-1;
        ctop=-1;
        if(dfs(0))
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

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

#define V vector<int>{0}

int main() {
	int n, x, z;
	cin >> n;

	for (int i = 0; i < n; i++) {
		vector< vector<int> > v = { V, V, V };
		z = 1;
		for (int j = 0; j < 10; j++) {
			cin >> x;
			for (int k = 0; k < z; k++) {
				if (v[k].back() < x) {
					v[k].push_back(x);
					break;
				}

				if (k == z - 1) {
					v[z].push_back(x);
					z++;
					break;
				}
			}

			if (z == 3) {
				x = -1;
				break;
			}
		}

		if (x == -1) {
			cout << "NO";
		}
		else {
			cout << "YES";
		}
		cout << endl;
	}
	return 0;
}