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>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 25
using namespace std;
int n,m;
int tmax,tmin;
int a[Maxn];
int ans1[Maxn];
int ans2[Maxn];
int main()
{
    int f;
    cin>>n;
    while(n--)
    {
        f=1;
        MEM(a,0);
        MEM(ans1,0);
        MEM(ans2,0);
        for(int i=1; i<=10; i++)
            cin>>a[i];
        ans1[1]=a[1];
        ans2[0]=0;
        int p1=0,p2=0;
        int i;
        for(i=2; i<=10; i++)
        {
//            if(ans1[p1]>ans[p2])
//            {
//                tmax=ans1[p1];
//                tmin=ans2[p2];
//            }
//            else
//            {
//                tmax=ans2[p2];
//                tmin=ans1[p1];
//            }
            if(a[i]>ans1[p1])
            {
                ans1[++p1]=a[i];
            }
            else if(a[i]>ans2[p2])
            {
                ans2[++p2]=a[i];
            }
            else
            {
                cout<<"NO"<<endl;
                break;
            }
        }
        if(i>10)
            cout<<"YES"<<endl;
    }
}

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

int main()
{
	int n,a;

	std::cin >> n;

	std::vector<int> ball;

	for(int i=0; i<n; ++i)
	{
		for(int i=0; i<10; ++i)
		{
			std::cin >> a;

			ball.push_back(a);
		}
		
		int right=-1,left=-1;

		right = ball[0];

		bool flg1 = 1;

		bool rightOK;

		bool leftOK;

		for(int i=1; i<10; ++i)
		{
			rightOK = ball[i]>right;

			leftOK = (ball[i]>left || left==-1);

			if(rightOK && leftOK)
			{
				if(right>left)
				{
					right = ball[i];
				}
				else
				{
					left = ball[i];
				}
			}
			else if(rightOK)
			{
				right =  ball[i];
			}
			else if(leftOK)
			{
				left = ball[i];
			}
			else
			{
				flg1 = 0;

				break;
			}
		}

		std::cout << (flg1 ? "YES\n" : "NO\n");

		ball.clear();
	}
}

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

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

int main() {
	int n; cin >> n;
	int l = 0, r = 0;
	while (n--) {
		bool ok = true;
		rep(i, 10) {
			int b; cin >> b;
			if(l < b) l = b;
			else if (r < b) {
				r = b;
				if (l < r) swap(l, r);
			}
			else {
				ok = false;
			}
		}
		cout << (ok ? "YES" : "NO" ) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string.h>
using namespace std;
int main(void)
{
  int n;
  cin>>n;
 
  for(int i=0;i<n;i++)
    {
      int num1[10];
      int count=0;
      for(int j=0;j<10;j++)
	{
	  cin>>num1[j];
	}
      for(int k=0;k<10-1;k++)
	{
	  int num2[10];
	  if(num1[k]>num1[k+1])
	    {
	      int l=0;
	      num2[l]=num1[k];
	      l++;
	    }
	  if(num1[k]>num1[k+1] && num2[k]>num2[k+1] && num2[k+1]!=0)count++;
	}
      if(count>0)cout<<"NO"<<endl;
      else cout<<"YES"<<endl;
      
    }
  return 0;
}

C++: public class Main {
	void run() {
		scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] boll = new int[10];
		for(int k = 0; k < n; k++) {
			for(int i = 0; i < 10; i++) {
				boll[i] = scan.nextInt();
			}
			int judg = 0;
			for(int i = 0; i < n; i++) {
				int right,left;
				right = boll[0];
				left = 0;
				for(int m = 1; m < 10; m++) {
					if(right > boll[m]) {
						if(left < boll[m]) {
							left = boll[m];
						}
						else {
							judg = 0;
							break;
						}
					}
					else if(right < boll[m]) {
						right = boll[m];
					}
					judg = 1;
				}
				if(judg == 0) {
					System.out.println("NO");
				}
				else {
					System.out.println("YES");
				}
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

C++: #include<iostream>
using namespace std;
int main(void)
{
int n;
cin>>n;
int b[10]={0};
int c[10]={0};
for(int i=0;i<n;i++)
{
	int a[10];
	for(int j=0;j<10;j++)
	{
	int x;
	cin>>x;
	a[j]=x;
	}
	int k=0;
	for(int j=0;j<10-1;j++)
	{
	
	if(a[j]>a[j+1])
		{
		b[k]=a[j];
		k++;
		}
	else c[j]=a[j];
	}
	for(int i=0;i<10-1;i++)
	{
	if(b[i]>b[i+1] && b[i+1]!=0 || c[i]>c[i+1] && c[i+1]!=0)
	{
	cout<<"NO"<<endl;
	break;
	}
	else 
	{
	cout<<"YES"<<endl;
	break;
	}
	}
}
return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,s;
  cin >> n;
  for(int i=0;i<n;i++){
    int a=0,b=0,flg=0;
    for(int j=0;j<10;j++){
      cin >> s;
      if(s > a) a=s;
      else if(s > b) b=s;
      else flg=1;
    }
    printf("%s\n",flg==0?"YES":"NO");
  }
}

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;std::cin>>A,i<10;i++){
  if(B<A)B=A;else C<A?C=A:f=1;
 }
}

C++: #include <stdio.h>

int main(void)
{
	int tubeM[10];
	int tube1[10], tube2[10];
	int i, j, k;
	int n;
	int ans;
	
	for (i = 0; i < 10; i++){
		tube2[i] = 0;
	}
	
	scanf("%d", &n);
	
	while(n){
		for (i = 0; i < 10; i++){
			scanf("%d", &tubeM[i]);
		}
		
		tube1[0] = tubeM[0];
		for (i = 1, j = 0, k = 0; i < 10; i++){
			if (tubeM[i] > tube1[j]){
				tube1[j + 1] = tubeM[i];
				j++;
			}
			else {
				tube2[k] = tubeM[i];
				k++;
			}
		}
		
		ans = 0;
		for (i = 1; tube2[i] != 0; i++){
			if (tube2[i - 1] > tube2[i]){
				ans = 1;
				break;
			}
		}
		
		if (ans == 0){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		
		n--;
	}
	
	return (0);
}