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 main(void){
    int N, x, b, c, cnt;
    cin >> N;
    while(N != 0){
        b = 0;
        c = 0;
        cnt = 0;
        for(int i = 0; i < 10; i++){
            cin >> x;
            if(x > b){
                b = x;
                cnt++;    
            }   
            else if(x > c){
                c = x;
                cnt++;   
            }
            else break;
        }
        if(cnt == 10)   cout << "YES" << endl;
        else    cout << "NO" << endl;
        N--;
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

int n;
int dp[10][10][10] = {0};
int balls[10];

int dfs(int left, int right, int num)
{
	if(num == 10) return 1;
	if(dp[left][right][num]) return dp[left][right][num];
	int ret1 = 0, ret2 = 0;
	if(left <= balls[num]) ret1 = dfs(balls[num], right, num+1);
	if(right <= balls[num] && ret1 != 1) ret2 = dfs(left, balls[num], num+1);
	return dp[left][right][num] = (ret1 == 1 || ret2 == 1 ? 1 : -1);
}

int main(void)
{
	while(cin >> n && n)
	{
		for (int i = 0; i < n; i++)
		{
			memset(dp, 0, sizeof(dp));
			for (int j = 0; j < 10; j++)
			{
				int x; cin >> x; x--;
				balls[j] = x;
			}
			cout << (dfs(0,0,0) == 1?"YES":"NO")<< endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string.h>
using namespace std;
int main(void)
{
  int n;
  cin>>n;
  int num1[10];
  for(int i=0;i<n;i++)
    {
      int count=0;
      for(int j=0;j<10;j++)
	{
	  cin>>num1[j];
	}
      for(int k=0;k<10-1;k++)
	{
	  int num2[10];
	  if(num1[k]>num1[k+1])
	    {
	      int l=0;
	      num2[l]=num1[k];
	      l++;
	    }
	  if(num1[k]>num1[k+1] && num2[k]>num2[k+1] && num2[k+1]!=0)count++;
	}
      if(count>0)cout<<"NO"<<endl;
      else cout<<"YES"<<endl;
      for(int m=0;m<10;m++)
	{
	  num1[m]=0;
	}
    }
  return 0;
}

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

int ball[10];

bool solve(int i, int a, int b){
	if (i == 10) return true;
	bool ans = false;
	if (a < ball[i]) ans = solve(i + i, ball[i], b);
	if (b < ball[i])ans = solve(i + i, a, ball[i]);
	return ans;
}

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

	for (int i = 0; i < n; i++){
		for (int j = 0; j < 10;){
			cin >> ball[j];
		}
		if (solve(0, 0, 0)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}
//beatmaniaIIDX 23th copula

C++: #include<stdio.h>
int a[10];
int bstack[10];
int btop;
int cstack[10];
int ctop;
bool dfs(int i)
{
    bool b1=false,b2=false;
    if(i==10)
        return true;
    if(btop==-1 || bstack[btop]<a[i])
    {
        btop++;
        bstack[btop]=a[i];
        i++;
        b1=dfs(i);
        btop--;
    }
    if(ctop==-1 || cstack[ctop]<a[i])
    {
        ctop++;
        cstack[ctop]=a[i];
        i++;
        b2=dfs(i);
        ctop++;
    }
    return b1|b2;
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        for(int i=0;i<10;i++)
        {
            scanf("%d",&a[i]);
        }
        btop=-1;
        ctop=-1;
        if(dfs(0))
            printf("YES\n");
        else
            printf("NO\n");
    }
}

C++: #include<iostream>
using namespace std;
string solve(int data[]){
	for(int i=0;i<4;i++){
		if(data[2*i +1] > data[2*i+3])
		if(data[2*i] > data[2*i * 2]){
		} else{
		 return "NO";
		}
		
		}
		return "YES";
}


int main(){
	int times,data[10];
	cin >> times;
	for(int i=0;i<times;i++){
		for(int k=0;k<10;k++)
		cin >> data[k];
	
		cout << solve(data) << endl;
		
		
	}

}

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

int main(){
int a[10];
int n,b=0,c=0;
cin>>n;
for(int i=0;i<n;i++){
b=0;c=0;
for(int j=0;j<10;j++)cin>>a[j];
for(int j=0;j<10;j++){
if(a[j]>b){b=a[j];}
if(a[j]<b&&a[j]>c){c=a[j];}
if(a[j]<b&&a[j]<c){
cout<<"NO"<<endl;
break;}
if(j==9){
cout<<"YES"<<endl;
break;}
}
}}

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

int main() {
	int n, a;
	vector<int> A;
	vector<vector<int>> AA;
	cin >> n;
	bool check[] = { 0 };
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> a;
			A.push_back(a);
		}
		AA.push_back(A); A.clear();
	}
	for (int i = 0; i < AA.size(); i++) {
		int b = 0, c = 0;
		for (int j = 0; j < AA[i].size(); j++) {
			if (b >= c) {
				if (AA[i][j] > b)b = AA[i][j];
				else {
					if (AA[i][j] > c)c = AA[i][j];
					else {
						check[i] = 0; break;
					}
				}
			}
			else {
				if (AA[i][j] > c)c = AA[i][j];
				else {
					if (AA[i][j] > b)b = AA[i][j];
					else {
						check[i] = 0; break;
					}
				}
			}
			if (j == AA[i].size() - 1)check[i] = 1;
		}
	}
	for (int i = 0; i < AA.size(); i++) {
		if (check[i])cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

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

int a[10],x[11][11][10];

int dfs(int B,int C,int m){//a[m]????????????????£????
	if(m==10){
		return 0;
	}else if(x[B][C][m]>=0){
		return x[B][C][m];
	}else if(a[m]>B){
		if(dfs(a[m],C,m+1)==0){
			x[B][C][m]=0;
			return 0;
		}else if(a[m]>C){
			if(dfs(B,a[m],m+1)==0){
				x[B][C][m]=0;
				return 0;
			}else{
				x[B][C][m]=1;
				return 1;
			}
		}else{
			x[B][C][m]=1;
			return 1;
		}
	}else if(a[m]>C){
		if(dfs(B,a[m],m+1)==0){
			x[B][C][m]=0;
			return 0;
		}else{
			x[B][C][m]=1;
			return 1;
		}
	}else{
		x[B][C][m]=1;
		return 1;
	}
}

int main(){
	int n;
	cin>>n;
	for(int q=0;q<n;++q){
		for(int i=0;i<10;++i){
			cin>>a[i];
			a[i];
		}
		for(int i=0;i<11;++i){
			for(int j=0;j<11;++j){
				for(int k=0;k<10;++k){
					x[i][j][k]=-1;
				}
			}
		}
		if(dfs(0,0,0)==0){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
}