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 main(){
  int N;
  cin>>N;
  while(N--){
    int B,C=0,i=0,b[10];
    bool f=true;
    cin>>b[0]>>b[1]>>b[2]>>b[3]>>b[4]>>b[5]>>b[6]>>b[7]>>b[8]>>b[9];
    while(i<10){
      cout << b[i] << endl;
      if(B<b[i]){
	if(B<C&&C<b[i])C=b[i];
	else B=b[i];
      }else if(C<b[i]){
	C=b[i];
      }else{
	f=false;break;
      }
      i++;
    }
    cout<<(f?"YES":"NO")<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i, m) for(long long i=0; i<m; ++i)
#define FOR(i, n, m) for(long long i=n; i<m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vll;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	REP(roop,n) {
		vector<int> num(10);
		REP(i,10) cin>>num[i];
		bool d=false;
		REP(bit,(1<<10)) {
			vector<bool> used(10,false);
			ll buf=bit;
			REP(i,10) {
				if(buf%2==1) used[i]=true;
				buf/=2;
			}
			bool e=true;
			int an=0,bn=0;
			REP(i,10) {
				if(used[i]) {
					if(an>num[i]) e=false;
					an=num[i];
				} else {
					if(bn>num[i]) e=false;
					bn=num[i];
				}
			}
			d=d|e;
		}
		if(d) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <stack>
#include <sstream>
using namespace std;
int main(){
  int nlist[10],n;
  bool a,b;//a=ôÌ®,b=ïÌ®
  cin>>n;
  for(;n;n--){
    a=b=true;
    for(int i=0;i<10;i++)
      cin>>nlist[i];
    for(int j=2;j<10;j++)
      if(nlist[j-2]>nlist[j]){(j%2)?a=false:b=false;break;}
    (a&&b)?cout<<"YES"<<endl:cout<<"NO"<<endl;
  }
  return 0;
}

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

int data[10];

bool bt(int b, int c, int no) {
    if (no >= 10) return true;
    else if (data[no] < b && data[no] < c) return false;//どっちにも入れれない＞＜

    if (data[no] > b) return bt(data[no], c, no+1);
    else if (data[no] > c) return bt(b, data[no], no+1);
}

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

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

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int t,flag;
	//freopen("C:\\Users\\国民党\\Desktop\\text.txt", "r", stdin);
	cin >> t;
	while (t--)
	{
		flag = 1;
		int a, b = -1, c = -1;
		for (int i = 1; i <= 10; i++)
		{
			cin >> a;
			if (a > b)
			{
				b = a;
			}
			else if (a > c)
			{
				c = a;
			}
			else
				flag = 0;
		}
		cout << ((flag == 1) ? "Yes" : "No" )<< endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
int s[10]={0};
 
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        for(int i=0;i<10;i++)
            scanf("%d",&s[i]);
        int a=0,b=0;
        bool flag=0;
        for(int i=0;i<10;i++)
        {
            if(s[i]<a&&s[i]<b)
            {
                flag=1;
                break;
            }
            else if(s[i]<a&&s[i]>b)b=s[i];
            else if(s[i]>a&&s[i]<b)a=s[i];
            else
            {
                a=a>b?s[i]:a;
                b=a<b?s[i]:b;
                if(a==b)a=s[i];
            }
        }
        if(flag)printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}

C++: #include<cstdio>
#include<queue>
#include<set> 
#include<cstdlib> 
#include<cstring>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
const int inf = 0x3f3f3f3f;
using namespace std;

int ball[11], r[11], l[11];
int a, b;

bool DFS(int stp){
	if(stp == 10)
		return true;
	if(ball[stp] > l[a]){
		l[++a] = ball[stp]; 
		return DFS(stp + 1); 
	}
	if(ball[stp] > r[b]){
		r[++b] = ball[stp];
		return DFS(stp + 1);
	}
	return false;
}

int main()
{
	ios::sync_with_stdio(false);
	int t;
	cin >> t; 
	while(t--){
		a = 0;
		b = 0;
		for(int i = 0; i < 10; i++){
			cin >> ball[i];
		}
		l[a] = 0;
		r[b] = 0;
		cout << ((DFS(0) == 1)?"YES" : "NO") << endl;
//		for(int i = 0; i <= a; i++)
//			cout << l[i] << " ";
//		cout << endl;
//		for(int i = 0; i <= a; i++)
//			cout << r[i] << " ";
//		cout << endl;
		
	}
	
	return 0;
}

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

int main() {
	int n, x,a=0,b=0;
	bool f;
	cin >> n;
	for (int lop = 0,f=1,a=0,b=0; lop < n; lop++) {
		for (int i = 0; i < 10; i++) {
			cin >> x;
			if (f) {
				if (a < x) {
					a = x;
					continue;
				}
				if (b < x) {
					b = x;
					continue;
				}
				f = 0;
			}
		}

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

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

int main(){
	int n,ball,tp[2],con;
	
	cin >> n;
	
	for(; n > 0; n--){
		
		tp[0] = tp[1] = 0;
		
		for(int i = 0; i < 10; i++){
			cin >> ball;
			
			if(tp[0] > tp[1]){
				con = 0;
			}else{
				con = 1;
			}
			
			if(ball > tp[con]){
				tp[con] = ball;
			}else if(ball > tp[!con]){
				tp[!con] = ball;
			}else{
				cout << "NO" << endl;
				break;
			}
			
			if(i == 9){
				cout << "YES" << endl;
			}
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	int N; cin >> N;
	while(N--) {
		int bend = 0, cend=0;
		bool f = true;
		rep(i,10) {
			int num; cin >> num;
			if(bend < num) bend = num;
			else if(cend < num) cend = num;
			else {
				f = false;
				break;
			}
		}
		cout << (f ? "YES" : "NO") << endl;
	}
	return 0;
}