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<cstdio>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<string>
#include<cstring>
#include<math.h>
#include<algorithm>
#include<map>

#include<sstream>
#include<ctype.h>

#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
 
typedef long long ll;
using namespace std;
 
const int INF = 0x7f7f7f7f;
const double PI = acos(-1.0);
const int maxn = 1005;
const int MOD = (int)1e9+7;
#define LOCAL 0
#define MOD 1000000007

int a[15],l[15],r[15];
bool res;

bool dfs(int apos,int lpos,int rpos){
	
	if(apos == 11)	return true;
	if(a[apos] > l[lpos-1]){
		l[lpos] = a[apos];
		if(dfs(apos+1,lpos+1,rpos)) return true;
	} 
	if(a[apos] > r[rpos-1]){
		r[rpos] = a[apos];
		if(dfs(apos+1,lpos,rpos+1)) return true;
	} 
	return false;
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		memset(a,0,sizeof(a));
		memset(l,0,sizeof(l));
		memset(r,0,sizeof(r));
		for(int i = 1 ; i <= 10 ; i ++) 	scanf("%d",&a[i]);		
		if(dfs(1,1,1)){
			cout << "YES" << endl;	
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main(){
    int n; cin >> n;
    while(n--){
        vector<int> v(10);
        for(int i=0; i< 10; i++) cin >> v[i];
        int a=0, b=0;
        bool is = true;
        for(int i=0; i< 10; i++){
            if(v[i] < a && v[i] < b){is = false; break;}
            if(a < b) (b<v[i]?b:a) = v[i];
            else (a<v[i]?a:b) = v[i];
        }
        cout << (is?"YES":"NO") << endl;
    }
}

C++: #include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define INF 100000



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

C++: #include <iostream>

using namespace std;

int main(){
  int n;
  bool dropped[10];

  for(int i=0; i<10; i++)
    dropped[i] = false;

  cin >> n;
  while(n--){
    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]){
        if(a[i] != b + 1){
          cout << "NO" << endl;
          break;
        }
        else
          b = a[i];
      }
      else if(c < a[i]){
        if(a[i] != c + 1){
          cout << "NO" << endl;
          break;
        }
        else
          c = a[i];
      }

      if(i == 9)
        cout << "YES" << endl;
    }
  }
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int n;
const int m = 10;
int *data;
int *lp;
int *rp;

//return...fail:0, success:1
bool dfs(int i, int l, int r)
{
	if (i == m)
		return true;

	if (i<m && l<m && lp[l-1]<data[i]) {
		lp[l] = data[i];
		if (dfs(i+1, l+1, r))
			return true;
	}

	if (i<m && r<m && rp[l-1]<data[i]) {
		rp[r] = data[i];
		if (dfs(i+1, l, r+1))
			return true;
	}

	return false;
}

int main()
{
	int i, j;
	data = (int *)calloc(m, sizeof(int));
	lp = (int *)calloc(m, sizeof(int));
	rp = (int *)calloc(m, sizeof(int));
	memset(lp, 0, sizeof(int));
	memset(rp, 0, sizeof(int));
	
	scanf("%d ", &n);
	for (i=0; i<n; i++) {
		for (j=0; j<m; j++)
			scanf("%d ", &(data[j]));

	lp[0] = data[0];
	if (dfs(1, 1, 0))
		puts("YES");
	else
		puts("NO");

/*
		//check input
		for (j=0; j<m; j++)
			printf("%d ", data[j]);
		puts("");
*/
	}

	free(data);
	free(lp);
	free(rp);
	return 0;
}

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

int main(){
  int n,date;
  int sta[2];
  cin >> n;

  while(n--){
    bool f = true;
    sta[0] = 0;
    sta[1] = 0;
    for(int i = 0;i < 10 ; i++){
      cin >> date;

      if(date > sta[0])sta[0] = date;
      else if(date > sta[1])sta[1] = date;
      else f = false;

    }
    if(f)puts("YES");
    else puts("NO");


  }
  return 0;
}

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

int main(){
	stack<int> b,c;
	int n;
	cin>>n;

	for(int i=0;i<n;i++){
		bool flag=true;
		b.push(0);c.push(0);
		for(int j=0;j<10;j++){
			int t;
			cin>>t;
			if(b.top()<t && c.top()<t){
				if(b.top()>c.top()) b.push(t);
				else c.push(t);
			}
			else if(b.top()<t){
				b.push(t);
			}
			else if(c.top()<t){
				c.push(t);
			}
			else {
				flag=false;
				break;
			}
		}
		cout<<(flag?"YES":"NO")<<endl;

		while(!b.empty()) b.pop();
		while(!c.empty()) c.pop();
	}
	return 0;
}

C++: #include<stdio.h>
#include<string.h>

int main(){
	int ball[10];
	int cell[2][10]={0};
	int n,i,k,cell_1=1,cell_2=1,flag[1000]={0};
	
	scanf("%d",&n);
	
	for(k=0;k<n;k++){
		for(i=0;i<10;i++)scanf("%d",&ball[i]);
		
		cell[0][0]=0;
		cell[1][0]=0;

		for(i=0;i<10;i++){
			if(cell[0][cell_1-1] < ball[i]){
				cell[0][cell_1]=ball[i];
				cell_1++;
			}
			else if(cell[1][cell_2-1] < ball[i]){
				cell[1][cell_2]=ball[i];
				cell_2++;
			}
			else flag[k]=1;
		}	
	}
	
	cell_1=1;
	cell_2=1;
	
	for(i=0;i<n;i++){
		if(flag[i]==0)printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

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

int main() {
	int n, x, z;
	cin >> n;

	for (int i = 0; i < n; i++) {
		vector< vector<int> > v;
		v.assign(3, { 0 });
		z = 1;
		for (int j = 0; j < 10; j++) {
			cin >> x;
			for (int k = 0; k < z; k++) {
				if (v[k].back() < x) {
					v[k].push_back(x);
					break;
				}

				if (k == z - 1) {
					v[z].push_back(x);
					z++;
					break;
				}
			}

			if (z == 3) {
				x = -1;
				break;
			}
		}

		if (x == -1) {
			cout << "NO";
		}
		else {
			cout << "YES";
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>

int main(){
  int n;
  std::cin >> n;
  while(n--){
    int b = 0;
    int c = 0;
    for(int i=0; i<10; i++){
      int t;
      std::cin >> t;
      if(b < t){
        if(c < t)
          if(b < c) c = t;
          else      b = t;
        else  b = t;
      }
      else if(c < t)  c = t;
      else{
        std::cout << "NO" << std::endl;
        break;
      }
      if(i == 9)  std::cout  << "YES" << std::endl;
    }
  }
}

C++: #include<stdio.h>
#include<malloc.h>

bool decide(int *b){
	for(int i = 0; i < 8; i++)
		for(int j = i+1; j < 9; j++)
			for(int k = j + 1; k < 10; k++)
				if(b[i] > b[j] && b[j] > b[k])return false;
	return true;
}

int main(){
	int N;
	scanf("%d",&N);
	int (*a)[10];
	a = (int (*)[10])malloc(N*10*sizeof(int));
	for(int i = 0; i < N; i++)
		for(int j = 0; j < 10; j++)
			scanf("%d",&a[i][j]);

	for(int k = 0; k < N; k++){
		int *b = a[k];
		if(decide(b) == false)printf("NO\n");
		else printf("YES\n");
		}

	return 0;
}