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;

bool judge(int num){
	int i, n, q[2]={0,0};

	for (i=0; i<num; i++) {
		cin >> n;
		if (q[0]<n) q[0] = n;
		else if (q[1]<n) q[1] = n;
		else return false;
	}
	return true;

}

int main(){
	int i, n;

	cin >> n;
	for (i=0; i<n; i++)
		cout << (judge(10)? "YES": "NO") << "\n";

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define MOD 1000000007
#define ALL(a) begin((a)),end((a))
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
typedef vector<edge> edges;
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int a[10];
bool ans;
void solve(int i, int l, int r)
{
	if (i == 10) ans = true;
	if (l < a[i]) return solve(i + 1, a[i], r);
	if (r < a[i]) return solve(i + 1, l, a[i]);
}

int main()
{
	int n;
	cin >> n;
	REP(x, n)
	{
		ans = false;
		REP(i, 10) cin >> a[i];
		solve(0, 0, 0);
		cout << (ans ? "YES" : "NO") << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;

int n[12];
int N;

int kotae;


void dfs(int a,int b,int c){
	if(a==10){
		kotae = 1;
		return;
	}
	int now = n[a];
	if(now > b)dfs(a+1,now,c);
	if(now > c)dfs(a+1,b,now);
	return;
}
	


int main(){
	cin >> N;
	for(int ii=0;ii <N;ii++){
		for(int i=0;i<10;i++){
			cin >> n[i];
		}
		dfs(0,0,0);
		if(kotae == 1){
			cout << "YES" << endl;
		}
		else cout << "NO" << endl;
		kotae = 0;
	} 
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int input[10];
	int i = 0, num, j;
	int count = 0, flag = 0;

	cin >> num;

	while ( i < num )
	{
		for ( j = 0 ; j < 10 ; j = j + 1 )
		{
			cin >> input[j];
			if ( j >= 1 )
			{
				if ( input[j - 1] > input[j] )
					count = count + 1;
				else if ( input[j - 1] < input[j] )
					count = 0;

				if ( count == 2 )
				{
					flag = 1;
					break;
				}
			}

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

		flag = 0;
		count = 0;
		i = i + 1;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int rep;
  cin >> rep;
  for(int i=0;i<rep;i++){
	int in,b = 0,c = 0;
	bool ball = true;
	for(int j=0;j<10;j++){
	  cin >> in;
	  if (in < b && in < c){     
		ball = false;
	  }
	  else if (in < b && in > c){
		c = in;
	  }
	  else if (in > b && in < c){
		b = in;
	  }
	  else if (in > b && in > c){
		((b > c)? b : c ) = in;
	  }
	}
	cout << (ball?"YES":"NO") << endl;
  }
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

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

C++: #include <iostream>
using namespace std;
int main(){
int a;
int b;
int n;
int c;
int d;
int e;
int f;
c=0;
while(c<n){
f=0;
a=0;
b=0;
d=0;
while(d<10){
cin >>e;
if(e>a&&a>b){a=e;}
else if(e>b&&b>a){b=e;}
else if(e>a){a=e;}
else if(e>b){b=e;}
else{f=1; break;}
d=d+1;}
if(f==0){cout <<"YES"<<endl;}
if(f==1){cout <<"NO"<<endl;}
c=c+1;}

C++: #include <cstdio>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <algorithm>
#include <ctime>
#include <cctype>
#include <cmath>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <map>
#include <set>
#define sqr(x) ((x)*(x))
#define PI 3.1415926535897932384626
#define jue(x) (x>0?x:-x)
 
#define maxm 
#define maxn 1010
using namespace std;

int flag[10];
int num[10];

void dfs(int x){
	flag[x] = 1;
	for(int i = x + 1; i < 10; i++){
		if(num[i] > num[x]){
			dfs(i);
			break;
		}
	}
}

int main(){
	int n, res;
	while(scanf("%d", &n) == 1){
		while(n > 0){
			n--;
			res = 0;
			for(int i = 0; i < 10; i++){
				scanf("%d", &num[i]);
			}
			for(int i = 0; i < 10; i++){
				memset(flag, 0, sizeof flag);
				dfs(0);
				int numm[10], x = 0, y = 1;
				for(int j = 0; j < 10; j++){
					if(!flag[j]){
						numm[x++] = num[j];
					}
				}
				for(int j = 1; j < x; j++){
					if(numm[j - 1] >= numm[j]){
						y = 0;
					}
				}
				res = y;
				if(res) continue;
			}
			if(res){
				printf("YES\n");
			} else {
				printf("NO\n");
			}	
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int n;
	for (cin >> n; n--;)
	{
		vector<int> a(10);
		for (int i = 0; i < 10; i++)
		{
			cin >> a.at(i);
		}
		
		int id = 1;
		bool b = true;
		for (int i = 0; i < a.size() - 1; i++)
		{
			for (int j = 1; j < a.size() - 1; j++)
			{
				if (a.at(j) > a.at(j - 1))
				{
					continue;
				}
				else
				{
					if (id == a.at(j))
					{
						id++;
						a.erase(a.begin() + j);
						break;
					}
					else
					{
						b = false;
						break;
					}
				}
			}

			if (!b)
			{
				break;
			}
		}


		cout << (b ? "YES" : "NO") << endl;
	}
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        int a[10]={};
        int b[10]={};
        int dat[10],o=0,s=0;
		for(int j=0;j<10;j++) {
			cin>>dat[j];
		}
        for(int j=0;j<=10;j++){
            if(j==10){
                cout<<"YES"<<endl;
                break;
                        }
            if(s==0||dat[j]>a[s-1]){
                a[s]=dat[j];
                s++;
            }
            else if(o==0||dat[j]>b[o-1]){
                b[o]=dat[j];
                o++;}
            else {
                cout<<"NO"<<endl;
            break;
            }
                    } 
    }
    return 0;
}