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

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

	for (int i = 0; i < n; i++) {
		vector<vector<int>> v{ {0} };
		for (int j = 0; j < 10; j++) {
			cin >> x;
			for (int k = 0; k < v.size(); k++) {
				if (v[k].back() < x) {
					v[k].push_back(x);
					break;
				}

				if (k == v.size() - 1) {
					v.push_back({ 0 });
				}
			}

			if (v.size() == 3) {
				x = -1;
				break;
			}
		}
		if (x == -1) {
			cout << "NO";
		}
		else {
			cout << "YES";
		}
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int n,a;
  srand((unsigned)time(NULL));
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin>>a;
    }
    if(rand()%2==0){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}

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 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
typedef long long ll;

int n;
int a[10];
int b=-1, c=-1;
string solve(){
	REP(i, 10)
	{
		cin >> a[i];
	}
	REP(i,8)
	{
		if (a[i]>a[i+1]&&a[i]>a[i+2])
		{
			return "NO";
		}
	}
	return "YES";
}

int main()
{
	cin >> n;
	REP(i, n){
		cout << solve() << endl;
		
	}
	

	return 0;
}

C++: //Ball

#include<iostream>
#include<stack>
using namespace std;

int main(void){
    int n;
    
    cin >> n;
    
    for(int i = 0; i < n; i++){
        
        int j;
        stack<int> Q1;
        stack<int> Q2;
        Q1.push(0);
        Q2.push(0);
        
        for( j = 0; j < 10; j++){
            int x;
            cin >> x;
            
            if(Q1.top() < x)        Q1.push(x);
            else if(Q2.top() < x)   Q2.push(x);
            else {
                printf("NO\n");
                break;
            }
        }
        if(j == 10) printf("YES\n");    
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int a[10];

bool solve()
{
  bool ans = false;
  int s = 0, t = 0;
  REP(i,10) cin >> a[i];
  REP(i,10)
  {
    if(a[i] > s) s = a[i];
    else if(a[i] > t) t = a[i];
    else return false;
  }
  return true;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  REP(v,n) cout << (solve()?"YES":"NO") << "\n"; 
  return 0;
}

C++: #include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define B 0
#define C 1

int main()
{
    int n;
    cin >> n;
    while(n>0)
    {
        int a[10],b[10],c[10];
        rep(i,10)cin >> a[i];
        int bnum=0,cnum=0;
        int t;
        int side = B;
        int res =1;
        b[0] =a[9];
        bnum = 1;
        for(int i = 8;i!=-1;i--)
        {
            if(side == B)
            {
                if(b[bnum-1]<a[i])
                {
                    side=C;
                    if((cnum!=0)&&(c[cnum]<a[i])){res = 0;break;}
                    else{cnum++; c[cnum]=a[i]; }
                }
                else
                {
                    bnum++;
                    b[bnum] = a[i];
                }
            }
            else
            {
                if(c[cnum-1]<a[i]){
                    side = B;
                    if(b[bnum]<a[i]){res = 0;break;}
                    else{bnum++; b[bnum] = a[i];}
                }
                else
                {
                    cnum++;
                    c[cnum]=a[i];
                }
            }
        }
        if(res==1)cout <<"YES" << endl;
        else cout << "NO" << endl;
        n--;
    }
    return 0;
}

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

int main(){
	int b,c;
	int n,x[10];
	
	cin >> n;
	
	for(int i=0; i<n; i++){
		b=0; c=-1;
		for(int j=0; j<10;j++){
			cin >> x[j];
			if(b>c&&x[j]>b) b=x[j];
			else if(b<c&&x[j]>c) c=x[j];
			else if(b<c&&x[j]>b) b=x[j];
			else if(b>c&&x[j]>c) c=x[j];
			else b=11;
		}
		if(b==11) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include <vector>
using namespace std;
int ar[12];
vector<int> a,b;
bool dfs(int i)
{
	bool flag = true;
	if(i!=10)
	{
		if(a.empty()||a.back()<ar[i])
		{
			a.push_back(ar[i]);
			flag =  dfs(i+1);
		}
		else if(b.empty()||b.back()<ar[i])
		{
			b.push_back(ar[i]);
			flag = dfs(i+1);
		}
		else flag = false;
	}
	return flag;
}
int main()
{
	int n;
	cin >> n;
	while(n--)
	{
		for(int i = 0;i<10;i++)
			cin >> ar[i]; 
		cout<<(dfs(0)?"YES":"NO")<<endl;
		a.clear();b.clear();
	}
 }

C++: #include <cstdio>
int a[10],b,c,n;
bool ok;
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		for(int j=0;j<10;j++) scanf("%d",&a[j]);
		b=c=0;ok=true;
		for(int j=0;j<10;j++) {
			if(a[j]>b) b=a[j];
			else if(a[j]>c) c=a[j];
			else {ok=false;break;}
		}
		printf("%s\n",ok?"YES":"NO");
	}
}

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

C++: #include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,m;
int a[25];
int ans1[25];
int ans2[25];
int main()
{
    scanf("%d",&n);
    while(n--)
    {
        memset(a,0,sizeof(a));
        memset(ans1,0,sizeof(ans1));
        memset(ans2,0,sizeof(ans2));
        for(int i=1;i<=10;i++)
        {
            scanf("%d",&a[i]);
        }
        ans1[1]=a[1];
        ans2[0]=0;
        int p1=0,p2=0;
        int i;
        for(i=2;i<=10;i++)
        {
            if(a[i]>ans1[p1])
            {
                ans1[++p1]=a[i];
            }else if(a[i]>ans2[p2]){
                ans2[++p2]=a[i];
            }else{
                printf("NO\n");
                break;
            }
        }
        if(i>10)
        {
            printf("YES\n");
        }
    }
    return 0;
}