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<stdio.h>
#include <queue>
using namespace std;

bool flag = true;

void solve(queue<int> left, queue<int> right, queue<int> all) {
	if (all.size() > 0) {
		if (left.size() > 0) {
			if (all.front() > left.back()) {
				left.push(all.front());
				all.pop();
				solve(left, right, all);
			}
			else {
				if (right.size() > 0) {
					if (all.front() > right.back()) {
						right.push(all.front());
						all.pop();
						solve(left, right, all);
					}
					else if(all.size() == 0){
					
					}
					else {
						flag = false;
					}
				}
				else {
					right.push(all.front());
					all.pop();
					solve(left, right, all);
				}
			}
		}
		else {
			left.push(all.front());
			all.pop();
			solve(left, right, all);
		}
	}
}

int main() {

	int n;
	scanf("%d", &n);
	for (; n > 0; n--) {
		queue<int> all;
		queue<int> left;
		queue<int> right;
		for (int i = 0; i < 10; i++) {
			int temp;
			scanf("%d", &temp);
			all.push(temp);
		}
		solve(left, right, all);
		if (flag)
			printf("YES\n");
		else
			printf("NO\n");
	}	
	return 0;
}

C++: #include <stdio.h>

int a[11];

bool dfs(int i, int R, int L){
    if (i == 10) return true;
    if (dfs(i+1, a[i], L) && a[i] > R)
		return true;
    if (dfs(i+1, R, a[i]) && a[i] > L)
		return true;
    return false;
}

void solve(){
	for (int i=0; i<10; ++i){
		scanf("%d", &a[i]);
	}
	printf("%sn", dfs(0, 0, 0)?"YES":"NO");
}

int main (){
	int t;
	scanf("%d", &t);
	while (t --){
		solve();
	}
	return 0;
}

C++: #include<cstdio>

int main(){
	int n;
	int b,c;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		b = c = 0;
		int t;
		for(int j = 0; j < 10; j++){
			scanf("%d", &t);
			if(b < t){
				b = t;
			}else{
				if(c < t){
					c = t;
				}else{
					t = 11;
					break;
				}
			}
		}
		if(t - 11){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

C++: #include<iostream>
#include<stack>

using namespace std;

int main() {

	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int A[10];
		for (int j = 0; j < 10; j++)cin >> A[j];
		stack<int> B, C;
		B.push(A[0]);
		for (int j = 1; j < 10; j++) {
			if (B.top() < A[j])B.push(A[j]);
			else if (C.empty() == 1 || C.top() < A[j])C.push(A[j]);
			else {
				cout << "NO" << endl;
				break;
			}
			if (j == 9)cout << "YES" << endl;
		}
	}

	return 0;
}

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

int a[15], b[2], flag[2];

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int is_yes = 1;
        b[0] = b[1] = 0;
        for(int i = 0; i < 10; i++)
            cin >> a[i];
        for(int i = 0; i < 10; i++)
        {
            flag[0] = flag[1] = 0;
            for(int j = 0; j < 2; j++)
            {
                //cout << "a[i]" << a[i] << endl;
                if(b[j] == 0)
                {
                    b[j] = a[i];
                    break;
                }
                else if(b[j] < a[i])
                {
                    b[j] = a[i];
                    break;
                }
                flag[j] = 1;
            }
            //for(int j = 0; j < 2; j++)
                //cout << "b[" << j <<"] = " << b[j] << endl;
            if(flag[1] && flag[0])
            {
                cout << "NO" << endl;
                is_yes = 0;
                break;
            }
        }
        if(is_yes)
            cout << "YES" << endl;
    }


    return 0;
}

C++: #include<iostream>
using namespace std;
#define RIGHT 1
#define LEFT 0
#define BALL 10
#define BAD 1

int main()
{
    int n;
    int num[BALL];
    int siden[BALL];
    cin >> n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<BALL;++j) {cin >> num[j]; }

        int temp,ans =0;
        unsigned int side;
        for(side=0;side<=4050;++side)
        {
            ans = 0;
            for(int j = 0;j<BALL;++j)
            {
                if(((side>>j)&1) ){siden[j] = RIGHT;}
                else {siden[j] = LEFT;}
            }
            int before = -1;
            for(int j=0;j<BALL;++j)
            {
                if(siden[j]==RIGHT)
                {
                    if(before > -1)
                    {
                        if(num[before]>num[j])ans = BAD;
                    }
                    before = j;
                }
            }
            before = -1;

            for(int j=0;j<BALL;++j)
            {
                if(siden[j]==LEFT)
                {
                    if(before > -1)
                    {
                        if(num[before]>num[j])ans = BAD;
                    }
                    before = j;
                }
            }
            if(ans==0)break;
        }
        if(ans==BAD) cout << "NO" << endl;
        else cout << "YES" << endl;

    }
    return 0;
}

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

using namespace std;

int main(){
        int n;
        cin >> n;
        for(int i = 0; i < n; i++){
                int num[10];
                for(int j = 0; j < 10; j++){
                        cin >> num[j];
                }

                // 深さ優先探索?
                int a, b;
                int j;
                a = b = 0;
                for(j = 0; j < 10; j++){
                        if(a < num[j]){
                                a = num[j];
                                continue;
                        }
                        if(b < num[j]){
                                b = num[j];
                                continue;
                        }
                        break;
                }

                if(j != 10){
                        cout << "NO" << endl;
                } else {
                        cout << "YES" << endl;
                }
        }

        return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        int bs[10];
        for(int j=0;j<10;++j){
            cin>>bs[j];
        }
        int l=bs[0],r=0;
        bool flg=true;
        for(int k=1;k<10;++k){
            if(l<bs[k])l=bs[k];
            else if(r<bs[k])r=bs[k];
            else flg=false;
        }
        if(flg)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,a;
  int f = 0;
  int b = 0 ,c = 0;
  cin >> n;
  for(int j = 0;j < n;j++){
    f=0;
    for(int i = 0;i < 10;i++){
      cin >> a;
      if(b < a)b = a;
      else if(c < a)c = a;
      else {
	f = 1;	
      }  
    }
    if(f == 1)cout << "NO" << endl;
    else cout << "YES" << endl;
  }
  return 0;
}

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

int main() {
	int n, x,a=0,b=0;
	bool f;
	cin >> n;
	for (int lop = 0,f=1; lop < n; lop++) {
		for (int i = 0; i < 10; i++) {
			cin >> x;
			if (f) {
				if (a < x) {
					a = x;
					continue;
				}
				if (b < x) {
					b = x;
					continue;
				}
				f = 0;
			}
		}

		cout << (f ? "YES" : "NO") << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int x[10];
int func(int n,int r,int l){
    if(n == 10)return 1;
    if(x[n]>r){
        if(func(n+1,x[n],l))return 1;
    }

    if(x[n]>l){
        if(func(n+1,l,x[n]))return 1;
    }
    return 0;
}
int main(){
	int n;
	cin>>n;
	while(n-->0){
	for(int i=0;i<10;i++)
	cin>>x[i];
	if(func(0,0,0))
	cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	}
	return 0;
}