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;
	int d[10];
	int va[10];
	int vb[10];
	int trush;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> d[i];
		}

		int ca = 0, cb = 0;
		va[0] = d[0];
		ca++;
		if (d[1] > va[0]) {
			va[1] = d[1];
			ca++;
		}

		else {
			vb[0] = d[1];
			cb++;
		}

	for (int j = 2; j < 10; j++) {
			if (d[j] > va[ca-1]) {
				va[ca] = d[j];
				ca++;
			}

			else if (d[j] > vb[cb - 1]) {
				vb[cb] = d[j];
				cb++;
			}


			else if (d[j] < va[ca - 1] && d[j] < vb[cb - 1]) {
				cout << "NO" << endl;
				goto FINLOOP;
			}
			
		}
		cout << "YES" << endl;

		FINLOOP:
		for (int i = 0; i < 10; i++) {
			va[i] = 0;
		}
		for (int i = 0; i < 10; i++) {
			vb[i] = 0;
		}
	}
	return 0;
}

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

using namespace std;

void solve() {
  int a = 0, b = 0, c;
  for (int i = 0; i < 10; ++i) {
    cin >> c;
    if (c < a) {
      cout << "NO" << endl;
      return;
    }
    if (c < b) a = c;
    else b = c;
  }
  cout << "YES" << endl;
}

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) solve();
}

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

using namespace std;

int main()
{
	int n;
	scanf("%d",&n);
	while(n--){
		int b=-1,c=-1,a,flag=true;
		for(int i=0;i<10;i++){
			scanf("%d",&a);
			if(a>b){
				b=a;
			}else if(a>c){
				c=a;
			}else{
				flag=false;
			}
		}
		printf("%s\n",flag?"YES":"NO");
	}
	return 0;
}

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

int ball[10];

bool DFS(int B,int C,int cnt){
  if(cnt == 10)
    return true;

  bool ans = false;
  if(B < ball[cnt])
    ans = DFS(ball[cnt],C,cnt+1);
  if(C < ball[cnt])
    ans = DFS(B,ball[cnt],cnt+1);

  return ans;
}

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

  while(n--){
    for(int i = 0; i < 10; i++)
      cin >> ball[i];

    if(DFS(0,0,0)==true)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

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

int ma[11];
int a[11];int b[11];

bool ch;

int dx[]={1,0,0,-1};
int dy[]={0,-1,1,0};

void dfs(int deep,int aa,int bb)
{
    if(ch)return ;
    if(deep==10)
    {
        ch=true;
        return ;
    }


    if(ma[deep]>a[aa-1])
    {
        a[aa]=ma[deep];
        dfs(deep+1,aa+1,bb);
    }

    if(ch==false&&ma[deep]>b[bb-1])
    {
        b[bb]=ma[deep];
        dfs(deep+1,aa,bb+1);
    }

}


int main()
{
    int f;
    scanf("%d",&f);
    while(f--)
    {
        ch=false;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for(int i=0;i<10;i++)
            scanf("%d",&ma[i]);
        dfs(0,1,1);
        if(ch)
            printf("YES\n");
        else
            printf("NO\n");
    }


}

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

int main(){

  int n,m;

  cin >> n;

  for(int i=0;i<n;i++){

    int a[100],b[100] = {0},c[100] = {0} ,s = 0,t = 0,x,y,count = 0;

    for(int j=0;j<10;j++){

      cin >> m;

      if(j == 0){
	b[s] = m;
	s++;
      }

      if(j == 1){
	c[t] = m;
	t++;
      }

      if(m > b[s-1] && m < c[t-1]){
	b[s] = m;
	s++;
      }

      else if(m > c[t-1] && m < b[s-1]){
	c[t] = m;
	t++;
      }

      else if(b[s-1] > c[t-1] && m > b[s-1]){
	b[s] = m;
	s++;
      }

      else if(c[t-1] > b[s-1] && m > c[t-1]){
	c[t] = m;
	t++;
      }

      else if(m < c[t-1] && m < b[s-1])	count = 1;
    }

    if(count == 1) cout << "NO" << endl;
    else cout << "YES" << endl;

  }
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	int a = 0, b = 0;
	int in;
	int ans = 1;
	for(int i=0;i<10;i++){
		cin>> in;
		if(b < in){
			b = in;
		}else if(a < in){
			a = in;
		}else{
			ans = 0;
			break;
		}
		if(a > b) swap(a,b);
	}
	if(ans){
		cout<< "YES"<< endl;
	}else{
		cout<< "NO"<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		solve();
	}
	return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
typedef vector<int> veci;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define foreach(i, n) for (typeof(n) i = 0; i < (n); ++i)
#define foreach_eq(i, n) for (typeof(n) i = 0; i <= (n); ++i)
#define foreach_from(i, m, n) for (typeof(n) i = m; i < (n); ++i)
#define foreach_eq_from(i, m, n) for (typeof(n) i = m; i <= (n); ++i)

int dirctions[4][2] = {{0,-1}, {0,1}, {-1,0}, {1,0}};

#define BALL_NUM 10

int N;
int balls[BALL_NUM];

bool recur(int ix, int left, int right) {
    if (ix < 10) {
        return (left  < balls[ix] && recur(ix + 1, balls[ix], right))
            || (right < balls[ix] && recur(ix + 1, left, balls[ix]));
    } else {
        return true;
    }
}

int main() {
    cin >> N;
    foreach (n, N) {
        foreach (i, BALL_NUM) cin >> balls[i];
        cout << (recur(0,0,0) ? "YES" : "NO") << endl;
    }
}

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

int main(){
	int n;
	std::cin >> n;
	while (n){
		std::vector<int> ball(10);
		for (int i = 0; i < 10; ++i)std::cin >> ball[i];
		int cnt = 0;
		for (int i = 1; i < 10; ++i){
			if (ball[i] < ball[0])cnt++;
		}
		if (cnt < 3)std::cout << "YES" << std::endl;
		else std::cout << "NO" << std::endl;
		n--;
	}
	return 0;
}

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

int Balls[10];


bool not_dfs(int balls[]){
  int b = 0, c = 0;
  for (int i = 0; i < 10; i++) {
    if (b < balls[i]){b = balls[i]; continue;}
    if (c < balls[i]){c = balls[i]; continue;}
    return false;
  }
  return true;
}

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