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;
bool canbe = false;
int inp[10];

void dfs(int b, int c, int depth){
    if (depth >= 10){
	canbe = true; return;
    }
    if (inp[depth] < b && inp[depth] < c) return;

    if (inp[depth] > b) dfs(inp[depth], c, depth+1);
    if (inp[depth] > c) dfs(b, inp[depth], depth+1);
}


int n;
int main(){
    cin >> n;
    for (int i = 0; i < n; i++){
	canbe = false;
	for (int j = 0; j < 10; j++) cin >> inp[j];
	
	dfs(0, 0, 0);

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

C++: #include <bits/stdc++.h>
using namespace std;

int inp[10];
int n;
bool canbe = false;

void dfs(int b, int c, int depth) {
  if (depth >= 10) {
    canbe = true; return;
  }
  if (inp[depth] < b && inp[depth] < c) return;
  if (inp[depth] > b) dfs(inp[depth], c, depth+1);
  if (inp[depth] > c) dfs(b, inp[depth], depth+1);
}

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

  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 99999999
using namespace std;
typedef long long ll;
const int MAXN=1e9+10;
const int MAX=100+10;
int s[MAX];
int tag;
stack<int>l,r;
void dfs(int flag){
	if(tag)	return;
	if(flag==9){
		tag=1;
		return;
	}
	if(s[flag]>l.top()){
		l.push(s[flag]);
		dfs(flag+1);
		l.pop();
	}
	if(s[flag]>r.top()){
		r.push(s[flag]);
		dfs(flag+1);
		r.pop();
	}
}
int main(){
   #ifdef SIYU
   freopen("in.txt","r",stdin);
   #endif // SIYU
   //ios::sync_with_stdio(false);
   int T;
   cin>>T;
   while(T--){
   		for(int i=0;i<10;i++){
   			cin>>s[i];
   		}
   		tag=0;
   		l.push(0);
   		r.push(0);
   		dfs(0);
   		if(tag)
   			cout<<"YES"<<endl;
   		else
   			cout<<"NO"<<endl;
   }
   return 0;
}

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

int main()
{
int n;
scanf("%d", &n);
for(int testcase = 0; testcase < n; ++testcase) {
bool yes = false;
int s = 10;
vector<int> x;
x.resize(s);
for(int i = 0; i < s; ++i)
scanf("%d", &x[i]);
for(int bit = 0; bit < (1 << s); ++bit) {
bool valid = true;
for(int lr = 0; lr < 2; ++lr) {
int prev = -100;
for(int i = 0; i < s; ++i) {
if(((bit >> i) & 1) == lr) {
if(prev >= x[i]) {
valid = false;
break;
}
prev = x[i];
}
}
}
if(valid) {
yes = true;
break;
}
}
printf("%s\n", yes ? "YES" : "NO");
}
return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int test[51];
signed main() {
    int n, a, b; cin >> n;
    for (int h = 0; h < n; h++) {
        int sum = 0, num = 0, c = 0;
        for (int i = 0; i < 10; i++) {
            cin >> a;
            if (c == 0) {
                if (sum < a) { sum = a; }
                else if (num < a) { num = a; }
                else { cout << "NO" << endl; c++; }
            }
        }
        if (c == 0) { cout << "YES" << endl; }
    }
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n, i,j,a, b, c,flag;

	cin >> n;
	for (i = 0; i < n; i++) {
		b = c = 0;
		flag = 1;
		for (j = 0; j < 10; j++) {
			cin >> a;
			if (a > b) {
				b = a;
			}
			else if (a > c) {
				c = a;
			}else {
				flag = 0;
			}
		}

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

	return 0;
}

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

using namespace std;


int q;
int Ball[10];
bool flag;
vector<string> log;

bool is_satisfies(vector<int> a) {
    vector<int> copy = a;
    sort(a.begin(), a.end());
    return a == copy;
}

void bfs(int i, vector<int> B, vector<int> C) {
    if (i == 9) {
        if (is_satisfies(B) && is_satisfies(C))
            flag = true;
        else
            flag = flag == true ? true : false;
    } else {
        vector<int> temp;

        temp = B;
        temp.push_back(Ball[i]);
        bfs(i + 1, temp, C);

        temp = C;
        temp.push_back(Ball[i]);
        bfs(i + 1, B, temp);
    }
}

void solve() {
    vector<int> B, C;
    flag = false;

    bfs(0, B, C);

    if (flag)
        log.push_back("YES");
    else
        log.push_back("NO");
}

int main() {
    cin >> q;
    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < 10; ++j)
            scanf("%d", &Ball[j]);

        solve();
    }

    for (int i = 0; i < log.size(); ++i) {
        cout << log[i] << endl;
    }
}

C++: #include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)

int a[11];
bool ans;

int main()
{
	int n; cin >> n;
	REP(l, n)
	{
		REP(i, 10) cin >> a[i];
		int b = 0; int c = 0;
		REP(i, 10)
		{

			if (a[i] < b&&a[i] < c) goto miss;
			else if (a[i] > b&& a[i] > c)
			{
				if (b > c) b = a[i];
				else c = a[i];
			}
			else if (a[i] > b&& a[i] < c) b = a[i];
			else if (a[i] < b&& a[i] > c) c = a[i];
		}
		cout << "YES" << endl;
		continue;
	miss:
		cout << "NO" << endl;
	}
	return 0;
}

C++: # include <stdio.h>

int main ()
{
	int n; 
	int a[10], b[10], c[10] ;
	while(scanf("%d", &n) != EOF)
	{
		while(n --)
		{
			int m = 0 ;
			int k = 0 ;
			int maxn ;
			for(int i = 0; i < 10; i ++)
				scanf("%d", &a[i]) ;
			int f = 0 ;
			maxn = 0 ;
			for(int i = 0; i < 10; i ++)
			{
				if(a[i] > maxn)
				{
					maxn = a[i] ;
					b[m++] = a[i] ;
				}
				else
				{
					if(a[i] > f)
					{
						f = a[i] ;
						c[k++] = a[i] ;
					}					
				}
			}
			if(m + k == 10)
				puts("YES") ;
			else
				puts("NO") ;
		
		}	
	}
	return 0 ;
}