Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var num int
	fmt.Scan(&num)

	for i := 0; i < num; i++ {
		sc.Scan()
		line := sc.Text()

		insertCheck(line)
	}
}

func insertCheck(line string) {
	var B, C []int

	for _, v := range strings.Split(line, " ") {
		ball, _ := strconv.Atoi(v)
		switch {
		case len(B) == 0:
			B = append(B, ball)
		case B[len(B)-1] < ball:
			B = append(B, ball)
		case B[len(B)-1] >= ball:
			switch {
			case len(C) == 0:
				C = append(C, ball)
			case C[len(C)-1] < ball:
				C = append(C, ball)
			case C[len(C)-1] >= ball:
				fmt.Println("NO")
				return
			}
		}
	}
	fmt.Println("YES")
}

C++: #include <cstdio>

int a[10];


int main() {
  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 1;
}

C++: #include <iostream>
#include <string.h>
#include <fstream>
#include<time.h>
#include <string>
#include <string.h>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <stack>
#include <map>
#include <queue>
#include<cctype>
#include <math.h>
#include <algorithm>
#define Size 1000
using namespace std;
int number[10];
int lef[10];
bool dfs(int num){
    if(num == 10){
        int lnum = 0, rnum = 0;
        for(int i = 0; i < 10; i ++){
            if((lef[i] == 1 && lnum > number[i])
               ||(lef[i] == 0 && rnum > number[i]))
               return false;
            else if(lef[i] == 1)
                lnum = number[i];
            else
                rnum = number[i];
        }
        return true;
    }
    lef[num] = 1;
    bool left = dfs(num + 1);
    lef[num] = 0;
    bool right = dfs(num + 1);
    return left || right;
}
int main()
{
    //ifstream in;
    //in.open("a.txt", ios::in);
    int n;
    cin>>n;
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < 10; j ++){
            cin>>number[j];
        }
        if(dfs(0))
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
using namespace std;

int a[15];
int b[15],c[15];
int flag;
void dfs(int x)
{
    if(x<10)
    {
    	int e,i;
	if(b[0]>c[0])
	{
		e=b[0];
		b[0]=c[0];
		c[0]=e;
	}
	if(a[x]>c[0])
	c[0]=a[x];
	else if(a[x]>b[0])
	b[0]=a[x]; 
	else 
	{
		flag=1;
	 } 
	dfs(x+1);
	}
}
int main()
{
	int n,i,j;
	scanf("%d",&n);
	memset(b,0,sizeof(b));
	memset(c,0,sizeof(c));
	while(n--)
	{
		flag=0;
		for(i=0;i<10;i++)
		{
			scanf("%d",&a[i]);
		}
		dfs(0);
		if(flag) printf("NO\n");
		else printf("YES\n");
	}
}

C++: #include <iostream>

using namespace std;

int main(void){
    int a[11],fir,sec=0,i,n;
    cin>>n;
    while (1) {
    
    for (i=0; i<10; i++) {
        cin>>a[i];
    }
    fir=a[0];
    for (i=1; i<10; i++) {
        if(fir<a[i])fir=a[i];
        else if(sec<a[i])sec=a[i];
        else break;
    }
    if(i==10)puts("YES");
    else puts("NO");
        n--;
        if(n==0)break;
        
    }
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
int Check(int*);
int main(){
	int Count,KAZU,Ball[10];
	int Bzone[10],Czone[10];
	int *Result;
	for(Count=0;Count<10;Count++){
		Bzone[Count]=20*(Count+1);
		Czone[Count]=20*(Count+1);
	}

	scanf("%d",&KAZU);
	Result= (int*)malloc(KAZU);
	for(Count=0;Count<KAZU;Count++){
		int Count2,Count3;
		int YorN=0;
		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]);

		for(Count2=0;Count2<1024;Count2++){
			int B=0,C=0;
			int V;
			for(V=0;V<10;V++){
				Bzone[V]=20*(V+1);
				Czone[V]=20*(V+1);
			}
			for(Count3=0;Count3<10;Count3++){
				if(0!=(((int)pow(2.0,Count3))&Count2)){//真ならCにいれる
					Czone[C]=Ball[Count3];
					C++;
				}
				else {
					Bzone[B]=Ball[Count3];
					B++;
				}
			}
			//振り分け完了
			if(Check(Bzone)==1&&Check(Czone)==1){
				YorN=1;
				break;
			}
		}
		*(Result+Count)=YorN;
	}
	for(Count=0;Count<KAZU;Count++){
		if(*(Result+Count)==1){
			printf("YES\n");
		}
		else printf("NO\n");
	}

	for(Count=0;Count<10;Count++){
		Bzone[Count]=20*(Count+1);
		Czone[Count]=20*(Count+1);
	}
	printf("%d",Check(Bzone));
	return 0;
}


int Check(int *BALL){
	int Count,Check=1;
	for(Count=0;Count<9;Count++){
		if(BALL[Count]>=BALL[Count+1]){
			Check=0;
		}
	}
	return Check;
}

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

using namespace std;

int main(){

	int n;
	cin>>n;

	for(int i = 0; i < n; i++){
		int B=0,C=0;
		bool f=false;
		vector<int> numList;
		for(int j = 0; j < 10; j++){
			int t;
			cin>>t;
			numList.push_back(t);
		}

		for(int j = 0; j < 10; j++){
			int num=numList[j];
			if(num>B&&num>C){
				if(num-B>num-C){
					C=num;
				}
				else
					B=num;
			}
			else if(num>B){
				B=num;
			}
			else if(num>C)
				C=num;
			else{
				f=true;
				cout<<"NO"<<endl;
				break;
			}
		}
		if(!f)
			cout<<"YES"<<endl;
	}

	return 0;
}

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

int main(){
	int n, i, max;
	int a[10];
	int b, c;
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8] >> a[9]){
		b = 0;
		c = 0;
		for(i = 0; i < 10; i++){
			if(b > c){
				if (a[i] > b) {
					b = a[i];
				}else if(a[i] > c){
					c = a[i];
				}else{
					break;
				}
			}else{
				if(a[i] > c){
					c = a[i];
				}else if (a[i] > b) {
					b = a[i];
				}else{
					break;
				}
			}
		}

		if(i < 10){
			cout << "NO" << endl;
		}else{
			cout << "YES" << endl;
		}
	}
	return 0;
}

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

int N;
int ball[MAX_N];

int used[MAX_N];

bool dfs(int max_l, int max_r, int next) {
    if (next == MAX_N) return true;
    if(ball[next] > max_l)
        return dfs(ball[next],max_r,next+1);
    if(ball[next] > max_r) 
        return dfs(max_l,ball[next],next+1);
    return false;
}

string solve() {
   memset(used,0,sizeof(used));
   return dfs(0,0,0) ? "YES" : "NO";
}

main() {
    cin>>N;
    for(int i=0;i<N;i++) {
        for(int j=0;j<MAX_N;j++) {
            cin>>ball[j];
        }
        cout << solve() << endl;
    }
}

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

int main(void){

    vector<int> input(10,0);
    
    int times;
    cin >> times;

    while(times > 0){

        for(int i = 0;i < 10;i++){
            cin >> input[i];
        }
        vector<int> a(10,0);
        vector<int> b(10,0);
        a[0] = input[0];
        int j = 1,k = 0,flag = 1;
                
        for(int i = 1;i < 10;i++){

            if(a[j-1] < input[i] && b[k] < input[i]){
                a[j++] = input[i];
            }else if(b[k] < input[i]){
                b[k] = input[i];
            }else{
                flag = 0;
                break;
            }
        }

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




    return 0;
}

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

int main() {
	int n1=0,n2=0,flg=1,temp,num;
	cin>>num;
	while(num--){
		for(int i=0;i<10;i++){
			cin>>temp;
			if(temp>n1) n1=temp;
			else if(temp>n2) n2=temp;
			else flg=0;
		}
		if(flg==1) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}	return 0;
}