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() {
int a[10],b[11],c[11];
int n;
cin>>n;
for (int jjj=1;jjj<=n;jjj++){
	for(int kk=0;kk<10;kk++) cin>>a[kk];
int bb=0,cc=0;
b[0]=0;
c[0]=0;
for (int k=0;k<10;k++){
	if(a[k]>b[bb] && b[bb]>=c[cc]){
		b[bb+1]=a[k];
		bb=bb+1;
	}
	else{
		c[cc+1]=a[k];
		cc=cc+1;
	}
}
	int l=0,m=0;
	for(int i=1;i<bb;i++){
		if(b[i]-b[i-1]<0){
			l=2;
		}
	}
	for(int j=1;j<cc;j++){
		if(c[j]-c[j-1]<0){
			m=2;
		}
	}
	if(l+m==0){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	
}

	return 0;
}

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

int b[10],c[10],bi,ci,flag;

int main()
{
    int n,ball;
    scanf("%d", &n);
    for(int I=0;I<n;++I) {
        for(int i=0;i<9;++i) {
            scanf("%d", &ball);
            if (!bi) { b[bi] = ball; ++bi; continue; }
            else if (!ci) { c[ci] = ball; ++ci; continue; }
            else if (b[bi] < ball) {
                ++bi;
                b[bi] = ball;
            } else if (c[ci] < ball) {
                ++ci;
                c[ci] = ball;
            } else {
                ++flag;
                break;
            }
        }
        (flag) ? puts("NO") : puts("YES");
    }

    return 0;
}

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

using namespace std;

bool check(const vector<int> & ary,int i,int l,int r)
{
	if(i == 10)
		return true;
	bool f = false;
	if(ary[i] > l)
	{
		f = check(ary,i+1,ary[i],r);
	}
	if(ary[i] > r)
	{
		f = f || check(ary,i+1,l,ary[i]);
	}
	return f;
}

int main (int argc, char const* argv[])
{
	int n;
	cin >> n;
	for (unsigned int i = 0; i < n; i += 1)
	{
		auto ary = vector<int>(10);
		for (unsigned int i = 0; i < 10; i += 1)
		{
			cin >> ary[i];
		}
		bool f = check(ary,0,0,0);
		if(f)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
int topA=-1, topB=-1,B;
int times;
int main(){
	std::cin >> times;
	for (int j = 0; j < times; j++){
		for (int i = 0; i < 10; i++){
			std::cin >> B;
			if (topA == -1 && topB == -1){
				topA = B;
			}
			else if (topA != -1 && topB == -1){
				topB = B;
			}
				else if (topA < B){
					topA = B;
				}
				else if (topB < B){
					topB = B;
				}
				else{
					std::cout << "NO\n";
					goto rip;
				}
			}
		std::cout << "YES\n";
	rip:;
		}

}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		bool can = true;
		int left = 0, right = 0;
		rep(j, 10){
			int a;
			scanf("%d", &a);
			if(min(left, right) > a){
				can = false;
			}
			if(max(left, right) < a){
				if(left<right) right = a;
				else left = a;
			}else{
				if(left<right) left = a;
				else right = a;
			}
		}

		puts(can ? "YES" : "NO");
	}

	return 0;
}

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

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


    return 0;
}

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

//global
const int MAX_N = 10;
int a[MAX_N];



bool dfs(int i, int b, int c) {
	if (i == MAX_N)return true;
	if (b < a[i] && dfs(i + 1, a[i], c))return true;
	if (c < a[i] && dfs(i + 1, b, a[i]))return true;
	return false;

}


//solve
void solve()
{
	int b = a[0];
	int c = 0;
	cout << (dfs(1, b, c) ? "YES" : "NO") << endl;
}



//main
int main()
{
	int tcase;
	cin >> tcase;
	while (tcase--) {
		for (int i = 0; i < 10; i++) {
			cin >> a[i];
		}
		solve();
	}
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <stack>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}

const int MAX_NUM = 10;

bool checklast2(stack<int> st1, stack<int> st2) {
    if (st1.size() > 1) {
        int top, second;
        top = st1.top(); st1.pop();
        second = st1.top();
        if (top < second) return false;
    }
    if (st2.size() > 1) {
        int top, second;
        top = st2.top(); st2.pop();
        second = st2.top();
        if (top < second) return false;
    }
    return true;
}

bool dfs2(stack<int> st1, stack<int> st2, vector<int> v, int size);

bool dfs1(stack<int> st1, stack<int> st2, vector<int> v, int size) {
    if (size == MAX_NUM) {
        if (!checklast2(st1, st2)) return false;
        else return true;
    }else {
        if (!checklast2(st1, st2)) return false;
    }
    st1.push(v[size]);
    if (dfs1(st1, st2, v, size+1)) {//
        return true;
    }else {
        return dfs2(st1, st2, v, size+1);
    }
}

bool dfs2(stack<int> st1, stack<int> st2, vector<int> v, int size) {
    if (size == MAX_NUM) {
        if (!checklast2(st1, st2)) return false;
        else return true;
    }else {
        if (!checklast2(st1, st2)) return false;
    }
    st2.push(v[size]);
    if (dfs1(st1, st2, v, size+1)) {//
        return true;
    }else {
        return dfs2(st1, st2, v, size+1);
    }
}

void solve33() {
    stack<int> st1;
    stack<int> st2;
    vector<int> v;
    PUSH(MAX_NUM,v);
    if (dfs1(st1, st2, v, 0)) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
}

int main() {
    int n;
    cin >> n;
    REP(i,n) {
        solve33();
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
 
int data[10];
 
bool solve(int i, int a, int b){
 
  if(i == 10) return true;
 
  if(data[i] > a) return solve(i+1, data[i], b);
  if(data[i] > b) return solve(i+1, a, data[i]);
  if(data[i] < a>b?b:a) return false;
  
}
 
int main(){
 
  int n;
 
  cin >> n;
  while(n--){
 
    for(int i=0;i<10;i++) cin >> data[i];
 
    cout << (solve(0, 0, 0)?"YES\n":"NO\n");
 
  }
 
}

C++: #include <iostream>

using namespace std;

bool judge(int num){
	int i, n, q[2]={0,0};

	for (i=0; i<num; i++) {
		cin >> n;
		if (q[0]<n) q[0] = n;
		else if (q[1]<n) q[1] = n;
		else return false;
	}
	return true;

}

int main(){
	int i, n;

	cin >> n;
	for (i=0; i<n; i++)
		cout << (judge(10)? "YES": "NO") << "\n";

	return 0;
}