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<deque>
using namespace std;

int main() {
	int n;
	cin >> n;
	for ( int i = 0; i < n; i++ ){
		deque<int>b,c;
		bool endflag = false;
		int dummy;
		cin >> dummy;
		b.push_back( dummy );
		cin >> dummy;
		c.push_back( dummy );
		for ( int j = 0; j < 8; j++ ){
			cin >> dummy;
			if ( !endflag ) {
				if ( dummy > b[b.size()-1] )	b.push_back( dummy );
				else if ( dummy > c[c.size()-1] )	c.push_back( dummy );
				else {
					cout << "NO" << endl;
					endflag = true;
				}
			}
		}
		if( !endflag )	cout << "YES" << endl;
	}
	
	return 0;
}

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 (l < r)
				swap(l, r);
		}
		if (flag == true)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		N--;
	}
}
int main() {
	int n = 0;
	cin >> n;
	solve(n);
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  int a[10];
  int f,s;
  bool flg=true;
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin>>a[j];
    }
    f=0;s=0;flg=true;
    for(int i=0;i<10;i++){
      if(a[i]<f){
	if(a[i]<s)flg=false;
	else s=a[i];
      }
      else f=a[i];
    }
    if(flg)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

C++: #include <iostream>

using namespace std;

int main(void){

  int a;
  int b[10] = {0};
  int c[10] = {0};
  int out[10] = {0};

  int n;
  cin >> n;
  while(n--){

    for( int l = 10 ; l > 0 ; l-- ){
    cin >> a;
    int i = 0;
    int j = 0;
    int k = 0;
    if( b[i] < a ){
    b[i++] = a;
    }
    else if( c[j] < a ){
	c[j++] = a;
      }
    else out[k++] = a;
    }
    if( out[0] == 0 )cout << "YES" << endl;
    else cout << "NO" << endl;
  }
 return 0;
}

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

using namespace std;

int a[10];
int l, r;

bool dfs(int i)
{
    if (i == 10) return true;

    bool res = false;

    int tmp;

    if (l <= a[i]) {
        tmp = l;
        l = a[i];
        res = res || dfs(i + 1);
        l = tmp;
    }

    if (r <= a[i]) {
        tmp = r;
        r = a[i];
        res = res || dfs(i + 1);
        r = tmp;
    }

    return res;
}

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

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

C++: #include <stdio.h>
#include <vector>
#include <iostream>

using namespace std;

int main() {
	vector<int> left;
	vector<int> right;
	vector<int> all;

	bool flag = true;

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			int temp;
			cin >> temp;
			all.push_back(temp);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			if (left.size() > 0) {
				if (all[10 * i + j] > left[left.size() - 1]) {
					left.push_back(all[10 * i + j]);
				}
				else {
					if (right.size() > 0) {
						if (all[10 * i + j] > right[right.size() - 1])
							right.push_back(all[10 * i + j]);
						else
							flag = false;
					}
					else {
						right.push_back(all[10 * i + j]);
					}
				}
			}
			else {
				left.push_back(all[10 * i + j]);
			}
		}

		if (flag)
			cout << "YES" << endl;
		else
			cout << "NO"<<endl;
		flag = true;
	}

	return 0;
}

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  Solver(vector<int> bs) : bs(bs) {}
  bool solve(int it=0, int a=0, int b=0){
    if (it == bs.size()) return true;
    if (a < bs[it] && solve(it + 1, bs[it], b)) return true;
    if (b < bs[it] && solve(it + 1, a, bs[it])) return true;
    return false;
  }
  vector<int> bs;
};

int main()
{
  int n = in();
  for (int i = 0; i < n; i++){
    vector<int> bs;
    for (int j = 0; j < 10; j++){
      bs.push_back(in());
    }
    Solver solver(bs);
    if (solver.solve()) puts("YES");
    else puts("NO");
  }
  return (0);
}

C++: #include <iostream>
using namespace std;
int main()
{
cout<<"YES"<<endl;
cout<<"NO"<<endl;
}

C++: #include <iostream>
#include <algorithm>
#include <stack>
using namespace std;
int a[10];
bool ans;
void dfs(int i,int r,int l){
	if(i==10)return;
	if(a[i]<r&&a[i]<l){
		ans=0;
		return;
	}
	if(r<a[i])dfs(i+1,a[i],l);
	if(l<a[i])dfs(i+1,r,a[i]);
}
int main(){
	int t;
	cin>>t;
	while(t--){
		ans=1;
		for(int i=0;i<10;i++)cin>>a[i];
		dfs(0,0,0);
		if(ans)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

C++: #include<cstdio>

int main(void){
	int n,i,j;
	int a[1024][10];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<10;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(i=0;i<n;i++){
		int b[10],c[10];
		b[0]=a[i][0];
		bool x=true;
		int k=0,l=0;
		for(j=1;j<10;j++){
			if(a[i][j]>b[k]){
				k++;
				b[k]=a[i][j];
			}else {
				c[l]=a[i][j];
				l++;
			}
		}

		for(j=0;j<l-2;j++){
			if (c[j]>c[j+1]){
				x=false;
			}
			//if(c[j]>c[j+1]) break;
		}
		if(x==true){
			printf("YES\n");
		} else{
			printf("NO\n");
		}	
	}
	return 0;
}

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

int n;
int a[10];


bool dfs(int i, int left, int right) {
    if (i == 9) return a[i] > left || a[i] > right;
    if (a[i] > left && dfs(i+1, a[i], right)) return true;
    if (a[i] > right && dfs(i+1, left, a[i])) return true;
    return false;
}

void solve() {
    if (dfs(0,0,0)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> a[j];
        }
        solve();
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  while (n--) {
    int a, b = 0, c = 0;
    bool f = true;
    for (int i = 0; i < 10; i++) {
      cin >> a;
      if (b < a) b = a;
      else if (c < a) c = a;
      else f = false;
    }
    cout << (f ? "YES\n" : "NO\n");
  }
}