Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	for i := 0; i < n; i++ {
		a := -1
		b := -1
		ans := true
		// それぞれの筒の一番上にあるたまの数字に着目すればよい
		for j := 0; j < 10; j++ {
			x := nextInt()
			if x > a {
				a = x
			} else if x > b {
				b = x
			} else {
				ans = false
			}
		}
		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include<iostream>
using namespace std;
int ball[10];
bool flag;  //true??????YES???false??????NO
//?????°??§?§£????????????
void search(int left,int right,int d){//1??????????????°????????´?????????????????????????????????
                                      //2??????????????°????????´?????????????????????????????????
                                      //3??????????????°?????±???

  if(d==10){ //???????????????????????§??\???????????????
    flag=true;
    return;
  }
  if(left<ball[d]) //????????????????????\????????¨????????¶??????????????????
    search(ball[d],right,d+1);
  if(right<ball[d])//????????????????????\????????¨????????¶??????????????????
    search(left,ball[d],d+1);
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    flag=false;//????????°????????????
    for(int j=0;j<10;j++)
      cin>>ball[j];
    search(ball[0],0,1);//????????????????????\??????????????????
                        //3??????????????°?????±???
                        //?????????????????\?????????????????\???????????????????????§
                        //????????\?????????????????????????????????
    if(flag)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}

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

int A[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int B[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

bool isSorted(void)
{
	int i = 1;
	while(A[i]!=0 && i<=9)
	{
		if(A[i] < A[i-1]) return false;
		i++;
	}

	i = 1;
	while(B[i]!=0 && i<=9)
	{
		if(B[i] < B[i-1]) return false;
		i++;
	}

	return true;
}

int main(void)
{
	int n;
	cin >> n;
	bool enable = false;
	for(int i=0; i<n; i++)
	{
		int X[10];
		for(int j=0; j<10; j++)
			cin >> X[j];

		for(int j=0; j<1024; j++)
		{
			int a = 0, b = 0;
			int e = 1;
			for(int k=0; k<10; k++)
			{
				if( (j & e) == e)
				{
					A[a] = X[k];
					a++;
				}
				else
				{
					B[b] = X[k];
					b++;
				}
				e *= 2;
			}
			if(isSorted())
			{
				enable = true;
			}

			//initialize
			for(int j=0; j<10; j++)
			{
				A[j] = 0; B[j] = 0;
			}
		}
		if(enable) cout << "YES" << endl;
		else cout << "NO" << endl;
		enable = false;
	}
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	for(int l=0; l < n; l++){
		bool isLined = true;
		int num[10];
		int b = -1, c = -1;
		for(int i=0; i < 10; i++){
			cin >> num[i];
		}

		for(int i=0; i < 10; i++){
			if(num[i] < b && num[i] < c){
				isLined = false;
				break;
			}
			else if(b < num[i] && c < num[i]){
				if(b < c) c = num[i];
				else b = num[i];
			}
			else if(b < num[i]){
				b = num[i];
			}
			else c = num[i];
		}
		if(isLined) cout << "YES" << endl;
		else cout << "NO" << endl;

	}
}

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

using std::cout;
using std::endl;

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

    while (data_num--) {
        std::array<int, 10> balls;
        for (auto i = 0; i < 10; i++) {
            std::cin >> balls.at(i);
        }

        std::vector<int> b(1, 0), c(1, 0);
        b.push_back(balls.at(0));

        for (auto i = 1; i < 10; i++) {
            int b_end = b.at(b.size() - 1);
            int c_end = c.at(c.size() - 1);
            int ball = balls.at(i);

            if (b_end > ball && c_end > ball) {
                cout << "NO" << endl;
                break;
            } else if (b_end < ball && c_end > ball) {
                b.push_back(ball);
            } else if (b_end > ball && c_end < ball) {
                c.push_back(ball);
            } else {
                if (b_end > c_end) {
                    b.push_back(ball);
                } else {
                    c.push_back(ball);
                }
            }

            if (i == 9) {
                cout << "YES" << endl;
            }
        }
    }

    return 0;
}

C++: #include <stdio.h>

int a[11];

bool dfs(int i, int L, int R){
    if (i == 10) return true;
    if (dfs(i+1, a[i], R) && a[i] > L)
		return true;
    if (dfs(i+1, L, a[i]) && a[i] > R)
		return true;
    return false;
}

void solve(){
	for (int i=0; i<10; ++i){
		scanf("%d", &a[i]);
	}
	printf("%sn", dfs(0, 0, 0)?"YES":"NO");
}

int main (){
	int t;
	scanf("%d", &t);
	while (t --){
		solve();
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  cin>>n;
  rep(i,n){
    vector<int>a,b;
    int tmp;
    cin>>tmp;
    pb(a,tmp);
    rep(j,9){
      cin>>tmp;
      if(a[a.size()-1]<tmp)pb(a,tmp);
      else pb(b,tmp);
    }
    bool han=true;
    rep(j,b.size()-1)if(b[j]>b[j+1])han=false;
    if(han)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int n, a, b;
int data[10] = { 0 };

int main() {
	cin >> n;

	for (int i = 0; i < n; ++i) {
		int boxa = 0, boxb = 0;
		bool flag = false;
		for (int j = 0; j < 10; ++j) {
			cin >> data[j];
		}
		for (int j = 0; j < 10; ++j) {
			if (boxa > boxb && boxa < data[j]) {
				boxa = data[j];
			} else if (boxb < data[j]) {
				boxb = data[j];
			} else if (boxa < data[j]) {
				boxa = data[j];
			} else {
				cout << "NO" << endl;
				flag = true;
				break;
			}
		}
		if (!flag)cout << "YES" << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <stack>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(void)
{
    int s[10], n, b, c;
    bool flag;

    cin >> n;
    rep(i, n) {
        b = 0, c = 0, flag = true;
        rep(i, 10)
            cin >> s[i];
        rep(i, 10) {
            if (s[i] > b)
                b = s[i];
            else if (s[i] > c)
                c = s[i];
            else
                flag = false;
        }
        
        cout << (flag ? "YES" : "NO") << 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<iostream>
using namespace std;main(){int N,i,O=0,B=0,C=0,A;cin>>N;for(i=0;i<N;i++){for(int i=0;i<10;i++){cin>>A;if(!O)A>B?B=A:A>C?C=A:O=true;}cout<<(O?"NO":"YES")<<endl;}}