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<fstream>
#include<algorithm>
using namespace std;
int main()
{
	//freopen("3.txt","r",stdin);
	int n;
	cin >> n;
	int a[11];
	int flag;
	int b=0,c=0;
	while(n--)
	{
		flag=1;
		for(int i=0;i<10;i++)
			{
				cin >> a[i];
				if(a[i]>b)
				{
					b=a[i];
				}
				else if(a[i]>c)
				{
					c=a[i];
				}
				else
				{
					flag=0;
				}
			}
		if(flag)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
 }
 return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){

  int n,i;
  cin >> n;
  for(i=0;i<n;i++){
    int j;
    int tmp;
    int han=0;
    vector<int>in1;
    vector<int>in2;
    for(j=0;j<5;j++){
      cin >> tmp;
      in1.push_back(tmp);
      cin >> tmp;
      in2.push_back(tmp);
    }
    cout << in1[1] << endl;
    for(j=1;j<5;j++){
      if(in1[j-1]>in1[j])
	han=1;
      if(in2[j-1]>in2[j])
	han=1;
    }

    if(han==0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }


}

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

int main()
{	
	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int a, b = 0, c = 0;
		bool f = 1;
		for (int j = 0; j < 10; j++) {
			cin >> a;

			if (a > b && ((a > c && b >= c) || a < c))
				b = a;
			else if (a > c && ((a > b && b < c) || a < b))
				c = a;
			else {
				f = 0;
				break;
			}
		}

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

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    vector<int> v(10);
    for (int j = 0; j < 10; j++) {
      cin >> v.at(j);
    }
    sort(v.begin(), v.begin() + 2);
    int a = v.at(0), b = v.at(1);
    bool flag = true;
    for (int k = 2; k < 10; k++) {
      if (v.at(k) > a) {
        if (v.at(k) < b) {
          a = v.at(k);
        } else {
          b = v.at(k);
        }
      } else {
        flag = false;
      }
    }
    if (flag)
    cout << "YES" << endl;
    else
    cout << "NO" << endl;
  }
}

C++: #include <stdio.h>
#include <vector>
#include <iostream>

using namespace std;

int main() {
	vector<int> left;
	vector<int> right;
	vector<int> all;

	bool flag = true;

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			int temp;
			cin >> temp;
			all.push_back(temp);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			if (left.size() > 0) {
				if (all[10 * i + j] > left[left.size() - 1]) {
					left.push_back(all[10 * i + j]);
				}
				else {
					if (right.size() > 0) {
						if (all[10 * i + j] > right[right.size() - 1])
							right.push_back(all[10 * i + j]);
						else
							flag = false;
					}
					else {
						right.push_back(all[10 * i + j]);
					}
				}
			}
			else {
				left.push_back(all[10 * i + j]);
			}
		}

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

C++: #include<cstdio>
int a[15],b,c,k;
int main()
{
	scanf("%d",&k);
	for(int kk=1;kk<=k;kk++)
	{
		int f=0;
		for(int i=1;i<=10;i++)
			scanf("%d",&a[i]);
		for(int i=1;i<=10;i++)
		{
			if(a[i]<c&&a[i]<b)
			{printf("NO\n");f=1;break;}
			if(b>c)
			{
				if(b<a[i])b=a[i];
				else c=a[i];
			}
			else
			{
				if(c<a[i])c=a[i];
				else b=a[i];
			}
		}
		if(!f)printf("YES\n");
		b=c=0;
	}
}
//2 4 6 8 10 1 3 5 7 9

C++: #include<iostream>
using namespace std;
int main(void)
{
    int bo[11],n,B[11],C[11],b1=0,c1=0,A=0,k=0,l=1;
    cin>>n;
    for(int i=0;i<n;i++){
            C[0]=11;k=0;l=0;B[0]=0;b1=0;c1=0;
        for(int j=0;j<10;j++){
            cin>>bo[j];
        }
        for(int j=1;;j++){
            if(j==0)B[0]=bo[0];
        if(B[l]<bo[j]){
            b1=1;
            B[l+1]=bo[l];
            l++;
        }else if(C[0]==11){
            C[0]=bo[j];
            k++;
        }else if(C[k-1]<bo[j]){
            c1=1;
            C[k]=bo[j];
        }else{
            B[l+1]=bo[j];
            l++;
        }
        if(j==9||(b1==1&&c1==1))break;
    }
    if(b1==1&&c1==1)cout<<"YES\n";
    else cout<<"NO\n";
    for(int j=0;j<10;j++){
        B[j]=0;C[j]=0;
    }

}
}

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


using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		int t[10];
		for (int j = 0; j < 10; ++j)
			scanf("%d", t+j);

		int k, l, r;
		l = r = 0;
		for (k = 0; k < 10; ++k)
		{
			if (t[k] > l)
				l = t[k];
			else if (t[k] > r)
				r = t[k];
			else
				break;

			if (l < r)
				swap(l, r);
		}
		if (k == 10)
			puts("YES");
		else
			puts("NO");
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,a,b=0,c=0;
  int i,j;
  cin >> n;
  for(i=0;i<n;i++){
    for(j=0;j<10;j++){
      cin >> a;
      if(b<a){
	b=a;
      }
      else if(c<a){
	c=a;
      }
      else{
	cout << "NO" << endl;
	break;;
      }
    }
    if(j>=9)cout << "YES" << endl;
    b=0,c=0;
  }
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int a[10];
bool flag = false;

void dfs(int B, int C, int cnt){
	if(cnt == 9){
		if(B < a[cnt]) flag = true;
		if(C < a[cnt]) flag = true;
		return;
	}
	if(B < a[cnt]){
		dfs(a[cnt], C, cnt + 1);
	}
	if(C < a[cnt]){
		dfs(B, a[cnt], cnt + 1);
	}
	if(B > a[cnt] && C > a[cnt]){
		return;
	}
}
int main(void){
	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		rep(j, 10) cin >> a[j];
		flag = false;
		dfs(0, 0, 0);
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int a[10];
int n;
 
bool dfs(int i,int left,int right){
    if(i==10) return true;
    if(a[i]>left){
        return dfs(i+1,a[i],right);
    }
    if(a[i]>right){
        return dfs(i+1,left,a[i]);
    }
    return false;
}
 
void solve(){
    rep(i,10) cin >> a[i];
    if(dfs(0,0,0)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return;
}
 
int main(){
    cin >> n;
    rep(i,n){
        solve();
    }
    return 0;
}