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<queue>
using namespace std;
int main(void){
	int num;
	queue<int> qu;
	int a=0,b=0;
	int n;

	cin>>n;
	while(n--){
		for(int i=0;i<10;i++){//ツボツーツδ仰づーツ詰ツづ淞づゥ
			cin>>num;
			qu.push(num);
		}

		while(1){
			if(a < qu.front()){
				a=qu.front();
			}else if(b < qu.front()){
				b=qu.front();
			}else{
				cout<<"NO"<<endl;
				break;
			}
			qu.pop();
			if(qu.empty()==true){
				cout<<"YES"<<endl;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;

int N;
int l[15];
int b,c;
int res[1000000000000];


void solve(int k){
  for(int i=0;i<10;i++){
    if(b<l[i] && c<l[i]){
      if(l[i]-b < l[i]-c) b=l[i];
      else c=l[i];
    }
    else if(b<l[i] && c>l[i]) b=l[i];
    else if(b>l[i] && c<l[i]) c=l[i];
    else{
      res[k]=0;
      return;
    }
  }
  res[k]=1;
  return;
}


int main(){
  scanf("%d",&N);

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

  for(int i=0;i<N;i++){
    if(res[i]==0) printf("NO\n");
    else printf("YES\n");
  }


  return 0;
}

C++: #include<iostream>
#include<algorithm>
int N;
int t[10000][10];
bool d[10000];
int a, b, c;
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			std::cin >> t[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			if (t[i][j] > a) {
				a = t[i][j];
			}
			else if (t[i][j] > b) {
				b = t[i][j];
			}
			else {
				std::cout << "NO" << "\n";
				a = 0; b = 0;
				break;
			}
			if (j == 9) {
				std::cout << "YES" << "\n";
			}
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int ball;
	int n;
	while(cin >> n){
		bool flag = true;
		int B=0, C=0;
		for(int i=0; i<n; i++){
			for(int j=0; j<10; j++){
				cin >> ball;
				if(flag){
					if(B < ball) B=ball;
					else if(C < ball) C=ball;
					else flag=false;
				}
			}
			if(flag) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#define mem(name,value) memset(name,value,sizeof(name))
#define push_back pb
using namespace std;
typedef long long ll;

const int maxn=10;
int T,A[maxn+2],B[maxn+2],C[maxn+2];
int x,y;

bool dfs(int a)
{
    if(a==maxn) return true;
    if(A[a]<B[x-1] && A[a]<C[y-1]) return false;
    else if(A[a]>B[x-1]) B[x++]=A[a];
    else if(A[a]>C[y-1]) C[y++]=A[a];
    return dfs(a+1);
}

int main()
{
    cin>>T;
    while(T--){
        for(int i=0;i<maxn;i++)
            cin>>A[i];
        mem(B,0);
        mem(C,0);
        x=y=1;
        if(dfs(0)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

C++: #include <iostream>

int a[10];

int main() {
	int T;
	cin >> T;
	while (T--) {
		bool ans = true;
		for (int i = 0; i < 10; ++i) {
			cin >> 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 {
				and = false;
				break;
			}
		}
		cout << (ans ? "YES" : "NO") << endl;
	}
}

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

C++: #include <iostream>
#include <stdlib.h>

using namespace std;

int main() {

	int n;
	int num[10];
	int pos;
	cin >> n;
	while (n-- > 0)
	{
		int min_A = 0, min_B = 0;
		for (int i = 0; i < 10; i++)
		{
			cin >> num[i];
		}
		for (pos = 0; pos < 10; pos++)
		{
			if (num[pos] > min_A)
			{
				min_A = num[pos];
			}
			else if (num[pos] > min_B)
			{
				min_B = num[pos];
			}
			else
			{
				break;
			}
		}
		if (pos == 10)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int ball[10];

bool dfs(int n, int b, int c) {
    if(n == 10) return true;
    if(b < ball[n]) return dfs(n + 1, b = ball[n], c);
    if(c < ball[n]) return dfs(n + 1, b, c = ball[n]);
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    rep(i, n) {
        rep(i, 10) cin >> ball[i];
        dfs(0, 0, 0) ? cout << "YES" : cout << "NO";
        cout << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
  int n;
  int i;

  cin >> n;

  while (n--){
    int ai = 1, bi = 1;
    int ans = 0;
    int ball[10], a[10] = {0}, b[10] = {0};
    
    for (i = 0; i < 10; i++){
      cin >> ball[i];
    }
    for (i = 0; i < 10; i++){
      if (ball[i] > a[ai - 1]){
        ans++;
        a[ai++] = ball[i];
      }
      else if (ball[i] > b[bi - 1]){
        ans++;
        b[bi++] = ball[i];
      }
      else {
        cout << "NO" << endl;
        break;
      }
    }
    if (ans == 10) cout << "YES" << endl;
  }
}

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

using namespace std;


bool saiki(vector<int> ball,stack<int> B,stack<int> C){

    if(ball.size() == 0) return true;
    int temp = ball.front();
    bool flag1=false,flag2=false;
    ball.erase(ball.begin());
    if(temp > B.top()){
	B.push(temp);
       	flag1 = saiki(ball,B,C);
    }
    B.pop();
    if(temp > C.top()){
	C.push(temp);
	flag2 = saiki(ball,B,C);
    }
    return flag1 || flag2;
}


int main(){

    int N,temp;
    vector<int> ball;
    stack<int>B,C;
    B.push(0);
    C.push(0);
    cin >> N;
    for(int i=0;i<N;i++){
	for(int j=0;j<10;j++){
	    cin >> temp;
	    ball.push_back(temp);
	}
	if(saiki(ball,B,C)) cout << "YES" << endl;
	else cout << "NO" << endl;
	ball.clear();
    }
    return 0;
}

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[9]={};
		int b[9]={};
		int dat,o=0,s=0;
		for(int j=0;j<=10;j++){
			if(j==10){
				cout<<"YES"<<endl;
				break;
						}
			cin>>dat;
                        if(s==0||dat>a[s-1]){
				a[s]=dat;
				s++;
			}
			else if(o==0||dat>b[o-1]){
				b[o]=dat;
				o++;}
			else {
				cout<<"NO"<<endl;
			break;
			}
					}
	}
	return 0;
}