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<cstdio>  
#include<cstring> 
#include <cmath> 
#include<stack>
#include<vector>
#include<map> 
#include<set>
#include<queue> 
#include<algorithm>  
using namespace std;

typedef long long LL;
const int INF = (1<<30)-1;
const int mod=1000000007;
const int maxn=105;

int a[maxn];
int b[maxn],c[maxn];
int cnt1,cnt2;

bool ok(int b[],int c[]){
	for(int i=1;i<cnt1;i++){
		if(b[i] < b[i-1]) return false;
	}
	
	for(int i=1;i<cnt2;i++){
		if(c[i] < c[i-1]) return false;
	}
	return true;
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		for(int i=0;i<10;i++) scanf("%d",&a[i]);
		
		int flag=0;
		for(int i=0;i< 1<<10;i++){
			 cnt1=0;cnt2=0;
			memset(b,0,sizeof(b));
			memset(c,0,sizeof(c));
			for(int j=0;j<10;j++){
				if(i>>j & 1) b[++cnt1]=a[j];
				else c[++cnt2]=a[j];				
			}
			
			if(ok(b,c)){
					flag=1;
					break;			
				}	
		//	printf("cnt1=%d  cnt2=%d\n",cnt1,cnt2);
		}
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
	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 k;
	cin>>k;
	while(k-->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;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	vector<bool>l;
	int o[10], n;
	cin >> n;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 10; j++)
			cin >> o[i];
		int sum = o[i], num = 0;
		for (int k = 0; k < 10;k++) {
			if (o[k] < sum){
				num++;
				sum = o[k];
			}
		}
		l.push_back(num >= 2);
	}
	for (bool b : l) {
		if (b)cout << "YES";
		else cout << "NO";
		cout << endl;
	}
	char c;
	cin >> c;
}

C++: #include<iostream>
using namespace std;
int main(){
  int t;
  cin >> t;
  int n;
  int b[10]={0};
  int c[10]={0};
  int bcount=0,ccount=0,h=0;
  for(int i=0;i<t;i++){
    for(int j=0;j<10;j++){
      cin >> n;
      if(b[0]==0) b[bcount] = n;
      else if(b[bcount]>c[ccount]&&b[bcount]<n){
    bcount++;
    b[bcount] = n;
      }
      else if(c[ccount]>b[bcount]&&c[ccount]<n){
    if(c[ccount]!=0) ccount++;
    c[ccount] = n;
      }
      else if(b[bcount]>c[ccount]&&b[bcount]>n&&c[ccount]<n){
    if(c[ccount]!=0) ccount++;
    c[ccount] = n;
      }
      else if(c[ccount]>b[bcount]&&c[ccount]>n&&b[bcount]<n){
    bcount++;
    b[bcount] = n;
      }
      else if(b[bcount]>n&&c[ccount]>n){
    cout << "NO" << endl;
    h = 1;
    break;
      }
    }
    if(h==0) cout << "YES" << endl;
    for(int i=0;i<10;i++){
      b[i] = 0;
      c[i] = 0;
    }
      bcount = 0;
      ccount = 0;
      h = 0;
  }
  return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int i, j;
	int ball[10];
	int a, b;
	int n;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		for (j = 0; j < 10; j++){
			scanf("%d", &ball[i]);
		}
		
		for (j = 0; j < 10; j++){
			if (ball[i] < a && ball [i] < b){
				printf("NO\n");
				break;
			}
			if (a > b && a < ball[i]){
				a = ball[i];
			}
			else if (a < b && b < ball[i]){
				b = ball[i];
			}
			else if (a < ball[i]){
				a = ball[i];
			}
			else if (b < ball[i]){
				b = ball[i];
			}
		}
		if (j == 10){
			printf("YES\n");
		}
	}
	return (0);
}

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

std::string answer;
std::vector<int> input, left, right;

void dfs(int i, std::vector<int> L, std::vector<int> R){
	int temp, L_flag, R_flag;
	std::vector<int> Add_L, Add_R;

	if(answer.compare("YES")==0 || i>9) return;

	L_flag = R_flag = 0;
	if(L.size()>0){
		temp = L[0];
		for(unsigned int j=1; j<L.size(); j++){
			if(temp>L[j]){
				L_flag = 1;
				break;
			}
			temp = L[j];
		}
	}
	if(R.size()>0){
		temp = R[0];
		for(unsigned int j=1; j<R.size(); j++){
			if(temp>R[j]){
				R_flag = 1;
				break;
			}
			temp = R[j];
		}
	}

	if(L_flag>0 || R_flag>0) { return; }
	else if(L_flag==0 && R_flag==0 && i==9) { answer = "YES"; }
	
	Add_L = L;
	Add_L.insert(Add_L.end(), input[i]);
	Add_R = R;
	Add_R.insert(Add_R.end(), input[i]);

	dfs(i+1, Add_L, R);
	dfs(i+1, L, Add_R);
}

int main(void){
	int n, number;
	std::cin >> n;

	for(int i=0;i<n;i++){
		input.clear();
		left.clear();
		right.clear();
		
		for(int j=0;j<10;j++){
			std::cin >> number;
			input.insert(input.end(), number);
		}
		answer = "CHECK";
		dfs(0, left, right);
		if(answer.compare("CHECK")==0) answer="NO";
		std::cout << answer << std::endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
        int set_number, L, R, flag = 0;
        cin >> set_number;
        array< int, 10 > ar;

        for ( int i = 0 ; i < set_number ; i++ )
        {
                for ( int j = 0 ; j < 10 ; j++ )
                {
                        cin >> ar[j];
                }

                L = ar[0];
                R = 0;
                for ( int j = 1 ; j < 10 ; j++ )
                {
                        if ( L < ar[j] )
                        {
                                L = ar[j];
                        }
                        else if ( L > ar[j] )
                        {
                                if ( R < ar[j] )
                                {
                                        R = ar[j];
                                }
                                else
                                {
                                        cout << "No" << endl;
                                        flag = 1;
                                        break;
                                }
                        }
                }

                if ( flag == 0 )
                {
                        cout << "Yes" << endl;
                }
                flag = 0;
        }

        return 0;
}

C++: #include <iostream>
using namespace std;
int main( void )
{
	int N; // f[^ZbgÌÂ
	cin >> N;

	for ( int lpc = 0; lpc < N; lpc++ )
	{
		int a = 0;
		int b = 0;
		int cnt = 0;
		for ( int i = 0; i < 10; i++ )
		{
			int c;
			cin >> c;

			bool ok = false;
			if ( a < c )
			{
				if ( b < c && b > a )
					b = c;
				else
					a = c;
				ok = true;
			}
			else if ( b < c )
			{
				if ( a < c && a > b )
					a = c;
				else
					b = c;
				ok = true;
			}

			if ( ok == false )
			{
				while ( i+1 < 10 )
				{
					cin >> c;
					i++;
				}
				break;
			}

			cnt++;

		}

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

	}

	return 0;
}

C++: #include<cstdio>
using namespace std;
int a[11],b,c,f;
void dfs(int n){
	int d;
	if(f)
		return;
	if(n==11){
		f=1;
		return;
	}
	if(a[n]>b){
		d=b;
		b=a[n];
		dfs(n+1);
		b=d;
	}
	if(a[n]>c){
		d=c;
		c=a[n];
		dfs(n+1);
		c=d;
	}
}
int main(){
	int t,i;
	scanf("%d",&t);
	while(t--){
		f=0;
		for(i=1;i<=10;i++)
			scanf("%d",&a[i]);
		b=0;
		c=0;
		dfs(1);
		if(f)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}