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;

int main(){
    int n,tmp,a = 0,b = 0;
    bool judge;
    cin >> n;
    while(n--){
        judge = true;
        for(int i=0;i<10;i++){
            cin >> tmp;
            if(tmp > a) a = tmp;
            else if(tmp > b) b = tmp;
            else judge = false;
        }
        if(judge) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

C++: #include <cstdio>

int a[10];

int main(int argc, const char * argv[]) {
    int T;
    scanf("%d", &T);
    while (T--) {
        bool ans = true;
        for (int i = 0; i < 10; i++) {
            scanf("%d", &a[i]);
        }
        int l, r;
        l = r = 0;
        for (int i = 0; i < 10; i++) {
            if (a[i] > l) {
                l = a[i];
            } else if (a[i] > r) {
                r = a[i];
            } else {
                ans = false;
                break;
            }
        }
        printf("%s\n", ans ? "YES" : "NO");
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
#include<cstdio>
#include<string.h>
int a[50][11];
int b[50][11],c[50][11];
//int flag[100][11];
int by = 0,cy = 0;
int lb ;
int lc ;
void dfs(int x,int y){
    if(y<10){
    if(b[x][by]<a[x][y]){
        b[x][++by]=a[x][y++];
        ++lb;
    }
    else if(c[x][cy]<a[x][y]){
        c[x][++cy] = a[x][y++];
        ++lc;
    }
    // y +=1;

    dfs(x,y);}
}
void solve(){
    int n;
cin>>n;
        while(n--){
           
    for(int i = 0; i < n; i++)
            for(int j = 0; j < 10; j++)
                cin>>a[i][j];
     for(int i = 0; i < n; i++){
                dfs(i,0);
                if(lb+lc==10)
            printf("YES\n");
        else
            printf("NO\n");}
    }
}


int main(){
solve();
return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
int N;
int ball[10];
int l[20],r[20];
bool flag;
void DFS(int i,int ll,int rr)//i:当前所放球的序号 ll:左边该第ll位放球 rr:右边该第rr位放球
{
    if(i>=10)
        flag=1;
    if(ball[i]>l[ll-1])
    {
        l[ll]=ball[i];
        DFS(i+1,ll+1,rr);
    }
    if(ball[i]>r[rr-1])
    {
        r[rr]=ball[i];
        DFS(i+1,ll,rr+1);
    }
}
int main()
{
    scanf("%d",&N);
    while(N--)
    {
        memset(l,0,sizeof(l));
        memset(r,0,sizeof(r));
        for(int i=0;i<10;i++)
            scanf("%d",&ball[i]);
        flag=0;
        DFS(0,1,1);
        if(flag)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

C++: #include <stdio.h>

int main()
{
	int N, ball[10], B[10], C[10], b, c, k;

	scanf("%d", &N);

	for (int i = 0; i < 2; i++){
		scanf("%d %d %d %d %d %d %d %d %d %d", &ball[0], &ball[1], &ball[2], &ball[3], &ball[4], &ball[5], &ball[6], &ball[7], &ball[8], &ball[9]);

		b = 0;
		c = 0;
		k = 0;
		for (int j = 0; j < 10; j++){
			if(b < ball[j]) b = ball[j];
			else if(c < ball[j]) c = ball[j];
			else {k = 1; break;}
		}

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

C++: #include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

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

	rep(i,0,n){
		int x=0,y=0;
		bool f = 1;
		rep(j,0,10){
			int b;
			cin >> b;
			if( b - x > 0 && b - x <= b - y )
				x = b;
			else if( b - y > 0 )
				y = b;
			else{
				NO;
				f = 0;
				break;
			}

		}

		if(f)
			YES;
	}
	
	ret 0;
}

C++: #include <iostream>
using namespace std;
int N;
int num[10];
int lnum,rnum;
bool dfs(int n){
	if(n==10) return true;
	if((num[n]<lnum)&&(num[n]<rnum)) return false;
	else{
		if((num[n]>=lnum)&&(num[n]<rnum)){
			lnum=num[n];
			if(dfs(n+1)) return true;
		}
		else if((num[n]>=rnum)&&(num[n]<lnum)){
			rnum=num[n];
			if(dfs(n+1)) return true;
			
		}
		else{
			int temp=lnum;
			lnum=num[n];
			if(dfs(n+1)) return true;
			else{
				lnum=temp;
				rnum=num[n];
				if(dfs(n+1)) return true;
			}
		}
	}
	return false;
}
void solve(){
	cin>>N;
	for(int i=0;i<N;i++)
	{
		rnum=0;
	    for(int j=0;j<10;j++)
	    cin>>num[j];
	    lnum=num[0];
	    if(dfs(1)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}
int main(){
	solve();
	return 0;
}

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

using namespace std;

int N, H[10];

void solve() {
	int big=0, small=0;
	for (int i = 0; i < 10; i++) {
		if (big < small) swap(big, small);
		if (H[i] < small) {
			printf("NO\n");
			goto JUMP;
		}

		if (H[i] > big) big = H[i];
		else if (H[i] > small) small = H[i];

	}
	printf("YES\n");
JUMP:
	;
}

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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main( void )
{
	int N; // f[^ZbgÌÂ
	cin >> N;

	for ( int lpc = 0; lpc < N; lpc++ )
	{
		int a = 0;
		int b = 0;
		int cnt = 0;
		for ( int i = 0; i < 10; i++ )
		{
			int c;
			cin >> c;

			bool ok = false;
			if ( a < c )
			{
				if ( b < c && b > a )
					b = c;
				else
					a = c;
				ok = true;
			}
			else if ( b < c )
			{
				if ( a < c && a > b )
					a = c;
				else
					b = c;
				ok = true;
			}

			if ( ok == false )
			{
				while ( i+1 < 10 )
				{
					cin >> c;
					i++;
				}
				break;
			}

			cnt++;

		}

		cout << cnt << endl;
		if ( cnt == 10 )
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}

	}

	return 0;
}

C++: #include <iostream>
#include <vector>  

using namespace std;

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

	bool flag = true;

	int n;
	cin >> n;
	if (n == 0) return -1;
	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;
}