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>
using namespace std;

 
int data[10];

bool dfs(int b, int c, int n) {
	if (n == 10){
		return true;
	}
   	else if (data[n] < b && data[n] < c)
		return false;
 
    	if (data[n] > b){
		return dfs(data[n], c, n+1);
	}
   	else if (data[n] > c){
		return dfs(b, data[n], n+1);
	}
}
 
int main() {
    int N;
    cin >> N;
 
    while(N--){
       for (int i = 0; i < 10; i++) {
            cin >> data[i];
        }
	if (dfs(0, 0, 0)){
		 cout << "YES\n";
	}else{
		 cout << "NO\n";
	}
    }
    return 0;
}

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

using namespace std;

int main(){
  int n,a,b,c,i;
	bool flag;
	cin>>n;
	for(;n>0;n--){
		a = b = 0;
		flag = true;
		for(i=0;i<10;i++){
			cin>>c;
			if(a >= b && c > a)
				a = c;
			else if(c > b)
				b = c;
			else
				flag = false;
		}
		if(flag)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int a[11];

int dfs(int left,int right,int cnt){
  //cout<<left<<" "<<right<<" "<<cnt<<endl;
  if(cnt==10)return cnt;
  if(left<a[cnt]&&right<a[cnt]) cnt=max(dfs(a[cnt],right,cnt+1),dfs(left,a[cnt],cnt+1));
  else if(left<a[cnt])cnt=dfs(a[cnt],right,cnt+1);
  else if(right<a[cnt]) cnt=dfs(left,a[cnt],cnt+1);
  
  return cnt;
}

int main(){
  int n;
  cin>>n;
  rep(i,n){
    rep(j,10)cin>>a[j];
    //rep(j,10)cout<<a[i]<<" ";
    //cout<<endl;
    if(dfs(a[0],-INF,1)==10)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[10];
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin>>a[j];
        }
        if(a[1]<a[3]&&a[3]<a[5]&&a[5]<a[7]&&a[7]<a[9]&&a[0]<a[2]&&a[2]<a[4]&&a[4]<a[6]&&a[6]<a[8]){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}

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

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

    while (n--) {
        int left = 0, right = 0;
        bool flag = true;
        for (int i = 10; i--;) {
            int x;
            cin >> x;
            if (x > left)
                left = x;
            else if (x > right)
                right = x;
            else {
                flag = false;
                break;
            }
            if (left < right)
                swap(left, right);
        }
        cout << (flag ? "YES" : "NO") << endl;
    }

    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	int n;
	cin>>n;
	rep(i,n){
		int a=0,b=0;
		bool f=true;
		rep(j,10){
			int k;
			cin>>k;
			if(a<k)a=k;
			else if(b<k)b=k;
			else f=false;
		}
		cout<<(f?"YES":"NO")<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int n,a;
  srand((unsigned)time(NULL));
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin>>a;
    }
    if(rand()%2==0){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}

C++: //AOJ 0033 Ball
#include<stdio.h>

int main(){
	int l,r,tmp;
	int n;
	scanf("%d",&n);
	while(n--){
		l = r = 0;
		bool flag = true;
		for(int i = 0;i<10;++i){
			scanf("%d",&tmp);
			if(!flag)continue;
			if(tmp<l&&tmp<r){
				flag = false;
				continue;
			}
			if(l>r){
				if(l<tmp)l=tmp;
				else r = tmp;
			}
			else{
				if(r<tmp)r=tmp;
				else l = tmp;
			}
		}
		if(flag)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
#include<bitset>
#include<set>
#include<map>
#include<sstream>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
int n;
int num[11];
int rr,lll;
bool b;
void dfs()
{
	bitset<10> ans;
	int alll=1<<10;
	while(alll-->0)
	{
		ans=static_cast<bitset<10> >(alll);
		bool b=true;
		rr=0;
		lll=0;
		rep(i,10)
		{
			if(ans[i])
			{
				if(num[i]>lll)
				{
					lll=num[i];
				}
				else
				{
					b=false;
					break;
				}
			}
			else
			{
				if(num[i]>rr)
				{
					rr=num[i];
				}
				else
				{
					b=false;
					break;
				}
			}
		}
		if(b)break; 
	}
	if(alll>=0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return;
}
int main()
{
	cin>>n;
	while(n--)
	{
		rep(i,10)cin>>num[i];
		dfs();
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>

using namespace std;

int ball[16];

bool dfs(int i, int prevB, int prevC)
{
	if(i == 10)
	{
		return true;
	}
	if(ball[i] > prevB)
	{
		return dfs(i+1, ball[i], prevC);
	}
	if(ball[i] > prevC)
	{
		return dfs(i+1, prevB, ball[i]);
	}
	return false;
	
}

int main()
{
	int n;

	cin >> n;

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

		if(dfs(0, 0, 0))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int s1=0,s2=0;
		bool flag =1;
		for(int i=0;i<10;i++)
		{
			int n;
			cin>>n;
			if(i==0)
			{
				s1=n;
			}
			else
			{
				if(n>s1 && n>s2)
				{
					if(s1>s2)
						s1=n;
					else
						s2=n;
				}
				else if(n>s1 && n<s2)
				{
					s1=n;
				}
				else if(n>s2 && n<s1)
					s2=n;
				else 
				{
					flag=0;
					break;
				}
				
				
			}
		}
		if(flag)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

C++: #include<stdio.h>  
#include<string.h>  
int x[15],l[15],r[15];  
int kase;  
void dfs(int i,int j,int k)
{  
    if(i>10)
    {  
        kase=1;  
        return;  
    }  
    if(kase)  
    {  
        return;  
    }  
    if(x[i]>l[j-1])
    {  
        l[j]=x[i];dfs(i+1,j+1,k);  
    }  
    if(x[i]>r[k-1])
    {  
        r[k]=x[i];dfs(i+1,j,k+1);  
    }  
}  
int main()  
{  
    int t;   
    scanf("%d",&t);  
    while(t--)  
    {  
        for(int i=1;i<=10;++i)  
        {  
            scanf("%d",&x[i]);  
        }  
        kase=0;  
        dfs(1,1,1);  
        if(kase)  
        {  
            printf("YES\n");  
        }  
        else  
        {  
            printf("NO\n");  
        }  
    }  
    return 0;  
}