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 <vector>

using namespace std;

int n;
vector<int> vec;
int lcount, rcount, l, r;

bool dfs(int i)
{
	if(i == 10) return true;
	if(lcount < 10 && l < vec[i]){ l = vec[i]; if(dfs(i + 1)) return true; }
	if(rcount < 10 && r < vec[i]){ r= vec[i]; if(dfs(i + 1)) return true; }
	return false;
}

int main()
{
	cin >> n;
	lcount = 0; rcount = 0; l = 0; r = 0;
	vec.resize(10);
	for (int j = 0; j < n; j++)
	{

		for (int i = 0; i < 10; i++)
		{
			cin >> vec[i];
		}	
		cout << (dfs(0) ? "YES" : "NO") << endl;
	}
	return 0;
}

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

int B[11]={0};
int C[11]={0};

bool DFS(int *a,int i=0,int b=1,int c=1)
{
	bool judge=true;

	if(i==10)
		return judge;

	judge=false;

	if(B[b-1]<a[i]){
		B[b]=a[i];
		judge=DFS(a,i+1,b+1,c);
		
	}
	if(C[c-1]<a[i]){
		C[c]=a[i];
		judge=DFS(a,i+1,b,c+1);
		
	}

	return judge;
}        

int main()
{
        int N;
		int i=0;
        cin>>N;

		while(i<N){
			int A[10]={0};
			for(int i=0;i<10;i++)
				cin>>A[i];

            if(DFS(A)==true)
                cout<<"YES"<<endl;
            else
				cout<<"NO"<<endl;



		for(int i=1;i<=10;i++){
			cout<<"??????B["<<i<<"]="<<B[i]<<' ';
		}
		cout<<endl;

		for(int i=1;i<=10;i++){
			cout<<"??????C["<<i<<"]="<<C[i]<<' ';
		}
		cout<<endl;




			i++;
        }
                
		while(1);

        return 0;
}

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

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int a = 0, b = 0;
		int num[10];
		for(int j = 0; j < 10; j++){
			cin >> num[j];
		}
		for(int j = 0; j < 10; j++){
			if(a < b){
				swap(a,b);
			}
			if(num[j] > a){
				a = num[j];
			}
			else if(num[j] > b){
				b = num[j];
			}
			else{
				cout << "NO" << endl;
				break;
			}
			if(j == 9){
				cout << "YES" << endl;
			}
		}
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

int a[10];

bool dfs(int i, int l, int r)
{
    if (i == 10) return true;

    if (l < a[i] && dfs(i + 1, a[i], r)) return true;
    if (r < a[i] && dfs(i + 1, r, a[i])) return true;

    return false;
}

int main()
{
    int n; cin >> n;

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

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

int main(){
	int B, C;
	int N;
	int ball[10];
	bool bo;
	
	scanf("%d", &N);
	while(N--){
		for(int i = 0; i < 10; i++) scanf("%d", &ball[i]);
		
		B = 0; C = 0;
		
		bo = true;
		for(int i = 0; i < 10; i++){
			if(ball[i] > B) B = ball[i];
			else if(ball[i] > C) C = ball[i];
			else{
				bo = false;
				break;
			}
		}
		
		if(bo) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

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

using namespace std;

int main(){
	int N,temp;
	int b,tempb,tempc,ch;
	
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		tempb=0;
		tempc=0;
		ch=0;
		for(int j=0;j<10;j++){
			scanf("%d",&temp);
			if(tempb<temp)
			tempb=temp;
			else if(tempc<temp)
			tempc=temp;
			else{
				ch=1;
			}
		}
		if(ch==0)
		printf("YES\n");
		else
		printf("NO\n");
	}
}

C++: #include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
	int N,pre,current,second_pre;
	bool NO_FLG;

	scanf("%d",&N);
	for(int i=0;i<N;i++){
		pre = -1;
		second_pre = -1;
		NO_FLG = false;
		for(int k = 0; k < 10; k++){
			scanf("%d",&current);
			if(k == 0){
				pre = current;
			}else{
				if(pre > current){
					if(second_pre == -1){
						second_pre = pre;
					}else{
						if(second_pre > pre){
							printf("NO\n");
							NO_FLG = true;
							break;
						}else{
							second_pre = pre;
						}
					}
				}
				pre = current;
			}
		}
		if(!NO_FLG)printf("YES\n");

	}
	return 0;
}

C++: #include <iostream>

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++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main() {

	stack<int> B, C;
	int n,ball;

	cin >> n;

	while (n) {
		for (int i = 0; i < 10; i++) {
			cin >> ball;

			if (i == 0)
				B.push(ball);

			else if (B.top() > ball)
				if (C.empty())
					C.push(ball);
				else if (C.top() < ball)
					C.push(ball);
				else {
					cout << "NO" << endl;
					break;
				}

			else {
				if (B.top() < ball)
					B.push(ball);
				else {
					cout << "NO" << endl;
					break;
				}
			}

			if (i == 9)
				cout << "YES" << endl;
		}
		n--;
	}
	return 0;
}

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

int B[11]={0};
int C[11]={0};

bool DFS(int *a,int i=0,int b=1,int c=1)
{
	bool judge=true;

	if(i==10)
		return judge;

	judge=false;

	if(B[b-1]<a[i]){
		B[b]=a[i];
		judge=DFS(a,i+1,b+1,c);
		
	}
	if(C[c-1]<a[i]){
		C[c]=a[i];
		judge=DFS(a,i+1,b,c+1);
		
	}

	return judge;
}        

int main()
{
        int N;
	int i=0;
        cin>>N;

	while(i<N){
          int A[10];
          for(int i=0;i<10;i++){
           cin>>A[i];
          }

          if(DFS(A)==true){
           cout<<"YES"<<endl;
          }
          else{
           cout<<"NO"<<endl;
          }

          i++;
        }
                
        return 0;
}

C++: //0033
//include-------------------------------------
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<stack>

using namespace std;

//typedef--------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define MP make_pair

//repetition-----------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

//constant-------------------------------------
const double PI = acos(-1.0);

//cout,cin-------------------------------------
#define COUT(x) cout<<(x)<<endl;
#define CIN(x) cin>>(x);


int main(){
	int n;
	int x[10];
	bool ans;

	CIN(n);

	REP(i, n){
		
		REP(j, 10) CIN(x[j]);
		stack<int> B, C;
		B.push(0);
		C.push(0);

		REP(j, 10){
			if ((B.top() > x[j]) && (C.top() > x[j])){
				ans = false;
				break;
			}
			else { 
				if ((B.top() >= C.top()) && (B.top() < x[j])) B.push(x[j]);
				else C.push(x[j]);
			}

		}
		COUT(ans==false?"NO":"YES");
		
	}

	return 0;

}

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

int main() {
	int n;
	for (cin >> n; n; --n) {
		int a = 0;
		int b = 0;
		bool result = true;
		for (int i = 0; i < 10; ++i) {
			int ball;
			cin >> ball;
			if (ball > a) {
				a = ball;
			}
			else if (ball > b) {
				b = ball;	
			}
			else if (result) {
				result = !result;
			}
		}
		cout << (result ? "YES" : "NO") << endl;
	}
	return 0;
}