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 main()
{
    int n, s, t, c, p, f;
    cin >> n;
     
    while(n--)
    {
        s = f = t = 0;
        for(int i = 0; i < 10; i++)
          {
            cin >> p;
            if(p < s && p < t){
                f = 1;
            }
                else if(p > s){
                s = p;
            } 
                else if(p > t){
                t = p;
            }  
                else {
                f = 1;
            }
        }
        if(f == 0){
            cout << "YES" << endl;
        } 
            else {
            cout << "NO" << endl;
        }
    }
     
    return 0;
}

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

C++: /*
* @Author: key
* @Date:   2016-03-04 11:52:34
* @Last Modified by:   key
* @Last Modified time: 2016-03-04 12:37:55
*/

#include <iostream>

using namespace std;

int c[10];

int a[10],b[10];

bool flag;

void dfs(int x,int y,int z){
    if(x > 9){
        flag = true;
        return;
    }

    if(flag)
        return;

    if(y < 0 || c[x] > a[y]){
        a[y+1] = c[x];
        dfs(x+1,y+1,z);
    }

    if(z < 0 || c[x] > b[z]){
        b[z+1] = c[x];
        dfs(x+1,y,z+1);
    }

}

int main(){

    int n;

    cin >> n;

    while(n--){
        flag = false;
        for(int i = 0; i < 10; i++){
            cin >> c[i];
            a[i] = 0;
            b[i] = 0;
        }
        dfs(0,-1,-1);
        if(flag)
            cout << "Yes" <<endl;
        else
            cout << "No" << endl;
    }

    return 0;
}

C++: #include <stdio.h>


void solve(){
	int tan;
	int sho;

	int flg = 0;
	for (int i=0; i<10; ++i){
		int tama;
		scanf("%d", &tama);
		if (!i) {
			tan = tama;
			continue;
		}
		if (i==1) {
			sho = tama;
			continue;
		}
		if (i%2 == 0){
			if (tama < tan) flg = 1;
			tan = tama;
		}else {
			if (tama < sho) flg = 1;
			sho = tama;
		}
	}
	printf("%s\n", flg?"NO":"YES");
}

int main (){
	int t;
	scanf("%d", &t);
	while (t --){
		solve();
	}
	return 0;
}

C++: #include<stdio.h>
main(){
    int x[10],y[10],z[10],i,j,n,cz,cy,tmp;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        tmp=0;
        cy=0;cz=0;
        for(j=0;j<10;j++){
        scanf("%d",&x[j]);
        z[j]=0;y[j]=0;
        }
        for(j=0;j<10;j++){
        if(x[j]>=y[cy-1*(cy>0)])
        y[cy++]=x[j];
        else if(x[j]>=z[cz-1*(cz>0)])
        z[cz++]=x[j];
        else
        tmp=1;
        }
        if(tmp==1)
        printf("NO\n");
        else
        printf("YES\n");
    }
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int t,data[10],A,B;
	scanf("%d",&t);
	while(t--){
		rep(i,10)scanf("%d",data+i);
		A = B = 0;
		int j;
		bool f = true;
		for(j=0; j<10; j++){
			if( A<data[j] && B<data[j] ){
				if( A<B ){
					B = data[j];
				}else{
					A = data[j];
				}
			}else if( A<data[j] ){
				A = data[j];
			}else if( B<data[j] ){
				B = data[j];
			}else{
				f = false; break;
			}
		}
		puts(f ? "YES" : "NO" );
	}
	return 0;
}

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

int main(){
	int N,ball,B=0,C=0;
	bool failure;
	cin>>N;
	for(int i=0;i<N;i++){
		failure=0;
		for(int j=0;j<10;j++){
			cin>>ball;
			if(ball<B && ball<C){failure=1;}
			if(B<ball && C<B){B=ball;}
			else if(C<ball && B<C){C=ball;}
			else if(C<B){C=ball;}
			else 		{B=ball;}
		}	
		if(failure) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
		B=C=failure=0;
	}
	return 0;
}

C++: //
// Created by Tnecesoc on 2017/3/22.
//

#include <cstdio>

const int MAX_N = 10 + 10;

int a[MAX_N];

int cur1, cur2;
int b1[MAX_N], b2[MAX_N];

bool dfs(int n) {

    if (n >= 10) {
        return true;
    } else {

        if (cur1 == -1 || b1[cur1] < a[n]) {
            b1[++cur1] = a[n];
            if (dfs(n + 1)) {
                return true;
            }
        }

        if (cur2 == -1 || b2[cur2] < a[n]) {
            b2[++cur2] = a[n];
            if (dfs(n + 1)) {
                return true;
            }
        }

        return false;
    }

}

int main() {

    int n;
    scanf("%d", &n);
    while (n--) {
        for (int i = 0; i < 10; ++i) {
            scanf("%d", &a[i]);
        }

        printf("%s\n", dfs(0) ? "YES" : "NO");
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int ball[11];

bool bfs(int b, int c, int sum){
    if(sum == 10){
        return true;
    }
    if(b < ball[sum]){
        return bfs(ball[sum], c, sum+1);
    }
    if(c < ball[sum]){
        return bfs(b, ball[sum], sum + 1);
    }
    if(c > ball[sum] && b > ball[sum]){
        return false;
    }
}
int main(void){
    int n;
    cin >> n;
    for(int i=0; i<n ;i++){
        for(int j=0;j<10;j++){
            cin >> ball[j];
        }
        if(bfs(0, 0, 0)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

C++: #include <iostream>

using namespace std;
const int kBalln = 10;
int main(){
  int n;
  int ball;
  int b, c;
  cin >> n;
  for (int j = 0; j < n; ++j)
    {
      b = 0; c = 0;
      for (int i = 0; i < kBalln; ++i)
        {
          cin >> ball;
          if (b < ball)
            {
              b = ball;
            }
          else if (c < ball)
            {
              c = ball;
            }
          else
            {
              cout << "NO" << endl;
              break;
            }
        }
      cout << "YES"  << endl;
    }
  return 0;
}

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

int main() {
int a[10],b[11],c[11];
int n;
cin>>n;
for (int jjj=1;jjj<=n;jjj++){
	for(int kk=0;kk<10;kk++) cin>>a[kk];
int bb=0,cc=0;
b[0]=0;
c[0]=0;
for (int k=0;k<10;k++){
	if(a[k]>b[bb] && b[bb]>=c[cc]){
		b[bb+1]=a[k];
		bb=bb+1;
	}
	else{
		c[cc+1]=a[k];
		cc=cc+1;
	}
}
	int l=0,m=0;
	for(int i=1;i<=bb;i++){
		if(b[i]-b[i-1]<0){
			l=2;
		}
	}
	for(int j=1;j<=cc;j++){
		if(c[j]-c[j-1]<0){
			m=2;
		}
	}
	if(l+m==0){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	
}

	return 0;
}