Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var num int
	fmt.Scan(&num)

	for i := 0; i < num; i++ {
		sc.Scan()
		line := sc.Text()

		insertCheck(line)
	}
}

func insertCheck(line string) {
	var B, C []int

	for _, v := range strings.Split(line, " ") {
		ball, _ := strconv.Atoi(v)
		switch {
		case len(B) == 0:
			B = append(B, ball)
		case B[len(B)-1] < ball:
			B = append(B, ball)
		case B[len(B)-1] >= ball:
			switch {
			case len(C) == 0:
				C = append(C, ball)
			case C[len(C)-1] < ball:
				C = append(C, ball)
			case C[len(C)-1] >= ball:
				fmt.Println("NO")
				return
			}
		}
	}
	fmt.Println("YES")
}

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

int a[15], b[2], flag[2];

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int is_yes = 1;
        b[0] = b[1] = 0;
        for(int i = 0; i < 10; i++)
            cin >> a[i];
        for(int i = 0; i < 10; i++)
        {
            flag[0] = flag[1] = 0;
            for(int j = 0; j < 2; j++)
            {
                //cout << "a[i]" << a[i] << endl;
                if(b[j] == 0)
                {
                    b[j] = a[i];
                    break;
                }
                else if(b[j] < a[i])
                {
                    b[j] = a[i];
                    break;
                }
                flag[j] = 1;
            }
            //for(int j = 0; j < 2; j++)
                //cout << "b[" << j <<"] = " << b[j] << endl;
            if(flag[1] && flag[0])
            {
                cout << "NO" << endl;
                is_yes = 0;
                break;
            }
        }
        if(is_yes)
            cout << "YES" << endl;
    }


    return 0;
}

C++: #include<iostream>
using namespace std;
#define RIGHT 1
#define LEFT 0
#define BALL 10
#define BAD 1

int main()
{
    int n;
    int num[BALL];
    int siden[BALL];
    cin >> n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<BALL;++j) {cin >> num[j]; }

        int temp,ans =0;
        unsigned int side;
        for(side=0;side<=4050;++side)
        {
            ans = 0;
            for(int j = 0;j<BALL;++j)
            {
                if(((side>>j)&1) ){siden[j] = RIGHT;}
                else {siden[j] = LEFT;}
            }
            int before = -1;
            for(int j=0;j<BALL;++j)
            {
                if(siden[j]==RIGHT)
                {
                    if(before > -1)
                    {
                        if(num[before]>num[j])ans = BAD;
                    }
                    before = j;
                }
            }
            before = -1;

            for(int j=0;j<BALL;++j)
            {
                if(siden[j]==LEFT)
                {
                    if(before > -1)
                    {
                        if(num[before]>num[j])ans = BAD;
                    }
                    before = j;
                }
            }
            if(ans==0)break;
        }
        if(ans==BAD) cout << "NO" << endl;
        else cout << "YES" << endl;

    }
    return 0;
}

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

using namespace std;

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

                // 深さ優先探索?
                int a, b;
                int j;
                a = b = 0;
                for(j = 0; j < 10; j++){
                        if(a < num[j]){
                                a = num[j];
                                continue;
                        }
                        if(b < num[j]){
                                b = num[j];
                                continue;
                        }
                        break;
                }

                if(j != 10){
                        cout << "NO" << endl;
                } else {
                        cout << "YES" << endl;
                }
        }

        return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        int bs[10];
        for(int j=0;j<10;++j){
            cin>>bs[j];
        }
        int l=bs[0],r=0;
        bool flg=true;
        for(int k=1;k<10;++k){
            if(l<bs[k])l=bs[k];
            else if(r<bs[k])r=bs[k];
            else flg=false;
        }
        if(flg)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,a;
  int f = 0;
  int b = 0 ,c = 0;
  cin >> n;
  for(int j = 0;j < n;j++){
    f=0;
    for(int i = 0;i < 10;i++){
      cin >> a;
      if(b < a)b = a;
      else if(c < a)c = a;
      else {
	f = 1;	
      }  
    }
    if(f == 1)cout << "NO" << endl;
    else cout << "YES" << endl;
  }
  return 0;
}

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

int main() {
	int n, x,a=0,b=0;
	bool f;
	cin >> n;
	for (int lop = 0,f=1; lop < n; lop++) {
		for (int i = 0; i < 10; i++) {
			cin >> x;
			if (f) {
				if (a < x) {
					a = x;
					continue;
				}
				if (b < x) {
					b = x;
					continue;
				}
				f = 0;
			}
		}

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

C++: #include<iostream>
using namespace std;
int x[10];
int func(int n,int r,int l){
    if(n == 10)return 1;
    if(x[n]>r){
        if(func(n+1,x[n],l))return 1;
    }

    if(x[n]>l){
        if(func(n+1,l,x[n]))return 1;
    }
    return 0;
}
int main(){
	int n;
	cin>>n;
	while(n-->0){
	for(int i=0;i<10;i++)
	cin>>x[i];
	if(func(0,0,0))
	cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	}
	return 0;
}