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;

int main(){
	int N;
	bool N_Flag;
	int first, second, current;
	cin>>N;
	for(int i=0;i<N;i++){
		N_Flag = false;
		first = -1;
		second = -1;
		for(int k=0;k<10;k++){
			cin>>current;
			if(current>first){
				first = current;
			}else{
				if(current>second){
					second = current;
				}else{
					N_Flag = true;
//					break;  去掉break的目的是完成循环，耗尽多余的数字，以便下一循环的数据正确 
				}
			}
		}
		if(N_Flag){
			cout<<"NO"<<endl;
		}else{
			cout<<"YES"<<endl;
		}
	}
}

C++: #include<iostream>

int N;
int a[10];

int main()
{
	std::cin >> N;
	
	while( N-- )
	{
		for( int i = 0; i < 10; i++ )
			std::cin >> a[i];

		int lm = 0, rm = 0;

		bool f = true;

		for( int i = 0; i < 10; i++ )
		{
			if( a[i] > lm )
				lm = a[i];
			else if( a[i] > rm )
				rm = a[i];
			else 
				f = false;
		}

		if( f ) 
			puts( "YES" );
		else
			puts( "NO" );
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int n,a;
  srand((unsigned)time(NULL));
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin>>a;
    }
    if(rand()%2==0){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}

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]&&r[i]!=0) return false;
		}
		for(int i = 1; i <= lt ; ++i)
		{
			if(l[i-1]>l[i]&&l[i]!=0) return false;
		}
		return true;
	}

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

	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 <vector>
#include <string>
#include <algorithm>
using namespace std;

bool check(vector<int>& s){
	int crt = 0;
	bool res = true;
	for(int i = 0;i < s.size();++i){
		if(s[i] > crt) crt = s[i];
		else{
			res = false;
			break;
		}
	}
	return res;
}

int main(){
	int n;cin >> n;
	cin.get();
	while(n--){
		vector<int> nums(10);
		for(int i = 0;i < 10;++i) cin >> nums[i];
		int size = 10;
		bool res = false;
		for(int i = 0;i < (1<<size);++i){
			vector<int> num1,num2;
			for(int j = 0;j < size;++j){
				if((i>>j)&1) num1.push_back(nums[j]);
				else num2.push_back(nums[j]);
			}
			if(check(num1) && check(num2)){
				res = true;
				break;
			}
		}
		if(res) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

int main() {
    int n, x;
    cin >> n;
    while (n--) {
        int a = 0, b = 0;
        bool ok = true;
        for (int j=0; j<10; ++j) {
            cin >> x;
            if (a < x && b < x) {
                if (a < b) {
                    b = x;
                } else {
                    a = x;
                }
            } else if (a < x) {
                a = x;
            } else if (b < x) {
                b = x;
            } else {
                ok = false;
                break;
            }
        }
        cout << (ok ? "YES" : "NO") << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int a[10];

bool dfs(int i, int left, int right){
	//cout << left << " " << right << " " << i << endl;
	if(i == 10) return true;
	bool answer = false;
	if(left < a[i]){
		answer = dfs(i+1, a[i], right);
	}
	if(right < a[i]){
		answer = dfs(i+1, left, a[i]);
	}

	return answer;
}


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

C++: #include <iostream>
#include <climits>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>

#define ll long long
#define REP(i, n) for (int i=0;i<n;++i)
#define REP_1(i, n) for (int i=1;i<=n;++i)
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)

#define JU_RAN(a,x,b) a<=x&&x<=b



using namespace std;

int v[15];
void solve(){
    int n;
    cin>>n;
    while (n--){
        REP_1(i,10)cin>>v[i];
        stack<int > a;
        stack<int > b;
        a.push(0);
        b.push(0);

        bool f=1;
        REP_1(i,10){
            if(a.top()>=b.top()){
                if(a.top()<v[i]){
                    a.push(v[i]);
                } else if(b.top()<v[i]){
                    b.push(v[i]);
                } else{
                    f=0;
                    break;
                }
            }
            else{
                if(b.top()<v[i]){
                    b.push(v[i]);
                } else if(a.top()<v[i]){
                    a.push(v[i]);
                } else{
                    f=0;
                    break;
                }
            }
        }

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

    }

}



int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    solve();



#ifdef LOCAL_DEFINE
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}

C++: #include <cstdio>
using namespace std;
int n;
int a[11];
int main() {
    scanf("%d", &n);
    for (int t = 0; t < n; ++t) {
        int l = 0, r = 0;
        for (int i = 0; i < 10; ++i) scanf("%d", &a[i]);
        bool flag=false;
        for (int i = 0; i < 10; ++i) {
            if (r > l) {
                if (a[i] > r) r = a[i];
                else if (a[i] > l) l = a[i];
                else flag=true;
            } else {
                if (a[i] > l) l = a[i];
                else if (a[i] > r) r = a[i];
                else flag=true;
            }
        }
        if (flag) printf("NO\n");
        else printf("YES\n");

    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int num[10];
bool dfs(int start, int topl, int topr)
{
	if (start == 9)
	{
		if (num[start] > topl || num[start] > topr)
			return true;
		else
			return false;
	}
	else
	{
		bool b1 = false, b2 = false;
		if (num[start] > topl)
			b1=dfs(start + 1, num[start], topr);
		if (num[start] > topr)
			b2 = dfs(start + 1, topl, num[start]);
		return (b1 || b2);
	}
}
	
int main()
{
	int k;
	cin >> k;
	while (k--)
	{
		for (int i = 0; i <= 9; ++i)
			cin >> num[i];
		if (dfs(0,0,0))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}