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 <stdio.h>
#include <vector>
#include <iostream>

using namespace std;

int main() {
	vector<int> left;
	vector<int> right;
	vector<int> all;

	bool flag = true;

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			int temp;
			cin >> temp;
			all.push_back(temp);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			if (left.size() > 0) {
				if (all[10 * i + j] > left[left.size() - 1]) {
					left.push_back(all[10 * i + j]);
				}
				else {
					if (right.size() > 0) {
						if (all[10 * i + j] > right[right.size() - 1])
							right.push_back(all[10 * i + j]);
						else
							flag = false;
					}
					else {
						right.push_back(all[10 * i + j]);
					}
				}
			}
			else {
				left.push_back(all[10 * i + j]);
			}
		}

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

C++: #include<cstdio>
int a[15],b,c,k;
int main()
{
	scanf("%d",&k);
	for(int kk=1;kk<=k;kk++)
	{
		int f=0;
		for(int i=1;i<=10;i++)
			scanf("%d",&a[i]);
		for(int i=1;i<=10;i++)
		{
			if(a[i]<c&&a[i]<b)
			{printf("NO\n");f=1;break;}
			if(b>c)
			{
				if(b<a[i])b=a[i];
				else c=a[i];
			}
			else
			{
				if(c<a[i])c=a[i];
				else b=a[i];
			}
		}
		if(!f)printf("YES\n");
		b=c=0;
	}
}
//2 4 6 8 10 1 3 5 7 9

C++: #include<iostream>
using namespace std;
int main(void)
{
    int bo[11],n,B[11],C[11],b1=0,c1=0,A=0,k=0,l=1;
    cin>>n;
    for(int i=0;i<n;i++){
            C[0]=11;k=0;l=0;B[0]=0;b1=0;c1=0;
        for(int j=0;j<10;j++){
            cin>>bo[j];
        }
        for(int j=1;;j++){
            if(j==0)B[0]=bo[0];
        if(B[l]<bo[j]){
            b1=1;
            B[l+1]=bo[l];
            l++;
        }else if(C[0]==11){
            C[0]=bo[j];
            k++;
        }else if(C[k-1]<bo[j]){
            c1=1;
            C[k]=bo[j];
        }else{
            B[l+1]=bo[j];
            l++;
        }
        if(j==9||(b1==1&&c1==1))break;
    }
    if(b1==1&&c1==1)cout<<"YES\n";
    else cout<<"NO\n";
    for(int j=0;j<10;j++){
        B[j]=0;C[j]=0;
    }

}
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		int t[10];
		for (int j = 0; j < 10; ++j)
			scanf("%d", t+j);

		int k, l, r;
		l = r = 0;
		for (k = 0; k < 10; ++k)
		{
			if (t[k] > l)
				l = t[k];
			else if (t[k] > r)
				r = t[k];
			else
				break;

			if (l < r)
				swap(l, r);
		}
		if (k == 10)
			puts("YES");
		else
			puts("NO");
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,a,b=0,c=0;
  int i,j;
  cin >> n;
  for(i=0;i<n;i++){
    for(j=0;j<10;j++){
      cin >> a;
      if(b<a){
	b=a;
      }
      else if(c<a){
	c=a;
      }
      else{
	cout << "NO" << endl;
	break;;
      }
    }
    if(j>=9)cout << "YES" << endl;
    b=0,c=0;
  }
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int a[10];
bool flag = false;

void dfs(int B, int C, int cnt){
	if(cnt == 9){
		if(B < a[cnt]) flag = true;
		if(C < a[cnt]) flag = true;
		return;
	}
	if(B < a[cnt]){
		dfs(a[cnt], C, cnt + 1);
	}
	if(C < a[cnt]){
		dfs(B, a[cnt], cnt + 1);
	}
	if(B > a[cnt] && C > a[cnt]){
		return;
	}
}
int main(void){
	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		rep(j, 10) cin >> a[j];
		flag = false;
		dfs(0, 0, 0);
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int a[10];
int n;
 
bool dfs(int i,int left,int right){
    if(i==10) return true;
    if(a[i]>left){
        return dfs(i+1,a[i],right);
    }
    if(a[i]>right){
        return dfs(i+1,left,a[i]);
    }
    return false;
}
 
void solve(){
    rep(i,10) cin >> a[i];
    if(dfs(0,0,0)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return;
}
 
int main(){
    cin >> n;
    rep(i,n){
        solve();
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;
int numofbits(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

// BEGIN //////////////////////////////////////////////////////////////
int main() {
  int N = nextInt();
  REP(i, N) {
    stack<int> bs, cs;
    bool flag = true;
    bs.push(0);
    cs.push(0);
    REP(j, 10) {
      int a = nextInt();
      if (bs.top() < a) {
        if (cs.top() < a) {
          if (bs.top() > cs.top()) {
            bs.push(a);
          } else {
            cs.push(a);
          }
        } else {
          bs.push(a);
        }
      } else if (cs.top() < a) {
        cs.push(a);
      } else {
        flag = false;
        break;
      }
    }
    if (flag) {
      PRINT("YES");
    } else {
      PRINT("NO");
    }
  }
	return 0;
}
// END   //////////////////////////////////////////////////////////////

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main(){
    int n,b,B=0,C=0;
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        B=0;C=0;
        for(int j=0;j<10;j++){
            scanf("%d",&b);
            if(B==0 || B==b-1)
                B=b;
            else if(C==0 || C==b-1)
                C=b;
            else{
                B=0;C=0;
                break;
            }
        }
        if(B==10 || C==10)
            puts("YES");
        else
            puts("NO");
    }
}