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>
using namespace std;
int main(){
    int n,a[10];
    scanf("%d",&n);
    for(int ix=0;ix<n;ix++){
        for(int jx=0;jx<10;jx++){
            scanf("%d",&a[jx]);
        }
        bool is=false;
        for(int i=0;i<(1<<10);i++){
            vector<int> b,c;
            for(int j=0;j<10;j++){
                if(i&(1<<j))b.push_back(a[j]);
                else c.push_back(a[j]);
            }
            bool isb=true,isc=true;
            if(!b.empty()){
                for(int j=1;j<b.size();j++){
                    if(b[j-1]>b[j]){
                        isb=false;
                        break;
                    }
                }
            }
            if(!c.empty()){
                for(int j=1;j<c.size();j++){
                    if(c[j-1]>c[j]){
                        isb=false;
                        break;
                    }
                }
            }
            if(isb&&isc){
                is=true;
                break;
            }
        }
        if(is)printf("YES\n");
        else printf("NO\n");
    }
}

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

signed main()
{
  int n;
  vector<int> kanade;
  cin >> n;

  for (int i = 0; i < n; i++) {
    kanade.clear();
    for (int j = 0; j < 10; j++) {
      int tmp;
      cin >> tmp;
      kanade.push_back(tmp);
    }

    int b = 0, c = 0;
    bool hayami = true;
    for (int j = 0; j < 10; j++) {
      if (b == 0 || b < kanade[j]) {
        b = kanade[j];
      } else if (c == 0 || c < kanade[j]) {
        c = kanade[j];
      } else {
        hayami = false;
      }
    }

    if (hayami) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return (0);
}

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

const int N = 10;

int a[N];

void input()
{
    for (int i = 0; i < N; i ++) {
        scanf("%d", &a[i]);
    }
}

void solve()
{
    bool res = false;
    for (int k = 0; k < (1<<10); k++) {
        int num = 0;
        int i;
        for (i = 0; i < N; i ++) {
            if ( (1 << i)&k ) {
                if (a[i] > num)
                    num = a[i];
                else
                    break;
            }
        }
        if (i < N)
            continue;
        num = 0;
        for (i = 0; i < N; i ++) {
            if ( ((1 << i)&k) == 0 ) {
                if (a[i] > num)
                    num = a[i];
                else
                    break;
            }
        }
        if (i == N) {
            res = true;
            //printf("k=%d\n", k);
            break;
        }
    }
    if (res)
        printf("YES\n");
    else
        printf("NO\n");
}

int main(void)
{
    int t;
    cin >> t;
    while (t--) {
        input();

        solve();
    }

    return 0;
}

C++: #include <stdio.h>
#define Max_N 10

int N;
int preA,preB;
int data[Max_N+1];

bool dfs(int x){
	if(x==10) return true;
	if(preA<data[x]){
		preA=data[x];
		if(dfs(x+1)) return true;
	}
	if(preB<data[x]){
		preB=data[x];
		if(dfs(x+1)) return true;
	}
	return false;
}

void solve(){
	preA=0;preB=0;
	if(dfs(0)) printf("YES\n");
	else printf("NO\n"); 
}

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		for(int j=0;j<10;j++){
			scanf("%d",&data[j]);
		}
		solve();
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int N;

int nums[10];

bool dfs(int a, int b, int i) {
	if (i == 10) {
		return true;
	}
	bool ret = false;
	if (nums[i] > a) {
		ret = ret || dfs(nums[i], b, i + 1);
	}
	if (nums[i] > b) {
		ret = ret || dfs(a, nums[i], i + 1);
	}
	return ret;
}

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

C++: #include<stdio.h>
int a[10],b=0,c=0;
bool tube[10];
bool dfs(int i){
    if(i==10) return true;
    bool flagb,flagc;
    if(b>=a[i]&&c>=a[i]) return false;
    if(b<a[i]){
        int oldb=b;
        b=a[i];
        flagb=dfs(i+1);
        b=oldb;
        if(flagb) return true;
    }
    if(c<a[i]){
        int oldc=c;
        c=a[i];
        flagc=dfs(i+1);
        c=oldc;
        if(flagc) return true;
    }
    return false;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            scanf("%d",a+j);
        }
        if(dfs(0)) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

C++: #include<iostream>
#include<stack>
#include<map>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    stack<pair<int,int> > back;
    int a = 0,b = 0,row[10];
    bool f = true;
    for(int i=0; i<10; i++){cin >>row[i];}
    a = row[0];
    for(int i=1; i<10; i++){
      if(a < row[i] && b > row[i]){a = row[i];}
      else if(a > row[i] && b < row[i]){b = row[i];}
      else if(a < row[i] && b < row[i]){
	back.push(make_pair(a,i));
	a = row[i];
      }
      else if(a > row[i] && b > row[i]){
	if(back.empty()){cout <<"NO"<<endl;f = false;break;}
	else{
	  i = back.top().second;
	  a = back.top().first;
	  b = row[i];
	  back.pop();
	}
      }
    }
    if(f){cout <<"YES"<<endl;}
  }
  return 0;
}

C++: #include<iostream>
main(){
int n,i,A,B,C;
for(std::cin>>n;n-->0;puts(i>20?"NO":"YES"))
 for(B=C=i=0;i++<10;){
  std::cin>>A;
  if(B<A)B=A;else C<A?C=A:i=30;
 }
}

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

using namespace std;



int main(){
	int n;
	int left[11],right[11];
	int l=1,r=1;
	int number;
	bool T = 1;

	memset(left,0,sizeof(left));
	memset(right,0,sizeof(right));

	cin >> n;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			cin >> number;
			if(left[l-1] < number && (number < right[r-1] || (left[l-1] > right[r-1] && right[r-1] < number))){
				left[l] = number;
				l++;
			}else if(right[r-1] < number){
				right[r] = number;
				r++;
			}else if(left[l-1] == right[r-1]){
				left[l] = number;
				l++;
			}else {
				cout << "NO" << endl;
				T = 0;
				break;
			}
		}

		if(T){
			cout << "YES" << endl;
			T = 1;
		}
	}
}

C++: #include<iostream>
using namespace std;
int ball[10];
int B=0,C=0;
int N=10;

bool solve(int i){
	if(i==N)return true;
	if(B<ball[i]){
	B=ball[i];
	if(solve(i+1))return true;
	}
	if(C<ball[i]){
	C=ball[i];
	if(solve(i+1))return true;
	}
	return false;
}



int main(){
	int X;
	cin>>X;
	for(int i=0;i<X;i++){
		for(int i=0;i<10;i++)cin>>ball[i];
		if(solve(0))cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	
	
	}



return 0;
}

C++: #include<iostream>
using namespace std;
int n,a,t[11],tc,u[11],uc,flg;
int main(){
  cin>>n;
  while(n--){
    flg=t[0]=u[0]=tc=uc=0;
    for(int i=0;i<10;i++){
      cin>>a;
      if(t[tc]>u[uc]&&t[tc]<a){
	t[tc+1]=a;tc++;
      }else if(t[tc]<u[uc]&&u[uc]<a){
	u[uc+1]=a;uc++;
      }else if(t[tc]<a){
	t[tc+1]=a;tc++;
      }else if(u[uc]<a){
	u[uc+1]=a;uc++;
      }else{
	flg=1;
      }
    }
    /*
    for(int i=0;i<tc;i++)cout<<t[i]<<' ';
    cout<<endl;
    for(int i=0;i<uc;i++)cout<<u[i]<<' ';
    cout<<endl;
    */
    cout<<(flg?"NO":"YES")<<endl;
  }

}