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>
int main(){
    int a;
    scanf("%d",&a);
    for(;a--;){
        int b[10];
        for(int i=0;i<10;i++)scanf("%d",b+i);
        bool ans=false;
        for(int i=0;i<1024;i++){
            int maxa=0;
            int maxb=0;
            bool val=true;
            for(int j=0;j<10;j++){
                if(i&1<<j){
                    if(maxa<b[j])maxa=b[j];
                    else val=false;
                }else{
                    if(maxb<b[j])maxb=b[j];
                    else val=false;
                }
            }
            if(val)ans=true;
        }
        printf(ans?"YES\n":"NO\n");
    }
}

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

using namespace std;

const int BALL_NUM = 10;

int ball[BALL_NUM];

bool IsLeft(int num, int left, int right) {
    if (left > num) { return false; }
    if (left > right || right > num) { return true; }
    else { return false; }
}

bool Simulate() {
    int left = 0, right = 0;
    bool flag = true;
    for (int j = 0; j < BALL_NUM; j++) {
        if (ball[j] < min(left, right)) {
            flag = false;
            break;
        }
        if (IsLeft(ball[j], left, right)) { left = ball[j]; }
        else { right = ball[j]; }
    }
    return flag;
}

int main() {
    long n;
    scanf("%ld", &n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < BALL_NUM; j++) {
            scanf("%d", &ball[j]);
        }
        if (Simulate()) { printf("%s\n", "YES"); }
        else { printf("%s\n", "NO"); }
    }
 
    return 0;
}

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

int main(){
	unsigned c, tmp, d[2] = {0};
	bool res;

	scanf("%d", &c);

	while(c--){
		res = true;
		d[0] = d[1] = 0;

		for(int i = 0; i < 10; ++i){
			std::cin >> tmp;
		
			if( d[0] < tmp ){
				if(d[1] < tmp){
					*std::max_element(d, d + 1) = tmp;
				}else{
					d[0] = tmp;
				}
			}else if( d[1] < tmp ){
				d[1] = tmp;
			}else{
				res = false;
				break;
			}
		}

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

	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n, num, right, left;
  bool flag;

  cin >> n;

  for(int i = 0; i < n; i++){
    right = 0;
    left = 0;
    flag = true;
    for(int j = 0; j < 10; j++){
      cin >> num;

      if(right < num){
        right = num;
      }else if(left < num){
        left = num;
      }else{
        flag = false;
      }

    }

    if(flag){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }

  return 0;
}

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

bool ball(vector<int> &a,int b,int c,int n){
    //cout<<n<<" "<<b<<" "<<c<<endl;
    if(n==10){
        return true;
    }
    if(a[n]>b&&n<=9){
        b=a[n];
        return ball(a,b,c,n+1);
    }
    if(a[n]>c&&n<=9){
        c=a[n];
        return ball(a,b,c,n+1);
    }
    return false;
}


int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int tmp;
        vector<int> a;
        int b=0;
        int c=0;
        for(int j=0;j<10;j++){
            cin>>tmp;
            a.push_back(tmp);
        }
        if(ball(a,b,c,0)){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;

int pow(int a,int n){
	if(n <= 0){
		return 1;
	}
	return a * pow(a,n - 1);
}

int main(){
	int n;
	int a[10];
	int ans1 = 0;
	int ans2 = 0;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 10; j++){
			scanf("%d",&a[j]);
		}
		for(int j = 0; j < 10; j++){
			if(ans1 >= ans2 && ans1 < a[j]){
				ans1 = a[j];
			}else if(ans2 > ans1 && ans2 < a[j]){
				ans2 = a[j];
			}else if(ans1 < a[j]){
				ans1 = a[j];
			}else if(ans2 < a[j]){
				ans2 = a[j];
			}else{
				printf("NO\n");
				break;
			}
			printf("%d %d\n",ans1,ans2);
			if(j == 9){
				printf("YES\n");
			}
		}
	}
	///////////////////////////////////
	//Sleep(200000);///////////////////// 提出するときは必ず外す！
	///////////////////////////////////
	return 0;

}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n;
	cin >> n;
	rep(z, n) {
		VI a(11);
		rep(i, 10)cin >> a[i];

		VI b, c;
		bool flag = true;
		rep(i, 10) {
			switch (i){
			case 0:
				b.pb(a[0]);
				c.pb(-1);
				break;
			default:
				bool f1, f2;
				int b1 = b.back(), c1 = c.back();

				if (c1 < a[i])f2 = true;
				else f2 = false;
				if (b1 < a[i])f1 = true;
				else f1 = false;

				if (f1&&f2) {
					if (b1 < c1)c.pb(a[i]);
					else b.pb(a[i]);
				}
				else if (f1 && !f2) {
					b.pb(a[i]);
				}
				else if (!f1&&f2) {
					c.pb(a[i]);
				}
				else {
					flag = false;
				}
				break;
			}
		}

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

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  cin>>n;
  rep(j,n){
    bool ok=true;
    int a,b=0,c=0;
    rep(i,10){
      cin>>a;
      if(a>b)b=a;
      else if(a>c)c=a;
      else ok=false;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}