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;
const int kBalln = 10;
int main(){
  int n;
  int ball;
  int b, c;
  bool ans;
  cin >> n;
  for (int j = 0; j < n; ++j)
    {
      b = 0; c = 0;ans = true;
      for (int i = 0; i < kBalln; ++i)
        {
          cin >> ball;
          if (b < ball)
            {
              b = ball;
            }
          else if (c < ball)
            {
              c = ball;
            }
          else
            {
              ans = false;
              // cout << "NO" << endl;
              break;
            }
        }
      cout << (ans ? "YES" : "NO") << endl;
    }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n;
  bool success;

  cin >> n;
  while(n--){
    success = false;
    int b = 0, c = 0;
    int a[10];
    for(int i=0; i<10; i++){
      cin >> a[i];
    }

    for(int i=0; i<10; i++){ 
      if(b < a[i] && c < a[i]){
        if(b < c)
          c = a[i];
        else
          b = a[i];
      }
      else if(b < a[i]){
          b = a[i];
      }
      else if(c < a[i]){
          c = a[i];
      }
      else{
        success = false;
        break;
      }

      if(i == 9)
        success = true;
    }

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

C++: #include<cstdio>  
int n,l1,l2,a[15];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
	    bool f=0;l1=-1;l2=0;
		for(int j=1;j<=10;j++)
			scanf("%d",&a[j]);
		for(int j=1;j<=10;j++)
		if(!f)
		{
			if(a[j]<l1&&a[j]<l2){f=1;printf("No\n");break;}
			if(l1>l2){if(a[j]>l1)l1=a[j];else l2=a[j];} 
			else{if(a[j]>l2)l2=a[j];else l1=a[j];}
		}
		if(!f)printf("YES\n");a
	}
}

C++: #include<stdio.h>
#include<string.h>
int l[15],r[15],q[15];
bool yon;
void dfs(int i,int j,int k){
	if(i == 10){
		yon = true;
		return ;
	}
	if(yon){
		return ;
	} 
	if(q[i] > l[j-1]){
		l[j] = q[i];
		dfs(i+1,j+1,k);
	}
	if(q[i] > r[k-1]){
		r[k] = q[i];
		dfs(i+1,j,k+1);
	}
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--){
		for(int i=1;i<=10;i++){
			scanf("%d",&q[i]);
		}
		yon = false;
		dfs(1,1,1);
		if(yon){
			printf("YES\n");
		}else{
			printf("NO\n"); 
		}
	}
	return 0;
}

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


int main()
{
	int n;
	cin >> n;
	int a[11];
	while (n--)
	{
		bool flag = true;
		int min_a = 0, min_b = 0;
		for (int i = 0; i < 10; i++)
			cin >> a[i];
		for (int j = 0; j < 10; j++)
		{
			if (a[j] > min_a)
			{
				if (min_a >= min_b)
				{
					min_a = a[j];
				}
				else
				{
					min_b = a[j];
				}
				continue;
			}
			else if (a[j] > min_b)
			{
				min_b = a[j];
			}
			else
			{
				flag = false;
				break;
			}
		}
		if (flag==true)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
    return 0;
}

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

C++: #include<iostream>
using namespace std;
int main(){
	int row[2],order[10],memo[10][2],n;
	cin >>n;
	for(int i=0; i<n; i++){
		for(int l=0; l<10; l++){
			cin >>order[l];
		}
		row[0] = order[0];
		row[1] = 0;
		int x = 0,l;
		for(l=1; l<10; l++){
			if(row[0]<order[l] && row[1]>order[l]){row[0] = order[l];}
			else if(row[0]>order[l] && row[1]<order[l]){row[1] = order[l];}
			else if(row[0]<order[l] && row[1]<order[l]){
				memo[x][0] = row[0];
				memo[x][1] = l;
				row[0] = order[l];
				x++;
			}
			else if(row[0]>order[l] && row[1]>order[l]){
				if(x == 0){cout <<"NO"<<endl;break;}
				else{
					x--;
					row[0] = memo[x][2];
					l = memo[x][1];
					row[1] = order[l];
				}
			}
		}
		if(l == 10){cout <<"YES"<<endl;}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
int ball[10];
int left = 0,right = 0;
bool dfs(int de,int left, int right){//??????????????§???????????????
	if(de == 9)return true;
	if(left < ball[de]){
		left = ball[de];
		return dfs(de + 1,left,right);
	}
	if(right < ball[de]){
		right = ball[de];
		return dfs(de + 1,left,right);
	}
	return false;
}

int main(){
	int n;
	std::cin >> n;
	while(n--){
		for(int i = 0; i < 10; ++i){
			std::cin >> ball[i];
		}
		left = 0, right = 0;
		if(dfs(0,0,0))std::cout << "YES" << std::endl;
		else std::cout << "NO" << std::endl;
	}
}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
int N, acnt, bcnt;
int x[10], A[10], B[10];

bool dfs(int cnt) {
    if (cnt == 10) return true;
    // Aに入れる
    if (A[acnt] < x[cnt]) {
        A[++acnt] = x[cnt];
        return dfs(cnt+1);
    }
    // Bに入れる
    else if (B[bcnt] < x[cnt]) {
        B[++bcnt] = x[cnt];
        return dfs(cnt+1);
    }
    return false;
}

int main(void) {
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            A[j] = 0; B[j] = 0;
        }
        acnt = 0; bcnt = 0;
        for (int j = 0; j < 10; j++) cin >> x[j];
        if (dfs(0)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

C++: #include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
int num[10];
int left=-100000000000,right=-100000000000;
int dfs(int m){
	if(m==10)
	return 1;
	if(num[m]>=left){
		int nleft=left;
		left=num[m];
		if(dfs(m+1))
		return 1;
		left=nleft;
	}
	if(num[m]>=right){
		int nright=right;
		right=num[m];
		if(dfs(m+1))
		return 1;
		right=nright;
	}
	return 0;
}
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		for(int i=0;i<10;i++){
			scanf("%d",&num[i]);
		}
		if(dfs(0))
		printf("YES\n");
		else
		printf("NO\n");
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int k=0; k<n; k++) {
        int a[10];
        for(int i=0; i<10; i++) cin >> a[i];
        int b=-1, c=-1;
        bool f = 0;
        for(int i=0; i<10; i++) {
            if(b<a[i]) {
                b = a[i];
            } else if(c<a[i]) {
                c = a[i];
            } else {
                f = 1;
                break;
            }
        }
        printf("%s\n", f ? "NO" : "YES");
    }

    return 0;
}