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>
#include <bitset>
#include <iostream>
using namespace std;

int a[10];

bool solve(){
        int num = 1024;
        while (num-- > 0){
                bitset<10> option(num);
                int left = 0;
                int right = 0;
                bool flag = true;
                for (int i = 0; i < 10; i++){
                        if (option[i]){
                                // right
                                if (right < a[i]){
                                        right = a[i];
                                }else{
                                        flag = false;
                                        break;
                                }
                        }else{
                                // left
                                if (left < a[i]){
                                        left = a[i];
                                }else{
                                        flag = false;
                                        break;
                                }
                        }
                }

                if (flag) break;
        }
        if (num >= 0) return true;
        else return false;
}

int main(){
        int n;
        scanf("%d", &n);
        while (n--){
                for (int i = 0; i < 10; i++){
                        scanf("%d", &a[i]);
                }
                bool ans = solve();
                if (ans) 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<stdio.h>
 #include<string.h>
 int a[13],vis[13],flag;
 void dfs(int x,int l,int r)
 {
     int i;
     if(x==11)return; 
     if(flag)return ;
     if(a[x]>l)dfs(x+1,a[x],r);
     else  if(a[x]>r)dfs(x+1,l,a[x]);
     else  {flag=1;return;}
   
 }
 int main()
 {
 int T,i,j,k;
 scanf("%d",&T);
 while(T--)
 {
 flag=0;
 for(i=1;i<=10;i++)
 scanf("%d",&a[i]);
 memset(vis,0,sizeof(vis));
 dfs(1,0,0);
 if(flag)printf("NO/n");
 else printf("YES/n");
 }
 return 0;
 }

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

int main()
{
  int n;
  int i,A,B,C;
  bool f;
  cin>>n;
  while(n-->0){
    B=C=0;
    f=true;
    for(i=0;i<10;i++){
      cin>>A;
      if(B<A)B=A;
      else if(C<A) C=A;
      else f=false;
    }
    puts(f?"YES":"NO");
  }
}

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

int main(){
    int n;cin>>n;
    string yes="YES",no="NO";
    while(n--){
        vector<int> a(10);
        for(auto &e:a)cin>>e;

        bool ans=false;
        for(int i=0; i<(1<<10); i++){
            bool ok=true;
            int px=-1,py=-1;
            for(int j=0; j<10; j++){
                if(i&(1<<j)){
                    if(px==-1)px=a[j];
                    else
                        if(!(px<a[j])) ok=false;
                        else px=a[j];
                } else {
                    if(py==-1)py=a[j];
                    else
                        if(!(py<a[j])) ok=false;
                        else py=a[j];
                }
            }
            ans|=ok;
        }
        cout<<(ans?yes:no)<<endl;
    }
}

C++: #include<stdio.h>
int main(void)
{
	int n,i,m;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		int a[11];
		for(m=0;m<11;m++)
		a[m]=0;
		for(m=1;m<=10;m++)
		scanf("%d",&a[m]);
		if(a[1]<a[3]&&a[3]<a[5]&&a[5]<a[7]&&a[7]<a[9]){
			if(a[2]<a[4]&&a[4]<a[6]&&a[6]<a[8]&&a[8]<a[10])
			printf("YES\n");
		}
		else
		printf("NO\n");
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
bool separate(int* A, int i, vector<int>& vB, vector<int>& vC)
{
	if (i == 10)
		return true;
	
	if (vB.size() < 5){
		vector<int> vTmpB(vB);
		if (vTmpB.empty() || (!vTmpB.empty() && (vTmpB.back() < A[i]))){
			vTmpB.push_back(A[i]);
			if (separate(A, i + 1, vTmpB, vC))
				return true;
		}
	}

	if (vC.size() < 5){
		vector<int> vTmpC(vC);
		if (vTmpC.empty() || (!vTmpC.empty() && (vTmpC.back() < A[i]))){
			vTmpC.push_back(A[i]);
			if (separate(A, i + 1, vB, vTmpC))
				return true;
		}
	}

	return false;
}
int main()
{
	int n;
	cin >> n;
	int A[10] = {};
	while(n--){
		for (int j = 0; j < 10; ++j)
			cin >> A[j];
		vector<int> vB, vC;
		if (separate(A, 0, vB, vC)) cout << "YES\n";
		else cout << "NO\n";
	}
	return 0;
}

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

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

	for (int i = 0; i++ < n;) {
		int hole[2] = { 0 };
		string judge = "YES";
		for (int j = 0; j < 10; j++) {
			cin >> x;

			if (hole[0] < x) {
				hole[0] = x;
			}else if (hole[1] < x) {
				hole[1] = x;
			} else {
				judge = "NO";
				break;
			}
		}
		cout << judge << endl;
	}
	return 0;
}

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

int main(){
	bool ans;
	int n;
	int a,b,la,lb;
	cin>>n;
	for(int i=0;i<n;i++){
		ans=true;
		cin>>la>>lb;
		for(int j=0;j<4;j++){
			cin>>a>>b;
			if(la>a||lb>b)ans=false;
			la=a;lb=b;
		}
		if(ans==true)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

}

C++: #include<cstdio>

int ball[11], B[11], C[11];
int cnt1, cnt2;
bool flagb, flagc, flag;

void dfs(int cur) {
    if (flag)return;
    if (cur == 10) {
        flagb = 1, flagc = 1;
        if (cnt1 > 1) {
            for (int i = 0; i < cnt1 - 1; i++)
                if (B[i] > B[i + 1]) {
                    flagb = 0;
                    break;
                }
        }
        if (cnt2 > 1) {
            for (int i = 0; i < cnt2 - 1; i++)
                if (C[i] > C[i + 1]) {
                    flagc = 0;
                    break;
                }
        }

        if (flagb && flagc) {
            flag = 1;
            return;
        }
        return;
    }
    B[cnt1++] = ball[cur];
    dfs(cur + 1);
    cnt1--;
    C[cnt2++] = ball[cur];
    dfs(cur + 1);
    cnt2--;
}

void solve() {
    flag = 0;
    dfs(0);
    if (flag)printf("YES\n");
    else printf("NO\n");
}

int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        cnt1 = 0, cnt2 = 0;
        for (int i = 0; i < 10; i++)
            scanf("%d", &ball[i]);
        solve();
    }
    return 0;
}

C++: #include<iostream>
int main() {
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i += 1) {
		int N[10];
		for (int n = 0; n < 10; n += 1) 
			std::cin >> N[i];
		if (N[0] != 1 && N[1] != 1)
			std::cout << "NO" << std::endl;
		else
			std::cout << "YES" << std::endl;
	}
	return 0;
}