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<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		int a[9]={};
		int b[9]={};
		int dat,o=1,s=1;
		for(int j=0;j<=10;j++){
			if(j==10){
				cout<<"YES"<<endl;
				break;
						}
			cin>>dat;
		 	if(j==0){
				a[0]=dat;
                                s++;
			}
			else if(dat>a[s-1]){
				a[s]=dat;
				s++;
			}
			else if(dat>b[o-1]){
				b[o]=dat;
				o++;}
			else if(dat<a[s-1] && dat<b[o-1]){
				cout<<"NO"<<endl;
			break;
			}
					}
	}
	return 0;
}

C++: #include<stdio.h>
#include<string.h>
int x[15],l[15],r[15];
int kase;
void dfs(int i,int j,int k)//i 是当前下落的球，j是左?的桶的第几个球，k 是右?放入
{
    if(i>10)//如果可以全部下落，肯定?足
    {
        kase=1;
        return;
    }
    if(kase)
    {
        return;
    }
    if(x[i]>l[j-1])//??落在左?
    {
        l[j]=x[i];dfs(i+1,j+1,k);
    }
    if(x[i]>r[k-1])//??落在右?
    {
        r[k]=x[i];dfs(i+1,j,k+1);
    }
}
int main()
{
    int t;
    //freopen("shuju.txt","r",stdin);
    scanf("%d",&t);
    while(t--)
    {
        for(int i=1;i<=10;++i)
        {
            scanf("%d",&x[i]);
        }
        kase=0;
        dfs(1,1,1);
        if(kase)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}

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

using namespace std;

int main (int argc, char const* argv[])
{
	auto ary = vector<int>();
	while(!feof(stdin))
	{
		int n;
		scanf("%d ",&n);
		if(n == 0)
		{
			cout << ary[ary.size()-1] << endl;
			ary.pop_back();
		}
		else
		{
			ary.push_back(n);
		}
	}
	return 0;
}

C++: #include <iostream>
#include <stack>
#include <cstdio>
using namespace std;
stack<int>a;
stack<int>b;
int main()
{
    int n;
    scanf("%d",&n);
   	while(n--)
   	{
   		int x;
   		int flag = 1;
   		for(int i = 0; i < 10; i ++)
   		{
   			scanf("%d",&x);
   			if( a.empty() )
   				a.push(x);
   			else 
   				if(a.top() < x)
	   			{
	   				if( b.empty() )
	   					a.push(x);
	   				else if(b.top() < x)
	   				{
	   					if(a.top() < b.top())
	   						b.push(x);
	   					else a.push(x);
	   				}
	   				else
	   					a.push(x);
	   			}
	   			else
	   			{
	   				if(b.empty() || b.top() < x)
	   					b.push(x);
	   				else
	   					flag = 0;

   			}
   		}

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

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

int BALLNUM = 10;

	static int data[10];
class balldata
{
private:
	//static std::vector <int> data;
	//int ballnum;
public:
	balldata(int datanum);
	static void enter();
	static void answer();
	static bool check();
	static bool check(int num,int right,int left);
};




int main()
{
	balldata ball(BALLNUM);

int N;
	std::cin >> N;
	for (int i = 0; i < N; i++)
	{
		ball.enter();
		ball.answer();
	}
}


balldata::balldata(int datanum)
{
	//ballnum = datanum;
	//data.resize(datanum);
}



void balldata::enter()
{
	for (int i = 0; i < 10; i++)
	{
		std::cin >> data[i];
	}
	return;
}

bool balldata::check(int num,int right,int left)
{
	//if (num == data.size())return true;
	if (num == 10)return true;
	if (balldata::check(num + 1, right, data[num])&&left<data[num]){ return true; }
	if (balldata::check(num + 1, data[num], left)&&right<data[num]){ return true; }

	return false;
}
bool check()
{
	return balldata::check(0, 0, 0);
}

void balldata::answer()
{ 
	if (balldata::check(0, 0, 0))
	{
		std::cout << "YES" << std::endl;
	}
	else
	{
		std::cout << "NO" << std::endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(void)
{
    int bo[11],n,B[11],C[11],b1=0,c1=0,A=0,k=0,l=1;
    cin>>n;
    for(int i=0;i<n;i++){
            C[0]=11;k=0;l=0;B[0]=0;b1=0;c1=0;C[1]=13;
        for(int j=0;j<10;j++){
            cin>>bo[j];
        }
        for(int j=1;;j++){
                cout<<bo[j]<<" ";
            if(j==1)B[0]=bo[0];
        if(C[0]==11&&j==2){
            C[0]=bo[j];
            k++;
            //cout<<"6\n";
        }else if(C[1]==13&&j>3&&C[0]<bo[j]){
            C[1]=bo[j];
            k++;
            c1=1;
           // cout<<"7\n";
        }else if(B[l]<bo[j]){
            b1=1;
            B[l+1]=bo[l];
            l++;
           // cout<<"1\n";
        }else if(C[0]==11){
            C[0]=bo[j];
            k++;
            //cout<<"2\n";
        }else if(C[k-1]<bo[j]){
            c1=1;
            C[k+1]=bo[j];
           // cout<<"3\n";
        }else if(B[l]<bo[j+1]){
            C[k+1]=bo[j];
            k++;
           // cout<<"5\n";
        }else{
            B[l+1]=bo[j];
            l++;
          //  cout<<"4\n";
        }
        if(j==9||(b1==1&&c1==1))break;
    }
    if(b1==1&&c1==1)cout<<"YES\n";
    else cout<<"NO\n";
    for(int j=0;j<10;j++){
        B[j]=0;C[j]=0;
    }

}
}

C++: #include<iostream>
#include<string.h>
using namespace std;
int main(void)
{
  int n;
  cin>>n;
  int num1[10];
  for(int i=0;i<n;i++)
    {
      int count=0;
      for(int j=0;j<10;j++)
	{
	  cin>>num1[j];
	}
      for(int k=0;k<10-1;k++)
	{
	  int num2[10];
	  if(num1[k]>num1[k+1])
	    {
	      int l=0;
	      num2[l]=num1[k];
	      l++;
	    }
	  if(num1[k]>num1[k+1] && num2[k]>num2[k+1] && num2[k+1]!=0)count++;
	}
      if(count>0)cout<<"NO"<<endl;
      else cout<<"YES"<<endl;
    }
  return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int t,flag;
	//freopen("C:\\Users\\国民党\\Desktop\\text.txt", "r", stdin);
	cin >> t;
	while (t--)
	{
		flag = 1;
		int a, b = -1, c = -1;
		for (int i = 1; i <= 10; i++)
		{
			cin >> a;
			if (a > b)
			{
				b = a;
			}
			else if (a > c)
			{
				c = a;
			}
			else
				flag = 0;
		}
		cout << ((flag == 1) ? "YES" : "NO" )<< endl;
	}
	return 0;
}