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 Balls[10];

bool fork(int balls[], int i, int b, int c) {
  if (i == 10) return true;
  if (b > balls[i] && c > balls[i]) return false;
  if (b < balls[i] && fork(balls, i + 1, balls[i], c)) return true;
  if (c < balls[i] && fork(balls, i + 1, b, balls[i])) return true;
  return false;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> Balls[j];
    }
    if(fork(Balls, 0, 0, 0)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
        int set_number, L, R, flag = 0;
        cin >> set_number;
        array< int, 10 > ar;

        for ( int i = 0 ; i < set_number ; i++ )
        {
                for ( int j = 0 ; j < 10 ; j++ )
                {
                        cin >> ar[j];
                }

                L = ar[0];
                R = 0;
                for ( int j = 1 ; j < 10 ; j++ )
                {
                        if ( L < ar[j] )
                        {
                                L = ar[j];
                        }
                        else if ( L > ar[j] )
                        {
                                if ( R < ar[j] )
                                {
                                        R = ar[j];
                                }
                                else
                                {
                                        fprintf( stdout, "No\n" );
                                        flag = 1;
                                        break;
                                }
                        }
                }

                if ( flag == 0 )
                {
                        fprintf( stdout, "Yes\n" );
                }
        }

        return 0;
}

C++: #include<iostream>
main(){
int n,i,A,B,C,f;
for(std::cin>>n;n-->0;puts(f?"NO":"YES"))
 for(B=C=f=i=0;i<10;i++){
  std::cin>>A;
  if(B<A)B=A;
  else C<A?C=A:f=1;
 }
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i<k;i++)
int N;
int A[10];
bool DFS(int Aindex,int x,int y){
  if(Aindex ==10)return true;
  if(x>A[Aindex] && y>A[Aindex])return false;
  bool m=false;
  if(x<A[Aindex])m=max(m,DFS(Aindex+1,A[Aindex],y));
  if(y<A[Aindex])m=max(m,DFS(Aindex+1,x,A[Aindex]));
  return m;
}
int main(){
  cin >> N;
  string ans[2]={"NO","YES"};
  rep(i,0,N){
    rep(i,0,10){
      cin >>A[i];
    }
    cout << ans[DFS(0,0,0)]<<endl;
  }
  return 0;
}

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

int main() {
    int n; cin >> n;  
    while(n--){
        int balls[10] = {0};
        for(int i = 0; i < 10; i++){ cin >> balls[i]; }
        
        bool isYES = true;  
        int topB = 0, topC = 0; 
        for(int i = 0; i < 10; i++){
            if (topB < balls[i]){
                topB = balls[i];
            } else if (topC < balls[i]) {
                topC = balls[i];
            } else {
                isYES = false;
                break;
            }
        }
        cout << (isYES ? "YES" : "NO") << endl;
    }
}

C++: #include<iostream>
using namespace std;
bool solve(int, int, int);
int a[10];

int main(void){
	int n;
	char t;
	bool flag;
	cin >> n;
	do{
		n--;
		cin >> a[0];
		for(int i = 1; i < 10; i++){
			cin >> t >> a[i];
		}
		if(solve(0,0,0)){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}while(n != 0);
	return 0;
}

bool solve(int i, int b, int c){
	if(i == 9){
		if(a[i] > b || a[i] > c)
			return (true);
		return(false);
	}
		if(solve(i + 1, a[i], c) || solve(i + 1, b, a[i])){
			return (true);
		}
	return (false);
}

C++: #include<iostream>
using namespace std;
 
int data[10];
 
bool solve(int i, int a, int b){
 
  if(i == 10) return true;
 
  if(data[i] > a) return solve(i+1, data[i], b);
  if(data[i] > b) return solve(i+1, a, data[i]);
  
  return false;
}
 
int main(){
 
  int n;
 
  cin >> n;
  while(n--){
 
    for(int i=0;i<10;i++) cin >> data[i];
 
    cout << (solve(0, 0, 0)?"YES\n":"NO\n");
 
  }
 
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	LOOP(N){
		auto V=vecin(10);
		vector<int> B,C;
		bool success = true;
		REP(i,10){
			if(B.empty() || B.back()<V[i]){
				B.push_back(V[i]);
			}
			else if(C.empty() || C.back()<V[i]){
				C.push_back(V[i]);
			}
			else{
				success = false;
				break;
			}
		}

		out(success?"YES":"NO");
	}
	return 0;
}

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

int main() {
	int n1,n2,num,temp,flg=1;
	cin>>num;
	while(num--){
		cin>>n1; cin>>n2;
		for(int i=0;i<8;i++){
			cin>>temp;
			if(temp-n1<0&&temp-n2<0) flg=0;
			if(temp-n1>temp-n2) n2=temp;
			else if(temp-n2>temp-n1) n1=temp;
		}if(flg==1) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}return 0;
}

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

using namespace std;
 
 
int data[10];
 
bool searchB (int a){
    vector<int >sea;
 
    for(int i=0;i<10;i++){
        if(a>>i & 1)sea.push_back(data[i]);
    }
    if(sea.size()>1){
    for(int i=0;i<sea.size()-1;i++){
        if(sea[i]>sea[i+1])return false;
    }
    }
    return true;
}
 
int main(){
 
    int n=0;
    cin>>n;
 
    for(int i=0;i<n;i++){
         
 
    for(int j=0;j<10;j++){
        cin>>data[j];
    }
    bool suc=false;
    for(int i=0;i<1024;i++){
        if(searchB(i) && searchB(~i)){
            cout<<"YES"<<endl;
            suc=true;
            break;
        }
    }
    if(!suc)cout<<"NO"<<endl;
    }
    return 0;
}