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 <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int a[10];
int ok;
vector <int> n;
vector <int> m;
void bfs(int cur)
{
    if(cur==10)
    {
        ok=1;
        return;
    }
    if(a[cur]>n.back())
    {
        n.push_back(a[cur]);
        bfs(cur+1);
    }
    if(a[cur]>m.back())
    {
        m.push_back(a[cur]);
        bfs(cur+1);
    }
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        ok=0;
        while(!n.empty())
        {
            n.pop_back();
        }
        while(!m.empty())
        {
            m.pop_back();
        }
        n.push_back(0);
        m.push_back(0);
        for(int i=0;i<10;i++)
            scanf("%d",a+i);
            bfs(0);
        if(ok)
            printf("YES\n");
        else
            printf("NO\n");
    }
}

C++: #include <stdio.h>

int ball[10];

bool can(int n,int left,int right){
	bool flag;
	
	if(n==10) return true;
	if(ball[n]>right && can(n+1,left ,ball[n]))return true;
	if(ball[n]>left  && can(n+1,ball[n]),right)return true;
	
	return false;
}


int main(){
	
	int N;
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++){
		for(j=0;j<10;j++){
			scanf("%d",&ball[j]);
		}
		
		printf(can(0,0,0)?"YES":"NO");
		
		
	
}

C++: /* AOJ0033 Ball */

#include <stdio.h>

#define N 10

int main(void)
{
    int n, ans, i;

    scanf("%d", &n);
    while(n--) {
        ans = 1;
        int a, b=-1, c=-1;
        for(i=1; i<=N; i++) {
            scanf("%d", &a);
            if(ans) {
                if(a > b)
                    b = a;
                else if(a > c)
                    c = a;
                else
                    ans = 0;
            }
        }

        printf("%s\n", ans ? "YES" : "NO");
    }

    return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

bool solve(vector<int> data) {
	vector<int> B(1, 0), C(1, 0);
	int b=-1, c=-1;
	for (int i=0; i<10; i++) {
		if (b == -1) {
			B[0] = data[i];
			b++;
		} else if (B[b] > data[i]) {
			if (c == -1) {
				C[0] = data[i];
				c++;
			} else if (C[c] < data[i]) {
				C.push_back(data[i]);
				c++;
			} else {
				return false;
			}
		} else {
			B.push_back(data[i]);
			b++;
		}
	}
	return true;
}

int main() {
	int N; cin >> N;
	vector<int> data(10); bool b;
	for (int i=0; i<N; i++) {
		cin >> data[0] >> data[1] >> data[2] >> data[3] >> data[4] >> data[5] >> data[6] >> data[7] >> data[8] >> data[9];
		b = solve(data);
		if (b) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
}

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

using namespace std;

int main(){
	int N,temp;
	int b,tempb,tempc,ch;
	
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&tempb);
		scanf("%d",&temp);
		tempc=0;
		ch=0;
		if(tempb<temp)
		tempb=temp;
		else
		tempc=temp;
		for(int j=1;j<10;j++){
			scanf("%d",&temp);
			if(tempb<temp)
			tempb=temp;
			else if(tempc<temp)
			tempc=temp;
			else{
				ch=1;
				break;
			}
		}
		if(ch==0)
		printf("YES\n");
		else
		printf("NO\n");
	}
}

C++: #include<iostream>
using namespace std;
#define NUM 10
int main(){
  int n;
  int ball[NUM];
  int b[NUM];
  cin>>n;
  for(int c=0;c<n;c++){
    for(int i=0;i<NUM;i++){
      cin>>ball[i];
      b[i]=-1;
    }
    int x=0;
    for(int j=0;j<NUM-1;j++){

      while(j<NUM-1 && ball[j]>=ball[j+1]){
	b[x]=ball[j+1];
	x++;
	j++;
      }
    }
    int f=true;
    for(int j=1;j<NUM && b[j]>0;j++){
      if(b[j]<=b[j-1]){
        f=false;
	break;
      }
    }
    if(f)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
}

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

#define MAX 10	// ÊÌ

int main()
{
	stack<int> B, C;
	int A;
	int n;
	int i;
	int flag;

	cin>>n;
	for (i = 0; i < n; i++) {
		while(B.size()) B.pop();
		while(C.size()) C.pop();
		flag = 1;
		while (B.size()+C.size() < MAX) {
			cin>>A;

			if (B.size()==0) {
				B.push(A);
				continue;
			}
			else if (C.size()==0) {
				C.push(A);
				continue;
			}

				if (B.top() < A) {
					B.push(A);
				} else if (C.top() < A) {
					C.push(A);
				} else {
					cout<<"NO"<<endl;
					flag = 0;
					break;
				}
		}
		if (flag) cout<<"YES"<<endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a;
  cin >> n;
  for(int i=0;i<n;i++){
    long long b=0,c=0;
    bool f=true;
    for(int j=0;j<10;j++){
      cin >> a;
      if(b<a){
        b=a;
      }else if(c<a){
        c=a;
      }else{
        f=false;
      }
    }
    cout << (f?"YES":"NO") << endl;
  }
  return 0;
}

C++: #include<cstdio>
#define MAX(x,y) ((x>y)? x:y)

using namespace std;

int BOX[2];
int n;
int DATE[10];
bool answer=true;


int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		BOX[0]=0;BOX[1]=0;
		for(int j=0;j<10;j++)
		{
			scanf("%d",&DATE[j]);
		}
		for(int j=0;j<10;j++)
		{
			if(j==0)BOX[0]=DATE[j];
			else
			{
				if(BOX[0]>DATE[j]&&BOX[1]>DATE[j])answer=false;
				else if(BOX[0]>DATE[j])BOX[1]=DATE[j];
				else if(BOX[1]>DATE[j])BOX[0]=DATE[j];
				else if(BOX[0]>BOX[1])BOX[0]=DATE[j];
				else BOX[1]=DATE[j];

			}
		}
		if(answer==true) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

stack<int> b,c;

int main()
{
    int ball,n,flag=0;
    scanf("%d", &n);
    for(int i=0;i<n;++i) {
        for(int j=0;j<10;++j) {
            scanf("%d", &ball);
            if (b.empty())           { b.push(ball); continue; }
            else if (b.top() < ball) { b.push(ball); continue; }
            else if (c.empty())      { c.push(ball); continue; }
            else if (c.top() < ball) { c.push(ball); continue; }
            else { ++flag; break; }
        }
        (flag) ? puts("NO") : puts("YES");
    }

    return 0;
}

C++: #include <stdio.h>

int a[11];

bool dfs(int i, int R, int L){
    if (i == 10) return true;
    if (a[i] > R && dfs(i+1, a[i], L))
		return true;
    if (a[i] > L && dfs(i+1, R, a[i]))
		return true;
    return false;
}

void solve(){
	for (int i=0; i<10; ++i){
		scanf("%d", &a[i]);
	}
	if (dfs(0, 0, 0))
		printf("YES");
	else 
		printf("NO");
}

int main (){
	int t;
	scanf("%d", &t);
	while (t --){
		solve();
	}
	return 0;
}

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

int main() {

  int n;
  cin >> n;

  for ( int i = 0; i < n; i++ ) {

    int b = 0;
    int c = 0;
    int input;
    bool flag = false;
    for ( int j = 0; j < 10; j++ ) {
      cin >> input;

      if ( input < b && input < c ) flag = true;
      if ( flag ) continue;

      if ( input < b ) {
	c = input;
      }else if ( input < c ) {
	b = input;
      }else {
	if ( b < c ) {
	  c = input;
	}else {
	  b = input;
	}
      }

    }

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

  }

  return 0;

}