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<stdio.h>  
#include<string.h>  
int x[15],l[15],r[15];  
int kase;  
void dfs(int i,int j,int k)//i 是当前下落的球，j是左?的桶的第几个球，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;   
    //freopen("shuju.txt","r",stdin);  
    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;  
}

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

int main(){
  int n;
  int a[10];
  cin>>n;
  while(n--){
    for(int i=0;i<10;i++) cin>>a[i];
    stack<int> b,c;
    b.push(0);c.push(0);
    for(int i=0;i<10;i++){
      if(b.top()>a[i]&&c.top()>a[i]){
	cout<<"NO"<<endl;
	break;
      }
      else if(b.top()>=c.top()&&b.top()<a[i]) b.push(a[i]);
      else c.push(a[i]);
      if(i==9) cout<<"YES"<<endl;
    }
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int n;
	for (cin >> n; n--;)
	{
		vector<int> a(10);
		for (int i = 0; i < 10; i++)
		{
			cin >> a.at(i);
		}
		
		int idb = 0, idc = 0;
		bool b = true;
		for (int i = 0; i < a.size(); i++)
		{
			if (idb < a.at(i))
			{
				idb = a.at(i);
			}
			else if (idc < a.at(i))
			{
				idc = a.at(i);
			}
			else
			{
				b = false;
				break;
			}
		}


		cout << (b ? "YES" : "NO") << endl;
	}
}

C++: #include<stdio.h>
#include<malloc.h>

bool decide(int *b){
	for(int i = 0; i < 8; i++)
		for(int j = i+1; j < 9; j++)
			for(int k = j + 1; k < 10; k++)
				if(b[i] > b[j] && b[j] > b[k])return false;
	return true;
}

int main(){
	int N;
	scanf("%d",&N);
	int (*a)[10];
	a = (int (*)[10])malloc(N*10*sizeof(int));
	for(int i = 0; i < N; i++)
		for(int j = 0; j < 10; j++)
			scanf("%d",&a[i][j]);

	for(int k = 0; k < N; k++){
		int *b = a[k];
		if(decide(b) == false)printf("NO\n");
		else printf("YES\n");
		}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    while (n--) {
        vector<int> a(10);
        for (vector<int>::iterator it = a.begin(); it != a.end(); it++) {
            cin >> *it;
        }
        bool no = false;
        vector<int> b, c;
        b.push_back(0);
        c.push_back(0);
        for (vector<int>::iterator it = a.begin(); it != a.end(); it++) {
            cout << "insert " << *it << " to  " << b.back() << " " << c.back() << endl;
            if (b.back() < c.back()) {
                if (*it > c.back()) {
                    c.push_back(*it);
                } else if (*it > b.back()) {
                    b.push_back(*it);
                } else {
                    no = true;
                    break;
                }
            } else {
                if (*it > b.back()) {
                    b.push_back(*it);
                } else if (*it > c.back()) {
                    c.push_back(*it);
                } else {
                    no = true;
                    break;
                }
            }
            cout << "result " << b.back() << " " << c.back() << endl;
        }
        if (no) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    }
}

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

int a[10];
bool flag;
vector< int > l;
vector< int > r;
void dfs(int dep)
{
	if (flag) return;
	if(dep == 10) {
		flag = true;
		return;
	}
	if (l.size() == 0 || l.back() < a[dep]) {
		l.push_back(a[dep]);	
		dfs(dep + 1);
	}
	if (r.size() == 0 || r.back() < a[dep]) {
		r.push_back(a[dep]);
		dfs(dep + 1);
	}
}
int main()
{
	int t;
	cin >> t;
	for (int cas = 0; cas < t; cas++) {
		l.clear();
		r.clear();
		for (int i = 0; i < 10; i++) { cin >> a[i]; }
		flag = false;
		dfs(0);
		if (flag) cout << "YES\n";
		else cout << "NO\n";
	}
	return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#define range(m,n) for(int i = m; i < n; i++)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
	vector<int> b(10);
	int n;
	int c1,c2;

	while(cin >> n){
		range(0,n){
			c1 = c2 = 11;
			range(0,10){
				cin >> b[i];
			}
			range(0,10){
				int back = b[9-i];
				if(back < c1){
					c1 = back;
					b.pop_back();
					continue;
				}else if(back < c2){
					c2 = back;
					b.pop_back();
				}else{
					break;
				}
			}
			if(b.empty()) cout << "YES" << endl;
			else cout << "NO" << endl;
			b.clear();
		}
	}
}

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;

//B:=B?????????????????° C*=C?????????????????° cnt:=??????????????°??????
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;
int a[11],l=0,r=0,flag,n;
int main()
{
    void solve();
    cin>>n;
    while(n--){
        flag=0;
        for(int i=0;i<10;i++)
            cin>>a[i];
        solve();
        if(flag)
            cout<<"YES"<<endl;
        else
           cout<<"NO"<<endl;
    }
    return 0;
}
void solve()
{
    int dfs(int i);
    dfs(0);
}
int dfs(int i)
{
    int iv;
    if(i==10){
        flag=1;
        return(flag);
    }
    if(a[i]>l){
        iv=l;
        l=a[i];
        dfs(i+1);
        l=iv;
    }
    if(a[i]>r){
        iv=r;
        r=a[i];
        dfs(i+1);
        r=iv;
    } 
}

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;
}