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(void){
  int N,t,B,C,i,j;
  cin >> N;
  for(i = 0 ; i < N ; i++){
    for( B = 0, C = 0, j = 0; j < 10; j++){
      cin >> t;
      if(B >= t && C >= t) break;
      else if(B < t && C < t){
	if(B < C) C = t;
	else B = t;
      }
      else if(B < t) B = t;
      else if(C < t) C = t;
    }
    if(j == 10) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
const int maxn = 10;
int flag = 0;
int a[maxn];
void dfs(int l, int r, int x) {
	if (x == 10) {
		flag = 1;
		return;
	}
	if (a[x] > l) dfs(a[x], r, x + 1);
	else if (a[x] > r) dfs(l, a[x], x + 1);
	if (flag == 1) return;

}


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

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

int a[10];
bool ans=false;
int siwake(int cun,int b,int c){
	if(cun == 10){ans=true;}
	if(a[cun]>b){siwake(cun+1,a[cun],c);}
	if(a[cun]>c){siwake(cun+1,b,a[cun]);}
	return 0;
}

int main(){
	int i,z,zc;
	cin>>z;
	for(zc=0;zc!=z;zc++){
		for(i=0;i!=10;i++){cin>>a[i];}
		siwake(0,0,0);
		if(ans==true){cout<<"YES"<<endl;
			ans=false;
		}
		else{cout<<"NO"<<endl;}
	}
}

C++: #include <iostream>
#define INF -99999999

using namespace std;

int N;
int a[10];

bool solve()
{
	bool flag = true;
	int b[11], c[11];
	b[0] = INF + 1;
	c[0] = INF;
	int p1 = 0,p2 = 0;
	for(int i = 0; i < 10; i++){
		if(a[i] > b[p1]){
			if(a[i] > c[p2]){
				if(b[p1] > c[p2])
					b[++p1] = a[i];
				else
					c[++p2] = a[i];
			}
			b[++p1] = a[i];
		}
		else if(a[i] > c[p2])
			c[++p2] = a[i];
		else{
			flag = false;
			break;
		}
	}
	return flag;
}

int main()
{
	cin >> N;
	while(N--){
		for(int i = 0; i < 10; i++)
			cin >> a[i];
		if(solve())
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int A[10];
bool dfs(int start, int topB, int topC){
	if(start == 9){
		if(A[start] > topB || A[start] > topC){
			return true;
		}
		else{
			return false;
		}
	}
	bool b1 = false, b2 = false;
	if(A[start] > topB){
		b1 = dfs(start+1, A[start], topC);
	}
	if(A[start] > topC){
		b2 = dfs(start+1,topB,A[start]);
	}
	return (b1 || b2 );
}
int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; ++i){
		for(int j = 0; j < 10; ++j){
			cin >> A[j];
		}
		bool result = dfs(0,0,0);
		if(result == true){
			cout << "YES" << endl; 
		}
		else{
			cout << "NO" <<endl; 
		}
	}
	return 0;
}

C++: #include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

string solve(){
    vector<int> a(10,0);
    rep(i,10){
        cin>>a[i];
    }
    for(int bit = 0; bit < (1<<11);++bit){
        vector<int> bv,cv;
        int b=0,c=0;
        bool is = true;
        rep(i,10){
            if(bit & (1<<i)){
                if(b<a[i]) b = a[i];
                else is = false;
            }else{
               if(c<a[i])c = a[i];
               else is = false;
            }
        }
        if(is) return "YES";
    }
    return "NO";

}

int main(){
    int n;
    cin >> n;
    rep(i,n){
        cout<<solve()<<endl;
    }

    return 0;
}

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

using namespace std;
int a[10];
bool dfs(int k,int B,int C)
{
    if(k==10)
        return true;
    if(a[k]>B)
    {
        if(dfs(k+1,a[k],C))
            return true;
    }
    if(a[k]>C)
    {
        if(dfs(k+1,B,a[k]))
            return true;
    }
    return false;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        for(int i=0;i<10;i++)
            cin>>a[i];
        if(dfs(0,0,0))
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

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

C++: #include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define SC(x) scanf("%d",&x);
#define pr(x)  cout << x << endl;
#define mem(arr,v) memset(arr,v,sizeof arr);
#define bug(x) cout << "#x = " << x <<endl;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
typedef long long ll;
using namespace std;
int a[maxn];
stack<int> s[2];

bool dfs(int pos) {
//	bug(pos)
	if(pos == 10) return true;
	int cur = a[pos];
	for(int i = 0; i < 2 ; i++) {
		if(s[i].empty() || s[i].top() <= cur) {
			s[i].push(cur);
			if(dfs(pos + 1)) return true;
			s[i].pop();
		}
	}
	return false;
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		for(int i =0 ; i < 2; i++)
			while(!s[i].empty())
				s[i].pop();
		for(int i = 0 ; i < 10 ; i++)
			cin >> a[i];
		if(dfs(0))
			puts("YES");
		else
			puts("NO");
	}
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;cin >> n;
  while(n--){
    int r=0,l=0,d;
    bool f=false;
    for(int i=0;i<10;i++){
      cin >> d;
      //cout << d << endl;
      if(r<d){
	if(r<l&&l<d) l=d;
	else r=d;
      }else if(l<d){
	l=d;
      }else{
	f=true;
	break;
      }
      //cout << l << ":" << r << endl;
    }
    if(f) cout << "NO" << endl;
    else cout << "YES" << endl;
  }  
}

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

int l=0, r=0;
bool flag=true;

void solve(int N) {
	int a = 0;
	while (N > 0) {
		for (int i = 0; i < 10; i++) {
			cin >> a;
			if (a > l)
				l = a;
			else if (a > r)
				r = a;
			else {
				flag = false;
			}
		}
		if (flag == true)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		N--;
	}
}
int main() {
	int n = 0;
	cin >> n;
	solve(n);
	return 0;
}

C++: #include<stdio.h>
main(){
    int x[10],y[10],z[10],i,j,n,cz,cy,tmp;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        tmp=0;
        cy=0;cz=0;
        for(j=0;j<10;j++){
        scanf("%d",&x[j]);
        z[j]=0;y[j]=0;
        }
        for(j=0;j<10;j++){
        if(x[j]>=y[cy-1*cy>0])
        y[cy++]=x[j];
        else if(x[j]>=z[cz-1*cz>0])
        z[cz++]=x[j];
        else
        tmp=1;
        }
        if(tmp==1)
        printf("No\n");
        else
        printf("Yes\n");
    }
}