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 <stack>
#include <cstdio>
using namespace std;
  int main(){
    int a,b,n,i,j,x[10];
    scanf("%d",&n);
for(j=0;j<n;j++){
    for(i=0;i<10;i++){
       scanf("%d",&x[i]);
}
stack<int> B;
stack<int> C;
B.push(x[0]);
C.push(x[1]);
for(i=1;i<9;i++){
if(B.top()<x[i+1]){
B.push(x[i+1]);
}else if(C.top()<x[i+1]){
	C.push(x[i+1]);
}else{
	printf("NO\n");
	goto aaa;
}
}
printf("YES\n");
aaa:;
}
return 0;
  }

C++: #include <iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	while(N--){
		int pipe[2] = {0};
		int i=0;
		bool f=false;
		for(; i < 10; i++){
			int num;
			cin >> num;
			if(pipe[1] > pipe[0]){
				
				if(num > pipe[1]){
					pipe[1] = num;
				}else if(num > pipe[0]){
					pipe[0] = num;
				}else{
					f=true;
					break;
				}
				
			}else{
				if(num > pipe[0]){
					pipe[0] = num;
				}else if(num>pipe[1]){
					pipe[1] = num;
				}else{
					f=true;
					break;
				}
			}
			
		}
		if(!f) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int t,n,i,j,mmax;
	int a[11];
	cin>>t;
	while(t--) {
		for(i=1;i<=10;i++) cin>>a[i];
		mmax=a[1];
		a[1]=-1;
		for(i=2;i<=10;i++) {
			if(a[i]>mmax) {
				mmax=a[i];
				a[i]=-1;
			}
		}
		mmax=-1;
		for(i=1;i<=10;i++) {
			if(a[i]==-1) continue;
			if(a[i]<mmax) break;
			mmax=a[i];
		}
		if(i==11) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int n; cin>>n;
    while(n--){
        int amin = 0;
        int bmin = 0;
        int tmp;
        bool ans = true;
        for(int i=0;i<10;++i){
            cin>>tmp;
            if(tmp <= amin && tmp <= bmin){
                ans = false;
            }
            if(!ans) continue;
            if(tmp > amin && tmp > bmin){
                if(bmin > amin)
                    bmin = tmp;
                else
                    amin = tmp;
            }else if(tmp > amin)
                amin = tmp;
            else
                bmin = tmp;
        }
        if(ans) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

C++: #include <cstdio>
using namespace std;
int n, arr[15];
bool flag;
void dfs(int x1, int x2, int y1, int y2, int cnt)
{
    if (x2 < x1 || y2 < y1)
        return;
    if (cnt == 10)
    {
        flag = true;
        return;
    }
    dfs(x2, arr[cnt], y1, y2, cnt + 1);
    dfs(x1, x2, y2, arr[cnt], cnt + 1);
}
int main()
{
    scanf("%d", &n);
    while (n--)
    {
        for (int i = 0; i < 10; i++)
            scanf("%d", &arr[i]);
        flag = false;
        dfs(0, 0, 0, 0, 0);
        if (flag)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<bitset>
#include<queue>
#include<string>
#include<vector>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,n,a) for(int i=n;i>a;i--)
#define mem0(x) memset(x,0,sizeof(x))
#define memff(x) memset(x,INF,sizeof(x))
#define INF 100000000
using namespace std;
typedef pair<int,int> p;
typedef long long LL;
int aa[15];
int main()
{
    //freopen("input.in","r",stdin);
    int n;
    bitset<10> dis;
    while(cin>>n)
    {
        for(int i=1;i<=10;i++)
        cin>>aa[i];
        int all=1024;
        while(all>0)
        {
            dis=static_cast<bitset<10> >(all);
            bool flag=true;
            int left=0,right=0;
            for(int i=1;i<=10;i++)
            {
                if(dis[i-1])
                {
                    if(aa[i]>left)
                    {
                         left=aa[i];
                    }
                    else
                    {
                        flag=false;
                        break;
                    }
                }
                else
                {
                    if(aa[i]>right)
                    {
                        right=aa[i];
                    }
                    else
                    {
                        flag=false;
                        break;
                    }
                }
            }
            if(flag)
            {
                break;
            }
            else all--;
        }
        if(all>0)
        cout<<"YES"<<endl;
        else
        cout<<"NO"<<endl;
    }
    return 0;
}

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

int main(){
	int n,ball,tp[2],con,bad;
	
	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;
				cin.ignore(64, "\n");
			}
			
			if(i == 9){
				cout << "YES" << endl;
			}
		}
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

bool ballTest(int *balls, int *b, int numB, int *c, int numC, int num)
{
        if (num <= 0) {
                return true;
        }
        if (balls[0] > b[numB - 1]) {
                b[numB] = balls[0];
                if (ballTest(&balls[1], b, numB + 1, c, numC, num - 1)) {
                        return true;
                }
        }
        if (balls[0] > c[numC - 1]) {
                c[numC] = balls[0];
                if (ballTest(&balls[1], b, numB, c, numC + 1, num - 1)) {
                        return true;
                }
        }
        return false;
}


int main(int argc, char **argv)
{
        int num;

        cin >> num;

        for (int i = 0; i < num; i++) {
                int balls[11];
                int b[10], c[10];
                int numB, numC;

                b[0] = c[0] = 0;
                numB = numC = 1;
                cin >> balls[1] >> balls[2] >> balls[3] >> balls[4] >> balls[5] >> balls[6] >> balls[7] >> balls[8] >> balls[9] >> balls[10];
                if (ballTest(&balls[1], b, 1, c, 1, 10)) {
                        cout << "YES\n";
                } else {
                        cout << "NO\n";
                }
        }
        return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,a[10];
	cin>>n;
	for(int i=0;i<n;i++){
		bool t=true;
		for(int j=0;j<10;j++)
			cin>>a[i];
		int b,c;
		if(a[0]>a[1]){
			b=a[0];
			c=a[1];
		}
		else{
			b=a[1];
			c=a[0];
		}
		for(int j=2;j<10;j++){
			if(c>a[j])
				t=false;
			if(c<a[j]&&b>a[j])
				c=a[j];
			if(b<a[j])
				b=a[j];
		}
		if(t==true)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

	int a, b=0, i, N, x[10], end=0;

	cin >> N;
	for(; N!=0; N--) {
		for(i=0; i<10; i++)
			cin >> x[i];
		for(i=0; i<10; i++) {
			if(i==0) {
				a=x[i];
				i++;
			}
			if(a>x[i]&&b>x[i]) {
				end++;
				break;
			}
			if(a>x[i]) {
				if(b<x[i])
					b=x[i];
			}
			else {
				if(b>x[i])
					a=x[i];
				else
					a>b ? a : b =x[i];
			}
		}

		if (end!=0)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
		end=0;
	}

	return 0;

}