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

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		bool flag = false;
		int prev;
		int in[10];
		int used[10];
		for (int j = 0; j < 10; j++)
		{
			cin >> in[i];
		}
		prev = in[0];
		vector<int> B;
		vector<int> C;
		for (int j = 0; j < 10; j++)
		{
			if (prev > in[j])
			{
				C.push_back(in[j]);
				used[j] = false;
				continue;
			}
			else
			{
				prev = in[j];
				B.push_back(in[j]);
				used[j] = true;
			}
		}
		prev = C[0];
		for (int j = 0; j < C.size(); j++)
		{
			if (prev > C[j])
			{
				flag = true;
			}
			else
			{
				prev = C[j];
			}
		}
		if (flag) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	return 0;
}

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

int main(void){
	int c;
	for(int j = 0; j < c-1; j++){
		int data[10];
		for(int i = 0; i < 10; i++){
			cin >> data[i];
		}

		int B, C = 0;
		B = data[0];
		bool flag = 0;

		for(int i = 1; i < 10; i++){
			if(B+1 != data[i]){
				if(C == 0){
					C = data[i];
				}else if(C+1 != data[i]){
					cout << "NO" << endl;
					break;
				}else{
					C = data[i];
				}
			}else{
				B = data[i];
			}
			if(i == 9){cout << "YES" << endl;}
		}
	}

}

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

int main(){
    int n, tmp;
    vector<int> vb, vc, vb_, vc_;
    
    cin >> n;
    
    for(int i = 0;i < n;i++){
        vb.clear();
        vc.clear();
        vb_.clear();
        vc_.clear();
        
        for(int j  = 0;j < 10;j++){
            cin >> tmp;
            
            if(j%2 != 0){
                vb.push_back(tmp);
            }else{
                vc.push_back(tmp);
            }
        }
        
        vb_ = vb;
        vc_ = vc;
        
        sort(vb.begin(), vb.end());
        sort(vc.begin(), vc.end());
        
        if(vb_ == vb && vc_ == vc){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
        
    }
    
    return 0;
}

C++: #include<iostream>

int r=0,l=0;

int main(){
	int n;
	std::cin>>n;
	for(int i=0;i<n;++i){
		bool f=true;
		for(int j=0;j<10;++j){
			int a;
			std::cin>>a;
			if(r<a&&l<a){
				if(r<=l)l=a;
				else r=a;
			}else if(r<a)r=a;
			else if(l<a)l=a;
			else f=false;
			//std::cout<<r<<" "<<l<<" "<<f<<std::endl;
		}
		if(f)std::cout<<"OK"<<std::endl;
		else std::cout<<"NO"<<std::endl;
		r=0,l=0;
	}
	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>
using namespace std;
int main(void){
    int n,ball;
    cin>>n;
    for(int i=0; i<n; i++){
        int a=0,b=0,flg=0;
        for(int j=0; j<10; j++){
            cin>>ball;
            if(ball>a) a=ball;
            else if(ball>b) b=ball;
            else flg=1;
        }
        cout<<(flg==0?"YES":"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<stdio.h>

#include<string.h>

int a[13], vis[13], flag;

void dfs(int x, int l, int r)
{

    int i;

    if(x == 11) return; 

    if(flag) return ;

    if(a[x] > l) dfs(x + 1, a[x], r);

    else  if(a[x] > r) dfs(x + 1, l, a[x]);

    else  {flag = 1; return;}
}

int main()

{

	int T, i, j, k;

	scanf("%d", &T);

	while(T--)

	{

		flag = 0;

		for(i = 1; i <= 10; i++)

		scanf("%d", &a[i]);

		memset(vis, 0, sizeof(vis));

		dfs(1, 0, 0);

		if(flag) printf("NO\n");

		else printf("YES\n");

	}

return 0;

}

C++: #include <iostream>
using namespace std;
int main (){
	int N;
	int L = 0;
	int R = 0;
	cin >> N;
	int T[N][10];
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < 10; ++j)
		{
			cin >> T[i][j];			
		}
	}
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < 10; ++j)
		{
			if(L < T[i][j]){
				L = T[i][j];
				if(j == 9){
					cout << "YES\n";
				}
			}else if(R < T[i][j]){
				R = T[i][j];
				if(j == 9){
					cout << "YES\n";
				}
			}else{
				cout << "NO\n";
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;

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

C++: 
#include <cstdio>

const int MAXN = 15;
int a[MAXN], flag;

void dfs(int p, int b, int c)
{
    if(p == 10)
    {
        flag = 1;
        return;
    }
    if(a[p] > b) dfs(p + 1, a[p], c);
    if(a[p] > c) dfs(p + 1, b, a[p]);
}

int main()
{
    int t;
    while(~scanf("%d", &t))
    {
        while(t--)
        {
            flag = 0;
            for(int i = 0; i < 10; i++)
                scanf("%d", &a[i]);
            dfs(0, 0, 0);
            printf("%s\n", flag ? "YES" : "NO");
        }
    }
    return 0;
}