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 <algorithm>
#include <cstdlib>

int main(){
	unsigned c, tmp, d[2] = {0};
	bool res;

	scanf("%d", &c);

	while(c--){
		res = true;
		d[0] = d[1] = 0;

		for(int i = 0; i < 10; ++i){
			std::cin >> tmp;
		
			if( d[0] < tmp ){
				if(d[1] < tmp){
					*std::max_element(d, d + 1) = tmp;
				}else{
					d[0] = tmp;
				}
			}else if( d[1] < tmp ){
				d[1] = tmp;
			}else{
				res = false;
				break;
			}
		}

		std::cout << (res ? "YES" : "NO") << std::endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n, num, right, left;
  bool flag;

  cin >> n;

  for(int i = 0; i < n; i++){
    right = 0;
    left = 0;
    flag = true;
    for(int j = 0; j < 10; j++){
      cin >> num;

      if(right < num){
        right = num;
      }else if(left < num){
        left = num;
      }else{
        flag = false;
      }

    }

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

  return 0;
}

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

bool ball(vector<int> &a,int b,int c,int n){
    //cout<<n<<" "<<b<<" "<<c<<endl;
    if(n==10){
        return true;
    }
    if(a[n]>b&&n<=9){
        b=a[n];
        return ball(a,b,c,n+1);
    }
    if(a[n]>c&&n<=9){
        c=a[n];
        return ball(a,b,c,n+1);
    }
    return false;
}


int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int tmp;
        vector<int> a;
        int b=0;
        int c=0;
        for(int j=0;j<10;j++){
            cin>>tmp;
            a.push_back(tmp);
        }
        if(ball(a,b,c,0)){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
}

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

int pow(int a,int n){
	if(n <= 0){
		return 1;
	}
	return a * pow(a,n - 1);
}

int main(){
	int n;
	int a[10];
	int ans1 = 0;
	int ans2 = 0;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 10; j++){
			scanf("%d",&a[j]);
		}
		for(int j = 0; j < 10; j++){
			if(ans1 >= ans2 && ans1 < a[j]){
				ans1 = a[j];
			}else if(ans2 > ans1 && ans2 < a[j]){
				ans2 = a[j];
			}else if(ans1 < a[j]){
				ans1 = a[j];
			}else if(ans2 < a[j]){
				ans2 = a[j];
			}else{
				printf("NO\n");
				break;
			}
			printf("%d %d\n",ans1,ans2);
			if(j == 9){
				printf("YES\n");
			}
		}
	}
	///////////////////////////////////
	//Sleep(200000);///////////////////// 提出するときは必ず外す！
	///////////////////////////////////
	return 0;

}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n;
	cin >> n;
	rep(z, n) {
		VI a(11);
		rep(i, 10)cin >> a[i];

		VI b, c;
		bool flag = true;
		rep(i, 10) {
			switch (i){
			case 0:
				b.pb(a[0]);
				c.pb(-1);
				break;
			default:
				bool f1, f2;
				int b1 = b.back(), c1 = c.back();

				if (c1 < a[i])f2 = true;
				else f2 = false;
				if (b1 < a[i])f1 = true;
				else f1 = false;

				if (f1&&f2) {
					if (b1 < c1)c.pb(a[i]);
					else b.pb(a[i]);
				}
				else if (f1 && !f2) {
					b.pb(a[i]);
				}
				else if (!f1&&f2) {
					c.pb(a[i]);
				}
				else {
					flag = false;
				}
				break;
			}
		}

		puts(flag ? "YES" : "NO");
	}
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  cin>>n;
  rep(j,n){
    bool ok=true;
    int a,b=0,c=0;
    rep(i,10){
      cin>>a;
      if(a>b)b=a;
      else if(a>c)c=a;
      else ok=false;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>

#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;

using namespace std;

int balls[10];
int ar[10];

bool solve()
{
	int a(0);
	int b(0);

	REP(i, 10){
		if (ar[i]){
			if (a > balls[i])
				return false;
			a = balls[i];
		}
		else{
			if (b > balls[i])
				return false;
			b = balls[i];
		}
	}
	return true;
}

int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	//fstream fs("input.txt");
	////////////ここから開始///////////
	int n(0);
	cin >> n;
	while (n--){
		bool f = false;
		REP(i, 10){
			cin >> balls[i];
			ar[i] = 0;
		}
		for (int i = 0; i < 1 << 10; ++i){
			REP(j, 10)
				ar[9 - j] = i >> j & 1;

			f |= solve();
		}
		string ans = f ? "YES" : "NO";
		cout << ans << endl;
	}
	
	return 0;
}

C++: /*
Á·Ï°Ìâ£ºBall_AOJ 0033
*/
#include <cstdio>
using namespace std;

int a[15];

bool dfs(int x)
{
	if(x>=8)
		return true;
	if(a[x]<a[x+2])
	{
		return dfs(x+2);
	}
	else
		return false;
	
	
}

int main()
{
	int T;
	scanf("%d", &T);
	while(T--)
	{
		for(int i=0; i<10; i++)
			scanf("%d", &a[i]);
		int f1=dfs(0);
		int f2=dfs(1);
		if(f1&&f2)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}