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 <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  for (int I = 0; I < N; I++) {
    int b = 0, c = 0;
    for (int i = 0; i < 10; i++) {
      int x;
      cin >> x;
      if (x < b)
        if (x < c) {
          cout << "NO" << endl;
          goto next;
        } else
          c = x;
      else
        b = x;
    }
    cout << "YES" << endl;
next:;
  }
  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; cin >> num;
    int ans = 0;
    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 += INT_MIN;
            else ans++;
        }
        if(ans >= 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

C++: #include<iostream>
#include<cstring>
#include<stack>
using namespace std;
int const MAXN=1e2+9;
int n;
int t1=1;
int t2=1;
int a[MAXN]={0};
int s1[MAXN]={0};
int s2[MAXN]={0};
bool used[MAXN]={false};

bool check(int *s,int t)
{
	for(int i=1;i<t-1;i++)
		if(!(s[i]<s[i+1]))
			return false;
	return true;
}

bool dfs(int i)
{
	if(i==n)
	{
		t2=1;
		for(int i=1;i<=n;i++)
			if(!used[i])
				s2[t2++]=a[i];
		if(check(s1,t1)&&check(s2,t2))
			return true;
		return false;
	}
	if(dfs(i+1))
		return true;
	if(a[i]>=s1[t1-1])
	{
		used[i]=true;
		s1[t1++]=a[i];
		if(dfs(i+1))
			return true;
		used[i]=false;
		t1--;
	}
	return false;
}

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		n=10;
		t1=1;
		t2=1;
		memset(a,0,sizeof(a));
		memset(s1,0,sizeof(s1));
		memset(s2,0,sizeof(s2));
		memset(used,false,sizeof(used));
		for(int i=1;i<=n;i++)
			cin>>a[i];
		s1[t1++]=a[1];
		used[1]=true;
		if(dfs(2))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}
	return 0;
}

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

int a[10],b[10],c[10];

void initial()
{
	for(int i=0;i<10;i++)
	{
	 b[i]=-1;
         c[i]=-1;
	}
}
bool judge()
{
  int p=0,q=0,i;
  initial();
  b[0]=a[0];
  for(i=1;i<10;i++)
  {
	  if(a[i]>b[p])b[++p]=a[i];
	  else if(q==0)c[q++]=a[i];
	  else if(a[i]>c[q-1])c[q++]=a[i];
	  else 
	  {
		  return false;
		  break;
	  }
  }
  if(i==10)
    return true;
}

int main()
{
	int num;
	cin>>num;
	while(num--)
	{
		for(int i=0;i<10;i++)
			cin>>a[i];
		puts(judge()?"YES":"NO");
	}
return 0;
}

C++: import java.util.Scanner;
public class Main{
	public static void main(String[] args)throws Exception{
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();//the number of test case
		for(int i=0;i<n;i++){
			int[] d=new int[10];
			for(int j=0;j<10;j++){
				d[j]=sc.nextInt();
			}
			int a=-999999;int b=-999999;
			//??????a<=b????????????????????????
			outside:for(int j=0;j<10;j++){
				if(d[j]>b)b=d[j];
				else if(d[j]>a)a=d[j];
				else{
					System.out.println("NO");
					break outside;
				}
				if(a>b){
					int dummy=b;
					b=a;
					a=dummy;
				}
				if(j==9)System.out.println("YES");
			}
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

	for( int i = 0; i < n; ++i ) {
		vector<int> a( 10 );
		for( auto& v: a ) { cin >> v; }

		bool result = true;
		int x = 0;
		int y = 0;

		for( int j = 0; j < 10; ++j ) {
			if( a[j] > x ) {
				x = a[j];
			}
			else if( a[j] > y ) {
				y = a[j];
			}
			else {
				result = false;
				break;
			}
		}

		cout << (result ? "YES" : "NO") << '\n';
	}
}

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

using namespace std;


int q;
int Ball[10];
bool flag;
vector<string> log_vec;

bool is_satisfies(vector<int> a) {
    vector<int> copy = a;
    sort(a.begin(), a.end());
    return a == copy;
}

void bfs(int i, vector<int> B, vector<int> C) {
    if (i == 9) {
        if (is_satisfies(B) && is_satisfies(C))
            flag = true;
        else
            flag = flag == true ? true : false;
    } else {
        vector<int> temp;

        temp = B;
        temp.push_back(Ball[i]);
        bfs(i + 1, temp, C);

        temp = C;
        temp.push_back(Ball[i]);
        bfs(i + 1, B, temp);
    }
}

void solve() {
    vector<int> B, C;
    flag = false;

    bfs(0, B, C);

    if (flag)
        log_vec.push_back("YES");
    else
        log_vec.push_back("NO");
}

int main() {
    cin >> q;
    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < 10; ++j)
            scanf("%d", &Ball[j]);

        solve();
    }

    for (int i = 0; i < log_vec.size(); ++i) {
        cout << log_vec[i] << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
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>

using namespace std;


int main(){

	int n, A, B, C;
	bool ans;

	cin >> n;

	while (n--){
		ans = 1;
		B = 0;
		C = 0;

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

			if (A > B){
				B = A;
			}
			else if(A > C){
				C = A;
			}
			else{
				ans = 0;
				break;
			}
		}

		cout << (ans ? "YES" : "NO") << endl;

	}


	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  int ball[100][10],count=0;
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin >> ball[i][j];
    }
    for(int j=0;j<6;j++){
      if(ball[i][j] > ball[i][j+2] || ball[i][j+1] > ball[i][j+3]){
	cout << "NO" << endl;
	  count++;
	  break;
      }
    }
    if(count == 0){
      cout << "YES" << endl;
    }
    count=0;
  }
}

C++: #include<iostream>
int box[10];
int ltop=-1,rtop=-1;
bool ball(int i){
	if(i==9)return true; 
	if(ltop==-1 || rtop==-1){
		if(ltop==-1){
			ltop=box[i];
			return ball(i+1);
		}
		else{
		    rtop=box[i];
			return ball(i+1);	
		}
	}
	else{
		if(box[i]>ltop&&box[i]>rtop){
			if(ltop>rtop){
				ltop=box[i];
			}
			else{
				rtop=box[i];
			}
			return ball(i+1);
		}
		else if(box[i]>ltop){
			ltop=box[i];
			return ball(i+1);
		}
		else if(box[i]>rtop){
			rtop=box[i];
			return ball(i+1);
		}
		else return false;
	}
}
int main(){
	int n;
	std::cin>>n;
	for(int what=0;what<n;++what){
		for(int i=0;i<10;++i){
			std::cin>>box[i];
		}
		if(ball(0))std::cout<<"YES\n";
		else std::cout<<"NO\n";
	}
}