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>
#include <string>
using namespace std;

int main(void)
{
	int N,ball,B = 0,C = 0;
	bool ans;
	cin >> N;
	for (int i = 0; i < N; i++) {
		C = 0;
		cin >> B;
		ans = true;
		for (int j = 1;j < 10; j++) {
			cin >> ball;

			int b = ball - B;
			int c = ball - C;

			if (b < 0 && c < 0 || !ans) {
				ans = false;
				continue;
			}
			else {
				if (b > 0 && c < 0 || b > 0 && c > 0 && b < c) {
					B = ball;
				}
				else if (b < 0 && c > 0 || b > 0 && c > 0 && b > c) {
					C = ball;
				}
			}
		}
		cout << (ans ? "YES" : "NO") << endl;
	}
	if (N == 0) {
		cout << endl;
	}
}

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

int main()
{
	int n,t,a,b,f;

	cin >> n;
	while(n--)
	{
		a=b=f=0;
		for(int i=0; i<10; i++)
		{
			cin >> t;

			if(t-a<0 && t-b<0)
			{
				f=1; break;
			}
			else if(t-a<0)		b=t;
			else if(t-b<0)		a=t;
			else if(t-a<t-b)	a=t;
			else				b=t;
		}
		cout << (f?"NO":"YES") << endl;
	}
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

int N;
int M = 10;
int **inData;
int *lTube;
int *rTube;

bool dfs(int n, int i, int l, int r)
{
	if (i==M)
		return true;

	//left tube
	if (l==-1 || inData[n][i]>lTube[l]) {
		lTube[l+1] = inData[n][i];
		if (dfs(n, i+1, l+1, r)) return true;
	}

	//right tube
	if (r==-1 || inData[n][i]>rTube[r]) {
		rTube[r+1] = inData[n][i];
		if (dfs(n, i+1, l, r+1)) return true;
	}

	//failed
	return false;
}

int main()
{
	int n, i, j;

	while (1) {

		//input & allocate memory
		if (scanf("%d ", &N) == EOF) break;

		inData = (int **)calloc(N, sizeof(int *));
		for (i=0; i<N; i++) {
			inData[i] = (int *)calloc(M, sizeof(int));
			
			for (j=0; j<M; j++)
				scanf("%d ", &(inData[i][j]));
		}

		lTube = (int *)calloc(M, sizeof(int));
		rTube = (int *)calloc(M, sizeof(int));

		for (n=0; n<N; n++) {
			for (i=0; i<M; i++)
				lTube[i] = rTube[i] = 0;

			//dfs & output
			if (dfs(n, 0, -1, -1))
				printf("YES\n");
			else
				printf("NO\n");
/*			
			printf("Left:\n");
			for (i=0; i<M; i++)
				printf("%d ", lTube[i]);
			puts("");
			printf("Right:\n");
			for (i=0; i<M; i++)
				printf("%d ", rTube[i]);
			puts("");
			printf("------------------\n");
*/
		}
/*
		for (i=0; i<N; i++) {
			for (j=0; j<M; j++)
				printf("%d ", inData[i][j]);
			puts("");
		}
*/
		//free memory
		for (i=0; i<N; i++)
			free(inData[i]);
		free(inData);
		free(lTube);
		free(rTube);
	}

	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rrep(i,n) for(int i = 1; i <= n; i++)
#define drep(i,n) for(int i = n; i >= 0; i--)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

void chmax(int& a,int b){
	if(b > a){
		a=b;
	}
}
string j(){
	int d1=0,d2=0;
	rep(j,10){
		int n;
		cin >> n;
		if(d1<n){
			d1=n;
			continue;
		}else{
			if(d2<n){
				d2=n;
				continue;
			}else{
				return "NO";
			}
		}
	}
	return "YES";

}
int main(){
	int N;
	cin >> N;
	rep(i,N){
		cout << j() << endl;
	}
}

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

using namespace std ;
int flag ;
int q[11];

void dfs(int pos, int left,int right)
{
	if (pos==10) 
	{
		flag = 1 ;
		return ;
	}
	if (q[pos] > left )
	dfs(pos+1 , q[pos] , right);
	
	if (q[pos] > right)
	dfs (pos+1,left ,q[pos]);
	
}
int main ()
{
	
	int n;
	cin >> n ;
	for (int i=0;i<n;i++)
	{
		flag = 0 ;
		for (int i=0;i<10;i++)
			cin >> q[i];
		dfs(0,-1,-1);
		if (flag == 1)
		cout <<"YES"<<endl;
		else 
		cout <<"NO"<<endl;
	}
	
	return 0;
}

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

int B[11]={0};
int C[11]={0};

bool DFS(int *a,int i=0,int b=1,int c=1)
{
	bool judge=true;

	if(i==10)
		return judge;

	judge=false;

	if(B[b-1]<a[i]){
		B[b]=a[i];
		judge=DFS(a,i+1,b+1,c);
		
	}
	if(C[c-1]<a[i]){
		C[c]=a[i];
		judge=DFS(a,i+1,b,c+1);
		
	}

	return judge;
}        

int main()
{
        int N;
	int i=0;
        cin>>N;

	while(i<N){
	???int A[10]={0};
	???for(int i=0;i<10;i++){
	??? cin>>A[i];
          }

          if(DFS(A)==true){
           cout<<"YES"<<endl;
          }
          else{
           cout<<"NO"<<endl;
          }

	???i++;
        }
                
	
        return 0;
}

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

int N, H[10];

void solve()
{
  int big=0, small=0;
  bool flag = true;
  for (int i = 0; i < 10; i++)
  {
    if (H[i] > big) big = H[i];
    else if (H[i] > small) small = H[i];
    else
    {
      flag = false;
      break;
    }
  }
  if (flag) printf("YES\n");
  else  printf("NO\n");
}

int main()
{
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 10; j++) cin >> H[j];
    solve();
  }
  return 0;
}

C++: #include<cstdio>
#include<cstring>
int t;
int a[15];

int main()
{
    scanf("%d",&t);
    while(t--)
    {
        int i;
        int z[15],y[15];
        memset(z,0,sizeof(z));
        memset(y,0,sizeof(y));
        for( i=0;i<10;i++)
            scanf("%d",&a[i]);

            z[0]=a[0];int f=1;
            int t=0;int tt=0;
            for(int i=1;i<10;i++)
            {
                if(a[i]>z[t])
                {
                    z[++t]=a[i];
                    f++;
                }
                else if(a[i]>y[tt])
                    {
                        y[++tt]=a[i];
                        f++;
                    }
            }
           // printf("%d!",f);
        if(f==10)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}