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<vector>
#include<string>
#include <algorithm>

using namespace std;

int a[10];

int main()
{
    int t;
    cin >> t;

    while(t--)
    {
        for(int i = 0; i < 10; ++i)
        {
            cin>>a[i];
        }

        vector<int> x[2];
        auto lar = &x[0];
        auto sma = &x[1];

        bool ans = true;

        for(int i = 0; i < 10; ++i)
        {
            int c = a[i];

            if(i == 0){
                lar->push_back(c);
            }
            else if(c >= lar->back())
            {
                lar->push_back(c);
            }
            else if(sma->empty())
            {
                sma->push_back(c);
                
            }
            else if(c >= sma->back())
            {
                sma->push_back(c);
                
            }
            else
            {
                ans = false;
                break;
            }
            
        }
        if(ans)
            cout<<"YES" <<endl;
        else
            cout<<"NO" <<endl;

    }
}

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

using namespace std;

int n;
vector<int> vec;
int lcount, rcount, l, r;

bool dfs(int i)
{
	if(i == 10) return true;
	if(lcount < 10 && l < vec[i]){ l = vec[i]; if(dfs(i + 1)) return true; }
	if(rcount < 10 && r < vec[i]){ r= vec[i]; if(dfs(i + 1)) return true; }
	return false;
}

int main()
{
	cin >> n;
	for (int j = 0; j < n; j++)
	{
		lcount = 0; rcount = 0; l = 0; r = 0;
		vec.resize(10);

		for (int i = 0; i < 10; i++)
		{
			cin >> vec[i];
		}	
		cout << (dfs(0) ? "YES" : "NO") << endl;
	}
	return 0;
}

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

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

int main(){
    int n,tmp,a = 0,b = 0;
    bool judge;
    cin >> n;
    while(n--){
        judge = true;
        for(int i=0;i<10;i++){
            cin >> tmp;
            if(tmp > a) a = tmp;
            else if(tmp > b) b = tmp;
            else judge = false;
        }
        if(judge) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

C++: #include <cstdio>

int a[10];

int main(int argc, const char * argv[]) {
    int T;
    scanf("%d", &T);
    while (T--) {
        bool ans = true;
        for (int i = 0; i < 10; i++) {
            scanf("%d", &a[i]);
        }
        int l, r;
        l = r = 0;
        for (int i = 0; i < 10; i++) {
            if (a[i] > l) {
                l = a[i];
            } else if (a[i] > r) {
                r = a[i];
            } else {
                ans = false;
                break;
            }
        }
        printf("%s\n", ans ? "YES" : "NO");
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
#include<cstdio>
#include<string.h>
int a[50][11];
int b[50][11],c[50][11];
//int flag[100][11];
int by = 0,cy = 0;
int lb ;
int lc ;
void dfs(int x,int y){
    if(y<10){
    if(b[x][by]<a[x][y]){
        b[x][++by]=a[x][y++];
        ++lb;
    }
    else if(c[x][cy]<a[x][y]){
        c[x][++cy] = a[x][y++];
        ++lc;
    }
    // y +=1;

    dfs(x,y);}
}
void solve(){
    int n;
cin>>n;
        while(n--){
           
    for(int i = 0; i < n; i++)
            for(int j = 0; j < 10; j++)
                cin>>a[i][j];
     for(int i = 0; i < n; i++){
                dfs(i,0);
                if(lb+lc==10)
            printf("YES\n");
        else
            printf("NO\n");}
    }
}


int main(){
solve();
return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
int N;
int ball[10];
int l[20],r[20];
bool flag;
void DFS(int i,int ll,int rr)//i:当前所放球的序号 ll:左边该第ll位放球 rr:右边该第rr位放球
{
    if(i>=10)
        flag=1;
    if(ball[i]>l[ll-1])
    {
        l[ll]=ball[i];
        DFS(i+1,ll+1,rr);
    }
    if(ball[i]>r[rr-1])
    {
        r[rr]=ball[i];
        DFS(i+1,ll,rr+1);
    }
}
int main()
{
    scanf("%d",&N);
    while(N--)
    {
        memset(l,0,sizeof(l));
        memset(r,0,sizeof(r));
        for(int i=0;i<10;i++)
            scanf("%d",&ball[i]);
        flag=0;
        DFS(0,1,1);
        if(flag)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

C++: #include <stdio.h>

int main()
{
	int N, ball[10], B[10], C[10], b, c, k;

	scanf("%d", &N);

	for (int i = 0; i < 2; i++){
		scanf("%d %d %d %d %d %d %d %d %d %d", &ball[0], &ball[1], &ball[2], &ball[3], &ball[4], &ball[5], &ball[6], &ball[7], &ball[8], &ball[9]);

		b = 0;
		c = 0;
		k = 0;
		for (int j = 0; j < 10; j++){
			if(b < ball[j]) b = ball[j];
			else if(c < ball[j]) c = ball[j];
			else {k = 1; break;}
		}

		if(k == 0) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;

	rep(i,0,n){
		int x=0,y=0;
		bool f = 1;
		rep(j,0,10){
			int b;
			cin >> b;
			if( b - x > 0 && b - x <= b - y )
				x = b;
			else if( b - y > 0 )
				y = b;
			else{
				NO;
				f = 0;
				break;
			}

		}

		if(f)
			YES;
	}
	
	ret 0;
}

C++: #include <iostream>
using namespace std;
int N;
int num[10];
int lnum,rnum;
bool dfs(int n){
	if(n==10) return true;
	if((num[n]<lnum)&&(num[n]<rnum)) return false;
	else{
		if((num[n]>=lnum)&&(num[n]<rnum)){
			lnum=num[n];
			if(dfs(n+1)) return true;
		}
		else if((num[n]>=rnum)&&(num[n]<lnum)){
			rnum=num[n];
			if(dfs(n+1)) return true;
			
		}
		else{
			int temp=lnum;
			lnum=num[n];
			if(dfs(n+1)) return true;
			else{
				lnum=temp;
				rnum=num[n];
				if(dfs(n+1)) return true;
			}
		}
	}
	return false;
}
void solve(){
	cin>>N;
	for(int i=0;i<N;i++)
	{
		rnum=0;
	    for(int j=0;j<10;j++)
	    cin>>num[j];
	    lnum=num[0];
	    if(dfs(1)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}
int main(){
	solve();
	return 0;
}