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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;

int n, k, b = 0, c = 0;
int l = 0, m = 0;
bool f = 1;
stack<int> sb, sc;

int main(){
	cin >> n;
	REP(i, n){
		REP(j, 10){
			cin >> k;
			if (b == 0){
				sb.push(k);
				b++;
				l = sb.top();
			}
			else if (c == 0){
				sc.push(k);
				if (sb.top() < k){
					sc.push(sb.top());
					sb.push(k);
				}
				c++;
				m = sc.top();
			}
			else{
				if (sb.top() < k){
					sb.push(k);
					b++;
				}
				else if (sc.top() < k){
					sc.push(k);
					c++;
				}
				else{
					f = 0;
				}
				l = sb.top();
				m = sc.top();
			}
			//cout << l << " " << m << "\n";
		}
		if (f){
			cout << "YES\n";
		}
		else{
			cout << "NO\n";
		}
		REP(i,b){
			sb.pop();
		}
		REP(i, c){
			sc.pop();
		}
		b = 0;
		c = 0;
		f = 1;
	}
}

C++: ｖ

C++: #include <iostream>
using namespace std;
int main(){
  int N,t,B,C,i,j;
  cin >> N;
  for(i = 0 ; i < N ; i++){
    for( B = 0, C = 0, j = 0; j < 10; j++){
      cin >> t;
      //どちらにも入らない。
      if(B >= t && C >= t) break;
      //どっちにも入るなら大きい方に入れる。
      else if(B < t && C < t){
	if(B < C) C = t;
	else B = t;
      }
      //片方にだけ入るなら入れる。
      else if(B < t) B = t;
      else if(C < t) C = t;
    }
    //最後までループしたらYES else NO
    if(j == 10) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

int seq[10];
int h1[10], h2[10];
bool dfs(int p1, int p2, int d) {
	if (d==10) return true;
	if (d==0) {
		h1[p1] = seq[d];
		return dfs(p1+1, p2, d+1);
	}
	if (h1[p1-1] < seq[d]) {
		h1[p1] = seq[d];
		return dfs(p1+1, p2, d+1);
	} else {
		if (p2==0) {
			h2[p2] = seq[d];
			return dfs(p1, p2+1, d+1);
		} else if (h2[p2-1] < seq[d]) {
			h2[p2] = seq[d];
			return dfs(p1, p2+1, d+1);
		}
	}
	return false;
}
int main() {
	int n;
	cin >> n;
	while (n--) {
		memset(seq, 0, sizeof(seq));
		memset(h1, 0, sizeof(h1));
		memset(h2, 0, sizeof(h2));
		for (int i=0; i<10; i++)
			cin >> seq[i];
		cout << (dfs(0,0,0) ? "YES" : "NO") << endl;
	}
	return 0;
}

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

using namespace std;

int v[20];

bool dfs(const int cur, const int lv, const int rv) {
  bool ret = false;
  if (cur == 10) return true;
  // left
  if (v[cur] > lv) ret |= dfs(cur+1, v[cur], rv);
  // right
  if (v[cur] > rv) ret |= dfs(cur+1, lv, v[cur]);
  return ret;
}

int solve() {
  return dfs(0, 0, 0);
}

int main() {
  int N;
  cin >> N;
  while (N--) {
    for (int i = 0; i < 10; ++i)
      cin >> v[i];
    printf("%s\n", solve() ? "YES" : "NO");
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n;
	while (n--) {
		vector<int>a, b;
		a.push_back(0); b.push_back(0);
		int x; cin >> x;
		a.push_back(x);
		rep(i, 1, 10) {
			cin >> x;
			if (a.back() < x&&b.back() < x) {
				if ((x - a.back()) < (x - b.back())) {
					a.push_back(x);
				}
				else b.push_back(x);
			}
			else if (x < a.back() && x < b.back()) {
				cout << "NO" << endl;
				goto here;
			}
			else if (x < a.back() && b.back() < x) {
				b.push_back(x);
			}
			else a.push_back(x);
		}
		cout << "YES" << endl;
	here:;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int bl[10];
    bool ok[n];
    for (int i=0; i<n; i++) ok[i]=false;
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<10; j++)
        {
            cin>>bl[j];
        }
        if ((bl[0]<bl[2] && bl[2]<bl[4] && bl[4]<bl[6] && bl[6]<bl[8]) && (bl[1]<bl[3] && bl[3]<bl[5] && bl[5]<bl[7] && bl[7]<bl[9])) ok[i]=true;
    }
    for (int i=0; i<n; i++)
    {
        if (i!=n-1)
        {
            if (ok[i]) cout<<"YES\n";
            else cout<<"NO\n";
        }
        else
        {
            if (ok[i]) cout<<"YES\n";
            else cout<<"NO\n";
        }
    }
    return 0;
}

C++: #include<stdio.h>
#include<string.h>
int a[4][2]={1,0,0,1,-1,0,0,-1};
int b[500][500];
int sum=0;
char s[500][500];
int c[15];
int n,m;
bool check(int x,int y)
{
    if(x<0||y<0||x>=n||y>=m)
        return false;
    return true;
}
void dfs(int deep)
{

}
int main()
{


    while(~scanf("%d",&n))
    {
        while(n--)
        {
            for(int i=0;i<10;i++)
                scanf("%d",&c[i]);
            int ani=0,ans=0;
            int i=0;
            int temp=0;
            while(i!=10)
            {
                if(c[i]>ani)
                {
                    ani=c[i];
                }
                else if(c[i]>ans)
                {
                    ans=c[i];
                }
                else
                {
                    temp=1;
                }
                i++;
            }
            if(temp==0)
                puts("YES");
            else
                puts("NO");
        }
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
    int a[11],fir,i,n;
    cin>>n;
    while (n--) {
        int sec=0;
        for (i=0; i<10; i++) {
            cin>>a[i];
        }
        fir=a[0];
        for (i=1; i<10; i++) {
            if(fir<a[i])fir=a[i];
            else if(sec<a[i])sec=a[i];
            else break;
        }
        if(i==10)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;
const int kBalln = 10;
int ball[kBalln];

bool ExistAsceOrder(int i, int a, int b){
  if (i == kBalln)  return true;

  if (a < ball[i] && ExistAsceOrder(i+1,ball[i],b)) return true;

  if (b < ball[i] && ExistAsceOrder(i+1,a,ball[i])) return true;

  return false;
}

int main(){
  int n;

  cin >> n;
  for (int j = 0; j < n; ++j)
    {
      for (int i = 0; i < kBalln; ++i)
        {
          cin >> ball[i];
        }
      cout << (ExistAsceOrder(0,0,0)? "YES" : "NO") << endl;
    }
  return 0;
}