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 <bitset>
#include <algorithm>
using namespace std;
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	int n;
	cin >> n;
	while (n--)
	{
		int ball[10];
		
		for (int i = 0; i < 10; ++i)
		{
			cin >> ball[i];
		}
 
		bitset<10> direction;
		int all = 1024;
		while (all-- > 0)
		{
			direction = static_cast<bitset<10> >(all);
			bool perfect = true;
			int left = 0;
			int right = 0;
			for (int i = 0; i < 10; ++i)
			{
				if (direction[i])
				{
					if (ball[i] > left)
					{
						left = ball[i];
					}
					else
					{
						perfect = false;
						break;
					}
				}
				else
				{
					if (ball[i] > right)
					{
						right = ball[i];
					}
					else
					{
						perfect = false;
						break;
					}
				}
			}
			if (perfect)
			{
				break;
			}
		}
	
		if (all >= 0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
 
	return 0;
}

C++: #include <iostream>  
#include <cstdio>  
using namespace std;  
  
const int N = 10;  
  
int a[N];  
  
void input()  
{  
    for (int i = 0; i < N; i ++) {  
        scanf("%d", &a[i]);  
    }  
}  
  
void solve()  
{  
    bool res = false;  
    for (int k = 0; k < (1<<10); k++) {  
        int num = 0;  
        int i;  
        for (i = 0; i < N; i ++) {  
            if ( (1 << i)&k ) {  
                if (a[i] > num)  
                    num = a[i];  
                else  
                    break;  
            }  
        }  
        if (i < N)  
            continue;  
        num = 0;  
        for (i = 0; i < N; i ++) {  
            if ( ((1 << i)&k) == 0 ) {  
                if (a[i] > num)  
                    num = a[i];  
                else  
                    break;  
            }  
        }  
        if (i == N) {  
            res = true;  
            //printf("k=%d\n", k);  
            break;  
        }  
    }  
    if (res)  
        printf("YES\n");  
    else  
        printf("NO\n");  
}  
  
int main(void)  
{  
    int t;  
    cin >> t;  
    while (t--) {  
        input();  
  
        solve();  
    }  
  
    return 0;  
}

C++: #include<cstdio>
#include<queue>
using namespace std;
int main(){
	int n, tmp, top;
	queue<int> q;
	scanf("%d", &n);
	while(n--){
		top = 1;
		while (!q.empty()) q.pop();
		bool flag = true;
		for(int i = 0; i < 10; i++){
			scanf("%d", &tmp);
			if (tmp == top){
				top++;
				continue;
			}
			if (!q.empty() && q.front() == tmp){
				q.pop();
				continue;
			}
			if (tmp < top){
				flag = false;
				break;
			}
			while (top != tmp){
				q.push(top);
				top++;
			}
			top++;
		}
		if (flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

using namespace std;

int a[15],l[15],r[15];
int flag;

void dfs(int i,int j,int k)
{
    if(i>10)
    flag=1;
    if(flag)
    return;
    else
    {
        if(a[i]>l[j-1])
        {
            l[j]=a[i];
            dfs(i+1,j+1,k);
        }
        if(a[i]>r[k-1])
        {
            r[k]=a[i];
            dfs(i+1,j,k+1);
        }
    }

}

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

C++: #include <iostream>

using namespace std;

int main(){
  int n, num, right, left;
  bool flag;

  cin >> n;

  for(int i = 0; i < n; i++){
    right = 0;
    left = 0;
    flag = true;

    for(int j = 0; j < 10; j++){
      cin >> num;

      if(right < num){
        right = num;
      }else if(left < num){
        left = num;
      }else{
        flag = false;
      }
    }

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

  return 0;
}

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

int N;
int ball[MAX_N];

int used[MAX_N];

bool dfs(int max_l, int max_r, int next) {
    if (next == MAX_N) return true;
    if(ball[next] > max_l)
        return dfs(ball[next],max_r,next+1);
    if(ball[next] > max_r) 
        return dfs(max_l,ball[next],next+1);
    return false;
}

string solve() {
   memset(used,0,sizeof(used));
   return dfs(0,0,0) ? "YES" : "NO";
}

main() {
    cin>>N;
    for(int i=0;i<N;i++) {
        for(int j=0;j<MAX_N;j++) {
            cin>>ball[j];
        }
        cout << solve() << endl;
    }
}

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

typedef long long ll;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t; cin >> t;
    int a[10], b[10];
    while(t--) {
        for(int i = 0; i < 10; i++) {
            cin >> a[i];
        }
        int pre = a[0], count = 0;
        for(int i = 1; i < 10; i++) {
            if(a[i] > pre) pre = a[i];
            else b[count++] = a[i];
        }
        bool flag = false;
        for(int i = 1; i < count; i++) {
            if(b[i] <= b[i-1]) {
                flag = true;
                break;
            }
        }
        if(flag) cout << "NO\n";
        else cout << "YES\n";
    }
    return 0;
}

C++: #include<cstdio>
#include<string>
#include<vector>
#include<fstream>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<cwctype>
#include<algorithm>
#include<math.h>

using namespace std;


int data[10];

bool searchB (int a){
	vector<int >sea;

	for(int i=0;i<10;i++){
		if(a>>i & 1)sea.push_back(data[i]);
	}
	if(sea.size()>1){
	for(int i=0;i<sea.size()-1;i++){
		if(sea[i]>sea[i+1])return false;
	}
	}
	return true;
}

int main(){

	int n=0;
	cin>>n;

	for(int i=0;i<n;i++){
		

	for(int j=0;j<10;j++){
		cin>>data[j];
	}
	bool suc=false;
	for(int i=0;i<2048;i++){
		if(searchB(i) && searchB(~i)){
			cout<<"YES"<<endl;
			suc=true;
			break;
		}
	}
	if(!suc)cout<<"NO"<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<set>
#include<string>
#include<queue>
#include<string.h>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<stack>
#include<sstream>
using namespace std;
int num[11];
int preA, preB, x;
bool dfs(int preA,int preB,int x,int cnt) {
	if (cnt == 11) {
		return true;
	}
	if (x > preA) {
		preA = x;
		x = num[cnt + 1];
		dfs(preA, preB, x, cnt + 1);
	}
	if (x > preB) {
		preB = x;
		x = num[cnt + 1];
		dfs(preA, preB, x, cnt + 1);
	}
	if (x < preA&&x < preB) {
		return false;
	}
}
int main() {
	int t;
	cin >> t;
	while (t--) {
		for (int i = 1; i <= 10; i++)
			cin >> num[i];
		preA = num[1];
		preB = 0;
		x = num[2];
		int cnt = 2;
		if (dfs(preA, preB, x, cnt))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int tubeM[10];
	int tube1[10], tube2[10];
	int i, j, k;
	int n;
	int ans;
	
	scanf("%d", &n);
	
	while(n){
		
		for (i = 0; i < 10; i++){
			scanf("%d", &tubeM[i]);
			
			tube2[i] = 0;
		}
		
		tube1[0] = tubeM[0];
		for (i = 1, j = 0, k = 0; i < 10; i++){
			if (tubeM[i] > tube1[j]){
				tube1[j + 1] = tubeM[i];
				j++;
			}
			else {
				tube2[k] = tubeM[i];
				k++;
			}
		}
		
		ans = 0;
		for (i = 1; tube2[i] != 0; i++){
			if (tube2[i - 1] > tube2[i]){
				ans = 1;
				break;
			}
		}
		
		if (ans == 0){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		
		n--;
	}
	
	return (0);
}