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 <stdio.h>

using namespace std;

int flag, a[10];

void f(int x0, int x1, int i)
{
	if (flag)
		return;
	if (i == 10)
	{
		flag = 1;
		return;
	}
	if (a[i] < x0 && a[i] < x1)
		return;
	if (a[i] > x0)
		f(a[i], x1, i + 1);
	if (a[i] > x1)
		f(x0, a[i], i + 1);
}

int main()
{
	int t, i;
	scanf("%d", &t);
	while (t--)
	{
		for (i = flag = 0; i < 10; i++)
			scanf("%d", &a[i]);
		f(0, 0, 0);
		if (flag)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

C++: #include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
int l[10];
int v[2];
double m;
double pos;
int ans;
while(scanf("%d,%d,%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],&v[0],&v[1])!=EOF){
m=0;
for(int i=0;i<10;i++){
m+=l[i];
}
pos=(m*v[0])/double(v[0]+v[1]);
for(int i=0;i<10;i++){
pos-=l[i];
if(!(pos>0)){
ans=i+1;
break;
}
}
cout<<ans<<endl;
}
return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 10;

bool dfs(vector<int> a, vector<int> b, vector<int> vec, int now){
    if(now >= N) return true;
    else{
        bool ret = false;
        if(a.size() == 0 || vec[now] > a[a.size() - 1]){
            vector<int> tmp = a;
            tmp.push_back(vec[now]);
            ret = max(ret, dfs(tmp, b, vec, now + 1));
        }
        if(b.size() == 0 || vec[now] > b[b.size() - 1]){
            vector<int> tmp = b;
            tmp.push_back(vec[now]);
            ret = max(ret, dfs(a, tmp, vec, now + 1));
        }
        return ret;
    }
}


int main(){
    int n; cin >>n;
    REP(z, n){
        vector<int> vec(N); REP(i, N) cin >>vec[i];
        cout <<((dfs(vector<int>(), vector<int>(), vec, 0))? "YES" : "NO") <<endl;
    }
    return 0;
}

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

C++: C++

#include <iostream> // C++?????\??????
#include <stdio.h> // C ?????\??????
#include <algorithm> // sort ???????????¢?????´?????????
#include <string.h> // C ??????????????¨
#include <ctype.h> // C ??????????¨???¨
#include <string> // C++????????????
#include <math.h>
#include <sstream>
using namespace std;
int ball[10];
bool dfs(int i,int b,int c);
int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int s=0;s<10;s++){
            cin>>ball[s];
        }
        if(dfs(0,0,0))cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}
bool dfs(int i,int b,int c){
    if(i==10)return true;
    if(b<ball[i]){
        if(dfs(i+1,ball[i],c))return true;
    }
    if(c<ball[i]){
        if(dfs(i+1,b,ball[i]))return true;
    }
    return false;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  while(cin>>n){
    bool ok=true;
    int a,b=0,c=0;
    rep(i,10){
      cin>>a;
      if(b>c){
	if(a>b)b=a;
	else if(a>c)c=a;
	else ok=false;
      }else{
	if(a>c)c=a;
	else if(a>b)b=a;
	else ok=false;
      }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <stack>
using namespace std;
int main(){
  stack<int>st[2];
  int n,f;
  cin >> n;
  while(n--){
    f = 1;
    st[0].push(0);st[1].push(0);
    int i;
    for(i = 0 ; i < 10 ; i++ ){
      int a;
      cin >> a;
      if(a-st[0].top() > 0 && st[0].top() > st[1].top()){
	st[0].push(a);
      } else if(a-st[1].top() > 0 ){
	st[1].push(a);
      } else {f=0;}
    }
    if(f)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

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";
				a = 0; b = 0;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	
	for (int i = 0; i < N; i++) {
		int a[10];
		bool success = false;
		for (int j = 0; j < 10; j++) scanf("%d", &a[j]);
		int len = 1 << 10;
		for (int j = 0; j < len; j++) {
			vector<int> u;
			vector<int> v;
			for (int k = 0; k < 10; k++) {
				if (j >> k & 1) u.push_back(a[k]);
				else v.push_back(a[k]);
			}
			
			bool x = is_sorted(u.begin(), u.end());
			bool y = is_sorted(v.begin(), v.end());
			if (x && y) {
				printf("YES\n");
				success = true;
				break;
			}
		}
		
		if (!success) {
			printf("NO\n");
		}
	}
}

C++: 
#include<iostream>
using namespace std;
int table[10];

bool ok(int i,int left,int right){
	if(i>=9){
		return true;
	}
	if(left<table[i]){
		if(ok(i+1,table[i],right))return true;
		else return false;
	}
	
	if(right<table[i]){
		if(ok(i+1,left,table[i]))return true;
		else return false;
	}
	return false;
}
int main(){
	int n;
	cin>>n;
	for(int set=0;set<n;set++){
		for(int i=0;i<10;i++)cin>>table[i];
		if(ok(0,0,0))cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	
	}
	return 0;
}