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 <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		bool can = true;
		int left = 0, right = 0;
		rep(j, 10){
			int a;
			scanf("%d", &a);
			if(min(left, right) > a){
				can = false;
				break;
			}
			if(max(left, right) < a){
				if(left<right) right = a;
				else left = a;
			}else{
				if(left<right) left = a;
				else right = a;
			}
		}

		puts(can ? "YES" : "NO");
	}

	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int a[10];
int main() {
	int n; cin >> n;
	rep(k, n) {
		rep(i, 10)scanf("%d", &a[i]);
		rep(i, 1 << 10) {
			stack<int>s[2];
			rep(j, 10)if (s[(i >> j) & 1].empty() || a[j] > s[(i >> j) & 1].top())s[(i >> j) & 1].push(a[j]);
			if (s[0].size() + s[1].size() == 10) { puts("YES"); break; }
			if (i == (1 << 10) - 1)puts("NO");
		}
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int a[10];

bool dfs(int i, vector<int>& l, vector<int>& r) {
  if (i == 10) return true;
  bool res = false;
  if (l.empty() || l.back() < a[i]) {
    l.emplace_back(a[i]);
    res |= dfs(i + 1, l, r);
    l.pop_back();
  }
  if (r.empty() || r.back() < a[i]) {
    r.emplace_back(a[i]);
    res |= dfs(i + 1, l, r);
    r.pop_back();
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> a[j];
    }
    vector<int> l, r;
    cout << (dfs(0, l, r) ? "YES" : "NO") << endl;
  }

  return 0;
}

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

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 {
				ans = false;
				break;
			}
		}
		cout << (ans ? "YES" : "NO") << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <sstream>
#include <cstdio>
#include <stack>
using namespace std;

// Ball(0033)
int main()
{
	int N;
	while (cin >> N) {
		for (int i = 0; i < N; ++i) {
			vector<int> ball(10);
			for (int j = 0; j < 10; ++j)
				cin >> ball[j];

			int prev = ball.front();
			ball[0] = -1;
			for (int j = 1; j < ball.size(); ++j) {
				if (prev < ball[j]) {
					prev = ball[j];
					ball[j] = -1;
				}
			}

			prev = -1;
			for (int j = 0; j < ball.size(); ++j) {
				if (prev == -1 && ball[j] != -1) {
					prev = ball[j];
					ball[j] = -1;
				} else {
					if (prev < ball[j]) {
						prev = ball[j];
						ball[j] = -1;
					}
				}
			}

			if (count(ball.begin(), ball.end(), -1) == 10)
				cout << "YES" << endl;
			else
				cout << "NO" << endl;
		}
	}
	return 0;
}

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

using namespace std;

int A[10];
int n;

bool dfs(int, int, int);

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
  {
  for(int i = 0; i < 10; i++)
    scanf("%d", &A[i]);

    cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
  }
  return 0;
}

bool dfs(int ai, int b, int c)
{
  if(ai == 10)
    return true;
  int bb = b;
  int bc = c;
  bool ans = false;
  if(A[ai] > b)
  {
    b = A[ai];
    //cout << b  << " into B" << ai << endl;
    ans = ans || dfs(ai + 1, b, c);
    b = bb;
  }
  if(A[ai] > c)
  {
    c = A[ai];
    //cout << b  << " into C" << ai << endl;
    ans = ans || dfs(ai + 1, b, c);
    c = bc;
  }
  return ans;
}

C++: #include<stdio.h>

int main()
{
  int i,j;
  int n,N;
  int b=0,c=0;
  char *str="YES";
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      for(j=0;j<10;j++)
	{
	  scanf("%d",&n);
	  if(n>b)
	    b=n;
	  else if(n>c)
	    c=n;
	  else
	    str="NO";
	}
      puts(str);
    }
  
  return 0;
}

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;
 }
}