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<iostream>
#include<cstdio>
#include<fstream>
#include<queue>
#include<vector>
#include<cstring>
#define MAX 20
#define INF 10000000

using namespace std;



int main(){
	int A[MAX];
	int B = 0;
	int C = 0;
	int n;
	cin >> n;
	while(n--){
		int i;
		B = 0;
		C = 0;
		for(i=0; i<10; i++)
			cin >> A[i];
		for(i=0; i<10; i++){
			if(A[i] > B){
				B = A[i];
				continue;
			}
			if(A[i] > C){
				C = A[i];
				continue;
			}
			else{
				cout << "NO" << endl;
				break;
			}
		}
		if(i == 10)
			cout << "YES" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <climits>
using namespace std;
int b = INT_MIN, c = INT_MIN;
bool push(int ball) {
    if(ball > b) b = ball;
    else if (ball > c) c = ball;
    else return(false);
    return(true);
}

int main(void) {
    int num, ans = 0; cin >> num;
    for(int r = 0; r < num; r++) {
        for(int c = 0; c < 10; c++) {
            int input; cin >> input;
            bool result = push(input);
            if(!result) ans -= 100;
        }
        if(ans == 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return(0);
}

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

int main()
{
    int balls[10];
    int out[2][10];
    int outCount[2]={0};
    int num;
    cin>>num;
    while(num!=0){
        bool flag=false;
        int a[10]={0};
        for(int i=0;i<10;i++){
            cin>>balls[i];
        }
        for(a[0]=0;a[0]<2;a[0]++){
            for(a[1]=0;a[1]<2;a[1]++){
                for(a[2]=0;a[2]<2;a[2]++){
                    for(a[3]=0;a[3]<2;a[3]++){
                        for(a[4]=0;a[4]<2;a[4]++){
                            for(a[5]=0;a[5]<2;a[5]++){
                                for(a[6]=0;a[6]<2;a[6]++){
                                    for(a[7]=0;a[7]<2;a[7]++){
                                        for(a[8]=0;a[8]<2;a[8]++){
                                            for(a[9]=0;a[9]<2;a[9]++){
                                                for(int i=0;i<10;i++){
                                                    out[a[i]][outCount[a[i]]]=balls[i];
                                                    if(out[a[i]][outCount[a[i]]-1]>balls[i]&&outCount[a[i]]!=0){
                                                        break;
                                                    }
                                                    if(i==9){
                                                        flag=true;
                                                    }
                                                    outCount[a[i]]++;
                                                }
                                                for(int i=0;i<10;i++){
                                                    out[0][i]=0;
                                                    out[1][i]=0;
                                                }
                                                outCount[0]=0;
                                                outCount[1]=0;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if(flag){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
        num--;
    }
    return 0;
}

C++: #include<iostream>
#include<string.h>
using namespace std;
int a[15],dp[15];
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		memset(dp,0,sizeof(dp));
		for(int i=1;i<=10;i++)
		 cin>>a[i];
		int ans=0;
		for(int i=10;i>=1;i--)
		{
			dp[i]++;
		 for(int j=i+1;j<=10;j++)
		  {
		  	if(a[i]>a[j])
		  	 dp[i]=max(dp[i],dp[j]+1);
		  	
		  }
		  ans=max(ans,dp[i]);
	}
		  if(ans>2)
		  cout<<"NO"<<endl;
		  else
		  cout<<"YES"<<endl;
	}
}

C++: #include <iostream>

using namespace std;

int N;
int tama[11];

bool dfs(int n){
	if(tama[n+2]<=tama[n])	return false;
	if(n==6||n==7)	return true;
	dfs(n+2);
}

int main(){
	cin >> N;
	while(N--){
		for(int i=0;i<10;i++)
			cin >> tama[i];
		if(dfs(0)&&dfs(1))	cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

C++: #include<stdio.h>

int main(){

int n[11]={};
int m[11]={},p[11]={};
int N;
int P=0,M=0;
bool f=true;


scanf("%d",&N);
for(int j=0;j<N;j++)
{
for(int i=0;i<10;i++)
scanf("%d",&n[i]);

for(int i=0;i<10;i++){

	if(M==0){m[M]=n[i];M++;}
	else if(m[M-1]<n[i]&&M>0){M++;m[M]=n[i];}

	else if(P==0){p[P]=n[i];P++;}
	else if(p[P-1]<n[i]&&P>0){P++;p[P]=n[i];}
	
	
else f=false;
}


if(f==true)printf("YES\n");
else if(f==false)printf("NO\n");
for(int i=0;i<10;i++)
	printf("%d %d\n",m[i],p[i]);

//for(int i=0;i<10;i++)
//{p[i]=0;m[i]=0;}

bool f=true;
P=0,M=0;


}
return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int ball[10];
int serch(int now,int B,int C)
{
    if(now==10)return 1;
    if(B<ball[now])return serch(now+1,ball[now],C);
    if(C<ball[now])return serch(now+1,B,ball[now]);
    return 0;
}
int main()
{
    int n,ans;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++)cin>>ball[j];
        ans=serch(0,0,0);
        if(ans==1)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }

}

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

using namespace std;

int balls[10];

int solve(int n, int a, int b) {
	if (n == 10) return 1;
	if (balls[n] < a && balls[n] < b) {
		return -1;
	}
	if (balls[n] < a) {
		return solve(n+1, a, balls[n]);
	}
	if (balls[n] < b) {
		return solve(n+1, balls[n], b);
	}
	int x = solve(n+1, balls[n], b),
		y = solve(n+1, a, balls[n]);
	if (x == -1 && y == -1) return -1;
	return 1;
}
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 10; ++j)
			cin >> balls[j];
		if (solve(0, 0, 0) == -1) cout << "NO" << endl;
		else cout << "YES" << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <stack>
#include <sstream>
using namespace std;
int main(){
  int nlist[10],n,a;
  stack<int> b,c;
  b.push(0),c.push(0);
  bool f;//a=ôÌ®,b=ïÌ®
  cin>>n;
  for(;n;n--){
    f=true;
    for(int i=0;i<10;i++)
      cin>>nlist[i];
    for(int j=0;j<10;j++){
      a=nlist[j];
      if(!a)b.push(a);
      else{
	if(b.top()>a){
	  if(c.top()>a){f=false;break;}
	  else{c.push(a);}
	}
	else{b.push(a);}
      }
    }
    (f)?cout<<"YES"<<endl:cout<<"NO"<<endl;
  }
  return 0;
}

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

int main(){
	int n, ball;cin >> n;
	stack<int> r, l;
	while(n--){
		r.push(0);l.push(0);
		bool f = false;
		
		for(int i = 0;i < 10;i++){
			cin >> ball;
			if(f)continue;
			if(r.top() < ball)r.push(ball);
			else if(l.top() < ball)l.push(ball);
			else f = true;
		}
		
		while(!r.empty())r.pop();
		while(!l.empty())l.pop();
		if(!f)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}