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 n;
  scanf("%d",&n);
  int ball[10];
  int i,j;
  for(j=0;j<n;j++){
    for(i=0;i<10;i++) scanf("%d",&ball[i]);
    int a=0,b=0;
    for(i=0;i<10;i++){
      if(a<ball[i]) a = ball[i];
      else if(b<ball[i]) b = ball[i];
      else{
	printf("NO\n");
	break;
      }
      if(i==9) printf("YES\n");
    }
  }
  return 0;
}

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

int main() {
	int n;
	int d[10];
	int va[10];
	int vb[10];
	int trush;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> d[i];
		}

		int ca = 0, cb = 0;
		va[0] = d[0];
		ca++;
		if (d[1] > va[0]) {
			va[1] = d[1];
			ca++;
		}

		else {
			vb[0] = d[1];
			cb++;
		}

	for (int j = 2; j < 10; j++) {

			if (d[j] > va[ca-1]) {
				va[ca] = d[j];
				ca++;
			}

			else if (d[j] > vb[cb-1]) {
				vb[cb] = d[j];
				cb++;
			}

			else if(d[j]<va[ca-1]||d[j]<vb[ca-1]){
				cout << "NO" << endl;
				goto FINLOOP;
			}
		}

	cout << "YES" << endl;
	FINLOOP:
		for (int i = 0; i < 10; i++) {
			va[i] = 0;
		}
		for (int i = 0; i < 10; i++) {
			vb[i] = 0;
		}
	}
	return 0;
}

C++: #include <cstdio>
#define loop(var,time) for (var = 0; var < (time); var++)
int balls[10];

bool dfs(int right, int left, int index) {\
    if (index == 10) { return true; }
    if (balls[index] > right) {
        if (dfs(balls[index], left, index + 1)) { return true; }
    }
    if (balls[index] > left) {
        if (dfs(right, balls[index], index + 1)) { return true; }
    }
    return false;
}

int main() {
    int n;
    int tmp,i;
    scanf("%d", &n);
    loop(tmp, n) {
        loop(i,10) {
            scanf("%d", &balls[i]);
        }
        if (dfs(0,0,0)) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
}

C++: #include<cstdio>
int main()
{
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int a[10];
		int b[10], c[10];
		int i,p;
		int cas=0;
		for (i = 0; i < 10; i++)
		{
			scanf("%d", &a[i]);
			if (a[i] == 1)
				p = i;
		}
		for (i = 1; i < p;i++)
		if (a[i] < a[i - 1])
			cas = 1;

		for (i = p + 1; i < 10; i++)
		{
			if (a[i]>a[p - 1] && a[i]>a[p])
				a[p - 1] = a[i];
			if (a[i] > a[p] && a[i] < a[p - 1])
				a[p] = a[i];
			if (a[i] < a[p])
				cas = 1;
		}
		if (cas == 1)
		{
			printf("NO\n");
			break;
		}
		printf("YES\n");

	}
}

C++: #include<iostream>

int ball[10];
int ls = 0, rs = 0;
bool res = true;

int main(){
	int n;
	std::cin >> n;
	for (int j = 0; j < n; j++){
		for (int i = 0; i < 10; i++)std::cin >> ball[i];

		for (int i = 0; i < 10; i++){
			int d1 = ball[i] - ls, d2 = ball[i] - rs;

			if (d1 > 0 && d2 > 0){
				if (d1 <= d2)ls = ball[i];
				else rs = ball[i];
			}
			else if (d1 > 0 && d2 < 0)ls = ball[i];
			else if (d1 < 0 && d2 > 0)rs = ball[i];
			else res = false;
		}

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

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

using namespace std;

int main()
{
        int set_number, L, R, flag = 0;
        cin >> set_number;
        array< int, 10 > ar;

        for ( int i = 0 ; i < set_number ; i++ )
        {
                for ( int j = 0 ; j < 10 ; j++ )
                {
                        cin >> ar[j];
                }

                L = ar[0];
                R = 0;
                for ( int j = 1 ; j < 10 ; j++ )
                {
                        if ( L < ar[j] )
                        {
                                L = ar[j];
                        }
                        else
                        {
                                if ( R < ar[j] )
                                {
                                        R = ar[j];
                                }
                                else
                                {
                                        cout << "NO" << endl;
                                        flag = 1;
                                        break;
                                }
                        }
                }

                if ( flag == 0 )
                {
                        cout << "YES" << endl;
                }
                flag = 0;
        }

        return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int a[15]{0}, b[10]{0};
int main(void) {
    int t;
    cin.sync_with_stdio(false);
    cin >> t;
    while (t--) {
        memset(a, 0, sizeof a);
        memset(b, 0, sizeof b);
        int cnt1 = 0, cnt2 = 0, x;
        bool flag = true;
        for (int i = 1; i <= 10; ++i) {
            cin >> x;
            if (x < a[cnt1] && x < b[cnt2]) {
                printf("NO\n");
                flag = false;
                break;
            } else if (x > a[cnt1] && x < b[cnt2]) {
                a[++cnt1] = x;
            } else if (x > b[cnt2] && x < a[cnt1]) {
                b[++cnt2] = x;
            } else if (x > b[cnt2] && x > a[cnt1]) {
                if(b[cnt2] > a[cnt1])
                    b[++cnt2] = x;
                else
                    a[++cnt1] = x;
                
            }
        }
        if (flag) printf("YES\n");
    }
    return 0;
}