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<cstring>
#include<algorithm>
#include<stack>
#include<bitset>
#include<queue>
#include<string>
#include<vector>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,n,a) for(int i=n;i>a;i--)
#define mem0(x) memset(x,0,sizeof(x))
#define memff(x) memset(x,INF,sizeof(x))
#define INF 100000000
using namespace std;
typedef pair<int,int> p;
typedef long long LL;
int aa[15];
int main()
{
    //freopen("input.in","r",stdin);
    int n;
    bitset<10> dis;
    cin>>n;
    while(n--)
    {
        for(int i=1;i<=10;i++)
        cin>>aa[i];
        int all=1024;
        while(all>0)
        {
            dis=static_cast<bitset<10> >(all);
            bool flag=true;
            int left=0,right=0;
            for(int i=1;i<=10;i++)
            {
                if(dis[i-1])
                {
                    if(aa[i]>left)
                    {
                         left=aa[i];
                    }
                    else
                    {
                        flag=false;
                        break;
                    }
                }
                else
                {
                    if(aa[i]>right)
                    {
                        right=aa[i];
                    }
                    else
                    {
                        flag=false;
                        break;
                    }
                }
            }
            if(flag)
            {
                break;
            }
            else all--;
        }
        if(all>0)
        cout<<"YES"<<endl;
        else
        cout<<"NO"<<endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int N;
	
	cin >> N;
	
	for(int n = 0;n < N;n++)
	{
		int tubeB = 0, tubeC = 0;
		bool ans = true;
		
		for(int i = 0;i < 10;i++)
		{
			int ball;
			cin >> ball;
			
			if(tubeB < ball) tubeB = ball;
			else if(tubeC < ball) tubeC = ball;
			else ans = false;
		}
		
		if(ans) cout << "YES\n";
		else cout << "NO\n";
	}
	
	return 0;
}

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

int a[10];
bool check;

void dfs(int b, int c, int index) {
  if(index == 10) {
    check = true;
  }
  if(b < a[index]) {
    dfs(a[index], c, index + 1);
  }
  if(c < a[index]) {
    dfs(b, a[index], index + 1);
  }
}

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

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        int a[10];
        bool f = 0;
        for(int j=0; j<10; j++) cin >> a[j];
        for(int j=0; j<8; j++) {
            if(a[j] > a[j+1] && a[j+1] > a[j+2]) {
                f = 1;
                break;
            }
        }
        printf("%s\n", f ? "No" : "Yes");

    }

    return 0;
}

C++: #include<cstdio>  
#include<string>  
#include<iostream>  
#include<cstring>  
#include<algorithm>  
using namespace std;  
typedef long long LL;  
const int INF = 0x7FFFFFFF;  
const int maxn = 1e5 + 10;  
   
int a[11],vis[11],flag;  
  
void dfs(int x,int l,int r)  
{  
    int i;  
    if(x==11)return;   
    if(flag)return;  
    if(a[x]>l)dfs(x+1,a[x],r);  
    else if(a[x]>r)dfs(x+1,l,a[x]);  
    else{flag=1;return;}  
}  
  
int main()  
{  
  int T,i,j,k;  
  scanf("%d",&T);  
  while(T--)  
  {  
    flag=0;  
    for(i=1;i<=10;i++)  
      scanf("%d",&a[i]);  
    memset(vis,0,sizeof(vis));  
    dfs(1,0,0);  
    if(flag)printf("NO\n");  
    else printf("YES\n");  
  }  
 return 0;  
}

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

bool res = false;
int a[10];

void dfs(int i, int l, int r) {
    if (i >= 10) {
        res = true;
        return;
    }
    else {
        if (a[i] > l) dfs(i + 1, a[i], r);
        if (a[i] > r) dfs(i + 1, l, a[i]);
    }
}

int main() {
    int T;
    cin >> T;
    for (int i = 0; i < T; ++i) {
        for (int j = 0; j < 10; ++j) cin >> a[j];
        res = false;
        dfs(0, 0, 0);
        cout << (res?"YES":"NO") << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<set>
#include<map>
#include<sstream>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
int n;
int num[11];
int rr,lll;
bool b;
void dfs()
{
	bitset<10> ans;
	int alll=1<<10;
	while(alll-->0)
	{
		ans=static_cast<bitset<10> >(alll);
		bool b=true;
		rep(i,10)
		{
			if(ans[i])
			{
				if(num[i]>lll)
				{
					lll=num[i];
				}
				else
				{
					b=false;
					break;
				}
			}
			else
			{
				if(num[i]>rr)
				{
					rr=num[i];
				}
				else
				{
					b=false;
					break;
				}
			}
		}
		if(b)break; 
	}
	if(alll>=0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return;
}
int main()
{
	cin>>n;
	while(n--)
	{
		rr=0;
		lll=0;
		rep(i,10)cin>>num[i];
		dfs();
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int r[10],l[10];
int data[10];

bool solve(int n,int rt,int lt)
{
	if(n==10)
	{
		for(int i = 1; i <= rt ; ++i)
		{
			if(r[i-1]>r[i]) return false;
		}
		for(int i = 0; i <= lt ; ++i)
		{
			if(l[i-1]>l[i]) return false;
		}
		return true;
	}

	r[rt]=data[n];
	if(solve(n+1,rt+1,lt)) return true;
	l[lt]=data[n];
	if(solve(n+1,rt,lt+1)) return true;

	return false;
}

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

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int a[10];
int n;
 
bool dfs(int i,int left,int right){
    if(i==10) return true;
    if(a[i]>left){
        return dfs(i+1,a[i],right);
    }
    if(a[i]>right){
        return dfs(i+1,left,a[i]);
    }
    return false;
}
 
void solve(){
    rep(i,10) cin >> a[i];
    if(dfs(0,0,0)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return;
}
 
int main(){
    cin >> n;
    rep(i,n){
        solve();
    }
    return 0;
}